[PATCH v1 5/9] usb: phy: dsps: adding usbphy driver for am33xx platform
Adds usb-phy driver support for am33xx platform, the host/device peripheral controller shall get this phy object to control the phy operations. Signed-off-by: Ravi Babu ravib...@ti.com --- drivers/usb/phy/Kconfig|9 ++ drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy-dsps-usb.c | 236 3 files changed, 246 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/phy/phy-dsps-usb.c diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 372db48..b55c265 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -85,6 +85,15 @@ config OMAP_USB3 This driver interacts with the OMAP Control USB Driver to power on/off the PHY. +config DSPS_USB2PHY + tristate DSPS USB2 PHY Driver + depends on SOC_AM33XX + help + Enable this to support the transceiver that is part of SOC. This + phy supports all LS/FS/HS speed and also supports OTG functionality. + The USB OTG controller communicates with this phy through stand UTMI + interface. + config SAMSUNG_USBPHY tristate Samsung USB PHY Driver help diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 33863c0..0b16fb3 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_NOP_USB_XCEIV) += phy-nop.o obj-$(CONFIG_OMAP_CONTROL_USB) += phy-omap-control.o obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o obj-$(CONFIG_OMAP_USB3)+= phy-omap-usb3.o +obj-$(CONFIG_DSPS_USB2PHY) += phy-dsps-usb.o obj-$(CONFIG_SAMSUNG_USBPHY) += phy-samsung-usb.o obj-$(CONFIG_SAMSUNG_USB2PHY) += phy-samsung-usb2.o obj-$(CONFIG_SAMSUNG_USB3PHY) += phy-samsung-usb3.o diff --git a/drivers/usb/phy/phy-dsps-usb.c b/drivers/usb/phy/phy-dsps-usb.c new file mode 100644 index 000..aae97b3 --- /dev/null +++ b/drivers/usb/phy/phy-dsps-usb.c @@ -0,0 +1,236 @@ +/* + * phy-dsps-usb.c - TI gs70 based usb phy driver used by usb controller + * + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/module.h +#include linux/platform_device.h +#include linux/slab.h +#include linux/of.h +#include linux/io.h +#include linux/usb/omap_usb.h +#include linux/usb/phy_companion.h +#include linux/clk.h +#include linux/err.h +#include linux/pm_runtime.h +#include linux/delay.h +#include linux/usb/phy.h + +struct dsps_phy { + struct usb_phy phy; + struct device *dev; + struct platform_device *pdev; + void __iomem *phy_ctrl; + void __iomem *phy_wkup; + u8 is_suspended:1; + int id; +}; + +#define DSPS_USBPHY_CM_PWRDN (1 0) +#define DSPS_USBPHY_OTG_PWRDN (1 1) +#define DSPS_USBPHY_OTGVDET_EN (1 19) +#define DSPS_USBPHY_OTGSESSEND_EN (1 20) +#define DSPS_USB0_WKUP_CTRL_ENABLE (1 0) +#define DSPS_USB1_WKUP_CTRL_ENABLE (1 8) +#define phy_to_dspsphy(x) container_of((x), struct dsps_phy, phy) + +static void dsps_usbphy_power(struct usb_phy *phy, bool is_on) +{ + struct dsps_phy *dsps_phy = phy_to_dspsphy(phy); + u32 val; + + val = readl(dsps_phy-phy_ctrl); + + if (is_on) { + val = ~(DSPS_USBPHY_CM_PWRDN | DSPS_USBPHY_OTG_PWRDN); + val |= DSPS_USBPHY_OTGVDET_EN | + DSPS_USBPHY_OTGSESSEND_EN; + } else + val |= DSPS_USBPHY_CM_PWRDN | DSPS_USBPHY_OTG_PWRDN; + + writel(val, dsps_phy-phy_ctrl); +} + +static void dsps_usbphy_wakeup(struct usb_phy *phy, bool enable) +{ + struct dsps_phy *dsps_phy = phy_to_dspsphy(phy); + int id = dsps_phy-id; + u32 val, wkup_flag; + + val = readl(dsps_phy-phy_wkup); + wkup_flag = id ? DSPS_USB1_WKUP_CTRL_ENABLE : + DSPS_USB0_WKUP_CTRL_ENABLE; + + if (enable) + val |= wkup_flag; + else + val = ~wkup_flag; + + writel(val, dsps_phy-phy_wkup); +} + +static int dsps_usbphy_suspend(struct usb_phy *x, int suspend) +{ + struct dsps_phy *dsps_phy = phy_to_dspsphy(x); + + if (suspend) { + if (!pm_runtime_suspended(dsps_phy-pdev-dev)) + pm_runtime_put(dsps_phy-pdev-dev); + } else if (!suspend) + pm_runtime_get(dsps_phy-pdev-dev); + + return 0; +} + +static int
[PATCH v1 9/9] usb: musb: dsp: remove the usb-phy control acess from platform glue
Remove usb-phy control access from platform glue, after moving usb-phy controls to saperate phy-dsps-usb driver. Signed-off-by: Ravi Babu ravib...@ti.com --- drivers/usb/musb/musb_dsps.c | 51 -- 1 files changed, 0 insertions(+), 51 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 0d8581b..958c6b6 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -123,49 +123,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 */ @@ -494,16 +453,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) { -- 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 v1 1/9] usb: musb: dsps: enable dual instance support for am33xx platform
The dsps am33xx platform has two instances of musb controller, enable the support for dual musb instances Signed-off-by: Ravi Babu ravib...@ti.com --- drivers/usb/musb/musb_dsps.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 3a18e44..590dd0b 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -746,7 +746,7 @@ static const struct dsps_musb_wrapper ti81xx_driver_data = { .rxep_bitmap= (0xfffe 16), .musb_core_offset = 0x400, .poll_seconds = 2, - .instances = 1, + .instances = 2, }; static const struct platform_device_id musb_dsps_id_table[] = { -- 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 v1 3/9] arch: arm: omap3: remove unused usb_nop_xceive register API's
Remove the unused usb_nop_xceiv register(_unregister) usage, it is recommeded to use DT bindings to use usb-nop-xceiv driver Signed-off-by: Ravi Babu ravib...@ti.com --- arch/arm/mach-omap2/board-omap3evm.c |3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c index 48789e0..aa7e515 100644 --- a/arch/arm/mach-omap2/board-omap3evm.c +++ b/arch/arm/mach-omap2/board-omap3evm.c @@ -711,9 +711,6 @@ static void __init omap3_evm_init(void) omap_serial_init(); omap_sdrc_init(mt46h32m32lf6_sdrc_params, NULL); - /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */ - usb_nop_xceiv_register(); - if (get_omap3_evm_rev() = OMAP3EVM_BOARD_GEN_2) { /* enable EHCI VBUS using GPIO22 */ omap_mux_init_gpio(OMAP3_EVM_EHCI_VBUS, OMAP_PIN_INPUT_PULLUP); -- 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 v1 6/9] usb: musb: dsps: use usb-phy driver API for phy power on/off
use usb-phy driver API for powering on/off phy and removed usage of the phy control access in platform glue driver. Signed-off-by: Ravi Babu ravib...@ti.com --- drivers/usb/musb/musb_dsps.c | 22 +- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 0ecedb3..0096aad 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -36,6 +36,7 @@ #include linux/dma-mapping.h #include linux/pm_runtime.h #include linux/module.h +#include linux/usb/phy.h #include linux/platform_data/usb-omap.h #include linux/sizes.h @@ -432,7 +433,7 @@ static int dsps_musb_init(struct musb *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); + usb_phy_init(musb-xceiv); musb-isr = dsps_interrupt; @@ -459,10 +460,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); - - /* NOP driver needs change if supporting dual instance */ - usb_put_phy(musb-xceiv); + usb_phy_shutdown(musb-xceiv); return 0; } @@ -690,10 +688,13 @@ 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; + struct musb *musb; int i; - for (i = 0; i wrp-instances; i++) - musb_dsps_phy_control(glue, i, 0); + for (i = 0; i wrp-instances; i++) { + musb = dev_get_drvdata(glue-musb[i]-dev); + usb_phy_set_suspend(musb-xceiv, 1); + } return 0; } @@ -703,10 +704,13 @@ 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 dsps_musb_wrapper *wrp = glue-wrp; + struct musb *musb; int i; - for (i = 0; i wrp-instances; i++) - musb_dsps_phy_control(glue, i, 1); + for (i = 0; i wrp-instances; i++) { + musb = dev_get_drvdata(glue-musb[i]-dev); + usb_phy_set_suspend(musb-xceiv, 0); + } return 0; } -- 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 v1 7/9] usb: musb: dsps: use get-usb-phy by phandle for multi instance
In case of mutli instance support, use get-phy object using phandle to return to repsective phy xceiv object for each instance Signed-off-by: Ravi Babu ravib...@ti.com --- drivers/usb/musb/musb_dsps.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 0096aad..0d8581b 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -416,7 +416,11 @@ static int dsps_musb_init(struct musb *musb) musb-mregs += wrp-musb_core_offset; /* NOP driver needs change if supporting dual instance */ - musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2); + if (dev-parent-of_node) + musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent, + usb-phy, pdev-id); + else + musb-xceiv = devm_usb_get_phy_dev(dev, pdev-id); if (IS_ERR_OR_NULL(musb-xceiv)) return -EPROBE_DEFER; -- 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 v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx
The am33xx platforms suppors dual musb instance which need two instances of usb-phy. Add dual instance usb-phy DT bindings for am333x platform. Signed-off-by: Ravi Babu ravib...@ti.com --- arch/arm/boot/dts/am33xx.dtsi | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 0957645..b0b4deb 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -322,6 +322,22 @@ status = disabled; }; + phy1: usbphy-gs70@44e10620 { + compatible = ti,dsps-usbphy; + reg = 0x44e10620 0x8 + 0x44e10648 0x4; + reg-names = phy_ctrl,phy_wkup; + id = 0; + }; + + phy2: usbphy-gs70@44e10628 { + compatible = ti,dsps-usbphy; + reg = 0x44e10628 0x8 + 0x44e10648 0x4; + reg-names = phy_ctrl,phy_wkup; + id = 1; + }; + usb@4740 { compatible = ti,musb-am33xx; reg = 0x4740 0x1000/* usbss */ @@ -337,6 +353,7 @@ port1-mode = 3; power = 250; ti,hwmods = usb_otg_hs; + usb-phy = phy1, phy2; }; mac: ethernet@4a10 { -- 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 v1 4/9] usb: phy: nop: removing unused usb_nop_xceiv_(un_)register API
remove the unused the usb_nop_xceiv_register _unregister API's from phy-nop driver. The glue platform driver should use DT bindings use usb-nop-xceiv driver Signed-off-by: Ravi Babu ravib...@ti.com --- drivers/usb/musb/musb_dsps.c |1 - drivers/usb/phy/phy-nop.c | 21 - include/linux/usb/nop-usb-xceiv.h | 14 -- 3 files changed, 0 insertions(+), 36 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 14067a1..0ecedb3 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -36,7 +36,6 @@ #include linux/dma-mapping.h #include linux/pm_runtime.h #include linux/module.h -#include linux/usb/nop-usb-xceiv.h #include linux/platform_data/usb-omap.h #include linux/sizes.h diff --git a/drivers/usb/phy/phy-nop.c b/drivers/usb/phy/phy-nop.c index 2b10cc9..52d3fdd 100644 --- a/drivers/usb/phy/phy-nop.c +++ b/drivers/usb/phy/phy-nop.c @@ -44,27 +44,6 @@ struct nop_usb_xceiv { struct regulator *reset; }; -static struct platform_device *pd; - -void usb_nop_xceiv_register(void) -{ - if (pd) - return; - pd = platform_device_register_simple(nop_usb_xceiv, -1, NULL, 0); - if (!pd) { - printk(KERN_ERR Unable to register usb nop transceiver\n); - return; - } -} -EXPORT_SYMBOL(usb_nop_xceiv_register); - -void usb_nop_xceiv_unregister(void) -{ - platform_device_unregister(pd); - pd = NULL; -} -EXPORT_SYMBOL(usb_nop_xceiv_unregister); - static int nop_set_suspend(struct usb_phy *x, int suspend) { return 0; diff --git a/include/linux/usb/nop-usb-xceiv.h b/include/linux/usb/nop-usb-xceiv.h index 148d351..b23c942 100644 --- a/include/linux/usb/nop-usb-xceiv.h +++ b/include/linux/usb/nop-usb-xceiv.h @@ -12,18 +12,4 @@ struct nop_usb_xceiv_platform_data { unsigned int needs_reset:1; }; -#if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) defined(MODULE)) -/* sometimes transceivers are accessed only through e.g. ULPI */ -extern void usb_nop_xceiv_register(void); -extern void usb_nop_xceiv_unregister(void); -#else -static inline void usb_nop_xceiv_register(void) -{ -} - -static inline void usb_nop_xceiv_unregister(void) -{ -} -#endif - #endif /* __LINUX_USB_NOP_XCEIV_H */ -- 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 v1 0/9] adding dual instance and usb-phy support for am335x platform
This patch set series - adds dual musb instances support for am335x platform - adds phy-dsps-usb driver based on TI's gs70 driver - adds DT bindings for am33xx usb-phy - removed references to usb-nop-xceiv from musb has been verified on tree [1] [1] git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git Ravi Babu (9): usb: musb: dsps: enable dual instance support for am33xx platform usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue arch: arm: omap3: remove unused usb_nop_xceive register API's usb: phy: nop: removing unused usb_nop_xceiv_(un_)register API usb: phy: dsps: adding usbphy driver for am33xx platform usb: musb: dsps: use usb-phy driver API for phy power on/off usb: musb: dsps: use get-usb-phy by phandle for multi instance usb: phy: dts: Adding usbphy DT bindings for am33xx usb: musb: dsp: remove the usb-phy control acess from platform glue arch/arm/boot/dts/am33xx.dtsi| 17 +++ arch/arm/mach-omap2/board-omap3evm.c |3 - drivers/usb/musb/am35x.c |2 - drivers/usb/musb/blackfin.c |2 - drivers/usb/musb/da8xx.c |2 - drivers/usb/musb/davinci.c |3 - drivers/usb/musb/musb_dsps.c | 85 +++-- drivers/usb/musb/tusb6010.c |3 - drivers/usb/phy/Kconfig |9 ++ drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy-dsps-usb.c | 236 ++ drivers/usb/phy/phy-nop.c| 21 --- include/linux/usb/nop-usb-xceiv.h| 14 -- 13 files changed, 282 insertions(+), 116 deletions(-) create mode 100644 drivers/usb/phy/phy-dsps-usb.c -- 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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue
removed unused nop xceiv (un_)register API's from all musb platform drivers Signed-off-by: Ravi Babu ravib...@ti.com --- drivers/usb/musb/am35x.c |2 -- drivers/usb/musb/blackfin.c |2 -- drivers/usb/musb/da8xx.c |2 -- drivers/usb/musb/davinci.c |3 --- drivers/usb/musb/musb_dsps.c |3 --- drivers/usb/musb/tusb6010.c |3 --- 6 files changed, 0 insertions(+), 15 deletions(-) diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 2231850..1074c5e 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -362,7 +362,6 @@ static int am35x_musb_init(struct musb *musb) if (!rev) return -ENODEV; - usb_nop_xceiv_register(); musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (IS_ERR_OR_NULL(musb-xceiv)) return -EPROBE_DEFER; @@ -404,7 +403,6 @@ static int am35x_musb_exit(struct musb *musb) data-set_phy_power(0); usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return 0; } diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 5e63b16..8e338d4 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -402,7 +402,6 @@ static int bfin_musb_init(struct musb *musb) } gpio_direction_output(musb-config-gpio_vrsel, 0); - usb_nop_xceiv_register(); musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (IS_ERR_OR_NULL(musb-xceiv)) { gpio_free(musb-config-gpio_vrsel); @@ -427,7 +426,6 @@ static int bfin_musb_exit(struct musb *musb) gpio_free(musb-config-gpio_vrsel); usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return 0; } diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index ea7e591..11dcb6c 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -419,7 +419,6 @@ static int da8xx_musb_init(struct musb *musb) if (!rev) goto fail; - usb_nop_xceiv_register(); musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (IS_ERR_OR_NULL(musb-xceiv)) { ret = -EPROBE_DEFER; @@ -454,7 +453,6 @@ static int da8xx_musb_exit(struct musb *musb) phy_off(); usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return 0; } diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index bea6cc3..94bc1fe 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -382,7 +382,6 @@ static int davinci_musb_init(struct musb *musb) u32 revision; int ret = -ENODEV; - usb_nop_xceiv_register(); musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (IS_ERR_OR_NULL(musb-xceiv)) { ret = -EPROBE_DEFER; @@ -440,7 +439,6 @@ static int davinci_musb_init(struct musb *musb) fail: usb_put_phy(musb-xceiv); unregister: - usb_nop_xceiv_unregister(); return ret; } @@ -488,7 +486,6 @@ static int davinci_musb_exit(struct musb *musb) phy_off(); usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return 0; } diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 590dd0b..14067a1 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -416,7 +416,6 @@ 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); if (IS_ERR_OR_NULL(musb-xceiv)) return -EPROBE_DEFER; @@ -449,7 +448,6 @@ static int dsps_musb_init(struct musb *musb) return 0; err0: usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return status; } @@ -466,7 +464,6 @@ static int dsps_musb_exit(struct musb *musb) /* NOP driver needs change if supporting dual instance */ usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return 0; } diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 7369ba3..2810d2b 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -1066,7 +1066,6 @@ static int tusb_musb_init(struct musb *musb) void __iomem*sync = NULL; int ret; - usb_nop_xceiv_register(); musb-xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (IS_ERR_OR_NULL(musb-xceiv)) return -EPROBE_DEFER; @@ -1118,7 +1117,6 @@ done: iounmap(sync); usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); } return ret; } @@ -1134,7 +1132,6 @@ static int tusb_musb_exit(struct musb *musb) iounmap(musb-sync_va); usb_put_phy(musb-xceiv); - usb_nop_xceiv_unregister(); return 0; } -- 1.7.0.4
[PATCH v4 0/8] Equivalent of g_ncm.ko with configfs
Here I present the conversion of everthing that is required to provide the equivalent of g_ncm.ko with configfs. A branch will be available here (from 23rd May 2013, afternoon UTC): git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs v3..v4: - don't unregister a network interface if it has not been registered before v2..v3: - fixed a bug resulting from the delayed registration of a network interface (should be registered only once) v1..v2: - delayed registering a network interface until gadgets's bind (per Alan's request) - created a helper macro to define USB Ethernet modules' parameters (Michal's review) - fixed and simplified some helper functions (Michal's review) - changed hostaddr variable name to host_mac in several modules (Michal's review) BACKWARD COMPATIBILITY == Please note that the old g_ncm.ko is still available and works. USING THE NEW GADGET == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). Here is the description specific to using g_ncm.ko equivalent. The old g_ncm.ko offered three parameters: qmult - queue length multiplier for high/super -speed devices dev_addr - device's MAC address host_addr - host's MAC address With configfs the procedure is as follows, compared to the information mentioned above (*): instead of mkdir functions/acm.ttyS1 do mkdir functions/ncm.instance name e.g. mkdir functions/ncm.usb0 In functions/ncm.instance name there will be the following attribute files: qmult dev_addr host_addr ifname and after creating the functions/ncm.instance name they contain default values: qmult is 5, dev_addr and host_addr are randomly selected. Except for ifname they can be written to until the function is linked to a configuration. The ifname is read-only and contains the name of the interface which was assigned by the net core, e. g. usb0. The rest of the procedure (*) remains the same. After unbinding the gadget with echo UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS (actually there is just one) == ncm) On the device: ping host's IP On the host: ping device's IP Andrzej Pietrasiewicz (8): usb/gadget: u_ether: convert into module usb/gadget: rndis: convert into module usb/gadget: u_ether: construct with default values and add setters/getters usb/gadget: f_ncm: convert to new function interface with backward compatibility usb/gadget: ncm: convert to new function interface usb/gadget: f_ncm: remove compatibility layer usb/gadget: f_ncm: use usb_gstrings_attach usb/gadget: f_ncm: add configfs support drivers/usb/gadget/Kconfig | 20 +++ drivers/usb/gadget/Makefile |5 + drivers/usb/gadget/cdc2.c| 10 +- drivers/usb/gadget/ether.c | 18 ++- drivers/usb/gadget/f_ncm.c | 336 ++ drivers/usb/gadget/g_ffs.c | 15 +- drivers/usb/gadget/multi.c | 15 +- drivers/usb/gadget/ncm.c | 58 +--- drivers/usb/gadget/nokia.c | 11 +- drivers/usb/gadget/rndis.c | 16 ++ drivers/usb/gadget/rndis.h |1 + drivers/usb/gadget/u_ether.c | 223 +--- drivers/usb/gadget/u_ether.h | 155 +++- drivers/usb/gadget/u_ncm.h | 36 + 14 files changed, 779 insertions(+), 140 deletions(-) create mode 100644 drivers/usb/gadget/u_ncm.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
[PATCH v4 1/8] usb/gadget: u_ether: convert into module
u_ether.c has been #include'd by all gadgets which implement USB Ethernet functions. In order to add configfs support, the f_ecm.c, f_eem.c, f_ncm.c, f_subset.c, f_rndis.c need to be converted into modules and must not be #include'd. Consequently, the u_ether.c needs to be a module too, in a manner similar to u_serial.c. The resulting module should not take any parameters, so they are pushed to the current users of it, that is ether.c, g_ffs.c, multi.c, ncm.c, nokia.c. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig | 10 ++ drivers/usb/gadget/Makefile |1 + drivers/usb/gadget/cdc2.c| 10 ++ drivers/usb/gadget/ether.c | 14 -- drivers/usb/gadget/g_ffs.c | 13 - drivers/usb/gadget/multi.c | 13 - drivers/usb/gadget/ncm.c | 10 ++ drivers/usb/gadget/nokia.c | 11 +++ drivers/usb/gadget/u_ether.c | 38 ++ drivers/usb/gadget/u_ether.h | 30 ++ 10 files changed, 98 insertions(+), 52 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 3ddebff..9152428 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -551,6 +551,9 @@ config USB_F_SS_LB config USB_U_SERIAL tristate +config USB_U_ETHER + tristate + config USB_F_SERIAL tristate @@ -647,6 +650,7 @@ config USB_ETH tristate Ethernet Gadget (with CDC Ethernet support) depends on NET select USB_LIBCOMPOSITE + select USB_U_ETHER select CRC32 help This driver implements Ethernet style communication, in one of @@ -719,6 +723,7 @@ config USB_G_NCM tristate Network Control Model (NCM) support depends on NET select USB_LIBCOMPOSITE + select USB_U_ETHER select CRC32 help This driver implements USB CDC NCM subclass standard. NCM is @@ -762,6 +767,7 @@ config USB_FUNCTIONFS config USB_FUNCTIONFS_ETH bool Include configuration with CDC ECM (Ethernet) depends on USB_FUNCTIONFS NET + select USB_U_ETHER help Include a configuration with CDC ECM function (Ethernet) and the Function Filesystem. @@ -769,6 +775,7 @@ config USB_FUNCTIONFS_ETH config USB_FUNCTIONFS_RNDIS bool Include configuration with RNDIS (Ethernet) depends on USB_FUNCTIONFS NET + select USB_U_ETHER help Include a configuration with RNDIS function (Ethernet) and the Filesystem. @@ -869,6 +876,7 @@ config USB_CDC_COMPOSITE depends on NET select USB_LIBCOMPOSITE select USB_U_SERIAL + select USB_U_ETHER select USB_F_ACM help This driver provides two functions in one configuration: @@ -886,6 +894,7 @@ config USB_G_NOKIA depends on PHONET select USB_LIBCOMPOSITE select USB_U_SERIAL + select USB_U_ETHER select USB_F_ACM help The Nokia composite gadget provides support for acm, obex @@ -913,6 +922,7 @@ config USB_G_MULTI select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS select USB_LIBCOMPOSITE select USB_U_SERIAL + select USB_U_ETHER select USB_F_ACM help The Multifunction Composite Gadget provides Ethernet (RNDIS diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 2e102ff..061abec 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -46,6 +46,7 @@ usb_f_serial-y:= f_serial.o obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o usb_f_obex-y := f_obex.o obj-$(CONFIG_USB_F_OBEX) += usb_f_obex.o +obj-$(CONFIG_USB_U_ETHER) += u_ether.o # # USB gadget drivers diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index c6ee6f1..07b3aaf 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c @@ -35,6 +35,8 @@ /*-*/ USB_GADGET_COMPOSITE_OPTIONS(); +USB_ETHERNET_MODULE_PARAMETERS(); + /* * Kbuild is not very cooperative with respect to linking separately * compiled library objects into one module. So for now we won't use @@ -43,7 +45,6 @@ USB_GADGET_COMPOSITE_OPTIONS(); * a gcc --combine ... part1.c part2.c part3.c ... build would. */ #include f_ecm.c -#include u_ether.c /*-*/ @@ -102,7 +103,7 @@ static struct usb_gadget_strings *dev_strings[] = { NULL, }; -static u8 hostaddr[ETH_ALEN]; +static u8 host_mac[ETH_ALEN]; static struct eth_dev *the_dev; /*-*/ static struct usb_function *f_acm; @@ -120,7 +121,7 @@ static int __init
[PATCH v4 2/8] usb/gadget: rndis: convert into module
In order to convert to configfs the usb functions need to be converted to a new interface and compiled as modules. This patch creates an rndis module which will be used by the new functions. After all users of f_rndis are converted to the new interface, this module can be merged with f_rndis module. 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/Kconfig |6 ++ drivers/usb/gadget/Makefile |2 ++ drivers/usb/gadget/ether.c |4 +++- drivers/usb/gadget/g_ffs.c |2 +- drivers/usb/gadget/multi.c |2 +- drivers/usb/gadget/rndis.c | 16 drivers/usb/gadget/rndis.h |1 + 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 9152428..91b6eab 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -554,6 +554,9 @@ config USB_U_SERIAL config USB_U_ETHER tristate +config USB_U_RNDIS + tristate + config USB_F_SERIAL tristate @@ -651,6 +654,7 @@ config USB_ETH depends on NET select USB_LIBCOMPOSITE select USB_U_ETHER + select USB_U_RNDIS select CRC32 help This driver implements Ethernet style communication, in one of @@ -776,6 +780,7 @@ config USB_FUNCTIONFS_RNDIS bool Include configuration with RNDIS (Ethernet) depends on USB_FUNCTIONFS NET select USB_U_ETHER + select USB_U_RNDIS help Include a configuration with RNDIS function (Ethernet) and the Filesystem. @@ -923,6 +928,7 @@ config USB_G_MULTI select USB_LIBCOMPOSITE select USB_U_SERIAL select USB_U_ETHER + select USB_U_RNDIS select USB_F_ACM help The Multifunction Composite Gadget provides Ethernet (RNDIS diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 061abec..3f51952 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -47,6 +47,8 @@ obj-$(CONFIG_USB_F_SERIAL)+= usb_f_serial.o usb_f_obex-y := f_obex.o obj-$(CONFIG_USB_F_OBEX) += usb_f_obex.o obj-$(CONFIG_USB_U_ETHER) += u_ether.o +u_rndis-y := rndis.o +obj-$(CONFIG_USB_U_RNDIS) += u_rndis.o # # USB gadget drivers diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 75418c7..6bff24f 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -91,6 +91,8 @@ static inline bool has_rndis(void) #endif } +#include linux/module.h + /*-*/ /* @@ -104,7 +106,7 @@ static inline bool has_rndis(void) #include f_subset.c #ifdef USB_ETH_RNDIS #include f_rndis.c -#include rndis.c +#include rndis.h #endif #include f_eem.c diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index 45f26be..fbfdb53 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c @@ -32,7 +32,7 @@ # include f_subset.c # ifdef USB_ETH_RNDIS #include f_rndis.c -#include rndis.c +#include rndis.h # endif # include u_ether.h diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index d0dd603..b8222c4 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -47,7 +47,7 @@ MODULE_LICENSE(GPL); #include f_subset.c #ifdef USB_ETH_RNDIS # include f_rndis.c -# include rndis.c +# include rndis.h #endif #include u_ether.h diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index d9297ee..1ce6bae 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -761,6 +761,7 @@ int rndis_signal_connect(int configNr) return rndis_indicate_status_msg(configNr, RNDIS_STATUS_MEDIA_CONNECT); } +EXPORT_SYMBOL(rndis_signal_connect); int rndis_signal_disconnect(int configNr) { @@ -769,6 +770,7 @@ int rndis_signal_disconnect(int configNr) return rndis_indicate_status_msg(configNr, RNDIS_STATUS_MEDIA_DISCONNECT); } +EXPORT_SYMBOL(rndis_signal_disconnect); void rndis_uninit(int configNr) { @@ -783,11 +785,13 @@ void rndis_uninit(int configNr) while ((buf = rndis_get_next_response(configNr, length))) rndis_free_response(configNr, buf); } +EXPORT_SYMBOL(rndis_uninit); void rndis_set_host_mac(int configNr, const u8 *addr) { rndis_per_dev_params[configNr].host_mac = addr; } +EXPORT_SYMBOL(rndis_set_host_mac); /* * Message Parser @@ -870,6 +874,7 @@ int rndis_msg_parser(u8 configNr, u8 *buf) return -ENOTSUPP; } +EXPORT_SYMBOL(rndis_msg_parser); int rndis_register(void (*resp_avail)(void *v), void *v) { @@ -891,6 +896,7 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
[PATCH v3 1/5] usb/gadget: add helpers for configfs support for USB Ethernet
All USB Ethernet functions will have very similar attributes in configfs. This patch provides helper definitions to ease writing the functions and reduce source code duplication. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_ncm.c| 139 ++- drivers/usb/gadget/u_ether_configfs.h | 164 + 2 files changed, 175 insertions(+), 128 deletions(-) create mode 100644 drivers/usb/gadget/u_ether_configfs.h diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index 697262e..47a5724 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c @@ -24,6 +24,7 @@ #include linux/usb/cdc.h #include u_ether.h +#include u_ether_configfs.h #include u_ncm.h /* @@ -1298,138 +1299,20 @@ static inline struct f_ncm_opts *to_f_ncm_opts(struct config_item *item) func_inst.group); } -CONFIGFS_ATTR_STRUCT(f_ncm_opts); -CONFIGFS_ATTR_OPS(f_ncm_opts); +/* f_ncm_item_ops */ +USB_ETHERNET_CONFIGFS_ITEM(ncm); -static void ncm_attr_release(struct config_item *item) -{ - struct f_ncm_opts *opts = to_f_ncm_opts(item); - - usb_put_function_instance(opts-func_inst); -} - -static struct configfs_item_operations ncm_item_ops = { - .release= ncm_attr_release, - .show_attribute = f_ncm_opts_attr_show, - .store_attribute = f_ncm_opts_attr_store, -}; - -static ssize_t ncm_opts_dev_addr_show(struct f_ncm_opts *opts, char *page) -{ - int result; - - mutex_lock(opts-lock); - result = gether_get_dev_addr(opts-net, page, PAGE_SIZE); - mutex_unlock(opts-lock); - - return result; -} - -static ssize_t ncm_opts_dev_addr_store(struct f_ncm_opts *opts, - const char *page, size_t len) -{ - int ret; - - mutex_lock(opts-lock); - if (opts-refcnt) { - mutex_unlock(opts-lock); - return -EBUSY; - } - - ret = gether_set_dev_addr(opts-net, page); - mutex_unlock(opts-lock); - if (!ret) - ret = len; - return ret; -} - -static struct f_ncm_opts_attribute f_ncm_opts_dev_addr = - __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, ncm_opts_dev_addr_show, - ncm_opts_dev_addr_store); - -static ssize_t ncm_opts_host_addr_show(struct f_ncm_opts *opts, char *page) -{ - int result; - - mutex_lock(opts-lock); - result = gether_get_host_addr(opts-net, page, PAGE_SIZE); - mutex_unlock(opts-lock); - - return result; -} - -static ssize_t ncm_opts_host_addr_store(struct f_ncm_opts *opts, - const char *page, size_t len) -{ - int ret; +/* f_ncm_opts_dev_addr */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ncm); - mutex_lock(opts-lock); - if (opts-refcnt) { - mutex_unlock(opts-lock); - return -EBUSY; - } - - ret = gether_set_host_addr(opts-net, page); - mutex_unlock(opts-lock); - if (!ret) - ret = len; - return ret; -} - -static struct f_ncm_opts_attribute f_ncm_opts_host_addr = - __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, ncm_opts_host_addr_show, - ncm_opts_host_addr_store); - -static ssize_t ncm_opts_qmult_show(struct f_ncm_opts *opts, char *page) -{ - unsigned qmult; - - mutex_lock(opts-lock); - qmult = gether_get_qmult(opts-net); - mutex_unlock(opts-lock); - return sprintf(page, %d, qmult); -} - -static ssize_t ncm_opts_qmult_store(struct f_ncm_opts *opts, - const char *page, size_t len) -{ - u8 val; - int ret; +/* f_ncm_opts_host_addr */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ncm); - mutex_lock(opts-lock); - if (opts-refcnt) { - ret = -EBUSY; - goto out; - } - - ret = kstrtou8(page, 0, val); - if (ret) - goto out; - - gether_set_qmult(opts-net, val); - ret = len; -out: - mutex_unlock(opts-lock); - return ret; -} - -static struct f_ncm_opts_attribute f_ncm_opts_qmult = - __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, ncm_opts_qmult_show, - ncm_opts_qmult_store); - -static ssize_t ncm_opts_ifname_show(struct f_ncm_opts *opts, char *page) -{ - int ret; - - mutex_lock(opts-lock); - ret = gether_get_ifname(opts-net, page, PAGE_SIZE); - mutex_unlock(opts-lock); - - return ret; -} +/* f_ncm_opts_qmult */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm); -static struct f_ncm_opts_attribute f_ncm_opts_ifname = - __CONFIGFS_ATTR_RO(ifname, ncm_opts_ifname_show); +/* f_ncm_opts_ifname */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm); static struct configfs_attribute *ncm_attrs[] = { f_ncm_opts_dev_addr.attr, diff --git a/drivers/usb/gadget/u_ether_configfs.h
[PATCH v3 5/5] usb/gadget: f_ecm: add configfs support
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_ecm.c | 50 +++- drivers/usb/gadget/u_ecm.h |9 2 files changed, 58 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 1b2139d..5c578fb 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c @@ -19,6 +19,7 @@ #include linux/etherdevice.h #include u_ether.h +#include u_ether_configfs.h #include u_ecm.h @@ -706,8 +707,10 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) * with regard to ecm_opts-bound access */ if (!ecm_opts-bound) { + mutex_lock(ecm_opts-lock); gether_set_gadget(ecm_opts-net, cdev-gadget); status = gether_register_netdev(ecm_opts-net); + mutex_unlock(ecm_opts-lock); if (status) return status; ecm_opts-bound = true; @@ -898,6 +901,41 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], #else +static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item) +{ + return container_of(to_config_group(item), struct f_ecm_opts, + func_inst.group); +} + +/* f_ecm_item_ops */ +USB_ETHERNET_CONFIGFS_ITEM(ecm); + +/* f_ecm_opts_dev_addr */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(ecm); + +/* f_ecm_opts_host_addr */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(ecm); + +/* f_ecm_opts_qmult */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm); + +/* f_ecm_opts_ifname */ +USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm); + +static struct configfs_attribute *ecm_attrs[] = { + f_ecm_opts_dev_addr.attr, + f_ecm_opts_host_addr.attr, + f_ecm_opts_qmult.attr, + f_ecm_opts_ifname.attr, + NULL, +}; + +static struct config_item_type ecm_func_type = { + .ct_item_ops= ecm_item_ops, + .ct_attrs = ecm_attrs, + .ct_owner = THIS_MODULE, +}; + static void ecm_free_inst(struct usb_function_instance *f) { struct f_ecm_opts *opts; @@ -917,21 +955,28 @@ static struct usb_function_instance *ecm_alloc_inst(void) opts = kzalloc(sizeof(*opts), GFP_KERNEL); if (!opts) return ERR_PTR(-ENOMEM); - + mutex_init(opts-lock); opts-func_inst.free_func_inst = ecm_free_inst; opts-net = gether_setup_default(); if (IS_ERR(opts-net)) return ERR_PTR(PTR_ERR(opts-net)); + config_group_init_type_name(opts-func_inst.group, , ecm_func_type); + return opts-func_inst; } static void ecm_free(struct usb_function *f) { struct f_ecm *ecm; + struct f_ecm_opts *opts; ecm = func_to_ecm(f); + opts = container_of(f-fi, struct f_ecm_opts, func_inst); kfree(ecm); + mutex_lock(opts-lock); + opts-refcnt--; + mutex_unlock(opts-lock); } static void ecm_unbind(struct usb_configuration *c, struct usb_function *f) @@ -958,6 +1003,8 @@ struct usb_function *ecm_alloc(struct usb_function_instance *fi) return ERR_PTR(-ENOMEM); opts = container_of(fi, struct f_ecm_opts, func_inst); + mutex_lock(opts-lock); + opts-refcnt++; /* export host's Ethernet address in CDC format */ status = gether_get_host_addr_cdc(opts-net, ecm-ethaddr, @@ -969,6 +1016,7 @@ struct usb_function *ecm_alloc(struct usb_function_instance *fi) ecm_string_defs[1].s = ecm-ethaddr; ecm-port.ioport = netdev_priv(opts-net); + mutex_unlock(opts-lock); ecm-port.cdc_filter = DEFAULT_FILTER; ecm-port.func.name = cdc_ethernet; diff --git a/drivers/usb/gadget/u_ecm.h b/drivers/usb/gadget/u_ecm.h index 99b6b99..262cc03 100644 --- a/drivers/usb/gadget/u_ecm.h +++ b/drivers/usb/gadget/u_ecm.h @@ -22,6 +22,15 @@ struct f_ecm_opts { struct usb_function_instancefunc_inst; struct net_device *net; boolbound; + + /* +* Read/write access to configfs attributes is handled by configfs. +* +* This is to protect the data from concurrent access by read/write +* and create symlink/remove symlink. +*/ + struct mutexlock; + int refcnt; }; #endif /* U_ECM_H */ -- 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 v3 4/5] usb/gadget: f_ecm: use usb_gstrings_attach
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_ecm.c | 23 +-- 1 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index b3a1747..1b2139d 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c @@ -686,6 +686,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) { struct usb_composite_dev *cdev = c-cdev; struct f_ecm*ecm = func_to_ecm(f); + struct usb_string *us; int status; struct usb_ep *ep; @@ -712,16 +713,14 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) ecm_opts-bound = true; } #endif - if (ecm_string_defs[0].id == 0) { - status = usb_string_ids_tab(c-cdev, ecm_string_defs); - if (status) - return status; - - ecm_control_intf.iInterface = ecm_string_defs[0].id; - ecm_data_intf.iInterface = ecm_string_defs[2].id; - ecm_desc.iMACAddress = ecm_string_defs[1].id; - ecm_iad_descriptor.iFunction = ecm_string_defs[3].id; - } + us = usb_gstrings_attach(cdev, ecm_strings, +ARRAY_SIZE(ecm_string_defs)); + if (IS_ERR(us)) + return PTR_ERR(us); + ecm_control_intf.iInterface = us[0].id; + ecm_data_intf.iInterface = us[2].id; + ecm_desc.iMACAddress = us[1].id; + ecm_iad_descriptor.iFunction = us[3].id; /* allocate instance-specific interface IDs */ status = usb_interface_id(c, f); @@ -841,7 +840,6 @@ ecm_old_unbind(struct usb_configuration *c, struct usb_function *f) DBG(c-cdev, ecm unbind\n); - ecm_string_defs[0].id = 0; usb_free_all_descriptors(f); kfree(ecm-notify_req-buf); @@ -884,7 +882,6 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], ecm-port.cdc_filter = DEFAULT_FILTER; ecm-port.func.name = cdc_ethernet; - ecm-port.func.strings = ecm_strings; /* descriptors are per-instance copies */ ecm-port.func.bind = ecm_bind; ecm-port.func.unbind = ecm_old_unbind; @@ -943,7 +940,6 @@ static void ecm_unbind(struct usb_configuration *c, struct usb_function *f) DBG(c-cdev, ecm unbind\n); - ecm_string_defs[0].id = 0; usb_free_all_descriptors(f); kfree(ecm-notify_req-buf); @@ -976,7 +972,6 @@ struct usb_function *ecm_alloc(struct usb_function_instance *fi) ecm-port.cdc_filter = DEFAULT_FILTER; ecm-port.func.name = cdc_ethernet; - ecm-port.func.strings = ecm_strings; /* descriptors are per-instance copies */ ecm-port.func.bind = ecm_bind; ecm-port.func.unbind = ecm_unbind; -- 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 v3 3/5] usb/gadget: cdc2: convert to new interface of f_ecm
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/cdc2.c | 84 ++- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index bcadb5c..d064e0f 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -890,6 +890,7 @@ config USB_CDC_COMPOSITE select USB_U_SERIAL select USB_U_ETHER select USB_F_ACM + select USB_F_ECM help This driver provides two functions in one configuration: a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link. diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index a0cba7e..b80b963 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c @@ -15,6 +15,7 @@ #include u_ether.h #include u_serial.h +#include u_ecm.h #define DRIVER_DESCCDC Composite Gadget @@ -32,21 +33,10 @@ #define CDC_VENDOR_NUM 0x0525 /* NetChip */ #define CDC_PRODUCT_NUM0xa4aa /* CDC Composite: ECM + ACM */ -/*-*/ USB_GADGET_COMPOSITE_OPTIONS(); USB_ETHERNET_MODULE_PARAMETERS(); -/* - * Kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a gcc --combine ... part1.c part2.c part3.c ... build would. - */ -#define USBF_ECM_INCLUDED -#include f_ecm.c - /*-*/ static struct usb_device_descriptor device_desc = { @@ -104,44 +94,54 @@ static struct usb_gadget_strings *dev_strings[] = { NULL, }; -static u8 host_mac[ETH_ALEN]; -static struct eth_dev *the_dev; /*-*/ static struct usb_function *f_acm; static struct usb_function_instance *fi_serial; +static struct usb_function_instance *fi_ecm; +static struct usb_function *f_ecm; + /* * We _always_ have both CDC ECM and CDC ACM functions. */ static int __init cdc_do_config(struct usb_configuration *c) { - int status; + int status; if (gadget_is_otg(c-cdev-gadget)) { c-descriptors = otg_desc; c-bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - status = ecm_bind_config(c, host_mac, the_dev); - if (status 0) - return status; + f_ecm = usb_get_function(fi_ecm); + if (IS_ERR(f_ecm)) { + status = PTR_ERR(f_ecm); + goto err_get_ecm; + } - fi_serial = usb_get_function_instance(acm); - if (IS_ERR(fi_serial)) - return PTR_ERR(fi_serial); + status = usb_add_function(c, f_ecm); + if (status 0) + goto err_add_ecm; f_acm = usb_get_function(fi_serial); - if (IS_ERR(f_acm)) - goto err_func_acm; + if (IS_ERR(f_acm)) { + status = PTR_ERR(f_acm); + goto err_get_acm; + } status = usb_add_function(c, f_acm); if (status) - goto err_conf; + goto err_add_acm; + return 0; -err_conf: + +err_add_acm: usb_put_function(f_acm); -err_func_acm: - usb_put_function_instance(fi_serial); +err_get_acm: + usb_remove_function(c, f_ecm); +err_add_ecm: + usb_put_function(f_ecm); +err_get_ecm: return status; } @@ -157,6 +157,7 @@ static struct usb_configuration cdc_config_driver = { static int __init cdc_bind(struct usb_composite_dev *cdev) { struct usb_gadget *gadget = cdev-gadget; + struct f_ecm_opts *ecm_opts; int status; if (!can_support_ecm(cdev-gadget)) { @@ -165,11 +166,23 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) return -EINVAL; } - /* set up network link layer */ - the_dev = gether_setup(cdev-gadget, dev_addr, host_addr, host_mac, - qmult); - if (IS_ERR(the_dev)) - return PTR_ERR(the_dev); + fi_ecm = usb_get_function_instance(ecm); + if (IS_ERR(fi_ecm)) + return PTR_ERR(fi_ecm); + + ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst); + + gether_set_qmult(ecm_opts-net, qmult); + if (!gether_set_host_addr(ecm_opts-net, host_addr)) + pr_info(using host ethernet address: %s, host_addr); + if (!gether_set_dev_addr(ecm_opts-net, dev_addr)) + pr_info(using self ethernet address: %s, dev_addr); + + fi_serial = usb_get_function_instance(acm); + if
[PATCH v2 0/9] Equivalent of g_nokia.ko with configfs
Here I present the conversion of everything that is required to provide the equivalent of g_nokia.ko with configfs. A branch will be available here (from 23rd May 2013, afternoon UTC): git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs v1..v2: - don't unregister a network interface if it has not been registered before - add phonet function description in Documentation/ABI This series requires the following series to be applied: http://comments.gmane.org/gmane.linux.usb.general/86773 http://comments.gmane.org/gmane.linux.usb.general/86783 http://www.spinics.net/lists/linux-usb/msg85307.html BACKWARD COMPATIBILITY == Please note that the old g_nokia.ko is still available and works. USING THE NEW GADGET == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). Here is the description specific to using g_nokia.ko equivalent. The old g_nokia.ko provides 4 functions: - Phonet - Obex (2 instances) - ACM - ECM in 2 configurations, which contain this same set of functions, but differ in MaxPower. The procedure of setting up such a gadget with configfs is given below with an example: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ echo 0x01c8 idProduct $ echo 0x0421 idVendor $ mkdir strings/0x409 $ echo Nokia strings/0x409/manufacturer $ echo N900 (PC-Suite Mode) strings/0x409/product $ mkdir configs/c.1 $ echo 500 configs/c.1/MaxPower $ mkdir configs/c.1/strings/0x409 $ echo Conf 1 configs/c.1/strings/0x409/configuration $ mkdir configs/c.2 $ echo 100 configs/c.2/MaxPower $ mkdir configs/c.2/strings/0x409 $ echo Conf 2 configs/c.2/strings/0x409/configuration $ mkdir functions/phonet.pn0 $ mkdir functions/obex.obex1 $ mkdir functions/obex.obex2 $ mkdir functions/acm.tty0 $ mkdir functions/ecm.usb0 $ ln -s functions/phonet.pn0 configs/c.1 $ ln -s functions/obex.obex1 configs/c.1 $ ln -s functions/obex.obex2 configs/c.1 $ ln -s functions/acm.tty0 configs/c.1 $ ln -s functions/ecm.usb0 configs/c.1 $ ln -s functions/phonet.pn0 configs/c.2 $ ln -s functions/obex.obex1 configs/c.2 $ ln -s functions/obex.obex2 configs/c.2 $ ln -s functions/acm.tty0 configs/c.2 $ ln -s functions/ecm.usb0 configs/c.2 $ echo s3c-hsotg UDC The obex and acm functions provide only one, readonly, attribute port_num, which contains their port number. The phonet function provides only one, readonly, attribute ifname, which contains the network interface name associated with the function. The ecm function provides qmult, dev_addr, host_addr read-write attributes, and ifname readonly attribute. and after creating the functions/ecm.instance name it contains default values: qmult is 5, dev_addr and host_addr are randomly selected. Except for ifname they can be written to until the function is linked to a configuration. The ifname is read-only and contains the name of the interface which was assigned by the net core, e. g. usb0. After unbinding the gadget with echo UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS phonet) It is not possible to test the SOCK_STREAM protocol without a specific piece of hardware, so only SOCK_DGRAM has been tested. For the latter to work, I had to apply the patch mentioned here: http://www.spinics.net/lists/linux-usb/msg85689.html For this to work, these tools are required git://git.gitorious.org/meego-cellular/phonet-utils.git On the host: $ ./phonet -a 0x10 -i usbpn0 $ ./pnroute add 0x6c usbpn0 $./pnroute add 0x10 usbpn0 $ ifconfig usbpn0 up On the device: $ ./phonet -a 0x6c -i upnlink0 $ ./pnroute add 0x10 upnlink0 $ ifconfig upnlink0 up Then a test program can be used: http://www.spinics.net/lists/linux-usb/msg85690.html On the device: $ ./pnxmit -a 0x6c -r On the host: $ ./pnxmit -a 0x10 -s 0x6c As a result some data should be sent from host to device. Then the other way round: On the host: $ ./pnxmit -a 0x10 -r On the device: $ ./pnxmit -a 0x6c -s 0x10 obex) On device: seriald -f /dev/ttyGSY -s 1024 On host: serialc -v vendorID -p productID -iinterface# -a1 -s1024 \ -tout endpoint addr -rin endpoint addr where seriald and serialc are Felipe's utilities found here: https://git.gitorious.org/usb/usb-tools.git master acm) On host: cat /dev/ttyACMX On target: cat /dev/ttyGSY then the other way round On target: cat /dev/ttyGSY On host: cat /dev/ttyACMX ecm) On the device: ping host's IP On the host: ping device's IP
[PATCH v2 3/9] usb/gadget: f_obex: remove compatibility layer
There are no old function interface users left, so the old interface can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_obex.c | 52 --- 1 files changed, 0 insertions(+), 52 deletions(-) diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c index 1b61fe7..ab35eac 100644 --- a/drivers/usb/gadget/f_obex.c +++ b/drivers/usb/gadget/f_obex.c @@ -402,55 +402,6 @@ fail: return status; } -#ifdef USBF_OBEX_INCLUDED - -static void -obex_old_unbind(struct usb_configuration *c, struct usb_function *f) -{ - usb_free_all_descriptors(f); - kfree(func_to_obex(f)); -} - -/** - * obex_bind_config - add a CDC OBEX function to a configuration - * @c: the configuration to support the CDC OBEX instance - * @port_num: /dev/ttyGS* port this interface will use - * Context: single threaded during gadget setup - * - * Returns zero on success, else negative errno. - */ -int __init obex_bind_config(struct usb_configuration *c, u8 port_num) -{ - struct f_obex *obex; - int status; - - /* allocate and initialize one new instance */ - obex = kzalloc(sizeof *obex, GFP_KERNEL); - if (!obex) - return -ENOMEM; - - obex-port_num = port_num; - - obex-port.connect = obex_connect; - obex-port.disconnect = obex_disconnect; - - obex-port.func.name = obex; - /* descriptors are per-instance copies */ - obex-port.func.bind = obex_bind; - obex-port.func.unbind = obex_old_unbind; - obex-port.func.set_alt = obex_set_alt; - obex-port.func.get_alt = obex_get_alt; - obex-port.func.disable = obex_disable; - - status = usb_add_function(c, obex-port.func); - if (status) - kfree(obex); - - return status; -} - -#else - static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item) { return container_of(to_config_group(item), struct f_serial_opts, @@ -577,8 +528,5 @@ struct usb_function *obex_alloc(struct usb_function_instance *fi) } DECLARE_USB_FUNCTION_INIT(obex, obex_alloc_inst, obex_alloc); - -#endif - MODULE_AUTHOR(Felipe Balbi); MODULE_LICENSE(GPL); -- 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 v2 2/9] usb/gadget: nokia: convert to new interface of f_obex
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/nokia.c | 122 ++-- 2 files changed, 85 insertions(+), 38 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 8a0f14e..66e7577 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -974,6 +974,7 @@ config USB_G_NOKIA select USB_U_SERIAL select USB_U_ETHER select USB_F_ACM + select USB_F_OBEX help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver. diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index 8e42c88..a69e8bf 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c @@ -16,6 +16,7 @@ */ #include linux/kernel.h +#include linux/module.h #include linux/device.h #include u_serial.h @@ -39,8 +40,6 @@ */ #define USBF_ECM_INCLUDED #include f_ecm.c -#define USBF_OBEX_INCLUDED -#include f_obex.c #include f_phonet.c #include u_ether.h @@ -102,16 +101,12 @@ MODULE_LICENSE(GPL); static struct usb_function *f_acm_cfg1; static struct usb_function *f_acm_cfg2; static u8 host_mac[ETH_ALEN]; +static struct usb_function *f_obex1_cfg1; +static struct usb_function *f_obex2_cfg1; +static struct usb_function *f_obex1_cfg2; +static struct usb_function *f_obex2_cfg2; static struct eth_dev *the_dev; -enum { - TTY_PORT_OBEX0, - TTY_PORT_OBEX1, - TTY_PORTS_MAX, -}; - -static unsigned char tty_lines[TTY_PORTS_MAX]; - static struct usb_configuration nokia_config_500ma_driver = { .label = Bus Powered, .bConfigurationValue = 1, @@ -129,27 +124,51 @@ static struct usb_configuration nokia_config_100ma_driver = { }; static struct usb_function_instance *fi_acm; +static struct usb_function_instance *fi_obex1; +static struct usb_function_instance *fi_obex2; static int __init nokia_bind_config(struct usb_configuration *c) { struct usb_function *f_acm; + struct usb_function *f_obex1 = NULL; + struct usb_function *f_obex2 = NULL; int status = 0; + int obex1_stat = 0; + int obex2_stat = 0; status = phonet_bind_config(c); if (status) - printk(KERN_DEBUG could not bind phonet config\n); + pr_debug(could not bind phonet config\n); - status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX0]); - if (status) - printk(KERN_DEBUG could not bind obex config %d\n, 0); + if (!IS_ERR(fi_obex1)) { + f_obex1 = usb_get_function(fi_obex1); + if (IS_ERR(f_obex1)) + pr_debug(could not get obex function 0\n); + } - status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX1]); - if (status) - printk(KERN_DEBUG could not bind obex config %d\n, 0); + if (!IS_ERR(fi_obex2)) { + f_obex2 = usb_get_function(fi_obex2); + if (IS_ERR(f_obex2)) + pr_debug(could not get obex function 1\n); + } f_acm = usb_get_function(fi_acm); - if (IS_ERR(f_acm)) - return PTR_ERR(f_acm); + if (IS_ERR(f_acm)) { + status = PTR_ERR(f_acm); + goto err_get_acm; + } + + if (!IS_ERR_OR_NULL(f_obex1)) { + obex1_stat = usb_add_function(c, f_obex1); + if (obex1_stat) + pr_debug(could not add obex function 0\n); + } + + if (!IS_ERR_OR_NULL(f_obex2)) { + obex2_stat = usb_add_function(c, f_obex2); + if (obex2_stat) + pr_debug(could not add obex function 1\n); + } status = usb_add_function(c, f_acm); if (status) @@ -160,16 +179,30 @@ static int __init nokia_bind_config(struct usb_configuration *c) pr_debug(could not bind ecm config %d\n, status); goto err_ecm; } - if (c == nokia_config_500ma_driver) + if (c == nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; - else + f_obex1_cfg1 = f_obex1; + f_obex2_cfg1 = f_obex2; + } else { f_acm_cfg2 = f_acm; + f_obex1_cfg2 = f_obex1; + f_obex2_cfg2 = f_obex2; + } return status; err_ecm: usb_remove_function(c, f_acm); err_conf: + if (!obex2_stat) + usb_remove_function(c, f_obex2); + if (!obex1_stat) + usb_remove_function(c, f_obex1); usb_put_function(f_acm); +err_get_acm: + if (!IS_ERR_OR_NULL(f_obex2)) + usb_put_function(f_obex2); + if (!IS_ERR_OR_NULL(f_obex1)) + usb_put_function(f_obex1); return status; } @@ -177,18 +210,11 @@ static
[PATCH v2 5/9] usb/gadget: f_phonet: convert to new function interface with backward compatibility
Converting f_phonet to the new function interface requires converting the f_phonet's function code and its users. This patch converts the f_phonet.c to the new function interface. The file is now compiled into a separate usb_f_phonet.ko module. The old function interface is provided by means of preprocessor conditional directives. After all users are converted, the old interface can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig|3 + drivers/usb/gadget/Makefile |2 + drivers/usb/gadget/f_phonet.c | 151 +++-- drivers/usb/gadget/nokia.c|1 + drivers/usb/gadget/u_phonet.h |9 +++ 5 files changed, 161 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 66e7577..0493542 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -569,6 +569,9 @@ config USB_F_NCM config USB_F_ECM tristate +config USB_F_PHONET + tristate + choice tristate USB Gadget Drivers default USB_ETH diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index ecfa7c3..f065e67 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -53,6 +53,8 @@ usb_f_ncm-y := f_ncm.o obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o usb_f_ecm-y:= f_ecm.o obj-$(CONFIG_USB_F_ECM)+= usb_f_ecm.o +usb_f_phonet-y := f_phonet.o +obj-$(CONFIG_USB_F_PHONET) += usb_f_phonet.o # # USB gadget drivers diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c index e79ee34..547c4ad 100644 --- a/drivers/usb/gadget/f_phonet.c +++ b/drivers/usb/gadget/f_phonet.c @@ -13,6 +13,7 @@ #include linux/mm.h #include linux/slab.h #include linux/kernel.h +#include linux/module.h #include linux/device.h #include linux/netdevice.h @@ -473,8 +474,7 @@ static void pn_disconnect(struct usb_function *f) /*-*/ -static __init -int pn_bind(struct usb_configuration *c, struct usb_function *f) +static int pn_bind(struct usb_configuration *c, struct usb_function *f) { struct usb_composite_dev *cdev = c-cdev; struct usb_gadget *gadget = cdev-gadget; @@ -482,6 +482,27 @@ 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); + + /* +* in drivers/usb/gadget/configfs.c:configfs_composite_bind() +* configurations are bound in sequence with list_for_each_entry, +* in each configuration its functions are bound in sequence +* with list_for_each_entry, so we assume no race condition +* with regard to phonet_opts-bound access +*/ + if (!phonet_opts-bound) { + gphonet_set_gadget(phonet_opts-net, gadget); + status = gphonet_register_netdev(phonet_opts-net); + if (status) + return status; + phonet_opts-bound = true; + } +#endif + /* Reserve interface IDs */ status = usb_interface_id(c, f); if (status 0) @@ -555,8 +576,10 @@ err: return status; } +#ifdef USBF_PHONET_INCLUDED + static void -pn_unbind(struct usb_configuration *c, struct usb_function *f) +pn_old_unbind(struct usb_configuration *c, struct usb_function *f) { struct f_phonet *fp = func_to_pn(f); int i; @@ -588,7 +611,7 @@ int __init phonet_bind_config(struct usb_configuration *c, fp-dev = dev; fp-function.name = phonet; fp-function.bind = pn_bind; - fp-function.unbind = pn_unbind; + fp-function.unbind = pn_old_unbind; fp-function.set_alt = pn_set_alt; fp-function.get_alt = pn_get_alt; fp-function.disable = pn_disconnect; @@ -600,7 +623,125 @@ int __init phonet_bind_config(struct usb_configuration *c, return err; } -struct net_device __init *gphonet_setup(struct usb_gadget *gadget) +#else + +static void phonet_free_inst(struct usb_function_instance *f) +{ + struct f_phonet_opts *opts; + + opts = container_of(f, struct f_phonet_opts, func_inst); + if (opts-bound) + gphonet_cleanup(opts-net); + else + free_netdev(opts-net); + kfree(opts); +} + +static struct usb_function_instance *phonet_alloc_inst(void) +{ + struct f_phonet_opts *opts; + + opts = kzalloc(sizeof(*opts), GFP_KERNEL); + if (!opts) + return ERR_PTR(-ENOMEM); + + opts-func_inst.free_func_inst = phonet_free_inst; + opts-net = gphonet_setup_default(); + if (IS_ERR(opts-net)) + return
Re: [PATCH 0/7 v4] ARM: at91: dt: add USBA support
Hi Felipe, if it's ok with you I send the patch series via at91 with the DT Best Regards, J. On 18:21 Mon 20 May , Jean-Christophe PLAGNIOL-VILLARD wrote: HI, v4: fix multi instance support v3: rebase againt 3.10-rc1 + dt macro cleanup This patch serie finish to add the usb device support to dt for at91 with the usba support present on the last at91 generation since sam9g45 The following changes since commit b3f442b0eedbc20b5ce3f4a96530588d14901199: ARM: at91: udpate defconfigs (2013-05-17 15:05:08 +0200) are available in the git repository at: git://github.com/at91linux/linux-at91.git j/for-3.11-usba for you to fetch changes up to 910026a08e2c2205953f2507cc11f4822998989b: ARM: at91: sam9m10g45ek add udc DT support (2013-05-20 23:52:17 +0800) Jean-Christophe PLAGNIOL-VILLARD (7): USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc USB: gadget: atmel_usba: allow multi instance USB: gadget: atmel_usba: add DT support ARM: at91: sam9x5 add udc DT support ARM: at91: sam9x5ek add udc DT support ARM: at91: sam9g45 add udc DT support ARM: at91: sam9m10g45ek add udc DT support Documentation/devicetree/bindings/usb/atmel-usb.txt | 82 ++ arch/arm/boot/dts/at91sam9g45.dtsi | 62 +++ arch/arm/boot/dts/at91sam9m10g45ek.dts |5 ++ arch/arm/boot/dts/at91sam9x5.dtsi | 62 +++ arch/arm/boot/dts/at91sam9x5ek.dtsi |5 ++ arch/arm/mach-at91/at91sam9g45.c|2 + arch/arm/mach-at91/at91sam9x5.c |2 + drivers/usb/gadget/Kconfig |2 +- drivers/usb/gadget/atmel_usba_udc.c | 264 ++- drivers/usb/gadget/atmel_usba_udc.h |2 + 10 files changed, 407 insertions(+), 81 deletions(-) Best Regards, J. ___ devicetree-discuss mailing list devicetree-disc...@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss -- 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: host: use platform_{get,set}_drvdata()
Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with pdev-dev, so we can directly pass a struct platform_device. Also, unnecessary dev_set_drvdata() is removed, because the driver core clears the driver data to NULL after device_release or on probe failure. Signed-off-by: Jingoo Han jg1@samsung.com --- drivers/usb/host/ehci-grlib.c |6 ++ drivers/usb/host/ehci-ppc-of.c|6 ++ drivers/usb/host/ehci-xilinx-of.c |5 ++--- drivers/usb/host/isp1760-if.c | 10 -- drivers/usb/host/ohci-ppc-of.c|5 ++--- drivers/usb/host/uhci-grlib.c |6 ++ drivers/usb/host/uhci-platform.c |2 +- drivers/usb/host/xhci-plat.c |2 +- 8 files changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c index 5d75de9..a77bd8d 100644 --- a/drivers/usb/host/ehci-grlib.c +++ b/drivers/usb/host/ehci-grlib.c @@ -153,9 +153,7 @@ err_irq: static int ehci_hcd_grlib_remove(struct platform_device *op) { - struct usb_hcd *hcd = dev_get_drvdata(op-dev); - - dev_set_drvdata(op-dev, NULL); + struct usb_hcd *hcd = platform_get_drvdata(op); dev_dbg(op-dev, stopping GRLIB GRUSBHC EHCI USB Controller\n); @@ -171,7 +169,7 @@ static int ehci_hcd_grlib_remove(struct platform_device *op) static void ehci_hcd_grlib_shutdown(struct platform_device *op) { - struct usb_hcd *hcd = dev_get_drvdata(op-dev); + struct usb_hcd *hcd = platform_get_drvdata(op); if (hcd-driver-shutdown) hcd-driver-shutdown(hcd); diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c index 56dc732..86da09c 100644 --- a/drivers/usb/host/ehci-ppc-of.c +++ b/drivers/usb/host/ehci-ppc-of.c @@ -180,14 +180,12 @@ err_irq: static int ehci_hcd_ppc_of_remove(struct platform_device *op) { - struct usb_hcd *hcd = dev_get_drvdata(op-dev); + struct usb_hcd *hcd = platform_get_drvdata(op); struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct device_node *np; struct resource res; - dev_set_drvdata(op-dev, NULL); - dev_dbg(op-dev, stopping PPC-OF USB Controller\n); usb_remove_hcd(hcd); @@ -219,7 +217,7 @@ static int ehci_hcd_ppc_of_remove(struct platform_device *op) static void ehci_hcd_ppc_of_shutdown(struct platform_device *op) { - struct usb_hcd *hcd = dev_get_drvdata(op-dev); + struct usb_hcd *hcd = platform_get_drvdata(op); if (hcd-driver-shutdown) hcd-driver-shutdown(hcd); diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c index d845e3b..35c7f90 100644 --- a/drivers/usb/host/ehci-xilinx-of.c +++ b/drivers/usb/host/ehci-xilinx-of.c @@ -209,8 +209,7 @@ err_irq: */ static int ehci_hcd_xilinx_of_remove(struct platform_device *op) { - struct usb_hcd *hcd = dev_get_drvdata(op-dev); - dev_set_drvdata(op-dev, NULL); + struct usb_hcd *hcd = platform_get_drvdata(op); dev_dbg(op-dev, stopping XILINX-OF USB Controller\n); @@ -229,7 +228,7 @@ static int ehci_hcd_xilinx_of_remove(struct platform_device *op) */ static void ehci_hcd_xilinx_of_shutdown(struct platform_device *op) { - struct usb_hcd *hcd = dev_get_drvdata(op-dev); + struct usb_hcd *hcd = platform_get_drvdata(op); if (hcd-driver-shutdown) hcd-driver-shutdown(hcd); diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index a13709e..3df49b1 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c @@ -118,7 +118,7 @@ static int of_isp1760_probe(struct platform_device *dev) goto free_gpio; } - dev_set_drvdata(dev-dev, drvdata); + platform_set_drvdata(dev, drvdata); return ret; free_gpio: @@ -133,9 +133,7 @@ free_data: static int of_isp1760_remove(struct platform_device *dev) { - struct isp1760 *drvdata = dev_get_drvdata(dev-dev); - - dev_set_drvdata(dev-dev, NULL); + struct isp1760 *drvdata = platform_get_drvdata(dev); usb_remove_hcd(drvdata-hcd); iounmap(drvdata-hcd-regs); @@ -398,7 +396,7 @@ static int isp1760_plat_probe(struct platform_device *pdev) irqflags, -ENOENT, pdev-dev, dev_name(pdev-dev), devflags); - dev_set_drvdata(pdev-dev, hcd); + platform_set_drvdata(pdev, hcd); if (IS_ERR(hcd)) { pr_warning(isp1760: Failed to register the HCD device\n); @@ -419,7 +417,7 @@ static int isp1760_plat_remove(struct platform_device *pdev) { struct resource *mem_res; resource_size_t mem_size; - struct usb_hcd *hcd = dev_get_drvdata(pdev-dev); + struct usb_hcd *hcd = platform_get_drvdata(pdev); usb_remove_hcd(hcd); diff --git a/drivers/usb/host/ohci-ppc-of.c
[PATCH] USB: gadget: use platform_{get,set}_drvdata()
Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with pdev-dev, so we can directly pass a struct platform_device. Signed-off-by: Jingoo Han jg1@samsung.com --- drivers/usb/gadget/fsl_qe_udc.c |4 ++-- drivers/usb/gadget/fusb300_udc.c |4 ++-- drivers/usb/gadget/m66592-udc.c |4 ++-- drivers/usb/gadget/mv_u3d_core.c |2 +- drivers/usb/gadget/r8a66597-udc.c |4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index 9a7ee33..f3bb363 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -2589,7 +2589,7 @@ static int qe_udc_probe(struct platform_device *ofdev) if (ret) goto err6; - dev_set_drvdata(ofdev-dev, udc); + platform_set_drvdata(ofdev, udc); dev_info(udc-dev, %s USB controller initialized as device\n, (udc-soc_type == PORT_QE) ? QE : CPM); @@ -2640,7 +2640,7 @@ static int qe_udc_resume(struct platform_device *dev) static int qe_udc_remove(struct platform_device *ofdev) { - struct qe_udc *udc = dev_get_drvdata(ofdev-dev); + struct qe_udc *udc = platform_get_drvdata(ofdev); struct qe_ep *ep; unsigned int size; DECLARE_COMPLETION(done); diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index b8632d4..c83f3e1 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c @@ -1347,7 +1347,7 @@ static const struct usb_gadget_ops fusb300_gadget_ops = { static int __exit fusb300_remove(struct platform_device *pdev) { - struct fusb300 *fusb300 = dev_get_drvdata(pdev-dev); + struct fusb300 *fusb300 = platform_get_drvdata(pdev); usb_del_gadget_udc(fusb300-gadget); iounmap(fusb300-reg); @@ -1416,7 +1416,7 @@ static int __init fusb300_probe(struct platform_device *pdev) spin_lock_init(fusb300-lock); - dev_set_drvdata(pdev-dev, fusb300); + platform_set_drvdata(pdev, fusb300); fusb300-gadget.ops = fusb300_gadget_ops; diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index 51cfe72..46ba983 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c @@ -1533,7 +1533,7 @@ static const struct usb_gadget_ops m66592_gadget_ops = { static int __exit m66592_remove(struct platform_device *pdev) { - struct m66592 *m66592 = dev_get_drvdata(pdev-dev); + struct m66592 *m66592 = platform_get_drvdata(pdev); usb_del_gadget_udc(m66592-gadget); @@ -1602,7 +1602,7 @@ static int __init m66592_probe(struct platform_device *pdev) m66592-irq_trigger = ires-flags IRQF_TRIGGER_MASK; spin_lock_init(m66592-lock); - dev_set_drvdata(pdev-dev, m66592); + platform_set_drvdata(pdev, m66592); m66592-gadget.ops = m66592_gadget_ops; m66592-gadget.max_speed = USB_SPEED_HIGH; diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c index 751b17a..07fdb3e 100644 --- a/drivers/usb/gadget/mv_u3d_core.c +++ b/drivers/usb/gadget/mv_u3d_core.c @@ -2050,7 +2050,7 @@ static SIMPLE_DEV_PM_OPS(mv_u3d_pm_ops, mv_u3d_suspend, mv_u3d_resume); static void mv_u3d_shutdown(struct platform_device *dev) { - struct mv_u3d *u3d = dev_get_drvdata(dev-dev); + struct mv_u3d *u3d = platform_get_drvdata(dev); u32 tmp; tmp = ioread32(u3d-op_regs-usbcmd); diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c index 7ff7d9c..51ea169 100644 --- a/drivers/usb/gadget/r8a66597-udc.c +++ b/drivers/usb/gadget/r8a66597-udc.c @@ -1822,7 +1822,7 @@ static const struct usb_gadget_ops r8a66597_gadget_ops = { static int __exit r8a66597_remove(struct platform_device *pdev) { - struct r8a66597 *r8a66597 = dev_get_drvdata(pdev-dev); + struct r8a66597 *r8a66597 = platform_get_drvdata(pdev); usb_del_gadget_udc(r8a66597-gadget); del_timer_sync(r8a66597-timer); @@ -1909,7 +1909,7 @@ static int __init r8a66597_probe(struct platform_device *pdev) } spin_lock_init(r8a66597-lock); - dev_set_drvdata(pdev-dev, r8a66597); + platform_set_drvdata(pdev, r8a66597); r8a66597-pdata = pdev-dev.platform_data; r8a66597-irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; -- 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 0/1] USB: ehci-omap: Fixes for 3.10
Hi Greg, There is one patch for 3.10 that fixes an issue with dma_mask pointer when ehci-omap is used as a module and kernel is booted using device tree. More details in the patch. Roger Quadros (1): USB: ehci-omap: Reset dma_mask pointer on probe drivers/usb/host/ehci-omap.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) cheers, -roger -- 1.7.4.1 -- 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/7] USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc
On 23/05/2013 04:23, Bo Shen : Hi J, On 5/21/2013 00:25, Jean-Christophe PLAGNIOL-VILLARD wrote: so we can have multiple usb gadget instance Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: linux-usb@vger.kernel.org For this series, test OK on at91sam9m10g45ek and at91sam9x5ek board Tested-by: Bo Shen voice.s...@atmel.com After reading this v4 series, it seems good. So, on the whole series: Acked-by: Nicolas Ferre nicolas.fe...@atmel.com PS: When do testing, we need build in or choose as module: Device Drivers --- Generic Target Core Mod (TCM) and ConfigFS infrastructure Thanks a lot to you, Bo and Jean-Christophe. Bye, -- Nicolas Ferre -- 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
[RFC V6 PATCH 0/3] USB: OHCI: Start splitting up the driver
This series of patches begins the process of splitting ohci-hcd up into a core library module and independent pci driver modules. Patch 1/3 prepares the way by exporting a few functions from ohci-hcd and adding a new mechanism for platform-specific drivers to initialize their hc_driver structures. This deserves to be done in the core because almost all of the entries in these structures are pure boilerplate -- practically none of the drivers need to override more than three of the standard core values. Patch 2/3 is part of separating the ohci pci host controller driver from ohci-hcd host code. Moved sb800_prefetch() function from ohci-pci.c to pci-quirks.c file and EXPORTed, this is part of the effort to move the ohci pci related code to generic pci code. Patch 3/3 separate out ohci-pci into independent driver modules. Manjunath Goudar (3): USB: OHCI: prepare to make ohci-hcd a library module USB: OHCI: Generic changes to make ohci-pci a separate driver USB: OHCI: make ohci-pci a separate driver drivers/usb/host/Kconfig |4 +- drivers/usb/host/Makefile |3 + drivers/usb/host/ohci-hcd.c | 129 +- drivers/usb/host/ohci-hub.c |1 - drivers/usb/host/ohci-pci.c | 152 - drivers/usb/host/ohci-q.c |8 ++- drivers/usb/host/ohci.h | 21 ++ drivers/usb/host/pci-quirks.c | 14 drivers/usb/host/pci-quirks.h |3 + 9 files changed, 189 insertions(+), 146 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
[RFC V6 PATCH 1/3] USB: OHCI: prepare to make ohci-hcd a library module
This patch prepares ohci-hcd for being split up into a core library and separate platform driver modules. A generic ohci_hc_driver structure is created, containing all the standard values, and a new mechanism is added whereby a driver module can specify a set of overrides to those values. In addition the ohci_restart(),ohci_suspend() and ohci_resume() routines need to be EXPORTed for use by the drivers. Added ohci_setip(() and ohci_start() routine for to start the generic controller rather than each having its own idiosyncratic approach. This allow to clean duplicated code in most of SOC driver In V2: -ohci_hcd_init() ohci_run() and ohci_stop() are not made non-static. -Adds the ohci_setup() and ohci_start() routine. In V3: -purpose of ohci_setup() and ohci_start() function description written in the patch description. -ohci_init() are not made non-static but now called beginning of the ohci_restart(). -ohci_run() signature change reverted back. -unrelated changes removed. -duplicate comment line removed. -inline ohci_suspend() and ohci_resume() is not needed so removed from ohci.h file. In V4: -ohci-init() EXPORTed because it is called by all bus glue modules. -ohci-setup() removed from 1/2 added into 2/2 patch. In V5: -Again ohci_setup() is added and EXPORTed because to replace the ohci_init() from all bus glues. -ohci_init() is not made non-static function. In V6: -ohci_init() call is removed from ohci_quirk_nec_worker(), because it is already called in ohci_restart(). 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 --- drivers/usb/host/ohci-hcd.c | 103 +++ drivers/usb/host/ohci-hub.c |1 - drivers/usb/host/ohci-pci.c |7 --- drivers/usb/host/ohci.h | 17 +++ 4 files changed, 111 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 9e6de95..13ebbb7 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -79,13 +79,7 @@ static const charhcd_name [] = ohci_hcd; #include pci-quirks.h static void ohci_dump (struct ohci_hcd *ohci, int verbose); -static int ohci_init (struct ohci_hcd *ohci); static void ohci_stop (struct usb_hcd *hcd); - -#if defined(CONFIG_PM) || defined(CONFIG_PCI) -static int ohci_restart (struct ohci_hcd *ohci); -#endif - #ifdef CONFIG_PCI static void sb800_prefetch(struct ohci_hcd *ohci, int on); #else @@ -768,6 +762,30 @@ retry: return 0; } +/* ohci_setup routine for generic controller initialization */ + +int ohci_setup(struct usb_hcd *hcd) +{ + struct ohci_hcd *ohci = hcd_to_ohci(hcd); + + return ohci_init(ohci); +} +EXPORT_SYMBOL_GPL(ohci_setup); + +/* ohci_start routine for generic controller start of all OHCI bus glue */ +static int ohci_start(struct usb_hcd *hcd) +{ + struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; + + ret = ohci_run(ohci); + if (ret 0) { + ohci_err(ohci, can't start\n); + ohci_stop(hcd); + } + return ret; +} + /*-*/ /* an interrupt happens */ @@ -949,12 +967,13 @@ static void ohci_stop (struct usb_hcd *hcd) #if defined(CONFIG_PM) || defined(CONFIG_PCI) /* must not be called from interrupt context */ -static int ohci_restart (struct ohci_hcd *ohci) +int ohci_restart(struct ohci_hcd *ohci) { int temp; int i; struct urb_priv *priv; + ohci_init(ohci); spin_lock_irq(ohci-lock); ohci-rh_state = OHCI_RH_HALTED; @@ -1008,12 +1027,13 @@ static int ohci_restart (struct ohci_hcd *ohci) ohci_dbg(ohci, restart complete\n); return 0; } +EXPORT_SYMBOL_GPL(ohci_restart); #endif #ifdef CONFIG_PM -static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) +int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); unsigned long flags; @@ -1031,9 +1051,10 @@ static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) return 0; } +EXPORT_SYMBOL_GPL(ohci_suspend); -static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated) +int ohci_resume(struct usb_hcd *hcd, bool hibernated) { struct ohci_hcd *ohci = hcd_to_ohci(hcd); int port; @@ -1081,8 +1102,72 @@ static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated) return 0; } +EXPORT_SYMBOL_GPL(ohci_resume); + +#endif + +/*-*/ + +/* + * Generic structure: This gets copied for platform drivers so that + * individual entries can be overridden as needed. + */ +static const struct hc_driver
[RFC PATCH 2/3] USB: OHCI: Generic changes to make ohci-pci a separate driver
Note that this changes is part of separating the ohci pci host controller driver from ohci-hcd host code. This contains : -Moved sb800_prefetch() function from ohci-pci.c to pci-quirks.c file and EXPORTed, this is part of the effort to move the ohci pci related code to generic pci code. -Passed pci_dev argument instead of ohci_hcd in sb800_prefetch() function to avoid extra include file in pci-quirks.c. 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 --- drivers/usb/host/ohci-hcd.c | 11 +-- drivers/usb/host/ohci-pci.c | 13 - drivers/usb/host/ohci-q.c |6 -- drivers/usb/host/pci-quirks.c | 12 drivers/usb/host/pci-quirks.h |2 ++ 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 13ebbb7..2490b81 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -80,15 +80,6 @@ static const charhcd_name [] = ohci_hcd; static void ohci_dump (struct ohci_hcd *ohci, int verbose); static void ohci_stop (struct usb_hcd *hcd); -#ifdef CONFIG_PCI -static void sb800_prefetch(struct ohci_hcd *ohci, int on); -#else -static inline void sb800_prefetch(struct ohci_hcd *ohci, int on) -{ - return; -} -#endif - #include ohci-hub.c #include ohci-dbg.c @@ -1275,7 +1266,7 @@ MODULE_LICENSE (GPL); #define PLATFORM_DRIVERohci_platform_driver #endif -#if!defined(PCI_DRIVER) \ +#if!defined(PCI_DRIVER) \ !defined(PLATFORM_DRIVER) \ !defined(OMAP1_PLATFORM_DRIVER) \ !defined(OMAP3_PLATFORM_DRIVER) \ diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 2c27a5f..c3fa936 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -168,19 +168,6 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd) return 0; } -static void sb800_prefetch(struct ohci_hcd *ohci, int on) -{ - struct pci_dev *pdev; - u16 misc; - - pdev = to_pci_dev(ohci_to_hcd(ohci)-self.controller); - pci_read_config_word(pdev, 0x50, misc); - if (on == 0) - pci_write_config_word(pdev, 0x50, misc 0xfcff); - else - pci_write_config_word(pdev, 0x50, misc | 0x0300); -} - /* List of quirks for OHCI */ static const struct pci_device_id ohci_pci_quirks[] = { { diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 88731b7..78e0095 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c @@ -41,6 +41,7 @@ finish_urb(struct ohci_hcd *ohci, struct urb *urb, int status) __releases(ohci-lock) __acquires(ohci-lock) { + struct pci_dev *pdev = to_pci_dev(ohci_to_hcd(ohci)-self.controller); // ASSERT (urb-hcpriv != 0); urb_free_priv (ohci, urb-hcpriv); @@ -55,7 +56,7 @@ __acquires(ohci-lock) if (quirk_amdiso(ohci)) usb_amd_quirk_pll_enable(); if (quirk_amdprefetch(ohci)) - sb800_prefetch(ohci, 0); + sb800_prefetch(pdev, 0); } break; case PIPE_INTERRUPT: @@ -580,6 +581,7 @@ static void td_submit_urb ( struct urb *urb ) { struct urb_priv *urb_priv = urb-hcpriv; + struct pci_dev *pdev = to_pci_dev(ohci_to_hcd(ohci)-self.controller); dma_addr_t data; int data_len = urb-transfer_buffer_length; int cnt = 0; @@ -689,7 +691,7 @@ static void td_submit_urb ( if (quirk_amdiso(ohci)) usb_amd_quirk_pll_disable(); if (quirk_amdprefetch(ohci)) - sb800_prefetch(ohci, 1); + sb800_prefetch(pdev, 1); } periodic = ohci_to_hcd(ohci)-self.bandwidth_isoc_reqs++ == 0 ohci_to_hcd(ohci)-self.bandwidth_int_reqs == 0; diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 4c338ec..5f01540 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -91,6 +91,18 @@ static struct amd_chipset_info { static DEFINE_SPINLOCK(amd_lock); +void sb800_prefetch(struct pci_dev *pdev, int on) +{ + u16 misc; + + pci_read_config_word(pdev, 0x50, misc); + if (on == 0) + pci_write_config_word(pdev, 0x50, misc 0xfcff); + else + pci_write_config_word(pdev, 0x50, misc | 0x0300); +} +EXPORT_SYMBOL_GPL(sb800_prefetch); + int usb_amd_find_chipset_info(void) { u8 rev = 0; diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h index 7f69a39..7c5fbc1 100644 ---
[RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver
This patch splits the PCI portion of ohci-hcd out into its own separate driver module, called ohci-pci. The major point of difficulty lies in ohci-pci's many vendor- and device-specific workarounds. Some of them have to be applied before calling ohci_start() some after, which necessitates a fair amount of code motion. The other platform drivers require much smaller changes. The complete sb800_prefetch() function moved to ohci-q.c,because its only related to ohci-pci driver. V2: - few specific content of pci related code in ohci_pci_start function has been moved to ohci_pci_reset and rest of the generic code is written in ohci_start of ohci-hcd.c file. V3: - ohci_restart() has been called in ohci_pci_reset() function for to reset the ohci pci. V4: -sb800_prefetch() moved to ohci-q.c,because its only related to ohci-pci. -no longer _creating_ CONFIG_USB_OHCI_PCI,creating CONFIG_USB_OHCI_HCD_PCI. -overrides renamed with pci_override,its giving proper meaning. V5: -sb800_prefetch() moved to pci-quirks.c,because its only related to pci. V6: -sb800_prefetch() function has been moved to pci-quirks.c made as separate patch in 2/3. -Most of the generic ohci pci changes moved in 2/3 patch,now this is complete ohci-pci separation patch. 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 --- drivers/usb/host/Kconfig |4 +- drivers/usb/host/Makefile |3 + drivers/usb/host/ohci-hcd.c | 15 - drivers/usb/host/ohci-pci.c | 132 ++--- drivers/usb/host/ohci-q.c |2 + drivers/usb/host/ohci.h |4 ++ drivers/usb/host/pci-quirks.c |2 + drivers/usb/host/pci-quirks.h |1 + 8 files changed, 59 insertions(+), 104 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 64d7209..7e75387 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -377,7 +377,7 @@ config USB_FUSBH200_HCD module will be called fusbh200-hcd. config USB_OHCI_HCD - tristate OHCI HCD support + tristate OHCI HCD (USB 1.1) support depends on USB_ARCH_HAS_OHCI select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 depends on USB_ISP1301 || !ARCH_LPC32XX @@ -446,7 +446,7 @@ config USB_OHCI_HCD_PPC_OF default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE config USB_OHCI_HCD_PCI - bool OHCI support for PCI-bus USB controllers + tristate OHCI support for PCI-bus USB controllers depends on PCI (STB03xxx || PPC_MPC52xx || USB_OHCI_HCD_PPC_OF) default y select USB_OHCI_LITTLE_ENDIAN diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 661c558..2214ded 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -42,7 +42,10 @@ obj-$(CONFIG_USB_EHCI_TEGRA)+=ehci-tegra.o obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o + obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o +obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o + obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 2490b81..36fc3f7 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1166,11 +1166,6 @@ MODULE_AUTHOR (DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE (GPL); -#ifdef CONFIG_PCI -#include ohci-pci.c -#define PCI_DRIVER ohci_pci_driver -#endif - #if defined(CONFIG_ARCH_SA1100) defined(CONFIG_SA) #include ohci-sa.c #define SA_DRIVER ohci_hcd_sa_driver @@ -1341,12 +1336,6 @@ static int __init ohci_hcd_mod_init(void) goto error_sa; #endif -#ifdef PCI_DRIVER - retval = pci_register_driver(PCI_DRIVER); - if (retval 0) - goto error_pci; -#endif - #ifdef SM501_OHCI_DRIVER retval = platform_driver_register(SM501_OHCI_DRIVER); if (retval 0) @@ -1440,10 +1429,6 @@ static int __init ohci_hcd_mod_init(void) platform_driver_unregister(SM501_OHCI_DRIVER); error_sm501: #endif -#ifdef PCI_DRIVER - pci_unregister_driver(PCI_DRIVER); - error_pci: -#endif #ifdef SA_DRIVER sa_driver_unregister(SA_DRIVER); error_sa: diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index c3fa936..ea088c1 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -14,12 +14,19 @@ * This file is licenced under the GPL. */ -#ifndef CONFIG_PCI -#error This file is PCI bus glue. CONFIG_PCI must be defined. -#endif - -#include linux/pci.h #include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/pci.h
Re: [PATCH] HID: usbhid: ignore Jabra speakerphones HID interface
On Wed, 22 May 2013, Vincent Palatin wrote: Add a quirk to ignore Jabra speakerphone 410 and 510 devices HID interface. On those devices, the USB audio interface is working nicely, but the HID interface is not working with the kernel usbhid driver, and it requires a specific userspace program. We could unbind it from userspace but just attaching the usbhid driver has sometimes nasty effects: either confusing the device state machine or triggering a storm of volume key events making eventual sound UI blinking like crazy. Signed-off-by: Vincent Palatin vpala...@chromium.org --- drivers/hid/hid-core.c | 2 ++ drivers/hid/hid-ids.h | 4 2 files changed, 6 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 264f550..5d2ef66 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2042,6 +2042,8 @@ static const struct hid_device_id hid_ignore_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, + { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, USB_DEVICE_ID_JABRA_SPEAK_410) }, + { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, USB_DEVICE_ID_JABRA_SPEAK_510) }, { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 38535c9..533815b 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -447,6 +447,10 @@ #define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615 #define USB_DEVICE_ID_IRTOUCH_INFRARED_USB 0x0070 +#define USB_VENDOR_ID_JABRA 0x0b0e +#define USB_DEVICE_ID_JABRA_SPEAK_4100x0412 +#define USB_DEVICE_ID_JABRA_SPEAK_5100x0420 + #define USB_VENDOR_ID_JESS 0x0c45 #define USB_DEVICE_ID_JESS_YUREX 0x1010 Applied, thanks. -- Jiri Kosina SUSE Labs -- 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/2] usb: dwc3: pci: PHY should be deleted later than dwc3 core
Hi, On Tue, May 21, 2013 at 09:26:32AM +0800, Peter Chen wrote: On Mon, May 20, 2013 at 06:18:52PM +0300, Felipe Balbi wrote: On Mon, May 20, 2013 at 10:55:57AM +0800, Peter Chen wrote: If the glue layer is removed first (core layer later), it deletes the phy device first, then the core device. But at core's removal, it still uses PHY's resources, it may cause kernel's oops. It is much like the problem Paul Zimmerman reported at: http://marc.info/?l=linux-usbm=136547502011472w=2. Besides, it is reasonable the PHY is deleted at last as the controller is the PHY's user. Signed-off-by: Peter Chen peter.c...@freescale.com this needs to Cc stable. Please figure out which kernels need to have this and resend with proper Cc: stable tags. I am afraid I have not worked at dwc3 platform, I don't know from which kernel this fix is needed. Maybe Paul or you can figure it out? git blame helps there -- balbi signature.asc Description: Digital signature
Re: Huawei 3276 with option and cdc_ncm
Alexey Orishko alexey.oris...@gmail.com writes: Hi all, On Wed, May 22, 2013 at 10:40 PM, Bjørn Mork bj...@mork.no wrote: Thomas Schäfer tschae...@t-online.de writes: TX-counter-problem ... This is expected as a result of the cdc_ncm = usbnet design. . The buffer filling may seem strange, but Alexey has explained it several times here on this list. It has to do with device DMA optimizations. Google it or search this list if you want the proper explanation. Thank you for the explanation (again). May be the following question is also repeated. Is there a different way to count the tx bytes? On mobile devices, mostly with volume-limited contracts, this number may have a higher meaning than normal. Yes, I understand that. I don't have any good answers. You really want to know the number of bytes transmitted and received by the modem. This is never the same as the host counters, but the approximation is good enough for most drivers. Just not for cdc_ncm (or cdc_mbim which use the same logic). If you can read the modem counters via some management protocol, then that would be best. But I don't know if that is supported for devices using cdc_ncm with AT command managent. We should probably make a better payload counter available for cdc_ncm and cdc_mbim. I must admit that I know next to nothing about netdev counter policies. I assume the current driver behaviour is correct (it really counts the number of bytes transferred from the host to the device). Maybe you could research this a bit? If the current behaviour is considered correct, how do we add other counters to a driver? This needs to be done in a generic way. I am pretty sure there are examples of net drivers counting lots of stuff. Actually counting the bytes isn't hard. It's the userspace interface that needs some consideration. It is possible to count exact size of IP packets in Tx(Rx) direction, since we know size of each IP packet when we add(extract) it into(from) NTB. And it's possible to make this information available to user space application as well. Yes, looking quickly at this I believe usbnet in general could benefit from having ethtool stats added, including a few extra counters showing bytes/packets before calling the minidriver rx/tx fixup functions. This would be useful for all minidrivers using some sort of extra framing. However, the main problem is that host driver statistic will never be exact match of the statistic done by mobile operator while charging you for the used traffic. They most likely are charging you for the volume over the air and it means additional framing from 3GPP protocol stack, which is unavailable for ncm driver. Also there might be some internal applications on mobile device which are generating some traffic over the air. I would rather rely on Tx/Rx values provided via AT commands by each vendor (if implemented) instead of using usb driver counters. Agreed. That is definitely much better if available. But this doesn't rule out the possibility of adding more driver counters as well. Bjørn -- 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
time source unstable on usb/serial/pl2303 (globalsat br-353)
Hi all, I have a lot of linux computers equipped with a GlobalSat Br-353 GPS receiver, which is connected via USB (an integrated PL2303). The GPS receiver emits one multi-line message every second, giving position and time. I listen to this messages in a user program running in the highest priority, and I have noticed that under load, the messages are not delivered to my process every second, but often delayed, which is not great for a time source. I looked at the sources of pl2303 and added a diagnostic message if the beginning of a message came more than one second later than the beginning of the previous one, and I noticed that the delay was already present in the kernel: often even more than one second delay after the expected beginning time. Can you give me some advice on how to avoid that delay ? How can I increase the polling priority of this serial line, or how may I get some usefull debugging about the USB polling for this serial line ? Thanks in advance Philippe -- 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: [RFC PATCH 2/3] USB: OHCI: Generic changes to make ohci-pci a separate driver
On Thursday 23 May 2013, Manjunath Goudar wrote: @@ -1275,7 +1266,7 @@ MODULE_LICENSE (GPL); #define PLATFORM_DRIVERohci_platform_driver #endif -#if!defined(PCI_DRIVER) \ +#if!defined(PCI_DRIVER) \ !defined(PLATFORM_DRIVER) \ !defined(OMAP1_PLATFORM_DRIVER) \ !defined(OMAP3_PLATFORM_DRIVER) \ This part didn't really belong here, otherwise the patch looks right to me. Arnd -- 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] build some drivers only when compile-testing
On Wed, 2013-05-22 at 19:23 -0700, Greg Kroah-Hartman wrote: On Wed, May 22, 2013 at 11:18:46AM +0200, Jiri Slaby wrote: Some drivers can be built on more platforms than they run on. This causes users and distributors packaging burden when they have to manually deselect some drivers from their allmodconfigs. Or sometimes it is even impossible to disable the drivers without patching the kernel. Introduce a new config option COMPILE_TEST and make all those drivers to depend on the platform they run on, or on the COMPILE_TEST option. Now, when users/distributors choose COMPILE_TEST=n they will not have the drivers in their allmodconfig setups, but developers still can compile-test them with COMPILE_TEST=y. I understand the urge, and it's getting hard for distros to handle these drivers that just don't work on other architectures, but it's really valuable to ensure that they build properly, for those of us that don't have many/any cross compilers set up. Now the drivers where we use this new option: * PTP_1588_CLOCK_PCH: The PCH EG20T is only compatible with Intel Atom processors so it should depend on x86. * FB_GEODE: Geode is 32-bit only so only enable it for X86_32. * USB_CHIPIDEA_IMX: The OF_DEVICE dependency will be met on powerpc systems -- which do not actually support the hardware via that method. This seems ripe to start to get really messy, really quickly. Shouldn't default configs handle if this should be enabled for a platform or not, and let the rest of us just build them with no problems? Debian aims to provide a consistent feature set across all supported architectures so far as possible, and I would expect other distributions to do the same. I don't believe anyone is coordinating defconfigs across architectures to ensure that. Distributions may also have particular requirements from userland that a distribution-agnostic defconfig obviously doesn't cover. (Isn't that why we had the discussion about 'configure for my distribution' some months back?) For the driver configuration, what we provide in Debian is closer to allmodconfig, only with some attempt to exclude those useless drivers. Dependencies like this would make it easier to do that. What problems is this causing you? Are you running out of space in kernel packages with drivers that will never be actually used? On most x86 systems this isn't going to be an issue. But if packages are built natively (as they are for most distributions) then building useless drivers for some architecture which doesn't have fast processors available is a waste of precious resources. This is particularly bad where the architecture doesn't support generic kernels that boot on a wide range of machines and therefore we must build many times over. These unfortunately tend to be among those with slower processors (ARM[1], MIPS, SH, ...). Currently, Debian's linux package takes ~48 hours to build for armel (ARM processors without FPU) - and that's without building many of the PCI drivers we could for those platforms which have PCI support. So that's a minimum of 2 days to provide a security update across all architectures[2]. [1] I'm aware that ARM is getting better in this regard and most ARMv7 machines are likely to be supportable by a single kernel image soon. That doesn't mean the whole problem is solved. [2] We don't always wait for all builds before releasing/announcing an update; for example http://www.debian.org/security/2013/dsa-2669. But that's no comfort for those using the slower architecture. +config COMPILE_TEST + bool Compile also drivers which will not load if EXPERT EXPERT is getting to be the let's hide it here option, isn't it... This little detail seems likely to reduce the usefulness of randconfig as many drivers will become dependent on both EXPERT and COMPILE_TEST being selected. I don't know, if no one else strongly objects, I can be convinced that this is needed, but so far, I don't see why it really is, or what this is going to help with. Ben. -- Ben Hutchings friends: People who know you well, but like you anyway. signature.asc Description: This is a digitally signed message part
Re: Misbehaving device
On Wed, 22 May 2013, Joe Julian wrote: Right, and I'm supposed to know that how? You're the one who's an expert on usb. You know how HID keyboards pass data. I'm starting from scratch and only have data that is sensitive. It's hard to know what you can share when you don't know what you have. Sorry; it's not easy to tell what other people know beforehand. Since you have expectations that I'm not ready to meet can you at least point me to documentation on how HID keyboards are supposed to work? My Google foo is failing me there. http://www.usb.org/developers/hidpage/ 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 1/1] usb: host: ehci-spear: Remove redundant checks
On Thu, 23 May 2013, Sachin Kamat wrote: 'hcd' can never be NULL and the spear_ehci_hcd_drv_remove routine will never be called in_interrupt. Hence remove these checks. Signed-off-by: Sachin Kamat sachin.ka...@linaro.org Cc: Viresh Kumar viresh.ku...@linaro.org Cc: Alan Stern st...@rowland.harvard.edu --- Compile tested on linux-next (20130522). --- drivers/usb/host/ehci-spear.c |4 1 file changed, 4 deletions(-) diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index f5ac4e2..1cf0adb 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c @@ -148,10 +148,6 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) struct usb_hcd *hcd = platform_get_drvdata(pdev); struct spear_ehci *sehci = to_spear_ehci(hcd); - if (!hcd) - return 0; - if (in_interrupt()) - BUG(); usb_remove_hcd(hcd); if (sehci-clk) 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
[RFC PATCH v3 3/4] usb: xhci: add USB2 Link power management BESL support
usb 2.0 devices with link power managment (LPM) can describe their idle link timeouts either in BESL or HIRD format, so far xHCI has only supported HIRD but later xHCI errata add BESL support as well BESL timeouts need to inform exit latency changes with an evaluate context command the same way USB 3.0 link PM code does. The same xhci_change_max_exit_latency() function is used as with USB3 but code is pulled out from #ifdef CONFIG_PM as USB2.0 BESL LPM funcionality does not depend on CONFIG_PM. Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci-ext-caps.h |1 + drivers/usb/host/xhci.c | 204 ++ drivers/usb/host/xhci.h | 21 include/linux/usb.h |2 + 4 files changed, 164 insertions(+), 64 deletions(-) diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h index 377f424..8d7a132 100644 --- a/drivers/usb/host/xhci-ext-caps.h +++ b/drivers/usb/host/xhci-ext-caps.h @@ -71,6 +71,7 @@ /* USB 2.0 xHCI 1.0 hardware LMP capability - section 7.2.2.1.3.2 */ #define XHCI_HLC (1 19) +#define XHCI_BLC (1 19) /* command register values to disable interrupts and halt the HC */ /* start/stop HC execution - do not write unless HC is halted*/ diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 317bf08..d1eb393 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3805,6 +3805,56 @@ int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1) return raw_port; } +/* + * Issue an Evaluate Context command to change the Maximum Exit Latency in the + * slot context. If that succeeds, store the new MEL in the xhci_virt_device. + */ +static int xhci_change_max_exit_latency(struct xhci_hcd *xhci, + struct usb_device *udev, u16 max_exit_latency) +{ + struct xhci_virt_device *virt_dev; + struct xhci_command *command; + struct xhci_input_control_ctx *ctrl_ctx; + struct xhci_slot_ctx *slot_ctx; + unsigned long flags; + int ret; + + spin_lock_irqsave(xhci-lock, flags); + if (max_exit_latency == xhci-devs[udev-slot_id]-current_mel) { + spin_unlock_irqrestore(xhci-lock, flags); + return 0; + } + + /* Attempt to issue an Evaluate Context command to change the MEL. */ + virt_dev = xhci-devs[udev-slot_id]; + command = xhci-lpm_command; + xhci_slot_copy(xhci, command-in_ctx, virt_dev-out_ctx); + spin_unlock_irqrestore(xhci-lock, flags); + + ctrl_ctx = xhci_get_input_control_ctx(xhci, command-in_ctx); + ctrl_ctx-add_flags |= cpu_to_le32(SLOT_FLAG); + slot_ctx = xhci_get_slot_ctx(xhci, command-in_ctx); + slot_ctx-dev_info2 = cpu_to_le32(~((u32) MAX_EXIT)); + slot_ctx-dev_info2 |= cpu_to_le32(max_exit_latency); + + xhci_dbg(xhci, Set up evaluate context for LPM MEL change.\n); + xhci_dbg(xhci, Slot %u Input Context:\n, udev-slot_id); + xhci_dbg_ctx(xhci, command-in_ctx, 0); + + /* Issue and wait for the evaluate context command. */ + ret = xhci_configure_endpoint(xhci, udev, command, + true, true); + xhci_dbg(xhci, Slot %u Output Context:\n, udev-slot_id); + xhci_dbg_ctx(xhci, virt_dev-out_ctx, 0); + + if (!ret) { + spin_lock_irqsave(xhci-lock, flags); + virt_dev-current_mel = max_exit_latency; + spin_unlock_irqrestore(xhci-lock, flags); + } + return ret; +} + #ifdef CONFIG_PM_RUNTIME /* BESL to HIRD Encoding array for USB2 LPM */ @@ -3846,6 +3896,28 @@ static int xhci_calculate_hird_besl(struct xhci_hcd *xhci, return besl; } +/* Calculate BESLD, L1 timeout and HIRDM for USB2 PORTHLPMC */ +static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev) +{ + u32 field; + int l1; + int besld = 0; + int hirdm = 0; + + field = le32_to_cpu(udev-bos-ext_cap-bmAttributes); + + /* xHCI l1 is set in steps of 256us, xHCI 1.0 section 5.4.11.2 */ + l1 = XHCI_L1_TIMEOUT / 256; + + /* device has preferred BESLD */ + if (field USB_BESL_DEEP_VALID) { + besld = USB_GET_BESL_DEEP(field); + hirdm = 1; + } + + return PORT_BESLD(besld) | PORT_L1_TIMEOUT(l1) | PORT_HIRDM(hirdm); +} + static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, struct usb_device *udev) { @@ -3978,11 +4050,12 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, { struct xhci_hcd *xhci = hcd_to_xhci(hcd); __le32 __iomem **port_array; - __le32 __iomem *pm_addr; - u32 temp; + __le32 __iomem *pm_addr, *hlpm_addr; + u32 pm_val, hlpm_val, field; unsigned intport_num; unsigned long flags; - int hird; + int
[RFC PATCH v3 4/4] usb: add usb2 Link PM variables to sysfs and usb_device
Adds abitilty to tune L1 timeout (inactivity timer for usb2 link sleep) and BESL (best effort service latency)via sysfs. This also adds a new usb2_lpm_parameters structure with those variables to struct usb_device. Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- Documentation/ABI/testing/sysfs-bus-usb | 27 +++ drivers/usb/core/sysfs.c| 54 +++ drivers/usb/host/xhci.c |6 ++- include/linux/usb.h | 18 ++ 4 files changed, 103 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index f093e59..9759b8c 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb @@ -236,3 +236,30 @@ Description: This attribute is to expose these information to user space. The file will read hotplug, wired and not used if the information is available, and unknown otherwise. + +What: /sys/bus/usb/devices/.../power/usb2_lpm_l1_timeout +Date: May 2013 +Contact: Mathias Nyman mathias.ny...@linux.intel.com +Description: + USB 2.0 devices may support hardware link power management (LPM) + L1 sleep state. The usb2_lpm_l1_timeout attribute allows + tuning the timeout for L1 inactivity timer (LPM timer), e.g. + needed inactivity time before host requests the device to go to L1 sleep. + Useful for power management tuning. + Supported values are 0 - 65535 microseconds. + +What: /sys/bus/usb/devices/.../power/usb2_lpm_besl +Date: May 2013 +Contact: Mathias Nyman mathias.ny...@linux.intel.com +Description: + USB 2.0 devices that support hardware link power management (LPM) + L1 sleep state now use a best effort service latency value (BESL) to + indicate the best effort to resumption of service to the device after the + initiation of the resume event. + If the device does not have a preferred besl value then the host can select + one instead. This usb2_lpm_besl attribute allows to tune the host selected besl + value in order to tune power saving and service latency. + + Supported values are 0 - 15. + More information on how besl values map to microseconds can be found in + USB 2.0 ECN Errata for Link Power Management, section 4.10) diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index aa38db4..d9284b9 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -497,8 +497,62 @@ set_usb2_hardware_lpm(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR(usb2_hardware_lpm, S_IRUGO | S_IWUSR, show_usb2_hardware_lpm, set_usb2_hardware_lpm); +static ssize_t +show_usb2_lpm_l1_timeout(struct device *dev, struct device_attribute *attr, +char *buf) +{ + struct usb_device *udev = to_usb_device(dev); + return sprintf(buf, %d\n, udev-l1_params.timeout); +} + +static ssize_t +set_usb2_lpm_l1_timeout(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct usb_device *udev = to_usb_device(dev); + u16 timeout; + + if (kstrtou16(buf, 0, timeout)) + return -EINVAL; + + udev-l1_params.timeout = timeout; + + return count; +} + +static DEVICE_ATTR(usb2_lpm_l1_timeout, S_IRUGO | S_IWUSR, + show_usb2_lpm_l1_timeout, set_usb2_lpm_l1_timeout); + +static ssize_t +show_usb2_lpm_besl(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct usb_device *udev = to_usb_device(dev); + return sprintf(buf, %d\n, udev-l1_params.besl); +} + +static ssize_t +set_usb2_lpm_besl(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct usb_device *udev = to_usb_device(dev); + u8 besl; + + if (kstrtou8(buf, 0, besl) || besl 15) + return -EINVAL; + + udev-l1_params.besl = besl; + + return count; +} + +static DEVICE_ATTR(usb2_lpm_besl, S_IRUGO | S_IWUSR, + show_usb2_lpm_besl, set_usb2_lpm_besl); + static struct attribute *usb2_hardware_lpm_attr[] = { dev_attr_usb2_hardware_lpm.attr, + dev_attr_usb2_lpm_l1_timeout.attr, + dev_attr_usb2_lpm_besl.attr, NULL, }; static struct attribute_group usb2_hardware_lpm_attr_group = { diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index d1eb393..ba7822f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3907,7 +3907,7 @@ static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev) field =
Re: [PATCH 1/1] USB: ehci-omap: Reset dma_mask pointer on probe
On Thu, 23 May 2013, Roger Quadros wrote: Device tree probed devices don't get dma_mask set. Previously we were setting the dma_mask pointer only if it was NULL. However, the address of 'omap_ehci_dma_mask' would change each time the module is unloaded and loaded back thus causing the devices dma_mask pointer to be invalid on the next load. This will cause page faults if any driver tries to access the old dma_mask pointer. Unconditionally re-setting the dma_mask pointer fixes this problem. diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 3d1491b..b33e306 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -146,8 +146,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) * Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ - if (!pdev-dev.dma_mask) - pdev-dev.dma_mask = omap_ehci_dma_mask; + pdev-dev.dma_mask = omap_ehci_dma_mask; Is this the solution that people have agreed on? There has been a lot of discussion on this topic. In particular, there has been talk about fixing it in the DT core. This particular approach doesn't seem very robust. What if pdev-dev.dma_mask is already set to a different value for some good reason? 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] USB: host: use platform_{get,set}_drvdata()
On Thu, 23 May 2013, Jingoo Han wrote: Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with pdev-dev, so we can directly pass a struct platform_device. Also, unnecessary dev_set_drvdata() is removed, because the driver core clears the driver data to NULL after device_release or on probe failure. 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
[RFC PATCH v3 0/4] Add usb2 link powermanagement BESL support
This series adds usb2 best effort service latency (BESL) link PM support to xHCI. BESL is an updated alternative to host initated resume delay (HIRD) method of describing idle link timeouts. Additionally this series fixes port capability checking and replaces magic numbers with port register names. Changes since v1: -Use kstrto* and unsigned values in sysfs functions as Alan Stern suggested Changes since v2: - Add Documentation/ABI/testing/sysfs-bus-usb entries for new sysfs attributes - store l1_timeout value in microseconds instead of xHCI specific values Mathias Nyman (4): usb: xhci: check usb2 port capabilities before adding hw link PM support usb: xhci: define port register names and use them instead of magic numbers usb: xhci: add USB2 Link power management BESL support usb: add usb2 Link PM variables to sysfs and usb_device Documentation/ABI/testing/sysfs-bus-usb | 27 drivers/usb/core/sysfs.c| 54 +++ drivers/usb/host/xhci-ext-caps.h|1 + drivers/usb/host/xhci-hub.c | 16 +-- drivers/usb/host/xhci-mem.c | 33 - drivers/usb/host/xhci.c | 237 ++- drivers/usb/host/xhci.h | 29 include/linux/usb.h | 20 +++ 8 files changed, 337 insertions(+), 80 deletions(-) -- 1.7.4.1 -- 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
[RFC PATCH v3 1/4] usb: xhci: check usb2 port capabilities before adding hw link PM support
Hardware link powermanagement in usb2 is a per-port capability. Previously support for hw lpm was enabled for all ports if any usb2 port supported it. Now instead cache the capability values and check them for each port individually Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci-mem.c | 33 + drivers/usb/host/xhci.c | 27 ++- drivers/usb/host/xhci.h |3 +++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 965b539..5fd97d1 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1851,6 +1851,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) kfree(xhci-usb3_ports); kfree(xhci-port_array); kfree(xhci-rh_bw); + kfree(xhci-ext_caps); xhci-page_size = 0; xhci-page_shift = 0; @@ -2038,7 +2039,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci) } static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, - __le32 __iomem *addr, u8 major_revision) + __le32 __iomem *addr, u8 major_revision, int max_caps) { u32 temp, port_offset, port_count; int i; @@ -2063,6 +2064,10 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, /* WTF? Valid values are ‘1’ to MaxPorts */ return; + /* cache usb2 port capabilities */ + if (major_revision 0x03 xhci-num_ext_caps max_caps) + xhci-ext_caps[xhci-num_ext_caps++] = temp; + /* Check the host's USB2 LPM capability */ if ((xhci-hci_version == 0x96) (major_revision != 0x03) (temp XHCI_L1C)) { @@ -2120,10 +2125,11 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, */ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) { - __le32 __iomem *addr; - u32 offset; + __le32 __iomem *addr, *tmp_addr; + u32 offset, tmp_offset; unsigned int num_ports; int i, j, port_index; + int cap_count = 0; addr = xhci-cap_regs-hcc_params; offset = XHCI_HCC_EXT_CAPS(xhci_readl(xhci, addr)); @@ -2156,13 +2162,32 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) * See section 5.3.6 for offset calculation. */ addr = xhci-cap_regs-hc_capbase + offset; + + tmp_addr = addr; + tmp_offset = offset; + + /* count extended protocol capability entries for later caching */ + do { + u32 cap_id; + cap_id = xhci_readl(xhci, tmp_addr); + if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL) + cap_count++; + tmp_offset = XHCI_EXT_CAPS_NEXT(cap_id); + tmp_addr += tmp_offset; + } while (tmp_offset); + + xhci-ext_caps = kzalloc(sizeof(*xhci-ext_caps) * cap_count, flags); + if (!xhci-ext_caps) + return -ENOMEM; + while (1) { u32 cap_id; cap_id = xhci_readl(xhci, addr); if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL) xhci_add_in_port(xhci, num_ports, addr, - (u8) XHCI_EXT_PORT_MAJOR(cap_id)); + (u8) XHCI_EXT_PORT_MAJOR(cap_id), + cap_count); offset = XHCI_EXT_CAPS_NEXT(cap_id); if (!offset || (xhci-num_usb2_ports + xhci-num_usb3_ports) == num_ports) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index b4aa79d..e540a36 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4023,15 +4023,40 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, return 0; } +/* check if a usb2 port supports a given extened capability protocol + * only USB2 ports extended protocol capability values are cached. + * Return 1 if capability is supported + */ +static int xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int port, + unsigned capability) +{ + u32 port_offset, port_count; + int i; + + for (i = 0; i xhci-num_ext_caps; i++) { + if (xhci-ext_caps[i] capability) { + /* port offsets starts at 1 */ + port_offset = XHCI_EXT_PORT_OFF(xhci-ext_caps[i]) - 1; + port_count = XHCI_EXT_PORT_COUNT(xhci-ext_caps[i]); + if (port = port_offset + port port_offset + port_count) + return 1; + } + } + return 0; +} + int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) { struct xhci_hcd *xhci = hcd_to_xhci(hcd);
[RFC PATCH v3 2/4] usb: xhci: define port register names and use them instead of magic numbers
Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci-hub.c | 16 +++- drivers/usb/host/xhci.c |4 ++-- drivers/usb/host/xhci.h |5 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 187a3ec..1d35459 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -867,18 +867,18 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, case USB_PORT_FEAT_U1_TIMEOUT: if (hcd-speed != HCD_USB3) goto error; - temp = xhci_readl(xhci, port_array[wIndex] + 1); + temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); temp = ~PORT_U1_TIMEOUT_MASK; temp |= PORT_U1_TIMEOUT(timeout); - xhci_writel(xhci, temp, port_array[wIndex] + 1); + xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); break; case USB_PORT_FEAT_U2_TIMEOUT: if (hcd-speed != HCD_USB3) goto error; - temp = xhci_readl(xhci, port_array[wIndex] + 1); + temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); temp = ~PORT_U2_TIMEOUT_MASK; temp |= PORT_U2_TIMEOUT(timeout); - xhci_writel(xhci, temp, port_array[wIndex] + 1); + xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); break; default: goto error; @@ -1098,10 +1098,8 @@ int xhci_bus_suspend(struct usb_hcd *hcd) __le32 __iomem *addr; u32 tmp; - /* Add one to the port status register address to get -* the port power control register address. -*/ - addr = port_array[port_index] + 1; + /* Get the port power control register address. */ + addr = port_array[port_index] + PORTPMSC; tmp = xhci_readl(xhci, addr); tmp |= PORT_RWE; xhci_writel(xhci, tmp, addr); @@ -1193,7 +1191,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) /* Add one to the port status register address to get * the port power control register address. */ - addr = port_array[port_index] + 1; + addr = port_array[port_index] + PORTPMSC; tmp = xhci_readl(xhci, addr); tmp = ~PORT_RWE; xhci_writel(xhci, tmp, addr); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index e540a36..317bf08 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3901,7 +3901,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, * Check device's USB 2.0 extension descriptor to determine whether * HIRD or BESL shoule be used. See USB2.0 LPM errata. */ - pm_addr = port_array[port_num] + 1; + pm_addr = port_array[port_num] + PORTPMSC; hird = xhci_calculate_hird_besl(xhci, udev); temp = PORT_L1DS(udev-slot_id) | PORT_HIRD(hird); xhci_writel(xhci, temp, pm_addr); @@ -3999,7 +3999,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, port_array = xhci-usb2_ports; port_num = udev-portnum - 1; - pm_addr = port_array[port_num] + 1; + pm_addr = port_array[port_num] + PORTPMSC; temp = xhci_readl(xhci, pm_addr); xhci_dbg(xhci, %s port %d USB2 hardware LPM\n, diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 1dbc63f..b6cd55e 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -132,6 +132,11 @@ struct xhci_cap_regs { /* Number of registers per port */ #defineNUM_PORT_REGS 4 +#define PORTSC 0 +#define PORTPMSC 1 +#define PORTLI 2 +#define PORTHLPMC 3 + /** * struct xhci_op_regs - xHCI Host Controller Operational Registers. * @command: USBCMD - xHC command register -- 1.7.4.1 -- 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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue
Hello. On 23-05-2013 10:01, Ravi Babu wrote: removed unused nop xceiv (un_)register API's from all musb platform drivers Since when are they unused? Signed-off-by: Ravi Babu ravib...@ti.com WBR, Sergei -- 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 v1 7/9] usb: musb: dsps: use get-usb-phy by phandle for multi instance
On 23-05-2013 10:01, Ravi Babu wrote: In case of mutli instance support, use get-phy object using phandle to return to repsective phy xceiv object for each instance Only respective and s/xceiv/transceiver/. Signed-off-by: Ravi Babu ravib...@ti.com WBR, Sergei -- 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: [RFC V6 PATCH 1/3] USB: OHCI: prepare to make ohci-hcd a library module
On Thu, 23 May 2013, Manjunath Goudar wrote: This patch prepares ohci-hcd for being split up into a core library and separate platform driver modules. A generic ohci_hc_driver structure is created, containing all the standard values, and a new mechanism is added whereby a driver module can specify a set of overrides to those values. In addition the ohci_restart(),ohci_suspend() and ohci_resume() routines need to be EXPORTed for use by the drivers. Added ohci_setip(() and ohci_start() routine for to start the generic controller rather than each having its own idiosyncratic approach. This allow to clean duplicated code in most of SOC driver This patch looks good. 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 v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx
On 23-05-2013 10:01, Ravi Babu wrote: The am33xx platforms suppors dual musb instance which need two instances of usb-phy. Add dual instance usb-phy DT bindings for am333x platform. Signed-off-by: Ravi Babu ravib...@ti.com --- arch/arm/boot/dts/am33xx.dtsi | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 0957645..b0b4deb 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -322,6 +322,22 @@ status = disabled; }; + phy1: usbphy-gs70@44e10620 { + compatible = ti,dsps-usbphy; + reg = 0x44e10620 0x8 + 0x44e10648 0x4; + reg-names = phy_ctrl,phy_wkup; + id = 0; + }; + + phy2: usbphy-gs70@44e10628 { + compatible = ti,dsps-usbphy; + reg = 0x44e10628 0x8 + 0x44e10648 0x4; The second register conflicts with phy1. WBR, Sergei -- 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: [RFC PATCH 2/3] USB: OHCI: Generic changes to make ohci-pci a separate driver
On Thu, 23 May 2013, Manjunath Goudar wrote: Note that this changes is part of separating the ohci pci host controller driver from ohci-hcd host code. This contains : -Moved sb800_prefetch() function from ohci-pci.c to pci-quirks.c file and EXPORTed, this is part of the effort to move the ohci pci related code to generic pci code. -Passed pci_dev argument instead of ohci_hcd in sb800_prefetch() function to avoid extra include file in pci-quirks.c. diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 13ebbb7..2490b81 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1275,7 +1266,7 @@ MODULE_LICENSE (GPL); #define PLATFORM_DRIVER ohci_platform_driver #endif -#if !defined(PCI_DRIVER) \ +#if !defined(PCI_DRIVER) \ !defined(PLATFORM_DRIVER) \ !defined(OMAP1_PLATFORM_DRIVER) \ !defined(OMAP3_PLATFORM_DRIVER) \ As Arnd mentioned, this doesn't belong here. diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 88731b7..78e0095 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c @@ -41,6 +41,7 @@ finish_urb(struct ohci_hcd *ohci, struct urb *urb, int status) __releases(ohci-lock) __acquires(ohci-lock) { + struct pci_dev *pdev = to_pci_dev(ohci_to_hcd(ohci)-self.controller); You shouldn't call to_pci_dev(). At this point you don't know if the controller is a PCI device or not. Instead, just do struct device *dev = ohci_to_hcd(ohci)-self.controller; Then in sb800_prefetch(), where it makes sense, you can call to_pci_dev(). @@ -580,6 +581,7 @@ static void td_submit_urb ( struct urb *urb ) { struct urb_priv *urb_priv = urb-hcpriv; + struct pci_dev *pdev = to_pci_dev(ohci_to_hcd(ohci)-self.controller); Same thing here. Otherwise this is okay. 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: [RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver
On Thu, 23 May 2013, Manjunath Goudar wrote: This patch splits the PCI portion of ohci-hcd out into its own separate driver module, called ohci-pci. The major point of difficulty lies in ohci-pci's many vendor- and device-specific workarounds. Some of them have to be applied before calling ohci_start() some after, which necessitates a fair amount of code motion. The other platform drivers require much smaller changes. The complete sb800_prefetch() function moved to ohci-q.c,because its only related to ohci-pci driver. V2: - few specific content of pci related code in ohci_pci_start function has been moved to ohci_pci_reset and rest of the generic code is written in ohci_start of ohci-hcd.c file. V3: - ohci_restart() has been called in ohci_pci_reset() function for to reset the ohci pci. V4: -sb800_prefetch() moved to ohci-q.c,because its only related to ohci-pci. -no longer _creating_ CONFIG_USB_OHCI_PCI,creating CONFIG_USB_OHCI_HCD_PCI. -overrides renamed with pci_override,its giving proper meaning. V5: -sb800_prefetch() moved to pci-quirks.c,because its only related to pci. V6: -sb800_prefetch() function has been moved to pci-quirks.c made as separate patch in 2/3. -Most of the generic ohci pci changes moved in 2/3 patch,now this is complete ohci-pci separation patch. This patch has a lot of extra stuff in it. It looks like you forgot to undo a bunch of things from the previous version, things that are no longer needed. As I said before, you really need to proofread your patches before emailing them. Don't rely on other people to find your mistakes. Also, you left out one thing that should still be here. What happened to the part about changing #if !defined(PCI_DRIVER) \ to #if !ENABLED(CONFIG_USB_OHCI_HCD_PCI) \ ? 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 1/1] USB: ehci-omap: Reset dma_mask pointer on probe
On 05/23/2013 05:11 PM, Alan Stern wrote: On Thu, 23 May 2013, Roger Quadros wrote: Device tree probed devices don't get dma_mask set. Previously we were setting the dma_mask pointer only if it was NULL. However, the address of 'omap_ehci_dma_mask' would change each time the module is unloaded and loaded back thus causing the devices dma_mask pointer to be invalid on the next load. This will cause page faults if any driver tries to access the old dma_mask pointer. Unconditionally re-setting the dma_mask pointer fixes this problem. diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 3d1491b..b33e306 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -146,8 +146,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) * Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ -if (!pdev-dev.dma_mask) -pdev-dev.dma_mask = omap_ehci_dma_mask; +pdev-dev.dma_mask = omap_ehci_dma_mask; Is this the solution that people have agreed on? There has been a lot of discussion on this topic. In particular, there has been talk about fixing it in the DT core. Fixing it in DT core would be best. This particular approach doesn't seem very robust. What if pdev-dev.dma_mask is already set to a different value for some good reason? Then it breaks. But for OMAP, that situation seems unlikely. 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: time source unstable on usb/serial/pl2303 (globalsat br-353)
On Thu, May 23, 2013 at 03:07:09PM +0200, Philippe De Muyter wrote: Hi all, I have a lot of linux computers equipped with a GlobalSat Br-353 GPS receiver, which is connected via USB (an integrated PL2303). The GPS receiver emits one multi-line message every second, giving position and time. I listen to this messages in a user program running in the highest priority, and I have noticed that under load, the messages are not delivered to my process every second, but often delayed, which is not great for a time source. I looked at the sources of pl2303 and added a diagnostic message if the beginning of a message came more than one second later than the beginning of the previous one, and I noticed that the delay was already present in the kernel: often even more than one second delay after the expected beginning time. Then that implies that the device itself is holding on to the message, right? Can you give me some advice on how to avoid that delay ? How can I increase the polling priority of this serial line, or how may I get some usefull debugging about the USB polling for this serial line ? There is no polling of USB serial devices (well, there is, but it's a USB thing, and the hardware does it for us, not the software). The pl2303 is a _very_ cheap chip, and it might buffer the message for a long time before it decides to send it to the USB host. The delay might also be in the GPS device itself, it has to send serial data to the pl2303 device, and who knows at what baud rate that is coming in at. USB is not something that you can rely on for very high-frequency, low latency, timing things. Although to be fair, second delays are quite rare, which implies that your hardware is to blame here. Sorry, 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
[GIT PATCH] USB fixes for 3.10-rc3
The following changes since commit f722406faae2d073cc1d01063d1123c35425939e: Linux 3.10-rc1 (2013-05-11 17:14:08 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ tags/usb-3.10-rc2 for you to fetch changes up to 2a0ebf80aa95cc758d4725f74a7016e992606a39: USB: cxacru: potential underflow in cxacru_cm_get_array() (2013-05-20 11:35:47 -0700) USB fixes for 3.10-rc2 Here are a number of tiny USB bugfixes / new device ids for 3.10-rc2 The majority of these are USB gadget fixes, but they are all small. Other than that, some USB host controller fixes, and USB serial driver fixes for problems reported with them. Also hopefully a fixed up USB_OTG Kconfig dependancy, that one seems to be almost impossible to get right for all of the different platforms these days. Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org Alan Stern (6): USB: xHCI: override bogus bulk wMaxPacketSize values USB: fix Kconfig logic for USB_UHCI_HCD USB: UHCI: fix for suspend of virtual HP controller USB: fix latency in uhci-hcd and ohci-hcd USB: OHCI: fix logic for scheduling isochronous URBs USB: remove remaining instances of USB_SUSPEND Arnd Bergmann (1): USB: EHCI: remove bogus #error Dan Carpenter (1): USB: cxacru: potential underflow in cxacru_cm_get_array() Dan Williams (1): USB: option: add device IDs for Dell 5804 (Novatel E371) WWAN card David Rientjes (1): usb, chipidea: fix link error when USB_EHCI_HCD is a module Gomella, Andrew (NIH/NHLBI) [F] (1): USB: ftdi_sio: Add support for Newport CONEX motor drivers Greg Kroah-Hartman (1): Merge tag 'fixes-for-v3.10-rc2' of git://git.kernel.org/.../balbi/usb into usb-linus Jingoo Han (1): usb: gadget: s3c-hsotg: pass 'struct usb_request *' to usb_gadget_unmap_request() Johan Hovold (7): USB: serial: add wait_until_sent operation USB: serial: add generic wait_until_sent implementation USB: ftdi_sio: clean up get_modem_status USB: ftdi_sio: fix chars_in_buffer overhead USB: io_ti: fix chars_in_buffer overhead USB: ti_usb_3410_5052: fix chars_in_buffer overhead USB: serial: clean up chars_in_buffer Libo Chen (3): usb: ehci-s5p: fix memleak when fallback to pdata usb: isp1760-if: fix memleak when platform_get_resource fail usb: ohci: fix goto wrong tag in err case Michael Grzeschik (1): usb: otg: mxs-phy: add missing type to usb_phy Oliver Neukum (1): USB: reset resume quirk needed by a hub Paul Bolle (1): usb: phy: remove CONFIG_USB_OTG_UTILS once more Robert Jarzmik (1): usb: phy: Fix NULL pointer exception during usb_get_phy Robert P. J. Day (2): Correct typo supperspeed to superspeed. Add a couple kernel-doc lines to prevent warnings. Sachin Kamat (12): usb: gadget: atmel_usba_udc: Remove redundant platform_set_drvdata() usb: gadget: bcm63xx_udc: Remove redundant platform_set_drvdata() usb: gadget: dummy_hcd: Remove redundant platform_set_drvdata() usb: gadget: f_uac2: Remove redundant platform_set_drvdata() usb: gadget: imx_udc: Remove redundant platform_set_drvdata() usb: gadget: pxa25x_udc: Remove redundant platform_set_drvdata() usb: gadget: s3c2410_udc: Remove redundant platform_set_drvdata() usb: phy: ab8500-usb: Remove redundant platform_set_drvdata() usb: phy: gpio-vbus-usb: Remove redundant platform_set_drvdata() usb: phy: mv-usb: Remove redundant platform_set_drvdata() usb: phy: mxs-usb: Remove redundant platform_set_drvdata() usb: phy: nop: Remove redundant platform_set_drvdata() Schemmel Hans-Christoph (1): USB: Blacklisted Cinterion's PLxx WWAN Interface Stephen Warren (1): USB: set device dma_mask without reference to global data Teppo Kotilainen (1): usb: option: Add Telewell TW-LTE 4G Vivek Gautam (1): usb: dwc3: Fix compilation break when building with USB_DWC3_DUAL_ROLE=y Wei WANG (1): USB: usb-stor: realtek_cr: Fix compile error Wei Yongjun (9): usb: gadget: zero: fix error return code in zero_bind() usb: musb: omap2430: add missing platform_device_put() on error in omap2430_probe() usb: musb: dsps: fix error return code in dsps_create_musb_pdev() usb: gadget: s3c2410_udc: fix error return code in s3c2410_udc_probe() usb: gadget: r8a66597-udc: fix error return code in r8a66597_probe() usb: gadget: m66592-udc: fix error return code in m66592_probe() usb: gadget: fusb300_udc: fix error return code in fusb300_probe() usb: gadget: dummy_hcd: fix error return code in init() usb: gadget: fix error return code in configfs_composite_bind() Wolfram Sang (2): usb: gadget: don't check resource with
Re: [GIT PATCH] USB fixes for 3.10-rc3
On Thu, May 23, 2013 at 09:14:57AM -0700, Greg KH wrote: The following changes since commit f722406faae2d073cc1d01063d1123c35425939e: Linux 3.10-rc1 (2013-05-11 17:14:08 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ tags/usb-3.10-rc2 for you to fetch changes up to 2a0ebf80aa95cc758d4725f74a7016e992606a39: USB: cxacru: potential underflow in cxacru_cm_get_array() (2013-05-20 11:35:47 -0700) Linus, you will get a merge conflict with this pull request, in one of the USB host controller driver. The fixup should be obvious, but if you need me to resolve it, I can create another branch for 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: [RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver
On Thursday 23 May 2013, Alan Stern wrote: On Thu, 23 May 2013, Manjunath Goudar wrote: Also, you left out one thing that should still be here. What happened to the part about changing #if !defined(PCI_DRIVER) \ to #if !ENABLED(CONFIG_USB_OHCI_HCD_PCI) \ This section of the driver is gone now since 86510bb248 USB: OHCI: clarify Kconfig dependencies, so the change is no longer needed. Arnd -- 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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue
Sergei Subject: Re: [PATCH v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue Hello. On 23-05-2013 10:01, Ravi Babu wrote: removed unused nop xceiv (un_)register API's from all musb platform drivers Since when are they unused? Please refer to commit id 662dca54 : usb: otg: support for multiple transceivers by a single controller. Usb_get_phy() is used to get the of phy used by controller, phy bindings are done through DT. Signed-off-by: Ravi Babu ravib...@ti.com -- Ravi B -- 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 v1 7/9] usb: musb: dsps: use get-usb-phy by phandle for multi instance
Subject: Re: [PATCH v1 7/9] usb: musb: dsps: use get-usb-phy by phandle for multi instance On 23-05-2013 10:01, Ravi Babu wrote: In case of mutli instance support, use get-phy object using phandle to return to repsective phy xceiv object for each instance Only respective and s/xceiv/transceiver/. Ok. Signed-off-by: Ravi Babu ravib...@ti.com -- Ravi B -- 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 v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx
Sergei +phy1: usbphy-gs70@44e10620 { +compatible = ti,dsps-usbphy; +reg = 0x44e10620 0x8 + 0x44e10648 0x4; +reg-names = phy_ctrl,phy_wkup; +id = 0; +}; + +phy2: usbphy-gs70@44e10628 { +compatible = ti,dsps-usbphy; +reg = 0x44e10628 0x8 + 0x44e10648 0x4; The second register conflicts with phy1. The two instances of phy uses common phy wakeup register. -- Ravi B -- 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: [RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver
On Thu, 23 May 2013, Arnd Bergmann wrote: On Thursday 23 May 2013, Alan Stern wrote: On Thu, 23 May 2013, Manjunath Goudar wrote: Also, you left out one thing that should still be here. What happened to the part about changing #if !defined(PCI_DRIVER) \ to #if !ENABLED(CONFIG_USB_OHCI_HCD_PCI) \ This section of the driver is gone now since 86510bb248 USB: OHCI: clarify Kconfig dependencies, so the change is no longer needed. I don't know what tree you're referring to. That commit is not present in Greg's usb-linus or usb-next branches. The usb-next branch is what I use for new development. 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: [RFC V6 PATCH 3/3] USB: OHCI: make ohci-pci a separate driver
On Thursday 23 May 2013, Alan Stern wrote: This section of the driver is gone now since 86510bb248 USB: OHCI: clarify Kconfig dependencies, so the change is no longer needed. I don't know what tree you're referring to. That commit is not present in Greg's usb-linus or usb-next branches. The usb-next branch is what I use for new development. Sorry, my mistake. I had looked at a temporary tree based on linux-next, and I thought that Greg had applied my patch and put it into usb-next, but instead it's a patch I had sitting on the branch I used for build testing. I have not yet submitted that one again, and I'm sure that Manjunath doesn't have it on his machine, so your comment still applies. Arnd -- 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 v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx
Hello. On 05/23/2013 09:13 PM, B, Ravi wrote: + phy1: usbphy-gs70@44e10620 { + compatible = ti,dsps-usbphy; + reg = 0x44e10620 0x8 + 0x44e10648 0x4; + reg-names = phy_ctrl,phy_wkup; + id = 0; + }; + + phy2: usbphy-gs70@44e10628 { + compatible = ti,dsps-usbphy; + reg = 0x44e10628 0x8 + 0x44e10648 0x4; The second register conflicts with phy1. The two instances of phy uses common phy wakeup register. That's why there is a resource conflict. Have you actually tried to instantiate the devices out of such tree? This register should be declared somewhere above the PHYs I think... -- Ravi B WBR, Sergei -- 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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue
Hello. On 05/23/2013 09:07 PM, B, Ravi wrote: removed unused nop xceiv (un_)register API's from all musb platform drivers Since when are they unused? Please refer to commit id 662dca54 : usb: otg: support for multiple transceivers by a single controller. Usb_get_phy() is used to get the of phy used by controller, phy bindings are done through DT. Why are you sure that all these platforms support DT (in all configurations)? It seems to me that you're simply breaking the patched glue layers with this patch. I'll let Felipe decide the fate of this patch though... Signed-off-by: Ravi Babu ravib...@ti.com -- Ravi B WBR, Sergei -- 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/7] USB: gadget: atmel_usba: allow multi instance
On Mon, May 20, 2013 at 06:25:55PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: drop static struct usba_udc the_udc Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: linux-usb@vger.kernel.org Acked-by: Felipe Balbi ba...@ti.com --- drivers/usb/gadget/atmel_usba_udc.c | 36 +-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index d2ffd04..eea57a3 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -27,9 +27,6 @@ #include atmel_usba_udc.h - -static struct usba_udc the_udc; - #ifdef CONFIG_USB_GADGET_DEBUG_FS #include linux/debugfs.h #include linux/uaccess.h @@ -1013,16 +1010,13 @@ static void nop_release(struct device *dev) } -static struct usba_udc the_udc = { - .gadget = { - .ops= usba_udc_ops, - .ep_list= LIST_HEAD_INIT(the_udc.gadget.ep_list), - .max_speed = USB_SPEED_HIGH, - .name = atmel_usba_udc, - .dev= { - .init_name = gadget, - .release= nop_release, - }, +struct usb_gadget usba_gadget_template = { + .ops= usba_udc_ops, + .max_speed = USB_SPEED_HIGH, + .name = atmel_usba_udc, + .dev= { + .init_name = gadget, + .release= nop_release, }, }; @@ -1839,10 +1833,17 @@ static int __init usba_udc_probe(struct platform_device *pdev) struct usba_platform_data *pdata = pdev-dev.platform_data; struct resource *regs, *fifo; struct clk *pclk, *hclk; - struct usba_udc *udc = the_udc; + struct usba_udc *udc; static struct usba_ep *usba_ep; int irq, ret, i; + udc = devm_kzalloc(pdev-dev, sizeof(*udc), GFP_KERNEL); + if (!udc) + return -ENOMEM; + + udc-gadget = usba_gadget_template; + INIT_LIST_HEAD(udc-gadget.ep_list); + regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); if (!regs || !fifo || !pdata) @@ -1897,8 +1898,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) goto err_alloc_ep; udc-usba_ep = usba_ep; - - the_udc.gadget.ep0 = usba_ep[0].ep; + udc-gadget.ep0 = usba_ep[0].ep; INIT_LIST_HEAD(usba_ep[0].ep.ep_list); usba_ep[0].ep_regs = udc-regs + USBA_EPT_BASE(0); @@ -1907,7 +1907,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) usba_ep[0].ep.ops = usba_ep_ops; usba_ep[0].ep.name = pdata-ep[0].name; usba_ep[0].ep.maxpacket = pdata-ep[0].fifo_size; - usba_ep[0].udc = the_udc; + usba_ep[0].udc = udc; INIT_LIST_HEAD(usba_ep[0].queue); usba_ep[0].fifo_size = pdata-ep[0].fifo_size; usba_ep[0].nr_banks = pdata-ep[0].nr_banks; @@ -1924,7 +1924,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) ep-ep.ops = usba_ep_ops; ep-ep.name = pdata-ep[i].name; ep-ep.maxpacket = pdata-ep[i].fifo_size; - ep-udc = the_udc; + ep-udc = udc; INIT_LIST_HEAD(ep-queue); ep-fifo_size = pdata-ep[i].fifo_size; ep-nr_banks = pdata-ep[i].nr_banks; -- 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 -- balbi signature.asc Description: Digital signature
Re: [PATCH 1/7] USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc
On Mon, May 20, 2013 at 06:25:54PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: so we can have multiple usb gadget instance Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: linux-usb@vger.kernel.org Acked-by: Felipe Balbi ba...@ti.com -- balbi signature.asc Description: Digital signature
Re: [PATCH 3/7] USB: gadget: atmel_usba: add DT support
On Mon, May 20, 2013 at 06:25:56PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: Allow to compile the driver all the time if AT91 enabled. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: linux-usb@vger.kernel.org Acked-by: Felipe Balbi ba...@ti.com -- balbi signature.asc Description: Digital signature
Re: usb-storage read transfer sizes with Wireless USB HCD (HWA)
On Thu, 23 May 2013, Thomas Pugliese wrote: Hi, I am attempting to get a wireless USB mass storage device to work with an HWA as the host controller. Everything works fine as long as the SCSI reads are smaller than 4kbytes. When the usb-storage driver receives the first 16kB read, it breaks it up into 4-4kB URBs and sends it to the HWA host controller. This causes problems because the max packet size of the bulk in endpoint on the wireless device is 3854 bytes. It responds to the host poll request with 7kB of data (2x3.5kB packets) which causes a babble since the host was only expecting 4kB. Is there a way to get the usb-storage driver to send the entire buffer down to the HCD in a single URB instead of breaking it up? I assume it has something to do with the SG or DMA settings when the HCD is created but I'm not sure what the correct settings are. You're right -- the host controller driver must support SG transfers. I have no idea what would be involved in adding this support to the HWA driver. Another option would be for usb-storage to take into account the max packet size when segmenting the requests and make sure all but the last segment are multiples of the max packet size. usb-storage doesn't break requests up at all. The requests are already segmented by the block layer, which transfers data in multiples of the page size (which is 4 KB). I think you will have a very difficult time breaking up 4-KB units into pieces that are multiples of 3.5 KB. The only solution is to use bounce buffers. 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: usb-storage read transfer sizes with Wireless USB HCD (HWA)
On Thu, 23 May 2013, Alan Stern wrote: On Thu, 23 May 2013, Thomas Pugliese wrote: Hi, I am attempting to get a wireless USB mass storage device to work with an HWA as the host controller. Everything works fine as long as the SCSI reads are smaller than 4kbytes. When the usb-storage driver receives the first 16kB read, it breaks it up into 4-4kB URBs and sends it to the HWA host controller. This causes problems because the max packet size of the bulk in endpoint on the wireless device is 3854 bytes. It responds to the host poll request with 7kB of data (2x3.5kB packets) which causes a babble since the host was only expecting 4kB. Is there a way to get the usb-storage driver to send the entire buffer down to the HCD in a single URB instead of breaking it up? I assume it has something to do with the SG or DMA settings when the HCD is created but I'm not sure what the correct settings are. You're right -- the host controller driver must support SG transfers. I have no idea what would be involved in adding this support to the HWA driver. Another option would be for usb-storage to take into account the max packet size when segmenting the requests and make sure all but the last segment are multiples of the max packet size. usb-storage doesn't break requests up at all. The requests are already segmented by the block layer, which transfers data in multiples of the page size (which is 4 KB). I think you will have a very difficult time breaking up 4-KB units into pieces that are multiples of 3.5 KB. The only solution is to use bounce buffers. Alan Stern Thanks Alan, Wireless USB does allow the host to force the device to use a smaller packet size than it advertises in its endpoint descriptor as long as the size is a multiple of 512 bytes. I can update the HWA so that it will impose a packet size on the device that divides evenly into 4k and submit a patch once is working. Tom -- 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] usb: ehci-s5p: skip phy setup for Exynos5440 based platforms
From: Thomas Abraham thomas...@samsung.com Exynos5440 does not require any explict USB phy configuration. So skip the USB phy configuration for Exynos5440 based platforms. Signed-off-by: Thomas Abraham thomas...@samsung.com Signed-off-by: Jingoo Han jg1@samsung.com --- Changes since v2: - changed all occurrences of s5p_ehci-pdata-phy*. - set s5p_ehci-pdata to NULL. Changes since v1: - re-based on the latest 'linux-next' tree drivers/usb/host/ehci-s5p.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index 379037f..32ba4d5 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c @@ -101,6 +101,13 @@ static int s5p_ehci_probe(struct platform_device *pdev) return -ENOMEM; } s5p_ehci = to_s5p_ehci(hcd); + + if (of_device_is_compatible(pdev-dev.of_node, + samsung,exynos5440-ehci)) { + s5p_ehci-pdata = NULL; + goto skip_phy; + } + phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2); if (IS_ERR(phy)) { /* Fallback to pdata */ @@ -116,6 +123,8 @@ static int s5p_ehci_probe(struct platform_device *pdev) s5p_ehci-otg = phy-otg; } +skip_phy: + s5p_ehci-clk = devm_clk_get(pdev-dev, usbhost); if (IS_ERR(s5p_ehci-clk)) { @@ -156,7 +165,7 @@ static int s5p_ehci_probe(struct platform_device *pdev) if (s5p_ehci-phy) usb_phy_init(s5p_ehci-phy); - else if (s5p_ehci-pdata-phy_init) + else if (s5p_ehci-pdata s5p_ehci-pdata-phy_init) s5p_ehci-pdata-phy_init(pdev, USB_PHY_TYPE_HOST); ehci = hcd_to_ehci(hcd); @@ -178,7 +187,7 @@ static int s5p_ehci_probe(struct platform_device *pdev) fail_add_hcd: if (s5p_ehci-phy) usb_phy_shutdown(s5p_ehci-phy); - else if (s5p_ehci-pdata-phy_exit) + else if (s5p_ehci-pdata s5p_ehci-pdata-phy_exit) s5p_ehci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST); fail_io: clk_disable_unprepare(s5p_ehci-clk); @@ -199,7 +208,7 @@ static int s5p_ehci_remove(struct platform_device *pdev) if (s5p_ehci-phy) usb_phy_shutdown(s5p_ehci-phy); - else if (s5p_ehci-pdata-phy_exit) + else if (s5p_ehci-pdata s5p_ehci-pdata-phy_exit) s5p_ehci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST); clk_disable_unprepare(s5p_ehci-clk); @@ -234,7 +243,7 @@ static int s5p_ehci_suspend(struct device *dev) if (s5p_ehci-phy) usb_phy_shutdown(s5p_ehci-phy); - else if (s5p_ehci-pdata-phy_exit) + else if (s5p_ehci-pdata s5p_ehci-pdata-phy_exit) s5p_ehci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST); clk_disable_unprepare(s5p_ehci-clk); @@ -255,7 +264,7 @@ static int s5p_ehci_resume(struct device *dev) if (s5p_ehci-phy) usb_phy_init(s5p_ehci-phy); - else if (s5p_ehci-pdata-phy_init) + else if (s5p_ehci-pdata s5p_ehci-pdata-phy_init) s5p_ehci-pdata-phy_init(pdev, USB_PHY_TYPE_HOST); /* DMA burst Enable */ @@ -277,6 +286,7 @@ static const struct dev_pm_ops s5p_ehci_pm_ops = { #ifdef CONFIG_OF static const struct of_device_id exynos_ehci_match[] = { { .compatible = samsung,exynos4210-ehci }, + { .compatible = samsung,exynos5440-ehci }, {}, }; MODULE_DEVICE_TABLE(of, exynos_ehci_match); -- 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
Re: [PATCH] build some drivers only when compile-testing
On 05/23/2013 09:01:40 AM, Ben Hutchings wrote: On Wed, 2013-05-22 at 19:23 -0700, Greg Kroah-Hartman wrote: On Wed, May 22, 2013 at 11:18:46AM +0200, Jiri Slaby wrote: Some drivers can be built on more platforms than they run on. This causes users and distributors packaging burden when they have to manually deselect some drivers from their allmodconfigs. Or sometimes it is even impossible to disable the drivers without patching the kernel. Introduce a new config option COMPILE_TEST and make all those drivers to depend on the platform they run on, or on the COMPILE_TEST option. Now, when users/distributors choose COMPILE_TEST=n they will not have the drivers in their allmodconfig setups, but developers still can compile-test them with COMPILE_TEST=y. I understand the urge, and it's getting hard for distros to handle these drivers that just don't work on other architectures, but it's really valuable to ensure that they build properly, for those of us that don't have many/any cross compilers set up. In http://landley.net/aboriginal/bin grab the cross-compiler-*.tar.bz2 tarballs, extract them, add the bin subdirectory of each to the $PATH. Congratulations, you have cross compilers set up. (They're statically linked and relocatable, so should run just about anywhere. If they don't, let me know and I'll fix it.) Example build: make ARCH=sparc sparc32_defconfig PATH=/home/landley/simple-cross-compiler-sparc/bin:$PATH \ make ARCH=sparc CROSS_COMPILE=sparc- Rob-- 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 v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx
Subject: Re: [PATCH v1 8/9] usb: phy: dts: Adding usbphy DT bindings for am33xx Hello. On 05/23/2013 09:13 PM, B, Ravi wrote: + phy1: usbphy-gs70@44e10620 { + compatible = ti,dsps-usbphy; + reg = 0x44e10620 0x8 + 0x44e10648 0x4; + reg-names = phy_ctrl,phy_wkup; + id = 0; + }; + + phy2: usbphy-gs70@44e10628 { + compatible = ti,dsps-usbphy; + reg = 0x44e10628 0x8 + 0x44e10648 0x4; The second register conflicts with phy1. The two instances of phy uses common phy wakeup register. That's why there is a resource conflict. Have you actually tried to instantiate the devices out of such tree? This register should be declared somewhere above the PHYs I think... I did not face any problem with this, I have tested both instances of phy used by dual instance controller, worked fine. What do you suggest, in case of common register which both phy have to use this for wakeup functionality. The DT should support this. What do you suggest in such case? -- Ravi B -- 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 v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue
Subject: Re: [PATCH v1 2/9] usb: musb: nop: remove unused nop_xceiv_(un)register APIs from glue Hello. On 05/23/2013 09:07 PM, B, Ravi wrote: removed unused nop xceiv (un_)register API's from all musb platform drivers Since when are they unused? Please refer to commit id 662dca54 : usb: otg: support for multiple transceivers by a single controller. Usb_get_phy() is used to get the of phy used by controller, phy bindings are done through DT. Why are you sure that all these platforms support DT (in all configurations)? It seems to me that you're simply breaking the patched glue layers with this patch. I'll let Felipe decide the fate of this patch though... You are correct, the bindings of phy and controller need not to done through DT alone, there is a saperate API Phy API's available for such bindings done in respective board platform files. Signed-off-by: Ravi Babu ravib...@ti.com -- Ravi B WBR, Sergei -- 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