From: yangkai Date: Mon, 3 Sep 2012 02:40:26 +0000 (+0800) Subject: rk3066b usb update X-Git-Tag: firefly_0821_release~8757 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e9e325263cb7053b0325666bda8990f0cea04c10;p=firefly-linux-kernel-4.4.55.git rk3066b usb update --- diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.c b/drivers/usb/dwc_otg/dwc_otg_cil.c index 406aad103928..87c0319494ca 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil.c @@ -66,6 +66,7 @@ #include "dwc_otg_driver.h" #include "dwc_otg_cil.h" #include "dwc_otg_pcd.h" +#include "usbdev_rk.h" static dwc_otg_core_if_t * dwc_core_if = NULL; /** * This function is called to initialize the DWC_otg CSR data @@ -917,6 +918,8 @@ void dwc_otg_core_host_init(dwc_otg_core_if_t *_core_if) dwc_otg_hc_regs_t *hc_regs; int num_channels; gotgctl_data_t gotgctl = {.d32 = 0}; + struct dwc_otg_platform_data *pldata; + pldata = _core_if->otg_dev->pldata; DWC_DEBUGPL(DBG_CILV,"%s(%p)\n", __func__, _core_if); @@ -1018,6 +1021,8 @@ void dwc_otg_core_host_init(dwc_otg_core_if_t *_core_if) hprt0.b.prtpwr = 1; dwc_write_reg32(host_if->hprt0, hprt0.d32); } + if(pldata->power_enable) + pldata->power_enable(1); } dwc_otg_enable_host_interrupts( _core_if ); diff --git a/drivers/usb/dwc_otg/dwc_otg_hcd.c b/drivers/usb/dwc_otg/dwc_otg_hcd.c index bf8cb979e659..1324a86abfa7 100755 --- a/drivers/usb/dwc_otg/dwc_otg_hcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_hcd.c @@ -858,32 +858,12 @@ int __devinit dwc_otg_hcd_init(struct device *dev) } #ifdef CONFIG_USB11_HOST -/* - * suspend: 0 usb phy enable - * 1 usb phy suspend - */ -static int32_t host11_phy_suspend_cb( void *_p, int suspend) -{ - unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); - - if(suspend) { - *otg_phy_con1 &= ~(0x01<<28); - DWC_DEBUGPL(DBG_PCDV, "enable usb phy\n"); - } - else - { - *otg_phy_con1 |= (0x01<<28); - DWC_DEBUGPL(DBG_PCDV, "disable usb phy\n"); - } - - return suspend; -} + static dwc_otg_cil_callbacks_t host11_cil_callbacks = { .start = dwc_otg_hcd_start_cb, .stop = dwc_otg_hcd_stop_cb, .disconnect = dwc_otg_hcd_disconnect_cb, .session_start = dwc_otg_hcd_session_start_cb, - .suspend = host11_phy_suspend_cb, .p = 0,//hcd }; @@ -1363,6 +1343,8 @@ void dwc_otg_hcd_stop(struct usb_hcd *_hcd) { dwc_otg_hcd_t *dwc_otg_hcd = hcd_to_dwc_otg_hcd (_hcd); hprt0_data_t hprt0 = { .d32=0 }; + struct dwc_otg_platform_data *pldata; + pldata = dwc_otg_hcd->core_if->otg_dev->pldata; DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD STOP\n"); @@ -1380,6 +1362,8 @@ void dwc_otg_hcd_stop(struct usb_hcd *_hcd) hprt0.b.prtpwr = 0; dwc_write_reg32(dwc_otg_hcd->core_if->host_if->hprt0, hprt0.d32); + if(pldata->power_enable) + pldata->power_enable(0); return; } diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c b/drivers/usb/dwc_otg/dwc_otg_pcd.c index 29cbeff1bc7a..cb9a149d95ce 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c @@ -1664,7 +1664,7 @@ static void dwc_phy_reconnect(struct work_struct *work) DWC_PRINT("********soft connect!!!*****************************************\n"); } } -#if defined(CONFIG_ARCH_RK29) || defined(CONFIG_ARCH_RK3066B) +#if defined(CONFIG_ARCH_RK29) static void dwc_otg_pcd_check_vbus_timer( unsigned long pdata ) { struct device *_dev = (struct device *)pdata; @@ -1821,106 +1821,6 @@ connect: return; } #endif -#if 0 //def CONFIG_ARCH_RK30 -int dwc_otg_check_dpdm(void) -{ - static uint8_t * reg_base = 0; - volatile unsigned int * otg_dctl; - volatile unsigned int * otg_gotgctl; - volatile unsigned int * otg_hprt0; - int bus_status = 0; - unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON2); - - // softreset & clockgate - *(unsigned int*)(RK30_CRU_BASE+0x120) = ((7<<5)<<16)|(7<<5); // otg0 phy clkgate - udelay(3); - *(unsigned int*)(RK30_CRU_BASE+0x120) = ((7<<5)<<16)|(0<<5); // otg0 phy clkgate - dsb(); - *(unsigned int*)(RK30_CRU_BASE+0xd4) = ((1<<5)<<16); // otg0 phy clkgate - *(unsigned int*)(RK30_CRU_BASE+0xe4) = ((1<<13)<<16); // otg0 hclk clkgate - *(unsigned int*)(RK30_CRU_BASE+0xe0) = ((3<<5)<<16); // hclk usb clkgate - - // exit phy suspend - *otg_phy_con1 = ((0x01<<2)<<16); // exit suspend. - - // soft connect - if(reg_base == 0){ - reg_base = ioremap(RK30_USBOTG20_PHYS,USBOTG_SIZE); - if(!reg_base){ - bus_status = -1; - goto out; - } - } - mdelay(105); - printk("regbase %p 0x%x, otg_phy_con%p, 0x%x\n", - reg_base, *(reg_base), otg_phy_con1, *otg_phy_con1); - otg_dctl = (unsigned int * )(reg_base+0x804); - otg_gotgctl = (unsigned int * )(reg_base); - otg_hprt0 = (unsigned int * )(reg_base + DWC_OTG_HOST_PORT_REGS_OFFSET); - if(*otg_gotgctl &(1<<19)){ - bus_status = 1; - *otg_dctl &= ~2; - mdelay(50); // delay about 10ms - // check dp,dm - if((*otg_hprt0 & 0xc00)==0xc00) - bus_status = 2; - } -out: - return bus_status; -} - -EXPORT_SYMBOL(dwc_otg_check_dpdm); -#endif -#ifdef CONFIG_ARCH_RK2928 -int dwc_otg_check_dpdm(void) -{ - static uint8_t * reg_base = 0; - volatile unsigned int * otg_dctl; - volatile unsigned int * otg_gotgctl; - volatile unsigned int * otg_hprt0; - int bus_status = 0; - unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON5);//@lyz modify UOC0_CON2 to CON5 - - // softreset & clockgate //@lyz modify RK2928_CRU_BASE - *(unsigned int*)(RK2928_CRU_BASE+0x120) = ((7<<5)<<16)|(7<<5); // otg0 phy clkgate - udelay(3); - *(unsigned int*)(RK2928_CRU_BASE+0x120) = ((7<<5)<<16)|(0<<5); // otg0 phy clkgate - dsb(); - *(unsigned int*)(RK2928_CRU_BASE+0xd4) = ((1<<5)<<16); // otg0 phy clkgate - *(unsigned int*)(RK2928_CRU_BASE+0xe4) = ((1<<13)<<16); // otg0 hclk clkgate - *(unsigned int*)(RK2928_CRU_BASE+0xf4) = ((3<<10)<<16); // hclk usb clkgate//@lyz to be check - - // exit phy suspend - *otg_phy_con1 = ((0x01<<0)<<16); // exit suspend.@lyz - - // soft connect - if(reg_base == 0){ - reg_base = ioremap(RK2928_USBOTG20_PHYS,USBOTG_SIZE);//@lyz - if(!reg_base){ - bus_status = -1; - goto out; - } - } - mdelay(105); - printk("regbase %p 0x%x, otg_phy_con%p, 0x%x\n", - reg_base, *(reg_base), otg_phy_con1, *otg_phy_con1); - otg_dctl = (unsigned int * )(reg_base+0x804); - otg_gotgctl = (unsigned int * )(reg_base); - otg_hprt0 = (unsigned int * )(reg_base + DWC_OTG_HOST_PORT_REGS_OFFSET); - if(*otg_gotgctl &(1<<19)){ - bus_status = 1; - *otg_dctl &= ~(0x01<<1);//@lyz exit soft-disconnect mode - mdelay(50); // delay about 10ms - // check dp,dm - if((*otg_hprt0 & 0xc00)==0xc00)//@lyz check hprt[11:10] - bus_status = 2; - } -out: - return bus_status; -} - -EXPORT_SYMBOL(dwc_otg_check_dpdm); -#endif void dwc_otg_pcd_start_vbus_timer( dwc_otg_pcd_t * _pcd ) { struct timer_list *vbus_timer = &_pcd->check_vbus_timer; diff --git a/drivers/usb/dwc_otg/usbdev_rk30.c b/drivers/usb/dwc_otg/usbdev_rk30.c index c4ffc03832d9..0d6f0e940984 100755 --- a/drivers/usb/dwc_otg/usbdev_rk30.c +++ b/drivers/usb/dwc_otg/usbdev_rk30.c @@ -10,6 +10,7 @@ #include #include "usbdev_rk.h" +#include "dwc_otg_regs.h" #ifdef CONFIG_ARCH_RK30 #define GRF_REG_BASE RK30_GRF_BASE @@ -23,7 +24,55 @@ #define USBGRF_UOC0_CON2 (GRF_REG_BASE+0x184) #define USBGRF_UOC1_CON2 (GRF_REG_BASE+0x190) #endif -//#define USB_IOMUX_INIT(a,b) rk30_mux_api_set(a,b) + +int dwc_otg_check_dpdm(void) +{ + static uint8_t * reg_base = 0; + volatile unsigned int * otg_dctl; + volatile unsigned int * otg_gotgctl; + volatile unsigned int * otg_hprt0; + int bus_status = 0; + unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON2); + + // softreset & clockgate + *(unsigned int*)(RK30_CRU_BASE+0x120) = ((7<<5)<<16)|(7<<5); // otg0 phy clkgate + udelay(3); + *(unsigned int*)(RK30_CRU_BASE+0x120) = ((7<<5)<<16)|(0<<5); // otg0 phy clkgate + dsb(); + *(unsigned int*)(RK30_CRU_BASE+0xd4) = ((1<<5)<<16); // otg0 phy clkgate + *(unsigned int*)(RK30_CRU_BASE+0xe4) = ((1<<13)<<16); // otg0 hclk clkgate + *(unsigned int*)(RK30_CRU_BASE+0xe0) = ((3<<5)<<16); // hclk usb clkgate + + // exit phy suspend + *otg_phy_con1 = ((0x01<<2)<<16); // exit suspend. + + // soft connect + if(reg_base == 0){ + reg_base = ioremap(RK30_USBOTG20_PHYS,USBOTG_SIZE); + if(!reg_base){ + bus_status = -1; + goto out; + } + } + mdelay(105); + printk("regbase %p 0x%x, otg_phy_con%p, 0x%x\n", + reg_base, *(reg_base), otg_phy_con1, *otg_phy_con1); + otg_dctl = (unsigned int * )(reg_base+0x804); + otg_gotgctl = (unsigned int * )(reg_base); + otg_hprt0 = (unsigned int * )(reg_base + DWC_OTG_HOST_PORT_REGS_OFFSET); + if(*otg_gotgctl &(1<<19)){ + bus_status = 1; + *otg_dctl &= ~2; + mdelay(50); // delay about 10ms + // check dp,dm + if((*otg_hprt0 & 0xc00)==0xc00) + bus_status = 2; + } +out: + return bus_status; +} + +EXPORT_SYMBOL(dwc_otg_check_dpdm); #ifdef CONFIG_USB20_OTG /*DWC_OTG*/ @@ -114,18 +163,33 @@ int usb20otg_get_status(int id) unsigned int usbgrf_status = *(unsigned int*)(USBGRF_SOC_STATUS0); switch(id) { - case 0x01: +#ifdef CONFIG_ARCH_RK3066B + case USB_STATUS_BVABLID: + // bvalid in grf + ret = (usbgrf_status &(1<<10)); + break; + case USB_STATUS_DPDM: + // dpdm in grf + ret = (usbgrf_status &(3<<11)); + break; + case USB_STATUS_ID: + // id in grf + ret = (usbgrf_status &(1<<13)); + break; +#else + case USB_STATUS_BVABLID: // bvalid in grf ret = (usbgrf_status &0x20000); break; - case 0x02: + case USB_STATUS_DPDM: // dpdm in grf ret = (usbgrf_status &(3<<18)); break; - case 0x03: + case USB_STATUS_ID: // id in grf ret = (usbgrf_status &(1<<20)); break; +#endif default: break; } @@ -188,11 +252,11 @@ void usb20host_phy_suspend(void* pdata, int suspend) unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC1_CON2); if(suspend){ *otg_phy_con1 = 0x554|(0xfff<<16); // enter suspend. - usbpdata->phy_status = 0; + usbpdata->phy_status = 1; } else{ *otg_phy_con1 = ((0x01<<2)<<16); // exit suspend. - usbpdata->phy_status = 1; + usbpdata->phy_status = 0; } } void usb20host_soft_reset(void) @@ -238,6 +302,20 @@ int usb20host_get_status(int id) unsigned int usbgrf_status = *(unsigned int*)(USBGRF_SOC_STATUS0); switch(id) { +#ifdef CONFIG_ARCH_RK3066B + case USB_STATUS_BVABLID: + // bvalid in grf + ret = (usbgrf_status &(1<<17)); + break; + case USB_STATUS_DPDM: + // dpdm in grf + ret = (usbgrf_status &(3<<18)); + break; + case USB_STATUS_ID: + // id in grf + ret = (usbgrf_status &(1<<20)); + break; +#else case USB_STATUS_BVABLID: // bvalid in grf ret = (usbgrf_status &(1<<22)); @@ -250,6 +328,7 @@ int usb20host_get_status(int id) // id in grf ret = 0; break; +#endif default: break; } @@ -289,6 +368,7 @@ static int __init usbdev_init_devices(void) #ifdef CONFIG_USB20_HOST platform_device_register(&device_usb20_host); #endif + return 0; } arch_initcall(usbdev_init_devices); -#endif \ No newline at end of file +#endif