diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.c b/drivers/usb/dwc_otg/dwc_otg_cil.c index 8fc8441718bb..1fbd039cfbb0 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil.c @@ -376,14 +376,14 @@ static uint32_t calc_num_in_eps(dwc_otg_core_if_t *_core_if) { uint32_t num_in_eps = 0; uint32_t num_eps = _core_if->hwcfg2.b.num_dev_ep; - uint32_t hwcfg1 = _core_if->hwcfg1.d32 >> 2; //fix bug yk@rk 20100512 + uint32_t hwcfg1 = _core_if->hwcfg1.d32 >> 3; uint32_t num_tx_fifos = _core_if->hwcfg4.b.num_in_eps; int i; for(i = 0; i < num_eps; ++i) { - if((hwcfg1 & 0x3) == 0x01) + if(!(hwcfg1 & 0x1)) num_in_eps++; hwcfg1 >>= 2; @@ -413,14 +413,13 @@ static uint32_t calc_num_out_eps(dwc_otg_core_if_t *_core_if) for(i = 0; i < num_eps; ++i) { - if((hwcfg1 & 0x3) == 0x02) + if(!(hwcfg1 & 0x1)) num_out_eps++; hwcfg1 >>= 2; } return num_out_eps; } - /** * This function initializes the DWC_otg controller registers and * prepares the core for device mode or host mode operation. @@ -715,14 +714,24 @@ void dwc_otg_core_dev_init(dwc_otg_core_if_t *_core_if) 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 ); - - /* Configure data FIFO sizes */ +#ifdef CONFIG_ARCH_RK29 + /* Configure data FIFO sizes, RK29 otg has 0x3c0 dwords total */ dwc_write_reg32( &global_regs->grxfsiz, 0x00000210 ); dwc_write_reg32( &global_regs->gnptxfsiz, 0x00100210 ); //ep0 tx fifo dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[0], 0x01000220 ); //ep1 tx fifo dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[1], 0x00100320 ); //ep3 tx fifo dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[2], 0x00800330 ); //ep5 tx fifo - +#endif +#ifdef CONFIG_ARCH_RK30 + /* Configure data FIFO sizes, RK30 otg has 0x3cc dwords total */ + dwc_write_reg32( &global_regs->grxfsiz, 0x00000120 ); + dwc_write_reg32( &global_regs->gnptxfsiz, 0x00100120 ); //ep0 tx fifo + dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[0], 0x01000130 ); //ep1 tx fifo + dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[1], 0x00800230 ); //ep3 tx fifo + dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[2], 0x008002b0 ); //ep5 tx fifo + dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[2], 0x00800330 ); //ep7 tx fifo + dwc_write_reg32( &global_regs->dptxfsiz_dieptxf[2], 0x001003b0 ); //ep9 tx fifo +#endif if(_core_if->en_multiple_tx_fifo && _core_if->dma_enable) { dev_if->non_iso_tx_thr_en = _core_if->core_params->thr_ctl & 0x1; diff --git a/drivers/usb/dwc_otg/dwc_otg_driver.c b/drivers/usb/dwc_otg/dwc_otg_driver.c index 81d911f62fd6..54b295f3a9af 100755 --- a/drivers/usb/dwc_otg/dwc_otg_driver.c +++ b/drivers/usb/dwc_otg/dwc_otg_driver.c @@ -1332,8 +1332,6 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) retval = -ENOMEM; goto fail; } - DWC_PRINT("%s otg2.0 reg addr: 0x%x remap:0x%x\n",__func__, - (unsigned)res_base->start, (unsigned)dwc_otg_device->base); #if 0 dwc_otg_device->base = (void*)(USB_OTG_BASE_ADDR_VA); @@ -1353,7 +1351,6 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev) snpsid = dwc_read_reg32((uint32_t *)((uint8_t *)dwc_otg_device->base + 0x40)); if ((snpsid & 0xFFFFF000) != 0x4F542000) { - DWC_PRINT("%s::snpsid=0x%x,want 0x%x" , __func__ , snpsid , 0x4F542000 ); dev_err(dev, "Bad value for SNPSID: 0x%08x\n", snpsid); retval = -EINVAL; goto fail; diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c b/drivers/usb/dwc_otg/dwc_otg_pcd.c index 5be087e735d8..9732965493f6 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c @@ -188,7 +188,7 @@ void request_nuke( dwc_otg_pcd_ep_t *_ep ) * This function assigns periodic Tx FIFO to an periodic EP * in shared Tx FIFO mode */ - #if 0 + #ifdef CONFIG_ARCH_RK30 static uint32_t assign_perio_tx_fifo(dwc_otg_core_if_t *core_if) { uint32_t PerTxMsk = 1; @@ -215,9 +215,9 @@ static void release_perio_tx_fifo(dwc_otg_core_if_t *core_if, uint32_t fifo_num) } /** * This function assigns periodic Tx FIFO to an periodic EP - * in shared Tx FIFO mode + * in Dedicated FIFOs mode */ -#if 0 +#ifdef CONFIG_ARCH_RK30 static uint32_t assign_tx_fifo(dwc_otg_core_if_t *core_if) { uint32_t TxMsk = 1; @@ -237,7 +237,7 @@ static uint32_t assign_tx_fifo(dwc_otg_core_if_t *core_if) #endif /** * This function releases periodic Tx FIFO - * in shared Tx FIFO mode + * in Dedicated FIFOs mode */ static void release_tx_fifo(dwc_otg_core_if_t *core_if, uint32_t fifo_num) { @@ -304,7 +304,7 @@ static int dwc_otg_pcd_ep_enable(struct usb_ep *_ep, if(ep->dwc_ep.is_in) { - #if 0 +#ifdef CONFIG_ARCH_RK30 if(!pcd->otg_dev->core_if->en_multiple_tx_fifo) { ep->dwc_ep.tx_fifo_num = 0; @@ -325,7 +325,7 @@ static int dwc_otg_pcd_ep_enable(struct usb_ep *_ep, */ ep->dwc_ep.tx_fifo_num = assign_tx_fifo(pcd->otg_dev->core_if); } - #endif +#else /* yk@rk * ep0 -- tx fifo 0 * ep1 -- tx fifo 1 @@ -340,6 +340,7 @@ static int dwc_otg_pcd_ep_enable(struct usb_ep *_ep, ep->dwc_ep.tx_fifo_num = 3; else ep->dwc_ep.tx_fifo_num = (ep->dwc_ep.num>>1)+1 ; /* 1,3,5 */ +#endif } /* Set initial data PID. */ if ((_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == @@ -1477,7 +1478,15 @@ void dwc_otg_pcd_reinit(dwc_otg_pcd_t *_pcd) * here? Before EP type is set? */ ep->ep.maxpacket = MAX_PACKET_SIZE; - + + /** + * @yk@rk 20120329 + * EP8&EP9 of rk30 are IN&OUT ep, we use ep8 as OUT EP default + */ + #ifdef CONFIG_ARCH_RK30 + if(i == 8) + continue; + #endif list_add_tail (&ep->ep.ep_list, &_pcd->gadget.ep_list); INIT_LIST_HEAD (&ep->queue); @@ -1530,6 +1539,14 @@ void dwc_otg_pcd_reinit(dwc_otg_pcd_t *_pcd) */ ep->ep.maxpacket = MAX_PACKET_SIZE; + /** + * @yk@rk 20120329 + * EP8&EP9 of rk30 are IN&OUT ep, we use ep9 as IN EP default + */ + #ifdef CONFIG_ARCH_RK30 + if(i == 9) + continue; + #endif list_add_tail (&ep->ep.ep_list, &_pcd->gadget.ep_list); INIT_LIST_HEAD (&ep->queue); @@ -1774,7 +1791,65 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long pdata ) add_timer(&_pcd->check_vbus_timer); local_irq_restore(flags); } - +#ifdef CONFIG_ARCH_RK29 +/* + * This function can be only called in charge mode. + * return value: + * -1: ioremap fail; + * 0: vbus not connected; + * 1: vbus connected, dp,dm not in both high status; + * 2: vbus connected and both dp,dm in high level.(standard USB charger) + */ +int dwc_otg_check_dpdm(void) +{ + static uint8_t * reg_base = 0; + volatile unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON); + volatile unsigned int * otg_clkgate = (unsigned int*)(USB_CLKGATE_CON); + volatile unsigned int * otg_clkreset = (unsigned int*)(RK29_CRU_BASE+0x70); + volatile unsigned int * otg_dctl; + volatile unsigned int * otg_gotgctl; + volatile unsigned int * otg_hprt0; + int bus_status = 0; + + + // softreset & clockgate + *otg_clkreset |= (7<<16); + udelay(3); + *otg_clkreset &= ~(7<<16); + *otg_clkgate &= ~((1<<4)|(3<<25)); + + // exit phy suspend + *otg_phy_con1 |= (0x01<<2); + *otg_phy_con1 |= (0x01<<3); // exit suspend. + *otg_phy_con1 &= ~(0x01<<2); + + // soft connect + if(reg_base == 0){ + reg_base = ioremap(RK29_USBOTG0_PHYS,USBOTG_SIZE); + if(!reg_base){ + bus_status = -1; + goto out; + } + } + mdelay(105); + printk("regbase %p 0x%x, otg_phy_con%p, 0x%x, otg_clkgate %p,0x%x\n", + reg_base, *(reg_base), otg_phy_con1, *otg_phy_con1, otg_clkgate, *otg_clkgate); + 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 void dwc_otg_pcd_start_vbus_timer( dwc_otg_pcd_t * _pcd ) { struct timer_list *vbus_timer = &_pcd->check_vbus_timer; @@ -1953,7 +2028,7 @@ void dwc_otg_pcd_remove( struct device *dev ) kfree( pcd ); otg_dev->pcd = 0; - s_pcd = 0; // HSL@RK,20090901 + s_pcd = 0; } /** diff --git a/drivers/usb/gadget/f_accessory.c b/drivers/usb/gadget/f_accessory.c old mode 100644 new mode 100755 index 05e65e5cd704..51ce8dfb5dca --- a/drivers/usb/gadget/f_accessory.c +++ b/drivers/usb/gadget/f_accessory.c @@ -716,7 +716,9 @@ static void acc_function_disable(struct usb_function *f) DBG(cdev, "acc_function_disable\n"); acc_set_disconnected(dev); usb_ep_disable(dev->ep_in); + dev->ep_in->driver_data = NULL; usb_ep_disable(dev->ep_out); + dev->ep_out->driver_data = NULL; /* readers may be blocked waiting for us to go online */ wake_up(&dev->read_wq); diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c old mode 100644 new mode 100755 index 9855ad55dcab..83e1f59385a2 --- a/drivers/usb/gadget/f_adb.c +++ b/drivers/usb/gadget/f_adb.c @@ -538,7 +538,9 @@ static void adb_function_disable(struct usb_function *f) dev->online = 0; dev->error = 1; usb_ep_disable(dev->ep_in); + dev->ep_in->driver_data = NULL; usb_ep_disable(dev->ep_out); + dev->ep_out->driver_data = NULL; /* readers may be blocked waiting for us to go online */ wake_up(&dev->read_wq); @@ -550,8 +552,6 @@ static int adb_bind_config(struct usb_configuration *c) { struct adb_dev *dev = _adb_dev; - printk(KERN_INFO "adb_bind_config\n"); - dev->cdev = c->cdev; dev->function.name = "adb"; dev->function.descriptors = fs_adb_descs; diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c old mode 100644 new mode 100755 index f75613a35836..ef0cd7fbe1a0 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2600,10 +2600,12 @@ reset: /* Disable the endpoints */ if (fsg->bulk_in_enabled) { usb_ep_disable(fsg->bulk_in); + fsg->bulk_in->driver_data = NULL; fsg->bulk_in_enabled = 0; } if (fsg->bulk_out_enabled) { usb_ep_disable(fsg->bulk_out); + fsg->bulk_out->driver_data = NULL; fsg->bulk_out_enabled = 0; } diff --git a/drivers/usb/gadget/f_mtp.c b/drivers/usb/gadget/f_mtp.c old mode 100644 new mode 100755 index 64ad4e6d234d..72d24554b022 --- a/drivers/usb/gadget/f_mtp.c +++ b/drivers/usb/gadget/f_mtp.c @@ -411,15 +411,6 @@ static int mtp_create_bulk_endpoints(struct mtp_dev *dev, ep->driver_data = dev; /* claim the endpoint */ dev->ep_out = ep; - ep = usb_ep_autoconfig(cdev->gadget, out_desc); - if (!ep) { - DBG(cdev, "usb_ep_autoconfig for ep_out failed\n"); - return -ENODEV; - } - DBG(cdev, "usb_ep_autoconfig for mtp ep_out got %s\n", ep->name); - ep->driver_data = dev; /* claim the endpoint */ - dev->ep_out = ep; - ep = usb_ep_autoconfig(cdev->gadget, intr_desc); if (!ep) { DBG(cdev, "usb_ep_autoconfig for ep_intr failed\n"); @@ -1176,8 +1167,11 @@ static void mtp_function_disable(struct usb_function *f) DBG(cdev, "mtp_function_disable\n"); dev->state = STATE_OFFLINE; usb_ep_disable(dev->ep_in); + dev->ep_in->driver_data = NULL; usb_ep_disable(dev->ep_out); + dev->ep_out->driver_data = NULL; usb_ep_disable(dev->ep_intr); + dev->ep_intr->driver_data = NULL; /* readers may be blocked waiting for us to go online */ wake_up(&dev->read_wq);