Add Intel Penwell USB Device Controller Support in langwell_udc driver. This driver will support both langwell/penwell USB Device controller with this patch. This patch includes PHY mode enable and vbus_active set fixing. Signed-off-by: JiebingLi <jiebing.li@xxxxxxxxx> Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx> --- drivers/usb/gadget/Kconfig | 4 +- drivers/usb/gadget/langwell_udc.c | 90 ++++++++++++++++--------------------- drivers/usb/gadget/langwell_udc.h | 2 +- include/linux/usb/langwell_udc.h | 2 +- 4 files changed, 43 insertions(+), 55 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 607d0db..db84f31 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -475,11 +475,11 @@ config USB_GOKU select USB_GADGET_SELECTED config USB_GADGET_LANGWELL - boolean "Intel Langwell USB Device Controller" + boolean "Intel Langwell/Penwell USB Device Controller" depends on PCI select USB_GADGET_DUALSPEED help - Intel Langwell USB Device Controller is a High-Speed USB + Intel Langwell/Penwell USB Device Controller is a High-Speed USB On-The-Go device controller. The number of programmable endpoints is different through diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index 9917f94..47e6335 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c @@ -1,6 +1,6 @@ /* - * Intel Langwell USB Device Controller driver - * Copyright (C) 2008-2009, Intel Corporation. + * Intel Langwell/Penwell USB Device Controller driver + * Copyright (C) 2008-2010, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -21,7 +21,7 @@ /* #undef DEBUG */ /* #undef VERBOSE_DEBUG */ -#if defined(CONFIG_USB_LANGWELL_OTG) +#if defined(CONFIG_USB_LANGWELL_OTG) || defined(CONFIG_USB_PENWELL_OTG) #define OTG_TRANSCEIVER #endif @@ -53,8 +53,8 @@ #include "langwell_udc.h" -#define DRIVER_DESC "Intel Langwell USB Device Controller driver" -#define DRIVER_VERSION "16 May 2009" +#define DRIVER_DESC "Intel Langwell/Penwell USB Device Controller driver" +#define DRIVER_VERSION "June 3, 2010" static const char driver_name[] = "langwell_udc"; static const char driver_desc[] = DRIVER_DESC; @@ -1218,8 +1218,7 @@ static int langwell_wakeup(struct usb_gadget *_gadget) dev_info(&dev->pdev->dev, "device remote wakeup\n"); /* exit PHY low power suspend */ - if (dev->pdev->device != 0x0829) - langwell_phy_low_power(dev, 0); + langwell_phy_low_power(dev, 0); /* force port resume */ portsc1 |= PORTS_FPR; @@ -1552,21 +1551,6 @@ static void stop_activity(struct langwell_udc *dev, /*-------------------------------------------------------------------------*/ -/* device "function" sysfs attribute file */ -static ssize_t show_function(struct device *_dev, - struct device_attribute *attr, char *buf) -{ - struct langwell_udc *dev = the_controller; - - if (!dev->driver || !dev->driver->function - || strlen(dev->driver->function) > PAGE_SIZE) - return 0; - - return scnprintf(buf, PAGE_SIZE, "%s\n", dev->driver->function); -} -static DEVICE_ATTR(function, S_IRUGO, show_function, NULL); - - /* device "langwell_udc" sysfs attribute file */ static ssize_t show_langwell_udc(struct device *_dev, struct device_attribute *attr, char *buf) @@ -1885,10 +1869,6 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, return retval; } - retval = device_create_file(&dev->pdev->dev, &dev_attr_function); - if (retval) - goto err_unbind; - dev->usb_state = USB_STATE_ATTACHED; dev->ep0_state = WAIT_FOR_SETUP; dev->ep0_dir = USB_DIR_OUT; @@ -1909,14 +1889,6 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, driver->driver.name); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); return 0; - -err_unbind: - driver->unbind(&dev->gadget); - dev->gadget.dev.driver = NULL; - dev->driver = NULL; - - dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); - return retval; } EXPORT_SYMBOL(usb_gadget_probe_driver); @@ -1932,12 +1904,11 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); - if (unlikely(!driver || !driver->unbind)) + if (unlikely(!driver || !driver->unbind || !driver->disconnect)) return -EINVAL; /* exit PHY low power suspend */ - if (dev->pdev->device != 0x0829) - langwell_phy_low_power(dev, 0); + langwell_phy_low_power(dev, 0); /* unbind OTG transceiver */ if (dev->transceiver) @@ -1962,8 +1933,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) dev->gadget.dev.driver = NULL; dev->driver = NULL; - device_remove_file(&dev->pdev->dev, &dev_attr_function); - dev_info(&dev->pdev->dev, "unregistered driver '%s'\n", driver->driver.name); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); @@ -2800,8 +2769,7 @@ static void handle_bus_suspend(struct langwell_udc *dev) } /* enter PHY low power suspend */ - if (dev->pdev->device != 0x0829) - langwell_phy_low_power(dev, 0); + langwell_phy_low_power(dev, 1); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); } @@ -2815,8 +2783,7 @@ static void handle_bus_resume(struct langwell_udc *dev) dev->resume_state = 0; /* exit PHY low power suspend */ - if (dev->pdev->device != 0x0829) - langwell_phy_low_power(dev, 0); + langwell_phy_low_power(dev, 0); otg_notify_event(USB_OTG_DEV_RESU); @@ -3385,8 +3352,7 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) pci_set_power_state(pdev, PCI_D3hot); /* enter PHY low power suspend */ - if (dev->pdev->device != 0x0829) - langwell_phy_low_power(dev, 1); + langwell_phy_low_power(dev, 1); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__); return 0; @@ -3402,8 +3368,7 @@ static int langwell_udc_resume(struct pci_dev *pdev) dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); /* exit PHY low power suspend */ - if (dev->pdev->device != 0x0829) - langwell_phy_low_power(dev, 0); + langwell_phy_low_power(dev, 0); /* set device D0 power state */ pci_set_power_state(pdev, PCI_D0); @@ -3501,6 +3466,13 @@ static const struct pci_device_id pci_ids[] = { { .device = 0x0811, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, +}, { + .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), + .class_mask = ~0, + .vendor = 0x8086, + .device = 0x0829, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, }, { /* end: all zeroes */ } }; @@ -3524,8 +3496,10 @@ static struct pci_driver langwell_pci_driver = { #ifdef OTG_TRANSCEIVER static int intel_mid_start_peripheral(struct intel_mid_otg_xceiv *iotg) { - struct pci_dev *pdev; - int retval; + struct langwell_udc *dev = the_controller; + struct pci_dev *pdev; + unsigned long flags; + int retval; if (iotg == NULL) return -EINVAL; @@ -3536,13 +3510,21 @@ static int intel_mid_start_peripheral(struct intel_mid_otg_xceiv *iotg) if (retval) dev_dbg(&pdev->dev, "Failed to start peripheral driver\n"); + if (dev) { + spin_lock_irqsave(&dev->lock, flags); + dev->vbus_active = 1; + spin_unlock_irqrestore(&dev->lock, flags); + } + return retval; } static int intel_mid_stop_peripheral(struct intel_mid_otg_xceiv *iotg) { - struct pci_dev *pdev; - int retval; + struct langwell_udc *dev = the_controller; + struct pci_dev *pdev; + unsigned long flags; + int retval; if (iotg == NULL) return -EINVAL; @@ -3553,6 +3535,12 @@ static int intel_mid_stop_peripheral(struct intel_mid_otg_xceiv *iotg) if (retval) dev_dbg(&pdev->dev, "Failed to stop peripheral driver\n"); + if (dev) { + spin_lock_irqsave(&dev->lock, flags); + dev->vbus_active = 0; + spin_unlock_irqrestore(&dev->lock, flags); + } + return retval; } diff --git a/drivers/usb/gadget/langwell_udc.h b/drivers/usb/gadget/langwell_udc.h index 988d6d1..cf77d63 100644 --- a/drivers/usb/gadget/langwell_udc.h +++ b/drivers/usb/gadget/langwell_udc.h @@ -1,5 +1,5 @@ /* - * Intel Langwell USB Device Controller driver + * Intel Langwell/Penwell USB Device Controller driver * Copyright (C) 2008-2009, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it diff --git a/include/linux/usb/langwell_udc.h b/include/linux/usb/langwell_udc.h index 2d2d1bb..ab959cb 100644 --- a/include/linux/usb/langwell_udc.h +++ b/include/linux/usb/langwell_udc.h @@ -1,5 +1,5 @@ /* - * Intel Langwell USB Device Controller driver + * Intel Langwell/Penwell USB Device Controller driver * Copyright (C) 2008-2009, Intel Corporation. * * This program is free software; you can redistribute it and/or modify it -- 1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html