usb-uart: add a propertie in dts to enable usb-uart debug
authorlyz <lyz@rock-chips.com>
Thu, 7 Aug 2014 12:59:37 +0000 (20:59 +0800)
committerlyz <lyz@rock-chips.com>
Fri, 15 Aug 2014 02:39:10 +0000 (10:39 +0800)
Documentation/devicetree/bindings/usb/rockchip-usb.txt
arch/arm/boot/dts/rk3288-tb.dts
arch/arm/boot/dts/rk3288-tb_8846.dts
drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c
drivers/usb/dwc_otg_310/usbdev_rk32.c

index bd8f13fbc507055e1b1f8e3db718d06a82163132..cf8009b3c168dc4cd8e5477cf8865782a29ea5bf 100644 (file)
@@ -178,6 +178,12 @@ Optional properties:
  - rk_usb,xcvrsel
  - rk_usb,termsel
 
+ The child node 'usb_uart' to the node 'dwc_control_usb' is for
+ the usb uart debug function.
+ Required propertie:
+ - status : If be "ok" or "okay" will enable the usb-uart debug
+   function and bypass UART2 to USB OTG io port.
+
 Example:
  - RK3288
 
@@ -220,6 +226,9 @@ Example:
                        rk_usb,fsvminus   = <0x2cc 25 1>;
                        rk_usb,fsvplus    = <0x2cc 24 1>;
                };
+               usb_uart {
+                       status = "okay";
+               };
        };
 
 ROCKCHIP USB-COMMON CONTROL
index b73c2259f6b042ef0dccee2353fc3b5f25b65e9d..2f99f0b032dbf111351b77f00c918be8af0e7c21 100755 (executable)
 &ion_cma {
        reg = <0x40000000 0x28000000>; /* 640MB */
 };
+
+&dwc_control_usb {
+       usb_uart {
+               status = "disabled";
+       };
+};
index 717d447014e9f23d8da59fa41ca01bcb7d207dc2..bbcb35dc15b0b1291db9256ec33e13aa040ec6ba 100644 (file)
 &ion_cma {
        reg = <0x40000000 0x28000000>; /* 640MB */
 };
+
+&dwc_control_usb {
+       usb_uart {
+               status = "disabled";
+       };
+};
index 89261e056770355bb75103b14ce0f1b958c6e0e9..c16e5671f87046c61635d85f78ff031e7ba61863 100755 (executable)
@@ -1653,9 +1653,7 @@ static void dwc_otg_pcd_work_init(dwc_otg_pcd_t *pcd,
 {
 
        struct dwc_otg_device *otg_dev = pcd->otg_dev;
-#ifdef CONFIG_RK_USB_UART
        struct dwc_otg_platform_data *pldata = otg_dev->pldata;
-#endif
 
        pcd->vbus_status = USB_BC_TYPE_DISCNT;
        pcd->phy_suspend = USB_PHY_ENABLED;
@@ -1667,7 +1665,6 @@ static void dwc_otg_pcd_work_init(dwc_otg_pcd_t *pcd,
 
        if (dwc_otg_is_device_mode(pcd->core_if) &&
            (otg_dev->core_if->usb_mode != USB_MODE_FORCE_HOST)) {
-#ifdef CONFIG_RK_USB_UART
                if (pldata->get_status(USB_STATUS_BVABLID)) {
                        /* enter usb phy mode */
                        pldata->dwc_otg_uart_mode(pldata, PHY_USB_MODE);
@@ -1675,14 +1672,11 @@ static void dwc_otg_pcd_work_init(dwc_otg_pcd_t *pcd,
                        /* usb phy bypass to uart mode */
                        pldata->dwc_otg_uart_mode(pldata, PHY_UART_MODE);
                }
-#endif
                schedule_delayed_work(&pcd->check_vbus_work, (HZ << 4));
        }
-#ifdef CONFIG_RK_USB_UART
        else if (pldata->dwc_otg_uart_mode != NULL)
                /* host mode,enter usb phy mode */
                pldata->dwc_otg_uart_mode(pldata, PHY_USB_MODE);
-#endif
 
 }
 
index 97675201256b881d0f38f8aaf19c3b3b0b7a17a6..5a59c0bb811e150dafab0f86e00f1a3705138d15 100755 (executable)
@@ -134,9 +134,27 @@ static int usb20otg_get_status(int id)
 }
 
 #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)
 {
-       if (1 == enter_usb_uart_mode) {
+       if ((1 == enter_usb_uart_mode) && dwc_otg_uart_enabled()) {
                /* bypass dm, enter uart mode */
                control_usb->grf_uoc0_base->CON3 = (0x00c0 | (0x00c0 << 16));
 
@@ -145,6 +163,10 @@ static void dwc_otg_uart_mode(void *pdata, int enter_usb_uart_mode)
                control_usb->grf_uoc0_base->CON3 = (0x00c0 << 16);
        }
 }
+#else
+static void dwc_otg_uart_mode(void *pdata, int enter_usb_uart_mode)
+{
+}
 #endif
 
 static void usb20otg_power_enable(int enable)
@@ -172,9 +194,7 @@ struct dwc_otg_platform_data usb20otg_pdata_rk3288 = {
        .clock_enable = usb20otg_clock_enable,
        .get_status = usb20otg_get_status,
        .power_enable = usb20otg_power_enable,
-#ifdef CONFIG_RK_USB_UART
        .dwc_otg_uart_mode = dwc_otg_uart_mode,
-#endif
        .bc_detect_cb = usb20otg_battery_charger_detect_cb,
 };
 
@@ -671,10 +691,8 @@ static irqreturn_t bvalid_irq_handler(int irq, void *dev_id)
        /* clear irq */
        control_usb->grf_uoc0_base->CON4 = (0x0008 | (0x0008 << 16));
 
-#ifdef CONFIG_RK_USB_UART
        /* usb otg dp/dm switch to usb phy */
        dwc_otg_uart_mode(NULL, PHY_USB_MODE);
-#endif
 
        if (control_usb->usb_irq_wakeup) {
                wake_lock_timeout(&control_usb->usb_wakelock,
@@ -705,10 +723,8 @@ static irqreturn_t id_irq_handler(int irq, void *dev_id)
 
        /* id fall */
        if (uoc_con & (1 << 7)) {
-#ifdef CONFIG_RK_USB_UART
                /* usb otg dp/dm switch to usb phy */
                dwc_otg_uart_mode(NULL, PHY_USB_MODE);
-#endif
                /* clear id fall irq pandding */
                control_usb->grf_uoc0_base->CON4 = ((1 << 7) | (1 << 23));
        }