From: yangkai Date: Sat, 24 Mar 2012 11:42:20 +0000 (+0800) Subject: add usb device driver for rk30 X-Git-Tag: firefly_0821_release~9595^2~10 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=21d3669fbc85f781a5fb3cc36dd44ea0c6fd4b5b;p=firefly-linux-kernel-4.4.55.git add usb device driver for rk30 --- diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c index 035342158caf..a62602a4b3ba 100755 --- a/arch/arm/mach-rk30/devices.c +++ b/arch/arm/mach-rk30/devices.c @@ -16,6 +16,9 @@ #include #include #include +#ifdef CONFIG_USB_ANDROID +#include +#endif #include #include #include @@ -927,6 +930,51 @@ static void __init rk30_init_i2s(void) #endif platform_device_register(&device_pcm); } +#ifdef CONFIG_USB20_OTG +/*DWC_OTG*/ +static struct resource usb20_otg_resource[] = { + { + .start = IRQ_USB_OTG, + .end = IRQ_USB_OTG, + .flags = IORESOURCE_IRQ, + }, + { + .start = RK30_USBOTG20_PHYS, + .end = RK30_USBOTG20_PHYS + RK30_USBOTG20_SIZE - 1, + .flags = IORESOURCE_MEM, + }, + +}; + +struct platform_device device_usb20_otg = { + .name = "usb20_otg", + .id = -1, + .num_resources = ARRAY_SIZE(usb20_otg_resource), + .resource = usb20_otg_resource, +}; +#endif +#ifdef CONFIG_USB20_HOST +static struct resource usb20_host_resource[] = { + { + .start = IRQ_USB_HOST, + .end = IRQ_USB_HOST, + .flags = IORESOURCE_IRQ, + }, + { + .start = RK30_USBHOST20_PHYS, + .end = RK30_USBHOST20_PHYS + RK30_USBHOST20_SIZE - 1, + .flags = IORESOURCE_MEM, + }, + +}; + +struct platform_device device_usb20_host = { + .name = "usb20_host", + .id = -1, + .num_resources = ARRAY_SIZE(usb20_host_resource), + .resource = usb20_host_resource, +}; +#endif #ifdef CONFIG_KEYS_RK29 extern struct rk29_keys_platform_data rk29_keys_pdata; @@ -1011,6 +1059,12 @@ static int __init rk30_init_devices(void) #ifdef CONFIG_KEYS_RK29 platform_device_register(&device_keys); #endif +#ifdef CONFIG_USB20_OTG + platform_device_register(&device_usb20_otg); +#endif +#ifdef CONFIG_USB20_HOST + platform_device_register(&device_usb20_host); +#endif #ifdef CONFIG_RGA_RK30 platform_device_register(&device_rga); #endif diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.c b/drivers/usb/dwc_otg/dwc_otg_cil.c index d0fdfbd44dae..a259a6923ec3 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil.c @@ -3255,6 +3255,7 @@ void dwc_otg_dump_global_registers(dwc_otg_core_if_t *_core_if) void dump_scu_regs(void) { +#ifdef CONFIG_ARCH_RK29 int regvalue; DWC_PRINT("_______________________System Regs________________________________\n"); regvalue = dwc_read_reg32((uint32_t *)(SCU_BASE_ADDR_VA+0x00)); @@ -3329,6 +3330,7 @@ void dump_scu_regs(void) DWC_PRINT("USB_PHY_CON1: 0x%08x\n",regvalue); regvalue = dwc_read_reg32((uint32_t *)(USB_GRF_IOMUX)); DWC_PRINT("GRF_GPIO4L_IOMUX: 0x%08x\n",regvalue); +#endif } void dwc_otg_dump_flags(dwc_otg_core_if_t *_core_if) { diff --git a/drivers/usb/dwc_otg/dwc_otg_driver.c b/drivers/usb/dwc_otg/dwc_otg_driver.c index a38c80a3ae2e..7cd74ca76899 100755 --- a/drivers/usb/dwc_otg/dwc_otg_driver.c +++ b/drivers/usb/dwc_otg/dwc_otg_driver.c @@ -68,9 +68,9 @@ #include "dwc_otg_cil.h" #include "dwc_otg_pcd.h" #include "dwc_otg_hcd.h" - +#ifdef CONFIG_ARCH_RK29 #include - +#endif //#define DWC_DRIVER_VERSION "2.60a 22-NOV-2006" //#define DWC_DRIVER_VERSION "2.70 2009-12-31" #define DWC_DRIVER_VERSION "3.00 2010-12-12 rockchip" @@ -1191,10 +1191,15 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) int irq; int32_t regval; struct clk *ahbclk,*phyclk,*busclk; +#ifdef CONFIG_ARCH_RK29 unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); - +#endif +#ifdef CONFIG_ARCH_RK30 + unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON2); +#endif regval = * otg_phy_con1; +#ifdef CONFIG_ARCH_RK29 #ifndef CONFIG_USB11_HOST /* * disable usb host 1.1 controller if not support @@ -1251,13 +1256,7 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) clk_disable(phyclk); clk_disable(ahbclk); #endif - - #if 0 - otgreg = ioremap(RK2818_USBOTG_PHYS,RK2818_USBOTG_SIZE); - DWC_PRINT("otgreg 0x%x",otgreg); - dwc_modify_reg32((uint32_t *)(otgreg+0xc),0x20000000,0x20000000); - dwc_write_reg32((uint32_t *)(otgreg+0x440), 0x1000); - #endif +#endif dwc_otg_device = kmalloc(sizeof(dwc_otg_device_t), GFP_KERNEL); @@ -1271,6 +1270,7 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) memset(dwc_otg_device, 0, sizeof(*dwc_otg_device)); dwc_otg_device->reg_offset = 0xFFFFFFFF; +#ifdef CONFIG_ARCH_RK29 cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_AHB_BUS, true); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_PHY, true); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_CONTROLLER, true); @@ -1279,7 +1279,6 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_AHB_BUS, false); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_PHY, false); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_CONTROLLER, false); - busclk = clk_get(NULL, "hclk_usb_peri"); if (IS_ERR(busclk)) { retval = PTR_ERR(busclk); @@ -1316,6 +1315,7 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) dwc_otg_device->phyclk = phyclk; dwc_otg_device->ahbclk = ahbclk; dwc_otg_device->busclk = busclk; +#endif /* * Map the DWC_otg Core memory into virtual address space. */ @@ -1446,7 +1446,12 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) /* Initialize the bus state. If the core is in Device Mode * HALT the USB bus and return. */ #ifndef CONFIG_DWC_OTG_DEVICE_ONLY +#ifdef CONFIG_ARCH_RK29 USB_IOMUX_INIT(GPIO4A5_OTG0DRVVBUS_NAME, GPIO4L_OTG0_DRV_VBUS); +#endif +#ifdef CONFIG_ARCH_RK30 + USB_IOMUX_INIT(GPIO0A5_OTGDRVVBUS_NAME, GPIO0A_OTG_DRV_VBUS); +#endif /* * Initialize the HCD */ @@ -1477,6 +1482,7 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) * handlers are installed. */ dwc_otg_enable_global_interrupts( dwc_otg_device->core_if ); +#ifdef CONFIG_ARCH_RK29 #ifndef CONFIG_DWC_OTG_DEVICE_ONLY if(dwc_otg_device->hcd->host_enabled == 0) { @@ -1485,6 +1491,7 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) *otg_phy_con1 |= (0x01<<2); *otg_phy_con1 &= ~(0x01<<3); // enter suspend. } +#endif #endif return 0; fail: @@ -1511,8 +1518,6 @@ static int dwc_otg_driver_suspend(struct platform_device *_dev , pm_message_t st rk28_usb_suspend(0); del_timer(&otg_dev->pcd->check_vbus_timer); - //DWC_PRINT("CRU_CLKGATE1_CON: 0x%08x\n",dwc_read_reg32((uint32_t *)(SCU_BASE_ADDR_VA+0x60))); - //DWC_PRINT("USB_PHY_CON1: 0x%08x\n",dwc_read_reg32((uint32_t *)(USB_GRF_CON))); return 0; } #else @@ -1972,7 +1977,12 @@ static __devinit int host20_driver_probe(struct platform_device *pdev) /* *Enable usb phy */ +#ifdef CONFIG_ARCH_RK29 unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); +#endif +#ifdef CONFIG_ARCH_RK30 + unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC1_CON2); +#endif otgreg = * otg_phy_con1; otgreg |= (0x01<<13); // software control @@ -1991,6 +2001,7 @@ static __devinit int host20_driver_probe(struct platform_device *pdev) dwc_otg_device = kmalloc(sizeof(dwc_otg_device_t), GFP_KERNEL); +#ifdef CONFIG_ARCH_RK29 cru_set_soft_reset(SOFT_RST_USB_HOST_2_0_AHB_BUS, true); cru_set_soft_reset(SOFT_RST_USB_HOST_2_0_PHY, true); cru_set_soft_reset(SOFT_RST_USB_HOST_2_0_CONTROLLER, true); @@ -2000,7 +2011,7 @@ static __devinit int host20_driver_probe(struct platform_device *pdev) cru_set_soft_reset(SOFT_RST_USB_HOST_2_0_AHB_BUS, false); cru_set_soft_reset(SOFT_RST_USB_HOST_2_0_PHY, false); cru_set_soft_reset(SOFT_RST_USB_HOST_2_0_CONTROLLER, false); - +#endif if (dwc_otg_device == 0) { dev_err(dev, "kmalloc of dwc_otg_device failed\n"); @@ -2019,7 +2030,12 @@ static __devinit int host20_driver_probe(struct platform_device *pdev) } clk_enable(phyclk); +#ifdef CONFIG_ARCH_RK29 ahbclk = clk_get(NULL, "usbotg1"); +#endif +#ifdef CONFIG_ARCH_RK30 + ahbclk = clk_get(NULL, "hclk_otg1"); +#endif if (IS_ERR(ahbclk)) { retval = PTR_ERR(ahbclk); DWC_ERROR("can't get USBOTG1 ahb bus clock\n"); @@ -2119,8 +2135,13 @@ static __devinit int host20_driver_probe(struct platform_device *pdev) { dwc_otg_device->common_irq_installed = 1; } - + +#ifdef CONFIG_ARCH_RK29 USB_IOMUX_INIT(GPIO4A6_OTG1DRVVBUS_NAME, GPIO4L_OTG1_DRV_VBUS); +#endif +#ifdef CONFIG_ARCH_RK30 + USB_IOMUX_INIT(GPIO0A6_HOSTDRVVBUS_NAME, GPIO0A_HOST_DRV_VBUS); +#endif /* * Initialize the DWC_otg core. */ diff --git a/drivers/usb/dwc_otg/dwc_otg_hcd.c b/drivers/usb/dwc_otg/dwc_otg_hcd.c index 6540e720b47d..b13da8738860 100755 --- a/drivers/usb/dwc_otg/dwc_otg_hcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_hcd.c @@ -586,6 +586,7 @@ static int32_t dwc_otg_hcd_session_start_cb( void *_p ) */ static int32_t dwc_otg_phy_suspend_cb( void *_p, int suspend) { +#ifdef CONFIG_ARCH_RK29 unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); if(suspend) { @@ -601,7 +602,7 @@ static int32_t dwc_otg_phy_suspend_cb( void *_p, int suspend) *otg_phy_con1 &= ~(0x01<<3); // enter suspend. DWC_DEBUGPL(DBG_PCDV, "disable usb phy\n"); } - +#endif return suspend; } @@ -693,9 +694,6 @@ int __devinit dwc_otg_hcd_init(struct device *dev) /* Initialize the DWC OTG HCD. */ dwc_otg_hcd = hcd_to_dwc_otg_hcd(hcd); - - spin_lock_init(&dwc_otg_hcd->global_lock); - dwc_otg_hcd->core_if = otg_dev->core_if; otg_dev->hcd = dwc_otg_hcd; @@ -887,8 +885,6 @@ int __devinit host11_hcd_init(struct device *dev) dwc_otg_hcd->host_enabled = 0; #endif - spin_lock_init(&dwc_otg_hcd->global_lock); - /* Register the HCD CIL Callbacks */ dwc_otg_cil_register_hcd_callbacks(otg_dev->core_if, @@ -966,8 +962,8 @@ int __devinit host11_hcd_init(struct device *dev) goto error3; } -// DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD Initialized HCD, bus=%s, usbbus=%d\n", -// dev->bus_id, hcd->self.busnum); + DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD Initialized HCD, bus=%s, usbbus=%d\n", + _lmdev->dev.bus_id, hcd->self.busnum); return 0; @@ -991,6 +987,7 @@ int __devinit host11_hcd_init(struct device *dev) */ static int32_t host20_phy_suspend_cb( void *_p, int suspend) { +#ifdef CONFIG_ARCH_RK29 unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); uint32_t regval; @@ -1009,7 +1006,7 @@ static int32_t host20_phy_suspend_cb( void *_p, int suspend) DWC_DEBUGPL(DBG_PCDV, "disable usb phy\n"); } *otg_phy_con1 = regval; - +#endif return suspend; } @@ -1081,8 +1078,6 @@ int __devinit host20_hcd_init(struct device *dev) dwc_otg_hcd->host_enabled = 0; #endif - spin_lock_init(&dwc_otg_hcd->global_lock); - /* Register the HCD CIL Callbacks */ dwc_otg_cil_register_hcd_callbacks(otg_dev->core_if, @@ -1248,12 +1243,10 @@ int dwc_otg_hcd_start(struct usb_hcd *_hcd) { dwc_otg_hcd_t *dwc_otg_hcd = hcd_to_dwc_otg_hcd (_hcd); dwc_otg_core_if_t *core_if = dwc_otg_hcd->core_if; - unsigned long flags; struct usb_bus *bus; DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD START\n"); - spin_lock_irqsave(&dwc_otg_hcd->global_lock, flags); bus = hcd_to_bus(_hcd); _hcd->state = HC_STATE_RUNNING; @@ -1292,7 +1285,6 @@ int dwc_otg_hcd_start(struct usb_hcd *_hcd) } hcd_reinit(dwc_otg_hcd); out: - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); return 0; } @@ -1511,7 +1503,6 @@ int dwc_otg_hcd_urb_enqueue(struct usb_hcd *_hcd, int retval; dwc_otg_hcd_t * dwc_otg_hcd = hcd_to_dwc_otg_hcd(_hcd); dwc_otg_qtd_t * qtd; - unsigned long flags; #if 0 retval = usb_hcd_link_urb_to_ep(_hcd, _urb); if (retval) @@ -1520,7 +1511,6 @@ int dwc_otg_hcd_urb_enqueue(struct usb_hcd *_hcd, return retval; } #endif - spin_lock_irqsave(&dwc_otg_hcd->global_lock, flags); #if 1 /* * Make sure the start of frame interrupt is enabled now that @@ -1555,7 +1545,6 @@ int dwc_otg_hcd_urb_enqueue(struct usb_hcd *_hcd, dwc_otg_hcd_qtd_free(qtd); } out: - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); return retval; } @@ -1572,6 +1561,7 @@ int dwc_otg_hcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb, int _status) //int retval; DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD URB Dequeue\n"); + local_irq_save(flags); urb_qtd = (dwc_otg_qtd_t *) _urb->hcpriv; if(_ep==NULL) { @@ -1580,14 +1570,6 @@ int dwc_otg_hcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb, int _status) return -1; } qh = (dwc_otg_qh_t *) _ep->hcpriv; - spin_lock_irqsave(&dwc_otg_hcd->global_lock, flags); - #if 0 - retval = usb_hcd_check_unlink_urb(_hcd, _urb, _status); - if (retval) { - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); - return retval; - } - #endif if(urb_qtd == NULL) { DWC_PRINT("%s,urb_qtd is null\n",__func__); @@ -1605,7 +1587,7 @@ int dwc_otg_hcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb, int _status) } #endif /* */ -#if 1 + if (urb_qtd == qh->qtd_in_process) { /* The QTD is in process (it has been assigned to a channel). */ if (dwc_otg_hcd->flags.b.port_connect_status) { @@ -1634,10 +1616,9 @@ int dwc_otg_hcd_urb_dequeue(struct usb_hcd *_hcd, struct urb *_urb, int _status) } else if (list_empty(&qh->qtd_list)) { dwc_otg_hcd_qh_remove(dwc_otg_hcd, qh); } -#endif + local_irq_restore(flags); urb_qtd_null: - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); _urb->hcpriv = NULL; //usb_hcd_unlink_urb_from_ep(_hcd, _urb); /* Higher layer software sets URB status. */ @@ -1657,12 +1638,9 @@ void dwc_otg_hcd_endpoint_disable(struct usb_hcd *_hcd, struct usb_host_endpoint *_ep) { - unsigned long flags; dwc_otg_qh_t *qh; dwc_otg_hcd_t *dwc_otg_hcd = hcd_to_dwc_otg_hcd(_hcd); - spin_lock_irqsave(&dwc_otg_hcd->global_lock, flags); - DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD EP DISABLE: _bEndpointAddress=0x%02x, " "endpoint=%d\n", _ep->desc.bEndpointAddress, dwc_ep_addr_to_endpoint(_ep->desc.bEndpointAddress)); @@ -1681,8 +1659,6 @@ void dwc_otg_hcd_endpoint_disable(struct usb_hcd *_hcd, _ep->hcpriv = NULL; } - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); - return; } @@ -1693,17 +1669,8 @@ void dwc_otg_hcd_endpoint_disable(struct usb_hcd *_hcd, * This function is called by the USB core when an interrupt occurs */ irqreturn_t dwc_otg_hcd_irq(struct usb_hcd *_hcd) { - irqreturn_t result; - unsigned long flags; dwc_otg_hcd_t *dwc_otg_hcd = hcd_to_dwc_otg_hcd (_hcd); - - spin_lock_irqsave(&dwc_otg_hcd->global_lock, flags); - - result = IRQ_RETVAL(dwc_otg_hcd_handle_intr(dwc_otg_hcd)); - - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); - - return result; + return IRQ_RETVAL(dwc_otg_hcd_handle_intr(dwc_otg_hcd)); } /** Creates Status Change bitmap for the root hub and root port. The bitmap is @@ -2262,7 +2229,6 @@ int dwc_otg_hcd_hub_control(struct usb_hcd *_hcd, u16 _wLength) { int retval = 0; - unsigned long flags; dwc_otg_hcd_t *dwc_otg_hcd = hcd_to_dwc_otg_hcd (_hcd); dwc_otg_core_if_t *core_if = hcd_to_dwc_otg_hcd (_hcd)->core_if; @@ -2270,7 +2236,6 @@ int dwc_otg_hcd_hub_control(struct usb_hcd *_hcd, hprt0_data_t hprt0 = {.d32 = 0}; uint32_t port_status; - spin_lock_irqsave(&dwc_otg_hcd->global_lock, flags); switch (_typeReq) { case ClearHubFeature: @@ -2527,13 +2492,11 @@ int dwc_otg_hcd_hub_control(struct usb_hcd *_hcd, hprt0.b.prtrst = 1; dwc_write_reg32(core_if->host_if->hprt0, hprt0.d32); } - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); /* Clear reset bit in 10ms (FS/LS) or 50ms (HS) */ // kever @rk 20110712 // can not use mdelay(60) while irq disable //MDELAY (60); msleep(60); - spin_lock_irqsave(&dwc_otg_hcd->global_lock, flags); hprt0.b.prtrst = 0; dwc_write_reg32(core_if->host_if->hprt0, hprt0.d32); break; @@ -2666,7 +2629,6 @@ int dwc_otg_hcd_hub_control(struct usb_hcd *_hcd, break; } - spin_unlock_irqrestore(&dwc_otg_hcd->global_lock, flags); return retval; } @@ -3267,12 +3229,9 @@ __acquires(_hcd->lock) } #endif - + _urb->status = _status; _urb->hcpriv = NULL; - //usb_hcd_unlink_urb_from_ep(dwc_otg_hcd_to_hcd(_hcd), _urb); - spin_unlock(&_hcd->lock); usb_hcd_giveback_urb(dwc_otg_hcd_to_hcd(_hcd), _urb, _status); - spin_lock(&_hcd->lock); } void dwc_otg_clear_halt(struct urb *_urb) diff --git a/drivers/usb/dwc_otg/dwc_otg_hcd.h b/drivers/usb/dwc_otg/dwc_otg_hcd.h index 079a69950878..0eb5c19c4c4d 100755 --- a/drivers/usb/dwc_otg/dwc_otg_hcd.h +++ b/drivers/usb/dwc_otg/dwc_otg_hcd.h @@ -366,8 +366,6 @@ typedef struct dwc_otg_hcd { /* Tasket to do a reset */ struct tasklet_struct *reset_tasklet; - spinlock_t global_lock; - #ifdef DEBUG uint32_t frrem_samples; uint64_t frrem_accum; diff --git a/drivers/usb/dwc_otg/dwc_otg_hcd_queue.c b/drivers/usb/dwc_otg/dwc_otg_hcd_queue.c index 49b0bcab3caf..2d71e478f25b 100755 --- a/drivers/usb/dwc_otg/dwc_otg_hcd_queue.c +++ b/drivers/usb/dwc_otg/dwc_otg_hcd_queue.c @@ -253,7 +253,7 @@ static int periodic_channel_available(dwc_otg_hcd_t *_hcd) * non-periodic transactions. */ int status; -#if 0 +#ifdef CONFIG_ARCH_RK30 int num_channels; num_channels = _hcd->core_if->core_params->host_channels; @@ -411,12 +411,10 @@ static int schedule_periodic(dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh) */ int dwc_otg_hcd_qh_add (dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh) { + unsigned long flags; int status = 0; - if (!spin_is_locked(&_hcd->global_lock)) { - //pr_err("%s don't have hcd->global_lock\n", __func__); - //BUG(); - } + local_irq_save(flags); if (!list_empty(&_qh->qh_list_entry)) { /* QH already in a schedule. */ @@ -432,7 +430,7 @@ int dwc_otg_hcd_qh_add (dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh) } done: - //local_irq_restore(flags); + local_irq_restore(flags); return status; } @@ -475,10 +473,9 @@ static void deschedule_periodic(dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh) * @param[in] _qh QH to remove from schedule. */ void dwc_otg_hcd_qh_remove (dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh) { - if (!spin_is_locked(&_hcd->global_lock)) { - //pr_err("%s don't have hcd->global_lock\n", __func__); - //BUG(); - } + unsigned long flags; + + local_irq_save(flags); if (list_empty(&_qh->qh_list_entry)) { /* QH is not in a schedule. */ @@ -495,7 +492,7 @@ void dwc_otg_hcd_qh_remove (dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh) } done: - ; + local_irq_restore(flags); } /** @@ -513,10 +510,9 @@ void dwc_otg_hcd_qh_remove (dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh) */ void dwc_otg_hcd_qh_deactivate(dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh, int sched_next_periodic_split) { - if (!spin_is_locked(&_hcd->global_lock)) { - //pr_err("%s don't have hcd->global_lock\n", __func__); - //BUG(); - } + unsigned long flags; + local_irq_save(flags); + if (dwc_qh_is_non_per(_qh)) { dwc_otg_hcd_qh_remove(_hcd, _qh); if (!list_empty(&_qh->qtd_list)) { @@ -578,7 +574,7 @@ void dwc_otg_hcd_qh_deactivate(dwc_otg_hcd_t *_hcd, dwc_otg_qh_t *_qh, int sched } } - + local_irq_restore(flags); } /** @@ -646,12 +642,11 @@ int dwc_otg_hcd_qtd_add (dwc_otg_qtd_t *_qtd, { struct usb_host_endpoint *ep; dwc_otg_qh_t *qh; - //unsigned long flags; + unsigned long flags; int retval = 0; struct urb *urb = _qtd->urb; - //local_irq_save(flags); /* * Get the QH which holds the QTD-list to insert to. Create QH if it @@ -667,14 +662,15 @@ int dwc_otg_hcd_qtd_add (dwc_otg_qtd_t *_qtd, } ep->hcpriv = qh; } - + + local_irq_save(flags); retval = dwc_otg_hcd_qh_add(_dwc_otg_hcd, qh); if (retval == 0) { list_add_tail(&_qtd->qtd_list_entry, &qh->qtd_list); } done: - //local_irq_restore(flags); + local_irq_restore(flags); return retval; } diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c b/drivers/usb/dwc_otg/dwc_otg_pcd.c index a4cecc92b6f8..6a2f4473df0e 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c @@ -84,8 +84,9 @@ #include "dwc_otg_regs.h" #include +#ifdef CONFIG_ARCH_RK29 #include - +#endif /** * Static PCD pointer for use in usb_gadget_register_driver and * usb_gadget_unregister_driver. Initialized in dwc_otg_pcd_init. @@ -729,7 +730,7 @@ static int dwc_otg_pcd_ep_dequeue(struct usb_ep *_ep, pcd = ep->pcd; if (!pcd->driver || pcd->gadget.speed == USB_SPEED_UNKNOWN) { - DWC_WARN("%s, bogus device state\n", __func__); + DWC_WARN("%s, bogus device state, %p, speed %d\n", __func__, pcd->driver, pcd->gadget.speed); return -ESHUTDOWN; } @@ -1145,9 +1146,9 @@ static int32_t dwc_otg_pcd_suspend_cb( void *_p ,int suspend) //#endif if (pcd->driver && pcd->driver->resume) { - SPIN_UNLOCK(&pcd->lock); +// SPIN_UNLOCK(&pcd->lock); pcd->driver->suspend(&pcd->gadget); - SPIN_LOCK(&pcd->lock); +// SPIN_LOCK(&pcd->lock); } return 1; } @@ -1559,7 +1560,7 @@ int dwc_pcd_reset(dwc_otg_pcd_t *pcd) dwc_otg_core_if_t *core_if = GET_CORE_IF(pcd); dwc_otg_disable_global_interrupts( core_if ); // - +#ifdef CONFIG_ARCH_RK29 cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_AHB_BUS, true); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_PHY, true); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_CONTROLLER, true); @@ -1568,7 +1569,7 @@ int dwc_pcd_reset(dwc_otg_pcd_t *pcd) cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_AHB_BUS, false); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_PHY, false); cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_CONTROLLER, false); - +#endif //rockchip_scu_reset_unit(12); dwc_otg_pcd_reinit( pcd ); dwc_otg_core_dev_init(core_if); @@ -1585,8 +1586,12 @@ int dwc_pcd_reset(dwc_otg_pcd_t *pcd) int rk28_usb_suspend( int exitsuspend ) { dwc_otg_pcd_t *pcd = s_pcd; - +#ifdef CONFIG_ARCH_RK29 unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); +#endif +#ifdef CONFIG_ARCH_RK30 + unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON2); +#endif if(exitsuspend && (pcd->phy_suspend == 1)) { clk_enable(pcd->otg_dev->ahbclk); clk_enable(pcd->otg_dev->phyclk); @@ -1821,12 +1826,13 @@ int dwc_otg_pcd_init(struct device *dev) memset( pcd, 0, sizeof(dwc_otg_pcd_t)); spin_lock_init( &pcd->lock ); - + spin_lock(&pcd->lock); otg_dev->pcd = pcd; s_pcd = pcd; pcd->gadget.name = pcd_name; //strcpy(pcd->gadget.dev.bus_id, "gadget"); + spin_unlock(&pcd->lock); pcd->otg_dev = otg_dev; pcd->gadget.dev.parent = dev; @@ -1906,7 +1912,8 @@ int dwc_otg_pcd_init(struct device *dev) pcd->vbus_status = 0; pcd->phy_suspend = 0; if(dwc_otg_is_device_mode(core_if)) - mod_timer(&pcd->check_vbus_timer, jiffies+(HZ<<4)); // delay 16 S + mod_timer(&pcd->check_vbus_timer, jiffies+(HZ<<2)); // delay 16 S +(HZ<<4) + DWC_PRINT("%s pass,everest\n", __func__); // dwc_otg_pcd_start_vbus_timer( pcd ); return 0; } diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c b/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c index fbcf68471096..7db4671907e0 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c @@ -606,9 +606,9 @@ void dwc_otg_pcd_stop(dwc_otg_pcd_t *_pcd) /* report disconnect; the driver is already quiesced */ if (_pcd->driver && _pcd->driver->disconnect) { - SPIN_UNLOCK(&_pcd->lock); +// SPIN_UNLOCK(&_pcd->lock); _pcd->driver->disconnect(&_pcd->gadget); - SPIN_LOCK(&_pcd->lock); +// SPIN_LOCK(&_pcd->lock); } } @@ -1032,7 +1032,6 @@ static inline void ep0_do_stall( dwc_otg_pcd_t *_pcd, const int err_val ) struct usb_ctrlrequest *ctrl = &_pcd->setup_pkt->req; DWC_WARN("req %02x.%02x v%04x i%04x l%04x protocol STALL; err %d\n", ctrl->bRequestType, ctrl->bRequest,ctrl->wValue, ctrl->wIndex, ctrl->wLength, err_val); - dump_stack(); ep0->dwc_ep.is_in = 1; dwc_otg_ep_set_stall( _pcd->otg_dev->core_if, &ep0->dwc_ep ); diff --git a/drivers/usb/dwc_otg/linux/dwc_otg_plat.h b/drivers/usb/dwc_otg/linux/dwc_otg_plat.h index 5bc5f78f8aab..6460005e97c3 100755 --- a/drivers/usb/dwc_otg/linux/dwc_otg_plat.h +++ b/drivers/usb/dwc_otg/linux/dwc_otg_plat.h @@ -39,7 +39,7 @@ #include #include #include - +#ifdef CONFIG_ARCH_RK29 #include #include #define GRF_REG_BASE RK29_GRF_BASE @@ -55,6 +55,17 @@ #define SCU_BASE_ADDR_VA RK29_CRU_BASE #endif #define USB_IOMUX_INIT(a,b) rk29_mux_api_set(a,b) +#endif + +#ifdef CONFIG_ARCH_RK30 +#include +#define GRF_REG_BASE RK30_GRF_BASE +#define USBOTG_SIZE RK30_USBOTG20_SIZE +#define USBGRF_UOC0_CON2 (GRF_REG_BASE+0x184) +#define USBGRF_UOC1_CON2 (GRF_REG_BASE+0x190) +#define USB_IOMUX_INIT(a,b) rk30_mux_api_set(a,b) +#endif + /** * @file *