From: yangkai Date: Thu, 17 Feb 2011 08:57:02 +0000 (+0800) Subject: adjust usb phy suspend and clockgate sequence X-Git-Tag: firefly_0821_release~10760 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=89cc53802044e2932edaaac0bf75ffb17f81a4ea;p=firefly-linux-kernel-4.4.55.git adjust usb phy suspend and clockgate sequence --- diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.c b/drivers/usb/dwc_otg/dwc_otg_cil.c index 0d8042b6e16f..4c20f6ba3a26 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil.c @@ -3336,8 +3336,13 @@ void dwc_otg_dump_flags(dwc_otg_core_if_t *_core_if) DWC_PRINT("core_if->usb_mode = %x\n",_core_if->usb_mode); DWC_PRINT("core_if->usb_wakeup = %x\n",_core_if->usb_wakeup); } + +#ifdef CONFIG_DWC_OTG_DEVICE_ONLY +extern void dwc_otg_pcd_stop(dwc_otg_pcd_t *_pcd); +#endif int dwc_debug(dwc_otg_core_if_t *core_if, int flag) { + dctl_data_t dctl = {.d32=0}; //dwc_otg_core_if_t *core_if = dwc_core_if; #ifdef CONFIG_DWC_OTG_DEVICE_ONLY dwc_otg_pcd_t * pcd; @@ -3354,6 +3359,12 @@ int dwc_debug(dwc_otg_core_if_t *core_if, int flag) otg_dev = core_if->otg_dev; pcd = otg_dev->pcd; pcd->vbus_status = 0; + pcd->conn_status = 0; + pcd->conn_en = 0; + dctl.d32 = dwc_read_reg32( &core_if->dev_if->dev_global_regs->dctl ); + dctl.b.sftdiscon = 1; + dwc_write_reg32( &core_if->dev_if->dev_global_regs->dctl, dctl.d32 ); + dwc_otg_pcd_stop(pcd); #endif break; case 3: @@ -3372,6 +3383,12 @@ int dwc_debug(dwc_otg_core_if_t *core_if, int flag) dwc_otg_dump_flags(core_if); break; case 8: + #ifdef CONFIG_DWC_OTG_DEVICE_ONLY + otg_dev = core_if->otg_dev; + pcd = otg_dev->pcd; + //pcd->vbus_status = 0; + pcd->conn_en = 1; + #endif break; case 9: dwc_otg_dump_flags(core_if); diff --git a/drivers/usb/dwc_otg/dwc_otg_driver.c b/drivers/usb/dwc_otg/dwc_otg_driver.c index 987794f7fe95..54cd562390d9 100755 --- a/drivers/usb/dwc_otg/dwc_otg_driver.c +++ b/drivers/usb/dwc_otg/dwc_otg_driver.c @@ -361,20 +361,20 @@ static ssize_t dwc_otg_enable_store( struct device *_dev, if (_core_if->hcd_cb && _core_if->hcd_cb->stop) { _core_if->hcd_cb->stop( _core_if->hcd_cb->p ); } - clk_disable(otg_dev->phyclk); - clk_disable(otg_dev->ahbclk); if (_core_if->hcd_cb && _core_if->hcd_cb->suspend) { _core_if->hcd_cb->suspend( _core_if->hcd_cb->p, val); } + clk_disable(otg_dev->phyclk); + clk_disable(otg_dev->ahbclk); } else if(val == 1) { DWC_PRINT("enable host controller:%s\n",pdev->name); + clk_enable(otg_dev->phyclk); + clk_enable(otg_dev->ahbclk); if (_core_if->hcd_cb && _core_if->hcd_cb->suspend) { _core_if->hcd_cb->suspend( _core_if->hcd_cb->p, val); } - clk_enable(otg_dev->phyclk); - clk_enable(otg_dev->ahbclk); mdelay(5); if (_core_if->hcd_cb && _core_if->hcd_cb->start) { _core_if->hcd_cb->start( _core_if->hcd_cb->p ); @@ -929,21 +929,65 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) int32_t regval; struct clk *ahbclk,*phyclk,*busclk; unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); - /* - *Enable usb phy - */ + + regval = * otg_phy_con1; - regval |= (0x01<<2); - regval |= (0x01<<3); // exit suspend. - regval &= ~(0x01<<2); #ifndef CONFIG_USB11_HOST + /* + * disable usb host 1.1 controller if not support + */ + phyclk = clk_get(NULL, "uhost"); + if (IS_ERR(phyclk)) { + retval = PTR_ERR(phyclk); + DWC_ERROR("can't get UHOST clock\n"); + goto fail; + } + clk_enable(phyclk); + + ahbclk = clk_get(NULL, "hclk_uhost"); + if (IS_ERR(ahbclk)) { + retval = PTR_ERR(ahbclk); + DWC_ERROR("can't get UHOST ahb bus clock\n"); + goto fail; + } + clk_enable(ahbclk); + regval |= (0x01<<28); + + *otg_phy_con1 = regval; + + clk_disable(phyclk); + clk_disable(ahbclk); #endif #ifndef CONFIG_USB20_HOST + /* + * disable usb host 2.0 phy if not support + */ + phyclk = clk_get(NULL, "otgphy1"); + if (IS_ERR(phyclk)) { + retval = PTR_ERR(phyclk); + DWC_ERROR("can't get USBPHY1 clock\n"); + goto fail; + } + clk_enable(phyclk); + + ahbclk = clk_get(NULL, "usbotg1"); + if (IS_ERR(ahbclk)) { + retval = PTR_ERR(ahbclk); + DWC_ERROR("can't get USBOTG1 ahb bus clock\n"); + goto fail; + } + clk_enable(ahbclk); + regval &= ~(0x01<<14); // exit suspend. regval |= (0x01<<13); // software control -#endif + *otg_phy_con1 = regval; + + clk_disable(phyclk); + clk_disable(ahbclk); +#endif + #if 0 otgreg = ioremap(RK2818_USBOTG_PHYS,RK2818_USBOTG_SIZE); DWC_PRINT("otgreg 0x%x",otgreg); @@ -988,6 +1032,15 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) } clk_enable(ahbclk); + /* + * Enable usb phy 0 + */ + regval = * otg_phy_con1; + regval |= (0x01<<2); + regval |= (0x01<<3); // exit suspend. + regval &= ~(0x01<<2); + *otg_phy_con1 = regval; + dwc_otg_device->phyclk = phyclk; dwc_otg_device->ahbclk = ahbclk; dwc_otg_device->busclk = busclk; diff --git a/drivers/usb/dwc_otg/dwc_otg_hcd.c b/drivers/usb/dwc_otg/dwc_otg_hcd.c index 226a06ab5944..5271b33000ae 100755 --- a/drivers/usb/dwc_otg/dwc_otg_hcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_hcd.c @@ -104,6 +104,7 @@ static int dwc_otg_hcd_suspend(struct usb_hcd *hcd) core_if->hcd_cb->suspend( core_if->hcd_cb->p, 0); } } + udelay(1); clk_disable(core_if->otg_dev->phyclk); clk_disable(core_if->otg_dev->ahbclk); //power off diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c b/drivers/usb/dwc_otg/dwc_otg_pcd.c index 0451addf8dc0..1ade6b05a809 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c @@ -1552,6 +1552,7 @@ int rk28_usb_suspend( int exitsuspend ) pcd->phy_suspend = 1; *otg_phy_con1 |= (0x01<<2); *otg_phy_con1 &= ~(0x01<<3); // enter suspend. + udelay(1); clk_disable(pcd->otg_dev->phyclk); clk_disable(pcd->otg_dev->ahbclk); //*otg_phy_con1 &= ~(0x01<<2);