rk312x: support usb-uart debug
authorlyz <lyz@rock-chips.com>
Fri, 1 Aug 2014 07:36:44 +0000 (15:36 +0800)
committerlyz <lyz@rock-chips.com>
Fri, 1 Aug 2014 07:37:38 +0000 (15:37 +0800)
arch/arm/mach-rockchip/rk312x.c
drivers/usb/dwc_otg_310/usbdev_bc.c
drivers/usb/dwc_otg_310/usbdev_rk3126.c

index 8fc06d08d0f0bf26696b6095fec52a7946c34b75..328053282e4552223fc9709b2ed5623b7032740c 100755 (executable)
@@ -78,11 +78,33 @@ static struct map_desc rk312x_io_desc[] __initdata = {
        RK_DEVICE(RK_GIC_VIRT + RK312X_GIC_DIST_SIZE, RK312X_GIC_CPU_PHYS, RK312X_GIC_CPU_SIZE),
        RK_DEVICE(RK312X_IMEM_VIRT, RK312X_IMEM_PHYS, SZ_4K),
 };
+static void usb_uart_init(void)
+{
+#ifdef CONFIG_RK_USB_UART
+       u32 soc_status0 = readl_relaxed(RK_GRF_VIRT + RK312X_GRF_SOC_STATUS0);
+#endif
+       writel_relaxed(0x34000000, RK_GRF_VIRT + RK312X_GRF_UOC1_CON4);
+#ifdef CONFIG_RK_USB_UART
+       if (!(soc_status0 & (1 << 5)) && (soc_status0 & (1 << 8))) {
+               /* software control usb phy enable */
+               writel_relaxed(0x007f0055, RK_GRF_VIRT + RK312X_GRF_UOC0_CON0);
+               writel_relaxed(0x34003000, RK_GRF_VIRT + RK312X_GRF_UOC1_CON4);
+       }
+#endif
+
+       writel_relaxed(0x07, RK_DEBUG_UART_VIRT + 0x88);
+       writel_relaxed(0x00, RK_DEBUG_UART_VIRT + 0x04);
+       writel_relaxed(0x83, RK_DEBUG_UART_VIRT + 0x0c);
+       writel_relaxed(0x0d, RK_DEBUG_UART_VIRT + 0x00);
+       writel_relaxed(0x00, RK_DEBUG_UART_VIRT + 0x04);
+       writel_relaxed(0x03, RK_DEBUG_UART_VIRT + 0x0c);
+}
 
 static void __init rk312x_dt_map_io(void)
 {
        iotable_init(rk312x_io_desc, ARRAY_SIZE(rk312x_io_desc));
        debug_ll_io_init();
+       usb_uart_init();
 
        /* enable timer5 for core */
        writel_relaxed(0, RK312X_TIMER5_VIRT + 0x10);
index ad382069033e8f79fd66117e10e0c8ba73cbfba8..5a23309071058f53939e320115397389b9311ef9 100755 (executable)
@@ -143,8 +143,7 @@ int usb_battery_charger_detect_rk(bool wait)
 
 int usb_battery_charger_detect_inno(bool wait)
 {
-
-       return -1;
+       return readl(RK_GRF_VIRT + RK312X_GRF_SOC_STATUS0) & (1 << 8);
 }
 
 /* When do BC detect PCD pull-up register should be disabled  */
index 0c691438dc8ac3e02b8b12f265a763a2e011562b..098a4b75b8009de55670609796ff48c4ee5c6586 100755 (executable)
@@ -111,19 +111,18 @@ static int usb20otg_get_status(int id)
 {
        int ret = -1;
        u32 soc_status0 = readl(RK_GRF_VIRT + RK312X_GRF_SOC_STATUS0);
-
        switch (id) {
        case USB_STATUS_BVABLID:
                /* bvalid in grf */
-               ret = soc_status0 & (0x1 << 8);
+               ret = soc_status0 & (0x1 << 5);
                break;
        case USB_STATUS_DPDM:
                /* dpdm in grf */
-               ret = soc_status0 & (0x3 << 9);
+               ret = soc_status0 & (0x3 << 6);
                break;
        case USB_STATUS_ID:
                /* id in grf */
-               ret = soc_status0 & (0x1 << 11);
+               ret = soc_status0 & (0x1 << 8);
                break;
        case USB_CHIP_ID:
                ret = control_usb->chip_id;