From: wlf Date: Wed, 19 Mar 2014 03:57:02 +0000 (+0800) Subject: USB: add usb properties in dts and delete some usb configs. X-Git-Tag: firefly_0821_release~6007 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=3cbd19d1c84db891b6c42e7742403e4a293b4f9d;p=firefly-linux-kernel-4.4.55.git USB: add usb properties in dts and delete some usb configs. --- diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi index 491e7587ae45..85bf0f56eff4 100755 --- a/arch/arm/boot/dts/rk3188.dtsi +++ b/arch/arm/boot/dts/rk3188.dtsi @@ -723,6 +723,8 @@ gpios = <&gpio0 GPIO_C0 GPIO_ACTIVE_LOW>, <&gpio3 GPIO_D5 GPIO_ACTIVE_LOW>; clocks = <&clk_gates4 5>; clock-names = "hclk_usb_peri"; + rockchip,remote_wakeup; + rockchip,usb_irq_wakeup; usb_bc{ compatible = "rockchip,ctrl"; diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi index bae204eea367..9de1b7558271 100755 --- a/arch/arm/boot/dts/rk3288.dtsi +++ b/arch/arm/boot/dts/rk3288.dtsi @@ -759,6 +759,8 @@ /* <&gpio0 GPIO_B4 GPIO_ACTIVE_LOW>;*//*OTG_VBUS_DRV*/ /*clocks = <&clk_gates7 9>;*/ /*clock-names = "hclk_usb_peri";*/ + rockchip,remote_wakeup; + rockchip,usb_irq_wakeup; usb_bc{ compatible = "rockchip,ctrl"; diff --git a/drivers/usb/dwc_otg_310/Kconfig b/drivers/usb/dwc_otg_310/Kconfig index a0280d9ae0a3..e885c8afd020 100755 --- a/drivers/usb/dwc_otg_310/Kconfig +++ b/drivers/usb/dwc_otg_310/Kconfig @@ -29,13 +29,3 @@ config DWC_OTG tristate depends on DWC_OTG_310 default y if USB11_HOST || USB20_HOST || USB20_OTG - -config DWC_REMOTE_WAKEUP - bool "remote wakeup support in DWC_OTG controller" - depends on DWC_OTG_310 - default y if USB20_HOST || USB20_OTG - -config RK_USB_DETECT_BY_OTG_BVALID - bool "Wakeup system by OTG BVALID interrupt when USB OTG conneted" - depends on USB_GADGET && ARCH_ROCKCHIP - default y if USB20_HOST || USB20_OTG diff --git a/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c b/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c index 0ee449f4f6fd..5c125e07c020 100755 --- a/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c @@ -749,15 +749,15 @@ static int dwc_otg_hcd_suspend(struct usb_hcd *hcd) pcgcctl.b.stoppclk = 1;//stop phy clk DWC_WRITE_REG32(core_if->pcgcctl, pcgcctl.d32); } -#ifndef CONFIG_DWC_REMOTE_WAKEUP else{ //no device connect - if(pldata->phy_suspend) - pldata->phy_suspend(pldata, USB_PHY_SUSPEND); + if(!pldata->get_status(USB_REMOTE_WAKEUP)){ + if(pldata->phy_suspend) + pldata->phy_suspend(pldata, USB_PHY_SUSPEND); + if (pldata->clock_enable) + pldata->clock_enable(pldata, 0); + } } - if (pldata->clock_enable) - pldata->clock_enable(pldata, 0); - #endif udelay(3); return 0; @@ -784,10 +784,10 @@ static int dwc_otg_hcd_resume(struct usb_hcd *hcd) return 0; //#endif -#ifndef CONFIG_DWC_REMOTE_WAKEUP - if (pldata->clock_enable) - pldata->clock_enable( pldata, 1); -#endif + if(!pldata->get_status(USB_REMOTE_WAKEUP)){ + if (pldata->clock_enable) + pldata->clock_enable( pldata, 1); + } hprt0.d32 = DWC_READ_REG32(core_if->host_if->hprt0); #ifdef CONFIG_PM_RUNTIME @@ -843,12 +843,12 @@ static int dwc_otg_hcd_resume(struct usb_hcd *hcd) mdelay(10); } -#ifndef CONFIG_DWC_REMOTE_WAKEUP else{ - if(pldata->phy_suspend) - pldata->phy_suspend( pldata, USB_PHY_ENABLED); + if(!pldata->get_status(USB_REMOTE_WAKEUP)){ + if(pldata->phy_suspend) + pldata->phy_suspend( pldata, USB_PHY_ENABLED); + } } -#endif gintmsk.b.portintr = 1; DWC_WRITE_REG32(&core_if->core_global_regs->gintmsk, gintmsk.d32); diff --git a/drivers/usb/dwc_otg_310/usbdev_rk.h b/drivers/usb/dwc_otg_310/usbdev_rk.h index 80fd925cb7e9..f459e0fdb8fa 100755 --- a/drivers/usb/dwc_otg_310/usbdev_rk.h +++ b/drivers/usb/dwc_otg_310/usbdev_rk.h @@ -34,6 +34,9 @@ #define USB_STATUS_DPDM (2) #define USB_STATUS_ID (3) #define USB_STATUS_UARTMODE (4) +#define USB_CHIP_ID (5) +#define USB_REMOTE_WAKEUP (6) +#define USB_IRQ_WAKEUP (7) /* rk3188 platform data */ extern struct dwc_otg_platform_data usb20otg_pdata_rk3188; @@ -62,7 +65,6 @@ struct dwc_otg_platform_data { void (*dwc_otg_uart_mode)(void* pdata, int enter_usb_uart_mode); void (*bc_detect_cb)(int bc_type); int (*get_status)(int id); - int (*get_chip_id)(void); }; struct rkehci_platform_data{ @@ -76,7 +78,6 @@ struct rkehci_platform_data{ void (*clock_init)(void* pdata); void (*clock_enable)(void *pdata, int enable); void (*soft_reset)(void); - int (*get_chip_id)(void); int clk_status; }; @@ -96,6 +97,8 @@ struct dwc_otg_control_usb { struct clk* hclk_usb_peri; struct delayed_work usb_det_wakeup_work; struct wake_lock usb_wakelock; + int remote_wakeup; + int usb_irq_wakeup; int chip_id; }; diff --git a/drivers/usb/dwc_otg_310/usbdev_rk30.c b/drivers/usb/dwc_otg_310/usbdev_rk30.c index 1903c4adeb19..f4913a0af9fe 100755 --- a/drivers/usb/dwc_otg_310/usbdev_rk30.c +++ b/drivers/usb/dwc_otg_310/usbdev_rk30.c @@ -5,11 +5,6 @@ static struct dwc_otg_control_usb *control_usb; -static int usb_get_chip_id(void) -{ - return control_usb->chip_id; -} - #ifdef CONFIG_USB20_OTG static void usb20otg_hw_init(void) @@ -101,6 +96,15 @@ static int usb20otg_get_status(int id) // id in grf ret = control_usb->grf_soc_status0_rk3188->otg_iddig; break; + case USB_CHIP_ID: + ret = control_usb->chip_id; + break; + case USB_REMOTE_WAKEUP: + ret = control_usb->remote_wakeup; + break; + case USB_IRQ_WAKEUP: + ret = control_usb->usb_irq_wakeup; + break; default: break; } @@ -146,7 +150,6 @@ struct dwc_otg_platform_data usb20otg_pdata_rk3188 = { .clock_init = usb20otg_clock_init, .clock_enable = usb20otg_clock_enable, .get_status = usb20otg_get_status, - .get_chip_id = usb_get_chip_id, .power_enable = usb20otg_power_enable, #ifdef CONFIG_RK_USB_UART .dwc_otg_uart_mode = dwc_otg_uart_mode, @@ -239,6 +242,15 @@ static int usb20host_get_status(int id) // id in grf ret = control_usb->grf_soc_status0_rk3188->uhost_iddig; break; + case USB_CHIP_ID: + ret = control_usb->chip_id; + break; + case USB_REMOTE_WAKEUP: + ret = control_usb->remote_wakeup; + break; + case USB_IRQ_WAKEUP: + ret = control_usb->usb_irq_wakeup; + break; default: break; } @@ -266,7 +278,6 @@ struct dwc_otg_platform_data usb20host_pdata_rk3188 = { .clock_init = usb20host_clock_init, .clock_enable = usb20host_clock_enable, .get_status = usb20host_get_status, - .get_chip_id = usb_get_chip_id, .power_enable = usb20host_power_enable, }; #endif @@ -364,18 +375,15 @@ struct rkehci_platform_data rkhsic_pdata_rk3188 = { .clock_init = rk_hsic_clock_init, .clock_enable = rk_hsic_clock_enable, .soft_reset = rk_hsic_soft_reset, - .get_chip_id = usb_get_chip_id, }; #endif -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID #define WAKE_LOCK_TIMEOUT (HZ * 10) inline static void do_wakeup(struct work_struct *work) { // rk28_send_wakeup_key(); } -#endif /********** handler for bvalid irq **********/ static irqreturn_t bvalid_irq_handler(int irq, void *dev_id) @@ -388,10 +396,10 @@ static irqreturn_t bvalid_irq_handler(int irq, void *dev_id) dwc_otg_uart_mode(NULL, PHY_USB_MODE); #endif -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID - wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); - schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); -#endif + if(control_usb->usb_irq_wakeup){ + wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); + schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); + } return IRQ_HANDLED; } @@ -402,10 +410,10 @@ static int otg_irq_detect_init(struct platform_device *pdev) int ret = 0; int irq = 0; -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID - wake_lock_init(&control_usb->usb_wakelock, WAKE_LOCK_SUSPEND, "usb_detect"); - INIT_DELAYED_WORK(&control_usb->usb_det_wakeup_work, do_wakeup); -#endif + if(control_usb->usb_irq_wakeup){ + wake_lock_init(&control_usb->usb_wakelock, WAKE_LOCK_SUSPEND, "usb_detect"); + INIT_DELAYED_WORK(&control_usb->usb_det_wakeup_work, do_wakeup); + } irq = platform_get_irq_byname(pdev, "otg_bvalid"); if (irq > 0) { @@ -418,9 +426,9 @@ static int otg_irq_detect_init(struct platform_device *pdev) /* clear & enable bvalid irq */ control_usb->grf_uoc0_base->CON3 = (3 << 30) | (3 << 14); -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID - enable_irq_wake(irq); -#endif + if(control_usb->usb_irq_wakeup){ + enable_irq_wake(irq); + } } return ret; @@ -503,6 +511,7 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev) int ret = 0; control_usb = devm_kzalloc(&pdev->dev, sizeof(*control_usb),GFP_KERNEL); + if (!control_usb) { dev_err(&pdev->dev, "unable to alloc memory for control usb\n"); ret = -ENOMEM; @@ -510,6 +519,10 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev) } control_usb->chip_id = RK3188_USB_CTLR; + control_usb->remote_wakeup = of_property_read_bool(np, + "rockchip,remote_wakeup"); + control_usb->usb_irq_wakeup = of_property_read_bool(np, + "rockchip,usb_irq_wakeup"); hclk_usb_peri = devm_clk_get(&pdev->dev, "hclk_usb_peri"); if (IS_ERR(hclk_usb_peri)) { diff --git a/drivers/usb/dwc_otg_310/usbdev_rk32.c b/drivers/usb/dwc_otg_310/usbdev_rk32.c index 3fd4284bc03a..965699214879 100755 --- a/drivers/usb/dwc_otg_310/usbdev_rk32.c +++ b/drivers/usb/dwc_otg_310/usbdev_rk32.c @@ -4,11 +4,6 @@ #include "dwc_otg_regs.h" static struct dwc_otg_control_usb *control_usb; -static int usb_get_chip_id(void) -{ - return control_usb->chip_id; -} - #ifdef CONFIG_USB20_OTG static void usb20otg_hw_init(void) { @@ -103,6 +98,15 @@ static int usb20otg_get_status(int id) // id in grf ret = control_usb->grf_soc_status2_rk3288->otg_iddig; break; + case USB_CHIP_ID: + ret = control_usb->chip_id; + break; + case USB_REMOTE_WAKEUP: + ret = control_usb->remote_wakeup; + break; + case USB_IRQ_WAKEUP: + ret = control_usb->usb_irq_wakeup; + break; default: break; } @@ -145,8 +149,6 @@ struct dwc_otg_platform_data usb20otg_pdata_rk3288 = { .clock_init = usb20otg_clock_init, .clock_enable = usb20otg_clock_enable, .get_status = usb20otg_get_status, - .get_chip_id = usb_get_chip_id, - .power_enable = usb20otg_power_enable, #ifdef CONFIG_RK_USB_UART .dwc_otg_uart_mode = dwc_otg_uart_mode, @@ -243,6 +245,15 @@ static int usb20host_get_status(int id) // id in grf ret = control_usb->grf_soc_status2_rk3288->host1_iddig; break; + case USB_CHIP_ID: + ret = control_usb->chip_id; + break; + case USB_REMOTE_WAKEUP: + ret = control_usb->remote_wakeup; + break; + case USB_IRQ_WAKEUP: + ret = control_usb->usb_irq_wakeup; + break; default: break; } @@ -271,7 +282,6 @@ struct dwc_otg_platform_data usb20host_pdata_rk3288 = { .clock_init = usb20host_clock_init, .clock_enable = usb20host_clock_enable, .get_status = usb20host_get_status, - .get_chip_id = usb_get_chip_id, .power_enable = usb20host_power_enable, }; @@ -371,7 +381,6 @@ struct rkehci_platform_data rkhsic_pdata_rk3288 = { .clock_init = rk_hsic_clock_init, .clock_enable = rk_hsic_clock_enable, .soft_reset = rk_hsic_soft_reset, - .get_chip_id = usb_get_chip_id, }; #endif @@ -404,7 +413,6 @@ struct rkehci_platform_data rkehci_pdata_rk3288 = { .clock_init = rk_ehci_clock_init, .clock_enable = rk_ehci_clock_enable, .soft_reset = rk_ehci_soft_reset, - .get_chip_id = usb_get_chip_id, }; #endif @@ -433,7 +441,6 @@ struct rkehci_platform_data rkohci_pdata_rk3288 = { .clock_init = rk_ohci_clock_init, .clock_enable = rk_ohci_clock_enable, .soft_reset = rk_ohci_soft_reset, - .get_chip_id = usb_get_chip_id, }; #endif @@ -441,13 +448,11 @@ struct rkehci_platform_data rkohci_pdata_rk3288 = { rk3288 usb detections *********************************************************************/ -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID #define WAKE_LOCK_TIMEOUT (HZ * 10) inline static void do_wakeup(struct work_struct *work) { // rk28_send_wakeup_key(); } -#endif /********** handler for bvalid irq **********/ static irqreturn_t bvalid_irq_handler(int irq, void *dev_id) @@ -460,11 +465,10 @@ static irqreturn_t bvalid_irq_handler(int irq, void *dev_id) dwc_otg_uart_mode(NULL, PHY_USB_MODE); #endif -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID - wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); - schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); -#endif - + if(control_usb->usb_irq_wakeup){ + wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); + schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); + } return IRQ_HANDLED; } @@ -489,10 +493,12 @@ static irqreturn_t id_irq_handler(int irq, void *dev_id) #endif control_usb->grf_uoc0_base->CON4 = ((1<<7)|(1<<23));//clear id fall irq pandding } -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID - wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); - schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); -#endif + + if(control_usb->usb_irq_wakeup){ + wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); + schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); + } + return IRQ_HANDLED; } @@ -513,11 +519,13 @@ static irqreturn_t line_irq_handler(int irq, void *dev_id) if(control_usb->grf_uoc2_base->CON0 & 1<<15){ control_usb->grf_uoc2_base->CON0 = (1<<15 | 1<<31); - } -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID - wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); - schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); -#endif + } + + if(control_usb->usb_irq_wakeup){ + wake_lock_timeout(&control_usb->usb_wakelock, WAKE_LOCK_TIMEOUT); + schedule_delayed_work(&control_usb->usb_det_wakeup_work, HZ/10); + } + return IRQ_HANDLED; } @@ -527,59 +535,84 @@ static int otg_irq_detect_init(struct platform_device *pdev) int ret = 0; int irq = 0; -#ifdef CONFIG_RK_USB_DETECT_BY_OTG_BVALID - wake_lock_init(&control_usb->usb_wakelock, WAKE_LOCK_SUSPEND, "usb_detect"); - INIT_DELAYED_WORK(&control_usb->usb_det_wakeup_work, do_wakeup); -#endif + if(control_usb->usb_irq_wakeup){ + wake_lock_init(&control_usb->usb_wakelock, WAKE_LOCK_SUSPEND, "usb_detect"); + INIT_DELAYED_WORK(&control_usb->usb_det_wakeup_work, do_wakeup); + } /*register otg_bvalid irq*/ irq = platform_get_irq_byname(pdev, "otg_bvalid"); if (irq > 0) { ret = request_irq(irq, bvalid_irq_handler, 0, "otg_bvalid", NULL); - if(ret < 0) + if(ret < 0){ dev_err(&pdev->dev, "request_irq %d failed!\n", irq); - else + return ret; + }else{ control_usb->grf_uoc0_base->CON4 = 0x000c000c;// enable bvalid irq + if(control_usb->usb_irq_wakeup){ + enable_irq_wake(irq); + } + } } /*register otg_id irq*/ irq = platform_get_irq_byname(pdev, "otg_id"); if(irq > 0){ ret = request_irq(irq, id_irq_handler, 0, "otg_id", NULL); - if(ret < 0) + if(ret < 0){ dev_err(&pdev->dev, "request_irq %d failed!\n", irq); - else + return ret; + }else{ control_usb->grf_uoc0_base->CON4 = 0x00f000f0; + if(control_usb->usb_irq_wakeup){ + enable_irq_wake(irq); + } + } } /*register otg_linestate irq*/ irq = platform_get_irq_byname(pdev, "otg_linestate"); if(irq > 0){ ret = request_irq(irq, line_irq_handler, 0, "otg_linestate", NULL); - if(ret < 0) + if(ret < 0){ dev_err(&pdev->dev, "request_irq %d failed!\n", irq); - else + return ret; + }else{ control_usb->grf_uoc0_base->CON0 = 0xc000c000; + if(control_usb->usb_irq_wakeup){ + enable_irq_wake(irq); + } + } } /*register host0_linestate irq*/ irq = platform_get_irq_byname(pdev, "host0_linestate"); if(irq > 0){ ret = request_irq(irq, line_irq_handler, 0, "host0_linestate", NULL); - if(ret < 0) + if(ret < 0){ dev_err(&pdev->dev, "request_irq %d failed!\n", irq); - else + return ret; + }else{ control_usb->grf_uoc1_base->CON0 = 0xc000c000; + if(control_usb->usb_irq_wakeup){ + enable_irq_wake(irq); + } + } } /*register host1_linestate irq*/ irq = platform_get_irq_byname(pdev, "host1_linestate"); if(irq > 0){ ret = request_irq(irq, line_irq_handler, 0, "host1_linestate", NULL); - if(ret < 0) + if(ret < 0){ dev_err(&pdev->dev, "request_irq %d failed!\n", irq); - else + return ret; + }else{ control_usb->grf_uoc2_base->CON0 = 0xc000c000; + if(control_usb->usb_irq_wakeup){ + enable_irq_wake(irq); + } + } } return ret; @@ -711,6 +744,11 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev) } control_usb->chip_id = RK3288_USB_CTLR; + control_usb->remote_wakeup = of_property_read_bool(np, + "rockchip,remote_wakeup"); + control_usb->usb_irq_wakeup = of_property_read_bool(np, + "rockchip,usb_irq_wakeup"); + /* disable for debug hclk_usb_peri = devm_clk_get(&pdev->dev, "hclk_usb_peri"); if (IS_ERR(hclk_usb_peri)) {