RE: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes
Hi, On Fri, 2013-07-26 at 02:06 +, Paul Zimmerman wrote: From: Felipe Balbi [mailto:ba...@ti.com] Sent: Thursday, July 25, 2013 1:52 PM On Thu, Jul 25, 2013 at 07:46:58PM +, Paul Zimmerman wrote: diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 607bef8..50c833f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -384,21 +384,6 @@ static int dwc3_probe(struct platform_device *pdev) dev_err(dev, missing memory resource\n); 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); if (node) { dwc-maximum_speed = of_usb_get_maximum_speed(node); @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) return -EPROBE_DEFER; } + 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; Ick. The driver is modifying the struct resource passed to it by the heh... platform code? That seems like a layering violation, and is fragile as hell. In addition to this bug, what would happen if the struct resource was declared 'const'? nothing would happen if it was declared const since platform_add_device makes a copy of what was declared, and that's always non-const. OK. Also, this is not *modifying* what was passed, just skipping the xHCI address space so we don't request_mem_region() an area we won't really handle and prevent xhci-hcd.ko from probing. Hmm? platform_get_resource() returns a pointer to an entry in the platform_device's resource[] array. And res-start += modifies the entry pointed at. If it didn't, the bug fixed by this patch wouldn't have happened. Are you sure this code will work OK if you build the driver as a module, modprobe it, rmmod it, and then modprobe it again? Seems like it won't, unless the dev-resource[] array gets reinitialized in between somehow. In addition, I think driver is wasting memory, because on every probe it will reallocate driver state variable. This also happens in several other drivers which are using deferred probe. Regards, Ivan All this assumes I'm reading the code correctly, of course. If I'm not, then never mind :) -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Audio I/O parameters
Alan Stern wrote: On Thu, 25 Jul 2013, James Stone wrote: The only slight difference I can see is that maybe the 3.10 uses slightly higher CPU load than 3.5 at the ridiculously low latency of 64 frames/period duplex. With the new patch, what you actually get is 44.1 frames/period (on average). In ALSA, the number of frames per period is a constant integer, and Jack requires it to be a power of two. (Where frame is an audio frame, and period is the interval between interrupts reported to user space.) However, something's not working right. The number of packets in each playback URB changes each time the URB is reused! That's not supposed to happen. The number of packets should remain fixed while the number of samples in each packet changes, based on the feedback info. I don't get it. The usbmon trace shows three URBs, and the number of packets goes like this: 8 8 8 8 4 8 4 8 3 8 4 8 4 8 3 8 4 8 3 8 4 8 4 8 With a sample rate of 44100 Hz and a packet rate of 8000 Hz, there should be about 5.5 samples per packet. With a period size of 64 audio frames, this results in about 11.6 packets per period. The driver does not completely fill URBs to ensure that interrupts happen at period boundaries. Another problem, not necessarily a bad one: The feedback data from the sound device indicates that its internal clock is actually running at 45168 Hz, even though it claims to be running at 44100. The feedback data is not measured in real Hz (wall clock time) but relatively to the 8 kHz bus clock. Furthermore, it does not show the device's internal clock but the rate at which the device wants to receive frames; this can be higher at the beginning of a stream if the device has an empty FIFO and wants to fill it up. Regards, Clemens -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
a small patch that fixes the ohci warn irq nobody cared on shutdown.
From: caizhiyong caizhiy...@huawei.com When ohci-hcd is shutting down, call ohci_usb_reset reset ohci-hcd, the root hub generate an interrupt, but ohci-rh_state is OHCI_RH_HALTED, and ohci_irq ignore the interrupt, the kernel trigger warning irq nobody cared. ehci-hcd is first disable interrupts, then reset ehci. this patch disable ohci interrupt before reset ohci. The patch is tested at the arm cortex-a9 demo board. Signed-off-by: caizhiyong caizhiy...@huawei.com --- drivers/usb/host/ohci-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index a9d3437..e4b3c63 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -938,8 +938,8 @@ static void ohci_stop (struct usb_hcd *hcd) if (quirk_nec(ohci)) flush_work(ohci-nec_work); - ohci_usb_reset (ohci); ohci_writel (ohci, OHCI_INTR_MIE, ohci-regs-intrdisable); + ohci_usb_reset(ohci); free_irq(hcd-irq, hcd); hcd-irq = 0; -- 1.8.1.5 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] USB: ohci_usb warn irq nobody cared on shutdown
From: caizhiyong caizhiy...@huawei.com When ohci-hcd is shutting down, call ohci_usb_reset reset ohci-hcd, the root hub generate an interrupt, but ohci-rh_state is OHCI_RH_HALTED, and ohci_irq ignore the interrupt, the kernel trigger warning irq nobody cared. ehci-hcd is first disable interrupts, then reset ehci. this patch disable ohci interrupt before reset ohci. The patch is tested at the arm cortex-a9 demo board. Signed-off-by: caizhiyong caizhiy...@huawei.com --- drivers/usb/host/ohci-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index a9d3437..e4b3c63 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -938,8 +938,8 @@ static void ohci_stop (struct usb_hcd *hcd) if (quirk_nec(ohci)) flush_work(ohci-nec_work); - ohci_usb_reset (ohci); ohci_writel (ohci, OHCI_INTR_MIE, ohci-regs-intrdisable); + ohci_usb_reset(ohci); free_irq(hcd-irq, hcd); hcd-irq = 0; -- 1.8.1.5 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] usb: phy-nop: Use RESET Controller for managing the reset line
On 07/25/2013 08:28 PM, Felipe Balbi wrote: On Thu, Jul 18, 2013 at 11:53:05AM +0300, Roger Quadros wrote: Till now we were modelling the RESET line as a voltage regulator and using the regulator framework to manage it. [1] introduces a GPIO based reset controller driver. We use that to manage the PHY reset line, at least for DT boots. For legacy boots, will still need to use the regulator framework for reset lines. [1] - http://thread.gmane.org/gmane.linux.drivers.devicetree/41348 Signed-off-by: Roger Quadros rog...@ti.com that's not in mainline yet, right ? Is it guaranteed that it will hit v3.12 merge window ? Right. It isn't yet. I'm not sure about 3.12. Let's ask Philipp. Philipp, is your GPIO Reset driver scheduled for 3.12? cheers, -roger -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: serial: add driver for Suunto ANT+ USB device
2013/7/26 Greg Kroah-Hartman: + Say Y here if you want to usb the Suunto ANT+ USB device. I think there might be a thinko: s/to usb/to use/ -- Daniele Forsi -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] usb: fix controller-PHY binding for OMAP3 platform
After the platform devices are created using PLATFORM_DEVID_AUTO, the device names given in usb_bind_phy (in board file) does not match with the actual device name causing the USB PHY library not to return the PHY reference when the MUSB controller request for the PHY in the non-dt boot case. So removed creating platform devices using PLATFORM_DEVID_AUTO in omap2430.c. This is also needed for the Generic PHY Framework [1] after it's redesigned to address Greg's concerns [2] *usb: musb: fix USB enumeration issue in OMAP3 platform* can be dropped since this patch series should fix the same issue. I've tested in beagle, but if any of you have any other OMAP3 boards, would be great if you can test it too. [1] - https://git.kernel.org/cgit/linux/kernel/git/kishon/linux-phy.git/ [2] - http://thread.gmane.org/gmane.linux.ports.arm.kernel/252813/focus=101661 Kishon Vijay Abraham I (2): usb: musb: omap: remove using PLATFORM_DEVID_AUTO in omap2430.c arm: omap: remove *.auto* from device names given in usb_bind_phy arch/arm/mach-omap2/board-2430sdp.c |2 +- arch/arm/mach-omap2/board-3430sdp.c |2 +- arch/arm/mach-omap2/board-cm-t35.c |2 +- arch/arm/mach-omap2/board-devkit8000.c |2 +- arch/arm/mach-omap2/board-igep0020.c |2 +- arch/arm/mach-omap2/board-ldp.c |2 +- arch/arm/mach-omap2/board-omap3beagle.c |2 +- arch/arm/mach-omap2/board-omap3evm.c |2 +- arch/arm/mach-omap2/board-omap3logic.c |2 +- arch/arm/mach-omap2/board-omap3pandora.c |2 +- arch/arm/mach-omap2/board-omap3stalker.c |2 +- arch/arm/mach-omap2/board-omap3touchbook.c |2 +- arch/arm/mach-omap2/board-overo.c|2 +- arch/arm/mach-omap2/board-rm680.c|2 +- arch/arm/mach-omap2/board-rx51.c |2 +- arch/arm/mach-omap2/board-zoom-peripherals.c |2 +- drivers/usb/musb/musb_core.c | 31 +- drivers/usb/musb/musb_core.h |2 ++ drivers/usb/musb/omap2430.c | 16 +++-- 19 files changed, 62 insertions(+), 19 deletions(-) -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] arm: omap: remove *.auto* from device names given in usb_bind_phy
Previously MUSB wrapper (OMAP) device used PLATFORM_DEVID_AUTO while creating MUSB core device. So in usb_bind_phy (binds the controller with the PHY), the device name of the controller had *.auto* in it. Since with using PLATFORM_DEVID_AUTO, there is no way to know the exact device name in advance, the data given in usb_bind_phy became obsolete and usb_get_phy was failing. So MUSB wrapper was modified not to use PLATFORM_DEVID_AUTO. Corresponding change is done in board file here. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- arch/arm/mach-omap2/board-2430sdp.c |2 +- arch/arm/mach-omap2/board-3430sdp.c |2 +- arch/arm/mach-omap2/board-cm-t35.c |2 +- arch/arm/mach-omap2/board-devkit8000.c |2 +- arch/arm/mach-omap2/board-igep0020.c |2 +- arch/arm/mach-omap2/board-ldp.c |2 +- arch/arm/mach-omap2/board-omap3beagle.c |2 +- arch/arm/mach-omap2/board-omap3evm.c |2 +- arch/arm/mach-omap2/board-omap3logic.c |2 +- arch/arm/mach-omap2/board-omap3pandora.c |2 +- arch/arm/mach-omap2/board-omap3stalker.c |2 +- arch/arm/mach-omap2/board-omap3touchbook.c |2 +- arch/arm/mach-omap2/board-overo.c|2 +- arch/arm/mach-omap2/board-rm680.c|2 +- arch/arm/mach-omap2/board-rx51.c |2 +- arch/arm/mach-omap2/board-zoom-peripherals.c |2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c index 244d8a5..17bb076 100644 --- a/arch/arm/mach-omap2/board-2430sdp.c +++ b/arch/arm/mach-omap2/board-2430sdp.c @@ -233,7 +233,7 @@ static void __init omap_2430sdp_init(void) omap_hsmmc_init(mmc); omap_mux_init_signal(usb0hs_stp, OMAP_PULL_ENA | OMAP_PULL_UP); - usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb); + usb_bind_phy(musb-hdrc.0, 0, twl4030_usb); usb_musb_init(NULL); board_smc91x_init(); diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c index 23b004a..5f43fc4 100644 --- a/arch/arm/mach-omap2/board-3430sdp.c +++ b/arch/arm/mach-omap2/board-3430sdp.c @@ -590,7 +590,7 @@ static void __init omap_3430sdp_init(void) omap_ads7846_init(1, gpio_pendown, 310, NULL); omap_serial_init(); omap_sdrc_init(hyb18m512160af6_sdrc_params, NULL); - usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb); + usb_bind_phy(musb-hdrc.0, 0, twl4030_usb); usb_musb_init(NULL); board_smc91x_init(); board_flash_init(sdp_flash_partitions, chip_sel_3430, 0); diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c index d4622ed..1c3345d 100644 --- a/arch/arm/mach-omap2/board-cm-t35.c +++ b/arch/arm/mach-omap2/board-cm-t35.c @@ -691,7 +691,7 @@ static void __init cm_t3x_common_init(void) cm_t35_init_display(); omap_twl4030_audio_init(cm-t3x, NULL); - usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb); + usb_bind_phy(musb-hdrc.0, 0, twl4030_usb); usb_musb_init(NULL); cm_t35_init_usbh(); cm_t35_init_camera(); diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c index f1d91ba..b4d57ec 100644 --- a/arch/arm/mach-omap2/board-devkit8000.c +++ b/arch/arm/mach-omap2/board-devkit8000.c @@ -594,7 +594,7 @@ static void __init devkit8000_init(void) omap_ads7846_init(2, OMAP3_DEVKIT_TS_GPIO, 0, NULL); - usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb); + usb_bind_phy(musb-hdrc.0, 0, twl4030_usb); usb_musb_init(NULL); usbhs_init(usbhs_bdata); board_nand_init(devkit8000_nand_partitions, diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c index 87e65dd..b1cbbba 100644 --- a/arch/arm/mach-omap2/board-igep0020.c +++ b/arch/arm/mach-omap2/board-igep0020.c @@ -659,7 +659,7 @@ static void __init igep_init(void) omap_serial_init(); omap_sdrc_init(m65kam_sdrc_params, m65kam_sdrc_params); - usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb); + usb_bind_phy(musb-hdrc.0, 0, twl4030_usb); usb_musb_init(NULL); igep_flash_init(); diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c index 62e4f70..02d7505 100644 --- a/arch/arm/mach-omap2/board-ldp.c +++ b/arch/arm/mach-omap2/board-ldp.c @@ -377,7 +377,7 @@ static void __init omap_ldp_init(void) omap_ads7846_init(1, 54, 310, NULL); omap_serial_init(); omap_sdrc_init(NULL, NULL); - usb_bind_phy(musb-hdrc.0.auto, 0, twl4030_usb); + usb_bind_phy(musb-hdrc.0, 0, twl4030_usb); usb_musb_init(NULL); board_nand_init(ldp_nand_partitions, ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0, nand_default_timings); diff --git
[PATCH 1/2] usb: musb: omap: remove using PLATFORM_DEVID_AUTO in omap2430.c
After the platform devices are created using PLATFORM_DEVID_AUTO, the device names given in usb_bind_phy (in board file) does not match with the actual device name causing the USB PHY library not to return the PHY reference when the MUSB controller request for the PHY in the non-dt boot case. So removed creating platform devices using PLATFORM_DEVID_AUTO in omap2430.c. This is also needed for the Generic PHY Framework. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- drivers/usb/musb/musb_core.c | 31 ++- drivers/usb/musb/musb_core.h |2 ++ drivers/usb/musb/omap2430.c | 16 ++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 29a24ce..eb5d876 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -121,7 +121,7 @@ MODULE_DESCRIPTION(DRIVER_INFO); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_LICENSE(GPL); MODULE_ALIAS(platform: MUSB_DRIVER_NAME); - +static DEFINE_IDA(musb_ida); /*-*/ @@ -132,6 +132,35 @@ static inline struct musb *dev_to_musb(struct device *dev) /*-*/ +int musb_get_id(struct device *dev, gfp_t gfp_mask) +{ + int ret; + int id; + + ret = ida_pre_get(musb_ida, gfp_mask); + if (!ret) { + dev_err(dev, failed to reserve resource for id\n); + return -ENOMEM; + } + + ret = ida_get_new(musb_ida, id); + if (ret 0) { + dev_err(dev, failed to allocate a new id\n); + return ret; + } + + return id; +} +EXPORT_SYMBOL_GPL(musb_get_id); + +void musb_put_id(struct device *dev, int id) +{ + + dev_dbg(dev, removing id %d\n, id); + ida_remove(musb_ida, id); +} +EXPORT_SYMBOL_GPL(musb_put_id); + #ifndef CONFIG_BLACKFIN static int musb_ulpi_read(struct usb_phy *phy, u32 offset) { diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c3..79545a4 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -511,6 +511,8 @@ static inline void musb_configure_ep0(struct musb *musb) extern const char musb_driver_name[]; extern void musb_stop(struct musb *musb); +extern int musb_get_id(struct device *dev, gfp_t gfp_mask); +extern void musb_put_id(struct device *dev, int id); extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 6708a3b..812a7fc 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -489,6 +489,7 @@ static int omap2430_probe(struct platform_device *pdev) struct device_node *np = pdev-dev.of_node; struct musb_hdrc_config *config; int ret = -ENOMEM; + int musbid; glue = devm_kzalloc(pdev-dev, sizeof(*glue), GFP_KERNEL); if (!glue) { @@ -496,10 +497,18 @@ static int omap2430_probe(struct platform_device *pdev) goto err0; } - musb = platform_device_alloc(musb-hdrc, PLATFORM_DEVID_AUTO); + /* get the musb id */ + musbid = musb_get_id(pdev-dev, GFP_KERNEL); + if (musbid 0) { + dev_err(pdev-dev, failed to allocate musb id\n); + ret = -ENOMEM; + goto err0; + } + + musb = platform_device_alloc(musb-hdrc, musbid); if (!musb) { dev_err(pdev-dev, failed to allocate musb device\n); - goto err0; + goto err1; } musb-dev.parent= pdev-dev; @@ -607,6 +616,9 @@ static int omap2430_probe(struct platform_device *pdev) err2: platform_device_put(musb); +err1: + musb_put_id(pdev-dev, musbid); + err0: return ret; } -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/16 = 2/2] usb: musb: dsps: remove EOI access
The EOI register is not present in the AM335x memory space according to the TRM and thus removed. Should any platform using the EOI register get merged then it may be used again if the register address is not zero. Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de --- drivers/usb/musb/musb_dsps.c | 15 ++- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 28ed497..36634e9 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -73,7 +73,6 @@ struct dsps_musb_wrapper { u16 revision; u16 control; u16 status; - u16 eoi; u16 epintr_set; u16 epintr_clear; u16 epintr_status; @@ -202,7 +201,6 @@ static void dsps_musb_disable(struct musb *musb) dsps_writel(reg_base, wrp-epintr_clear, wrp-txep_bitmap | wrp-rxep_bitmap); dsps_writeb(musb-mregs, MUSB_DEVCTL, 0); - dsps_writel(reg_base, wrp-eoi, 0); } static void otg_timer(unsigned long _musb) @@ -316,7 +314,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) /* Get usb core interrupts */ usbintr = dsps_readl(reg_base, wrp-coreintr_status); if (!usbintr !epintr) - goto eoi; + goto out; musb-int_usb = (usbintr wrp-usb_bitmap) wrp-usb_shift; if (usbintr) @@ -384,16 +382,11 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) if (musb-int_tx || musb-int_rx || musb-int_usb) ret |= musb_interrupt(musb); - eoi: - /* EOI needs to be written for the IRQ to be re-asserted. */ - if (ret == IRQ_HANDLED || epintr || usbintr) - dsps_writel(reg_base, wrp-eoi, 1); - /* Poll for ID change */ if (musb-xceiv-state == OTG_STATE_B_IDLE) mod_timer(glue-timer[pdev-id], jiffies + wrp-poll_seconds * HZ); - +out: spin_unlock_irqrestore(musb-lock, flags); return ret; @@ -447,9 +440,6 @@ static int dsps_musb_init(struct musb *musb) val = ~(1 wrp-otg_disable); dsps_writel(musb-ctrl_base, wrp-phy_utmi, val); - /* clear level interrupt */ - dsps_writel(reg_base, wrp-eoi, 0); - return 0; err0: usb_put_phy(musb-xceiv); @@ -746,7 +736,6 @@ static const struct dsps_musb_wrapper am33xx_driver_data = { .revision = 0x00, .control= 0x14, .status = 0x18, - .eoi= 0x24, .epintr_set = 0x38, .epintr_clear = 0x40, .epintr_status = 0x30, -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 02/14] usb: chipidea: imx: remove vbus regulator operation
Since we have added vbus reguatlor operation at common host file (chipidea/host.c), the glue layer vbus operation isn't needed any more. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/ci_hdrc_imx.c | 30 +++--- 1 files changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 14362c0..d06355e 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -31,7 +31,6 @@ struct ci_hdrc_imx_data { struct usb_phy *phy; struct platform_device *ci_pdev; struct clk *clk; - struct regulator *reg_vbus; }; static const struct usbmisc_ops *usbmisc_ops; @@ -141,22 +140,13 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) goto err_clk; } - /* we only support host now, so enable vbus here */ - data-reg_vbus = devm_regulator_get(pdev-dev, vbus); - if (!IS_ERR(data-reg_vbus)) { - ret = regulator_enable(data-reg_vbus); - if (ret) { - dev_err(pdev-dev, - Failed to enable vbus regulator, err=%d\n, - ret); - goto err_clk; - } - } else { - data-reg_vbus = NULL; - } - pdata.phy = data-phy; + /* Get the vbus regulator */ + pdata.reg_vbus = devm_regulator_get(pdev-dev, vbus); + if (IS_ERR(pdata.reg_vbus)) + pdata.reg_vbus = NULL; + if (!pdev-dev.dma_mask) pdev-dev.dma_mask = pdev-dev.coherent_dma_mask; if (!pdev-dev.coherent_dma_mask) @@ -167,7 +157,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) if (ret) { dev_err(pdev-dev, usbmisc init failed, ret=%d\n, ret); - goto err; + goto err_clk; } } @@ -179,7 +169,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) dev_err(pdev-dev, Can't register ci_hdrc platform device, err=%d\n, ret); - goto err; + goto err_clk; } if (usbmisc_ops usbmisc_ops-post) { @@ -200,9 +190,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) disable_device: ci_hdrc_remove_device(data-ci_pdev); -err: - if (data-reg_vbus) - regulator_disable(data-reg_vbus); err_clk: clk_disable_unprepare(data-clk); return ret; @@ -215,9 +202,6 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev) pm_runtime_disable(pdev-dev); ci_hdrc_remove_device(data-ci_pdev); - if (data-reg_vbus) - regulator_disable(data-reg_vbus); - if (data-phy) { usb_phy_shutdown(data-phy); module_put(data-phy-dev-driver-owner); -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 13/14] usb: chipidea: udc: .pullup is valid when vbus is on at CI_HDRC_PULLUP_ON_VBUS
When the flag CI_HDRC_PULLUP_ON_VBUS is set, .pullup should only be called when the vbus is active. When the CI_HDRC_PULLUP_ON_VBUS is set, the controller only begins to run when the vbus is on, So, it is only meaningful software set pullup/pulldown after the controller begins to run. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/udc.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 45abf4d..b7ead5f 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1514,6 +1514,10 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on) { struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); + if ((ci-platdata-flags CI_HDRC_PULLUP_ON_VBUS) +!ci-vbus_active) + return -EOPNOTSUPP; + if (is_on) hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS); else -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 12/14] usb: chipidea: udc: misuse flag CI_HDRC_REGS_SHARED and CI_HDRC_PULLUP_ON_VBUS
CI_HDRC_REGS_SHARED stands for the controller registers is shared with other USB drivers, if all USB drivers are at chipidea/, it doesn't needed to set. CI_HDRC_PULLUP_ON_VBUS stands for pullup dp when the vbus is on. This flag doesn't need to set if the vbus is always on for gadget since dp has always pulled up after the gadget has initialized. So, the current code seems to misuse this two flags. - When the gadget initializes, the controller doesn't need to run if it depends on vbus (CI_HDRC_PULLUP_ON_VBUS), it does not relate to shared register. - When the gadget starts (load one gadget module), the controller can run if vbus is on (CI_HDRC_PULLUP_ON_VBUS), it also does not relate to shared register. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/udc.c |5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index c70ce38..45abf4d 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1637,8 +1637,7 @@ static int ci_udc_start(struct usb_gadget *gadget, pm_runtime_get_sync(ci-gadget.dev); if (ci-platdata-flags CI_HDRC_PULLUP_ON_VBUS) { if (ci-vbus_active) { - if (ci-platdata-flags CI_HDRC_REGS_SHARED) - hw_device_reset(ci, USBMODE_CM_DC); + hw_device_reset(ci, USBMODE_CM_DC); } else { pm_runtime_put_sync(ci-gadget.dev); goto done; @@ -1801,7 +1800,7 @@ static int udc_start(struct ci_hdrc *ci) } } - if (!(ci-platdata-flags CI_HDRC_REGS_SHARED)) { + if (!(ci-platdata-flags CI_HDRC_PULLUP_ON_VBUS)) { retval = hw_device_reset(ci, USBMODE_CM_DC); if (retval) goto put_transceiver; -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Help adding trace events to xHCI
On Thu, 2013-07-11 at 15:29 -0400, Steven Rostedt wrote: Note that there's no easy way to dynamically allocate the right amount of space in the ringbuffer, or at least I haven't found one. We therefore have a static size, which is somewhat inefficient. Can you add a helper function? If these trace events can't nest (one in interrupt context and another in normal context with interrupts enabled), then you can just allocate a per-cpu buffer and store the string in that, and then move the string into the buffer. In my situation personally, I can't, because I can have them in interrupt and regular context (with interrupts enabled). My original though here was that we should be able to reserve (maximum) space on the per-CPU buffer, and then relinquish some of it after the tracepoint was written to the data, but I never had the time to check if that was possible to implement. It would make it a little inefficient at page boundaries, but that seems OK given that our maximum size is only ~100 bytes or so now. johannes -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 01/14] usb: chipidea: add vbus regulator control
For boards which have board level vbus control (eg, through gpio), we need to vbus operation according to below rules: - For host, we need open vbus before start hcd, and close it after remove hcd. - For otg, the vbus needs to be on/off when usb role switches. When the host roles begins, it opens vbus; when the host role finishes, it closes vbus. We put vbus operation to host as host is the only vbus user, When we are at host mode, the vbus is on, when we are not at host mode, vbus should be off. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/host.c | 23 ++- include/linux/usb/chipidea.h |1 + 2 files changed, 23 insertions(+), 1 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 40d0fda..e94e52b 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -24,6 +24,7 @@ #include linux/usb.h #include linux/usb/hcd.h #include linux/usb/chipidea.h +#include linux/regulator/consumer.h #include ../host/ehci.h @@ -64,9 +65,19 @@ static int host_start(struct ci_hdrc *ci) ehci-caps = ci-hw_bank.cap; ehci-has_hostpc = ci-hw_bank.lpm; + if (ci-platdata-reg_vbus) { + ret = regulator_enable(ci-platdata-reg_vbus); + if (ret) { + dev_err(ci-dev, + Failed to enable vbus regulator, ret=%d\n, + ret); + goto put_hcd; + } + } + ret = usb_add_hcd(hcd, 0, 0); if (ret) - usb_put_hcd(hcd); + goto disable_reg; else ci-hcd = hcd; @@ -74,6 +85,14 @@ static int host_start(struct ci_hdrc *ci) hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); return ret; + +disable_reg: + regulator_disable(ci-platdata-reg_vbus); + +put_hcd: + usb_put_hcd(hcd); + + return ret; } static void host_stop(struct ci_hdrc *ci) @@ -82,6 +101,8 @@ static void host_stop(struct ci_hdrc *ci) usb_remove_hcd(hcd); usb_put_hcd(hcd); + if (ci-platdata-reg_vbus) + regulator_disable(ci-platdata-reg_vbus); } int ci_hdrc_host_init(struct ci_hdrc *ci) diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 2562994..118bf66 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -24,6 +24,7 @@ struct ci_hdrc_platform_data { #define CI_HDRC_CONTROLLER_RESET_EVENT 0 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 void(*notify_event) (struct ci_hdrc *ci, unsigned event); + struct regulator *reg_vbus; }; /* Default offset of capability registers */ -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 07/14] usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG
Since we need otgsc to know vbus's status at some chipidea controllers even it is peripheral-only mode. Besides, some SoCs (eg, AR9331 SoC) don't have otgsc register even the DCCPARAMS_DC and DCCPARAMS_HC are both 1 at CAP_DCCPARAMS. We inroduce flag CI_HDRC_DUAL_ROLE_NOT_OTG to indicate if the controller is dual role, but not supports OTG. If this flag is not set, we follow the rule that if DCCPARAMS_DC and DCCPARAMS_HC are both 1 at CAP_DCCPARAMS, then this controller is otg capable. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/core.c | 38 +++--- include/linux/usb/chipidea.h |5 + 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 93961ff..28983c3 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -405,6 +405,18 @@ static inline void ci_role_destroy(struct ci_hdrc *ci) ci_hdrc_host_destroy(ci); } +static void ci_get_otg_capable(struct ci_hdrc *ci) +{ + if (ci-platdata-flags CI_HDRC_DUAL_ROLE_NOT_OTG) + ci-is_otg = false; + else + ci-is_otg = (hw_read(ci, CAP_DCCPARAMS, + DCCPARAMS_DC | DCCPARAMS_HC) + == (DCCPARAMS_DC | DCCPARAMS_HC)); + if (ci-is_otg) + dev_dbg(ci-dev, It is OTG capable controller\n); +} + static int ci_hdrc_probe(struct platform_device *pdev) { struct device *dev = pdev-dev; @@ -461,6 +473,9 @@ static int ci_hdrc_probe(struct platform_device *pdev) return -ENODEV; } + /* To know if controller is OTG capable or not */ + ci_get_otg_capable(ci); + if (!ci-platdata-phy_mode) ci-platdata-phy_mode = of_usb_get_phy_mode(dev-of_node); @@ -491,10 +506,22 @@ static int ci_hdrc_probe(struct platform_device *pdev) } if (ci-roles[CI_ROLE_HOST] ci-roles[CI_ROLE_GADGET]) { - ci-is_otg = true; - /* ID pin needs 1ms debouce time, we delay 2ms for safe */ - mdelay(2); - ci-role = ci_otg_role(ci); + if (ci-is_otg) { + /* +* ID pin needs 1ms debouce time, +* we delay 2ms for safe. +*/ + mdelay(2); + ci-role = ci_otg_role(ci); + ci_hdrc_otg_init(ci); + } else { + /* +* If the controller is not OTG capable, but support +* role switch, the defalt role is gadget, and the +* user can switch it through debugfs (proc in future?) +*/ + ci-role = CI_ROLE_GADGET; + } } else { ci-role = ci-roles[CI_ROLE_HOST] ? CI_ROLE_HOST @@ -514,9 +541,6 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ret) goto stop; - if (ci-is_otg) - ci_hdrc_otg_init(ci); - ret = dbg_create_files(ci); if (!ret) return 0; diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 118bf66..e94dc2e 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -20,6 +20,11 @@ struct ci_hdrc_platform_data { #define CI_HDRC_REQUIRE_TRANSCEIVERBIT(1) #define CI_HDRC_PULLUP_ON_VBUS BIT(2) #define CI_HDRC_DISABLE_STREAMING BIT(3) + /* +* Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1, +* but otg is not supported (no register otgsc). +*/ +#define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4) enum usb_dr_modedr_mode; #define CI_HDRC_CONTROLLER_RESET_EVENT 0 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 08/14] usb: chipidea: disable all interrupts and clear all interrupts status
During the initialization, it needs to disable all interrupts enable bit as well as clear all interrupts status bits to avoid exceptional interrupt. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/core.c | 11 ++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 28983c3..8884af6 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -198,6 +198,12 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem *base) if (ci-hw_ep_max ENDPT_MAX) return -ENODEV; + /* Disable all interrupts bits */ + hw_write(ci, OP_USBINTR, 0x, 0); + + /* Clear all interrupts status bits*/ + hw_write(ci, OP_USBSTS, 0x, 0x); + dev_dbg(ci-dev, ChipIdea HDRC found, lpm: %d; cap: %p op: %p\n, ci-hw_bank.lpm, ci-hw_bank.cap, ci-hw_bank.op); @@ -413,8 +419,11 @@ static void ci_get_otg_capable(struct ci_hdrc *ci) ci-is_otg = (hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DC | DCCPARAMS_HC) == (DCCPARAMS_DC | DCCPARAMS_HC)); - if (ci-is_otg) + if (ci-is_otg) { dev_dbg(ci-dev, It is OTG capable controller\n); + ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS); + ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS); + } } static int ci_hdrc_probe(struct platform_device *pdev) -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 10/14] usb: chipidea: add vbus interrupt handler
We add vbus interrupt handler at ci_otg_work, it uses OTGSC_BSV(at otgsc) to know it is connect or disconnet event. Meanwhile, we introduce two flags id_event and b_sess_valid_event to indicate it is an id interrupt or a vbus interrupt. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/ci.h |5 + drivers/usb/chipidea/core.c | 28 +++- drivers/usb/chipidea/otg.c | 42 +++--- drivers/usb/chipidea/otg.h |1 + drivers/usb/chipidea/udc.c |7 +++ 5 files changed, 71 insertions(+), 12 deletions(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 33cb29f..3160363 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -132,6 +132,9 @@ struct hw_bank { * @transceiver: pointer to USB PHY, if any * @hcd: pointer to usb_hcd for ehci host driver * @debugfs: root dentry for this controller in debugfs + * @id_event: indicates there is an id event, and handled at ci_otg_work + * @b_sess_valid_event: indicates there is a vbus event, and handled + * at ci_otg_work */ struct ci_hdrc { struct device *dev; @@ -168,6 +171,8 @@ struct ci_hdrc { struct usb_phy *transceiver; struct usb_hcd *hcd; struct dentry *debugfs; + boolid_event; + boolb_sess_valid_event; }; static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 78c4721..0fbeb45 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -304,16 +304,34 @@ static irqreturn_t ci_irq(int irq, void *data) if (ci-is_otg) otgsc = hw_read(ci, OP_OTGSC, ~0); - if (ci-role != CI_ROLE_END) - ret = ci_role(ci)-irq(ci); + /* +* Handle id change interrupt, it indicates device/host function +* switch. +*/ + if (ci-is_otg (otgsc OTGSC_IDIE) (otgsc OTGSC_IDIS)) { + ci-id_event = true; + ci_clear_otg_interrupt(ci, OTGSC_IDIS); + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + return IRQ_HANDLED; + } - if (ci-is_otg (otgsc OTGSC_IDIS)) { - hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS); + /* +* Handle vbus change interrupt, it indicates device connection +* and disconnection events. +*/ + if (ci-is_otg (otgsc OTGSC_BSVIE) (otgsc OTGSC_BSVIS)) { + ci-b_sess_valid_event = true; + ci_clear_otg_interrupt(ci, OTGSC_BSVIS); disable_irq_nosync(ci-irq); queue_work(ci-wq, ci-work); - ret = IRQ_HANDLED; + return IRQ_HANDLED; } + /* Handle device/host interrupt */ + if (ci-role != CI_ROLE_END) + ret = ci_role(ci)-irq(ci); + return ret; } diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 68f2faf..c74194d 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -52,13 +52,23 @@ enum ci_role ci_otg_role(struct ci_hdrc *ci) return role; } -/** - * ci_role_work - perform role changing based on ID pin - * @work: work struct - */ -static void ci_role_work(struct work_struct *work) +void ci_handle_vbus_change(struct ci_hdrc *ci) +{ + u32 otgsc; + + if (!ci-is_otg) + return; + + otgsc = hw_read(ci, OP_OTGSC, ~0); + + if (otgsc OTGSC_BSV) + usb_gadget_vbus_connect(ci-gadget); + else + usb_gadget_vbus_disconnect(ci-gadget); +} + +static void ci_handle_id_switch(struct ci_hdrc *ci) { - struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); enum ci_role role = ci_otg_role(ci); if (role != ci-role) { @@ -68,17 +78,35 @@ static void ci_role_work(struct work_struct *work) ci_role_stop(ci); ci_role_start(ci, role); } +} +/** + * ci_otg_work - perform otg (vbus/id) event handle + * @work: work struct + */ +static void ci_otg_work(struct work_struct *work) +{ + struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); + + if (ci-id_event) { + ci-id_event = false; + ci_handle_id_switch(ci); + } else if (ci-b_sess_valid_event) { + ci-b_sess_valid_event = false; + ci_handle_vbus_change(ci); + } else + dev_err(ci-dev, unexpected event occurs at %s\n, __func__); enable_irq(ci-irq); } + /** * ci_hdrc_otg_init - initialize otg struct * ci: the controller */ int ci_hdrc_otg_init(struct ci_hdrc *ci) { - INIT_WORK(ci-work, ci_role_work); + INIT_WORK(ci-work,
[PATCH v13 00/14] Add tested id switch and vbus connect detect support for Chipidea
This patchset adds tested otg id switch function and vbus connect and disconnect detection for chipidea driver. And fix kinds of bugs found at chipidea drivers after enabling id and vbus detection. This patch are fully tested at imx6 sabresd and imx28evk platform by me. Besides, marek tested it on two STMP3780-based boards (not yet mainline) and two MX28-based boards. My chipidea repo: https://github.com/hzpeterchen/linux-usb.git Chagnes for v13: - Add Tested-by: Marek Vasut ma...@denx.de - [Sascha's comments]: Add return value check for devm_regulator_get. [3/14] - [Marc's comments]: Change timeout usage at hw_wait_reg. [11/14] - [Alex's comments]: Using platdata flag to indicate dual role but not OTG controller. [7/14] Changes for v12: - Rebased greg's usb-next tree (3.10.0-rc7+) - Split more small patches for single function and fix. Changes for v11: - mark ci_handle_vbus_change as static as it is only used at core.c [3/9] - Move the vbus operation for platform code to host code, as vbus operation is common operation, and host is the only user for vbus. When it is host mode, we need to open vbus, when it is out of host mode, we need to close vbus. [6/9] [8/9] - Delete the delayed work at core.c as it is not needed. [7/9] Changes for v10: - Delete [8/9] at v9, ci core's drvdata must be set for further operation. [8/8] Changes for v9: - Some small comments from Alex like: variable comment for otg event additional newline. [3/9] - Import function tell show if the controller has otg capable, if the controller supports both host and device, we think it is otg capable, and can read OTGSC. [3/9] - Merge two otg patches [v8 3/8] and [v8 4/8] to one [v9 3/9]. [3/9] - Add inline to ci_hdrc_gadget_destroy if CONFIG_USB_CHIPIDEA_UDC is not defined, it can fix one build warning defined but not used [3/9] - One comment from Felipe about changing calling gadget disconnect API at chipidea's udc driver. I move calling ci-driver-disconnect from _gadget_stop_activity to which calls _gadget_stop_activity except ci13xxx_stop, as udc core will call disconnect when do rmmod gadget. [7/9] - Add ci core probe's return value to ci's platform_data, we do this for getting core's probe's result at platform layer, and quit it if the core's probe fails. [8/9] [9/9] Changes for v8: - Add ci_supports_gadget helper to know if the controller supports gadget, if the controller supports gadget, it needs to read otgsc to know the vbus value, basically, if the controller supports gadget, it will support host as well [3/8] - At ci_hdrc_probe, it needs to add free memory at error path [3/8] - Cosolidate ci-driver = NULL at ci13xxx_stop [8/8] Changes for v7: For Patch 8/8, we only need to set ci-driver to NULL when usb cable is not connected, for other changes, it will case some runtime pm unmatch and un-align with udc-core composite driver problems. Changes for v6: - Add Alex comments for init/destroy function [3/8] [4/8] - Remove memset(ci-gadget, 0, sizeof(ci-gadget)) at destory function [4/8] - Add Kishon's comment: Change the format of struct usb_otg otg at drivers/usb/chipidea/ci.h [1/8] - Add comments for CI_VBUS_STABLE_TIMEOUT [3/8] - Change the otg_set_peripheral return value check as the fully chipidea driver users don't need it. [4/8] - Fix one bug that the oops when re-plug in usb cable after rmmod gadget [8/8] Peter Chen (14): usb: chipidea: add vbus regulator control usb: chipidea: imx: remove vbus regulator operation usb: chipidea: imx: add return value check for devm_regulator_get usb: chipidea: udc: otg_set_peripheral is useless for some chipidea users usb: chipidea: otg: Add otg file used to access otgsc usb: chipidea: Add role init and destory APIs usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG usb: chipidea: disable all interrupts and clear all interrupts status usb: chipidea: move otg relate things to otg file usb: chipidea: add vbus interrupt handler usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts usb: chipidea: udc: misuse flag CI_HDRC_REGS_SHARED and CI_HDRC_PULLUP_ON_VBUS usb: chipidea: udc: .pullup is valid when vbus is on at CI_HDRC_PULLUP_ON_VBUS usb: chipidea: udc: fix the oops when plugs in usb cable after rmmod gadget drivers/usb/chipidea/Makefile |2 +- drivers/usb/chipidea/bits.h| 10 ++ drivers/usb/chipidea/ci.h |8 ++ drivers/usb/chipidea/ci_hdrc_imx.c | 40 - drivers/usb/chipidea/core.c| 161 drivers/usb/chipidea/host.c| 30 +++- drivers/usb/chipidea/host.h|6 ++ drivers/usb/chipidea/otg.c | 135 ++ drivers/usb/chipidea/otg.h | 22 + drivers/usb/chipidea/udc.c | 72 drivers/usb/chipidea/udc.h |6 ++ include/linux/usb/chipidea.h |6 ++ 12 files changed, 402 insertions(+), 96 deletions(-) create mode 100644
[PATCH v13 04/14] usb: chipidea: udc: otg_set_peripheral is useless for some chipidea users
It is useless at below cases: - If we implement both usb host and device at chipidea driver. - If we don't need phy-otg. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/udc.c |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index e475fcd..116c762 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1805,7 +1805,12 @@ static int udc_start(struct ci_hdrc *ci) if (ci-transceiver) { retval = otg_set_peripheral(ci-transceiver-otg, ci-gadget); - if (retval) + /* +* If we implement all USB functions using chipidea drivers, +* it doesn't need to call above API, meanwhile, if we only +* use gadget function, calling above API is useless. +*/ + if (retval retval != -ENOTSUPP) goto put_transceiver; } -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v13 09/14] usb: chipidea: move otg relate things to otg file
Move otg relate things to otg file. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/core.c | 63 +-- drivers/usb/chipidea/otg.c | 57 +- drivers/usb/chipidea/otg.h |2 + 3 files changed, 70 insertions(+), 52 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 8884af6..78c4721 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -295,40 +295,6 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode) return 0; } -/** - * ci_otg_role - pick role based on ID pin state - * @ci: the controller - */ -static enum ci_role ci_otg_role(struct ci_hdrc *ci) -{ - u32 sts = hw_read(ci, OP_OTGSC, ~0); - enum ci_role role = sts OTGSC_ID - ? CI_ROLE_GADGET - : CI_ROLE_HOST; - - return role; -} - -/** - * ci_role_work - perform role changing based on ID pin - * @work: work struct - */ -static void ci_role_work(struct work_struct *work) -{ - struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); - enum ci_role role = ci_otg_role(ci); - - if (role != ci-role) { - dev_dbg(ci-dev, switching from %s to %s\n, - ci_role(ci)-name, ci-roles[role]-name); - - ci_role_stop(ci); - ci_role_start(ci, role); - } - - enable_irq(ci-irq); -} - static irqreturn_t ci_irq(int irq, void *data) { struct ci_hdrc *ci = data; @@ -409,6 +375,8 @@ static inline void ci_role_destroy(struct ci_hdrc *ci) { ci_hdrc_gadget_destroy(ci); ci_hdrc_host_destroy(ci); + if (ci-is_otg) + ci_hdrc_otg_destory(ci); } static void ci_get_otg_capable(struct ci_hdrc *ci) @@ -475,13 +443,6 @@ static int ci_hdrc_probe(struct platform_device *pdev) return -ENODEV; } - INIT_WORK(ci-work, ci_role_work); - ci-wq = create_singlethread_workqueue(ci_otg); - if (!ci-wq) { - dev_err(dev, can't create workqueue\n); - return -ENODEV; - } - /* To know if controller is OTG capable or not */ ci_get_otg_capable(ci); @@ -510,8 +471,15 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (!ci-roles[CI_ROLE_HOST] !ci-roles[CI_ROLE_GADGET]) { dev_err(dev, no supported roles\n); - ret = -ENODEV; - goto rm_wq; + return -ENODEV; + } + + if (ci-is_otg) { + ret = ci_hdrc_otg_init(ci); + if (ret) { + dev_err(dev, init otg fails, ret = %d\n, ret); + goto stop; + } } if (ci-roles[CI_ROLE_HOST] ci-roles[CI_ROLE_GADGET]) { @@ -522,7 +490,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) */ mdelay(2); ci-role = ci_otg_role(ci); - ci_hdrc_otg_init(ci); + ci_enable_otg_interrupt(ci, OTGSC_IDIE); } else { /* * If the controller is not OTG capable, but support @@ -541,7 +509,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ret) { dev_err(dev, can't start %s role\n, ci_role(ci)-name); ret = -ENODEV; - goto rm_wq; + goto stop; } platform_set_drvdata(pdev, ci); @@ -557,9 +525,6 @@ static int ci_hdrc_probe(struct platform_device *pdev) free_irq(ci-irq, ci); stop: ci_role_destroy(ci); -rm_wq: - flush_workqueue(ci-wq); - destroy_workqueue(ci-wq); return ret; } @@ -569,8 +534,6 @@ static int ci_hdrc_remove(struct platform_device *pdev) struct ci_hdrc *ci = platform_get_drvdata(pdev); dbg_remove_files(ci); - flush_workqueue(ci-wq); - destroy_workqueue(ci-wq); free_irq(ci-irq, ci); ci_role_destroy(ci); diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index abefb4d..68f2faf 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -39,12 +39,65 @@ void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits) } /** - * ci_hdrc_otg_init - initialize otgsc bits + * ci_otg_role - pick role based on ID pin state + * @ci: the controller + */ +enum ci_role ci_otg_role(struct ci_hdrc *ci) +{ + u32 sts = hw_read(ci, OP_OTGSC, ~0); + enum ci_role role = sts OTGSC_ID + ? CI_ROLE_GADGET + : CI_ROLE_HOST; + + return role; +} + +/** + * ci_role_work - perform role changing based on ID pin + * @work: work struct + */ +static void ci_role_work(struct work_struct *work) +{ + struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); + enum ci_role role =
[PATCH v13 14/14] usb: chipidea: udc: fix the oops when plugs in usb cable after rmmod gadget
When we rmmod gadget, the ci-driver needs to be cleared. Otherwise, we plug in usb cable again, the driver will consider gadget is there, in fact, it was removed. Besides, consolidate the calling of ci-driver-disconnect, when we do rmmod gadget, the gadget's disconnect should be called from udc core. Below is the oops this patch fixes. root@freescale ~$ ci_hdrc ci_hdrc.0: Connected to host Unable to handle kernel paging request at virtual address 7f01171c pgd = 80004000 [7f01171c] *pgd=4fa1e811, *pte=, *ppte= Internal error: Oops: 7 [#1] SMP ARM Modules linked in: f_acm libcomposite u_serial [last unloaded: g_serial] CPU: 0Not tainted (3.8.0-rc5+ #221) PC is at _gadget_stop_activity+0xbc/0x128 LR is at ep_fifo_flush+0x68/0xa0 pc : [803634cc]lr : [80363938]psr: 2193 sp : 806c7dc8 ip : fp : 806c7de4 r10: r9 : 80710ea4 r8 : r7 : bf834094 r6 : bf834098 r5 : bf834010 r4 : bf8340a0 r3 : 7f011708 r2 : 01940194 r1 : a193 r0 : bf834014 Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c53c7d Table: 4f06404a DAC: 0017 Process swapper/0 (pid: 0, stack limit = 0x806c6238) Stack: (0x806c7dc8 to 0x806c8000) 7dc0: bf834010 bf809950 bf834010 004b 806c7e44 806c7de8 7de0: 80365400 8036341c ec1c ec1c 0040 fff5ede0 bf834014 7e00: 000a1220 002e d958 806c7e3c 806c7e20 8004e870 bf834010 7e20: bf809950 004b 004b 80710ea4 806c7e5c 806c7e48 7e40: 80362888 80365154 bfb35180 bf809950 806c7e9c 806c7e60 8008111c 803627f4 7e60: 00989680 bf809900 bf809964 812df8c0 bf809900 bf809950 806c3f2c 7e80: 004b 412fc09a 806c7eb4 806c7ea0 80081368 800810b8 7ea0: bf809900 bf809950 806c7ecc 806c7eb8 800843c8 8008130c 004b 806cf748 7ec0: 806c7ee4 806c7ed0 80081088 8008432c 806c6000 806cf748 806c7f0c 806c7ee8 7ee0: 8000fa44 8008105c f400010c 806ce974 806c7f30 f4000110 806d29e8 412fc09a 7f00: 806c7f2c 806c7f10 80008584 8000f9f4 8000fbd0 6013 806c7f64 7f20: 806c7f84 806c7f30 8000eac0 80008554 000f 8001aea0 7f40: 806c6000 80712a48 804f0040 806d29e8 412fc09a 806c7f84 7f60: 806c7f88 806c7f78 8000fbcc 8000fbd0 6013 806c7fac 806c7f88 7f80: 8001015c 8000fb9c 806cf5b0 80712980 806a4528 8fff 1000406a 412fc09a 7fa0: 806c7fbc 806c7fb0 804e5334 800100ac 806c7ff4 806c7fc0 80668940 804e52d4 7fc0: 806684bc 806a4528 10c53c7d 806ce94c 7fe0: 806a4524 806d29dc 806c7ff8 10008078 806686b0 Backtrace: [80363410] (_gadget_stop_activity+0x0/0x128) from [80365400] (udc_irq+0x2b8/0xf38) r7:004b r6:bf834010 r5:bf809950 r4:bf834010 [80365148] (udc_irq+0x0/0xf38) from [80362888] (ci_irq+0xa0/0xf4) [803627e8] (ci_irq+0x0/0xf4) from [8008111c] (handle_irq_event_percpu+0x70/0x254) r5:bf809950 r4:bfb35180 [800810ac] (handle_irq_event_percpu+0x0/0x254) from [80081368] (handle_irq_event+0x68/0x88) [80081300] (handle_irq_event+0x0/0x88) from [800843c8] (handle_fasteoi_irq+0xa8/0x178) r5:bf809950 r4:bf809900 [80084320] (handle_fasteoi_irq+0x0/0x178) from [80081088] (generic_handle_irq+0x38/0x40) r5:806cf748 r4:004b [80081050] (generic_handle_irq+0x0/0x40) from [8000fa44] (handle_IRQ+0x5c/0xbc) r5:806cf748 r4:806c6000 [8000f9e8] (handle_IRQ+0x0/0xbc) from [80008584] (gic_handle_irq+0x3c/0x70) r9:412fc09a r8:806d29e8 r7:f4000110 r6:806c7f30 r5:806ce974 r4:f400010c [80008548] (gic_handle_irq+0x0/0x70) from [8000eac0] (__irq_svc+0x40/0x54) Exception stack(0x806c7f30 to 0x806c7f78) 7f20: 000f 8001aea0 7f40: 806c6000 80712a48 804f0040 806d29e8 412fc09a 806c7f84 7f60: 806c7f88 806c7f78 8000fbcc 8000fbd0 6013 r7:806c7f64 r6: r5:6013 r4:8000fbd0 [8000fb90] (default_idle+0x0/0x4c) from [8001015c] (cpu_idle+0xbc/0xf8) [800100a0] (cpu_idle+0x0/0xf8) from [804e5334] (rest_init+0x6c/0x84) r9:412fc09a r8:1000406a r7:8fff r6:806a4528 r5:80712980 r4:806cf5b0 [804e52c8] (rest_init+0x0/0x84) from [80668940] (start_kernel+0x29c/0x2ec) [806686a4] (start_kernel+0x0/0x2ec) from [10008078] (0x10008078) Code: e12fff33 e5953200 e353 0a02 (e5933014) ---[ end trace aade28ad434062bd ]--- Kernel panic - not syncing: 0xbf8bdfa8) df60: 000f 8001aea0 bf8bc000 80712a48 804f0040 df80: 806d29e8 412fc09a bf8bdfb4 bf8bdfb8 bf8bdfa8 8000fbcc 8000fbd0 dfa0: 6013 r7:bf8bdf94 r6: r5:6013 r4:8000fbd0 [8000fb90] (default_idle+0x0/0x4c) from [8001015c] (cpu_idle+0xbc/0xf8) [800100a0] (cpu_idle+0x0/0xf8) from [804e7930] (secondary_start_kernel+0x120/0x148) r9:412fc09a r8:1000406a r7:80712d20 r6:10c03c7d r5:0002 r4:806e2008 [804e7810] (secondary_start_kernel+0x0/0x148) from [104e7148] (0x104e7148) r5:001f r4:4f8a806a CPU3: stopping Backtrace:
[PATCH v13 05/14] usb: chipidea: otg: Add otg file used to access otgsc
This file is mainly used to access otgsc currently, it may add otg related things in the future. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/Makefile |2 +- drivers/usb/chipidea/bits.h | 10 drivers/usb/chipidea/core.c |3 +- drivers/usb/chipidea/otg.c| 50 + drivers/usb/chipidea/otg.h| 19 +++ 5 files changed, 82 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 6cf5f68..a99d980 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o -ci_hdrc-y := core.o +ci_hdrc-y := core.o otg.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG) += debug.o diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h index aefa026..dd0cf9e 100644 --- a/drivers/usb/chipidea/bits.h +++ b/drivers/usb/chipidea/bits.h @@ -79,11 +79,21 @@ #define OTGSC_ASVIS BIT(18) #define OTGSC_BSVIS BIT(19) #define OTGSC_BSEIS BIT(20) +#define OTGSC_1MSIS BIT(21) +#define OTGSC_DPIS BIT(22) #define OTGSC_IDIE BIT(24) #define OTGSC_AVVIE BIT(25) #define OTGSC_ASVIE BIT(26) #define OTGSC_BSVIE BIT(27) #define OTGSC_BSEIE BIT(28) +#define OTGSC_1MSIE BIT(29) +#define OTGSC_DPIE BIT(30) +#define OTGSC_INT_EN_BITS (OTGSC_IDIE | OTGSC_AVVIE | OTGSC_ASVIE \ + | OTGSC_BSVIE | OTGSC_BSEIE | OTGSC_1MSIE \ + | OTGSC_DPIE) +#define OTGSC_INT_STATUS_BITS (OTGSC_IDIS | OTGSC_AVVIS | OTGSC_ASVIS \ + | OTGSC_BSVIS | OTGSC_BSEIS | OTGSC_1MSIS \ + | OTGSC_DPIS) /* USBMODE */ #define USBMODE_CM(0x03UL 0) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index a5df24c..761f7e8 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -71,6 +71,7 @@ #include bits.h #include host.h #include debug.h +#include otg.h /* Controller register map */ static uintptr_t ci_regs_nolpm[] = { @@ -508,7 +509,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) goto stop; if (ci-is_otg) - hw_write(ci, OP_OTGSC, OTGSC_IDIE, OTGSC_IDIE); + ci_hdrc_otg_init(ci); ret = dbg_create_files(ci); if (!ret) diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c new file mode 100644 index 000..abefb4d --- /dev/null +++ b/drivers/usb/chipidea/otg.c @@ -0,0 +1,50 @@ +/* + * otg.c - ChipIdea USB IP core OTG driver + * + * Copyright (C) 2013 Freescale Semiconductor, Inc. + * + * Author: Peter Chen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * This file mainly handles otgsc register, it may include OTG operation + * in the future. + */ + +#include linux/usb/otg.h +#include linux/usb/gadget.h +#include linux/usb/chipidea.h + +#include ci.h +#include bits.h + +void ci_clear_otg_interrupt(struct ci_hdrc *ci, u32 bits) +{ + /* Only clear request bits */ + hw_write(ci, OP_OTGSC, OTGSC_INT_STATUS_BITS, bits); +} + +void ci_enable_otg_interrupt(struct ci_hdrc *ci, u32 bits) +{ + hw_write(ci, OP_OTGSC, bits, bits); +} + +void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits) +{ + hw_write(ci, OP_OTGSC, bits, 0); +} + +/** + * ci_hdrc_otg_init - initialize otgsc bits + * ci: the controller + */ +int ci_hdrc_otg_init(struct ci_hdrc *ci) +{ + ci_enable_otg_interrupt(ci, OTGSC_IDIE); + + return 0; +} diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h new file mode 100644 index 000..f24ec37 --- /dev/null +++ b/drivers/usb/chipidea/otg.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2013 Freescale Semiconductor, Inc. + * + * Author: Peter Chen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H +#define __DRIVERS_USB_CHIPIDEA_OTG_H + +int ci_hdrc_otg_init(struct ci_hdrc *ci); +void ci_clear_otg_interrupt(struct ci_hdrc *ci, u32 bits); +void ci_enable_otg_interrupt(struct ci_hdrc *ci, u32 bits); +void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits); + +#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */ -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a
[PATCH v13 06/14] usb: chipidea: Add role init and destory APIs
- The role's init will be called at probe procedure. - The role's destory will be called at fail patch at probe and driver's removal. - The role's start/stop will be called when specific role has started. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/core.c | 10 -- drivers/usb/chipidea/host.c |7 +++ drivers/usb/chipidea/host.h |6 ++ drivers/usb/chipidea/udc.c | 36 +++- drivers/usb/chipidea/udc.h |6 ++ 5 files changed, 54 insertions(+), 11 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 761f7e8..93961ff 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -399,6 +399,12 @@ void ci_hdrc_remove_device(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(ci_hdrc_remove_device); +static inline void ci_role_destroy(struct ci_hdrc *ci) +{ + ci_hdrc_gadget_destroy(ci); + ci_hdrc_host_destroy(ci); +} + static int ci_hdrc_probe(struct platform_device *pdev) { struct device *dev = pdev-dev; @@ -517,7 +523,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) free_irq(ci-irq, ci); stop: - ci_role_stop(ci); + ci_role_destroy(ci); rm_wq: flush_workqueue(ci-wq); destroy_workqueue(ci-wq); @@ -533,7 +539,7 @@ static int ci_hdrc_remove(struct platform_device *pdev) flush_workqueue(ci-wq); destroy_workqueue(ci-wq); free_irq(ci-irq, ci); - ci_role_stop(ci); + ci_role_destroy(ci); return 0; } diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index e94e52b..382be5b 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -105,6 +105,13 @@ static void host_stop(struct ci_hdrc *ci) regulator_disable(ci-platdata-reg_vbus); } + +void ci_hdrc_host_destroy(struct ci_hdrc *ci) +{ + if (ci-role == CI_ROLE_HOST) + host_stop(ci); +} + int ci_hdrc_host_init(struct ci_hdrc *ci) { struct ci_role_driver *rdrv; diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h index 058875c..5707bf3 100644 --- a/drivers/usb/chipidea/host.h +++ b/drivers/usb/chipidea/host.h @@ -4,6 +4,7 @@ #ifdef CONFIG_USB_CHIPIDEA_HOST int ci_hdrc_host_init(struct ci_hdrc *ci); +void ci_hdrc_host_destroy(struct ci_hdrc *ci); #else @@ -12,6 +13,11 @@ static inline int ci_hdrc_host_init(struct ci_hdrc *ci) return -ENXIO; } +static inline void ci_hdrc_host_destroy(struct ci_hdrc *ci) +{ + +} + #endif #endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */ diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 116c762..24a100d 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -27,6 +27,7 @@ #include udc.h #include bits.h #include debug.h +#include otg.h /* control endpoint description */ static const struct usb_endpoint_descriptor @@ -1844,13 +1845,13 @@ free_qh_pool: } /** - * udc_remove: parent remove must call this to remove UDC + * ci_hdrc_gadget_destroy: parent remove must call this to remove UDC * * No interrupts active, the IRQ has been released */ -static void udc_stop(struct ci_hdrc *ci) +void ci_hdrc_gadget_destroy(struct ci_hdrc *ci) { - if (ci == NULL) + if (!ci-roles[CI_ROLE_GADGET]) return; usb_del_gadget_udc(ci-gadget); @@ -1865,15 +1866,32 @@ static void udc_stop(struct ci_hdrc *ci) if (ci-global_phy) usb_put_phy(ci-transceiver); } - /* my kobject is dynamic, I swear! */ - memset(ci-gadget, 0, sizeof(ci-gadget)); +} + +static int udc_id_switch_for_device(struct ci_hdrc *ci) +{ + if (ci-is_otg) { + ci_clear_otg_interrupt(ci, OTGSC_BSVIS); + ci_enable_otg_interrupt(ci, OTGSC_BSVIE); + } + + return 0; +} + +static void udc_id_switch_for_host(struct ci_hdrc *ci) +{ + if (ci-is_otg) { + /* host doesn't care B_SESSION_VALID event */ + ci_clear_otg_interrupt(ci, OTGSC_BSVIS); + ci_disable_otg_interrupt(ci, OTGSC_BSVIE); + } } /** * ci_hdrc_gadget_init - initialize device related bits * ci: the controller * - * This function enables the gadget role, if the device is device capable. + * This function initializes the gadget, if the device is device capable. */ int ci_hdrc_gadget_init(struct ci_hdrc *ci) { @@ -1886,11 +1904,11 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci) if (!rdrv) return -ENOMEM; - rdrv-start = udc_start; - rdrv-stop = udc_stop; + rdrv-start = udc_id_switch_for_device; + rdrv-stop = udc_id_switch_for_host; rdrv-irq = udc_irq; rdrv-name = gadget; ci-roles[CI_ROLE_GADGET] = rdrv; - return 0; + return udc_start(ci); } diff
[PATCH v13 11/14] usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts
When the gadget role starts, we need to make sure the vbus is lower than OTGSC_BSV, or there will be an vbus interrupt since we use B_SESSION_VALID as vbus interrupt to indicate connect and disconnect. When the host role starts, it may not be useful to wait vbus to lower than OTGSC_BSV, but it can indicate some hardware problems like the vbus is still higher than OTGSC_BSV after we disconnect to host some time later (5000 milliseconds currently), which is obvious not correct. Tested-by: Marek Vasut ma...@denx.de Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/ci.h |3 +++ drivers/usb/chipidea/core.c | 32 drivers/usb/chipidea/otg.c |4 3 files changed, 39 insertions(+), 0 deletions(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 3160363..1c94fc5 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -308,4 +308,7 @@ int hw_port_test_set(struct ci_hdrc *ci, u8 mode); u8 hw_port_test_get(struct ci_hdrc *ci); +int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask, + u32 value, unsigned int timeout_ms); + #endif /* __DRIVERS_USB_CHIPIDEA_CI_H */ diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 0fbeb45..6f9e04d 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -295,6 +295,38 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode) return 0; } +/** + * hw_wait_reg: wait the register value + * + * Sometimes, it needs to wait register value before going on. + * Eg, when switch to device mode, the vbus value should be lower + * than OTGSC_BSV before connects to host. + * + * @ci: the controller + * @reg: register index + * @mask: mast bit + * @value: the bit value to wait + * @timeout_ms: timeout in millisecond + * + * This function returns an error code if timeout + */ +int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask, + u32 value, unsigned int timeout_ms) +{ + unsigned long elapse = jiffies + msecs_to_jiffies(timeout_ms); + + while (hw_read(ci, reg, mask) != value) { + if (time_after(jiffies, elapse)) { + dev_err(ci-dev, timeout waiting for %08x in %d\n, + mask, reg); + return -ETIMEDOUT; + } + msleep(20); + } + + return 0; +} + static irqreturn_t ci_irq(int irq, void *data) { struct ci_hdrc *ci = data; diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index c74194d..d39cce8 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -67,6 +67,7 @@ void ci_handle_vbus_change(struct ci_hdrc *ci) usb_gadget_vbus_disconnect(ci-gadget); } +#define CI_VBUS_STABLE_TIMEOUT_MS 5000 static void ci_handle_id_switch(struct ci_hdrc *ci) { enum ci_role role = ci_otg_role(ci); @@ -76,6 +77,9 @@ static void ci_handle_id_switch(struct ci_hdrc *ci) ci_role(ci)-name, ci-roles[role]-name); ci_role_stop(ci); + /* wait vbus lower than OTGSC_BSV */ + hw_wait_reg(ci, OP_OTGSC, OTGSC_BSV, 0, + CI_VBUS_STABLE_TIMEOUT_MS); ci_role_start(ci, role); } } -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] USBNET: max rx/tx qlen change
On Thu, 2013-07-25 at 22:19 +0800, Ming Lei wrote: Hi, On Thu, Jul 25, 2013 at 3:38 PM, Oliver Neukum oneu...@suse.de wrote: On Thu, 2013-07-25 at 13:47 +0800, Ming Lei wrote: Hi, There are two patches on computing max rx/tx qlen, and fix one performance problem on USB3 NIC. I am afraid bisectability on SS is impaired. Otherwise this looks good. Bisectability on SS can't be impaired, and it is always the 2nd patch which fixes the performance issue on SS, and the 1st one only does code refactoring thing. Yes, it looks a bit unusual, bit is OK. Sorry Oliver -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 15/16] dmaengine: add transfered member to dma_async_tx_descriptor
On Thu, Jul 25, 2013 at 05:32:35PM +0200, Lars-Peter Clausen wrote: I see. But it can't be reused before calling the callback if it is going to call the callback, right? So if this is a no-no, I'm left with an additional argument to the complete callback? Hm, maybe using dmaengine_tx_status() and checking the residue field of the state struct. transferred is basically len - residue. This might actually work. So this would reduce the patch to simply update the kernel doc for residue in struct dma_tx_state that it might also be valid for DMA_SUCCESS. Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes
Hi, On Fri, Jul 26, 2013 at 09:48:26AM +0300, Ivan T. Ivanov wrote: Also, this is not *modifying* what was passed, just skipping the xHCI address space so we don't request_mem_region() an area we won't really handle and prevent xhci-hcd.ko from probing. Hmm? platform_get_resource() returns a pointer to an entry in the platform_device's resource[] array. And res-start += modifies the entry pointed at. If it didn't, the bug fixed by this patch wouldn't have happened. Are you sure this code will work OK if you build the driver as a module, modprobe it, rmmod it, and then modprobe it again? Seems like it won't, unless the dev-resource[] array gets reinitialized in between somehow. gotta try that one... Perhaps the correct way would be to copy the resource to a private struct resource and modify that one, leaving pdev-resources untouched. In addition, I think driver is wasting memory, because on every probe it will reallocate driver state variable. This also happens in several other drivers which are using deferred probe. We can't do much about this since we're using devm_* API. Perhaps deferred probe should make sure to destroy the device and add it back later ? Otherwise what's the benefit of using devm_* ? -- balbi signature.asc Description: Digital signature
Re: [PATCH] usb: gadget: at91_udc: Check gpio lookup results
On Thu, Jul 25, 2013 at 01:59:51PM -0700, Olof Johansson wrote: On Thu, Jul 25, 2013 at 10:19 AM, Felipe Balbi ba...@ti.com wrote: On Thu, Jul 25, 2013 at 09:18:39AM -0700, Olof Johansson wrote: That's what the code does today, and I wasn't trying to second-guess their decisions on that. Chances are firmware, in some instances, have left power on so continuing might do no harm. fair enough, then let's just decrease the error message level to debug or info. Fair enough. info seems appropriate (or warn). Want me to respin, or can you edit when you apply? please respin -- balbi signature.asc Description: Digital signature
[PATCH 0/3][RESEND] USB: mos7840: fixes for v3.11
Here's a resend of the three remaining mos7840-fixes for v3.11 rebased on usb-linus of today. Tested using a mcs7820-device (and by faking the mcs7810 LED). Johan Johan Hovold (3): USB: mos7840: fix race in register handling USB: mos7840: fix device-type detection USB: mos7840: fix race in led handling drivers/usb/serial/mos7840.c | 150 +-- 1 file changed, 87 insertions(+), 63 deletions(-) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] USB: mos7840: fix race in led handling
Fix race in LED handling introduced by commit 0eafe4de (USB: serial: mos7840: add support for MCS7810 devices) which reused the port control urb for manipulating the LED without making sure that the urb is not already in use. This could lead to the control urb being manipulated while in flight. Fix by adding a dedicated LED urb and ctrlrequest along with a LED-busy flag to handle concurrency. Cc: sta...@vger.kernel.org Signed-off-by: Johan Hovold jhov...@gmail.com --- drivers/usb/serial/mos7840.c | 59 +++- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index e95d914..c10fc15 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -185,6 +185,7 @@ enum mos7840_flag { MOS7840_FLAG_CTRL_BUSY, + MOS7840_FLAG_LED_BUSY, }; static const struct usb_device_id id_table[] = { @@ -240,9 +241,10 @@ struct moschip_port { /* For device(s) with LED indicator */ bool has_led; - bool led_flag; struct timer_list led_timer1; /* Timer for LED on */ struct timer_list led_timer2; /* Timer for LED off */ + struct urb *led_urb; + struct usb_ctrlrequest *led_dr; unsigned long flags; }; @@ -535,7 +537,7 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval, __u16 reg) { struct usb_device *dev = mcs-port-serial-dev; - struct usb_ctrlrequest *dr = mcs-dr; + struct usb_ctrlrequest *dr = mcs-led_dr; dr-bRequestType = MCS_WR_RTYPE; dr-bRequest = MCS_WRREQ; @@ -543,10 +545,10 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval, dr-wIndex = cpu_to_le16(reg); dr-wLength = cpu_to_le16(0); - usb_fill_control_urb(mcs-control_urb, dev, usb_sndctrlpipe(dev, 0), + usb_fill_control_urb(mcs-led_urb, dev, usb_sndctrlpipe(dev, 0), (unsigned char *)dr, NULL, 0, mos7840_set_led_callback, NULL); - usb_submit_urb(mcs-control_urb, GFP_ATOMIC); + usb_submit_urb(mcs-led_urb, GFP_ATOMIC); } static void mos7840_set_led_sync(struct usb_serial_port *port, __u16 reg, @@ -572,7 +574,19 @@ static void mos7840_led_flag_off(unsigned long arg) { struct moschip_port *mcs = (struct moschip_port *) arg; - mcs-led_flag = false; + clear_bit_unlock(MOS7840_FLAG_LED_BUSY, mcs-flags); +} + +static void mos7840_led_activity(struct usb_serial_port *port) +{ + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); + + if (test_and_set_bit_lock(MOS7840_FLAG_LED_BUSY, mos7840_port-flags)) + return; + + mos7840_set_led_async(mos7840_port, 0x0301, MODEM_CONTROL_REGISTER); + mod_timer(mos7840_port-led_timer1, + jiffies + msecs_to_jiffies(LED_ON_MS)); } /* @@ -770,14 +784,8 @@ static void mos7840_bulk_in_callback(struct urb *urb) return; } - /* Turn on LED */ - if (mos7840_port-has_led !mos7840_port-led_flag) { - mos7840_port-led_flag = true; - mos7840_set_led_async(mos7840_port, 0x0301, - MODEM_CONTROL_REGISTER); - mod_timer(mos7840_port-led_timer1, - jiffies + msecs_to_jiffies(LED_ON_MS)); - } + if (mos7840_port-has_led) + mos7840_led_activity(port); mos7840_port-read_urb_busy = true; retval = usb_submit_urb(mos7840_port-read_urb, GFP_ATOMIC); @@ -1454,13 +1462,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, data1 = urb-transfer_buffer; dev_dbg(port-dev, bulkout endpoint is %d\n, port-bulk_out_endpointAddress); - /* Turn on LED */ - if (mos7840_port-has_led !mos7840_port-led_flag) { - mos7840_port-led_flag = true; - mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0301); - mod_timer(mos7840_port-led_timer1, - jiffies + msecs_to_jiffies(LED_ON_MS)); - } + if (mos7840_port-has_led) + mos7840_led_activity(port); /* send it down the pipe */ status = usb_submit_urb(urb, GFP_ATOMIC); @@ -2412,6 +2415,14 @@ static int mos7840_port_probe(struct usb_serial_port *port) if (device_type == MOSCHIP_DEVICE_ID_7810) { mos7840_port-has_led = true; + mos7840_port-led_urb = usb_alloc_urb(0, GFP_KERNEL); + mos7840_port-led_dr = kmalloc(sizeof(*mos7840_port-led_dr), + GFP_KERNEL); + if (!mos7840_port-led_urb || !mos7840_port-led_dr) { + status = -ENOMEM; + goto error; +
[PATCH 1/3] USB: mos7840: fix race in register handling
Fix race in mos7840_get_reg which unconditionally manipulated the control urb (which may already be in use) by adding a control-urb busy flag. Cc: sta...@vger.kernel.org Signed-off-by: Johan Hovold jhov...@gmail.com --- drivers/usb/serial/mos7840.c | 18 -- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 603fb70..73dda1c 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -183,6 +183,10 @@ #define LED_ON_MS 500 #define LED_OFF_MS 500 +enum mos7840_flag { + MOS7840_FLAG_CTRL_BUSY, +}; + static int device_type; static const struct usb_device_id id_table[] = { @@ -241,6 +245,8 @@ struct moschip_port { bool led_flag; struct timer_list led_timer1; /* Timer for LED on */ struct timer_list led_timer2; /* Timer for LED off */ + + unsigned long flags; }; /* @@ -460,10 +466,10 @@ static void mos7840_control_callback(struct urb *urb) case -ESHUTDOWN: /* this urb is terminated, clean up */ dev_dbg(dev, %s - urb shutting down with status: %d\n, __func__, status); - return; + goto out; default: dev_dbg(dev, %s - nonzero urb status received: %d\n, __func__, status); - return; + goto out; } dev_dbg(dev, %s urb buffer size is %d\n, __func__, urb-actual_length); @@ -476,6 +482,8 @@ static void mos7840_control_callback(struct urb *urb) mos7840_handle_new_msr(mos7840_port, regval); else if (mos7840_port-MsrLsr == 1) mos7840_handle_new_lsr(mos7840_port, regval); +out: + clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, mos7840_port-flags); } static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, @@ -486,6 +494,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, unsigned char *buffer = mcs-ctrl_buf; int ret; + if (test_and_set_bit_lock(MOS7840_FLAG_CTRL_BUSY, mcs-flags)) + return -EBUSY; + dr-bRequestType = MCS_RD_RTYPE; dr-bRequest = MCS_RDREQ; dr-wValue = cpu_to_le16(Wval); /* 0 */ @@ -497,6 +508,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, mos7840_control_callback, mcs); mcs-control_urb-transfer_buffer_length = 2; ret = usb_submit_urb(mcs-control_urb, GFP_ATOMIC); + if (ret) + clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, mcs-flags); + return ret; } -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] USB: mos7840: fix device-type detection
Fix race in device-type detection introduced by commit 0eafe4de (USB: serial: mos7840: add support for MCS7810 devices) which used a static variable to hold the device type. Move type detection to probe and use serial data to store the device type. Cc: sta...@vger.kernel.org Signed-off-by: Johan Hovold jhov...@gmail.com --- drivers/usb/serial/mos7840.c | 75 +--- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 73dda1c..e95d914 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -187,8 +187,6 @@ enum mos7840_flag { MOS7840_FLAG_CTRL_BUSY, }; -static int device_type; - static const struct usb_device_id id_table[] = { {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, @@ -830,18 +828,6 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) // /* D R I V E R T T Y I N T E R F A C E F U N C T I O N S */ // -#ifdef MCSSerialProbe -static int mos7840_serial_probe(struct usb_serial *serial, - const struct usb_device_id *id) -{ - - /*need to implement the mode_reg reading and updating\ - structures usb_serial_ device_type\ - (i.e num_ports, num_bulkin,bulkout etc) */ - /* Also we can update the changes attach */ - return 1; -} -#endif /* * mos7840_open @@ -2201,38 +2187,48 @@ static int mos7810_check(struct usb_serial *serial) return 0; } -static int mos7840_calc_num_ports(struct usb_serial *serial) +static int mos7840_probe(struct usb_serial *serial, + const struct usb_device_id *id) { - __u16 data = 0x00; + u16 product = serial-dev-descriptor.idProduct; u8 *buf; - int mos7840_num_ports; + int device_type; + + if (product == MOSCHIP_DEVICE_ID_7810 || + product == MOSCHIP_DEVICE_ID_7820) { + device_type = product; + goto out; + } buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL); - if (buf) { - usb_control_msg(serial-dev, usb_rcvctrlpipe(serial-dev, 0), + if (!buf) + return -ENOMEM; + + usb_control_msg(serial-dev, usb_rcvctrlpipe(serial-dev, 0), MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, buf, VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); - data = *buf; - kfree(buf); - } - if (serial-dev-descriptor.idProduct == MOSCHIP_DEVICE_ID_7810 || - serial-dev-descriptor.idProduct == MOSCHIP_DEVICE_ID_7820) { - device_type = serial-dev-descriptor.idProduct; - } else { - /* For a MCS7840 device GPIO0 must be set to 1 */ - if ((data 0x01) == 1) - device_type = MOSCHIP_DEVICE_ID_7840; - else if (mos7810_check(serial)) - device_type = MOSCHIP_DEVICE_ID_7810; - else - device_type = MOSCHIP_DEVICE_ID_7820; - } + /* For a MCS7840 device GPIO0 must be set to 1 */ + if (buf[0] 0x01) + device_type = MOSCHIP_DEVICE_ID_7840; + else if (mos7810_check(serial)) + device_type = MOSCHIP_DEVICE_ID_7810; + else + device_type = MOSCHIP_DEVICE_ID_7820; + + kfree(buf); +out: + usb_set_serial_data(serial, (void *)device_type); + + return 0; +} + +static int mos7840_calc_num_ports(struct usb_serial *serial) +{ + int device_type = (int)usb_get_serial_data(serial); + int mos7840_num_ports; mos7840_num_ports = (device_type 4) 0x000F; - serial-num_bulk_in = mos7840_num_ports; - serial-num_bulk_out = mos7840_num_ports; - serial-num_ports = mos7840_num_ports; return mos7840_num_ports; } @@ -2240,6 +2236,7 @@ static int mos7840_calc_num_ports(struct usb_serial *serial) static int mos7840_port_probe(struct usb_serial_port *port) { struct usb_serial *serial = port-serial; + int device_type = (int)usb_get_serial_data(serial); struct moschip_port *mos7840_port; int status; int pnum; @@ -2496,9 +2493,7 @@ static struct usb_serial_driver moschip7840_4port_device = { .throttle = mos7840_throttle, .unthrottle = mos7840_unthrottle, .calc_num_ports = mos7840_calc_num_ports, -#ifdef MCSSerialProbe - .probe = mos7840_serial_probe, -#endif + .probe = mos7840_probe, .ioctl = mos7840_ioctl, .set_termios = mos7840_set_termios, .break_ctl = mos7840_break, --
Re: [PATCH] musb: don't reset endpoint data toggle on blackfin
Hi Balbi, On Thu, Jul 18, 2013 at 07:04:14PM -0400, Scott Jiang wrote: Reset endpoint data toggle would lead to failure for musb RTL version 1.9 on blackfin. is this specific to musb 1.9 or to blackfin ? I'm not sure about this. It failed in musb 1.9 on bf527. But this bug didn't affect musb RTL 2.0 on bf609. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] musb: don't reset endpoint data toggle on blackfin
Hi, On Fri, Jul 26, 2013 at 05:59:22PM +0800, Scott Jiang wrote: Hi Balbi, On Thu, Jul 18, 2013 at 07:04:14PM -0400, Scott Jiang wrote: Reset endpoint data toggle would lead to failure for musb RTL version 1.9 on blackfin. is this specific to musb 1.9 or to blackfin ? I'm not sure about this. It failed in musb 1.9 on bf527. But this bug didn't affect musb RTL 2.0 on bf609. Do you have Mentor's errata list or just Analog Device's errata ? -- balbi signature.asc Description: Digital signature
Re: [PATCH] USB: serial: add driver for Suunto ANT+ USB device
On Thu, Jul 25, 2013 at 09:52:29PM -0700, Greg Kroah-Hartman wrote: Steinar, I've tested the driver below with my device and it seems to work. If you have any problems with it, please let me know, otherwise I'll queue it up to get into the 3.11 kernel release soon. Backported to 3.10.3 and tested (with my own, old fork of gant), works fine. /* Steinar */ -- Homepage: http://www.sesse.net/ -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Help adding trace events to xHCI
On Fri, 2013-07-26 at 11:19 +0200, Johannes Berg wrote: My original though here was that we should be able to reserve (maximum) space on the per-CPU buffer, and then relinquish some of it after the tracepoint was written to the data, but I never had the time to check if that was possible to implement. It would make it a little inefficient at page boundaries, but that seems OK given that our maximum size is only ~100 bytes or so now. Yes that would be trivial to implement. If the max buffer is ~100 bytes, allocate 256 byte buffers per cpu. Also have a per cpu index, and then have something like this: index = local_add_return(this_cpu_ptr(trace_index), len); if (index = MAX_BUF) { /* write tracepoint with failed buffer */ local_sub(this_cpu_ptr(trace_index)); return; } index -= len; memcpy(this_cpu_ptr(trace_buf) + index, string, len); /* write tracepoint with trace_buf */ local_sub(this_cpu_ptr(trace_index), len); This way the trace_buf will work like a stack allocator. The local_add_return() will reserve the space in the buffer such that if an interrupt were to come in, it would allocate after that space. The check for MAX_BUF tests for the case that the buffer was too big and had to bail. Still trace that event to let the user (yourself) know you need a bigger buffer. -- Steve -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH - bugfix for 3.11 2/2] usb/gadget: f_phonet: remove unused preprocessor conditional
The compatibility layer which the USBF_PHONET_INCLUDED was a part of is no longer present - the USBF_PHONET_INCLUDED is not #defined by anyone anymore, so the ifndef is always true. Removing it. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com --- drivers/usb/gadget/f_phonet.c |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c index 1bf26e9..eb3aa81 100644 --- a/drivers/usb/gadget/f_phonet.c +++ b/drivers/usb/gadget/f_phonet.c @@ -488,7 +488,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f) struct usb_ep *ep; int status, i; -#ifndef USBF_PHONET_INCLUDED struct f_phonet_opts *phonet_opts; phonet_opts = container_of(f-fi, struct f_phonet_opts, func_inst); @@ -507,7 +506,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f) return status; phonet_opts-bound = true; } -#endif /* Reserve interface IDs */ status = usb_interface_id(c, f); -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: xhci: add missing dma-mapping.h includes
A randconfig build hit the following build errors because xhci.c and xhci-mem.c use dma mapping functions but don't include linux/dma-mapping.h. Add the missing includes to fix the build errors. drivers/usb/host/xhci.c In function 'xhci_gen_setup': drivers/usb/host/xhci.c +4872 : error: implicit declaration of function 'dma_set_mask' drivers/usb/host/xhci.c +4872 : error: implicit declaration of function 'DMA_BIT_MASK' drivers/usb/host/xhci-mem.c In function 'xhci_free_stream_ctx': drivers/usb/host/xhci-mem.c +435 : error: implicit declaration of function 'dma_free_coherent' drivers/usb/host/xhci-mem.c In function 'xhci_alloc_stream_ctx': drivers/usb/host/xhci-mem.c +463 : error: implicit declaration of function 'dma_alloc_coherent' Signed-off-by: James Hogan james.ho...@imgtec.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: linux-usb@vger.kernel.org Cc: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-mem.c | 1 + drivers/usb/host/xhci.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index fbf75e5..3e27d92 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -24,6 +24,7 @@ #include linux/pci.h #include linux/slab.h #include linux/dmapool.h +#include linux/dma-mapping.h #include xhci.h diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index d8f640b..247020c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -27,6 +27,7 @@ #include linux/moduleparam.h #include linux/slab.h #include linux/dmi.h +#include linux/dma-mapping.h #include xhci.h -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH - bugfix for 3.11 1/2] usb/gadget: multi: fix error return code in cdc_do_config()
Fix to return a negative error code from the error handling case instead of 0, as returned elsewhere in this function. Introduced by commit 59835a (usb: gadget: multi: use function framework for ACM.) Make rndis_do_config() consistent with cdc_do_config() in the way it handles returning the PTR_ERR(f_acm_*). Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com --- drivers/usb/gadget/multi.c | 10 +++--- 1 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 032b96a..2a1ebef 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -160,10 +160,8 @@ static __init int rndis_do_config(struct usb_configuration *c) return ret; f_acm_rndis = usb_get_function(fi_acm); - if (IS_ERR(f_acm_rndis)) { - ret = PTR_ERR(f_acm_rndis); - goto err_func_acm; - } + if (IS_ERR(f_acm_rndis)) + return PTR_ERR(f_acm_rndis); ret = usb_add_function(c, f_acm_rndis); if (ret) @@ -178,7 +176,6 @@ err_fsg: usb_remove_function(c, f_acm_rndis); err_conf: usb_put_function(f_acm_rndis); -err_func_acm: return ret; } @@ -226,7 +223,7 @@ static __init int cdc_do_config(struct usb_configuration *c) /* implicit port_num is zero */ f_acm_multi = usb_get_function(fi_acm); if (IS_ERR(f_acm_multi)) - goto err_func_acm; + return PTR_ERR(f_acm_multi); ret = usb_add_function(c, f_acm_multi); if (ret) @@ -241,7 +238,6 @@ err_fsg: usb_remove_function(c, f_acm_multi); err_conf: usb_put_function(f_acm_multi); -err_func_acm: return ret; } -- 1.7.0.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v10 5/8] ARM: dts: omap: update usb_otg_hs data
Updated the usb_otg_hs dt data to include the *phy* and *phy-names* binding in order for the driver to use the new generic PHY framework. Also updated the Documentation to include the binding information. The PHY binding information can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 ++ arch/arm/boot/dts/omap3-beagle-xm.dts |2 ++ arch/arm/boot/dts/omap3-evm.dts|2 ++ arch/arm/boot/dts/omap3-overo.dtsi |2 ++ arch/arm/boot/dts/omap4.dtsi |3 +++ arch/arm/boot/dts/twl4030.dtsi |1 + 7 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 57e71f6..825790d 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -19,6 +19,9 @@ OMAP MUSB GLUE - power : Should be 50. This signifies the controller can supply up to 100mA when operating in host mode. - usb-phy : the phandle for the PHY device + - phys : the phandle for the PHY device (used by generic PHY framework) + - phy-names : the names of the PHY corresponding to the PHYs present in the + *phy* phandle. Optional properties: - ctrl-module : phandle of the control module this glue uses to write to @@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 { num-eps = 16; ram-bits = 12; ctrl-module = omap_control_usb; + phys = usb2_phy; + phy-names = usb2-phy; }; Board specific device node entry diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt b/Documentation/devicetree/bindings/usb/usb-phy.txt index 61496f5..c0245c8 100644 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt @@ -5,6 +5,8 @@ OMAP USB2 PHY Required properties: - compatible: Should be ti,omap-usb2 - reg : Address and length of the register set for the device. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -16,6 +18,7 @@ usb2phy@4a0ad080 { compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; OMAP USB3 PHY @@ -25,6 +28,8 @@ Required properties: - reg : Address and length of the register set for the device. - reg-names: The names of the register addresses corresponding to the registers filled in reg. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -39,4 +44,5 @@ usb3phy@4a084400 { 0x4a084c00 0x40; reg-names = phy_rx, phy_tx, pll_ctrl; ctrl-module = omap_control_usb; + #phy-cells = 0; }; diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts index afdb164..533b2da 100644 --- a/arch/arm/boot/dts/omap3-beagle-xm.dts +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts @@ -144,6 +144,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts index 7d4329d..4134dd0 100644 --- a/arch/arm/boot/dts/omap3-evm.dts +++ b/arch/arm/boot/dts/omap3-evm.dts @@ -70,6 +70,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi index 8f1abec..a461d2f 100644 --- a/arch/arm/boot/dts/omap3-overo.dtsi +++ b/arch/arm/boot/dts/omap3-overo.dtsi @@ -76,6 +76,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 22d9f2b..1e8e2fe 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -520,6 +520,7 @@ compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; }; @@ -658,6 +659,8 @@ interrupt-names = mc, dma;
[PATCH v10 6/8] usb: musb: omap2430: use the new generic PHY framework
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume and usb_phy_set_suspend is replaced with power_on and power_off to align with the new PHY framework. musb-xceiv can't be removed as of now because musb core uses xceiv.state and xceiv.otg. Once there is a separate state machine to handle otg, these can be moved out of xceiv and then we can start using the generic PHY framework. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.h |2 ++ drivers/usb/musb/omap2430.c | 26 -- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 797e3fd..25e2e57 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate OMAP2430 and onwards depends on ARCH_OMAP2PLUS + select GENERIC_PHY config USB_MUSB_AM35X tristate AM35x diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c3..6e567bd 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -46,6 +46,7 @@ #include linux/usb.h #include linux/usb/otg.h #include linux/usb/musb.h +#include linux/phy/phy.h struct musb; struct musb_hw_ep; @@ -346,6 +347,7 @@ struct musb { u16 int_tx; struct usb_phy *xceiv; + struct phy *phy; int nIrq; unsignedirq_wake:1; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 6708a3b..f7b33f4 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb) * up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - if (dev-parent-of_node) + if (dev-parent-of_node) { + musb-phy = devm_phy_get(dev-parent, usb2-phy); + + /* We can't totally remove musb-xceiv as of now because +* musb core uses xceiv.state and xceiv.otg. Once we have +* a separate state machine to handle otg, these can be moved +* out of xceiv and then we can start using the generic PHY +* framework +*/ musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent, usb-phy, 0); - else + } else { musb-xceiv = devm_usb_get_phy_dev(dev, 0); + musb-phy = devm_phy_get(dev, usb); + } if (IS_ERR(musb-xceiv)) { status = PTR_ERR(musb-xceiv); @@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb) return -EPROBE_DEFER; } + if (IS_ERR(musb-phy)) { + pr_err(HS USB OTG: no PHY configured\n); + return PTR_ERR(musb-phy); + } musb-isr = omap2430_musb_interrupt; status = pm_runtime_get_sync(dev); @@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb) if (glue-status != OMAP_MUSB_UNKNOWN) omap_musb_set_mailbox(glue); - usb_phy_init(musb-xceiv); + phy_init(musb-phy); pm_runtime_put_noidle(musb-controller); return 0; @@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb) del_timer_sync(musb_idle_timer); omap2430_low_level_exit(musb); + phy_exit(musb-phy); return 0; } @@ -633,7 +648,7 @@ static int omap2430_runtime_suspend(struct device *dev) OTG_INTERFSEL); omap2430_low_level_exit(musb); - usb_phy_set_suspend(musb-xceiv, 1); + phy_power_off(musb-phy); } return 0; @@ -648,8 +663,7 @@ static int omap2430_runtime_resume(struct device *dev) omap2430_low_level_init(musb); musb_writel(musb-mregs, OTG_INTERFSEL, musb-context.otg_interfsel); - - usb_phy_set_suspend(musb-xceiv, 0); + phy_power_on(musb-phy); } return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v10 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops
Now that twl4030-usb is adapted to the new generic PHY framework, *set_suspend* and *phy_init* ops can be removed from twl4030-usb driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-twl4030-usb.c | 57 ++--- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index 494f107..c437211 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) } } -static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) +static int twl4030_phy_power_off(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (twl-asleep) - return; + return 0; twl4030_phy_power(twl, 0); twl-asleep = 1; dev_dbg(twl-dev, %s\n, __func__); -} - -static int twl4030_phy_power_off(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_suspend(twl, 0); return 0; } -static void __twl4030_phy_resume(struct twl4030_usb *twl) +static void __twl4030_phy_power_on(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); twl4030_i2c_access(twl, 1); @@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl) twl4030_i2c_access(twl, 0); } -static void twl4030_phy_resume(struct twl4030_usb *twl) +static int twl4030_phy_power_on(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (!twl-asleep) - return; - __twl4030_phy_resume(twl); + return 0; + __twl4030_phy_power_on(twl); twl-asleep = 0; dev_dbg(twl-dev, %s\n, __func__); @@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) cancel_delayed_work(twl-id_workaround_work); schedule_delayed_work(twl-id_workaround_work, HZ); } -} - -static int twl4030_phy_power_on(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_resume(twl); return 0; } @@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct *work) } } -static int twl4030_usb_phy_init(struct usb_phy *phy) +static int twl4030_phy_init(struct phy *phy) { - struct twl4030_usb *twl = phy_to_twl(phy); + struct twl4030_usb *twl = phy_get_drvdata(phy); enum omap_musb_vbus_id_status status; /* @@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); - twl4030_phy_resume(twl); + twl4030_phy_power_on(phy); } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } -static int twl4030_phy_init(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - return twl4030_usb_phy_init(twl-phy); -} - -static int twl4030_set_suspend(struct usb_phy *x, int suspend) -{ - struct twl4030_usb *twl = phy_to_twl(x); - - if (suspend) - twl4030_phy_suspend(twl, 1); - else - twl4030_phy_resume(twl); - - return 0; -} - static int twl4030_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { @@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl-phy.label = twl4030; twl-phy.otg= otg; twl-phy.type = USB_PHY_TYPE_USB2; - twl-phy.set_suspend= twl4030_set_suspend; - twl-phy.init = twl4030_usb_phy_init; otg-phy= twl-phy; otg-set_host = twl4030_set_host; -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v10 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data
The PHY framework uses the phy consumer data populated in platform data in the case of non-dt boot to return the reference to the PHY when the controller (PHY consumer) requests for it. So populated the phy consumer data in the platform data of twl usb. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- arch/arm/mach-omap2/twl-common.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index c05898f..b0d54da 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c @@ -24,6 +24,7 @@ #include linux/i2c/twl.h #include linux/gpio.h #include linux/string.h +#include linux/phy/phy.h #include linux/regulator/machine.h #include linux/regulator/fixed.h @@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void) } #if defined(CONFIG_ARCH_OMAP3) +struct phy_consumer consumers[] = { + PHY_CONSUMER(musb-hdrc.0, usb), +}; + +struct phy_init_data init_data = { + .consumers = consumers, + .num_consumers = ARRAY_SIZE(consumers), +}; + static struct twl4030_usb_data omap3_usb_pdata = { .usb_mode = T2_USB_MODE_ULPI, + .init_data = init_data, }; static int omap3_batt_table[] = { -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v10 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
Now that omap-usb2 is adapted to the new generic PHY framework, *set_suspend* ops can be removed from omap-usb2 driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-omap-usb2.c | 25 - 1 file changed, 25 deletions(-) diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 25e0f3c..dec3fab 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg, return 0; } -static int omap_usb2_suspend(struct usb_phy *x, int suspend) -{ - u32 ret; - struct omap_usb *phy = phy_to_omapusb(x); - - if (suspend !phy-is_suspended) { - omap_control_usb_phy_power(phy-control_dev, 0); - pm_runtime_put_sync(phy-dev); - phy-is_suspended = 1; - } else if (!suspend phy-is_suspended) { - ret = pm_runtime_get_sync(phy-dev); - if (ret 0) { - dev_err(phy-dev, get_sync failed with err %d\n, - ret); - return ret; - } - omap_control_usb_phy_power(phy-control_dev, 1); - phy-is_suspended = 0; - } - - return 0; -} - static int omap_usb_power_off(struct phy *x) { struct omap_usb *phy = phy_get_drvdata(x); @@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.dev= phy-dev; phy-phy.label = omap-usb2; - phy-phy.set_suspend= omap_usb2_suspend; phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; @@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev) return -ENODEV; } - phy-is_suspended = 1; omap_control_usb_phy_power(phy-control_dev, 0); otg-set_host = omap_usb_set_host; -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v10 2/8] usb: phy: omap-usb2: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. The omap-usb2 driver is also moved to driver/phy. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/phy/Kconfig | 12 + drivers/phy/Makefile |1 + drivers/{usb = }/phy/phy-omap-usb2.c | 45 ++--- drivers/usb/phy/Kconfig | 10 drivers/usb/phy/Makefile |1 - 5 files changed, 54 insertions(+), 15 deletions(-) rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 349bef2..38c3477 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -15,4 +15,16 @@ config GENERIC_PHY phy users can obtain reference to the PHY. All the users of this framework should select this config. +config OMAP_USB2 + tristate OMAP USB2 PHY Driver + depends on ARCH_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + select OMAP_CONTROL_USB + help + Enable this to support the transceiver that is part of SOC. This + driver takes care of all the PHY functionality apart from comparator. + The USB OTG controller communicates with the comparator using this + driver. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..ed5b088 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c similarity index 88% rename from drivers/usb/phy/phy-omap-usb2.c rename to drivers/phy/phy-omap-usb2.c index 844ab68..25e0f3c 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -28,6 +28,7 @@ #include linux/pm_runtime.h #include linux/delay.h #include linux/usb/omap_control_usb.h +#include linux/phy/phy.h /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_power_off(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 0); + + return 0; +} + +static int omap_usb_power_on(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 1); + + return 0; +} + +static struct phy_ops ops = { + .power_on = omap_usb_power_on, + .power_off = omap_usb_power_off, + .owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; + struct phy *generic_phy; struct usb_otg *otg; + struct phy_provider *phy_provider; phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; + phy_provider = devm_of_phy_provider_register(phy-dev, + of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + phy-control_dev = omap_get_control_dev(); if (IS_ERR(phy-control_dev)) { dev_dbg(pdev-dev, Failed to get control device\n); @@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev) otg-start_srp = omap_usb_start_srp; otg-phy= phy-phy; + platform_set_drvdata(pdev, phy); + pm_runtime_enable(phy-dev); + + generic_phy = devm_phy_create(phy-dev, ops, NULL); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k); if (IS_ERR(phy-wkupclk)) { dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n); @@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev) usb_add_phy_dev(phy-phy); - platform_set_drvdata(pdev, phy); - - pm_runtime_enable(phy-dev); - return 0; } diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..7813238 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -72,16 +72,6 @@ config
[PATCH v10 1/8] drivers: phy: add generic PHY framework
The PHY framework provides a set of APIs for the PHY drivers to create/destroy a PHY and APIs for the PHY users to obtain a reference to the PHY with or without using phandle. For dt-boot, the PHY drivers should also register *PHY provider* with the framework. PHY drivers should create the PHY by passing id and ops like init, exit, power_on and power_off. This framework is also pm runtime enabled. The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for dt binding can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Cc: Tomasz Figa t.f...@samsung.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../devicetree/bindings/phy/phy-bindings.txt | 66 ++ Documentation/phy.txt | 166 + MAINTAINERS|8 + drivers/Kconfig|2 + drivers/Makefile |2 + drivers/phy/Kconfig| 18 + drivers/phy/Makefile |5 + drivers/phy/phy-core.c | 714 include/linux/phy/phy.h| 270 9 files changed, 1251 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt create mode 100644 Documentation/phy.txt create mode 100644 drivers/phy/Kconfig create mode 100644 drivers/phy/Makefile create mode 100644 drivers/phy/phy-core.c create mode 100644 include/linux/phy/phy.h diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt new file mode 100644 index 000..8ae844f --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt @@ -0,0 +1,66 @@ +This document explains only the device tree data binding. For general +information about PHY subsystem refer to Documentation/phy.txt + +PHY device node +=== + +Required Properties: +#phy-cells:Number of cells in a PHY specifier; The meaning of all those + cells is defined by the binding for the phy node. The PHY + provider can use the values in cells to find the appropriate + PHY. + +For example: + +phys: phy { +compatible = xxx; +reg = ...; +. +. +#phy-cells = 1; +. +. +}; + +That node describes an IP block (PHY provider) that implements 2 different PHYs. +In order to differentiate between these 2 PHYs, an additonal specifier should be +given while trying to get a reference to it. + +PHY user node += + +Required Properties: +phys : the phandle for the PHY device (used by the PHY subsystem) +phy-names : the names of the PHY corresponding to the PHYs present in the + *phys* phandle + +Example 1: +usb1: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = usb2_phy, usb3_phy; +phy-names = usb2phy, usb3phy; +. +. +}; + +This node represents a controller that uses two PHYs, one for usb2 and one for +usb3. + +Example 2: +usb2: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = phys 1; +phy-names = usbphy; +. +. +}; + +This node represents a controller that uses one of the PHYs of the PHY provider +device defined previously. Note that the phy handle has an additional specifier +1 to differentiate between the two PHYs. diff --git a/Documentation/phy.txt b/Documentation/phy.txt new file mode 100644 index 000..4e056c4 --- /dev/null +++ b/Documentation/phy.txt @@ -0,0 +1,166 @@ + PHY SUBSYSTEM + Kishon Vijay Abraham I kis...@ti.com + +This document explains the Generic PHY Framework along with the APIs provided, +and how-to-use. + +1. Introduction + +*PHY* is the abbreviation for physical layer. It is used to connect a device +to the physical medium e.g., the USB controller has a PHY to provide functions +such as serialization, de-serialization, encoding, decoding and is responsible +for obtaining the required data transmission rate. Note that some USB +controllers have PHY functionality embedded into it and others use an external +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet, +SATA etc. + +The intention of creating this framework is to bring the PHY drivers spread +all over the Linux kernel to drivers/phy to increase code re-use and for +better code maintainability. + +This framework will be of use only to devices that use external PHY (PHY +functionality is not embedded within the controller). + +2. Registering/Unregistering the PHY provider + +PHY provider refers to an entity that implements one or more PHY instances. +For the simple case where the PHY provider implements only a single instance of +the
RE: [PATCH v2 01/21] usb/gadget: multi: fix error return code in cdc_do_config()
On Thursday, July 25, 2013 7:33 PM Felipe Balbi wrote: On Fri, Jul 19, 2013 at 12:28:13PM +0200, Andrzej Pietrasiewicz wrote: Fix to return a negative error code from the error handling case instead of 0, as returned elsewhere in this function. Introduced by commit 59835a (usb: gadget: multi: use function framework for ACM.) Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com you really don't want to send fixes and new code in the same series. Please split this series properly into two series (even if the fixes series is a single patch), and resend with Michal's ack in place so I can apply. Done. The first 2 of the 21 were actually bugfixes, now sent in a separate series, with ACKs. I've also implemented changes resulting from Michal's comments (thank you, Michal!) but since these are new features meant for 3.12, I will post the three configfs support series (mass_storage, acm_ms, multi) in the beginning of the next week after I've done some testing. Thanks, Andrzej -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH v10 4/8] arm: omap3: twl: add phy consumer data in twl4030_usb_data
The PHY framework uses the phy consumer data populated in platform data in the case of non-dt boot to return the reference to the PHY when the controller (PHY consumer) requests for it. So populated the phy consumer data in the platform data of twl usb. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- arch/arm/mach-omap2/twl-common.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index c05898f..b0d54da 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c @@ -24,6 +24,7 @@ #include linux/i2c/twl.h #include linux/gpio.h #include linux/string.h +#include linux/phy/phy.h #include linux/regulator/machine.h #include linux/regulator/fixed.h @@ -90,8 +91,18 @@ void __init omap_pmic_late_init(void) } #if defined(CONFIG_ARCH_OMAP3) +struct phy_consumer consumers[] = { + PHY_CONSUMER(musb-hdrc.0, usb), +}; + +struct phy_init_data init_data = { + .consumers = consumers, + .num_consumers = ARRAY_SIZE(consumers), +}; + static struct twl4030_usb_data omap3_usb_pdata = { .usb_mode = T2_USB_MODE_ULPI, + .init_data = init_data, }; static int omap3_batt_table[] = { -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH v10 6/8] usb: musb: omap2430: use the new generic PHY framework
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume and usb_phy_set_suspend is replaced with power_on and power_off to align with the new PHY framework. musb-xceiv can't be removed as of now because musb core uses xceiv.state and xceiv.otg. Once there is a separate state machine to handle otg, these can be moved out of xceiv and then we can start using the generic PHY framework. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/musb/Kconfig |1 + drivers/usb/musb/musb_core.h |2 ++ drivers/usb/musb/omap2430.c | 26 -- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 797e3fd..25e2e57 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -76,6 +76,7 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate OMAP2430 and onwards depends on ARCH_OMAP2PLUS + select GENERIC_PHY config USB_MUSB_AM35X tristate AM35x diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 7d341c3..6e567bd 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -46,6 +46,7 @@ #include linux/usb.h #include linux/usb/otg.h #include linux/usb/musb.h +#include linux/phy/phy.h struct musb; struct musb_hw_ep; @@ -346,6 +347,7 @@ struct musb { u16 int_tx; struct usb_phy *xceiv; + struct phy *phy; int nIrq; unsignedirq_wake:1; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 6708a3b..f7b33f4 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -348,11 +348,21 @@ static int omap2430_musb_init(struct musb *musb) * up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - if (dev-parent-of_node) + if (dev-parent-of_node) { + musb-phy = devm_phy_get(dev-parent, usb2-phy); + + /* We can't totally remove musb-xceiv as of now because +* musb core uses xceiv.state and xceiv.otg. Once we have +* a separate state machine to handle otg, these can be moved +* out of xceiv and then we can start using the generic PHY +* framework +*/ musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent, usb-phy, 0); - else + } else { musb-xceiv = devm_usb_get_phy_dev(dev, 0); + musb-phy = devm_phy_get(dev, usb); + } if (IS_ERR(musb-xceiv)) { status = PTR_ERR(musb-xceiv); @@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb) return -EPROBE_DEFER; } + if (IS_ERR(musb-phy)) { + pr_err(HS USB OTG: no PHY configured\n); + return PTR_ERR(musb-phy); + } musb-isr = omap2430_musb_interrupt; status = pm_runtime_get_sync(dev); @@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb) if (glue-status != OMAP_MUSB_UNKNOWN) omap_musb_set_mailbox(glue); - usb_phy_init(musb-xceiv); + phy_init(musb-phy); pm_runtime_put_noidle(musb-controller); return 0; @@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb) del_timer_sync(musb_idle_timer); omap2430_low_level_exit(musb); + phy_exit(musb-phy); return 0; } @@ -633,7 +648,7 @@ static int omap2430_runtime_suspend(struct device *dev) OTG_INTERFSEL); omap2430_low_level_exit(musb); - usb_phy_set_suspend(musb-xceiv, 1); + phy_power_off(musb-phy); } return 0; @@ -648,8 +663,7 @@ static int omap2430_runtime_resume(struct device *dev) omap2430_low_level_init(musb); musb_writel(musb-mregs, OTG_INTERFSEL, musb-context.otg_interfsel); - - usb_phy_set_suspend(musb-xceiv, 0); + phy_power_on(musb-phy); } return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH v10 3/8] usb: phy: twl4030: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. For powering on and powering off the PHY, power_on and power_off ops are used. Once the MUSB OMAP glue is adapted to the new framework, the suspend and resume ops of usb phy library will be removed. Also twl4030-usb driver is moved to drivers/phy/. However using the old usb phy library cannot be completely removed because otg is intertwined with phy and moving to the new framework completely will break otg. Once we have a separate otg state machine, we can get rid of the usb phy library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/Kconfig | 11 ++ drivers/phy/Makefile|1 + drivers/{usb = }/phy/phy-twl4030-usb.c | 56 +-- drivers/usb/phy/Kconfig |9 - drivers/usb/phy/Makefile|1 - include/linux/i2c/twl.h |2 ++ 6 files changed, 67 insertions(+), 13 deletions(-) rename drivers/{usb = }/phy/phy-twl4030-usb.c (95%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 38c3477..ac239ac 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -27,4 +27,15 @@ config OMAP_USB2 The USB OTG controller communicates with the comparator using this driver. +config TWL4030_USB + tristate TWL4030 USB Transceiver Driver + depends on TWL4030_CORE REGULATOR_TWL4030 USB_MUSB_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + help + Enable this to support the USB OTG transceiver on TWL4030 + family chips (including the TWL5030 and TPS659x0 devices). + This transceiver supports high and full speed devices plus, + in host mode, low speed. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index ed5b088..0dd8a98 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o +obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c similarity index 95% rename from drivers/usb/phy/phy-twl4030-usb.c rename to drivers/phy/phy-twl4030-usb.c index 8f78d2d..494f107 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -33,6 +33,7 @@ #include linux/io.h #include linux/delay.h #include linux/usb/otg.h +#include linux/phy/phy.h #include linux/usb/musb-omap.h #include linux/usb/ulpi.h #include linux/i2c/twl.h @@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) dev_dbg(twl-dev, %s\n, __func__); } +static int twl4030_phy_power_off(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_suspend(twl, 0); + return 0; +} + static void __twl4030_phy_resume(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); @@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) } } +static int twl4030_phy_power_on(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + twl4030_phy_resume(twl); + return 0; +} + static int twl4030_usb_ldo_init(struct twl4030_usb *twl) { /* Enable writing to power configuration registers */ @@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) status = twl4030_usb_linkstat(twl); twl-linkstat = status; - if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) + if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); + twl4030_phy_resume(twl); + } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } +static int twl4030_phy_init(struct phy *phy) +{ + struct twl4030_usb *twl = phy_get_drvdata(phy); + + return twl4030_usb_phy_init(twl-phy); +} + static int twl4030_set_suspend(struct usb_phy *x, int suspend) { struct twl4030_usb *twl = phy_to_twl(x); @@ -646,13 +672,23 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) return 0; } +static const struct phy_ops ops = { + .init = twl4030_phy_init, + .power_on = twl4030_phy_power_on, + .power_off = twl4030_phy_power_off, + .owner = THIS_MODULE, +}; + static int twl4030_usb_probe(struct platform_device *pdev) { struct twl4030_usb_data *pdata = pdev-dev.platform_data; struct twl4030_usb *twl; + struct phy *phy; int status, err; struct usb_otg *otg; struct device_node *np = pdev-dev.of_node; + struct phy_provider *phy_provider; + struct phy_init_data
[RESEND PATCH v10 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops
Now that twl4030-usb is adapted to the new generic PHY framework, *set_suspend* and *phy_init* ops can be removed from twl4030-usb driver. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- drivers/phy/phy-twl4030-usb.c | 57 ++--- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index 494f107..c437211 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) } } -static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off) +static int twl4030_phy_power_off(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (twl-asleep) - return; + return 0; twl4030_phy_power(twl, 0); twl-asleep = 1; dev_dbg(twl-dev, %s\n, __func__); -} - -static int twl4030_phy_power_off(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_suspend(twl, 0); return 0; } -static void __twl4030_phy_resume(struct twl4030_usb *twl) +static void __twl4030_phy_power_on(struct twl4030_usb *twl) { twl4030_phy_power(twl, 1); twl4030_i2c_access(twl, 1); @@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl) twl4030_i2c_access(twl, 0); } -static void twl4030_phy_resume(struct twl4030_usb *twl) +static int twl4030_phy_power_on(struct phy *phy) { + struct twl4030_usb *twl = phy_get_drvdata(phy); + if (!twl-asleep) - return; - __twl4030_phy_resume(twl); + return 0; + __twl4030_phy_power_on(twl); twl-asleep = 0; dev_dbg(twl-dev, %s\n, __func__); @@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) cancel_delayed_work(twl-id_workaround_work); schedule_delayed_work(twl-id_workaround_work, HZ); } -} - -static int twl4030_phy_power_on(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - twl4030_phy_resume(twl); return 0; } @@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct *work) } } -static int twl4030_usb_phy_init(struct usb_phy *phy) +static int twl4030_phy_init(struct phy *phy) { - struct twl4030_usb *twl = phy_to_twl(phy); + struct twl4030_usb *twl = phy_get_drvdata(phy); enum omap_musb_vbus_id_status status; /* @@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy) if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) { omap_musb_mailbox(twl-linkstat); - twl4030_phy_resume(twl); + twl4030_phy_power_on(phy); } sysfs_notify(twl-dev-kobj, NULL, vbus); return 0; } -static int twl4030_phy_init(struct phy *phy) -{ - struct twl4030_usb *twl = phy_get_drvdata(phy); - - return twl4030_usb_phy_init(twl-phy); -} - -static int twl4030_set_suspend(struct usb_phy *x, int suspend) -{ - struct twl4030_usb *twl = phy_to_twl(x); - - if (suspend) - twl4030_phy_suspend(twl, 1); - else - twl4030_phy_resume(twl); - - return 0; -} - static int twl4030_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { @@ -719,8 +690,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl-phy.label = twl4030; twl-phy.otg= otg; twl-phy.type = USB_PHY_TYPE_USB2; - twl-phy.set_suspend= twl4030_set_suspend; - twl-phy.init = twl4030_usb_phy_init; otg-phy= twl-phy; otg-set_host = twl4030_set_host; -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH v10 5/8] ARM: dts: omap: update usb_otg_hs data
Updated the usb_otg_hs dt data to include the *phy* and *phy-names* binding in order for the driver to use the new generic PHY framework. Also updated the Documentation to include the binding information. The PHY binding information can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com --- Documentation/devicetree/bindings/usb/omap-usb.txt |5 + Documentation/devicetree/bindings/usb/usb-phy.txt |6 ++ arch/arm/boot/dts/omap3-beagle-xm.dts |2 ++ arch/arm/boot/dts/omap3-evm.dts|2 ++ arch/arm/boot/dts/omap3-overo.dtsi |2 ++ arch/arm/boot/dts/omap4.dtsi |3 +++ arch/arm/boot/dts/twl4030.dtsi |1 + 7 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 57e71f6..825790d 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -19,6 +19,9 @@ OMAP MUSB GLUE - power : Should be 50. This signifies the controller can supply up to 100mA when operating in host mode. - usb-phy : the phandle for the PHY device + - phys : the phandle for the PHY device (used by generic PHY framework) + - phy-names : the names of the PHY corresponding to the PHYs present in the + *phy* phandle. Optional properties: - ctrl-module : phandle of the control module this glue uses to write to @@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 { num-eps = 16; ram-bits = 12; ctrl-module = omap_control_usb; + phys = usb2_phy; + phy-names = usb2-phy; }; Board specific device node entry diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt b/Documentation/devicetree/bindings/usb/usb-phy.txt index 61496f5..c0245c8 100644 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt @@ -5,6 +5,8 @@ OMAP USB2 PHY Required properties: - compatible: Should be ti,omap-usb2 - reg : Address and length of the register set for the device. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -16,6 +18,7 @@ usb2phy@4a0ad080 { compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; OMAP USB3 PHY @@ -25,6 +28,8 @@ Required properties: - reg : Address and length of the register set for the device. - reg-names: The names of the register addresses corresponding to the registers filled in reg. + - #phy-cells: determine the number of cells that should be given in the + phandle while referencing this phy. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on @@ -39,4 +44,5 @@ usb3phy@4a084400 { 0x4a084c00 0x40; reg-names = phy_rx, phy_tx, pll_ctrl; ctrl-module = omap_control_usb; + #phy-cells = 0; }; diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts index afdb164..533b2da 100644 --- a/arch/arm/boot/dts/omap3-beagle-xm.dts +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts @@ -144,6 +144,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts index 7d4329d..4134dd0 100644 --- a/arch/arm/boot/dts/omap3-evm.dts +++ b/arch/arm/boot/dts/omap3-evm.dts @@ -70,6 +70,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi index 8f1abec..a461d2f 100644 --- a/arch/arm/boot/dts/omap3-overo.dtsi +++ b/arch/arm/boot/dts/omap3-overo.dtsi @@ -76,6 +76,8 @@ usb_otg_hs { interface-type = 0; usb-phy = usb2_phy; + phys = usb2_phy; + phy-names = usb2-phy; mode = 3; power = 50; }; diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 22d9f2b..1e8e2fe 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -520,6 +520,7 @@ compatible = ti,omap-usb2; reg = 0x4a0ad080 0x58; ctrl-module = omap_control_usb; + #phy-cells = 0; }; }; @@ -658,6 +659,8 @@ interrupt-names = mc, dma;
[RESEND PATCH v10 0/8] PHY framework
Resending with fixed device tree mailing address! Added a generic PHY framework that provides a set of APIs for the PHY drivers to create/destroy a PHY and APIs for the PHY users to obtain a reference to the PHY with or without using phandle. This framework will be of use only to devices that uses external PHY (PHY functionality is not embedded within the controller). The intention of creating this framework is to bring the phy drivers spread all over the Linux kernel to drivers/phy to increase code re-use and to increase code maintainability. Comments to make PHY as bus wasn't done because PHY devices can be part of other bus and making a same device attached to multiple bus leads to bad design. If the PHY driver has to send notification on connect/disconnect, the PHY driver should make use of the extcon framework. Using this susbsystem to use extcon framwork will have to be analysed. You can find this patch series @ git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git testing I'll create a new branch *next* once this patch series is finalized. All the PHY driver development that depends on PHY framework can be based on this branch. Did USB enumeration testing in panda and beagle after applying [1] [1] - https://lkml.org/lkml/2013/7/26/88 Changes from v9: * Fixed Greg's concern on having *find PHY by string* and changed it to Tomasz pseudo code. * move omap-usb2 phy and twl4030-usb phy to drivers/phy * made all the dependent drivers select GENERIC_PHY instead of having depends on * Made PHY core to assign the id's (so changed the phy_create API). * Adapted twl4030-usb to the new design. Changes from v8: * Added phy_set_drvdata and phy_get_drvdata in phy.h. * Changed phy_create API not to take void *priv. private data should now be set using phy_set_drvdata now. Changes from v7: * Fixed Documentation * Added to_phy, of_phy_provider_register and devm_of_phy_provider_register * modified runtime_pm usage in phy_init, phy_exit, phy_power_on and phy_power_off. Now phy_power_on will enable the clocks and phy_power_off will disable the clocks. * pm_runtime_no_callbacks() is added so that pm_runtime_get_sync doesn't fail * modified other patches to adhere to the changes in the PHY framework * removed usb: phy: twl4030: twl4030 shouldn't be subsys_initcall as it will be merged separately. * reference counting has been added to protect phy ops when the PHY is shared by multiple consumers. Changes from v6 * corrected few typos in Documentation * Changed PHY Subsystem to *bool* in Kconfig (to avoid compilation errors when PHY Subsystem is kept as module and the dependent modules are built-in) * Added if pm_runtime_enabled check before runtime pm calls. Changes from v5: * removed the new sysfs entries as it dint have any new information other than what is already there in /sys/devices/... * removed a bunch of APIs added to get the PHY and now only phy_get and devm_phy_get are used. * Added new APIs to register/unregister the PHY provider. This is needed for dt boot case. * Enabled pm runtime and incorporated the comments given by Alan Stern in a different patch series by Gautam. * Removed the *phy_bind* API. Now the phy binding information should be passed using the platform data to the controller devices. * Fixed a few typos. Changes from v4: * removed of_phy_get_with_args/devm_of_phy_get_with_args. Now the *phy providers* should use their custom implementation of of_xlate or use of_phy_xlate to get *phy instance* from *phy providers*. * Added of_phy_xlate to be used by *phy providers* if it provides only one PHY. * changed phy_core from having subsys_initcall to module_init. * other minor fixes. Changes from v3: * Changed the return value of PHY APIs to ENOSYS * Added APIs of_phy_get_with_args/devm_of_phy_get_with_args to support getting PHYs if the same IP implements multiple PHYs. * modified phy_bind API so that the binding information can now be _updated_. In effect of this removed the binding information added in board files and added only in usb-musb.c. If a particular board uses a different phy binding, it can update it in board file after usb_musb_init(). * Added Documentation/devicetree/bindings/phy/phy-bindings.txt for dt binding information. Changes from v2: * removed phy_descriptor structure completely so changed the APIs which were taking phy_descriptor as parameters * Added 2 more APIs *of_phy_get_byname* and *devm_of_phy_get_byname* to be used by PHY user drivers which has *phy* and *phy-names* binding in the dt data * Fixed a few typos * Removed phy_list and we now use class_dev_iter_init, class_dev_iter_next and class_dev_iter_exit for traversing through the phy list. (Note we still need phy_bind list and phy_bind_mutex). * Changed the sysfs entry name from *bind* to *phy_bind*. Changes from v1: * Added Documentation for the PHY framework * Added few more APIs mostly w.r.t devres * Modified omap-usb2 and twl4030 to make
[RESEND PATCH v10 2/8] usb: phy: omap-usb2: use the new generic PHY framework
Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. The omap-usb2 driver is also moved to driver/phy. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/phy/Kconfig | 12 + drivers/phy/Makefile |1 + drivers/{usb = }/phy/phy-omap-usb2.c | 45 ++--- drivers/usb/phy/Kconfig | 10 drivers/usb/phy/Makefile |1 - 5 files changed, 54 insertions(+), 15 deletions(-) rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 349bef2..38c3477 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -15,4 +15,16 @@ config GENERIC_PHY phy users can obtain reference to the PHY. All the users of this framework should select this config. +config OMAP_USB2 + tristate OMAP USB2 PHY Driver + depends on ARCH_OMAP2PLUS + select GENERIC_PHY + select USB_PHY + select OMAP_CONTROL_USB + help + Enable this to support the transceiver that is part of SOC. This + driver takes care of all the PHY functionality apart from comparator. + The USB OTG controller communicates with the comparator using this + driver. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..ed5b088 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c similarity index 88% rename from drivers/usb/phy/phy-omap-usb2.c rename to drivers/phy/phy-omap-usb2.c index 844ab68..25e0f3c 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -28,6 +28,7 @@ #include linux/pm_runtime.h #include linux/delay.h #include linux/usb/omap_control_usb.h +#include linux/phy/phy.h /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) return 0; } +static int omap_usb_power_off(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 0); + + return 0; +} + +static int omap_usb_power_on(struct phy *x) +{ + struct omap_usb *phy = phy_get_drvdata(x); + + omap_control_usb_phy_power(phy-control_dev, 1); + + return 0; +} + +static struct phy_ops ops = { + .power_on = omap_usb_power_on, + .power_off = omap_usb_power_off, + .owner = THIS_MODULE, +}; + static int omap_usb2_probe(struct platform_device *pdev) { struct omap_usb *phy; + struct phy *generic_phy; struct usb_otg *otg; + struct phy_provider *phy_provider; phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev) phy-phy.otg= otg; phy-phy.type = USB_PHY_TYPE_USB2; + phy_provider = devm_of_phy_provider_register(phy-dev, + of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + phy-control_dev = omap_get_control_dev(); if (IS_ERR(phy-control_dev)) { dev_dbg(pdev-dev, Failed to get control device\n); @@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev) otg-start_srp = omap_usb_start_srp; otg-phy= phy-phy; + platform_set_drvdata(pdev, phy); + pm_runtime_enable(phy-dev); + + generic_phy = devm_phy_create(phy-dev, ops, NULL); + if (IS_ERR(generic_phy)) + return PTR_ERR(generic_phy); + + phy_set_drvdata(generic_phy, phy); + phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k); if (IS_ERR(phy-wkupclk)) { dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n); @@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev) usb_add_phy_dev(phy-phy); - platform_set_drvdata(pdev, phy); - - pm_runtime_enable(phy-dev); - return 0; } diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..7813238 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -72,16 +72,6 @@ config
[RESEND PATCH v10 1/8] drivers: phy: add generic PHY framework
The PHY framework provides a set of APIs for the PHY drivers to create/destroy a PHY and APIs for the PHY users to obtain a reference to the PHY with or without using phandle. For dt-boot, the PHY drivers should also register *PHY provider* with the framework. PHY drivers should create the PHY by passing id and ops like init, exit, power_on and power_off. This framework is also pm runtime enabled. The documentation for the generic PHY framework is added in Documentation/phy.txt and the documentation for dt binding can be found at Documentation/devicetree/bindings/phy/phy-bindings.txt Cc: Tomasz Figa t.f...@samsung.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Acked-by: Felipe Balbi ba...@ti.com Tested-by: Sylwester Nawrocki s.nawro...@samsung.com --- .../devicetree/bindings/phy/phy-bindings.txt | 66 ++ Documentation/phy.txt | 166 + MAINTAINERS|8 + drivers/Kconfig|2 + drivers/Makefile |2 + drivers/phy/Kconfig| 18 + drivers/phy/Makefile |5 + drivers/phy/phy-core.c | 714 include/linux/phy/phy.h| 270 9 files changed, 1251 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt create mode 100644 Documentation/phy.txt create mode 100644 drivers/phy/Kconfig create mode 100644 drivers/phy/Makefile create mode 100644 drivers/phy/phy-core.c create mode 100644 include/linux/phy/phy.h diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt b/Documentation/devicetree/bindings/phy/phy-bindings.txt new file mode 100644 index 000..8ae844f --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt @@ -0,0 +1,66 @@ +This document explains only the device tree data binding. For general +information about PHY subsystem refer to Documentation/phy.txt + +PHY device node +=== + +Required Properties: +#phy-cells:Number of cells in a PHY specifier; The meaning of all those + cells is defined by the binding for the phy node. The PHY + provider can use the values in cells to find the appropriate + PHY. + +For example: + +phys: phy { +compatible = xxx; +reg = ...; +. +. +#phy-cells = 1; +. +. +}; + +That node describes an IP block (PHY provider) that implements 2 different PHYs. +In order to differentiate between these 2 PHYs, an additonal specifier should be +given while trying to get a reference to it. + +PHY user node += + +Required Properties: +phys : the phandle for the PHY device (used by the PHY subsystem) +phy-names : the names of the PHY corresponding to the PHYs present in the + *phys* phandle + +Example 1: +usb1: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = usb2_phy, usb3_phy; +phy-names = usb2phy, usb3phy; +. +. +}; + +This node represents a controller that uses two PHYs, one for usb2 and one for +usb3. + +Example 2: +usb2: usb_otg_ss@xxx { +compatible = xxx; +reg = xxx; +. +. +phys = phys 1; +phy-names = usbphy; +. +. +}; + +This node represents a controller that uses one of the PHYs of the PHY provider +device defined previously. Note that the phy handle has an additional specifier +1 to differentiate between the two PHYs. diff --git a/Documentation/phy.txt b/Documentation/phy.txt new file mode 100644 index 000..4e056c4 --- /dev/null +++ b/Documentation/phy.txt @@ -0,0 +1,166 @@ + PHY SUBSYSTEM + Kishon Vijay Abraham I kis...@ti.com + +This document explains the Generic PHY Framework along with the APIs provided, +and how-to-use. + +1. Introduction + +*PHY* is the abbreviation for physical layer. It is used to connect a device +to the physical medium e.g., the USB controller has a PHY to provide functions +such as serialization, de-serialization, encoding, decoding and is responsible +for obtaining the required data transmission rate. Note that some USB +controllers have PHY functionality embedded into it and others use an external +PHY. Other peripherals that use PHY include Wireless LAN, Ethernet, +SATA etc. + +The intention of creating this framework is to bring the PHY drivers spread +all over the Linux kernel to drivers/phy to increase code re-use and for +better code maintainability. + +This framework will be of use only to devices that use external PHY (PHY +functionality is not embedded within the controller). + +2. Registering/Unregistering the PHY provider + +PHY provider refers to an entity that implements one or more PHY instances. +For the simple case where the PHY provider implements only a single instance of +the
Re: Help adding trace events to xHCI
On Fri, 2013-07-26 at 08:28 -0400, Steven Rostedt wrote: My original though here was that we should be able to reserve (maximum) space on the per-CPU buffer, and then relinquish some of it after the tracepoint was written to the data, but I never had the time to check if that was possible to implement. It would make it a little inefficient at page boundaries, but that seems OK given that our maximum size is only ~100 bytes or so now. Yes that would be trivial to implement. If the max buffer is ~100 bytes, allocate 256 byte buffers per cpu. Also have a per cpu index, and then have something like this: [snip] Ah, yes, that'd work. I was considering putting it into the trace event handling itself so I don't have to allocate those buffers and put the handling into every tracepoint, but I don't know how that'd work with interrupts coming in. If we assume that interrupts coming in in the middle of a tracepoint should be rare, we could do something like * allocate max buffer in on the tracing ringbuffer page * write data into it * if no interrupt came in, reduce reservation but I'm not sure how to implement step 3 :) johannes -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Help adding trace events to xHCI
On Fri, 2013-07-26 at 15:06 +0200, Johannes Berg wrote: On Fri, 2013-07-26 at 08:28 -0400, Steven Rostedt wrote: Ah, yes, that'd work. I was considering putting it into the trace event handling itself so I don't have to allocate those buffers and put the handling into every tracepoint, but I don't know how that'd work with interrupts coming in. If you create helper functions, it shouldn't be too hard. If we assume that interrupts coming in in the middle of a tracepoint should be rare, we could do something like * allocate max buffer in on the tracing ringbuffer page * write data into it * if no interrupt came in, reduce reservation but I'm not sure how to implement step 3 :) It's possible to reduce the ring buffer, it's just not implemented. I'm not sure I want to do that either. Interrupts coming in is not so rare as it can be any interrupt being traced. This means your tracepoints will likely waste a lot of buffer space if you are tracing interrupts as well. That said, I can probably implement a reduce feature of the ring buffer if needed. -- Steve -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Help adding trace events to xHCI
On Fri, 2013-07-26 at 09:17 -0400, Steven Rostedt wrote: On Fri, 2013-07-26 at 15:06 +0200, Johannes Berg wrote: On Fri, 2013-07-26 at 08:28 -0400, Steven Rostedt wrote: Ah, yes, that'd work. I was considering putting it into the trace event handling itself so I don't have to allocate those buffers and put the handling into every tracepoint, but I don't know how that'd work with interrupts coming in. If you create helper functions, it shouldn't be too hard. True, and I could even export them somewhere to share the buffers between all the different subsystems that might use this. If we assume that interrupts coming in in the middle of a tracepoint should be rare, we could do something like * allocate max buffer in on the tracing ringbuffer page * write data into it * if no interrupt came in, reduce reservation but I'm not sure how to implement step 3 :) It's possible to reduce the ring buffer, it's just not implemented. I'm not sure I want to do that either. Interrupts coming in is not so rare as it can be any interrupt being traced. This means your tracepoints will likely waste a lot of buffer space if you are tracing interrupts as well. Well, right now I can live with allocation 110 bytes for each tracepoint, this would just optimise it down. If I was in the middle of writing one such event while an interrupt came in, I'd not be able to reduce the ring-buffer allocation again. I doubt that an interrupt would come in much of the time between allocating the new event and deallocating it partially. The more difficult question would seem to be whether or not we can reliably detect an interrupt having written another event. Also, this would save the memcpy() your scheme had. Anyway, I'm fine with the current status quo, but if more people want to trace variable length things like formatted strings I think it might make sense to add some way of making that more efficient. johannes -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Help adding trace events to xHCI
On Fri, 2013-07-26 at 15:45 +0200, Johannes Berg wrote: Well, right now I can live with allocation 110 bytes for each tracepoint, this would just optimise it down. If I was in the middle of writing one such event while an interrupt came in, I'd not be able to reduce the ring-buffer allocation again. I doubt that an interrupt would come in much of the time between allocating the new event and deallocating it partially. The more difficult question would seem to be whether or not we can reliably detect an interrupt having written another event. Hmm, you may be convincing me ;-) As it just allocates the max anyway, this feature will actually help. Don't worry about the detection of interrupt, it already does that with the discard event. It wouldn't be that hard to extend that into a reduction too. -- Steve -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: serial: add driver for Suunto ANT+ USB device
On Thu, 25 Jul 2013, Greg Kroah-Hartman wrote: From: Greg Kroah-Hartman gre...@linuxfoundation.org This adds a driver for the Suunto ANT+ USB device, exposing it as a usb serial device. This lets the userspace gant program to talk to the device to communicate over the ANT+ protocol to any devices it finds. Reported-by: Steinar Gunderson sgunder...@bigfoot.com Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/usb/serial/Kconfig |7 +++ drivers/usb/serial/Makefile |1 + drivers/usb/serial/suunto.c | 41 + 3 files changed, 49 insertions(+) --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -719,6 +719,13 @@ config USB_SERIAL_FLASHLOADER To compile this driver as a module, choose M here: the module will be called flashloader. +config USB_SERIAL_SUUNTO + tristate USB Suunto ANT+ driver + help + Say Y here if you want to usb the Suunto ANT+ USB device. + + To compile this driver as a module, choose M here: the + module will be called suunto. config USB_SERIAL_DEBUG tristate USB Debugging Device --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI)+= obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o obj-$(CONFIG_USB_SERIAL_SSU100) += ssu100.o +obj-$(CONFIG_USB_SERIAL_SUUNTO) += suunto.o obj-$(CONFIG_USB_SERIAL_SYMBOL) += symbolserial.o obj-$(CONFIG_USB_SERIAL_WWAN)+= usb_wwan.o obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o --- /dev/null +++ b/drivers/usb/serial/suunto.c @@ -0,0 +1,41 @@ +/* + * Suunto ANT+ USB Driver + * + * Copyright (C) 2013 Greg Kroah-Hartman gre...@linuxfoundation.org + * Copyright (C) 2013 Linux Foundation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation only. + */ + +#include linux/kernel.h +#include linux/init.h +#include linux/tty.h +#include linux/module.h +#include linux/usb.h +#include linux/usb/serial.h +#include linux/uaccess.h + +static const struct usb_device_id id_table[] = { + { USB_DEVICE(0x0fcf, 0x1008) }, + { }, +}; +MODULE_DEVICE_TABLE(usb, id_table); + +static struct usb_serial_driver suunto_device = { + .driver = { + .owner =THIS_MODULE, + .name = KBUILD_MODNAME, + }, + .id_table = id_table, + .num_ports =1, +}; + +static struct usb_serial_driver * const serial_drivers[] = { + suunto_device, + NULL, +}; + +module_usb_serial_driver(serial_drivers, id_table); +MODULE_LICENSE(GPL); Would it be a good idea to combine all the little do-nothing modules like this into one single source file? Then adding a new device would require only two things: Change the help message for the Kconfig entry; Add a line to the id_table. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 35/50] media: usb: cx231xx: spin_lock in complete() cleanup
On 07/11/2013 11:05 AM, Ming Lei wrote: Complete() will be run with interrupt enabled, so change to spin_lock_irqsave(). Cc: Mauro Carvalho Chehab mche...@redhat.com Cc: Hans Verkuil hans.verk...@cisco.com Cc: linux-me...@vger.kernel.org Signed-off-by: Ming Lei ming@canonical.com --- drivers/media/usb/cx231xx/cx231xx-audio.c |6 ++ drivers/media/usb/cx231xx/cx231xx-core.c | 10 ++ drivers/media/usb/cx231xx/cx231xx-vbi.c |5 +++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c index 81a1d97..58c1b5c 100644 --- a/drivers/media/usb/cx231xx/cx231xx-audio.c +++ b/drivers/media/usb/cx231xx/cx231xx-audio.c @@ -136,6 +136,7 @@ static void cx231xx_audio_isocirq(struct urb *urb) stride = runtime-frame_bits 3; for (i = 0; i urb-number_of_packets; i++) { + unsigned long flags; int length = urb-iso_frame_desc[i].actual_length / stride; cp = (unsigned char *)urb-transfer_buffer + @@ -158,6 +159,7 @@ static void cx231xx_audio_isocirq(struct urb *urb) length * stride); } + local_irq_save(flags); snd_pcm_stream_lock(substream); Can't you use snd_pcm_stream_lock_irqsave here? Ditto for the other media drivers where this happens: em28xx and tlg2300. I've reviewed the media driver changes and they look OK to me, so if my comment above is fixed, then I can merge them for 3.12. Or are these changes required for 3.11? Regards, Hans dev-adev.hwptr_done_capture += length; @@ -174,6 +176,7 @@ static void cx231xx_audio_isocirq(struct urb *urb) period_elapsed = 1; } snd_pcm_stream_unlock(substream); + local_irq_restore(flags); } if (period_elapsed) snd_pcm_period_elapsed(substream); @@ -224,6 +227,7 @@ static void cx231xx_audio_bulkirq(struct urb *urb) stride = runtime-frame_bits 3; if (1) { + unsigned long flags; int length = urb-actual_length / stride; cp = (unsigned char *)urb-transfer_buffer; @@ -242,6 +246,7 @@ static void cx231xx_audio_bulkirq(struct urb *urb) length * stride); } + local_irq_save(flags); snd_pcm_stream_lock(substream); dev-adev.hwptr_done_capture += length; @@ -258,6 +263,7 @@ static void cx231xx_audio_bulkirq(struct urb *urb) period_elapsed = 1; } snd_pcm_stream_unlock(substream); + local_irq_restore(flags); } if (period_elapsed) snd_pcm_period_elapsed(substream); diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c index 4ba3ce0..593b397 100644 --- a/drivers/media/usb/cx231xx/cx231xx-core.c +++ b/drivers/media/usb/cx231xx/cx231xx-core.c @@ -798,6 +798,7 @@ static void cx231xx_isoc_irq_callback(struct urb *urb) container_of(dma_q, struct cx231xx_video_mode, vidq); struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); int i; + unsigned long flags; switch (urb-status) { case 0: /* success */ @@ -813,9 +814,9 @@ static void cx231xx_isoc_irq_callback(struct urb *urb) } /* Copy data from URB */ - spin_lock(dev-video_mode.slock); + spin_lock_irqsave(dev-video_mode.slock, flags); dev-video_mode.isoc_ctl.isoc_copy(dev, urb); - spin_unlock(dev-video_mode.slock); + spin_unlock_irqrestore(dev-video_mode.slock, flags); /* Reset urb buffers */ for (i = 0; i urb-number_of_packets; i++) { @@ -842,6 +843,7 @@ static void cx231xx_bulk_irq_callback(struct urb *urb) struct cx231xx_video_mode *vmode = container_of(dma_q, struct cx231xx_video_mode, vidq); struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); + unsigned long flags; switch (urb-status) { case 0: /* success */ @@ -857,9 +859,9 @@ static void cx231xx_bulk_irq_callback(struct urb *urb) } /* Copy data from URB */ - spin_lock(dev-video_mode.slock); + spin_lock_irqsave(dev-video_mode.slock, flags); dev-video_mode.bulk_ctl.bulk_copy(dev, urb); - spin_unlock(dev-video_mode.slock); + spin_unlock_irqrestore(dev-video_mode.slock, flags); /* Reset urb buffers */
Re: [PATCH] USB: ohci_usb warn irq nobody cared on shutdown
On Fri, 26 Jul 2013, Caizhiyong wrote: From: caizhiyong caizhiy...@huawei.com When ohci-hcd is shutting down, call ohci_usb_reset reset ohci-hcd, the root hub generate an interrupt, but ohci-rh_state is OHCI_RH_HALTED, and ohci_irq ignore the interrupt, the kernel trigger warning irq nobody cared. ehci-hcd is first disable interrupts, then reset ehci. this patch disable ohci interrupt before reset ohci. The patch is tested at the arm cortex-a9 demo board. Signed-off-by: caizhiyong caizhiy...@huawei.com --- drivers/usb/host/ohci-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index a9d3437..e4b3c63 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -938,8 +938,8 @@ static void ohci_stop (struct usb_hcd *hcd) if (quirk_nec(ohci)) flush_work(ohci-nec_work); - ohci_usb_reset (ohci); ohci_writel (ohci, OHCI_INTR_MIE, ohci-regs-intrdisable); + ohci_usb_reset(ohci); free_irq(hcd-irq, hcd); hcd-irq = 0; Reviewed-by: Alan Stern st...@rowland.harvard.edu -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: After entering D3 cold: URB ffff88020ea41000 submitted while active
On Thu, Jul 25, 2013 at 10:30 PM, Oleksii Shevchuk alx...@gmail.com wrote: https://bugzilla.kernel.org/show_bug.cgi?id=60621 Randomly after returning from S3 or enabling powersaving this trace goes to dmesg: [13108.297051] ehci-pci :00:1a.0: power state changed by ACPI to D3cold [13115.552813] [ cut here ] [13115.552841] WARNING: at drivers/usb/core/urb.c:327 usb_submit_urb+0x360/0x370 [usbcore]() [13115.552843] URB 88020ea41000 submitted while active Looks like a bug in cdc-wdm driver because both wdm_rxwork() and wdm_int_callback() may submit urb of desc-response. Thanks, -- Ming Lei -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH V3 1/2] USB: OHCI: make ohci-ep93xx a separate driver
Separate the OHCI EP93XX host controller driver from ohci-hcd host code so that it can be built as a separate driver module. This work is part of enabling multi-platform kernels on ARM. Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org Acked-by: Alan Stern st...@rowland.harvard.edu Cc: Arnd Bergmann a...@arndb.de Cc: Greg KH g...@kroah.com Cc: linux-usb@vger.kernel.org V2: -ohci_hcd_init() statements are removed, because by default it is called in ohci_setup(). V3: -Unused *ohci variable has been removed. --- drivers/usb/host/Kconfig |8 drivers/usb/host/Makefile |1 + drivers/usb/host/ohci-ep93xx.c | 80 +--- drivers/usb/host/ohci-hcd.c| 19 -- 4 files changed, 43 insertions(+), 65 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index f7f7823..cdfaa04 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -414,6 +414,14 @@ config USB_OHCI_HCD_DA8XX Enables support for the on-chip OHCI controller on DA8xx/OMAP-L1x chips. +config USB_OHCI_HCD_EP93XX + tristate Support for EP93XX on-chip OHCI USB controller + depends on USB_OHCI_HCD ARCH_EP93XX + default y + ---help--- + Enables support for the on-chip OHCI controller on + EP93XX chips. + config USB_OHCI_HCD_AT91 tristate Support for Atmel on-chip OHCI USB controller depends on USB_OHCI_HCD ARCH_AT91 diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index f8d59371..3fee3ea 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_USB_OHCI_HCD_AT91) += ohci-at91.o obj-$(CONFIG_USB_OHCI_HCD_S3C) += ohci-s3c2410.o obj-$(CONFIG_USB_OHCI_HCD_LPC32XX) += ohci-nxp.o obj-$(CONFIG_USB_OHCI_HCD_DA8XX) += ohci-da8xx.o +obj-$(CONFIG_USB_OHCI_HCD_EP93XX) += ohci-ep93xx.o obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index f0aaa48..7b0e3ae 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c @@ -25,8 +25,21 @@ #include linux/clk.h #include linux/device.h -#include linux/signal.h +#include linux/io.h +#include linux/kernel.h +#include linux/module.h #include linux/platform_device.h +#include linux/signal.h +#include linux/usb.h +#include linux/usb/hcd.h + +#include ohci.h + +#define DRIVER_DESC OHCI EP93xx driver + +static const char hcd_name[] = ohci-ep93xx; + +static struct hc_driver __read_mostly ohci_ep93xx_hc_driver; static struct clk *usb_host_clock; @@ -79,8 +92,6 @@ static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, ep93xx_start_hc(pdev-dev); - ohci_hcd_init(hcd_to_ohci(hcd)); - retval = usb_add_hcd(hcd, pdev-resource[1].start, 0); if (retval == 0) return retval; @@ -107,48 +118,6 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd, usb_put_hcd(hcd); } -static int ohci_ep93xx_start(struct usb_hcd *hcd) -{ - struct ohci_hcd *ohci = hcd_to_ohci(hcd); - int ret; - - if ((ret = ohci_init(ohci)) 0) - return ret; - - if ((ret = ohci_run(ohci)) 0) { - dev_err(hcd-self.controller, can't start %s\n, - hcd-self.bus_name); - ohci_stop(hcd); - return ret; - } - - return 0; -} - -static struct hc_driver ohci_ep93xx_hc_driver = { - .description= hcd_name, - .product_desc = EP93xx OHCI, - .hcd_priv_size = sizeof(struct ohci_hcd), - .irq= ohci_irq, - .flags = HCD_USB11 | HCD_MEMORY, - .start = ohci_ep93xx_start, - .stop = ohci_stop, - .shutdown = ohci_shutdown, - .urb_enqueue= ohci_urb_enqueue, - .urb_dequeue= ohci_urb_dequeue, - .endpoint_disable = ohci_endpoint_disable, - .get_frame_number = ohci_get_frame, - .hub_status_data= ohci_hub_status_data, - .hub_control= ohci_hub_control, -#ifdef CONFIG_PM - .bus_suspend= ohci_bus_suspend, - .bus_resume = ohci_bus_resume, -#endif - .start_port_reset = ohci_start_port_reset, -}; - -extern int usb_disabled(void); - static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev) { int ret; @@ -206,7 +175,6 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) } #endif - static struct platform_driver ohci_hcd_ep93xx_driver = { .probe = ohci_hcd_ep93xx_drv_probe, .remove = ohci_hcd_ep93xx_drv_remove, @@ -221,4 +189,24 @@ static struct platform_driver ohci_hcd_ep93xx_driver = { }, }; +static int
[PATCH V3 2/2] USB: OHCI: make ohci-pxa27x a separate driver
Separate the OHCI pxa27x/pxa3xx host controller driver from ohci-hcd host code so that it can be built as a separate driver module. This work is part of enabling multi-platform kernels on ARM. Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org Cc: Arnd Bergmann a...@arndb.de Cc: Greg KH g...@kroah.com Cc: Alan Stern st...@rowland.harvard.edu Cc: linux-usb@vger.kernel.org V2: -Changed ohci_hcd and pxa27x_ohci struct variable names. 1 ohci_hcd struct variable name is ohci. 2 pxa27x_ohci struct variable name is pxa_ohci. V3: -Rewrite the macro definition of to_pxa27x_ohci. -clk_put() function has been called before usb_put_hcd(). --- drivers/usb/host/Kconfig |8 ++ drivers/usb/host/Makefile |1 + drivers/usb/host/ohci-hcd.c|5 - drivers/usb/host/ohci-pxa27x.c | 242 ++-- 4 files changed, 115 insertions(+), 141 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index cdfaa04..0d7ee36 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -422,6 +422,14 @@ config USB_OHCI_HCD_EP93XX Enables support for the on-chip OHCI controller on EP93XX chips. +config USB_OHCI_HCD_PXA27X + tristate Support for PXA27X/PXA3XX on-chip OHCI USB controller + depends on USB_OHCI_HCD (PXA27x || PXA3xx) + default y + ---help--- + Enables support for the on-chip OHCI controller on + PXA27x/PXA3xx chips. + config USB_OHCI_HCD_AT91 tristate Support for Atmel on-chip OHCI USB controller depends on USB_OHCI_HCD ARCH_AT91 diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 3fee3ea..8b7fa89 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -55,6 +55,7 @@ obj-$(CONFIG_USB_OHCI_HCD_S3C)+= ohci-s3c2410.o obj-$(CONFIG_USB_OHCI_HCD_LPC32XX) += ohci-nxp.o obj-$(CONFIG_USB_OHCI_HCD_DA8XX) += ohci-da8xx.o obj-$(CONFIG_USB_OHCI_HCD_EP93XX) += ohci-ep93xx.o +obj-$(CONFIG_USB_OHCI_HCD_PXA27X) += ohci-pxa27x.o obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 3f46cff..f601dde 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1184,11 +1184,6 @@ MODULE_LICENSE (GPL); #define SA_DRIVER ohci_hcd_sa_driver #endif -#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) -#include ohci-pxa27x.c -#define PLATFORM_DRIVERohci_hcd_pxa27x_driver -#endif - #ifdef CONFIG_USB_OHCI_HCD_PPC_OF #include ohci-ppc-of.c #define OF_PLATFORM_DRIVER ohci_hcd_ppc_of_driver diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 5fb91f1..394f221 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -19,15 +19,26 @@ * This file is licenced under the GPL. */ -#include linux/device.h -#include linux/signal.h -#include linux/platform_device.h #include linux/clk.h +#include linux/device.h +#include linux/io.h +#include linux/kernel.h +#include linux/module.h #include linux/of_platform.h #include linux/of_gpio.h -#include mach/hardware.h #include linux/platform_data/usb-ohci-pxa27x.h #include linux/platform_data/usb-pxa3xx-ulpi.h +#include linux/platform_device.h +#include linux/signal.h +#include linux/usb.h +#include linux/usb/hcd.h +#include linux/usb/otg.h + +#include mach/hardware.h + +#include ohci.h + +#define DRIVER_DESC OHCI PXA27x/PXA3x driver /* * UHC: USB Host Controller (OHCI-like) register definitions @@ -101,16 +112,16 @@ #define PXA_UHC_MAX_PORTNUM3 -struct pxa27x_ohci { - /* must be 1st member here for hcd_to_ohci() to work */ - struct ohci_hcd ohci; +static const char hcd_name[] = ohci-pxa27x; + +static struct hc_driver __read_mostly ohci_pxa27x_hc_driver; - struct device *dev; +struct pxa27x_ohci { struct clk *clk; void __iomem*mmio_base; }; -#define to_pxa27x_ohci(hcd)(struct pxa27x_ohci *)hcd_to_ohci(hcd) +#define to_pxa27x_ohci(hcd)(struct pxa27x_ohci *)(hcd_to_ohci(hcd)-priv) /* PMM_NPS_MODE -- PMM Non-power switching mode @@ -122,10 +133,10 @@ struct pxa27x_ohci { PMM_PERPORT_MODE -- PMM per port switching mode Ports are powered individually. */ -static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *ohci, int mode) +static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *pxa_ohci, int mode) { - uint32_t uhcrhda = __raw_readl(ohci-mmio_base + UHCRHDA); - uint32_t uhcrhdb = __raw_readl(ohci-mmio_base + UHCRHDB); + uint32_t uhcrhda = __raw_readl(pxa_ohci-mmio_base + UHCRHDA); + uint32_t uhcrhdb = __raw_readl(pxa_ohci-mmio_base + UHCRHDB); switch (mode) { case PMM_NPS_MODE: @@ -149,20 +160,18 @@ static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *ohci, int mode) uhcrhda |=
[PATCH V3 0/2] USB: OHCI: more bus glues as separate modules
These patches are for separating the SOC On-Chip ohci host controller from ohci-hcd host code into its own driver module. This work is part of enabling multi-platform kernels on ARM. In V2: patch 1/2: -ohci_hcd_init() statements are removed, because by default it is called in ohci_setup(). Patch 2/2: -Changed ohci_hcd and pxa27x_ohci struct variable names. 1 ohci_hcd struct variable name is ohci. 2 pxa27x_ohci struct variable name is pxa_ohci. In V3: Patch 1/2: -Unused *ohci variable has been removed. patch 2/2: -Rewrite the macro definition of to_pxa27x_ohci. -clk_put() function has been called before usb_put_hcd(). Manjunath Goudar (2): USB: OHCI: make ohci-ep93xx a separate driver USB: OHCI: make ohci-pxa27x a separate driver drivers/usb/host/Kconfig | 16 +++ drivers/usb/host/Makefile |2 + drivers/usb/host/ohci-ep93xx.c | 80 ++--- drivers/usb/host/ohci-hcd.c| 24 drivers/usb/host/ohci-pxa27x.c | 242 ++-- 5 files changed, 158 insertions(+), 206 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: serial: add driver for Suunto ANT+ USB device
On Fri, Jul 26, 2013 at 10:27:51AM -0400, Alan Stern wrote: On Thu, 25 Jul 2013, Greg Kroah-Hartman wrote: From: Greg Kroah-Hartman gre...@linuxfoundation.org This adds a driver for the Suunto ANT+ USB device, exposing it as a usb serial device. This lets the userspace gant program to talk to the device to communicate over the ANT+ protocol to any devices it finds. Reported-by: Steinar Gunderson sgunder...@bigfoot.com Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/usb/serial/Kconfig |7 +++ drivers/usb/serial/Makefile |1 + drivers/usb/serial/suunto.c | 41 + 3 files changed, 49 insertions(+) --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -719,6 +719,13 @@ config USB_SERIAL_FLASHLOADER To compile this driver as a module, choose M here: the module will be called flashloader. +config USB_SERIAL_SUUNTO + tristate USB Suunto ANT+ driver + help + Say Y here if you want to usb the Suunto ANT+ USB device. + + To compile this driver as a module, choose M here: the + module will be called suunto. config USB_SERIAL_DEBUG tristate USB Debugging Device --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS)+= sierra.o obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o obj-$(CONFIG_USB_SERIAL_SSU100)+= ssu100.o +obj-$(CONFIG_USB_SERIAL_SUUNTO)+= suunto.o obj-$(CONFIG_USB_SERIAL_SYMBOL)+= symbolserial.o obj-$(CONFIG_USB_SERIAL_WWAN) += usb_wwan.o obj-$(CONFIG_USB_SERIAL_TI)+= ti_usb_3410_5052.o --- /dev/null +++ b/drivers/usb/serial/suunto.c @@ -0,0 +1,41 @@ +/* + * Suunto ANT+ USB Driver + * + * Copyright (C) 2013 Greg Kroah-Hartman gre...@linuxfoundation.org + * Copyright (C) 2013 Linux Foundation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation only. + */ + +#include linux/kernel.h +#include linux/init.h +#include linux/tty.h +#include linux/module.h +#include linux/usb.h +#include linux/usb/serial.h +#include linux/uaccess.h + +static const struct usb_device_id id_table[] = { + { USB_DEVICE(0x0fcf, 0x1008) }, + { }, +}; +MODULE_DEVICE_TABLE(usb, id_table); + +static struct usb_serial_driver suunto_device = { + .driver = { + .owner =THIS_MODULE, + .name = KBUILD_MODNAME, + }, + .id_table = id_table, + .num_ports =1, +}; + +static struct usb_serial_driver * const serial_drivers[] = { + suunto_device, + NULL, +}; + +module_usb_serial_driver(serial_drivers, id_table); +MODULE_LICENSE(GPL); Would it be a good idea to combine all the little do-nothing modules like this into one single source file? Then adding a new device would require only two things: Change the help message for the Kconfig entry; Add a line to the id_table. Yes, I agree. For some reason I thought I tried doing this a year or so ago, and things fell apart, but I can't remember why. I'll go merge them all together later today and see what happens... thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: udc: add gadget state kobject uevent
On Fri, Jul 26, 2013 at 01:56:19PM +0800, Barry Song wrote: 2013/7/18 Felipe Balbi ba...@ti.com: On Thu, Jul 18, 2013 at 05:28:19PM +0800, Rong Wang wrote: Hi Felipe, Thanks, I'll test the patch. But sysfs_notify(gadget-dev.kobj, NULL, status), status or state ? I notice that DEVICE_ATTR(state, S_IRUGO, usb_gadget_state_show, NULL) good eyes, please send a patch which I'll queue on this -rc and Cc: sta...@vger.kernel.org. ok. i will handle that for rong. and pls consider to merge rong's patch about sending uevent. It needs to be fixed based on the comments I had for it, before _anyone_ can merge it. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: gadget: mv_u3d_core: fix violation of locking discipline in mv_u3d_ep_disable()
Hi Felipe, On 07/25/2013 09:30 PM, Felipe Balbi wrote: On Wed, Jul 24, 2013 at 12:20:17AM +0400, Alexey Khoroshilov wrote: mv_u3d_nuke() expects to be calles with ep-u3d-lock held, because mv_u3d_done() does. But mv_u3d_ep_disable() calls it without lock that can lead to unpleasant consequences. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov khoroshi...@ispras.ru which commit introduced the bug ? Which kernels are affected by this bug ? The bug is present from the very beginning: commit 3d4eb9d of 15 June 2012. So it is in the mainline since v3.5. -- Alexey -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
* Bin Liu | 2013-07-23 13:55:27 [-0500]: Hi Sebastian, Hi Bin, either by SRP or HNP, or something else. In TI 3.2 kernel, there is workaround in otg_timer() to _toggle_ the SESSION bit to detect if ID pin is grounded, which means a USB device is connected. I've been looking at http://downloads.ti.com/sitara_linux/esd/AM335xSDK/latest/index_FDS.html and I can't find what you are talking about. My MUSB_DEVCTL doesn't change after I connect a device and the SESSION bit is not set. Also I remain in a_idle state. Do you have maybe a hint for me? :) Regards, -Bin. Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Ejected Nook (usb mass storage) prevents suspend
This is kernel 3.9.9-302.fc19.x86_64. I plugged in a BN Nook (a usb mass storage device), used it, and ejected it. This makes suspend fail: [50135.265514] PM: Entering freeze sleep [50135.265517] Suspending console(s) (use no_console_suspend to debug) [50135.287724] sd 7:0:0:0: [sdb] Synchronizing SCSI cache [50135.290413] sd 7:0:0:0: [sdb] [50135.290415] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [50135.290418] sd 7:0:0:0: [sdb] [50135.290422] Sense Key : Not Ready [current] [50135.290424] sd 7:0:0:0: [sdb] [50135.290429] Add. Sense: Medium not present [50135.290448] dpm_run_callback(): scsi_bus_suspend+0x0/0x40 returns -5 [50135.290454] PM: Device 7:0:0:0 failed to suspend async: error -5 [50138.486917] PM: Some devices failed to suspend [50138.525007] PM: resume of devices complete after 38.132 msecs [50138.525315] pci_pm_runtime_suspend(): hcd_pci_runtime_suspend+0x0/0x50 returns -16 [50138.536357] PM: Finishing wakeup. Experimenting a bit, here's what happens. - Plug in device (so it's working). Suspend works. - eject /dev/sdb. Suspend fails. - Physically unplug the device. Suspend works again. This is actually a real issue -- my laptop can continue to power its usb port while suspended, and the Nook is functional (and charges) while plugged in but ejected, but I can't suspend my laptop so it can charge my Nook. Curiously, this issue seems to be Nook-specific. I can't reproduce it with a Corsair Flash Voyager. --Andy -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Ejected Nook (usb mass storage) prevents suspend
On Fri, 26 Jul 2013, Andy Lutomirski wrote: This is kernel 3.9.9-302.fc19.x86_64. I plugged in a BN Nook (a usb mass storage device), used it, and ejected it. This makes suspend fail: [50135.265514] PM: Entering freeze sleep [50135.265517] Suspending console(s) (use no_console_suspend to debug) [50135.287724] sd 7:0:0:0: [sdb] Synchronizing SCSI cache [50135.290413] sd 7:0:0:0: [sdb] [50135.290415] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [50135.290418] sd 7:0:0:0: [sdb] [50135.290422] Sense Key : Not Ready [current] [50135.290424] sd 7:0:0:0: [sdb] [50135.290429] Add. Sense: Medium not present [50135.290448] dpm_run_callback(): scsi_bus_suspend+0x0/0x40 returns -5 [50135.290454] PM: Device 7:0:0:0 failed to suspend async: error -5 [50138.486917] PM: Some devices failed to suspend [50138.525007] PM: resume of devices complete after 38.132 msecs [50138.525315] pci_pm_runtime_suspend(): hcd_pci_runtime_suspend+0x0/0x50 returns -16 [50138.536357] PM: Finishing wakeup. It looks like sd_sync_cache() should return immediately if no media is present or the media has been changed. In addition, scsi_start_stop_device() should return immediately if no media is present. Or at least, it shouldn't treat medium not present responses as errors. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
Sebastian, On Fri, Jul 26, 2013 at 11:31 AM, Sebastian Andrzej Siewior bige...@linutronix.de wrote: * Bin Liu | 2013-07-23 13:55:27 [-0500]: Hi Sebastian, Hi Bin, either by SRP or HNP, or something else. In TI 3.2 kernel, there is workaround in otg_timer() to _toggle_ the SESSION bit to detect if ID pin is grounded, which means a USB device is connected. I've been looking at http://downloads.ti.com/sitara_linux/esd/AM335xSDK/latest/index_FDS.html and I can't find what you are talking about. My MUSB_DEVCTL doesn't change after I connect a device and the SESSION bit is not set. Also I remain in a_idle state. Do you have maybe a hint for me? :) In TI 3.2 kernel, the otg_timer() toggles the SESSION bit in OTG_STATE_B_IDLE state. So whenever the ID pin is grounded by connecting a device, the controller will try go into host mode. But I have no idea why your board is in a_idle not b_idle. The toggle does not handle a_idle. Do you use the AM335x GP EVM, not the smaller StarterKit EVM, right? the USB0 port on SK EVM is device only. But anyway, I have not seen any use case which uses micro-AB receptacle and requires such dynamic role switching. So I kind of think it is unnecessary to implement this feature. And it is not easy to implement it in a right way, because AM335x does not have an interrupt for ID pin grounding, so we can only try to set SESSION bit in otg_timer(), but that causes 2sec VBUS pulsing on the wire, which violates the specs. Regards, -Bin. Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
On Fri, Jul 26, 2013 at 12:53 PM, Bin Liu binml...@gmail.com wrote: Sebastian, On Fri, Jul 26, 2013 at 11:31 AM, Sebastian Andrzej Siewior bige...@linutronix.de wrote: * Bin Liu | 2013-07-23 13:55:27 [-0500]: Hi Sebastian, Hi Bin, either by SRP or HNP, or something else. In TI 3.2 kernel, there is workaround in otg_timer() to _toggle_ the SESSION bit to detect if ID pin is grounded, which means a USB device is connected. I've been looking at http://downloads.ti.com/sitara_linux/esd/AM335xSDK/latest/index_FDS.html and I can't find what you are talking about. My MUSB_DEVCTL doesn't change after I connect a device and the SESSION bit is not set. Also I remain in a_idle state. Do you have maybe a hint for me? :) In TI 3.2 kernel, the otg_timer() toggles the SESSION bit in OTG_STATE_B_IDLE state. So whenever the ID pin is grounded by connecting a device, the controller will try go into host mode. But I have no idea why your board is in a_idle not b_idle. The toggle does not handle a_idle. Do you use the AM335x GP EVM, not the smaller StarterKit EVM, right? the USB0 port on SK EVM is device only. But anyway, I have not seen any use case which uses micro-AB receptacle and requires such dynamic role switching. So I kind of I meant the real customer use cases, not the EVMs ;) -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
On 07/26/2013 08:17 PM, Bin Liu wrote: Hi Bin. In TI 3.2 kernel, the otg_timer() toggles the SESSION bit in OTG_STATE_B_IDLE state. So whenever the ID pin is grounded by connecting a device, the controller will try go into host mode. But I have no idea why your board is in a_idle not b_idle. The toggle does not handle a_idle. Do you use the AM335x GP EVM, not the smaller StarterKit EVM, right? the USB0 port on SK EVM is device only. But anyway, I have not seen any use case which uses micro-AB receptacle and requires such dynamic role switching. So I kind of I meant the real customer use cases, not the EVMs ;) I am using the about the second port on am335x evm which is used as host (not OTG mode (3) but HOST (1)). If I start the timer OTG after disconnect I see that it gets back to A mode: [ 97.570852] musb-hdrc musb-hdrc.1.auto: Poll devctl 19 (a_wait_bcon) [ 99.570306] musb-hdrc musb-hdrc.1.auto: Poll devctl 98 (a_idle) … [ 209.570259] musb-hdrc musb-hdrc.1.auto: Poll devctl 80 (a_idle) and now the session bit is missing and never gets back so I can not plug any other device. I really have no idea what is missing here… Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
Sebastian, On Fri, Jul 26, 2013 at 1:22 PM, Sebastian Andrzej Siewior bige...@linutronix.de wrote: On 07/26/2013 08:17 PM, Bin Liu wrote: Hi Bin. In TI 3.2 kernel, the otg_timer() toggles the SESSION bit in OTG_STATE_B_IDLE state. So whenever the ID pin is grounded by connecting a device, the controller will try go into host mode. But I have no idea why your board is in a_idle not b_idle. The toggle does not handle a_idle. Do you use the AM335x GP EVM, not the smaller StarterKit EVM, right? the USB0 port on SK EVM is device only. But anyway, I have not seen any use case which uses micro-AB receptacle and requires such dynamic role switching. So I kind of I meant the real customer use cases, not the EVMs ;) I am using the about the second port on am335x evm which is used as host (not OTG mode (3) but HOST (1)). If I start the timer OTG after disconnect I see that it gets back to A mode: [ 97.570852] musb-hdrc musb-hdrc.1.auto: Poll devctl 19 (a_wait_bcon) I don't think you are testing with the 3.2 kernel you referred from the ti.com link you mentioned above. 3.2 kernel should have no '.auto' at the end of the device name. If it is 3.8 or later, it seems the driver does something wrong, SESSION bit should not be cleared after the device is unplugged. [ 99.570306] musb-hdrc musb-hdrc.1.auto: Poll devctl 98 (a_idle) … [ 209.570259] musb-hdrc musb-hdrc.1.auto: Poll devctl 80 (a_idle) and now the session bit is missing and never gets back so I can not plug any other device. I really have no idea what is missing here… Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes
From: Felipe Balbi [mailto:ba...@ti.com] Sent: Friday, July 26, 2013 2:54 AM Also, this is not *modifying* what was passed, just skipping the xHCI address space so we don't request_mem_region() an area we won't really handle and prevent xhci-hcd.ko from probing. Hmm? platform_get_resource() returns a pointer to an entry in the platform_device's resource[] array. And res-start += modifies the entry pointed at. If it didn't, the bug fixed by this patch wouldn't have happened. Are you sure this code will work OK if you build the driver as a module, modprobe it, rmmod it, and then modprobe it again? Seems like it won't, unless the dev-resource[] array gets reinitialized in between somehow. gotta try that one... Perhaps the correct way would be to copy the resource to a private struct resource and modify that one, leaving pdev-resources untouched. Maybe this is a dumb question, but why can't the driver that is going to use the resource after this just know that it has to add DWC3_GLOBALS_REGS_START to the start address? Are there some versions of the core where that is not the case? Or, maybe there should be two sets of resources? -- Paul -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Audio I/O parameters
On Fri, 26 Jul 2013, Clemens Ladisch wrote: Alan Stern wrote: On Thu, 25 Jul 2013, James Stone wrote: The only slight difference I can see is that maybe the 3.10 uses slightly higher CPU load than 3.5 at the ridiculously low latency of 64 frames/period duplex. With the new patch, what you actually get is 44.1 frames/period (on average). In ALSA, the number of frames per period is a constant integer, and Jack requires it to be a power of two. (Where frame is an audio frame, and period is the interval between interrupts reported to user space.) With a sample rate of 44100 Hz and a packet rate of 8000 Hz, there should be about 5.5 samples per packet. With a period size of 64 audio frames, this results in about 11.6 packets per period. The driver does not completely fill URBs to ensure that interrupts happen at period boundaries. Oho! I missed all that period_elapsed stuff in prepare_playback_urb()! But you don't do the same thing for recording URBs -- presumably because you can't tell in advance how many samples the device will send. This makes the calculation of the number of URBs more complicated. Revised patch below. James, can you try this out and send me the usbmon trace? At 64 frames/period this should end up using 4 URBs, which is the minimum requirement if there are no more than 8 packets per URB and an incompletely filled URB can contain as few as 1 packets. With this patch, there should be no difficulty going down to 32 or maybe even 16 frames/period. One more thing: I don't understand the calculations involving delay, est_delay, last_delay, and so on in pcm.c. Regardless, they appear not to be as good as they could be, because they don't use urb-start_frame. Another problem, not necessarily a bad one: The feedback data from the sound device indicates that its internal clock is actually running at 45168 Hz, even though it claims to be running at 44100. The feedback data is not measured in real Hz (wall clock time) but relatively to the 8 kHz bus clock. Furthermore, it does not show the device's internal clock but the rate at which the device wants to receive frames; this can be higher at the beginning of a stream if the device has an empty FIFO and wants to fill it up. Sorry, this was a miscalculation on my part. I divided the value from the device by 8000 instead of 8192. The correct calculation shows the internal clock is running at 44109 Hz. Close enough. Alan Stern Index: usb-3.10/sound/usb/endpoint.c === --- usb-3.10.orig/sound/usb/endpoint.c +++ usb-3.10/sound/usb/endpoint.c @@ -575,6 +575,7 @@ static int data_ep_set_params(struct snd struct snd_usb_endpoint *sync_ep) { unsigned int maxsize, i, urb_packs, total_packs, packs_per_ms; + unsigned int min_queued_packs, max_packs; int is_playback = usb_pipeout(ep-pipe); int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels; @@ -608,11 +609,21 @@ static int data_ep_set_params(struct snd else ep-curpacksize = maxsize; - if (snd_usb_get_speed(ep-chip-dev) != USB_SPEED_FULL) + if (snd_usb_get_speed(ep-chip-dev) != USB_SPEED_FULL) { packs_per_ms = 8 ep-datainterval; - else + + /* high speed needs 10 USB uframes on the queue at all times */ + min_queued_packs = DIV_ROUND_UP(10, 8 / packs_per_ms); + max_packs = MAX_PACKS_HS; + } else { packs_per_ms = 1; + /* full speed needs one USB frame on the queue at all times */ + min_queued_packs = 1; + max_packs = MAX_PACKS; + } + max_packs = min(max_packs, MAX_QUEUE * packs_per_ms); + if (is_playback !snd_usb_endpoint_implicit_feedback_sink(ep)) { urb_packs = max(ep-chip-nrpacks, 1); urb_packs = min(urb_packs, (unsigned int) MAX_PACKS); @@ -625,42 +636,46 @@ static int data_ep_set_params(struct snd if (sync_ep !snd_usb_endpoint_implicit_feedback_sink(ep)) urb_packs = min(urb_packs, 1U sync_ep-syncinterval); - /* decide how many packets to be used */ - if (is_playback !snd_usb_endpoint_implicit_feedback_sink(ep)) { - unsigned int minsize, maxpacks; - /* determine how small a packet can be */ - minsize = (ep-freqn (16 - ep-datainterval)) - * (frame_bits 3); - /* with sync from device, assume it can be 12% lower */ - if (sync_ep) - minsize -= minsize 3; - minsize = max(minsize, 1u); - total_packs = (period_bytes + minsize - 1) / minsize; - /* we need at least two URBs for queueing */ - if (total_packs 2) { - total_packs = 2; - } else { -
Re: [PATCH V3 2/2] USB: OHCI: make ohci-pxa27x a separate driver
On Fri, 26 Jul 2013, Manjunath Goudar wrote: Separate the OHCI pxa27x/pxa3xx host controller driver from ohci-hcd host code so that it can be built as a separate driver module. This work is part of enabling multi-platform kernels on ARM. Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org Cc: Arnd Bergmann a...@arndb.de Cc: Greg KH g...@kroah.com Cc: Alan Stern st...@rowland.harvard.edu Cc: linux-usb@vger.kernel.org V2: -Changed ohci_hcd and pxa27x_ohci struct variable names. 1 ohci_hcd struct variable name is ohci. 2 pxa27x_ohci struct variable name is pxa_ohci. V3: -Rewrite the macro definition of to_pxa27x_ohci. -clk_put() function has been called before usb_put_hcd(). Acked-by: Alan Stern st...@rowland.harvard.edu -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] chipidea: core: Move hw_phymode_configure() into probe
Fabio Estevam fabio.este...@freescale.com writes: Currently hw_phymode_configure() is located inside hw_device_reset(), which is only called by chipidea udc driver. When operating in host mode, we also need to call hw_phymode_configure() in order to properly configure the PHY mode, so move this function into probe. After this change, USB Host1 port on mx53qsb board is functional. nice catch. With this patch and the vbus supply patch, the 2 ports of my imx53qsb are working here too. Thanks. Signed-off-by: Fabio Estevam fabio.este...@freescale.com Tested-by: Arnaud Patard arnaud.pat...@rtp-net.org Arnaud -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
On 07/26/2013 08:29 PM, Bin Liu wrote: Hi Bin, [ 97.570852] musb-hdrc musb-hdrc.1.auto: Poll devctl 19 (a_wait_bcon) I don't think you are testing with the 3.2 kernel you referred from the ti.com link you mentioned above. 3.2 kernel should have no '.auto' at the end of the device name. If it is 3.8 or later, it seems the driver does something wrong, SESSION bit should not be cleared after the device is unplugged. The bit is removed in otg_timer() because the phy gets into OTG_STATE_A_WAIT_BCON. Now, this is current HEAD + my stuff to get second port working. I downloaded v3.2 and browsed as I was looking for the workaround, never tested maybe I should… On v3.8 from git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git I don't get the second port to work. I see [1.989101] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002 [1.996361] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [2.004060] usb usb1: Product: MUSB HDRC host driver [2.009363] usb usb1: Manufacturer: Linux 3.8.13+ musb-hcd [2.015183] usb usb1: SerialNumber: musb-hdrc.0.auto [2.033653] hub 1-0:1.0: USB hub found [2.037861] hub 1-0:1.0: 1 port detected and nothing happens once I plug in the device. Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
Sebastian, On Fri, Jul 26, 2013 at 2:55 PM, Sebastian Andrzej Siewior bige...@linutronix.de wrote: The bit is removed in otg_timer() because the phy gets into OTG_STATE_A_WAIT_BCON. Now, this is current HEAD + my stuff to get second port working. I downloaded v3.2 and browsed as I was looking for the workaround, never tested maybe I should… On v3.8 from git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git I don't get the second port to work. I see [1.989101] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002 [1.996361] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [2.004060] usb usb1: Product: MUSB HDRC host driver [2.009363] usb usb1: Manufacturer: Linux 3.8.13+ musb-hcd [2.015183] usb usb1: SerialNumber: musb-hdrc.0.auto [2.033653] hub 1-0:1.0: USB hub found [2.037861] hub 1-0:1.0: 1 port detected and nothing happens once I plug in the device. I started thinking when I tried this git.ti.com 3.8 kernel, I might have done 'devmem2 0x47401c60 b 0x81' to manually set the SESSION bit after plugged a device. It was months ago, I don't quite remember what I tested. My build server is down this afternoon. Once it comes back next week, I will try 3.8 again, to see how I can help on this USB1 host mode issue. its devctl register should stay on 0x19 even nothing is connected. Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] usb: phy: rename nop_usb_xceiv = usb_phy_gen_xceiv
The nop driver isn't a do-nothing-stub but supports a couple functions like clock on/off or is able to use a voltage regulator. This patch simply renames the driver to generic since it is easy possible to extend it by a simple function istead of writing a complete driver. Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de --- arch/arm/mach-omap2/board-omap3beagle.c | 2 +- arch/arm/mach-omap2/board-omap3evm.c | 2 +- arch/arm/mach-omap2/board-omap3pandora.c | 2 +- arch/arm/mach-omap2/usb-host.c | 8 +++--- drivers/usb/dwc3/dwc3-exynos.c | 6 ++-- drivers/usb/dwc3/dwc3-pci.c | 6 ++-- drivers/usb/phy/Makefile | 2 +- drivers/usb/phy/{phy-nop.c = phy-generic.c} | 42 ++-- include/linux/usb/nop-usb-xceiv.h| 2 +- 9 files changed, 36 insertions(+), 36 deletions(-) rename drivers/usb/phy/{phy-nop.c = phy-generic.c} (84%) diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c index 04c1165..f595b23 100644 --- a/arch/arm/mach-omap2/board-omap3beagle.c +++ b/arch/arm/mach-omap2/board-omap3beagle.c @@ -279,7 +279,7 @@ static struct regulator_consumer_supply beagle_vsim_supply[] = { static struct gpio_led gpio_leds[]; /* PHY's VCC regulator might be added later, so flag that we need it */ -static struct nop_usb_xceiv_platform_data hsusb2_phy_data = { +static struct usb_phy_gen_xceiv_platform_data hsusb2_phy_data = { .needs_vcc = true, }; diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c index 8c02626..5d98ef0 100644 --- a/arch/arm/mach-omap2/board-omap3evm.c +++ b/arch/arm/mach-omap2/board-omap3evm.c @@ -468,7 +468,7 @@ struct wl12xx_platform_data omap3evm_wlan_data __initdata = { static struct regulator_consumer_supply omap3evm_vaux2_supplies[] = { REGULATOR_SUPPLY(VDD_CSIPHY1, omap3isp),/* OMAP ISP */ REGULATOR_SUPPLY(VDD_CSIPHY2, omap3isp),/* OMAP ISP */ - REGULATOR_SUPPLY(vcc, nop_usb_xceiv.2), /* hsusb port 2 */ + REGULATOR_SUPPLY(vcc, usb_phy_gen_xceiv.2), /* hsusb port 2 */ REGULATOR_SUPPLY(vaux2, NULL), }; diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c index b1547a0..d2b455e 100644 --- a/arch/arm/mach-omap2/board-omap3pandora.c +++ b/arch/arm/mach-omap2/board-omap3pandora.c @@ -352,7 +352,7 @@ static struct regulator_consumer_supply pandora_vcc_lcd_supply[] = { }; static struct regulator_consumer_supply pandora_usb_phy_supply[] = { - REGULATOR_SUPPLY(vcc, nop_usb_xceiv.2), /* hsusb port 2 */ + REGULATOR_SUPPLY(vcc, usb_phy_gen_xceiv.2), /* hsusb port 2 */ }; /* ads7846 on SPI and 2 nub controllers on I2C */ diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c index 2eb19d4..b54bd06 100644 --- a/arch/arm/mach-omap2/usb-host.c +++ b/arch/arm/mach-omap2/usb-host.c @@ -349,7 +349,7 @@ static struct fixed_voltage_config hsusb_reg_config = { /* .init_data filled later */ }; -static const char *nop_name = nop_usb_xceiv; /* NOP PHY driver */ +static const char *nop_name = usb_phy_gen_xceiv; /* NOP PHY driver */ static const char *reg_name = reg-fixed-voltage; /* Regulator driver */ /** @@ -460,9 +460,9 @@ int usbhs_init_phys(struct usbhs_phy_data *phy, int num_phys) pdevinfo.name = nop_name; pdevinfo.id = phy-port; pdevinfo.data = phy-platform_data; - pdevinfo.size_data = sizeof(struct nop_usb_xceiv_platform_data); - - scnprintf(phy_id, MAX_STR, nop_usb_xceiv.%d, + pdevinfo.size_data = + sizeof(struct usb_phy_gen_xceiv_platform_data); + scnprintf(phy_id, MAX_STR, usb_phy_gen_xceiv.%d, phy-port); pdev = platform_device_register_full(pdevinfo); if (IS_ERR(pdev)) { diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 9a8a5e1..1a83fb3 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -38,13 +38,13 @@ struct dwc3_exynos { static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) { - struct nop_usb_xceiv_platform_data pdata; + struct usb_phy_gen_xceiv_platform_data pdata; struct platform_device *pdev; int ret; memset(pdata, 0x00, sizeof(pdata)); - pdev = platform_device_alloc(nop_usb_xceiv, PLATFORM_DEVID_AUTO); + pdev = platform_device_alloc(usb_phy_gen_xceiv, PLATFORM_DEVID_AUTO); if (!pdev) return -ENOMEM; @@ -55,7 +55,7 @@ static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) if (ret) goto err1; - pdev = platform_device_alloc(nop_usb_xceiv, PLATFORM_DEVID_AUTO); + pdev =
[PATCH 3/4] usb: musb: dsps: remove the hardcoded phy pieces
dsps uses a nop driver which is added in dsps itself and does the PHY on/off calls within dsps. Since those calls are now moved the nop driver itself, we can now request the phy proper phy and remove those calls. Currently only the first musb interface is used so we only add one phy node for now. Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de --- drivers/usb/musb/musb_dsps.c | 97 +--- 1 file changed, 1 insertion(+), 96 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 23f511f..19819fd 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -120,49 +120,8 @@ struct dsps_glue { const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ struct timer_list timer[2]; /* otg_workaround timer */ unsigned long last_timer[2];/* last timer data for each instance */ - u32 __iomem *usb_ctrl[2]; }; -#defineDSPS_AM33XX_CONTROL_MODULE_PHYS_0 0x44e10620 -#defineDSPS_AM33XX_CONTROL_MODULE_PHYS_1 0x44e10628 - -static const resource_size_t dsps_control_module_phys[] = { - DSPS_AM33XX_CONTROL_MODULE_PHYS_0, - DSPS_AM33XX_CONTROL_MODULE_PHYS_1, -}; - -#define USBPHY_CM_PWRDN(1 0) -#define USBPHY_OTG_PWRDN (1 1) -#define USBPHY_OTGVDET_EN (1 19) -#define USBPHY_OTGSESSEND_EN (1 20) - -/** - * musb_dsps_phy_control - phy on/off - * @glue: struct dsps_glue * - * @id: musb instance - * @on: flag for phy to be switched on or off - * - * This is to enable the PHY using usb_ctrl register in system control - * module space. - * - * XXX: This function will be removed once we have a seperate driver for - * control module - */ -static void musb_dsps_phy_control(struct dsps_glue *glue, u8 id, u8 on) -{ - u32 usbphycfg; - - usbphycfg = readl(glue-usb_ctrl[id]); - - if (on) { - usbphycfg = ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN); - usbphycfg |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN; - } else { - usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN; - } - - writel(usbphycfg, glue-usb_ctrl[id]); -} /** * dsps_musb_enable - enable interrupts */ @@ -407,8 +366,7 @@ static int dsps_musb_init(struct musb *musb) musb-mregs += wrp-musb_core_offset; /* NOP driver needs change if supporting dual instance */ - usb_nop_xceiv_register(); - musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2); + musb-xceiv = devm_usb_get_phy_by_phandle(glue-dev, phys, 0); if (IS_ERR_OR_NULL(musb-xceiv)) return -EPROBE_DEFER; @@ -426,9 +384,6 @@ static int dsps_musb_init(struct musb *musb) /* Reset the musb */ dsps_writel(reg_base, wrp-control, (1 wrp-reset)); - /* Start the on-chip PHY and its PLL. */ - musb_dsps_phy_control(glue, pdev-id, 1); - musb-isr = dsps_interrupt; /* reset the otgdisable bit, needed for host mode to work */ @@ -438,8 +393,6 @@ static int dsps_musb_init(struct musb *musb) return 0; err0: - usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return status; } @@ -451,14 +404,7 @@ static int dsps_musb_exit(struct musb *musb) del_timer_sync(glue-timer[pdev-id]); - /* Shutdown the on-chip PHY and its PLL. */ - musb_dsps_phy_control(glue, pdev-id, 0); usb_phy_shutdown(musb-xceiv); - - /* NOP driver needs change if supporting dual instance */ - usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); - return 0; } @@ -487,16 +433,6 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) char res_name[11]; int ret; - resources[0].start = dsps_control_module_phys[id]; - resources[0].end = resources[0].start + SZ_4 - 1; - resources[0].flags = IORESOURCE_MEM; - - glue-usb_ctrl[id] = devm_ioremap_resource(pdev-dev, resources); - if (IS_ERR(glue-usb_ctrl[id])) { - ret = PTR_ERR(glue-usb_ctrl[id]); - goto err0; - } - /* first resource is for usbss, so start index from 1 */ res = platform_get_resource(pdev, IORESOURCE_MEM, id + 1); if (!res) { @@ -680,36 +616,6 @@ static int dsps_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int dsps_suspend(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev-parent); - struct dsps_glue *glue = platform_get_drvdata(pdev); - const struct dsps_musb_wrapper *wrp = glue-wrp; - int i; - - for (i = 0; i wrp-instances; i++) - musb_dsps_phy_control(glue, i, 0); - - return 0; -} - -static int dsps_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev-parent); - struct dsps_glue *glue = platform_get_drvdata(pdev); - const struct
[PATCH 4/4] usb: musb: dsps: use proper child nodes
This moves the two instances from the big node into two child nodes. The glue layer ontop does almost nothing. There is one devices containing the (2) phy, (2) usb and later the dma engine. The usb device is the glue device which contains the musb device as a child. This is what we do ever since. The new file musb_am335x is just here to prob the new bus and populate child devices. There are a lot of changes to the dsps file as a result of the changes: - musb_core_offset This is gone. The device tree provides memory ressources information for the device there is no need to fix things - instances This is gone as well. If we have two instances then we have have two child enabled nodes in the device tree. For instance the SoC in beagle bone has two USB instances but only one has been wired up so there is no need to load and init the second instance since it won't be used. - dsps_glue is now per glue device In the past there was one of this structs but with an array of two and each instance accessed its variable depending on the platform device id. - no unneeded copy of structs I do not know why struct dsps_musb_wrapper is copied but it is not necessary. The same goes for musb_hdrc_platform_data which allocated on demand and then again by platform_device_add_data(). One copy is enough. Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de --- arch/arm/boot/dts/am335x-bone.dts | 12 ++ arch/arm/boot/dts/am335x-evm.dts | 20 +++ arch/arm/boot/dts/am335x-evmsk.dts | 12 ++ arch/arm/boot/dts/am33xx.dtsi | 89 +++-- drivers/usb/musb/Kconfig | 4 + drivers/usb/musb/Makefile | 3 + drivers/usb/musb/musb_am335x.c | 55 drivers/usb/musb/musb_dsps.c | 255 ++--- 8 files changed, 279 insertions(+), 171 deletions(-) create mode 100644 drivers/usb/musb/musb_am335x.c diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts index 444b4ed..2c2ac84 100644 --- a/arch/arm/boot/dts/am335x-bone.dts +++ b/arch/arm/boot/dts/am335x-bone.dts @@ -120,6 +120,18 @@ status = okay; }; + musb: usb@4740 { + status = okay; + + phy@47401300 { + status = okay; + }; + + usb@47401000 { + status = okay; + }; + }; + i2c0: i2c@44e0b000 { pinctrl-names = default; pinctrl-0 = i2c0_pins; diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index 3aee1a4..93a25de 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts @@ -171,6 +171,26 @@ }; }; + musb: usb@4740 { + status = okay; + + phy@47401300 { + status = okay; + }; + + phy@47401b00 { + status = okay; + }; + + usb@47401000 { + status = okay; + }; + + usb@47401800 { + status = okay; + }; + }; + i2c1: i2c@4802a000 { pinctrl-names = default; pinctrl-0 = i2c1_pins; diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index 0c8ad17..766c23a 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts @@ -207,6 +207,18 @@ }; }; + musb: usb@4740 { + status = okay; + + phy@47401300 { + status = okay; + }; + + usb@47401000 { + status = okay; + }; + }; + epwmss2: epwmss@48304000 { status = okay; diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 38b446b..81afb27 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -26,6 +26,10 @@ serial5 = uart5; d_can0 = dcan0; d_can1 = dcan1; + usb0 = usb0; + usb1 = usb1; + phy0 = usb0_phy; + phy1 = usb1_phy; }; cpus { @@ -333,21 +337,78 @@ status = disabled; }; - usb@4740 { - compatible = ti,musb-am33xx; - reg = 0x4740 0x1000/* usbss */ - 0x47401000
am335x: support for multiple USB instances
Hi, The last series has been rebased ontop Felipe's testing branch. It contains only the support for multiple devices. I decided to keep the temporary change in the nop (now generic) phy driver which should ease the transition. I still have the problem that the second USB port does not work after reconnect due to the missing session bit. I dropped the patch which added it back for now. Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/4] usb: phy: add am335x pieces to generic phy
This patch copies the phy support bits from dsps into the generic phy driver. Most code can be re-used except for the on/off. The additional am335x can be removed once we have a phy driver that does more than this. Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de --- drivers/usb/phy/phy-generic.c | 116 +- 1 file changed, 104 insertions(+), 12 deletions(-) diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 57a0bf0..efc778a 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c @@ -35,6 +35,7 @@ #include linux/clk.h #include linux/regulator/consumer.h #include linux/of.h +#include linux/of_address.h struct usb_phy_gen_xceiv { struct usb_phy phy; @@ -42,6 +43,14 @@ struct usb_phy_gen_xceiv { struct clk *clk; struct regulator *vcc; struct regulator *reset; + + void __iomem *priv_reg; +}; + +struct phy_data { + int (*phy_init)(struct usb_phy *x); + void(*phy_shutdown)(struct usb_phy *x); + int (*reg_init)(struct platform_device *pdev); }; static struct platform_device *pd; @@ -139,8 +148,91 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) return 0; } +const struct phy_data usb_gen_phy_data = { + .phy_init = nop_init, + .phy_shutdown = nop_shutdown, +}; + +#ifdef CONFIG_SOC_AM33XX +static int am335x_reg_init(struct platform_device *pdev) +{ + struct device_node *node = pdev-dev.of_node; + struct usb_phy_gen_xceiv *nop; + struct resource res; + int ret; + + nop = platform_get_drvdata(pdev); + ret = of_address_to_resource(node, 0, res); + if (ret) + return ret; + + nop-priv_reg = devm_request_and_ioremap(pdev-dev, res); + if (!nop-priv_reg) + return -EINVAL; + return 0; +} + +#define AM335X_USB_CTRL0x00 +#define AM335x_USB_STS 0x04 + +#define USBPHY_CM_PWRDN(1 0) +#define USBPHY_OTG_PWRDN (1 1) +#define USBPHY_OTGVDET_EN (1 19) +#define USBPHY_OTGSESSEND_EN (1 20) +static void am335x_phy_power(struct usb_phy_gen_xceiv *nop, bool on) +{ + u32 val; + + val = readl(nop-priv_reg); + if (on) { + val = ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN); + val |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN; + } else { + val |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN; + } + + writel(val, nop-priv_reg); +} + +static int am335x_phy_init(struct usb_phy *phy) +{ + struct usb_phy_gen_xceiv *nop = dev_get_drvdata(phy-dev); + int ret; + + ret = nop_init(phy); + if (ret) + return ret; + am335x_phy_power(nop, true); + return 0; +} + +static void am335x_phy_shutdown(struct usb_phy *phy) +{ + struct usb_phy_gen_xceiv *nop = dev_get_drvdata(phy-dev); + + am335x_phy_power(nop, false); + nop_shutdown(phy); +} + +const struct phy_data am335x_phy_data = { + .reg_init = am335x_reg_init, + .phy_init = am335x_phy_init, + .phy_shutdown = am335x_phy_shutdown, +}; +#endif + +static const struct of_device_id nop_xceiv_dt_ids[] = { + { .compatible = usb-nop-xceiv, }, +#ifdef CONFIG_SOC_AM33XX + { .compatible = ti,am335x-usb-phy, .data = am335x_phy_data }, +#endif + { } +}; +MODULE_DEVICE_TABLE(of, nop_xceiv_dt_ids); + static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) { + const struct phy_data *phy_data = usb_gen_phy_data; struct device *dev = pdev-dev; struct usb_phy_gen_xceiv_platform_data *pdata = pdev-dev.platform_data; struct usb_phy_gen_xceiv*nop; @@ -154,6 +246,8 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) if (!nop) return -ENOMEM; + platform_set_drvdata(pdev, nop); + nop-phy.otg = devm_kzalloc(pdev-dev, sizeof(*nop-phy.otg), GFP_KERNEL); if (!nop-phy.otg) @@ -161,13 +255,20 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) if (dev-of_node) { struct device_node *node = dev-of_node; + const struct of_device_id *of_id; if (of_property_read_u32(node, clock-frequency, clk_rate)) clk_rate = 0; needs_vcc = of_property_read_bool(node, vcc-supply); needs_reset = of_property_read_bool(node, reset-supply); - + of_id = of_match_node(nop_xceiv_dt_ids, node); + if (of_id) { + phy_data = of_id-data; + err = phy_data-reg_init(pdev); + if (err) + return err; + } } else if (pdata) { type = pdata-type; clk_rate = pdata-clk_rate; @@
Re: [PATCH v2 3/7] usb: phy: msm: Move regulator usage to managed resource allocation
On Fri, Jul 26, 2013 at 03:31:34PM +0300, Ivan T. Ivanov wrote: Hi Felipe, On Thu, 2013-07-25 at 16:43 +0300, Ivan T. Ivanov wrote: On Wed, 2013-07-24 at 15:39 +0300, Felipe Balbi wrote: On Tue, Jul 09, 2013 at 06:47:09PM +0300, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com This patch move global regulators variables to driver state structire and move allocation of the regulators to be devm managed. split into two patches please. One for moving the global regulators into your structure and a separate patch to move to devm_* Would you accept patch which convert all resources allocation to devm_ variants in single patch or you prefer separate patches for memory, clocks, regulators and irq? devm_* all over the place should be fine ;-) -- balbi signature.asc Description: Digital signature
Re: [PATCH] usb: gadget: at91_udc: Check gpio lookup results
On Fri, Jul 26, 2013 at 09:23:35AM -0700, Olof Johansson wrote: On Fri, Jul 26, 2013 at 2:54 AM, Felipe Balbi ba...@ti.com wrote: On Thu, Jul 25, 2013 at 01:59:51PM -0700, Olof Johansson wrote: On Thu, Jul 25, 2013 at 10:19 AM, Felipe Balbi ba...@ti.com wrote: On Thu, Jul 25, 2013 at 09:18:39AM -0700, Olof Johansson wrote: That's what the code does today, and I wasn't trying to second-guess their decisions on that. Chances are firmware, in some instances, have left power on so continuing might do no harm. fair enough, then let's just decrease the error message level to debug or info. Fair enough. info seems appropriate (or warn). Want me to respin, or can you edit when you apply? please respin An older patch from Arnd that accomplishes the same warning removal has mysteriously showed up in -next in the last couple of days (ae40d64b1f2db93d7b092e6425a2f716289fbd09), even though commit date was July 15. So, might as well, drop this one. doesn't look like the same thing: commit ae40d64b1f2db93d7b092e6425a2f716289fbd09 Author: Arnd Bergmann a...@arndb.de Date: Wed Jun 19 13:27:27 2013 +0200 usb: gadget: at91_udc: call at91udc_of_init only when needed This avoids a build error in at91sam9261_9g10_defconfig: drivers/usb/gadget/at91_udc.c: In function 'at91udc_probe': drivers/usb/gadget/at91_udc.c:1685:34: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized] board-vbus_active_low = (flags OF_GPIO_ACTIVE_LOW) ? 1 : 0; ^ drivers/usb/gadget/at91_udc.c:1678:21: note: 'flags' was declared here enum of_gpio_flags flags; ^ Making the call to at91udc_of_init conditinal also reduces the object code size without sacrificing build coverage. Signed-off-by: Arnd Bergmann a...@arndb.de Cc: Felipe Balbi ba...@ti.com Cc: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Felipe Balbi ba...@ti.com diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 073b938..2cbab1c 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1725,7 +1725,7 @@ static int at91udc_probe(struct platform_device *pdev) /* init software state */ udc = controller; udc-gadget.dev.parent = dev; - if (pdev-dev.of_node) + if (IS_ENABLED(CONFIG_OF) pdev-dev.of_node) at91udc_of_init(udc, pdev-dev.of_node); else memcpy(udc-board, dev-platform_data, -- balbi signature.asc Description: Digital signature
Re: Ejected Nook (usb mass storage) prevents suspend
On Fri, 26 Jul 2013, Andy Lutomirski wrote: This is kernel 3.9.9-302.fc19.x86_64. I plugged in a BN Nook (a usb mass storage device), used it, and ejected it. This makes suspend fail: [50135.265514] PM: Entering freeze sleep [50135.265517] Suspending console(s) (use no_console_suspend to debug) [50135.287724] sd 7:0:0:0: [sdb] Synchronizing SCSI cache [50135.290413] sd 7:0:0:0: [sdb] [50135.290415] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [50135.290418] sd 7:0:0:0: [sdb] [50135.290422] Sense Key : Not Ready [current] [50135.290424] sd 7:0:0:0: [sdb] [50135.290429] Add. Sense: Medium not present [50135.290448] dpm_run_callback(): scsi_bus_suspend+0x0/0x40 returns -5 [50135.290454] PM: Device 7:0:0:0 failed to suspend async: error -5 [50138.486917] PM: Some devices failed to suspend [50138.525007] PM: resume of devices complete after 38.132 msecs [50138.525315] pci_pm_runtime_suspend(): hcd_pci_runtime_suspend+0x0/0x50 returns -16 [50138.536357] PM: Finishing wakeup. In addition to my earlier comment, the patch below should be applied. It will fix your immediate problem, although not in the best way. Alan Stern Index: usb-3.10/drivers/scsi/scsi_pm.c === --- usb-3.10.orig/drivers/scsi/scsi_pm.c +++ usb-3.10/drivers/scsi/scsi_pm.c @@ -48,8 +48,6 @@ static int scsi_dev_type_resume(struct d static int scsi_bus_suspend_common(struct device *dev, int (*cb)(struct device *)) { - int err = 0; - if (scsi_is_sdev_device(dev)) { /* * All the high-level SCSI drivers that implement runtime @@ -59,10 +57,10 @@ scsi_bus_suspend_common(struct device *d if (pm_runtime_suspended(dev)) return 0; - err = scsi_dev_type_suspend(dev, cb); + scsi_dev_type_suspend(dev, cb); } - return err; + return 0; /* System suspend should never fail */ } static int -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes
Hi, On Fri, Jul 26, 2013 at 06:44:23PM +, Paul Zimmerman wrote: From: Felipe Balbi [mailto:ba...@ti.com] Sent: Friday, July 26, 2013 2:54 AM Also, this is not *modifying* what was passed, just skipping the xHCI address space so we don't request_mem_region() an area we won't really handle and prevent xhci-hcd.ko from probing. Hmm? platform_get_resource() returns a pointer to an entry in the platform_device's resource[] array. And res-start += modifies the entry pointed at. If it didn't, the bug fixed by this patch wouldn't have happened. Are you sure this code will work OK if you build the driver as a module, modprobe it, rmmod it, and then modprobe it again? Seems like it won't, unless the dev-resource[] array gets reinitialized in between somehow. gotta try that one... Perhaps the correct way would be to copy the resource to a private struct resource and modify that one, leaving pdev-resources untouched. Maybe this is a dumb question, but why can't the driver that is going to use the resource after this just know that it has to add DWC3_GLOBALS_REGS_START to the start address? Are there some versions of the core where that is not the case? that won't work, because dwc3.ko will already have request_mem_region() the entire region and a subsequent request_mem_region() for xHCI space only would fail. Or, maybe there should be two sets of resources? maybe we should require two sets of resources, yes... but then there's no point in having any host initialization whatsoever in dwc3.ko. -- balbi signature.asc Description: Digital signature
Re: [PATCH 14/16] usb: musb: dsps: add MUSB_DEVCTL_SESSION back after removal
On 07/26/2013 10:15 PM, Bin Liu wrote: Sebastian, Hi Bin, I started thinking when I tried this git.ti.com 3.8 kernel, I might have done 'devmem2 0x47401c60 b 0x81' to manually set the SESSION bit after plugged a device. It was months ago, I don't quite remember what I tested. Ah. You cheated! :) My build server is down this afternoon. Once it comes back next week, I will try 3.8 again, to see how I can help on this USB1 host mode issue. its devctl register should stay on 0x19 even nothing is connected. Your help is greatly appreciated. To hear what will happen :) Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: gadget: at91_udc: Check gpio lookup results
On Fri, Jul 26, 2013 at 1:30 PM, Felipe Balbi ba...@ti.com wrote: On Fri, Jul 26, 2013 at 09:23:35AM -0700, Olof Johansson wrote: On Fri, Jul 26, 2013 at 2:54 AM, Felipe Balbi ba...@ti.com wrote: On Thu, Jul 25, 2013 at 01:59:51PM -0700, Olof Johansson wrote: On Thu, Jul 25, 2013 at 10:19 AM, Felipe Balbi ba...@ti.com wrote: On Thu, Jul 25, 2013 at 09:18:39AM -0700, Olof Johansson wrote: That's what the code does today, and I wasn't trying to second-guess their decisions on that. Chances are firmware, in some instances, have left power on so continuing might do no harm. fair enough, then let's just decrease the error message level to debug or info. Fair enough. info seems appropriate (or warn). Want me to respin, or can you edit when you apply? please respin An older patch from Arnd that accomplishes the same warning removal has mysteriously showed up in -next in the last couple of days (ae40d64b1f2db93d7b092e6425a2f716289fbd09), even though commit date was July 15. So, might as well, drop this one. doesn't look like the same thing: No, not the same patch, but fixes the same warning as a result. Please stick to the patch from Arnd that you've already applied. Thanks, -Olof -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] usb: host: Faraday fotg210-hcd driver
On Fri, Jul 26, 2013 at 09:52:56AM +, Feng-Hsin Chiang wrote: FOTG210 is an OTG controller which can be configured as an USB2.0 host. FOTG210 host is an ehci-like controller with some differences. First, register layout of FOTG210 is incompatible with EHCI. Furthermore, FOTG210 is lack of siTDs which means iTDs are used for both HS and FS ISO transfer. Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com --- v2: fix most of errors and warnings reported by checkpatch.pl v3: change maintainer You didn't refresh this against the latest tree, and as such, it fails to apply to the tree, which implies that you didn't test it against the latest kernel version either :( Please do this and resend it after testing. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: serial: add driver for Suunto ANT+ USB device
On Fri, Jul 26, 2013 at 02:00:42PM +0200, Steinar H. Gunderson wrote: On Thu, Jul 25, 2013 at 09:52:29PM -0700, Greg Kroah-Hartman wrote: Steinar, I've tested the driver below with my device and it seems to work. If you have any problems with it, please let me know, otherwise I'll queue it up to get into the 3.11 kernel release soon. Backported to 3.10.3 and tested (with my own, old fork of gant), works fine. Wonderful, thanks for testing. Where is the official place for gant these days anyway? greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: serial: add driver for Suunto ANT+ USB device
On Fri, Jul 26, 2013 at 10:55:19AM +0200, Daniele Forsi wrote: 2013/7/26 Greg Kroah-Hartman: + Say Y here if you want to usb the Suunto ANT+ USB device. I think there might be a thinko: s/to usb/to use/ Thanks, now fixed, too much USB on the brain... greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
I've now caught up on my pending USB patches
Hi all, I've now caught up on all pending USB patches that were sent to me, with the exception of Ming's EHCI patches, which I need to test further next week. If you've sent me something, that I haven't applied, please resend it, as it's probably lost somewhere. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] USB: mos7840: fix device-type detection
On Fri, Jul 26, 2013 at 11:55:18AM +0200, Johan Hovold wrote: Fix race in device-type detection introduced by commit 0eafe4de (USB: serial: mos7840: add support for MCS7810 devices) which used a static variable to hold the device type. Move type detection to probe and use serial data to store the device type. I'm getting the following build warnings after applying these patches: CC [M] drivers/usb/serial/mos7840.o drivers/usb/serial/mos7840.c: In function ‘mos7840_probe’: drivers/usb/serial/mos7840.c:2224:30: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] drivers/usb/serial/mos7840.c: In function ‘mos7840_calc_num_ports’: drivers/usb/serial/mos7840.c:2231:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] drivers/usb/serial/mos7840.c: In function ‘mos7840_port_probe’: drivers/usb/serial/mos7840.c:2242:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Can you send me a follow-on patch to fix them up? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: serial: add driver for Suunto ANT+ USB device
On Fri, Jul 26, 2013 at 02:12:46PM -0700, Greg Kroah-Hartman wrote: Backported to 3.10.3 and tested (with my own, old fork of gant), works fine. Wonderful, thanks for testing. Where is the official place for gant these days anyway? I wish I knew. I think there are like four forks, some of them under different names (like garmin-ant-downloader), and none really maintained. It doesn't really help that antlib seems to presuppose that sizeof(void*)=4. /* Steinar */ -- Homepage: http://www.sesse.net/ -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html