rk312x: usb-uart: support disable usb-uart bypass in DTS
authorlyz <lyz@rock-chips.com>
Fri, 22 Aug 2014 03:57:21 +0000 (11:57 +0800)
committerlyz <lyz@rock-chips.com>
Mon, 25 Aug 2014 08:46:44 +0000 (16:46 +0800)
arch/arm/boot/dts/rk3036-sdk.dts
arch/arm/boot/dts/rk3126-sdk.dts
arch/arm/boot/dts/rk3128-box.dts
arch/arm/boot/dts/rk3128-sdk.dts
drivers/usb/dwc_otg_310/usbdev_rk3036.c
drivers/usb/dwc_otg_310/usbdev_rk3126.c

index 3d5788c90a8beb196b7dee85935eacf66f280512..a7db2827173d73f46efd925c96583a60344a5ead 100644 (file)
 //      power-gpio = <&gpio0 GPIO_A6 GPIO_ACTIVE_HIGH>;
         reset-gpio = <&gpio2 GPIO_C6 GPIO_ACTIVE_LOW>;
 };
+
+&dwc_control_usb {
+       usb_uart {
+               status = "disabled";
+       };
+};
index 52b69333bfb076c0c65623ab7a18b7b651292f95..a4875b0732c69216391eb9776132f03a17d22fb1 100755 (executable)
@@ -83,3 +83,8 @@
         hp_ctl_io = <&gpio1 GPIO_A0 0>;
 };
 
+&dwc_control_usb {
+       usb_uart {
+               status = "disabled";
+       };
+};
index d4561c24781355133c75bbca7b68f88097ae293d..225c5f4815c35a3fde5f93e8134b8cdd0803b009 100755 (executable)
 &codec {
        hp_ctl_io = <&gpio1 GPIO_A3 0>;
 };
+
+&dwc_control_usb {
+       usb_uart {
+               status = "disabled";
+       };
+};
index dc5dd1f9285bfa36f89817189c8dc60588cb861c..71f575ddf852e387fcacbb6412e6845e9ff2e99d 100755 (executable)
@@ -62,3 +62,9 @@
                        gpio-key,wakeup;
                };
 };
+
+&dwc_control_usb {
+       usb_uart {
+               status = "ok";
+       };
+};
index b8fe46c40ce6d2b3d89df1035f2ec32014d49834..6f2e197cf8a4f420b18650556fde284542029606 100755 (executable)
@@ -141,20 +141,42 @@ static int usb20otg_get_status(int id)
        return ret;
 }
 
+#ifdef CONFIG_RK_USB_UART
+/**
+ *  dwc_otg_uart_enabled - check if a usb-uart bypass func is enabled in DT
+ *
+ *  Returns true if the status property of node "usb_uart" is set to "okay"
+ *  or "ok", if this property is absent it will use the default status "ok"
+ *  0 otherwise
+ */
+static bool dwc_otg_uart_enabled(void)
+{
+       struct device_node *np;
+
+       np = of_find_node_by_name(NULL, "usb_uart");
+       if (np && of_device_is_available(np))
+               return true;
+
+       return false;
+}
+
 static void dwc_otg_uart_mode(void *pdata, int enter_usb_uart_mode)
 {
-#ifdef CONFIG_RK_USB_UART
-       if (1 == enter_usb_uart_mode) {
+       if ((1 == enter_usb_uart_mode) && dwc_otg_uart_enabled()) {
                /* bypass dm, enter uart mode */
-               writel(UOC_HIWORD_UPDATE(0x3, 0x3, 12),
-                      RK_GRF_VIRT + RK3036_GRF_UOC1_CON4);
+               writel(UOC_HIWORD_UPDATE(0x3, 0x3, 12), RK_GRF_VIRT + 
+                          RK3036_GRF_UOC1_CON4);
        } else if (0 == enter_usb_uart_mode) {
                /* enter usb mode */
-               writel(UOC_HIWORD_UPDATE(0x0, 0x3, 12),
-                      RK_GRF_VIRT + RK3036_GRF_UOC1_CON4);
+               writel(UOC_HIWORD_UPDATE(0x0, 0x3, 12), RK_GRF_VIRT + 
+                          RK3036_GRF_UOC1_CON4);
        }
-#endif
 }
+#else
+static void dwc_otg_uart_mode(void *pdata, int enter_usb_uart_mode)
+{
+}
+#endif
 
 static void usb20otg_power_enable(int enable)
 {
index 5c6debc79e158b4aca37b3626dfafddf3b3ec4d7..b1467999657264bb35ce48557a8fa74162888cbe 100755 (executable)
@@ -139,20 +139,43 @@ static int usb20otg_get_status(int id)
        return ret;
 }
 
+#ifdef CONFIG_RK_USB_UART
+/**
+ *  dwc_otg_uart_enabled - check if a usb-uart bypass func is enabled in DT
+ *
+ *  Returns true if the status property of node "usb_uart" is set to "okay"
+ *  or "ok", if this property is absent it will use the default status "ok"
+ *  0 otherwise
+ */
+static bool dwc_otg_uart_enabled(void)
+{
+       struct device_node *np;
+
+       np = of_find_node_by_name(NULL, "usb_uart");
+       if (np && of_device_is_available(np))
+               return true;
+
+       return false;
+}
+
 static void dwc_otg_uart_mode(void *pdata, int enter_usb_uart_mode)
 {
-#ifdef CONFIG_RK_USB_UART
-       if (1 == enter_usb_uart_mode) {
+       if ((1 == enter_usb_uart_mode) && dwc_otg_uart_enabled()) {
                /* bypass dm, enter uart mode */
-               writel(UOC_HIWORD_UPDATE(0x3, 0x3, 12),
-                      RK_GRF_VIRT + RK312X_GRF_UOC1_CON4);
+               writel(UOC_HIWORD_UPDATE(0x3, 0x3, 12), RK_GRF_VIRT +
+                          RK312X_GRF_UOC1_CON4);
+
        } else if (0 == enter_usb_uart_mode) {
                /* enter usb mode */
-               writel(UOC_HIWORD_UPDATE(0x0, 0x3, 12),
-                      RK_GRF_VIRT + RK312X_GRF_UOC1_CON4);
+               writel(UOC_HIWORD_UPDATE(0x0, 0x3, 12), RK_GRF_VIRT + 
+                          RK312X_GRF_UOC1_CON4);
        }
-#endif
 }
+#else
+static void dwc_otg_uart_mode(void *pdata, int enter_usb_uart_mode)
+{
+}
+#endif
 
 static void usb20otg_power_enable(int enable)
 {