From: yangkai Date: Wed, 5 Sep 2012 08:10:20 +0000 (+0800) Subject: usb clock update X-Git-Tag: firefly_0821_release~8726 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=33ba6c615ab0e6b8d5b1e6d4bb7517296c10059b;p=firefly-linux-kernel-4.4.55.git usb clock update --- diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.c b/drivers/usb/dwc_otg/dwc_otg_cil.c index 87c0319494ca..fefde8c8749f 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil.c @@ -211,7 +211,6 @@ dwc_otg_core_if_t *dwc_otg_cil_init(const uint32_t *_reg_base_addr, core_if->srp_success = 0; core_if->srp_timer_started = 0; - core_if->usb_wakeup = 0; // if(dwc_core_if == NULL) dwc_core_if = core_if; return core_if; @@ -3303,7 +3302,6 @@ void dwc_otg_dump_flags(dwc_otg_core_if_t *_core_if) DWC_PRINT("_______________________dwc_otg flags_______________________________\n"); DWC_PRINT("core_if->op_state = %x\n",_core_if->op_state); DWC_PRINT("core_if->usb_mode = %x\n",_core_if->usb_mode); - DWC_PRINT("core_if->usb_wakeup = %x\n",_core_if->usb_wakeup); } #ifndef CONFIG_DWC_OTG_HOST_ONLY diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.h b/drivers/usb/dwc_otg/dwc_otg_cil.h index 6dadebf09ad8..f102c5919526 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.h +++ b/drivers/usb/dwc_otg/dwc_otg_cil.h @@ -609,10 +609,7 @@ typedef struct dwc_otg_core_if uint16_t rx_fifo_size; /** Size of Non-periodic Tx FIFO (Bytes) */ uint16_t nperio_tx_fifo_size; - - /** 1 if wakeup in system sleep mode, 0 otherwise */ - uint8_t usb_wakeup; - + /** 1 if DMA is enabled, 0 otherwise. */ uint8_t dma_enable; diff --git a/drivers/usb/dwc_otg/dwc_otg_driver.c b/drivers/usb/dwc_otg/dwc_otg_driver.c index df0d9bd40cb0..d1b18821f0f9 100755 --- a/drivers/usb/dwc_otg/dwc_otg_driver.c +++ b/drivers/usb/dwc_otg/dwc_otg_driver.c @@ -356,8 +356,6 @@ void dwc_otg_force_host(dwc_otg_core_if_t *core_if) printk("dwc_otg_force_host,already in A_HOST mode,everest\n"); return; } - if(pldata->phy_suspend) - pldata->phy_suspend(pldata,USB_PHY_ENABLED); del_timer(&otg_dev->pcd->check_vbus_timer); // force disconnect /* soft disconnect */ @@ -394,7 +392,6 @@ void dwc_otg_force_device(dwc_otg_core_if_t *core_if) otg_dev->core_if->op_state = B_PERIPHERAL; /* Reset the Controller */ dwc_otg_core_reset( core_if ); - //otg_dev->pcd->phy_suspend = 1; otg_dev->pcd->vbus_status = 0; dwc_otg_pcd_start_vbus_timer( otg_dev->pcd ); @@ -434,6 +431,11 @@ static ssize_t force_usb_mode_store(struct device_driver *_drv, const char *_buf { return _count; } + + if(pldata->phy_status==USB_PHY_SUSPEND){ + pldata->clock_enable(pldata, 1); + pldata->phy_suspend(pldata,USB_PHY_ENABLED); + } switch(new_mode) { @@ -482,8 +484,6 @@ static ssize_t force_usb_mode_store(struct device_driver *_drv, const char *_buf if(USB_MODE_FORCE_DEVICE == core_if->usb_mode) { core_if->usb_mode = new_mode; - if(pldata->phy_suspend) - pldata->phy_suspend(pldata,USB_PHY_ENABLED); del_timer(&otg_dev->pcd->check_vbus_timer); dwc_otg_set_gusbcfg(core_if, new_mode); msleep(50); @@ -502,8 +502,6 @@ static ssize_t force_usb_mode_store(struct device_driver *_drv, const char *_buf } else if(USB_MODE_FORCE_HOST == core_if->usb_mode) { - if(pldata->phy_suspend) - pldata->phy_suspend(pldata,USB_PHY_ENABLED); core_if->usb_mode = new_mode; dwc_otg_set_gusbcfg(core_if, new_mode); msleep(100); @@ -556,16 +554,19 @@ 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 ); } - if(pldata->phy_suspend) + if(pldata->phy_status==USB_PHY_ENABLED){ pldata->phy_suspend(pldata,USB_PHY_SUSPEND); - udelay(3); - pldata->clock_enable(pldata, 0); + udelay(3); + pldata->clock_enable(pldata, 0); + } } else if(val == 1) { DWC_PRINT("enable host controller:%s\n",pdev->name); - pldata->clock_enable(pldata, 1); - pldata->phy_suspend(pldata,USB_PHY_ENABLED); + if( pldata->phy_status == USB_PHY_SUSPEND ){ + pldata->clock_enable( pldata, 1); + pldata->phy_suspend(pldata, USB_PHY_ENABLED); + } mdelay(5); if (_core_if->hcd_cb && _core_if->hcd_cb->start) { _core_if->hcd_cb->start( _core_if->hcd_cb->p ); @@ -1159,6 +1160,9 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) struct dwc_otg_platform_data *pldata = dev->platform_data; // clock and hw init + if(pldata->hw_init) + pldata->hw_init(); + if(pldata->soft_reset) pldata->soft_reset(); @@ -1167,8 +1171,6 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) pldata->clock_enable(pldata, 1); } - if(pldata->hw_init) - pldata->hw_init(); if(pldata->phy_suspend) pldata->phy_suspend(pldata, USB_PHY_ENABLED); @@ -1369,8 +1371,13 @@ static int dwc_otg_driver_suspend(struct platform_device *_dev , pm_message_t st /* Clear any pending interrupts */ dwc_write_reg32( &core_if->core_global_regs->gintsts, 0xFFFFFFFF); dwc_otg_disable_global_interrupts(core_if); - pldata->phy_suspend(pldata,USB_PHY_SUSPEND); - del_timer(&otg_dev->pcd->check_vbus_timer); + if( pldata->phy_status == 0 ){ + /* no vbus detect here , close usb phy */ + pldata->phy_suspend(pldata, USB_PHY_SUSPEND); + udelay(3); + pldata->clock_enable( pldata, 0); + } +// del_timer(&otg_dev->pcd->check_vbus_timer); return 0; } @@ -1396,32 +1403,6 @@ static int dwc_otg_driver_resume(struct platform_device *_dev ) DWC_PRINT("%s,A_HOST mode\n", __func__); return 0; } -#ifndef CONFIG_DWC_OTG_HOST_ONLY - - pldata->phy_suspend(pldata,USB_PHY_ENABLED); - - /* soft disconnect */ - /* 20100226,HSL@RK,if not disconnect,when usb cable in,will auto reconnect - * besause now USB PHY is enable,and get USB RESET irq. - */ - /* soft disconnect */ - 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 ); - - /* Clear any pending interrupts */ - dwc_write_reg32( &global_regs->gintsts, 0xeFFFFFFF); - - dwc_otg_enable_global_interrupts(core_if); - mod_timer(&otg_dev->pcd->check_vbus_timer , jiffies + HZ); - -//sendwakeup: - if(core_if->usb_wakeup) - { - core_if->usb_wakeup = 0; - } - DWC_PRINT("%s gahbcfg:0x%x\n", __func__, global_regs->gahbcfg); -#endif return 0; } @@ -1546,6 +1527,9 @@ static __devinit int host20_driver_probe(struct platform_device *pdev) struct dwc_otg_platform_data *pldata = dev->platform_data; // clock and hw init + if(pldata->hw_init) + pldata->hw_init(); + if(pldata->soft_reset) pldata->soft_reset(); @@ -1554,8 +1538,6 @@ static __devinit int host20_driver_probe(struct platform_device *pdev) pldata->clock_enable(pldata, 1); } - if(pldata->hw_init) - pldata->hw_init(); if(pldata->phy_suspend) pldata->phy_suspend(pldata, USB_PHY_ENABLED); /* diff --git a/drivers/usb/dwc_otg/dwc_otg_hcd.c b/drivers/usb/dwc_otg/dwc_otg_hcd.c index acee5e211251..5018584f64d8 100755 --- a/drivers/usb/dwc_otg/dwc_otg_hcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_hcd.c @@ -70,7 +70,7 @@ static int dwc_otg_hcd_suspend(struct usb_hcd *hcd) DWC_PRINT("%s, usb device mode\n", __func__); return 0; } - if(!dwc_otg_hcd->host_enabled) + if(!(dwc_otg_hcd->host_enabled&1)) return 0; hprt0.d32 = dwc_read_reg32(core_if->host_if->hprt0); #ifdef CONFIG_USB_SUSPEND @@ -136,7 +136,7 @@ static int dwc_otg_hcd_resume(struct usb_hcd *hcd) return 0; } //#ifdef CONFIG_USB_SUSPEND - if(!dwc_otg_hcd->host_enabled) + if(!(dwc_otg_hcd->host_enabled&1)) return 0; //#endif #ifndef CONFIG_DWC_REMOTE_WAKEUP @@ -650,7 +650,7 @@ static void dwc_otg_hcd_enable(struct work_struct *work) } dwc_otg_hcd->host_enabled = dwc_otg_hcd->host_setenable; - if(dwc_otg_hcd->host_setenable == 0) // enable -> disable + if(dwc_otg_hcd->host_setenable == 2) // enable -> disable { DWC_PRINT("%s, disable host controller\n", __func__); #if 1 @@ -698,11 +698,11 @@ static void dwc_otg_hcd_connect_detect(unsigned long pdata) else{ // no device, suspend host if((dwc_read_reg32(core_if->host_if->hprt0) & 1) == 0) - dwc_otg_hcd->host_setenable = 0; + dwc_otg_hcd->host_setenable = 2; } - if(dwc_otg_hcd->host_setenable != dwc_otg_hcd->host_enabled){ - schedule_delayed_work(&dwc_otg_hcd->host_enable_work, 8); + if((dwc_otg_hcd->host_enabled)&&(dwc_otg_hcd->host_setenable != dwc_otg_hcd->host_enabled)){ + schedule_delayed_work(&dwc_otg_hcd->host_enable_work, 8); } // dwc_otg_hcd->connect_detect_timer.expires = jiffies + (HZ<<1); /* 1 s */ mod_timer(&dwc_otg_hcd->connect_detect_timer,jiffies + (HZ<<1)); diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c b/drivers/usb/dwc_otg/dwc_otg_pcd.c index 334882818001..31fae318a416 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c @@ -1766,9 +1766,10 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long data ) local_irq_save(flags); _pcd->check_vbus_timer.expires = jiffies + (HZ); /* 1 s */ if(!pldata->get_status(USB_STATUS_ID)){ // id low - - if( pldata->phy_status) - pldata->phy_suspend(pldata, USB_PHY_ENABLED); + if( pldata->phy_status){ + pldata->clock_enable( pldata, 1); + pldata->phy_suspend(pldata, USB_PHY_ENABLED); + } } else if(pldata->get_status(USB_STATUS_BVABLID)){ // bvalid /* if usb not connect before ,then start connect */ @@ -1806,7 +1807,6 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long data ) _pcd->conn_status = 0; dwc_otg_msc_unlock(_pcd); } - /* every 500 ms open usb phy power and start 1 jiffies timer to get vbus */ else if( pldata->phy_status == 0 ){ /* no vbus detect here , close usb phy */ pldata->phy_suspend(pldata, USB_PHY_SUSPEND); diff --git a/drivers/usb/dwc_otg/usbdev_rk30.c b/drivers/usb/dwc_otg/usbdev_rk30.c index acf5e4d798f4..2c3adc8dd965 100755 --- a/drivers/usb/dwc_otg/usbdev_rk30.c +++ b/drivers/usb/dwc_otg/usbdev_rk30.c @@ -145,11 +145,9 @@ void usb20otg_phy_suspend(void* pdata, int suspend) usbpdata->phy_status = 0; } #endif - } void usb20otg_soft_reset(void) { -#if 1 cru_set_soft_reset(SOFT_RST_USBOTG0, true); cru_set_soft_reset(SOFT_RST_USBPHY0, true); cru_set_soft_reset(SOFT_RST_OTGC0, true); @@ -159,7 +157,6 @@ void usb20otg_soft_reset(void) cru_set_soft_reset(SOFT_RST_USBPHY0, false); cru_set_soft_reset(SOFT_RST_OTGC0, false); mdelay(1); -#endif } void usb20otg_clock_init(void* pdata) { @@ -173,7 +170,7 @@ void usb20otg_clock_init(void* pdata) void usb20otg_clock_enable(void* pdata, int enable) { struct dwc_otg_platform_data *usbpdata=pdata; - #if 1 + if(enable){ clk_enable(usbpdata->ahbclk); clk_enable(usbpdata->phyclk); @@ -182,7 +179,6 @@ void usb20otg_clock_enable(void* pdata, int enable) clk_disable(usbpdata->phyclk); clk_disable(usbpdata->ahbclk); } - #endif } int usb20otg_get_status(int id) { @@ -258,8 +254,9 @@ struct dwc_otg_platform_data usb20otg_pdata = { .clock_init=usb20otg_clock_init, .clock_enable=usb20otg_clock_enable, .get_status=usb20otg_get_status, +#ifdef CONFIG_ARCH_RK3066B .power_enable=usb20otg_power_enable, - +#endif }; struct platform_device device_usb20_otg = { @@ -331,7 +328,6 @@ void usb20host_phy_suspend(void* pdata, int suspend) } void usb20host_soft_reset(void) { -#if 1 cru_set_soft_reset(SOFT_RST_USBOTG1, true); cru_set_soft_reset(SOFT_RST_USBPHY1, true); cru_set_soft_reset(SOFT_RST_OTGC1, true); @@ -341,7 +337,6 @@ void usb20host_soft_reset(void) cru_set_soft_reset(SOFT_RST_USBPHY1, false); cru_set_soft_reset(SOFT_RST_OTGC1, false); mdelay(1); -#endif } void usb20host_clock_init(void* pdata) { @@ -355,7 +350,7 @@ void usb20host_clock_init(void* pdata) void usb20host_clock_enable(void* pdata, int enable) { struct dwc_otg_platform_data *usbpdata=pdata; - #if 1 + if(enable){ clk_enable(usbpdata->ahbclk); clk_enable(usbpdata->phyclk); @@ -364,7 +359,6 @@ void usb20host_clock_enable(void* pdata, int enable) clk_disable(usbpdata->phyclk); clk_disable(usbpdata->ahbclk); } - #endif } int usb20host_get_status(int id) { @@ -441,7 +435,9 @@ struct dwc_otg_platform_data usb20host_pdata = { .clock_init=usb20host_clock_init, .clock_enable=usb20host_clock_enable, .get_status=usb20host_get_status, +#ifdef CONFIG_ARCH_RK3066B .power_enable=usb20host_power_enable, +#endif }; struct platform_device device_usb20_host = {