rk3026: usb: support for usb-debug
authorlyz <lyz@rock-chips.com>
Tue, 23 Jul 2013 03:06:47 +0000 (11:06 +0800)
committerlyz <lyz@rock-chips.com>
Tue, 23 Jul 2013 03:06:47 +0000 (11:06 +0800)
arch/arm/mach-rk2928/common.c
arch/arm/plat-rk/usb_detect.c
drivers/usb/dwc_otg/usbdev_rk3026.c

index 2ef95b56bebdf725c4c60d7459185f43fde9e33c..e9e5885bfc5c4d6032a9701bd5d173d4294b4837 100755 (executable)
@@ -216,21 +216,25 @@ static void usb_uart_init(void)
        writel_relaxed(0x03, DEBUG_UART_BASE + 0x0c);
 #endif //end of CONFIG_ARCH_RK2928
 #ifdef CONFIG_ARCH_RK3026
+
+writel_relaxed(0x34000000, RK2928_GRF_BASE + GRF_UOC1_CON0);
 #ifdef CONFIG_RK_USB_UART
-       if (!(readl_relaxed(RK30_GRF_BASE + GRF_SOC_STATUS0) & (1 << 13))) { //detect id
-               writel_relaxed((0x0300 << 16), RK30_GRF_BASE + GRF_UOC0_CON0);
-       } else {
-               if (!(readl_relaxed(RK30_GRF_BASE + GRF_SOC_STATUS0) & (1 << 10))) { //detect vbus
-                       writel_relaxed(((0x01 << 2) | ((0x01 << 2) << 16)), RK30_GRF_BASE + GRF_UOC0_CON2); //software control usb phy enable 
-                       writel_relaxed((0x2A | (0x3F << 16)), RK30_GRF_BASE + GRF_UOC0_CON3); //usb phy enter suspend
-                       writel_relaxed((0x0300 | (0x0300 << 16)), RK30_GRF_BASE + GRF_UOC0_CON0);
-               } else {
-                       writel_relaxed((0x0300 << 16), RK30_GRF_BASE + GRF_UOC0_CON0);
+       writel_relaxed(0x34000000, RK2928_GRF_BASE + GRF_UOC1_CON0);
+
+       if((readl_relaxed(RK2928_GRF_BASE + GRF_SOC_STATUS0) & (1<<10)))//detect id
+       {
+               if(!(readl_relaxed(RK2928_GRF_BASE + GRF_SOC_STATUS0) & (1<<7)))//detect vbus
+               {
+                       writel_relaxed(0x007f0055, RK2928_GRF_BASE + GRF_UOC0_CON0);
+                       writel_relaxed(0x34003000, RK2928_GRF_BASE + GRF_UOC1_CON0);
+               }
+               else
+               {
+                       writel_relaxed(0x34000000, RK2928_GRF_BASE + GRF_UOC1_CON0);
                }
        }
-#else
-       writel_relaxed((0x0300 << 16), RK30_GRF_BASE + GRF_UOC0_CON0);
-#endif //end of CONFIG_RK_USB_UART
+
+#endif // end of CONFIG_RK_USB_UART
 #endif //end of CONFIG_ARCH_RK3026
 #endif //end of DEBUG_UART_BASE
 }
index 3a0acd658ae85739dd497cea7519d03c3531f906..2adc06b6ba447a0e0d3fe46486477df2b5cde5fb 100755 (executable)
@@ -158,9 +158,7 @@ static irqreturn_t otg_id_irq_handler(int irq, void *dev_id)
        /* clear irq */
     uoc_con = readl_relaxed(RK2928_GRF_BASE + GRF_UOC_CON);
 
-#ifdef CONFIG_RK_USB_UART
-       /* to do @lyz*/
-#endif
+
     
     if(uoc_con & (1<<1)) //id rise 
     {
@@ -168,7 +166,12 @@ static irqreturn_t otg_id_irq_handler(int irq, void *dev_id)
     }
     if(uoc_con & (1<<3))//id fall
     { 
-        writel_relaxed((0x3 << 16) | 0x3, RK2928_GRF_BASE + GRF_UOC_CON);;//clear id fall irq pandding
+#ifdef CONFIG_RK_USB_UART
+        //if(!(readl_relaxed(RK2928_GRF_BASE + 0x014c) & (1<<10))){//id low          
+        writel_relaxed(0x04000000, RK2928_GRF_BASE + GRF_UOC1_CON0);   //enter usb phy    
+    }
+#endif
+        writel_relaxed((0x3 << 16) | 0x3, RK2928_GRF_BASE + GRF_UOC_CON);//clear id fall irq pandding
     }
        rk28_send_wakeup_key();
        return IRQ_HANDLED;
index e5ceae23985c58f3d0dc5c0df78e3943d764f8d4..9e7414cf2af9ee72533b4d681a70e362f7977465 100755 (executable)
@@ -221,13 +221,13 @@ void dwc_otg_uart_mode(void* pdata, int enter_usb_uart_mode)
     if(1 == enter_usb_uart_mode)   //uart mode
     {
         *otg_phy_con0 = (0x03 << 12 | (0x03<<(16+12)));//bypass dm
-        //printk("phy enter uart mode USBGRF_UOC1_CON0 = %08x\n",*otg_phy_con1);
+        printk("otg-phy enter uart mode USBGRF_UOC1_CON0 = %08x\n",*otg_phy_con1);
         
     }
     if(0 == enter_usb_uart_mode)   //usb mode
     {   
         *otg_phy_con0 = (0x03<<(12+16)); //bypass dm disable 
-        //printk("phy enter usb mode USBGRF_UOC1_CON0 = %8x\n",*otg_phy_con1);
+        printk("otg-phy enter usb mode USBGRF_UOC1_CON0 = %8x\n",*otg_phy_con1);
     }
 #endif
 }