From: lyz Date: Fri, 1 Aug 2014 07:36:44 +0000 (+0800) Subject: rk312x: support usb-uart debug X-Git-Tag: firefly_0821_release~4916^2~84 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8ba35134f6d36c6e5722214e45484aae4c60a9c3;p=firefly-linux-kernel-4.4.55.git rk312x: support usb-uart debug --- diff --git a/arch/arm/mach-rockchip/rk312x.c b/arch/arm/mach-rockchip/rk312x.c index 8fc06d08d0f0..328053282e45 100755 --- a/arch/arm/mach-rockchip/rk312x.c +++ b/arch/arm/mach-rockchip/rk312x.c @@ -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); diff --git a/drivers/usb/dwc_otg_310/usbdev_bc.c b/drivers/usb/dwc_otg_310/usbdev_bc.c index ad382069033e..5a2330907105 100755 --- a/drivers/usb/dwc_otg_310/usbdev_bc.c +++ b/drivers/usb/dwc_otg_310/usbdev_bc.c @@ -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 */ diff --git a/drivers/usb/dwc_otg_310/usbdev_rk3126.c b/drivers/usb/dwc_otg_310/usbdev_rk3126.c index 0c691438dc8a..098a4b75b800 100755 --- a/drivers/usb/dwc_otg_310/usbdev_rk3126.c +++ b/drivers/usb/dwc_otg_310/usbdev_rk3126.c @@ -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;