Commit 61fe2d75 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'usb-for-v3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next

Felipe writes:

usb: patches for v3.17 merge window

Surprisingly enough, while a big set of patches, the majority is
composed of cleanups (using devm_*, fixing sparse errors, moving
code around, adding const, etc).

The highlights are addition of new support for PLX USB338x devices,
and support for USB 2.0-only configurations of the DWC3 IP core.
Signed-of-by: default avatarFelipe Balbi <balbi@ti.com>
parents 499b3803 8346b33f
...@@ -556,11 +556,11 @@ been converted to this framework. ...@@ -556,11 +556,11 @@ been converted to this framework.
Near-term plans include converting all of them, except for "gadgetfs". Near-term plans include converting all of them, except for "gadgetfs".
</para> </para>
!Edrivers/usb/gadget/f_acm.c !Edrivers/usb/gadget/function/f_acm.c
!Edrivers/usb/gadget/f_ecm.c !Edrivers/usb/gadget/function/f_ecm.c
!Edrivers/usb/gadget/f_subset.c !Edrivers/usb/gadget/function/f_subset.c
!Edrivers/usb/gadget/f_obex.c !Edrivers/usb/gadget/function/f_obex.c
!Edrivers/usb/gadget/f_serial.c !Edrivers/usb/gadget/function/f_serial.c
</sect1> </sect1>
......
...@@ -386,6 +386,13 @@ static int dwc3_core_init(struct dwc3 *dwc) ...@@ -386,6 +386,13 @@ static int dwc3_core_init(struct dwc3 *dwc)
} }
dwc->revision = reg; dwc->revision = reg;
/* Handle USB2.0-only core configuration */
if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
if (dwc->maximum_speed == USB_SPEED_SUPER)
dwc->maximum_speed = USB_SPEED_HIGH;
}
/* issue device SoftReset too */ /* issue device SoftReset too */
timeout = jiffies + msecs_to_jiffies(500); timeout = jiffies + msecs_to_jiffies(500);
dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST); dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
...@@ -656,6 +663,31 @@ static int dwc3_probe(struct platform_device *pdev) ...@@ -656,6 +663,31 @@ static int dwc3_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
dwc->xhci_resources[0].start = res->start;
dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
DWC3_XHCI_REGS_END;
dwc->xhci_resources[0].flags = res->flags;
dwc->xhci_resources[0].name = res->name;
res->start += DWC3_GLOBALS_REGS_START;
/*
* Request memory region but exclude xHCI regs,
* since it will be requested by the xhci-plat driver.
*/
regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs))
return PTR_ERR(regs);
dwc->regs = regs;
dwc->regs_size = resource_size(res);
/*
* restore res->start back to its original value so that,
* in case the probe is deferred, we don't end up getting error in
* request the memory region the next time probe is called.
*/
res->start -= DWC3_GLOBALS_REGS_START;
if (node) { if (node) {
dwc->maximum_speed = of_usb_get_maximum_speed(node); dwc->maximum_speed = of_usb_get_maximum_speed(node);
...@@ -676,28 +708,9 @@ static int dwc3_probe(struct platform_device *pdev) ...@@ -676,28 +708,9 @@ static int dwc3_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
dwc->xhci_resources[0].start = res->start;
dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
DWC3_XHCI_REGS_END;
dwc->xhci_resources[0].flags = res->flags;
dwc->xhci_resources[0].name = res->name;
res->start += DWC3_GLOBALS_REGS_START;
/*
* Request memory region but exclude xHCI regs,
* since it will be requested by the xhci-plat driver.
*/
regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs))
return PTR_ERR(regs);
spin_lock_init(&dwc->lock); spin_lock_init(&dwc->lock);
platform_set_drvdata(pdev, dwc); platform_set_drvdata(pdev, dwc);
dwc->regs = regs;
dwc->regs_size = resource_size(res);
dev->dma_mask = dev->parent->dma_mask; dev->dma_mask = dev->parent->dma_mask;
dev->dma_parms = dev->parent->dma_parms; dev->dma_parms = dev->parent->dma_parms;
dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask); dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
......
...@@ -191,6 +191,19 @@ ...@@ -191,6 +191,19 @@
#define DWC3_GHWPARAMS1_PWROPT(n) ((n) << 24) #define DWC3_GHWPARAMS1_PWROPT(n) ((n) << 24)
#define DWC3_GHWPARAMS1_PWROPT_MASK DWC3_GHWPARAMS1_PWROPT(3) #define DWC3_GHWPARAMS1_PWROPT_MASK DWC3_GHWPARAMS1_PWROPT(3)
/* Global HWPARAMS3 Register */
#define DWC3_GHWPARAMS3_SSPHY_IFC(n) ((n) & 3)
#define DWC3_GHWPARAMS3_SSPHY_IFC_DIS 0
#define DWC3_GHWPARAMS3_SSPHY_IFC_ENA 1
#define DWC3_GHWPARAMS3_HSPHY_IFC(n) (((n) & (3 << 2)) >> 2)
#define DWC3_GHWPARAMS3_HSPHY_IFC_DIS 0
#define DWC3_GHWPARAMS3_HSPHY_IFC_UTMI 1
#define DWC3_GHWPARAMS3_HSPHY_IFC_ULPI 2
#define DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI 3
#define DWC3_GHWPARAMS3_FSPHY_IFC(n) (((n) & (3 << 4)) >> 4)
#define DWC3_GHWPARAMS3_FSPHY_IFC_DIS 0
#define DWC3_GHWPARAMS3_FSPHY_IFC_ENA 1
/* Global HWPARAMS4 Register */ /* Global HWPARAMS4 Register */
#define DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(n) (((n) & (0x0f << 13)) >> 13) #define DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(n) (((n) & (0x0f << 13)) >> 13)
#define DWC3_MAX_HIBER_SCRATCHBUFS 15 #define DWC3_MAX_HIBER_SCRATCHBUFS 15
......
...@@ -77,10 +77,6 @@ ...@@ -77,10 +77,6 @@
#define USBOTGSS_DEV_EBC_EN 0x0110 #define USBOTGSS_DEV_EBC_EN 0x0110
#define USBOTGSS_DEBUG_OFFSET 0x0600 #define USBOTGSS_DEBUG_OFFSET 0x0600
/* REVISION REGISTER */
#define USBOTGSS_REVISION_XMAJOR(reg) ((reg >> 8) & 0x7)
#define USBOTGSS_REVISION_XMAJOR1 1
#define USBOTGSS_REVISION_XMAJOR2 2
/* SYSCONFIG REGISTER */ /* SYSCONFIG REGISTER */
#define USBOTGSS_SYSCONFIG_DMADISABLE (1 << 16) #define USBOTGSS_SYSCONFIG_DMADISABLE (1 << 16)
...@@ -129,7 +125,6 @@ struct dwc3_omap { ...@@ -129,7 +125,6 @@ struct dwc3_omap {
u32 irq_eoi_offset; u32 irq_eoi_offset;
u32 debug_offset; u32 debug_offset;
u32 irq0_offset; u32 irq0_offset;
u32 revision;
u32 dma_status:1; u32 dma_status:1;
...@@ -383,6 +378,87 @@ static int dwc3_omap_vbus_notifier(struct notifier_block *nb, ...@@ -383,6 +378,87 @@ static int dwc3_omap_vbus_notifier(struct notifier_block *nb,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static void dwc3_omap_map_offset(struct dwc3_omap *omap)
{
struct device_node *node = omap->dev->of_node;
/*
* Differentiate between OMAP5 and AM437x.
*
* For OMAP5(ES2.0) and AM437x wrapper revision is same, even
* though there are changes in wrapper register offsets.
*
* Using dt compatible to differentiate AM437x.
*/
if (of_device_is_compatible(node, "ti,am437x-dwc3")) {
omap->irq_eoi_offset = USBOTGSS_EOI_OFFSET;
omap->irq0_offset = USBOTGSS_IRQ0_OFFSET;
omap->irqmisc_offset = USBOTGSS_IRQMISC_OFFSET;
omap->utmi_otg_offset = USBOTGSS_UTMI_OTG_OFFSET;
omap->debug_offset = USBOTGSS_DEBUG_OFFSET;
}
}
static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)
{
u32 reg;
struct device_node *node = omap->dev->of_node;
int utmi_mode = 0;
reg = dwc3_omap_read_utmi_status(omap);
of_property_read_u32(node, "utmi-mode", &utmi_mode);
switch (utmi_mode) {
case DWC3_OMAP_UTMI_MODE_SW:
reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
break;
case DWC3_OMAP_UTMI_MODE_HW:
reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
break;
default:
dev_dbg(omap->dev, "UNKNOWN utmi mode %d\n", utmi_mode);
}
dwc3_omap_write_utmi_status(omap, reg);
}
static int dwc3_omap_extcon_register(struct dwc3_omap *omap)
{
u32 ret;
struct device_node *node = omap->dev->of_node;
struct extcon_dev *edev;
if (of_property_read_bool(node, "extcon")) {
edev = extcon_get_edev_by_phandle(omap->dev, 0);
if (IS_ERR(edev)) {
dev_vdbg(omap->dev, "couldn't get extcon device\n");
return -EPROBE_DEFER;
}
omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
ret = extcon_register_interest(&omap->extcon_vbus_dev,
edev->name, "USB",
&omap->vbus_nb);
if (ret < 0)
dev_vdbg(omap->dev, "failed to register notifier for USB\n");
omap->id_nb.notifier_call = dwc3_omap_id_notifier;
ret = extcon_register_interest(&omap->extcon_id_dev,
edev->name, "USB-HOST",
&omap->id_nb);
if (ret < 0)
dev_vdbg(omap->dev, "failed to register notifier for USB-HOST\n");
if (extcon_get_cable_state(edev, "USB") == true)
dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
if (extcon_get_cable_state(edev, "USB-HOST") == true)
dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
}
return 0;
}
static int dwc3_omap_probe(struct platform_device *pdev) static int dwc3_omap_probe(struct platform_device *pdev)
{ {
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
...@@ -390,15 +466,11 @@ static int dwc3_omap_probe(struct platform_device *pdev) ...@@ -390,15 +466,11 @@ static int dwc3_omap_probe(struct platform_device *pdev)
struct dwc3_omap *omap; struct dwc3_omap *omap;
struct resource *res; struct resource *res;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct extcon_dev *edev;
struct regulator *vbus_reg = NULL; struct regulator *vbus_reg = NULL;
int ret; int ret;
int irq; int irq;
int utmi_mode = 0;
int x_major;
u32 reg; u32 reg;
void __iomem *base; void __iomem *base;
...@@ -448,58 +520,8 @@ static int dwc3_omap_probe(struct platform_device *pdev) ...@@ -448,58 +520,8 @@ static int dwc3_omap_probe(struct platform_device *pdev)
goto err0; goto err0;
} }
reg = dwc3_omap_readl(omap->base, USBOTGSS_REVISION); dwc3_omap_map_offset(omap);
omap->revision = reg; dwc3_omap_set_utmi_mode(omap);
x_major = USBOTGSS_REVISION_XMAJOR(reg);
/* Differentiate between OMAP5 and AM437x */
switch (x_major) {
case USBOTGSS_REVISION_XMAJOR1:
case USBOTGSS_REVISION_XMAJOR2:
omap->irq_eoi_offset = 0;
omap->irq0_offset = 0;
omap->irqmisc_offset = 0;
omap->utmi_otg_offset = 0;
omap->debug_offset = 0;
break;
default:
/* Default to the latest revision */
omap->irq_eoi_offset = USBOTGSS_EOI_OFFSET;
omap->irq0_offset = USBOTGSS_IRQ0_OFFSET;
omap->irqmisc_offset = USBOTGSS_IRQMISC_OFFSET;
omap->utmi_otg_offset = USBOTGSS_UTMI_OTG_OFFSET;
omap->debug_offset = USBOTGSS_DEBUG_OFFSET;
break;
}
/* For OMAP5(ES2.0) and AM437x x_major is 2 even though there are
* changes in wrapper registers, Using dt compatible for aegis
*/
if (of_device_is_compatible(node, "ti,am437x-dwc3")) {
omap->irq_eoi_offset = USBOTGSS_EOI_OFFSET;
omap->irq0_offset = USBOTGSS_IRQ0_OFFSET;
omap->irqmisc_offset = USBOTGSS_IRQMISC_OFFSET;
omap->utmi_otg_offset = USBOTGSS_UTMI_OTG_OFFSET;
omap->debug_offset = USBOTGSS_DEBUG_OFFSET;
}
reg = dwc3_omap_read_utmi_status(omap);
of_property_read_u32(node, "utmi-mode", &utmi_mode);
switch (utmi_mode) {
case DWC3_OMAP_UTMI_MODE_SW:
reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
break;
case DWC3_OMAP_UTMI_MODE_HW:
reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
break;
default:
dev_dbg(dev, "UNKNOWN utmi mode %d\n", utmi_mode);
}
dwc3_omap_write_utmi_status(omap, reg);
/* check the DMA Status */ /* check the DMA Status */
reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
...@@ -515,31 +537,9 @@ static int dwc3_omap_probe(struct platform_device *pdev) ...@@ -515,31 +537,9 @@ static int dwc3_omap_probe(struct platform_device *pdev)
dwc3_omap_enable_irqs(omap); dwc3_omap_enable_irqs(omap);
if (of_property_read_bool(node, "extcon")) { ret = dwc3_omap_extcon_register(omap);
edev = extcon_get_edev_by_phandle(dev, 0); if (ret < 0)
if (IS_ERR(edev)) { goto err2;
dev_vdbg(dev, "couldn't get extcon device\n");
ret = -EPROBE_DEFER;
goto err2;
}
omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
ret = extcon_register_interest(&omap->extcon_vbus_dev,
edev->name, "USB", &omap->vbus_nb);
if (ret < 0)
dev_vdbg(dev, "failed to register notifier for USB\n");
omap->id_nb.notifier_call = dwc3_omap_id_notifier;
ret = extcon_register_interest(&omap->extcon_id_dev, edev->name,
"USB-HOST", &omap->id_nb);
if (ret < 0)
dev_vdbg(dev,
"failed to register notifier for USB-HOST\n");
if (extcon_get_cable_state(edev, "USB") == true)
dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
if (extcon_get_cable_state(edev, "USB-HOST") == true)
dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
}
ret = of_platform_populate(node, NULL, NULL, dev); ret = of_platform_populate(node, NULL, NULL, dev);
if (ret) { if (ret) {
......
...@@ -1971,8 +1971,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, ...@@ -1971,8 +1971,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
} }
static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc,
struct dwc3_ep *dep, const struct dwc3_event_depevt *event, struct dwc3_ep *dep, const struct dwc3_event_depevt *event)
int start_new)
{ {
unsigned status = 0; unsigned status = 0;
int clean_busy; int clean_busy;
...@@ -2039,7 +2038,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, ...@@ -2039,7 +2038,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
return; return;
} }
dwc3_endpoint_transfer_complete(dwc, dep, event, 1); dwc3_endpoint_transfer_complete(dwc, dep, event);
break; break;
case DWC3_DEPEVT_XFERINPROGRESS: case DWC3_DEPEVT_XFERINPROGRESS:
if (!usb_endpoint_xfer_isoc(dep->endpoint.desc)) { if (!usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
...@@ -2048,7 +2047,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, ...@@ -2048,7 +2047,7 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
return; return;
} }
dwc3_endpoint_transfer_complete(dwc, dep, event, 0); dwc3_endpoint_transfer_complete(dwc, dep, event);
break; break;
case DWC3_DEPEVT_XFERNOTREADY: case DWC3_DEPEVT_XFERNOTREADY:
if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
......
This diff is collapsed.
# #
# USB peripheral controller drivers # USB peripheral controller drivers
# #
ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG
ccflags-y += -I$(PWD)/drivers/usb/gadget/udc
obj-$(CONFIG_USB_GADGET) += udc-core.o
obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
libcomposite-y := usbstring.o config.o epautoconf.o libcomposite-y := usbstring.o config.o epautoconf.o
libcomposite-y += composite.o functions.o configfs.o u_f.o libcomposite-y += composite.o functions.o configfs.o u_f.o
obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o
obj-$(CONFIG_USB_NET2272) += net2272.o
obj-$(CONFIG_USB_NET2280) += net2280.o
obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o
obj-$(CONFIG_USB_PXA25X) += pxa25x_udc.o
obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o
obj-$(CONFIG_USB_GOKU) += goku_udc.o
obj-$(CONFIG_USB_OMAP) += omap_udc.o
obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o
obj-$(CONFIG_USB_AT91) += at91_udc.o
obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o
obj-$(CONFIG_USB_BCM63XX_UDC) += bcm63xx_udc.o
obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o
fsl_usb2_udc-y := fsl_udc_core.o
fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o
obj-$(CONFIG_USB_M66592) += m66592-udc.o
obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o
obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o
obj-$(CONFIG_USB_S3C_HSUDC) += s3c-hsudc.o
obj-$(CONFIG_USB_LPC32XX) += lpc32xx_udc.o
obj-$(CONFIG_USB_EG20T) += pch_udc.o
obj-$(CONFIG_USB_MV_UDC) += mv_udc.o
mv_udc-y := mv_udc_core.o
obj-$(CONFIG_USB_FUSB300) += fusb300_udc.o
obj-$(CONFIG_USB_FOTG210_UDC) += fotg210-udc.o
obj-$(CONFIG_USB_MV_U3D) += mv_u3d_core.o
obj-$(CONFIG_USB_GR_UDC) += gr_udc.o
# USB Functions obj-$(CONFIG_USB_GADGET) += udc/ function/ legacy/
usb_f_acm-y := f_acm.o
obj-$(CONFIG_USB_F_ACM) += usb_f_acm.o
usb_f_ss_lb-y := f_loopback.o f_sourcesink.o
obj-$(CONFIG_USB_F_SS_LB) += usb_f_ss_lb.o
obj-$(CONFIG_USB_U_SERIAL) += u_serial.o
usb_f_serial-y := f_serial.o
obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
usb_f_obex-y := f_obex.o
obj-$(CONFIG_USB_F_OBEX) += usb_f_obex.o
obj-$(CONFIG_USB_U_ETHER) += u_ether.o
usb_f_ncm-y := f_ncm.o
obj-$(CONFIG_USB_F_NCM) += usb_f_ncm.o
usb_f_ecm-y := f_ecm.o
obj-$(CONFIG_USB_F_ECM) += usb_f_ecm.o
usb_f_phonet-y := f_phonet.o
obj-$(CONFIG_USB_F_PHONET) += usb_f_phonet.o
usb_f_eem-y := f_eem.o
obj-$(CONFIG_USB_F_EEM) += usb_f_eem.o
usb_f_ecm_subset-y := f_subset.o
obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o
usb_f_rndis-y := f_rndis.o rndis.o
obj-$(CONFIG_USB_F_RNDIS) += usb_f_rndis.o
usb_f_mass_storage-y := f_mass_storage.o storage_common.o
obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
usb_f_fs-y := f_fs.o
obj-$(CONFIG_USB_F_FS) += usb_f_fs.o
#
# USB gadget drivers
#
g_zero-y := zero.o
g_audio-y := audio.o
g_ether-y := ether.o
g_serial-y := serial.o
g_midi-y := gmidi.o
gadgetfs-y := inode.o
g_mass_storage-y := mass_storage.o
g_printer-y := printer.o
g_cdc-y := cdc2.o
g_multi-y := multi.o
g_hid-y := hid.o
g_dbgp-y := dbgp.o
g_nokia-y := nokia.o
g_webcam-y := webcam.o
g_ncm-y := ncm.o
g_acm_ms-y := acm_ms.o
g_tcm_usb_gadget-y := tcm_usb_gadget.o
obj-$(CONFIG_USB_ZERO) += g_zero.o
obj-$(CONFIG_USB_AUDIO) += g_audio.o
obj-$(CONFIG_USB_ETH) += g_ether.o
obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o
obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o
obj-$(CONFIG_USB_G_SERIAL) += g_serial.o
obj-$(CONFIG_USB_G_PRINTER) += g_printer.o
obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o
obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o
obj-$(CONFIG_USB_G_HID) += g_hid.o
obj-$(CONFIG_USB_G_DBGP) += g_dbgp.o
obj-$(CONFIG_USB_G_MULTI) += g_multi.o
obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o
obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o
obj-$(CONFIG_USB_G_NCM) += g_ncm.o
obj-$(CONFIG_USB_G_ACM_MS) += g_acm_ms.o
obj-$(CONFIG_USB_GADGET_TARGET) += tcm_usb_gadget.o
...@@ -1956,6 +1956,7 @@ void composite_dev_cleanup(struct usb_composite_dev *cdev) ...@@ -1956,6 +1956,7 @@ void composite_dev_cleanup(struct usb_composite_dev *cdev)
} }
if (cdev->req) { if (cdev->req) {
kfree(cdev->req->buf); kfree(cdev->req->buf);
usb_ep_dequeue(cdev->gadget->ep0, cdev->req);
usb_ep_free_request(cdev->gadget->ep0, cdev->req); usb_ep_free_request(cdev->gadget->ep0, cdev->req);
} }
cdev->next_string_id = 0; cdev->next_string_id = 0;
......
...@@ -1021,12 +1021,10 @@ static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop, ...@@ -1021,12 +1021,10 @@ static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop,
if (page[len - 1] == '\n' || page[len - 1] == '\0') if (page[len - 1] == '\n' || page[len - 1] == '\0')
--len; --len;
new_data = kzalloc(len, GFP_KERNEL); new_data = kmemdup(page, len, GFP_KERNEL);
if (!new_data) if (!new_data)
return -ENOMEM; return -ENOMEM;
memcpy(new_data, page, len);
if (desc->opts_mutex) if (desc->opts_mutex)
mutex_lock(desc->opts_mutex); mutex_lock(desc->opts_mutex);
kfree(ext_prop->data); kfree(ext_prop->data);
......
#
# USB peripheral controller drivers
#
ccflags-y := -I$(PWD)/drivers/usb/gadget/
ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/
# USB Functions
usb_f_acm-y := f_acm.o
obj-$(CONFIG_USB_F_ACM) += usb_f_acm.o
usb_f_ss_lb-y := f_loopback.o f_sourcesink.o
obj-$(CONFIG_USB_F_SS_LB) += usb_f_ss_lb.o
obj-$(CONFIG_USB_U_SERIAL) += u_serial.o
usb_f_serial-y := f_serial.o
obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
usb_f_obex-y := f_obex.o
obj-$(CONFIG_USB_F_OBEX) += usb_f_obex.o
obj-$(CONFIG_USB_U_ETHER) += u_ether.o
usb_f_ncm-y := f_ncm.o
obj-$(CONFIG_USB_F_NCM) += usb_f_ncm.o
usb_f_ecm-y := f_ecm.o
obj-$(CONFIG_USB_F_ECM) += usb_f_ecm.o
usb_f_phonet-y := f_phonet.o
obj-$(CONFIG_USB_F_PHONET) += usb_f_phonet.o
usb_f_eem-y := f_eem.o
obj-$(CONFIG_USB_F_EEM) += usb_f_eem.o
usb_f_ecm_subset-y := f_subset.o
obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o
usb_f_rndis-y := f_rndis.o rndis.o
obj-$(CONFIG_USB_F_RNDIS) += usb_f_rndis.o
usb_f_mass_storage-y := f_mass_storage.o storage_common.o
obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
usb_f_fs-y := f_fs.o
obj-$(CONFIG_USB_F_FS) += usb_f_fs.o
...@@ -355,20 +355,18 @@ static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb) ...@@ -355,20 +355,18 @@ static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb)
int padlen = 0; int padlen = 0;
u16 len = skb->len; u16 len = skb->len;
if (!skb_cloned(skb)) { int headroom = skb_headroom(skb);
int headroom = skb_headroom(skb); int tailroom = skb_tailroom(skb);
int tailroom = skb_tailroom(skb);
/* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0, /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0,
* stick two bytes of zero-length EEM packet on the end. * stick two bytes of zero-length EEM packet on the end.
*/ */
if (((len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) == 0) if (((len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) == 0)
padlen += 2; padlen += 2;
if ((tailroom >= (ETH_FCS_LEN + padlen)) && if ((tailroom >= (ETH_FCS_LEN + padlen)) &&
(headroom >= EEM_HLEN)) (headroom >= EEM_HLEN) && !skb_cloned(skb))
goto done; goto done;
}
skb2 = skb_copy_expand(skb, EEM_HLEN, ETH_FCS_LEN + padlen, GFP_ATOMIC); skb2 = skb_copy_expand(skb, EEM_HLEN, ETH_FCS_LEN + padlen, GFP_ATOMIC);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
......
...@@ -727,6 +727,10 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -727,6 +727,10 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
rndis_control_intf.bInterfaceNumber = status; rndis_control_intf.bInterfaceNumber = status;
rndis_union_desc.bMasterInterface0 = status; rndis_union_desc.bMasterInterface0 = status;
if (cdev->use_os_string)
f->os_desc_table[0].if_id =
rndis_iad_descriptor.bFirstInterface;
status = usb_interface_id(c, f); status = usb_interface_id(c, f);
if (status < 0) if (status < 0)
goto fail; goto fail;
......
...@@ -348,14 +348,34 @@ static int uac2_pcm_open(struct snd_pcm_substream *substream) ...@@ -348,14 +348,34 @@ static int uac2_pcm_open(struct snd_pcm_substream *substream)
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
spin_lock_init(&uac2->p_prm.lock); spin_lock_init(&uac2->p_prm.lock);
runtime->hw.rate_min = p_srate; runtime->hw.rate_min = p_srate;
runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; /* ! p_ssize ! */ switch (p_ssize) {
case 3:
runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE;
break;
case 4:
runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
break;
default:
runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
break;
}
runtime->hw.channels_min = num_channels(p_chmask); runtime->hw.channels_min = num_channels(p_chmask);
runtime->hw.period_bytes_min = 2 * uac2->p_prm.max_psize runtime->hw.period_bytes_min = 2 * uac2->p_prm.max_psize
/ runtime->hw.periods_min; / runtime->hw.periods_min;
} else { } else {
spin_lock_init(&uac2->c_prm.lock); spin_lock_init(&uac2->c_prm.lock);
runtime->hw.rate_min = c_srate; runtime->hw.rate_min = c_srate;
runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; /* ! c_ssize ! */ switch (c_ssize) {
case 3:
runtime->hw.formats = SNDRV_PCM_FMTBIT_S24_3LE;
break;
case 4:
runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
break;
default:
runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
break;
}
runtime->hw.channels_min = num_channels(c_chmask); runtime->hw.channels_min = num_channels(c_chmask);
runtime->hw.period_bytes_min = 2 * uac2->c_prm.max_psize runtime->hw.period_bytes_min = 2 * uac2->c_prm.max_psize
/ runtime->hw.periods_min; / runtime->hw.periods_min;
......
...@@ -483,7 +483,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, ...@@ -483,7 +483,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
struct net_device *net) struct net_device *net)
{ {
struct eth_dev *dev = netdev_priv(net); struct eth_dev *dev = netdev_priv(net);
int length = skb->len; int length = 0;
int retval; int retval;
struct usb_request *req = NULL; struct usb_request *req = NULL;
unsigned long flags; unsigned long flags;
...@@ -500,13 +500,13 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, ...@@ -500,13 +500,13 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
} }
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
if (!in) { if (skb && !in) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
/* apply outgoing CDC or RNDIS filters */ /* apply outgoing CDC or RNDIS filters */
if (!is_promisc(cdc_filter)) { if (skb && !is_promisc(cdc_filter)) {
u8 *dest = skb->data; u8 *dest = skb->data;
if (is_multicast_ether_addr(dest)) { if (is_multicast_ether_addr(dest)) {
...@@ -557,11 +557,17 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, ...@@ -557,11 +557,17 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
if (dev->port_usb) if (dev->port_usb)
skb = dev->wrap(dev->port_usb, skb); skb = dev->wrap(dev->port_usb, skb);
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
if (!skb) if (!skb) {
/* Multi frame CDC protocols may store the frame for
* later which is not a dropped frame.
*/
if (dev->port_usb->supports_multi_frame)
goto multiframe;
goto drop; goto drop;
}
length = skb->len;
} }
length = skb->len;
req->buf = skb->data; req->buf = skb->data;
req->context = skb; req->context = skb;
req->complete = tx_complete; req->complete = tx_complete;
...@@ -604,6 +610,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, ...@@ -604,6 +610,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
drop: drop:
dev->net->stats.tx_dropped++; dev->net->stats.tx_dropped++;
multiframe:
spin_lock_irqsave(&dev->req_lock, flags); spin_lock_irqsave(&dev->req_lock, flags);
if (list_empty(&dev->tx_reqs)) if (list_empty(&dev->tx_reqs))
netif_start_queue(net); netif_start_queue(net);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/usb/composite.h> #include <linux/usb/composite.h>
#include <linux/usb/cdc.h> #include <linux/usb/cdc.h>
#include <linux/netdevice.h>
#include "gadget_chips.h" #include "gadget_chips.h"
...@@ -74,6 +75,7 @@ struct gether { ...@@ -74,6 +75,7 @@ struct gether {
bool is_fixed; bool is_fixed;
u32 fixed_out_len; u32 fixed_out_len;
u32 fixed_in_len; u32 fixed_in_len;
bool supports_multi_frame;
struct sk_buff *(*wrap)(struct gether *port, struct sk_buff *(*wrap)(struct gether *port,
struct sk_buff *skb); struct sk_buff *skb);
int (*unwrap)(struct gether *port, int (*unwrap)(struct gether *port,
......
...@@ -216,6 +216,13 @@ struct ffs_data { ...@@ -216,6 +216,13 @@ struct ffs_data {
unsigned fs_descs_count; unsigned fs_descs_count;
unsigned hs_descs_count; unsigned hs_descs_count;
unsigned ss_descs_count; unsigned ss_descs_count;
unsigned ms_os_descs_count;
unsigned ms_os_descs_ext_prop_count;
unsigned ms_os_descs_ext_prop_name_len;
unsigned ms_os_descs_ext_prop_data_len;
void *ms_os_descs_ext_prop_avail;
void *ms_os_descs_ext_prop_name_avail;
void *ms_os_descs_ext_prop_data_avail;
unsigned short strings_count; unsigned short strings_count;
unsigned short interfaces_count; unsigned short interfaces_count;
......
This diff is collapsed.
#
# USB gadget drivers
#
ccflags-y := -I$(PWD)/drivers/usb/gadget/
ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/
ccflags-y += -I$(PWD)/drivers/usb/gadget/function/
g_zero-y := zero.o
g_audio-y := audio.o
g_ether-y := ether.o
g_serial-y := serial.o
g_midi-y := gmidi.o
gadgetfs-y := inode.o
g_mass_storage-y := mass_storage.o
g_printer-y := printer.o
g_cdc-y := cdc2.o
g_multi-y := multi.o
g_hid-y := hid.o
g_dbgp-y := dbgp.o
g_nokia-y := nokia.o
g_webcam-y := webcam.o
g_ncm-y := ncm.o
g_acm_ms-y := acm_ms.o
g_tcm_usb_gadget-y := tcm_usb_gadget.o
obj-$(CONFIG_USB_ZERO) += g_zero.o
obj-$(CONFIG_USB_AUDIO) += g_audio.o
obj-$(CONFIG_USB_ETH) += g_ether.o
obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o
obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o
obj-$(CONFIG_USB_G_SERIAL) += g_serial.o
obj-$(CONFIG_USB_G_PRINTER) += g_printer.o
obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o
obj-$(CONFIG_USB_CDC_COMPOSITE) += g_cdc.o
obj-$(CONFIG_USB_G_HID) += g_hid.o
obj-$(CONFIG_USB_G_DBGP) += g_dbgp.o
obj-$(CONFIG_USB_G_MULTI) += g_multi.o
obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o
obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o
obj-$(CONFIG_USB_G_NCM) += g_ncm.o
obj-$(CONFIG_USB_G_ACM_MS) += g_acm_ms.o
obj-$(CONFIG_USB_GADGET_TARGET) += tcm_usb_gadget.o
...@@ -267,18 +267,8 @@ static __refdata struct usb_composite_driver acm_ms_driver = { ...@@ -267,18 +267,8 @@ static __refdata struct usb_composite_driver acm_ms_driver = {
.unbind = __exit_p(acm_ms_unbind), .unbind = __exit_p(acm_ms_unbind),
}; };
module_usb_composite_driver(acm_ms_driver);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR("Klaus Schwarzkopf <schwarzkopf@sensortherm.de>"); MODULE_AUTHOR("Klaus Schwarzkopf <schwarzkopf@sensortherm.de>");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
static int __init init(void)
{
return usb_composite_probe(&acm_ms_driver);
}
module_init(init);
static void __exit cleanup(void)
{
usb_composite_unregister(&acm_ms_driver);
}
module_exit(cleanup);
...@@ -172,17 +172,7 @@ static __refdata struct usb_composite_driver audio_driver = { ...@@ -172,17 +172,7 @@ static __refdata struct usb_composite_driver audio_driver = {
.unbind = __exit_p(audio_unbind), .unbind = __exit_p(audio_unbind),
}; };
static int __init init(void) module_usb_composite_driver(audio_driver);
{
return usb_composite_probe(&audio_driver);
}
module_init(init);
static void __exit cleanup(void)
{
usb_composite_unregister(&audio_driver);
}
module_exit(cleanup);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR("Bryan Wu <cooloney@kernel.org>"); MODULE_AUTHOR("Bryan Wu <cooloney@kernel.org>");
......
...@@ -231,18 +231,8 @@ static __refdata struct usb_composite_driver cdc_driver = { ...@@ -231,18 +231,8 @@ static __refdata struct usb_composite_driver cdc_driver = {
.unbind = __exit_p(cdc_unbind), .unbind = __exit_p(cdc_unbind),
}; };
module_usb_composite_driver(cdc_driver);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR("David Brownell"); MODULE_AUTHOR("David Brownell");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int __init init(void)
{
return usb_composite_probe(&cdc_driver);
}
module_init(init);
static void __exit cleanup(void)
{
usb_composite_unregister(&cdc_driver);
}
module_exit(cleanup);
...@@ -475,18 +475,8 @@ static __refdata struct usb_composite_driver eth_driver = { ...@@ -475,18 +475,8 @@ static __refdata struct usb_composite_driver eth_driver = {
.unbind = __exit_p(eth_unbind), .unbind = __exit_p(eth_unbind),
}; };
module_usb_composite_driver(eth_driver);
MODULE_DESCRIPTION(PREFIX DRIVER_DESC); MODULE_DESCRIPTION(PREFIX DRIVER_DESC);
MODULE_AUTHOR("David Brownell, Benedikt Spanger"); MODULE_AUTHOR("David Brownell, Benedikt Spanger");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int __init init(void)
{
return usb_composite_probe(&eth_driver);
}
module_init(init);
static void __exit cleanup(void)
{
usb_composite_unregister(&eth_driver);
}
module_exit(cleanup);
...@@ -276,7 +276,7 @@ module_exit(gfs_exit); ...@@ -276,7 +276,7 @@ module_exit(gfs_exit);
static void *functionfs_acquire_dev(struct ffs_dev *dev) static void *functionfs_acquire_dev(struct ffs_dev *dev)
{ {
if (!try_module_get(THIS_MODULE)) if (!try_module_get(THIS_MODULE))
return ERR_PTR(-ENODEV); return ERR_PTR(-ENOENT);
return 0; return 0;
} }
......
...@@ -163,15 +163,4 @@ static __refdata struct usb_composite_driver midi_driver = { ...@@ -163,15 +163,4 @@ static __refdata struct usb_composite_driver midi_driver = {
.unbind = __exit_p(midi_unbind), .unbind = __exit_p(midi_unbind),
}; };
static int __init midi_init(void) module_usb_composite_driver(midi_driver);
{
return usb_composite_probe(&midi_driver);
}
module_init(midi_init);
static void __exit midi_cleanup(void)
{
usb_composite_unregister(&midi_driver);
}
module_exit(midi_cleanup);
...@@ -507,15 +507,4 @@ static __refdata struct usb_composite_driver multi_driver = { ...@@ -507,15 +507,4 @@ static __refdata struct usb_composite_driver multi_driver = {
.needs_serial = 1, .needs_serial = 1,
}; };
module_usb_composite_driver(multi_driver);
static int __init multi_init(void)
{
return usb_composite_probe(&multi_driver);
}
module_init(multi_init);
static void __exit multi_exit(void)
{
usb_composite_unregister(&multi_driver);
}
module_exit(multi_exit);
...@@ -204,18 +204,8 @@ static __refdata struct usb_composite_driver ncm_driver = { ...@@ -204,18 +204,8 @@ static __refdata struct usb_composite_driver ncm_driver = {
.unbind = __exit_p(gncm_unbind), .unbind = __exit_p(gncm_unbind),
}; };
module_usb_composite_driver(ncm_driver);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR("Yauheni Kaliuta"); MODULE_AUTHOR("Yauheni Kaliuta");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int __init init(void)
{
return usb_composite_probe(&ncm_driver);
}
module_init(init);
static void __exit cleanup(void)
{
usb_composite_unregister(&ncm_driver);
}
module_exit(cleanup);
...@@ -347,14 +347,4 @@ static __refdata struct usb_composite_driver nokia_driver = { ...@@ -347,14 +347,4 @@ static __refdata struct usb_composite_driver nokia_driver = {
.unbind = __exit_p(nokia_unbind), .unbind = __exit_p(nokia_unbind),
}; };
static int __init nokia_init(void) module_usb_composite_driver(nokia_driver);
{
return usb_composite_probe(&nokia_driver);
}
module_init(nokia_init);
static void __exit nokia_cleanup(void)
{
usb_composite_unregister(&nokia_driver);
}
module_exit(nokia_cleanup);
...@@ -390,20 +390,7 @@ static __refdata struct usb_composite_driver webcam_driver = { ...@@ -390,20 +390,7 @@ static __refdata struct usb_composite_driver webcam_driver = {
.unbind = webcam_unbind, .unbind = webcam_unbind,
}; };
static int __init module_usb_composite_driver(webcam_driver);
webcam_init(void)
{
return usb_composite_probe(&webcam_driver);
}
static void __exit
webcam_cleanup(void)
{
usb_composite_unregister(&webcam_driver);
}
module_init(webcam_init);
module_exit(webcam_cleanup);
MODULE_AUTHOR("Laurent Pinchart"); MODULE_AUTHOR("Laurent Pinchart");
MODULE_DESCRIPTION("Webcam Video Gadget"); MODULE_DESCRIPTION("Webcam Video Gadget");
......
...@@ -411,17 +411,7 @@ static __refdata struct usb_composite_driver zero_driver = { ...@@ -411,17 +411,7 @@ static __refdata struct usb_composite_driver zero_driver = {
.resume = zero_resume, .resume = zero_resume,
}; };
module_usb_composite_driver(zero_driver);
MODULE_AUTHOR("David Brownell"); MODULE_AUTHOR("David Brownell");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int __init init(void)
{
return usb_composite_probe(&zero_driver);
}
module_init(init);
static void __exit cleanup(void)
{
usb_composite_unregister(&zero_driver);
}
module_exit(cleanup);
...@@ -35,27 +35,63 @@ ...@@ -35,27 +35,63 @@
#define USB_EXT_PROP_UNICODE_LINK 6 #define USB_EXT_PROP_UNICODE_LINK 6
#define USB_EXT_PROP_UNICODE_MULTI 7 #define USB_EXT_PROP_UNICODE_MULTI 7
static inline u8 *__usb_ext_prop_ptr(u8 *buf, size_t offset)
{
return buf + offset;
}
static inline u8 *usb_ext_prop_size_ptr(u8 *buf)
{
return __usb_ext_prop_ptr(buf, USB_EXT_PROP_DW_SIZE);
}
static inline u8 *usb_ext_prop_type_ptr(u8 *buf)
{
return __usb_ext_prop_ptr(buf, USB_EXT_PROP_DW_PROPERTY_DATA_TYPE);
}
static inline u8 *usb_ext_prop_name_len_ptr(u8 *buf)
{
return __usb_ext_prop_ptr(buf, USB_EXT_PROP_W_PROPERTY_NAME_LENGTH);
}
static inline u8 *usb_ext_prop_name_ptr(u8 *buf)
{
return __usb_ext_prop_ptr(buf, USB_EXT_PROP_B_PROPERTY_NAME);
}
static inline u8 *usb_ext_prop_data_len_ptr(u8 *buf, size_t off)
{
return __usb_ext_prop_ptr(buf,
USB_EXT_PROP_DW_PROPERTY_DATA_LENGTH + off);
}
static inline u8 *usb_ext_prop_data_ptr(u8 *buf, size_t off)
{
return __usb_ext_prop_ptr(buf, USB_EXT_PROP_B_PROPERTY_DATA + off);
}
static inline void usb_ext_prop_put_size(u8 *buf, int dw_size) static inline void usb_ext_prop_put_size(u8 *buf, int dw_size)
{ {
put_unaligned_le32(dw_size, &buf[USB_EXT_PROP_DW_SIZE]); put_unaligned_le32(dw_size, usb_ext_prop_size_ptr(buf));
} }
static inline void usb_ext_prop_put_type(u8 *buf, int type) static inline void usb_ext_prop_put_type(u8 *buf, int type)
{ {
put_unaligned_le32(type, &buf[USB_EXT_PROP_DW_PROPERTY_DATA_TYPE]); put_unaligned_le32(type, usb_ext_prop_type_ptr(buf));
} }
static inline int usb_ext_prop_put_name(u8 *buf, const char *name, int pnl) static inline int usb_ext_prop_put_name(u8 *buf, const char *name, int pnl)
{ {
int result; int result;
put_unaligned_le16(pnl, &buf[USB_EXT_PROP_W_PROPERTY_NAME_LENGTH]); put_unaligned_le16(pnl, usb_ext_prop_name_len_ptr(buf));
result = utf8s_to_utf16s(name, strlen(name), UTF16_LITTLE_ENDIAN, result = utf8s_to_utf16s(name, strlen(name), UTF16_LITTLE_ENDIAN,
(wchar_t *) &buf[USB_EXT_PROP_B_PROPERTY_NAME], pnl - 2); (wchar_t *) usb_ext_prop_name_ptr(buf), pnl - 2);
if (result < 0) if (result < 0)
return result; return result;
put_unaligned_le16(0, &buf[USB_EXT_PROP_B_PROPERTY_NAME + pnl]); put_unaligned_le16(0, &buf[USB_EXT_PROP_B_PROPERTY_NAME + pnl - 2]);
return pnl; return pnl;
} }
...@@ -63,26 +99,23 @@ static inline int usb_ext_prop_put_name(u8 *buf, const char *name, int pnl) ...@@ -63,26 +99,23 @@ static inline int usb_ext_prop_put_name(u8 *buf, const char *name, int pnl)
static inline void usb_ext_prop_put_binary(u8 *buf, int pnl, const u8 *data, static inline void usb_ext_prop_put_binary(u8 *buf, int pnl, const u8 *data,
int data_len) int data_len)
{ {
put_unaligned_le32(data_len, put_unaligned_le32(data_len, usb_ext_prop_data_len_ptr(buf, pnl));
&buf[USB_EXT_PROP_DW_PROPERTY_DATA_LENGTH + pnl]); memcpy(usb_ext_prop_data_ptr(buf, pnl), data, data_len);
memcpy(&buf[USB_EXT_PROP_B_PROPERTY_DATA + pnl], data, data_len);
} }
static inline int usb_ext_prop_put_unicode(u8 *buf, int pnl, const char *string, static inline int usb_ext_prop_put_unicode(u8 *buf, int pnl, const char *string,
int data_len) int data_len)
{ {
int result; int result;
put_unaligned_le32(data_len, put_unaligned_le32(data_len, usb_ext_prop_data_len_ptr(buf, pnl));
&buf[USB_EXT_PROP_DW_PROPERTY_DATA_LENGTH + pnl]);
result = utf8s_to_utf16s(string, data_len >> 1, UTF16_LITTLE_ENDIAN, result = utf8s_to_utf16s(string, data_len >> 1, UTF16_LITTLE_ENDIAN,
(wchar_t *) &buf[USB_EXT_PROP_B_PROPERTY_DATA + pnl], (wchar_t *) usb_ext_prop_data_ptr(buf, pnl),
data_len - 2); data_len - 2);
if (result < 0) if (result < 0)
return result; return result;
put_unaligned_le16(0, put_unaligned_le16(0,
&buf[USB_EXT_PROP_B_PROPERTY_DATA + pnl + data_len]); &buf[USB_EXT_PROP_B_PROPERTY_DATA + pnl + data_len - 2]);
return data_len; return data_len;
} }
......
This diff is collapsed.
#
# USB peripheral controller drivers
#
obj-$(CONFIG_USB_GADGET) += udc-core.o
obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o
obj-$(CONFIG_USB_NET2272) += net2272.o
obj-$(CONFIG_USB_NET2280) += net2280.o
obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o
obj-$(CONFIG_USB_PXA25X) += pxa25x_udc.o
obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o
obj-$(CONFIG_USB_GOKU) += goku_udc.o
obj-$(CONFIG_USB_OMAP) += omap_udc.o
obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o
obj-$(CONFIG_USB_AT91) += at91_udc.o
obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o
obj-$(CONFIG_USB_BCM63XX_UDC) += bcm63xx_udc.o
obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o
fsl_usb2_udc-y := fsl_udc_core.o
fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o
obj-$(CONFIG_USB_M66592) += m66592-udc.o
obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o
obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o
obj-$(CONFIG_USB_S3C_HSUDC) += s3c-hsudc.o
obj-$(CONFIG_USB_LPC32XX) += lpc32xx_udc.o
obj-$(CONFIG_USB_EG20T) += pch_udc.o
obj-$(CONFIG_USB_MV_UDC) += mv_udc.o
mv_udc-y := mv_udc_core.o
obj-$(CONFIG_USB_FUSB300) += fusb300_udc.o
obj-$(CONFIG_USB_FOTG210_UDC) += fotg210-udc.o
obj-$(CONFIG_USB_MV_U3D) += mv_u3d_core.o
obj-$(CONFIG_USB_GR_UDC) += gr_udc.o
...@@ -1979,7 +1979,7 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, ...@@ -1979,7 +1979,7 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev,
return eps; return eps;
} }
static int __init usba_udc_probe(struct platform_device *pdev) static int usba_udc_probe(struct platform_device *pdev)
{ {
struct resource *regs, *fifo; struct resource *regs, *fifo;
struct clk *pclk, *hclk; struct clk *pclk, *hclk;
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include "fsl_usb2_udc.h"
static struct clk *mxc_ahb_clk; static struct clk *mxc_ahb_clk;
static struct clk *mxc_per_clk; static struct clk *mxc_per_clk;
static struct clk *mxc_ipg_clk; static struct clk *mxc_ipg_clk;
......
...@@ -2539,7 +2539,7 @@ static int qe_udc_probe(struct platform_device *ofdev) ...@@ -2539,7 +2539,7 @@ static int qe_udc_probe(struct platform_device *ofdev)
goto err2; goto err2;
/* create a buf for ZLP send, need to remain zeroed */ /* create a buf for ZLP send, need to remain zeroed */
udc->nullbuf = kzalloc(256, GFP_KERNEL); udc->nullbuf = devm_kzalloc(&ofdev->dev, 256, GFP_KERNEL);
if (udc->nullbuf == NULL) { if (udc->nullbuf == NULL) {
dev_err(udc->dev, "cannot alloc nullbuf\n"); dev_err(udc->dev, "cannot alloc nullbuf\n");
ret = -ENOMEM; ret = -ENOMEM;
...@@ -2547,10 +2547,10 @@ static int qe_udc_probe(struct platform_device *ofdev) ...@@ -2547,10 +2547,10 @@ static int qe_udc_probe(struct platform_device *ofdev)
} }
/* buffer for data of get_status request */ /* buffer for data of get_status request */
udc->statusbuf = kzalloc(2, GFP_KERNEL); udc->statusbuf = devm_kzalloc(&ofdev->dev, 2, GFP_KERNEL);
if (udc->statusbuf == NULL) { if (udc->statusbuf == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto err4; goto err3;
} }
udc->nullp = virt_to_phys((void *)udc->nullbuf); udc->nullp = virt_to_phys((void *)udc->nullbuf);
...@@ -2581,13 +2581,13 @@ static int qe_udc_probe(struct platform_device *ofdev) ...@@ -2581,13 +2581,13 @@ static int qe_udc_probe(struct platform_device *ofdev)
if (ret) { if (ret) {
dev_err(udc->dev, "cannot request irq %d err %d\n", dev_err(udc->dev, "cannot request irq %d err %d\n",
udc->usb_irq, ret); udc->usb_irq, ret);
goto err5; goto err4;
} }
ret = usb_add_gadget_udc_release(&ofdev->dev, &udc->gadget, ret = usb_add_gadget_udc_release(&ofdev->dev, &udc->gadget,
qe_udc_release); qe_udc_release);
if (ret) if (ret)
goto err6; goto err5;
platform_set_drvdata(ofdev, udc); platform_set_drvdata(ofdev, udc);
dev_info(udc->dev, dev_info(udc->dev,
...@@ -2595,9 +2595,9 @@ static int qe_udc_probe(struct platform_device *ofdev) ...@@ -2595,9 +2595,9 @@ static int qe_udc_probe(struct platform_device *ofdev)
(udc->soc_type == PORT_QE) ? "QE" : "CPM"); (udc->soc_type == PORT_QE) ? "QE" : "CPM");
return 0; return 0;
err6:
free_irq(udc->usb_irq, udc);
err5: err5:
free_irq(udc->usb_irq, udc);
err4:
irq_dispose_mapping(udc->usb_irq); irq_dispose_mapping(udc->usb_irq);
err_noirq: err_noirq:
if (udc->nullmap) { if (udc->nullmap) {
...@@ -2610,9 +2610,6 @@ static int qe_udc_probe(struct platform_device *ofdev) ...@@ -2610,9 +2610,6 @@ static int qe_udc_probe(struct platform_device *ofdev)
udc->nullp, 256, udc->nullp, 256,
DMA_TO_DEVICE); DMA_TO_DEVICE);
} }
kfree(udc->statusbuf);
err4:
kfree(udc->nullbuf);
err3: err3:
ep = &udc->eps[0]; ep = &udc->eps[0];
cpm_muram_free(cpm_muram_offset(ep->rxbase)); cpm_muram_free(cpm_muram_offset(ep->rxbase));
...@@ -2660,8 +2657,6 @@ static int qe_udc_remove(struct platform_device *ofdev) ...@@ -2660,8 +2657,6 @@ static int qe_udc_remove(struct platform_device *ofdev)
udc->nullp, 256, udc->nullp, 256,
DMA_TO_DEVICE); DMA_TO_DEVICE);
} }
kfree(udc->statusbuf);
kfree(udc->nullbuf);
ep = &udc->eps[0]; ep = &udc->eps[0];
cpm_muram_free(cpm_muram_offset(ep->rxbase)); cpm_muram_free(cpm_muram_offset(ep->rxbase));
......
...@@ -59,9 +59,9 @@ ...@@ -59,9 +59,9 @@
static const char driver_name[] = "fsl-usb2-udc"; static const char driver_name[] = "fsl-usb2-udc";
static const char driver_desc[] = DRIVER_DESC; static const char driver_desc[] = DRIVER_DESC;
static struct usb_dr_device *dr_regs; static struct usb_dr_device __iomem *dr_regs;
static struct usb_sys_interface *usb_sys_regs; static struct usb_sys_interface __iomem *usb_sys_regs;
/* it is initialized in probe() */ /* it is initialized in probe() */
static struct fsl_udc *udc_controller = NULL; static struct fsl_udc *udc_controller = NULL;
...@@ -159,6 +159,8 @@ static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) {} ...@@ -159,6 +159,8 @@ static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) {}
* request is still in progress. * request is still in progress.
*--------------------------------------------------------------*/ *--------------------------------------------------------------*/
static void done(struct fsl_ep *ep, struct fsl_req *req, int status) static void done(struct fsl_ep *ep, struct fsl_req *req, int status)
__releases(ep->udc->lock)
__acquires(ep->udc->lock)
{ {
struct fsl_udc *udc = NULL; struct fsl_udc *udc = NULL;
unsigned char stopped = ep->stopped; unsigned char stopped = ep->stopped;
...@@ -1392,6 +1394,8 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, ...@@ -1392,6 +1394,8 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value,
static void setup_received_irq(struct fsl_udc *udc, static void setup_received_irq(struct fsl_udc *udc,
struct usb_ctrlrequest *setup) struct usb_ctrlrequest *setup)
__releases(udc->lock)
__acquires(udc->lock)
{ {
u16 wValue = le16_to_cpu(setup->wValue); u16 wValue = le16_to_cpu(setup->wValue);
u16 wIndex = le16_to_cpu(setup->wIndex); u16 wIndex = le16_to_cpu(setup->wIndex);
...@@ -1957,8 +1961,7 @@ static int fsl_udc_start(struct usb_gadget *g, ...@@ -1957,8 +1961,7 @@ static int fsl_udc_start(struct usb_gadget *g,
&udc_controller->gadget); &udc_controller->gadget);
if (retval < 0) { if (retval < 0) {
ERR("can't bind to transceiver\n"); ERR("can't bind to transceiver\n");
driver->unbind(&udc_controller->gadget); udc_controller->driver = NULL;
udc_controller->driver = 0;
return retval; return retval;
} }
} }
...@@ -2246,7 +2249,7 @@ static void fsl_udc_release(struct device *dev) ...@@ -2246,7 +2249,7 @@ static void fsl_udc_release(struct device *dev)
* init resource for globle controller * init resource for globle controller
* Return the udc handle on success or NULL on failure * Return the udc handle on success or NULL on failure
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
static int __init struct_udc_setup(struct fsl_udc *udc, static int struct_udc_setup(struct fsl_udc *udc,
struct platform_device *pdev) struct platform_device *pdev)
{ {
struct fsl_usb2_platform_data *pdata; struct fsl_usb2_platform_data *pdata;
...@@ -2298,7 +2301,7 @@ static int __init struct_udc_setup(struct fsl_udc *udc, ...@@ -2298,7 +2301,7 @@ static int __init struct_udc_setup(struct fsl_udc *udc,
* ep0out is not used so do nothing here * ep0out is not used so do nothing here
* ep0in should be taken care * ep0in should be taken care
*--------------------------------------------------------------*/ *--------------------------------------------------------------*/
static int __init struct_ep_setup(struct fsl_udc *udc, unsigned char index, static int struct_ep_setup(struct fsl_udc *udc, unsigned char index,
char *name, int link) char *name, int link)
{ {
struct fsl_ep *ep = &udc->eps[index]; struct fsl_ep *ep = &udc->eps[index];
...@@ -2331,7 +2334,7 @@ static int __init struct_ep_setup(struct fsl_udc *udc, unsigned char index, ...@@ -2331,7 +2334,7 @@ static int __init struct_ep_setup(struct fsl_udc *udc, unsigned char index,
* all intialization operations implemented here except enabling usb_intr reg * all intialization operations implemented here except enabling usb_intr reg
* board setup should have been done in the platform code * board setup should have been done in the platform code
*/ */
static int __init fsl_udc_probe(struct platform_device *pdev) static int fsl_udc_probe(struct platform_device *pdev)
{ {
struct fsl_usb2_platform_data *pdata; struct fsl_usb2_platform_data *pdata;
struct resource *res; struct resource *res;
...@@ -2380,7 +2383,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) ...@@ -2380,7 +2383,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
goto err_release_mem_region; goto err_release_mem_region;
} }
pdata->regs = (void *)dr_regs; pdata->regs = (void __iomem *)dr_regs;
/* /*
* do platform specific init: check the clock, grab/config pins, etc. * do platform specific init: check the clock, grab/config pins, etc.
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#ifndef __FSL_USB2_UDC_H #ifndef __FSL_USB2_UDC_H
#define __FSL_USB2_UDC_H #define __FSL_USB2_UDC_H
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
/* ### define USB registers here /* ### define USB registers here
*/ */
#define USB_MAX_CTRL_PAYLOAD 64 #define USB_MAX_CTRL_PAYLOAD 64
......
...@@ -1325,8 +1325,6 @@ static int fusb300_udc_stop(struct usb_gadget *g, ...@@ -1325,8 +1325,6 @@ static int fusb300_udc_stop(struct usb_gadget *g,
{ {
struct fusb300 *fusb300 = to_fusb300(g); struct fusb300 *fusb300 = to_fusb300(g);
driver->unbind(&fusb300->gadget);
init_controller(fusb300); init_controller(fusb300);
fusb300->driver = NULL; fusb300->driver = NULL;
...@@ -1359,7 +1357,7 @@ static int __exit fusb300_remove(struct platform_device *pdev) ...@@ -1359,7 +1357,7 @@ static int __exit fusb300_remove(struct platform_device *pdev)
return 0; return 0;
} }
static int __init fusb300_probe(struct platform_device *pdev) static int fusb300_probe(struct platform_device *pdev)
{ {
struct resource *res, *ires, *ires1; struct resource *res, *ires, *ires1;
void __iomem *reg = NULL; void __iomem *reg = NULL;
......
...@@ -2213,7 +2213,7 @@ static int gr_probe(struct platform_device *pdev) ...@@ -2213,7 +2213,7 @@ static int gr_probe(struct platform_device *pdev)
return retval; return retval;
} }
static struct of_device_id gr_match[] = { static const struct of_device_id gr_match[] = {
{.name = "GAISLER_USBDC"}, {.name = "GAISLER_USBDC"},
{.name = "01_021"}, {.name = "01_021"},
{}, {},
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment