Re: [PATCH 2/6] usb: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 10:30:36AM +0800, Peter Chen wrote: > On Wed, Jan 30, 2013 at 04:29:38PM +0100, Sascha Hauer wrote: > > From: Michael Grzeschik > > > > This adds two little devicetree helper functions for determining the > > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from > > the devicetree. > > > > Signed-off-by: Michael Grzeschik > > Signed-off-by: Marc Kleine-Budde > > Signed-off-by: Sascha Hauer > > --- > > drivers/usb/usb-common.c | 69 > > ++ > > include/linux/usb/of.h | 27 ++ > > include/linux/usb/otg.h |7 + > > include/linux/usb/phy.h |9 ++ > > 4 files changed, 112 insertions(+) > > create mode 100644 include/linux/usb/of.h > > > > diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c > > index d29503e..1c0292c 100644 > > --- a/drivers/usb/usb-common.c > > +++ b/drivers/usb/usb-common.c > > @@ -14,6 +14,9 @@ > > #include > > #include > > #include > > +#include > > +#include > > +#include > > > > const char *usb_speed_string(enum usb_device_speed speed) > > { > > @@ -32,4 +35,70 @@ const char *usb_speed_string(enum usb_device_speed speed) > > } > > EXPORT_SYMBOL_GPL(usb_speed_string); > > > > +#ifdef CONFIG_OF > > +static const char *usb_dr_modes[] = { > > + [USB_DR_MODE_UNKNOWN] = "", > > + [USB_DR_MODE_HOST] = "host", > > + [USB_DR_MODE_PERIPHERAL]= "peripheral", > > + [USB_DR_MODE_OTG] = "otg", > > +}; > > + > > +/** > > + * of_usb_get_dr_mode - Get dual role mode for given device_node > > + * @np:Pointer to the given device_node > > + * > > + * The function gets phy interface string from property 'dr_mode', > > + * and returns the correspondig enum usb_phy_dr_mode > > + */ > > +enum usb_phy_dr_mode of_usb_get_dr_mode(struct device_node *np) > The word "phy" at usb_phy_dr_mode may cause misunderstand, just usb_dr_mode > is ok ok, changed. > > +{ > > + const char *dr_mode; > > + int err, i; > > + > > + err = of_property_read_string(np, "dr_mode", &dr_mode); > > + if (err < 0) > > + return USB_DR_MODE_UNKNOWN; > > + > > + for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) > > + if (!strcasecmp(dr_mode, usb_dr_modes[i])) > > + return i; > Just curious, why not using strcmp? Probably because this is based on drivers/of/of_net.c which uses strcasecmp. I never heard that devicetrees are case insensitive, so I'll change this to strcmp. > > + > > + return USB_DR_MODE_UNKNOWN; > > +} > > + > > +#ifdef CONFIG_OF > > +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); > > +enum usb_phy_dr_mode of_usb_get_dr_mode(struct device_node *np); > > +#else > > +static inline enum usb_phy_interface of_usb_get_phy_mode(struct > > device_node *np) > > +{ > > + return USBPHY_INTERFACE_MODE_NA; > > +} > > + > > +static inline enum usb_phy_dr_mode of_usb_get_dr_mode(struct device_node > > *np) > > +{ > > + return USB_DR_MODE_UNKNOWN; > > +} > For, dr_mode, if value has not existed, you use *_UNKNOWN, why > for usbphy, you use *_NA. It is better uniform. yup, fixed. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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/6] usb: add devicetree helpers for determining dr_mode and phy_type
On Thursday 31 January 2013 01:13 PM, Sascha Hauer wrote: On Thu, Jan 31, 2013 at 11:44:21AM +0530, kishon wrote: Hi, On Wednesday 30 January 2013 08:59 PM, Sascha Hauer wrote: From: Michael Grzeschik This adds two little devicetree helper functions for determining the dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from the devicetree. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/usb/usb-common.c | 69 ++ include/linux/usb/of.h | 27 ++ include/linux/usb/otg.h |7 + include/linux/usb/phy.h |9 ++ 4 files changed, 112 insertions(+) create mode 100644 include/linux/usb/of.h diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c index d29503e..1c0292c 100644 --- a/drivers/usb/usb-common.c +++ b/drivers/usb/usb-common.c @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include const char *usb_speed_string(enum usb_device_speed speed) { @@ -32,4 +35,70 @@ const char *usb_speed_string(enum usb_device_speed speed) } EXPORT_SYMBOL_GPL(usb_speed_string); +#ifdef CONFIG_OF +static const char *usb_dr_modes[] = { + [USB_DR_MODE_UNKNOWN] = "", + [USB_DR_MODE_HOST] = "host", + [USB_DR_MODE_PERIPHERAL]= "peripheral", + [USB_DR_MODE_OTG] = "otg", +}; + +/** + * of_usb_get_dr_mode - Get dual role mode for given device_node + * @np:Pointer to the given device_node + * + * The function gets phy interface string from property 'dr_mode', + * and returns the correspondig enum usb_phy_dr_mode + */ +enum usb_phy_dr_mode of_usb_get_dr_mode(struct device_node *np) +{ + const char *dr_mode; + int err, i; + + err = of_property_read_string(np, "dr_mode", &dr_mode); + if (err < 0) + return USB_DR_MODE_UNKNOWN; + + for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) + if (!strcasecmp(dr_mode, usb_dr_modes[i])) + return i; + + return USB_DR_MODE_UNKNOWN; +} +EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); + +static const char *usbphy_modes[] = { + [USBPHY_INTERFACE_MODE_NA] = "", + [USBPHY_INTERFACE_MODE_UTMI]= "utmi", + [USBPHY_INTERFACE_MODE_UTMIW] = "utmi_wide", + [USBPHY_INTERFACE_MODE_ULPI]= "ulpi", + [USBPHY_INTERFACE_MODE_SERIAL] = "serial", + [USBPHY_INTERFACE_MODE_HSIC]= "hsic", +}; + +/** + * of_get_usbphy_mode - Get phy mode for given device_node %s/of_get_usbphy_mode/of_usb_get_phy_mode + * @np:Pointer to the given device_node + * + * The function gets phy interface string from property 'phy_type', + * and returns the correspondig enum usb_phy_interface + */ +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) +{ You agreed to move this function inside usb/phy.. no? Yes, I did, but as mentioned in the introduction mail, the chipidea driver has to determine the phy type even when phy support (aka CONFIG_USB_OTG_UTILS) is disabled, so I can't put it in phy/phy.c. I could add a phy/of.c though. Would that be better? Yes. I think that would be better. Thanks Kishon -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: GADGET: optionally force full-speed for net2280 UDC
Hi, On Wed, Jan 30, 2013 at 04:40:14PM -0500, Alan Stern wrote: > This patch (as1656) adds a module parameter to the net2280 UDC driver > to force full-speed operation. It is intended for testing purposes, > where one wants to check how well a full-speed device performs when > attached to a high-speed bus. Without this parameter it would be > necessary to interpose a full-speed hub; otherwise the net2280 would > connect at high speed. > > Signed-off-by: Alan Stern I wonder if it wouldn't be better to expose this throught debugfs. I have been thinking on providing a generic UDC debugfs interface. For now, however, this can definitely go in: Acked-by: Felipe Balbi -- balbi signature.asc Description: Digital signature
Re: [PATCH] USB: GADGET: optionally force full-speed for net2280 UDC
Hi, On Thu, Jan 31, 2013 at 06:35:55AM +0100, Greg KH wrote: > On Wed, Jan 30, 2013 at 04:40:14PM -0500, Alan Stern wrote: > > This patch (as1656) adds a module parameter to the net2280 UDC driver > > to force full-speed operation. It is intended for testing purposes, > > where one wants to check how well a full-speed device performs when > > attached to a high-speed bus. Without this parameter it would be > > necessary to interpose a full-speed hub; otherwise the net2280 would > > connect at high speed. > > > > Signed-off-by: Alan Stern > > > > --- > > > > drivers/usb/gadget/net2280.c | 15 +++ > > 1 file changed, 15 insertions(+) > > Felipe, need me to just take this as-is, or do you want to queue it up > to one of your trees (I ask as you already sent me a huge set of 3.9 > patches and don't know if you are going to have others coming.) > > What ever is easiest for you, You can take this in patch form. I have given my Acked-by on the original patch. Thank you -- balbi signature.asc Description: Digital signature
[PATCH v2] Add USB of helpers and use them in the chipidea driver
changes since v1: - move phy specific of helper to drivers/usb/phy/of.c - use strcmp instead of strcasecmp for matching property values - change usb_phy_dr_mode to usb_dr_mode - change USBPHY_INTERFACE_MODE_NA to USBPHY_INTERFACE_MODE_UNKNOWN - add copyright header to new files - chipidea: drop mdelay at end of PTS/PTW setup - chipidea: implement lpm core type handling for PTS/PTW Sascha Michael Grzeschik (3): USB: add devicetree helpers for determining dr_mode and phy_type USB: chipidea: ci13xxx-imx: create dynamic platformdata USB: chipidea: add PTW and PTS handling Sascha Hauer (3): USB: move bulk of otg/otg.c to phy/phy.c USB chipidea: introduce dual role mode pdata flags USB chipidea i.MX: introduce dr_mode property .../devicetree/bindings/usb/ci13xxx-imx.txt|6 + drivers/usb/chipidea/bits.h| 14 +- drivers/usb/chipidea/ci13xxx_imx.c | 29 +- drivers/usb/chipidea/core.c| 60 ++- drivers/usb/otg/otg.c | 423 --- drivers/usb/phy/Makefile |2 + drivers/usb/phy/phy.c | 434 drivers/usb/usb-common.c | 36 ++ include/linux/usb/chipidea.h |3 +- include/linux/usb/of.h | 27 ++ include/linux/usb/otg.h|7 + include/linux/usb/phy.h|9 + 12 files changed, 609 insertions(+), 441 deletions(-) create mode 100644 drivers/usb/phy/phy.c create mode 100644 include/linux/usb/of.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 4/6] USB: chipidea: add PTW and PTS handling
From: Michael Grzeschik This patch makes it possible to configure the PTW and PTS bits inside the portsc register for host and device mode before the driver starts and the phy can be addressed as hardware implementation is designed. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +++ drivers/usb/chipidea/bits.h| 14 ++- drivers/usb/chipidea/ci13xxx_imx.c |3 ++ drivers/usb/chipidea/core.c| 39 include/linux/usb/chipidea.h |1 + 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt index 5778b9c..dd42ccd 100644 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt @@ -5,6 +5,11 @@ Required properties: - reg: Should contain registers location and length - interrupts: Should contain controller interrupt +Recommended properies: +- phy_type: the type of the phy connected to the core. Should be one + of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this + property the PORTSC register won't be touched + Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port - fsl,usbmisc: phandler of non-core register device, with one argument diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h index 050de85..d8ffc2f 100644 --- a/drivers/usb/chipidea/bits.h +++ b/drivers/usb/chipidea/bits.h @@ -48,10 +48,22 @@ #define PORTSC_SUSP BIT(7) #define PORTSC_HSPBIT(9) #define PORTSC_PTC(0x0FUL << 16) +/* PTS and PTW for non lpm version only */ +#define PORTSC_PTS(d) d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0)) +#define PORTSC_PTWBIT(28) /* DEVLC */ #define DEVLC_PSPD(0x03UL << 25) -#defineDEVLC_PSPD_HS (0x02UL << 25) +#define DEVLC_PSPD_HS (0x02UL << 25) +#define DEVLC_PTW BIT(27) +#define DEVLC_STS BIT(28) +#define DEVLC_PTS(d) (((d) & 0x7) << 29) + +/* Encoding for DEVLC_PTS and PORTSC_PTS */ +#define PTS_UTMI 0 +#define PTS_ULPI 2 +#define PTS_SERIAL3 +#define PTS_HSIC 4 /* OTGSC */ #define OTGSC_IDPU BIT(5) diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index 69024e0..ebc1148 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "ci.h" #include "ci13xxx_imx.h" @@ -112,6 +113,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) CI13XXX_PULLUP_ON_VBUS | CI13XXX_DISABLE_STREAMING; + pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node); + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 57cae1f..a3ec29d 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -67,6 +67,8 @@ #include #include #include +#include +#include #include "ci.h" #include "udc.h" @@ -211,6 +213,41 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base) return 0; } +static void hw_phymode_configure(struct ci13xxx *ci) +{ + u32 portsc, lpm; + + switch (ci->platdata->phy_mode) { + case USBPHY_INTERFACE_MODE_UTMI: + portsc = PORTSC_PTS(PTS_UTMI); + lpm = DEVLC_PTS(PTS_UTMI); + break; + case USBPHY_INTERFACE_MODE_UTMIW: + portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW; + lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW; + break; + case USBPHY_INTERFACE_MODE_ULPI: + portsc = PORTSC_PTS(PTS_ULPI); + lpm = DEVLC_PTS(PTS_ULPI); + break; + case USBPHY_INTERFACE_MODE_SERIAL: + portsc = PORTSC_PTS(PTS_SERIAL); + lpm = DEVLC_PTS(PTS_SERIAL); + break; + case USBPHY_INTERFACE_MODE_HSIC: + portsc = PORTSC_PTS(PTS_HSIC); + lpm = DEVLC_PTS(PTS_HSIC); + break; + default: + return; + } + + if (ci->hw_bank.lpm) + hw_write(ci, OP_PORTSC, DEVLC_PTS(7) | DEVLC_PTW, lpm); + else + hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc); +} + /** * hw_device_reset: resets chip (execute without interruption) * @ci: the controller @@ -476,6 +513,8 @@ static int ci_hdrc_probe(struct platform_device *pdev) : CI_ROLE_GAD
[PATCH 1/6] USB: move bulk of otg/otg.c to phy/phy.c
Most of otg/otg.c is not otg specific, but phy specific, so move it to the phy directory. Signed-off-by: Sascha Hauer Reported-by: kishon Cc: Felipe Balbi --- drivers/usb/otg/otg.c| 423 - drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy.c| 424 ++ 3 files changed, 425 insertions(+), 423 deletions(-) create mode 100644 drivers/usb/phy/phy.c diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c index e181439..358cfd9 100644 --- a/drivers/usb/otg/otg.c +++ b/drivers/usb/otg/otg.c @@ -8,432 +8,9 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ - -#include #include -#include -#include -#include -#include -#include - #include -static LIST_HEAD(phy_list); -static LIST_HEAD(phy_bind_list); -static DEFINE_SPINLOCK(phy_lock); - -static struct usb_phy *__usb_find_phy(struct list_head *list, - enum usb_phy_type type) -{ - struct usb_phy *phy = NULL; - - list_for_each_entry(phy, list, head) { - if (phy->type != type) - continue; - - return phy; - } - - return ERR_PTR(-ENODEV); -} - -static struct usb_phy *__usb_find_phy_dev(struct device *dev, - struct list_head *list, u8 index) -{ - struct usb_phy_bind *phy_bind = NULL; - - list_for_each_entry(phy_bind, list, list) { - if (!(strcmp(phy_bind->dev_name, dev_name(dev))) && - phy_bind->index == index) { - if (phy_bind->phy) - return phy_bind->phy; - else - return ERR_PTR(-EPROBE_DEFER); - } - } - - return ERR_PTR(-ENODEV); -} - -static struct usb_phy *__of_usb_find_phy(struct device_node *node) -{ - struct usb_phy *phy; - - list_for_each_entry(phy, &phy_list, head) { - if (node != phy->dev->of_node) - continue; - - return phy; - } - - return ERR_PTR(-ENODEV); -} - -static void devm_usb_phy_release(struct device *dev, void *res) -{ - struct usb_phy *phy = *(struct usb_phy **)res; - - usb_put_phy(phy); -} - -static int devm_usb_phy_match(struct device *dev, void *res, void *match_data) -{ - return res == match_data; -} - -/** - * devm_usb_get_phy - find the USB PHY - * @dev - device that requests this phy - * @type - the type of the phy the controller requires - * - * Gets the phy using usb_get_phy(), and associates a device with it using - * devres. On driver detach, release function is invoked on the devres data, - * then, devres data is freed. - * - * For use by USB host and peripheral drivers. - */ -struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type) -{ - struct usb_phy **ptr, *phy; - - ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return NULL; - - phy = usb_get_phy(type); - if (!IS_ERR(phy)) { - *ptr = phy; - devres_add(dev, ptr); - } else - devres_free(ptr); - - return phy; -} -EXPORT_SYMBOL(devm_usb_get_phy); - -/** - * usb_get_phy - find the USB PHY - * @type - the type of the phy the controller requires - * - * Returns the phy driver, after getting a refcount to it; or - * -ENODEV if there is no such phy. The caller is responsible for - * calling usb_put_phy() to release that count. - * - * For use by USB host and peripheral drivers. - */ -struct usb_phy *usb_get_phy(enum usb_phy_type type) -{ - struct usb_phy *phy = NULL; - unsigned long flags; - - spin_lock_irqsave(&phy_lock, flags); - - phy = __usb_find_phy(&phy_list, type); - if (IS_ERR(phy)) { - pr_err("unable to find transceiver of type %s\n", - usb_phy_type_string(type)); - goto err0; - } - - get_device(phy->dev); - -err0: - spin_unlock_irqrestore(&phy_lock, flags); - - return phy; -} -EXPORT_SYMBOL(usb_get_phy); - - /** - * devm_usb_get_phy_by_phandle - find the USB PHY by phandle - * @dev - device that requests this phy - * @phandle - name of the property holding the phy phandle value - * @index - the index of the phy - * - * Returns the phy driver associated with the given phandle value, - * after getting a refcount to it, -ENODEV if there is no such phy or - * -EPROBE_DEFER if there is a phandle to the phy, but the device is - * not yet loaded. While at that, it also associates the device with - * the phy using devres. On driver detach, release function is invoked - * on the devres data, then, devres data is freed. - * - * For use by USB host and peripheral drivers. - */ -struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, - const char *phandle, u8 index) -{ - struc
[PATCH 2/6] USB: add devicetree helpers for determining dr_mode and phy_type
From: Michael Grzeschik This adds two little devicetree helper functions for determining the dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from the devicetree. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy.c| 10 ++ drivers/usb/usb-common.c | 36 include/linux/usb/of.h | 27 +++ include/linux/usb/otg.h |7 +++ include/linux/usb/phy.h |9 + 6 files changed, 90 insertions(+) create mode 100644 include/linux/usb/of.h diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 9fa6327..e1be1e8 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -5,6 +5,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG obj-$(CONFIG_USB_OTG_UTILS)+= phy.o +obj-$(CONFIG_OF) += of.o obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o obj-$(CONFIG_OMAP_USB3)+= omap-usb3.o obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index ef35eb0..3ad4b5c 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -1,3 +1,13 @@ +/* + * phy.c -- USB phy handling + * + * Copyright (C) 2004 Texas Instruments + * + * 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. + */ #include #include #include diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c index d29503e..ad4d87d 100644 --- a/drivers/usb/usb-common.c +++ b/drivers/usb/usb-common.c @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include const char *usb_speed_string(enum usb_device_speed speed) { @@ -32,4 +35,37 @@ const char *usb_speed_string(enum usb_device_speed speed) } EXPORT_SYMBOL_GPL(usb_speed_string); +#ifdef CONFIG_OF +static const char *usb_dr_modes[] = { + [USB_DR_MODE_UNKNOWN] = "", + [USB_DR_MODE_HOST] = "host", + [USB_DR_MODE_PERIPHERAL]= "peripheral", + [USB_DR_MODE_OTG] = "otg", +}; + +/** + * of_usb_get_dr_mode - Get dual role mode for given device_node + * @np:Pointer to the given device_node + * + * The function gets phy interface string from property 'dr_mode', + * and returns the correspondig enum usb_dr_mode + */ +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) +{ + const char *dr_mode; + int err, i; + + err = of_property_read_string(np, "dr_mode", &dr_mode); + if (err < 0) + return USB_DR_MODE_UNKNOWN; + + for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) + if (!strcmp(dr_mode, usb_dr_modes[i])) + return i; + + return USB_DR_MODE_UNKNOWN; +} +EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); +#endif + MODULE_LICENSE("GPL"); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h new file mode 100644 index 000..4681a20 --- /dev/null +++ b/include/linux/usb/of.h @@ -0,0 +1,27 @@ +/* + * OF helpers for usb devices. + * + * This file is released under the GPLv2 + */ + +#ifndef __LINUX_USB_OF_H +#define __LINUX_USB_OF_H + +#include + +#ifdef CONFIG_OF +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); +#else +static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) +{ + return USBPHY_INTERFACE_MODE_UNKNOWN; +} + +static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) +{ + return USB_DR_MODE_UNKNOWN; +} +#endif + +#endif /* __LINUX_USB_OF_H */ diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index e8a5fe8..4e8bfbb 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -99,4 +99,11 @@ otg_start_srp(struct usb_otg *otg) /* for OTG controller drivers (and maybe other stuff) */ extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); +enum usb_dr_mode { + USB_DR_MODE_UNKNOWN, + USB_DR_MODE_HOST, + USB_DR_MODE_PERIPHERAL, + USB_DR_MODE_OTG, +}; + #endif /* __LINUX_USB_OTG_H */ diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 15847cb..5edddb1 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -12,6 +12,15 @@ #include #include +enum usb_phy_interface { + USBPHY_INTERFACE_MODE_UNKNOWN, + USBPHY_INTERFACE_MODE_UTMI, + USBPHY_INTERFACE_MODE_UTMIW, + USBPHY_INTERFACE_MODE_ULPI, + USBPHY_INTERFACE_MODE_SERIAL, + USBPHY_INTERFACE_MODE_HSIC, +}; + enum usb_phy_events { USB_EVENT_NONE, /* no events or cable disconnected */ USB_EVENT_VBUS, /* vbus va
[PATCH 6/6] USB chipidea i.MX: introduce dr_mode property
The dr_mode devicetree property allows to explicitly specify the host/peripheral/otg mode. This is necessary for boards without proper ID pin handling. Signed-off-by: Sascha Hauer --- Documentation/devicetree/bindings/usb/ci13xxx-imx.txt |1 + drivers/usb/chipidea/ci13xxx_imx.c|1 + 2 files changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt index dd42ccd..493a414 100644 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt @@ -9,6 +9,7 @@ Recommended properies: - phy_type: the type of the phy connected to the core. Should be one of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this property the PORTSC register won't be touched +- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index ebc1148..b598bb8f 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -114,6 +114,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) CI13XXX_DISABLE_STREAMING; pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node); + pdata->dr_mode = of_usb_get_dr_mode(pdev->dev.of_node); data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { -- 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 5/6] USB chipidea: introduce dual role mode pdata flags
Even if a chipidea core is otg capable the board may not. This allows to explicitly set the core to host/peripheral mode. Without these flags the driver falls back to the old behaviour. Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/core.c | 21 +++-- include/linux/usb/chipidea.h |2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index a3ec29d..b2dbf55 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -435,6 +435,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) struct resource *res; void __iomem*base; int ret; + int dr_mode; if (!dev->platform_data) { dev_err(dev, "platform data missing\n"); @@ -487,14 +488,22 @@ static int ci_hdrc_probe(struct platform_device *pdev) return -ENODEV; } + dr_mode = ci->platdata->dr_mode; + if (dr_mode == USB_DR_MODE_UNKNOWN) + dr_mode = USB_DR_MODE_OTG; + /* initialize role(s) before the interrupt is requested */ - ret = ci_hdrc_host_init(ci); - if (ret) - dev_info(dev, "doesn't support host\n"); + if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) { + ret = ci_hdrc_host_init(ci); + if (ret) + dev_info(dev, "doesn't support host\n"); + } - ret = ci_hdrc_gadget_init(ci); - if (ret) - dev_info(dev, "doesn't support gadget\n"); + if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) { + ret = ci_hdrc_gadget_init(ci); + if (ret) + dev_info(dev, "doesn't support gadget\n"); + } if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { dev_err(dev, "no supported roles\n"); diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 1a2aa18..b314647 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -20,7 +20,7 @@ struct ci13xxx_platform_data { #define CI13XXX_REQUIRE_TRANSCEIVERBIT(1) #define CI13XXX_PULLUP_ON_VBUS BIT(2) #define CI13XXX_DISABLE_STREAMING BIT(3) - + enum usb_dr_modedr_mode; #define CI13XXX_CONTROLLER_RESET_EVENT 0 #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 void(*notify_event) (struct ci13xxx *ci, unsigned event); -- 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 3/6] USB: chipidea: ci13xxx-imx: create dynamic platformdata
From: Michael Grzeschik This patch removes the limitation of having only one instance of the ci13xxx-imx platformdata and makes different configurations possible. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/ci13xxx_imx.c | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index 8c29122..69024e0 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data); /* End of common functions shared by usbmisc drivers*/ -static struct ci13xxx_platform_data ci13xxx_imx_platdata = { - .name = "ci13xxx_imx", - .flags = CI13XXX_REQUIRE_TRANSCEIVER | - CI13XXX_PULLUP_ON_VBUS | - CI13XXX_DISABLE_STREAMING, - .capoffset = DEF_CAPOFFSET, -}; - static int ci13xxx_imx_probe(struct platform_device *pdev) { struct ci13xxx_imx_data *data; + struct ci13xxx_platform_data *pdata; struct platform_device *plat_ci, *phy_pdev; struct device_node *phy_np; struct resource *res; @@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) && !usbmisc_ops) return -EPROBE_DEFER; + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n"); + return -ENOMEM; + } + + pdata->name = "ci13xxx_imx"; + pdata->capoffset = DEF_CAPOFFSET; + pdata->flags = CI13XXX_REQUIRE_TRANSCEIVER | + CI13XXX_PULLUP_ON_VBUS | + CI13XXX_DISABLE_STREAMING; + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); @@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) reg_vbus = NULL; } - ci13xxx_imx_platdata.phy = data->phy; + pdata->phy = data->phy; if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = devm_kzalloc(&pdev->dev, @@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) plat_ci = ci13xxx_add_device(&pdev->dev, pdev->resource, pdev->num_resources, - &ci13xxx_imx_platdata); + pdata); if (IS_ERR(plat_ci)) { ret = PTR_ERR(plat_ci); dev_err(&pdev->dev, -- 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] USB: EHCI: fix for leaking isochronous data
On Wed, Jan 30, 2013 at 04:35:02PM -0500, Alan Stern wrote: > This patch (as1653) fixes a bug in ehci-hcd. Unlike iTD entries, an > siTD entry in the periodic schedule may not complete until the frame > after the one it belongs to. Consequently, when scanning the periodic > schedule it is necessary to start with the frame _preceding_ the one > where the previous scan ended. > > Not doing this properly can result in memory leaks and failures to > complete isochronous URBs. > > Signed-off-by: Alan Stern > Reported-by: Andy Leiserson > > --- > > Greg: > > This patch is for 3.8. The same problem exists in 3.6 and 3.7, but the > code has changed in the meantime so they need a different patch. > Should I submit that one after this has been merged? Yes, I've marked this for stable (don't care about 3.6, that tree is end-of-life.) When you get the "this patch failed" email from my scripts trying to apply this to the 3.7 kernel tree, feel free to send me the fixed version for that kernel. thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/6] USB: add devicetree helpers for determining dr_mode and phy_type
Hi, On Thursday 31 January 2013 02:31 PM, Sascha Hauer wrote: From: Michael Grzeschik This adds two little devicetree helper functions for determining the dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from the devicetree. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy.c| 10 ++ drivers/usb/usb-common.c | 36 include/linux/usb/of.h | 27 +++ include/linux/usb/otg.h |7 +++ include/linux/usb/phy.h |9 + 6 files changed, 90 insertions(+) create mode 100644 include/linux/usb/of.h diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 9fa6327..e1be1e8 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -5,6 +5,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG obj-$(CONFIG_USB_OTG_UTILS) += phy.o +obj-$(CONFIG_OF) += of.o You've missed doing "git add ..usb/phy/of.c". obj-$(CONFIG_OMAP_USB2) += omap-usb2.o obj-$(CONFIG_OMAP_USB3) += omap-usb3.o obj-$(CONFIG_OMAP_CONTROL_USB)+= omap-control-usb.o diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index ef35eb0..3ad4b5c 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -1,3 +1,13 @@ +/* + * phy.c -- USB phy handling + * + * Copyright (C) 2004 Texas Instruments it's 2013 already :-P + * + * 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. But your *MODULE_LICENSE("GPL")* below tells it's only GPL. + */ . . . . MODULE_LICENSE("GPL"); Thanks Kishon -- 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 4/6] usb: chipidea: add PTW and PTS handling
Sascha Hauer a écrit : > On Wed, Jan 30, 2013 at 05:54:54PM +0100, Matthieu CASTET wrote: >>> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c >>> index 57cae1f..dcb650f 100644 >>> --- a/drivers/usb/chipidea/core.c >>> +++ b/drivers/usb/chipidea/core.c >>> @@ -67,6 +67,8 @@ >>> #include >>> #include >>> #include >>> +#include >>> +#include >>> >>> #include "ci.h" >>> #include "udc.h" >>> @@ -211,6 +213,42 @@ static int hw_device_init(struct ci13xxx *ci, void >>> __iomem *base) >>> return 0; >>> } >>> >>> +static void hw_phymode_configure(struct ci13xxx *ci) >>> +{ >>> + u32 portsc; >>> + >>> + /* >>> +* The lpm version has the corresponding bits in the devlc register. >>> +* Currently not implemented. >>> +*/ >>> + if (ci->hw_bank.lpm) >>> + return; >> Why you don't implement it ? >> >> If you don't implement it, I believe you should add a warning in order to >> catch >> it when used with lpm devices. > > I'm against adding a warning because current users seem to go well > without this setting. Adding a warning would lead to more confusion than > it would help. > > I could try and implement it, though I'm unsure about the register > layout. > > What I know from an earlier post from you is this: > > #define LPM_PTS(d) (((d)>>29)&7) > #define LPM_STS BIT(28) /* serial transceiver select */ > #define LPM_PTW BIT(27) /* parallel transceiver width */ > > Do you also know how LPM_PTS is decoded? I will say the same as not lpm device : PTS is made up from PORTSCx bits 25, 30 and 31. PTS is made up from devlc bits 31, 30 and 29. Also in my datasheet, they give a way to check if the bits are read only or read write [1]. I don't know if it is worth the trouble to check it. Matthieu [1] PTS This register bit pair is used in conjunction with the configuration constant VUSB_HS_PHY_TYPE to control which parallel transceiver interface is selected. If VUSB_HS_PHY_TYPE is set for 0, 1, 2, 3, 8 or 10 then this bit is read only. If VUSB_HS_PHY_TYPE is 4, 5, 6, 7, 9 or 11 then this bit is read/write. This field is reset to: '000b' if VUSB_HS_PHY_TYPE = 0, 4 UTMI/UTMI+ '001b' if VUSB_HS_PHY_TYPE = 1, 5 ULPI DDR '010b' if VUSB_HS_PHY_TYPE = 2, 6 ULPI '011b' if VUSB_HS_PHY_TYPE = 3, 7, 8, 9 Serial/1.1 PHY/IC_USB (FS Only) '100b' if VUSB_HS_PHY_TYPE = 10, 11 UTMI for HSIC PHY -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] USB: move bulk of otg/otg.c to phy/phy.c
Hi, On Thursday 31 January 2013 02:31 PM, Sascha Hauer wrote: Most of otg/otg.c is not otg specific, but phy specific, so move it to the phy directory. Signed-off-by: Sascha Hauer Reported-by: kishon Kishon Vijay Abraham I pls.. Thanks Kishon -- 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/6] USB: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 10:01:09AM +0100, Sascha Hauer wrote: > From: Michael Grzeschik > > This adds two little devicetree helper functions for determining the > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from > the devicetree. > > Signed-off-by: Michael Grzeschik > Signed-off-by: Marc Kleine-Budde > Signed-off-by: Sascha Hauer > --- > drivers/usb/phy/Makefile |1 + > drivers/usb/phy/phy.c| 10 ++ > drivers/usb/usb-common.c | 36 > include/linux/usb/of.h | 27 +++ > include/linux/usb/otg.h |7 +++ > include/linux/usb/phy.h |9 + > 6 files changed, 90 insertions(+) > create mode 100644 include/linux/usb/of.h > > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > index 9fa6327..e1be1e8 100644 > --- a/drivers/usb/phy/Makefile > +++ b/drivers/usb/phy/Makefile > @@ -5,6 +5,7 @@ > ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG > > obj-$(CONFIG_USB_OTG_UTILS) += phy.o > +obj-$(CONFIG_OF) += of.o > obj-$(CONFIG_OMAP_USB2) += omap-usb2.o > obj-$(CONFIG_OMAP_USB3) += omap-usb3.o > obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o > diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c > index ef35eb0..3ad4b5c 100644 > --- a/drivers/usb/phy/phy.c > +++ b/drivers/usb/phy/phy.c > @@ -1,3 +1,13 @@ > +/* > + * phy.c -- USB phy handling > + * > + * Copyright (C) 2004 Texas Instruments > + * > + * 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. > + */ Do you really mean to change the license of the file from GPLv2 to GPLv2+? Did TI agree to that licening change? I need some documentation from some TI people before I can ever accept something like this. 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
xhci streams bug
Hi, Started hacking streams support into qemu, trapped into this one: [ 218.807129] xhci_hcd :00:0f.0: ERROR Transfer event for disabled endpoint or incorrect stream ring [ 218.808087] xhci_hcd :00:0f.0: @3c32d560 38342000 0100 01078001 Triggers after xhci emulation stepping over the first link trb for a stream ring. I think it's because xhci doesn't manage the trb_address_map radix tree correctly. I can only find a single radix_tree_insert() call in the code, and that one is for the initial segment. But nobody seems to update the radix tree when linking the next segment ... cheers, Gerd -- 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/6] USB: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 10:20:59AM +0100, Greg KH wrote: > On Thu, Jan 31, 2013 at 10:01:09AM +0100, Sascha Hauer wrote: > > From: Michael Grzeschik > > > > This adds two little devicetree helper functions for determining the > > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from > > the devicetree. > > > > Signed-off-by: Michael Grzeschik > > Signed-off-by: Marc Kleine-Budde > > Signed-off-by: Sascha Hauer > > --- > > drivers/usb/phy/Makefile |1 + > > drivers/usb/phy/phy.c| 10 ++ > > drivers/usb/usb-common.c | 36 > > include/linux/usb/of.h | 27 +++ > > include/linux/usb/otg.h |7 +++ > > include/linux/usb/phy.h |9 + > > 6 files changed, 90 insertions(+) > > create mode 100644 include/linux/usb/of.h > > > > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > > index 9fa6327..e1be1e8 100644 > > --- a/drivers/usb/phy/Makefile > > +++ b/drivers/usb/phy/Makefile > > @@ -5,6 +5,7 @@ > > ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG > > > > obj-$(CONFIG_USB_OTG_UTILS)+= phy.o > > +obj-$(CONFIG_OF) += of.o > > obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o > > obj-$(CONFIG_OMAP_USB3)+= omap-usb3.o > > obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o > > diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c > > index ef35eb0..3ad4b5c 100644 > > --- a/drivers/usb/phy/phy.c > > +++ b/drivers/usb/phy/phy.c > > @@ -1,3 +1,13 @@ > > +/* > > + * phy.c -- USB phy handling > > + * > > + * Copyright (C) 2004 Texas Instruments > > + * > > + * 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. > > + */ > > Do you really mean to change the license of the file from GPLv2 to > GPLv2+? Did TI agree to that licening change? I need some > documentation from some TI people before I can ever accept something > like this. Sorry, the hunk above belongs to patch 1/6. I did not change the license, the header is a copy from drivers/usb/otg/otg.c which was GPLv2+ already. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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/6] USB: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 02:42:48PM +0530, kishon wrote: > Hi, > > On Thursday 31 January 2013 02:31 PM, Sascha Hauer wrote: > >From: Michael Grzeschik > > > >This adds two little devicetree helper functions for determining the > >dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from > >the devicetree. > > > >Signed-off-by: Michael Grzeschik > >Signed-off-by: Marc Kleine-Budde > >Signed-off-by: Sascha Hauer > >--- > > drivers/usb/phy/Makefile |1 + > > drivers/usb/phy/phy.c| 10 ++ > > drivers/usb/usb-common.c | 36 > > include/linux/usb/of.h | 27 +++ > > include/linux/usb/otg.h |7 +++ > > include/linux/usb/phy.h |9 + > > 6 files changed, 90 insertions(+) > > create mode 100644 include/linux/usb/of.h > > > >diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > >index 9fa6327..e1be1e8 100644 > >--- a/drivers/usb/phy/Makefile > >+++ b/drivers/usb/phy/Makefile > >@@ -5,6 +5,7 @@ > > ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG > > > > obj-$(CONFIG_USB_OTG_UTILS)+= phy.o > >+obj-$(CONFIG_OF)+= of.o > > You've missed doing "git add ..usb/phy/of.c". > > > obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o > > obj-$(CONFIG_OMAP_USB3)+= omap-usb3.o > > obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o > >diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c > >index ef35eb0..3ad4b5c 100644 > >--- a/drivers/usb/phy/phy.c > >+++ b/drivers/usb/phy/phy.c > >@@ -1,3 +1,13 @@ > >+/* > >+ * phy.c -- USB phy handling > >+ * > >+ * Copyright (C) 2004 Texas Instruments > > it's 2013 already :-P > >+ * > >+ * 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. > > But your *MODULE_LICENSE("GPL")* below tells it's only GPL. The MODULE_LICENSE("GPL") is in usb-common.c, not in the file I added. Sascha > . > > . > . > > > MODULE_LICENSE("GPL"); > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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/6] USB: add devicetree helpers for determining dr_mode and phy_type
On Thursday 31 January 2013 02:58 PM, Sascha Hauer wrote: On Thu, Jan 31, 2013 at 02:42:48PM +0530, kishon wrote: Hi, On Thursday 31 January 2013 02:31 PM, Sascha Hauer wrote: From: Michael Grzeschik This adds two little devicetree helper functions for determining the dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from the devicetree. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy.c| 10 ++ drivers/usb/usb-common.c | 36 include/linux/usb/of.h | 27 +++ include/linux/usb/otg.h |7 +++ include/linux/usb/phy.h |9 + 6 files changed, 90 insertions(+) create mode 100644 include/linux/usb/of.h diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 9fa6327..e1be1e8 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -5,6 +5,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG obj-$(CONFIG_USB_OTG_UTILS) += phy.o +obj-$(CONFIG_OF) += of.o You've missed doing "git add ..usb/phy/of.c". obj-$(CONFIG_OMAP_USB2) += omap-usb2.o obj-$(CONFIG_OMAP_USB3) += omap-usb3.o obj-$(CONFIG_OMAP_CONTROL_USB)+= omap-control-usb.o diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index ef35eb0..3ad4b5c 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -1,3 +1,13 @@ +/* + * phy.c -- USB phy handling + * + * Copyright (C) 2004 Texas Instruments it's 2013 already :-P + * + * 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. But your *MODULE_LICENSE("GPL")* below tells it's only GPL. The MODULE_LICENSE("GPL") is in usb-common.c, not in the file I added. huh.. just noticed. sorry for the noise. Thanks Kishon -- 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 4/6] usb: chipidea: add PTW and PTS handling
On Thu, Jan 31, 2013 at 10:15:54AM +0100, Matthieu CASTET wrote: > >> Why you don't implement it ? > >> > >> If you don't implement it, I believe you should add a warning in order to > >> catch > >> it when used with lpm devices. > > > > I'm against adding a warning because current users seem to go well > > without this setting. Adding a warning would lead to more confusion than > > it would help. > > > > I could try and implement it, though I'm unsure about the register > > layout. > > > > What I know from an earlier post from you is this: > > > > #define LPM_PTS(d) (((d)>>29)&7) > > #define LPM_STS BIT(28) /* serial transceiver select */ > > #define LPM_PTW BIT(27) /* parallel transceiver width */ > > > > Do you also know how LPM_PTS is decoded? > > I will say the same as not lpm device : > > PTS is made up from PORTSCx bits 25, 30 and 31. Here it is PTS0 -> bit 30 PTS1 -> bit 31 PTS2 -> bit 25 > > PTS is made up from devlc bits 31, 30 and 29. In my new series I now assumed: PTS0 -> bit 29 PTS1 -> bit 30 PTS2 -> bit 31 > > > Also in my datasheet, they give a way to check if the bits are read only or > read > write [1]. I don't know if it is worth the trouble to check it. > > > Matthieu > > > [1] > PTS > This register bit pair is used in conjunction with the configuration constant > VUSB_HS_PHY_TYPE to control which parallel transceiver interface is selected. > If > VUSB_HS_PHY_TYPE is set for 0, 1, 2, 3, 8 or 10 then this bit is read only. If > VUSB_HS_PHY_TYPE is 4, 5, 6, 7, 9 or 11 then this bit is read/write. > > This field is reset to: > '000b' if VUSB_HS_PHY_TYPE = 0, 4 UTMI/UTMI+ > '001b' if VUSB_HS_PHY_TYPE = 1, 5 ULPI DDR > '010b' if VUSB_HS_PHY_TYPE = 2, 6 ULPI > '011b' if VUSB_HS_PHY_TYPE = 3, 7, 8, 9 Serial/1.1 PHY/IC_USB (FS Only) > '100b' if VUSB_HS_PHY_TYPE = 10, 11 UTMI for HSIC PHY Ok, this seems to match my assumption, except that our controller marks the 'ULPI DDR' setting as reserved. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 3/6] USB: chipidea: ci13xxx-imx: create dynamic platformdata
On Thu, Jan 31, 2013 at 10:01:10AM +0100, Sascha Hauer wrote: > From: Michael Grzeschik > > This patch removes the limitation of having only one instance of the > ci13xxx-imx platformdata and makes different configurations possible. > > Signed-off-by: Michael Grzeschik > Signed-off-by: Marc Kleine-Budde > Signed-off-by: Sascha Hauer > --- > drivers/usb/chipidea/ci13xxx_imx.c | 25 +++-- > 1 file changed, 15 insertions(+), 10 deletions(-) > > diff --git a/drivers/usb/chipidea/ci13xxx_imx.c > b/drivers/usb/chipidea/ci13xxx_imx.c > index 8c29122..69024e0 100644 > --- a/drivers/usb/chipidea/ci13xxx_imx.c > +++ b/drivers/usb/chipidea/ci13xxx_imx.c > @@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data); > > /* End of common functions shared by usbmisc drivers*/ > > -static struct ci13xxx_platform_data ci13xxx_imx_platdata = { > - .name = "ci13xxx_imx", > - .flags = CI13XXX_REQUIRE_TRANSCEIVER | > - CI13XXX_PULLUP_ON_VBUS | > - CI13XXX_DISABLE_STREAMING, > - .capoffset = DEF_CAPOFFSET, > -}; > - > static int ci13xxx_imx_probe(struct platform_device *pdev) > { > struct ci13xxx_imx_data *data; > + struct ci13xxx_platform_data *pdata; > struct platform_device *plat_ci, *phy_pdev; > struct device_node *phy_np; > struct resource *res; > @@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device > *pdev) > && !usbmisc_ops) > return -EPROBE_DEFER; > > + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); > + if (!pdata) { > + dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n"); > + return -ENOMEM; > + } > + > + pdata->name = "ci13xxx_imx"; > + pdata->capoffset = DEF_CAPOFFSET; > + pdata->flags = CI13XXX_REQUIRE_TRANSCEIVER | > +CI13XXX_PULLUP_ON_VBUS | > +CI13XXX_DISABLE_STREAMING; > + > data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); > if (!data) { > dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); > @@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) > reg_vbus = NULL; > } > > - ci13xxx_imx_platdata.phy = data->phy; > + pdata->phy = data->phy; > > if (!pdev->dev.dma_mask) { > pdev->dev.dma_mask = devm_kzalloc(&pdev->dev, > @@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) > > plat_ci = ci13xxx_add_device(&pdev->dev, > pdev->resource, pdev->num_resources, > - &ci13xxx_imx_platdata); > + pdata); > if (IS_ERR(plat_ci)) { > ret = PTR_ERR(plat_ci); > dev_err(&pdev->dev, > -- > 1.7.10.4 > > Reviewed-by: Peter Chen -- Best Regards, Peter Chen -- 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 4/6] USB: chipidea: add PTW and PTS handling
On Thu, Jan 31, 2013 at 10:01:11AM +0100, Sascha Hauer wrote: > From: Michael Grzeschik > > This patch makes it possible to configure the PTW and PTS bits inside > the portsc register for host and device mode before the driver starts > and the phy can be addressed as hardware implementation is designed. > > Signed-off-by: Michael Grzeschik > Signed-off-by: Marc Kleine-Budde > Signed-off-by: Sascha Hauer > --- > .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +++ > drivers/usb/chipidea/bits.h| 14 ++- > drivers/usb/chipidea/ci13xxx_imx.c |3 ++ > drivers/usb/chipidea/core.c| 39 > > include/linux/usb/chipidea.h |1 + > 5 files changed, 61 insertions(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > index 5778b9c..dd42ccd 100644 > --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > @@ -5,6 +5,11 @@ Required properties: > - reg: Should contain registers location and length > - interrupts: Should contain controller interrupt > > +Recommended properies: > +- phy_type: the type of the phy connected to the core. Should be one > + of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this > + property the PORTSC register won't be touched > + > Optional properties: > - fsl,usbphy: phandler of usb phy that connects to the only one port > - fsl,usbmisc: phandler of non-core register device, with one argument > diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h > index 050de85..d8ffc2f 100644 > --- a/drivers/usb/chipidea/bits.h > +++ b/drivers/usb/chipidea/bits.h > @@ -48,10 +48,22 @@ > #define PORTSC_SUSP BIT(7) > #define PORTSC_HSPBIT(9) > #define PORTSC_PTC(0x0FUL << 16) > +/* PTS and PTW for non lpm version only */ > +#define PORTSC_PTS(d) d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) > : 0)) > +#define PORTSC_PTWBIT(28) > > /* DEVLC */ > #define DEVLC_PSPD(0x03UL << 25) > -#defineDEVLC_PSPD_HS (0x02UL << 25) > +#define DEVLC_PSPD_HS (0x02UL << 25) > +#define DEVLC_PTW BIT(27) > +#define DEVLC_STS BIT(28) > +#define DEVLC_PTS(d) (((d) & 0x7) << 29) > + > +/* Encoding for DEVLC_PTS and PORTSC_PTS */ > +#define PTS_UTMI 0 > +#define PTS_ULPI 2 > +#define PTS_SERIAL3 > +#define PTS_HSIC 4 > > /* OTGSC */ > #define OTGSC_IDPU BIT(5) > diff --git a/drivers/usb/chipidea/ci13xxx_imx.c > b/drivers/usb/chipidea/ci13xxx_imx.c > index 69024e0..ebc1148 100644 > --- a/drivers/usb/chipidea/ci13xxx_imx.c > +++ b/drivers/usb/chipidea/ci13xxx_imx.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include "ci.h" > #include "ci13xxx_imx.h" > @@ -112,6 +113,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) > CI13XXX_PULLUP_ON_VBUS | > CI13XXX_DISABLE_STREAMING; > > + pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node); > + > data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); > if (!data) { > dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c > index 57cae1f..a3ec29d 100644 > --- a/drivers/usb/chipidea/core.c > +++ b/drivers/usb/chipidea/core.c > @@ -67,6 +67,8 @@ > #include > #include > #include > +#include > +#include > > #include "ci.h" > #include "udc.h" > @@ -211,6 +213,41 @@ static int hw_device_init(struct ci13xxx *ci, void > __iomem *base) > return 0; > } > > +static void hw_phymode_configure(struct ci13xxx *ci) > +{ > + u32 portsc, lpm; > + > + switch (ci->platdata->phy_mode) { > + case USBPHY_INTERFACE_MODE_UTMI: > + portsc = PORTSC_PTS(PTS_UTMI); > + lpm = DEVLC_PTS(PTS_UTMI); > + break; > + case USBPHY_INTERFACE_MODE_UTMIW: > + portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW; > + lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW; > + break; > + case USBPHY_INTERFACE_MODE_ULPI: > + portsc = PORTSC_PTS(PTS_ULPI); > + lpm = DEVLC_PTS(PTS_ULPI); > + break; > + case USBPHY_INTERFACE_MODE_SERIAL: > + portsc = PORTSC_PTS(PTS_SERIAL); > + lpm = DEVLC_PTS(PTS_SERIAL); > + break; > + case USBPHY_INTERFACE_MODE_HSIC: > + portsc = PORTSC_PTS(PTS_HSIC); > + lpm = DEVLC_PTS(PTS_HSIC); > + break; > + default: > + return; > + } > + > + if (ci->hw_bank.lpm) > + hw_write(ci, OP_PORTSC, DEVLC_PTS(7) | DEVLC_PTW, lpm); > + else > + hw_write
Re: [PATCH 6/6] USB chipidea i.MX: introduce dr_mode property
On Thu, Jan 31, 2013 at 10:01:13AM +0100, Sascha Hauer wrote: > The dr_mode devicetree property allows to explicitly specify the > host/peripheral/otg mode. This is necessary for boards without proper > ID pin handling. > > Signed-off-by: Sascha Hauer > --- > Documentation/devicetree/bindings/usb/ci13xxx-imx.txt |1 + > drivers/usb/chipidea/ci13xxx_imx.c|1 + > 2 files changed, 2 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > index dd42ccd..493a414 100644 > --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt > @@ -9,6 +9,7 @@ Recommended properies: > - phy_type: the type of the phy connected to the core. Should be one >of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this >property the PORTSC register won't be touched > +- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" > > Optional properties: > - fsl,usbphy: phandler of usb phy that connects to the only one port > diff --git a/drivers/usb/chipidea/ci13xxx_imx.c > b/drivers/usb/chipidea/ci13xxx_imx.c > index ebc1148..b598bb8f 100644 > --- a/drivers/usb/chipidea/ci13xxx_imx.c > +++ b/drivers/usb/chipidea/ci13xxx_imx.c > @@ -114,6 +114,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) > CI13XXX_DISABLE_STREAMING; > > pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node); > + pdata->dr_mode = of_usb_get_dr_mode(pdev->dev.of_node); > > data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); > if (!data) { Reviewed-by: Peter Chen > -- > 1.7.10.4 > > -- Best Regards, Peter Chen -- 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/6] USB: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 10:01:09AM +0100, Sascha Hauer wrote: > From: Michael Grzeschik > > > + for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) > + if (!strcmp(dr_mode, usb_dr_modes[i])) > + return i; if (strcmp(dr_mode, usb_dr_modes[i]) == 0) may be more friendly. > + > +#ifndef __LINUX_USB_OF_H > +#define __LINUX_USB_OF_H > + > +#include > + > +#ifdef CONFIG_OF > +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); Will you put definition to phy.c, I can't find it at this version > index e8a5fe8..4e8bfbb 100644 > --- a/include/linux/usb/otg.h > +++ b/include/linux/usb/otg.h > @@ -99,4 +99,11 @@ otg_start_srp(struct usb_otg *otg) > /* for OTG controller drivers (and maybe other stuff) */ > extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); > > +enum usb_dr_mode { > + USB_DR_MODE_UNKNOWN, > + USB_DR_MODE_HOST, > + USB_DR_MODE_PERIPHERAL, > + USB_DR_MODE_OTG, > +}; > + I am not sure if otg.h is a good place to put this, in fact, we need a common header file for it. -- Best Regards, Peter Chen -- 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: Linux USB file storage gadget with new UDC
Hi, >> In the udc driver, i can't assign a single ep0 descriptor to both >> ep0_in_desc and ep0_out_desc. i think i should skip ep0_out_desc. Bear >> in mind that i only define 3 endpoints in udc driver: ep0, ep1 bulk >> in, ep1 bulk out. Will it cause any problem to gadget driver? > > There is no such thing as an ep0 descriptor. > > Alan Stern When ep1 receives CBW data, the isr routine is called. Then in isr, to get the usb_request: usb_request * req; req = list_entry(dev->ep[2].queue.next, struct kagen2_request, queue); however, the list_empty(&dev->ep[2].queue) is true. Where is the appropriate place to add list entry? thanks, victor -- 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/6] USB: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 06:01:08PM +0800, Peter Chen wrote: > On Thu, Jan 31, 2013 at 10:01:09AM +0100, Sascha Hauer wrote: > > From: Michael Grzeschik > > > > > > + for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) > > + if (!strcmp(dr_mode, usb_dr_modes[i])) > > + return i; > > if (strcmp(dr_mode, usb_dr_modes[i]) == 0) may be more friendly. > > > + > > +#ifndef __LINUX_USB_OF_H > > +#define __LINUX_USB_OF_H > > + > > +#include > > + > > +#ifdef CONFIG_OF > > +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); > > Will you put definition to phy.c, I can't find it at this version This goes to drivers/usb/phy/of.c Sorry, as Kishon noted I missed to git add the file. See the attached updated patch. > > > index e8a5fe8..4e8bfbb 100644 > > --- a/include/linux/usb/otg.h > > +++ b/include/linux/usb/otg.h > > @@ -99,4 +99,11 @@ otg_start_srp(struct usb_otg *otg) > > /* for OTG controller drivers (and maybe other stuff) */ > > extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); > > > > +enum usb_dr_mode { > > + USB_DR_MODE_UNKNOWN, > > + USB_DR_MODE_HOST, > > + USB_DR_MODE_PERIPHERAL, > > + USB_DR_MODE_OTG, > > +}; > > + > > I am not sure if otg.h is a good place to put this, in fact, we need > a common header file for it. Well linux/usb/otg.h is at least a header which can be included safely by everyone interested in usb_dr_mode. Anyway, I'm open for better suggestions, I just hesitated to add a new file just for this enum. Sascha >From 19c1a6552d6aa93f5ff354a224de0679d55a8126 Mon Sep 17 00:00:00 2001 From: Michael Grzeschik Date: Tue, 6 Nov 2012 16:10:10 +0100 Subject: [PATCH] USB: add devicetree helpers for determining dr_mode and phy_type This adds two little devicetree helper functions for determining the dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from the devicetree. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/usb/phy/Makefile |1 + drivers/usb/phy/of.c | 47 ++ drivers/usb/usb-common.c | 36 +++ include/linux/usb/of.h | 27 ++ include/linux/usb/otg.h |7 +++ include/linux/usb/phy.h |9 + 6 files changed, 127 insertions(+) create mode 100644 drivers/usb/phy/of.c create mode 100644 include/linux/usb/of.h diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 9fa6327..e1be1e8 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -5,6 +5,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG obj-$(CONFIG_USB_OTG_UTILS)+= phy.o +obj-$(CONFIG_OF) += of.o obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o obj-$(CONFIG_OMAP_USB3)+= omap-usb3.o obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c new file mode 100644 index 000..e6f3b74 --- /dev/null +++ b/drivers/usb/phy/of.c @@ -0,0 +1,47 @@ +/* + * USB of helper code + * + * 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. + */ + +#include +#include +#include +#include +#include + +static const char *usbphy_modes[] = { + [USBPHY_INTERFACE_MODE_UNKNOWN] = "", + [USBPHY_INTERFACE_MODE_UTMI]= "utmi", + [USBPHY_INTERFACE_MODE_UTMIW] = "utmi_wide", + [USBPHY_INTERFACE_MODE_ULPI]= "ulpi", + [USBPHY_INTERFACE_MODE_SERIAL] = "serial", + [USBPHY_INTERFACE_MODE_HSIC]= "hsic", +}; + +/** + * of_usb_get_phy_mode - Get phy mode for given device_node + * @np:Pointer to the given device_node + * + * The function gets phy interface string from property 'phy_type', + * and returns the correspondig enum usb_phy_interface + */ +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) +{ + const char *phy_type; + int err, i; + + err = of_property_read_string(np, "phy_type", &phy_type); + if (err < 0) + return USBPHY_INTERFACE_MODE_UNKNOWN; + + for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++) + if (!strcmp(phy_type, usbphy_modes[i])) + return i; + + return USBPHY_INTERFACE_MODE_UNKNOWN; +} +EXPORT_SYMBOL_GPL(of_usb_get_phy_mode); diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c index d29503e..ad4d87d 100644 --- a/drivers/usb/usb-common.c +++ b/drivers/usb/usb-common.c @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include const char *usb_speed_string(enum usb_device_speed speed) { @@ -32,4 +35,37 @@ const char *usb_speed_string(enum usb_device_speed speed) } EXPORT_SYMBOL_GPL(usb_speed_string); +#if
Re: Linux USB file storage gadget with new UDC
Hi, On Thu, Jan 31, 2013 at 06:10:10PM +0800, victor yeo wrote: > Hi, > > >> In the udc driver, i can't assign a single ep0 descriptor to both > >> ep0_in_desc and ep0_out_desc. i think i should skip ep0_out_desc. Bear > >> in mind that i only define 3 endpoints in udc driver: ep0, ep1 bulk > >> in, ep1 bulk out. Will it cause any problem to gadget driver? > > > > There is no such thing as an ep0 descriptor. > > > > Alan Stern > > When ep1 receives CBW data, the isr routine is called. Then in isr, to > get the usb_request: > > usb_request * req; > req = list_entry(dev->ep[2].queue.next, struct kagen2_request, queue); try to use list_for_entry() instead, or list_first_entry(). BTW your usage of list_entry() is wrong. > however, the list_empty(&dev->ep[2].queue) is true. Where is the > appropriate place to add list entry? only you will know, but your implementation of ep_queue is a nice bet. -- balbi signature.asc Description: Digital signature
Re: Clarifications on usb device driver probe() function
Hi, (always use reply-all) On Thu, Jan 31, 2013 at 11:12:07AM +0100, stl wrote: > Hi, > thanks for yours answers > > > which kernel version are you using ? usb_gadget_register_driver() has > > been re-factored into generic code long ago. > > Indeed, I am unfortunately using an old kernel version (2.6.19). sorry you're on your own. 2.6.19 is from 2006, can't help you. > Because of some deadlines, we have chosen to work on this, but an update to > a recent version is in progress, but it still need a certain amount of work to > be in an acceptable state. > It is for this reason that I know it will be difficult to have support. > But, even if certain function names have changed, I only want to > understand the concept > behind all of this. > > >> I have seen in some udc drivers that "resource_get_irq()" is called > > > > there is no such function in the kernel. Do you mean platform_get_irq()? > > Yes I mean platform_get_irq(), sorry for the mistake. > > >> before registering IRQ > >> with "request_irq()". > >> What is the purpose of this function? > > > > to get the proper IRQ number which is passed by platform code using > > struct resource. > > Why does the driver need to know the IRQ numbers? > request_irq() procedure is not enough to point to ISR during hardware > interrupt event? you need to attach ISR to a certain IRQ number. We don't want your ISR to be called when the MMC controller generates IRQ events. -- balbi signature.asc Description: Digital signature
Re: [PATCH,RFC] usb: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 10:05:44AM +0800, Peter Chen wrote: > On Wed, Jan 30, 2013 at 03:00:15PM +0100, Sascha Hauer wrote: > > On Wed, Jan 30, 2013 at 10:06:28AM +0800, Peter Chen wrote: > > > On Tue, Jan 29, 2013 at 01:55:04PM +0200, Alexander Shishkin wrote: > > > > Sascha Hauer writes: > > > > > > > > > From: Michael Grzeschik > > > > > > > > > > This adds two little devicetree helper functions for determining the > > > > > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from > > > > > the devicetree. > > > > > > > > > > Signed-off-by: Michael Grzeschik > > > > > Signed-off-by: Marc Kleine-Budde > > > > > --- > > > > > > > > > > The properties and their values have been taken from the fsl-mph-dr > > > > > driver. > > > > > This binding is also documented (though currently not used) for the > > > > > tegra > > > > > ehci driver > > > > > (Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt). > > > > > This is a first attempt to parse these bindings at a common place so > > > > > that > > > > > others can make use of it. > > > > > > > > > > Basically I want to know whether this binding is recommended for new > > > > > drivers > > > > > since normally the devicetree uses '-' instead of '_', and maybe > > > > > there are > > > > > other problems with it. > > > > > > > > > > I need this binding for the chipidea driver. I suspect that the > > > > > fsl-mph-dr > > > > > driver also really handles a chipidea core. > > > > > > > > As far as I know, it is a chipidea core. Adding Peter to Cc list, he can > > > > probably confirm. > > > > > > The fsl-mph-dr can't be used for chipdiea as it handles three platform > > > drivers for three roles (peripheral , host, otg). But chipidea only has > > > two platform drivers, one is the chipidea core, the other is related > > > controller wrapper. > > > > What do you mean by 'three platform drivers'? That's only how the driver > > is built, no? I was talking about the hardware the fsl-mph-dr driver > > handles which definitely smells like chipidea. > > It creates host/device/otg platform device according to dr_mode from > the device tree. Again, that's software specific. What I'd like to know is whether the *hardware* could be handled by the chipidea driver. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 v9 00/20] OMAP USB Host cleanup
Hi Samuel, Could you please pull this if it looks OK? Thanks :). cheers, -roger On 01/23/2013 12:37 PM, Roger Quadros wrote: > Hi Samuel, > > I think this series is in a pretty good shape to pull now :). I've added > Reviewed-by and Acked-by tags. You can please pull from below. > > NOTE: the first patch is a stable fix so Greg KH might want to pick it up for > 3.8-rc. > > The following changes since commit 7d1f9aeff1ee4a20b1aeb377dd0f579fe9647619: > > Linux 3.8-rc4 (2013-01-17 19:25:45 -0800) > > are available in the git repository at: > git://github.com/rogerq/linux.git linux-usbhost14-part > > This patchset addresses the following > > - Consolidate USB Host platform data. > - Avoid addressing clocks one by one by name and use a for loop + bunch > of cleanups. > - Get number of channels/ports dynamically either from revision register > or from platform data. Avoids getting clocks that are not present. > - Add OMAP5 and HSIC mode (Not tested). > > v9: > - Addressed clock framework related comments from Russell King. > - Removed 2 clock data patches from the series as they will be taken care > of by Paul Walmsey. > > v8: > - Re-arranged patch > "USB-ehci-omap-Don-t-free-gpios-that-we-didn-t-reques.patch" > to be the first since it is a candidate for stable. > - Fixed issues raised by Felipe, i.e. indentation and use of switch () > > v7: > - Updated patch 4 to not hold a spinlock when using clk_get(). > - Updated patches 3 and 11 to return -EADDRNOTAVAIL on failure of > demv_request_and_ioremap(). > > v6: > - Added USB Host platform data consolidation patch as the first patch. > based on request from Tony. > - Rebased on v3.8-rc3. > > v5: > - Rebased on top of todays arm-soc/for-next. > - Removed the clock merging patch from the list. > - Updated patches 14, 19 and 20 to accomodate the above change. > - Added patch 22 to fix a build warning. > > v4: > - Added appropriate maintainers in to/cc. > - minor print message fix in patch 23 to maintain consistency. > > v3: > - Rebased on arm-soc/for-next commit f979306c4d38d213c6977aaf3b1115e8ded71e3a. > - Rearranged patch that get rids of cpu_is_omap..() macros. > - Coding style fixes. > > v2: > - Clocks are allocated dynamically based on number of ports available > on the platform. > - Reduced console spam if non critical clocks are not found on the platform. > - Get rid of cpu_is_.. macros from USB host driver. > > cheers, > -roger > > --- > Roger Quadros (20): > USB: ehci-omap: Don't free gpios that we didn't request > mfd: omap-usb-host: Consolidate OMAP USB-HS platform data > mfd: omap-usb-tll: Fix channel count detection > mfd: omap-usb-tll: Use devm_kzalloc/ioremap and clean up error path > mfd: omap-usb-tll: Clean up clock handling > mfd: omap-usb-tll: introduce and use mode_needs_tll() > mfd: omap-usb-tll: Check for missing platform data in probe > mfd: omap-usb-tll: Fix error message > mfd: omap-usb-tll: serialize access to TLL device > mfd: omap-usb-tll: Add OMAP5 revision and HSIC support > mfd: omap_usb_host: Avoid missing platform data checks in suspend/resume > mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap() > mfd: omap-usb-host: know about number of ports from revision register > mfd: omap-usb-host: override number of ports from platform data > mfd: omap-usb-host: cleanup clock management code > mfd: omap-usb-host: Manage HSIC clocks for HSIC mode > mfd: omap-usb-host: Get rid of unnecessary spinlock > mfd: omap-usb-host: clean up omap_usbhs_init() > mfd: omap-usb-host: Don't spam console on clk_set_parent failure > mdf: omap-usb-host: get rid of build warning > > arch/arm/mach-omap2/board-3430sdp.c|2 +- > arch/arm/mach-omap2/board-3630sdp.c|2 +- > arch/arm/mach-omap2/board-am3517crane.c|2 +- > arch/arm/mach-omap2/board-am3517evm.c |2 +- > arch/arm/mach-omap2/board-cm-t35.c |2 +- > arch/arm/mach-omap2/board-cm-t3517.c |2 +- > arch/arm/mach-omap2/board-devkit8000.c |2 +- > arch/arm/mach-omap2/board-igep0020.c |4 +- > arch/arm/mach-omap2/board-omap3beagle.c|2 +- > arch/arm/mach-omap2/board-omap3evm.c |2 +- > arch/arm/mach-omap2/board-omap3pandora.c |2 +- > arch/arm/mach-omap2/board-omap3stalker.c |2 +- > arch/arm/mach-omap2/board-omap3touchbook.c |2 +- > arch/arm/mach-omap2/board-omap4panda.c |2 +- > arch/arm/mach-omap2/board-overo.c |2 +- > arch/arm/mach-omap2/board-zoom.c |2 +- > arch/arm/mach-omap2/usb-host.c | 29 +-- > arch/arm/mach-omap2/usb.h | 20 +- > drivers/mfd/omap-usb-host.c| 558 > +--- > drivers/mfd/omap-usb-tll.c | 243 +++-- > drivers/usb/host/ehci-omap.c | 14 +- > include/lin
Re: Linux USB file storage gadget with new UDC
Hi, >> When ep1 receives CBW data, the isr routine is called. Then in isr, to >> get the usb_request: >> >> usb_request * req; >> req = list_entry(dev->ep[2].queue.next, struct kagen2_request, queue); >> >> however, the list_empty(&dev->ep[2].queue) is true. Where is the >> appropriate place to add list entry? > > only you will know, but your implementation of ep_queue is a nice bet. i have list_add_tail() in my ep_queue() function. Prior to ep1 receiving data, my ep_queue() is called to send 0x00 to ep0. then it is not called. how to make it to be called by file gadget, in order to queue the request before ep1 interrupt? victor -- 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 RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
With device tree support in place for dwc3-core layer, it gets PHY from "synopsis-dwc3" node. Some controllers may not have separate memory maps and interrupts for dwc3 core and platform glue layers. In such case only glue layer's node will exist. Moreover, SoCs having multiple dwc3 controllers will have multiple PHYs, which eventually be added using usb_add_phy_dev(), and not using usb_add_phy(). So each dwc3 controller won't be able to get PHYs by simply calling devm_usb_get_phy() also. In such cases, dwc3 should expect PHYs from its parent's node. So, adding provision for getting PHY from platform specific device tree node. Signed-off-by: Vivek Gautam --- Based on 'usb-next'. drivers/usb/dwc3/core.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 094..75439c0 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -423,6 +423,11 @@ static int dwc3_probe(struct platform_device *pdev) if (node) { dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); + } else if (dev->parent->of_node) { + dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev->parent, + "usb-phy", 0); + dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev->parent, + "usb-phy", 1); } else { dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); -- 1.7.6.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] USB chipidea i.MX: use framework phy handling
This series switches the mxs phy and the i.MX chipidea support from homegrew phy support to use usb_add_phy_dev/devm_usb_get_phy_by_phandle. Based on [PATCH v2] Add USB of helpers and use them in the chipidea driver But I think this could also be applied separately if necessary. Sascha Sascha Hauer (2): USB mxs-phy: Register phy with framework USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy drivers/usb/chipidea/ci13xxx_imx.c | 31 ++- drivers/usb/otg/mxs-phy.c |9 + 2 files changed, 19 insertions(+), 21 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] USB mxs-phy: Register phy with framework
We now have usb_add_phy_dev(), so use it to register with the framework to be able to find the phy from the USB driver. Signed-off-by: Sascha Hauer --- drivers/usb/otg/mxs-phy.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c index 5158332..5b39885 100644 --- a/drivers/usb/otg/mxs-phy.c +++ b/drivers/usb/otg/mxs-phy.c @@ -127,6 +127,7 @@ static int mxs_phy_probe(struct platform_device *pdev) void __iomem *base; struct clk *clk; struct mxs_phy *mxs_phy; + int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -166,11 +167,19 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &mxs_phy->phy); + ret = usb_add_phy_dev(&mxs_phy->phy); + if (ret) + return ret; + return 0; } static int mxs_phy_remove(struct platform_device *pdev) { + struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); + + usb_remove_phy(&mxs_phy->phy); + platform_set_drvdata(pdev, NULL); return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/ci13xxx_imx.c | 31 ++- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index b598bb8f..1df4b41 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -30,7 +30,6 @@ ((struct usb_phy *)platform_get_drvdata(pdev)) struct ci13xxx_imx_data { - struct device_node *phy_np; struct usb_phy *phy; struct platform_device *ci_pdev; struct clk *clk; @@ -90,12 +89,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) { struct ci13xxx_imx_data *data; struct ci13xxx_platform_data *pdata; - struct platform_device *plat_ci, *phy_pdev; - struct device_node *phy_np; + struct platform_device *plat_ci; struct resource *res; struct regulator *reg_vbus; struct pinctrl *pinctrl; int ret; + struct usb_phy *phy; if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL) && !usbmisc_ops) @@ -147,18 +146,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) return ret; } - phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0); - if (phy_np) { - data->phy_np = phy_np; - phy_pdev = of_find_device_by_node(phy_np); - if (phy_pdev) { - struct usb_phy *phy; - phy = pdev_to_phy(phy_pdev); - if (phy && - try_module_get(phy_pdev->dev.driver->owner)) { - usb_phy_init(phy); - data->phy = phy; - } + phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0); + if (!IS_ERR(phy)) { + ret = usb_phy_init(phy); + if (ret) { + dev_err(&pdev->dev, "unable to init phy: %d\n", ret); + goto err_clk; } } @@ -170,7 +163,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to enable vbus regulator, err=%d\n", ret); - goto put_np; + goto err_clk; } data->reg_vbus = reg_vbus; } else { @@ -222,9 +215,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) err: if (reg_vbus) regulator_disable(reg_vbus); -put_np: - if (phy_np) - of_node_put(phy_np); +err_clk: clk_disable_unprepare(data->clk); return ret; } @@ -244,8 +235,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev) module_put(data->phy->dev->driver->owner); } - of_node_put(data->phy_np); - clk_disable_unprepare(data->clk); platform_set_drvdata(pdev, NULL); -- 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 RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
Hi, On Thursday 31 January 2013 04:50 PM, Vivek Gautam wrote: With device tree support in place for dwc3-core layer, it gets PHY from "synopsis-dwc3" node. Some controllers may not have separate memory maps and interrupts for dwc3 core and platform glue layers. In such case only glue layer's node will exist. Not really. As long as you have dwc3 core as a separate device, you can add a node for it. Just that the glue should create a device for dwc3 core using of_platform_populate.(You can have a look at drivers/usb/dwc3/dwc3-omap.c in usb-next) Moreover, SoCs having multiple dwc3 controllers will have multiple PHYs, which eventually be added using usb_add_phy_dev(), and not using usb_add_phy(). So each dwc3 controller won't be able to get PHYs by simply calling devm_usb_get_phy() also. No. We have added usb_get_phy_dev() for that purpose in the case of non-dt. I think, instead you can have a patch to use devm_usb_get_phy_dev() here and in exynos platform specific code use usb_bind_phy() to bind the phy and controller till you change it to dt. In such cases, dwc3 should expect PHYs from its parent's node. NAK. Thanks Kishon -- 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: musb: Correct Kconfig in order to avoid non compilable selection
Currently it is possible to have: USB_MUSB_OMAP2PLUS=m TWL4030_USB=y which would result compile time error due to missing symbols. With this change USB_MUSB_OMAP2PLUS and TWL4030_USB will be in sync. Reported-by: Vincent Stehle Signed-off-by: Peter Ujfalusi --- Hi Felipe, I have also noticed that we have similar issue around USB_MUSB_HDRC, CONFIG_USB_MUSB_TUSB6010 and CONFIG_USB_TUSB_OMAP_DMA. You can easily have a combination of y/m of these to have non compilable kernel. I have tried to fix it but my Kconfig skills are not adequate for it ;) Regards, Peter drivers/usb/musb/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 23a0b7f..a3fa19c 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -9,8 +9,6 @@ config USB_MUSB_HDRC depends on USB && USB_GADGET select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX) - select TWL4030_USB if MACH_OMAP_3430SDP - select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA select USB_OTG_UTILS help Say Y here if your system has a dual role high speed USB @@ -49,6 +47,8 @@ config USB_MUSB_TUSB6010 config USB_MUSB_OMAP2PLUS tristate "OMAP2430 and onwards" depends on ARCH_OMAP2PLUS + select TWL4030_USB if MACH_OMAP_3430SDP + select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA config USB_MUSB_AM35X tristate "AM35x" -- 1.8.1.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 2/2] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
Hi, On Thursday 31 January 2013 05:02 PM, Sascha Hauer wrote: Signed-off-by: Sascha Hauer Some maintainers don't accept patches without a commit message. Apart from that you can add, Reviewed-by: Kishon Vijay Abraham I Thanks Kishon -- 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 mxs-phy: Register phy with framework
On Thursday 31 January 2013 05:02 PM, Sascha Hauer wrote: We now have usb_add_phy_dev(), so use it to register with the framework to be able to find the phy from the USB driver. Signed-off-by: Sascha Hauer Reviewed-by: Kishon Vijay Abraham I --- drivers/usb/otg/mxs-phy.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c index 5158332..5b39885 100644 --- a/drivers/usb/otg/mxs-phy.c +++ b/drivers/usb/otg/mxs-phy.c @@ -127,6 +127,7 @@ static int mxs_phy_probe(struct platform_device *pdev) void __iomem *base; struct clk *clk; struct mxs_phy *mxs_phy; + int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -166,11 +167,19 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &mxs_phy->phy); + ret = usb_add_phy_dev(&mxs_phy->phy); + if (ret) + return ret; + return 0; } static int mxs_phy_remove(struct platform_device *pdev) { + struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); + + usb_remove_phy(&mxs_phy->phy); + platform_set_drvdata(pdev, NULL); return 0; -- 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: xhci streams bug
Hi, > I think it's because xhci doesn't manage the trb_address_map radix tree > correctly. I can only find a single radix_tree_insert() call in the > code, and that one is for the initial segment. But nobody seems to > update the radix tree when linking the next segment ... There seems to be a bit more fishy, a device reset doesn't bring the device back online. [ 117.169453] scsi3 : uas [ 117.171072] usbcore: registered new interface driver uas [ 117.175060] scsi 3:0:0:0: Direct-Access QEMU QEMU HARDDISK 1.3. PQ: 0 ANSI: 5 [ 117.195589] sd 3:0:0:0: Attached scsi generic sg1 type 0 [ 117.206834] sd 3:0:0:0: [sdb] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB) [ 117.223331] sd 3:0:0:0: [sdb] Write Protect is off [ 117.236356] sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [ 117.251144] sdb: sdb1 [ 117.266808] sd 3:0:0:0: [sdb] Attached SCSI disk All fine so far. [ 117.324571] xhci_hcd :00:0f.0: ERROR Transfer event for disabled endpoint or incorrect stream ring [ 117.325543] xhci_hcd :00:0f.0: @3c348550 3c8a8800 0d60 01058000 Hitting stream ring link bug, status pipe stops working. [ 177.760380] sd 3:0:0:0: [sdb] uas_eh_abort_handler 88003c8ef600 tag 0, inflight: CMD [ 180.769264] scsi host3: uas_eh_task_mgmt: ABORT TASK timed out [ 180.778724] sd 3:0:0:0: [sdb] uas_eh_abort_handler 8800350f6d00 tag 1, inflight: CMD [ 183.780182] scsi host3: uas_eh_task_mgmt: ABORT TASK timed out [ 183.790096] sd 3:0:0:0: uas_eh_abort_handler 88002e859100 tag 2, inflight: CMD [ 186.796318] scsi host3: uas_eh_task_mgmt: ABORT TASK timed out [ 186.799973] sd 3:0:0:0: uas_eh_device_reset_handler [ 189.805352] scsi host3: uas_eh_task_mgmt: LOGICAL UNIT RESET timed out scsi / uas tries to recover via task management, which fails. Probably due to the status pipe being hosed. Could also be a bug though in qemu's tmf code though. [ 189.815757] usb 7-3: URB BAD STATUS -2 [ 189.819638] usb 7-3: URB BAD STATUS -2 [ 189.822628] usb 7-3: URB BAD STATUS -2 [ 189.826979] usb 7-3: URB BAD STATUS -2 [ 189.829789] usb 7-3: URB BAD STATUS -2 [ 189.830699] usb 7-3: URB BAD STATUS -2 uas canceled inflight urbs here via usb_kill_anchored_urbs() [ 189.936982] usb 7-3: reset SuperSpeed USB device number 2 using xhci_hcd [ 189.956674] usb 7-3: Parent hub missing LPM exit latency info. Power management will be impacted. [ 189.958721] xhci_hcd :00:0f.0: xHCI xhci_drop_endpoint called with disabled ep 88003d043700 [ 189.964337] xhci_hcd :00:0f.0: xHCI xhci_drop_endpoint called with disabled ep 88003d043740 [ 189.968832] xhci_hcd :00:0f.0: xHCI xhci_drop_endpoint called with disabled ep 88003d043780 [ 189.970601] xhci_hcd :00:0f.0: xHCI xhci_drop_endpoint called with disabled ep 88003d0437c0 uas resets device. [ 189.974161] scsi host3: uas_eh_bus_reset_handler success uas thinks we are fine again ... [ 189.978617] scsi host3: sense urb submission failure ... but we are not, sense pipe still broken. [ 199.979340] sd 3:0:0:0: uas_eh_abort_handler 88002e859100 tag 2, inflight: s-st a-cmd s-cmd [ 199.991331] sd 3:0:0:0: abort completed [ 199.995088] sd 3:0:0:0: Device offlined - not ready after error recovery scsi layer decides to take the device offline as the request (test unit ready probably) didn't work. [ 199.999020] sd 3:0:0:0: Device offlined - not ready after error recovery [ 200.001558] sd 3:0:0:0: Device offlined - not ready after error recovery [ 200.003413] sd 3:0:0:0: [sdb] Unhandled error code [ 200.006862] sd 3:0:0:0: [sdb] [ 200.007532] Result: hostbyte=DID_TIME_OUT driverbyte=DRIVER_OK [ 200.011701] sd 3:0:0:0: [sdb] CDB: [ 200.013864] Read(10): 28 00 00 00 08 00 00 00 08 00 [ 200.015128] end_request: I/O error, dev sdb, sector 2048 [ 200.016244] Buffer I/O error on device sdb1, logical block 0 [ 200.017412] sd 3:0:0:0: [sdb] Unhandled error code [ 200.018384] sd 3:0:0:0: [sdb] [ 200.019023] Result: hostbyte=DID_TIME_OUT driverbyte=DRIVER_OK [ 200.020161] sd 3:0:0:0: [sdb] CDB: [ 200.020846] Read(10): 28 00 00 00 01 68 00 00 08 00 [ 200.023422] end_request: I/O error, dev sdb, sector 360 [ 200.024636] Buffer I/O error on device sdb, logical block 45 scsi layer finally throws an I/O error. But, hey, at least the machine is still fine, uas didn't crash in the process ... [ all still in qemu, will cross-checking on real hardware ] cheers, Gerd -- 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: Linux USB file storage gadget with new UDC
On Thu, 31 Jan 2013, victor yeo wrote: > Hi, > > >> When ep1 receives CBW data, the isr routine is called. Then in isr, to > >> get the usb_request: > >> > >> usb_request * req; > >> req = list_entry(dev->ep[2].queue.next, struct kagen2_request, queue); > >> > >> however, the list_empty(&dev->ep[2].queue) is true. Where is the > >> appropriate place to add list entry? > > > > only you will know, but your implementation of ep_queue is a nice bet. > > i have list_add_tail() in my ep_queue() function. Prior to ep1 > receiving data, my ep_queue() is called to send 0x00 to ep0. then it > is not called. how to make it to be called by file gadget, in order to > queue the request before ep1 interrupt? This should happen when get_next_command() calls start_transfer(), which calls usb_ep_queue(). 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 RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
Hi Kishon, On Thu, Jan 31, 2013 at 5:04 PM, kishon wrote: > Hi, > Thanks for your quick help. > > On Thursday 31 January 2013 04:50 PM, Vivek Gautam wrote: >> >> With device tree support in place for dwc3-core layer, >> it gets PHY from "synopsis-dwc3" node. >> Some controllers may not have separate memory maps and interrupts >> for dwc3 core and platform glue layers. In such case only glue >> layer's node will exist. > > > Not really. As long as you have dwc3 core as a separate device, you can add > a node for it. > Just that the glue should create a device for dwc3 core using > of_platform_populate.(You can have a look at drivers/usb/dwc3/dwc3-omap.c in > usb-next) > Right, we should be doing this way. >> Moreover, SoCs having multiple dwc3 controllers will have multiple >> PHYs, which eventually be added using usb_add_phy_dev(), and not >> using usb_add_phy(). So each dwc3 controller won't be able to >> get PHYs by simply calling devm_usb_get_phy() also. > > No. We have added usb_get_phy_dev() for that purpose in the case of non-dt. > I think, instead you can have a patch to use devm_usb_get_phy_dev() here and > in exynos platform specific code use usb_bind_phy() to bind the phy and > controller till you change it to dt. > We have dt support for dwc3-exynos, in such case we should go ahead with of_platform_populate(), right ? But if when i use of_platform_populate() i will not be able to set dma_mask to dwc3->dev. :-( And setting it in dwc3_probe() won't be good idea, isn't it ? >> In such cases, dwc3 should expect PHYs from its parent's node. > > NAK. > > Thanks > Kishon > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" > in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Thanks & Regards Vivek -- 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 RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
Hi, On Thu, Jan 31, 2013 at 08:53:27PM +0530, Vivek Gautam wrote: > >> Moreover, SoCs having multiple dwc3 controllers will have multiple > >> PHYs, which eventually be added using usb_add_phy_dev(), and not > >> using usb_add_phy(). So each dwc3 controller won't be able to > >> get PHYs by simply calling devm_usb_get_phy() also. > > > > No. We have added usb_get_phy_dev() for that purpose in the case of non-dt. > > I think, instead you can have a patch to use devm_usb_get_phy_dev() here and > > in exynos platform specific code use usb_bind_phy() to bind the phy and > > controller till you change it to dt. > > > > We have dt support for dwc3-exynos, in such case we should go ahead with > of_platform_populate(), right ? > But if when i use of_platform_populate() i will not be able to set > dma_mask to dwc3->dev. :-( do you have a special need for dma_mask because OF already sets it. -- balbi signature.asc Description: Digital signature
Re: [PATCH RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
Hi Felipe, On Thu, Jan 31, 2013 at 8:55 PM, Felipe Balbi wrote: > Hi, > > On Thu, Jan 31, 2013 at 08:53:27PM +0530, Vivek Gautam wrote: >> >> Moreover, SoCs having multiple dwc3 controllers will have multiple >> >> PHYs, which eventually be added using usb_add_phy_dev(), and not >> >> using usb_add_phy(). So each dwc3 controller won't be able to >> >> get PHYs by simply calling devm_usb_get_phy() also. >> > >> > No. We have added usb_get_phy_dev() for that purpose in the case of non-dt. >> > I think, instead you can have a patch to use devm_usb_get_phy_dev() here >> > and >> > in exynos platform specific code use usb_bind_phy() to bind the phy and >> > controller till you change it to dt. >> > >> >> We have dt support for dwc3-exynos, in such case we should go ahead with >> of_platform_populate(), right ? >> But if when i use of_platform_populate() i will not be able to set >> dma_mask to dwc3->dev. :-( > > do you have a special need for dma_mask because OF already sets it. > If i am not wrong of_platform_device_create_pdata() will set "dev->dev.coherent_dma_mask = DMA_BIT_MASK(32)" and not dma_mask. I fact we had some discussion sometime back when we needed the same for dwc3-exynos in the thread: [PATCH v2 1/2] USB: dwc3-exynos: Add support for device tree But couldn't get final node on it. So suggestions here please. :-) -- Thanks & Regards Vivek -- 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 RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
On Thu, Jan 31, 2013 at 09:00:37PM +0530, Vivek Gautam wrote: > Hi Felipe, > > > On Thu, Jan 31, 2013 at 8:55 PM, Felipe Balbi wrote: > > Hi, > > > > On Thu, Jan 31, 2013 at 08:53:27PM +0530, Vivek Gautam wrote: > >> >> Moreover, SoCs having multiple dwc3 controllers will have multiple > >> >> PHYs, which eventually be added using usb_add_phy_dev(), and not > >> >> using usb_add_phy(). So each dwc3 controller won't be able to > >> >> get PHYs by simply calling devm_usb_get_phy() also. > >> > > >> > No. We have added usb_get_phy_dev() for that purpose in the case of > >> > non-dt. > >> > I think, instead you can have a patch to use devm_usb_get_phy_dev() here > >> > and > >> > in exynos platform specific code use usb_bind_phy() to bind the phy and > >> > controller till you change it to dt. > >> > > >> > >> We have dt support for dwc3-exynos, in such case we should go ahead with > >> of_platform_populate(), right ? > >> But if when i use of_platform_populate() i will not be able to set > >> dma_mask to dwc3->dev. :-( > > > > do you have a special need for dma_mask because OF already sets it. > > > If i am not wrong of_platform_device_create_pdata() will set > "dev->dev.coherent_dma_mask = DMA_BIT_MASK(32)" > and not dma_mask. > I fact we had some discussion sometime back when we needed the same > for dwc3-exynos in the thread: > [PATCH v2 1/2] USB: dwc3-exynos: Add support for device tree > > But couldn't get final node on it. > So suggestions here please. :-) hmm.. you're right there. Grant, Rob ? Any hints ? -- balbi signature.asc Description: Digital signature
Adding a driver for my device
Hello, my device seems to be out of order since a few weeks: [ 5965.767060] usbserial_generic 1-2:1.1: generic converter detected [ 5965.767198] usb 1-2: generic converter now attached to ttyUSB1 [ 5965.767213] usbserial_generic 1-2:1.2: The "generic" usb-serial driver is only for testing and one-off prototypes. [ 5965.767216] usbserial_generic 1-2:1.2: Tell linux-usb@vger.kernel.org to add your device to a proper driver. It is a UMTS stick that worked beforehand with the same Kernel 3.6.6 on my gentoo box. Please tell me what to do? Kind regards Bastian -- 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 net] net: usbnet: fix tx_dropped statistics
It is normal for minidrivers accumulating frames to return NULL from their tx_fixup function. We do not want to count this as a drop, or log any debug messages. A different exit path is therefore chosen for such drivers, skipping the debug message and the tx_dropped increment. The test for accumulating drivers was however completely bogus, making the exit path selection depend on whether the user had enabled tx_err logging or not. This would arbitrarily mess up accounting for both accumulating and non-accumulating minidrivers, and would result in unwanted debug messages for the accumulating drivers. Fix by testing for FLAG_MULTI_PACKET instead, which probably was the intention from the beginning. This usage match the documented behaviour of this flag: Indicates to usbnet, that USB driver accumulates multiple IP packets. Affects statistic (counters) and short packet handling. Signed-off-by: Bjørn Mork --- drivers/net/usb/usbnet.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 9778377..5e33606 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1125,13 +1125,11 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, if (info->tx_fixup) { skb = info->tx_fixup (dev, skb, GFP_ATOMIC); if (!skb) { - if (netif_msg_tx_err(dev)) { - netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n"); - goto drop; - } else { - /* cdc_ncm collected packet; waits for more */ + /* packet collected; minidriver waiting for more */ + if (info->flags & FLAG_MULTI_PACKET) goto not_drop; - } + netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n"); + goto drop; } } length = skb->len; -- 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: Adding a driver for my device
Bastian Löffler writes: > Hello, > > my device seems to be out of order since a few weeks: > > [ 5965.767060] usbserial_generic 1-2:1.1: generic converter detected > [ 5965.767198] usb 1-2: generic converter now attached to ttyUSB1 > [ 5965.767213] usbserial_generic 1-2:1.2: The "generic" usb-serial driver is > only for testing and one-off prototypes. > [ 5965.767216] usbserial_generic 1-2:1.2: Tell linux-usb@vger.kernel.org to > add your device to a proper driver. It should still work as before. That is only a warning message. > It is a UMTS stick that worked beforehand with the same Kernel 3.6.6 > on my gentoo box. Please tell me what to do? please send us the output of "lsusb -v" for this device. Chances are good that it either already is supported by some other driver, or that we just can add it to an existing driver. Either way you should be able to drop the special usbserial loading you have been doing to make this device work. 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
Re: Adding a driver for my device
On Thu, 2013-01-31 at 19:50 +0100, Bjørn Mork wrote: > Bastian Löffler writes: > > > Hello, > > > > my device seems to be out of order since a few weeks: > > > > [ 5965.767060] usbserial_generic 1-2:1.1: generic converter detected > > [ 5965.767198] usb 1-2: generic converter now attached to ttyUSB1 > > [ 5965.767213] usbserial_generic 1-2:1.2: The "generic" usb-serial driver > > is only for testing and one-off prototypes. > > [ 5965.767216] usbserial_generic 1-2:1.2: Tell linux-usb@vger.kernel.org to > > add your device to a proper driver. > > It should still work as before. That is only a warning message. > > > It is a UMTS stick that worked beforehand with the same Kernel 3.6.6 > > on my gentoo box. Please tell me what to do? > > please send us the output of "lsusb -v" for this device. > > Chances are good that it either already is supported by some other > driver, or that we just can add it to an existing driver. Either way > you should be able to drop the special usbserial loading you have been > doing to make this device work. And also the model number and manufacturer of the device, as printed on the device. Bonus points for any FCC ID you find. Dan -- 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 v4 2/4] ARM: Exynos5250: Enabling ohci-exynos driver
Tomasz Figa wrote: > > Hi Vivek, [...] > > + usb@1212 { > > + compatible = "samsung,exynos4210-ohci"; > > + reg = <0x1212 0x100>; > > + interrupts = <0 71 0>; > > For Samsung platforms we decided per board enabling of nodes and so this > node should also contain: > > status = "disabled"; > > while in dts file of board using ohci there would be an overriding entry: > > usb@1212 { > status = "okay"; > }; > > I know that Exynos5250 has not been yet converted into this convention, > but using it when adding new devices will simplify the process. > Well, I have another opinion on this... Let's see, yeah, we are using following method in EXYNOS4 DT... - disabling IPs in SoC DT source and enabling IPs in board DT source But as I said, in EXYNOS5440 DT, I want to use following, because most of them should be enabled/used. - enabling IPs in SoC DT source and no need enabling in board DT source. I mean, it depends on each SoC's situation. Thanks. - Kukjin -- 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: Page allocation failure on v3.8-rc5
On Wed, 30 Jan 2013 19:53:22 +0800 Ming Lei wrote: > The allocation failure is caused by the big sizeof(struct parsed_partitions), > which is 64K in my 32bit box, Geeze. We could fix that nicely by making parsed_partitions.parts an array of pointers to a single `struct parsed_partition' and allocating those on-demand. But given the short-lived nature of this storage and the infrequency of check_partition(), that isn't necessary. > could you test the blow patch to see > if it can fix the allocation failure? (The patch is wordwrapped) > ... > > @@ -106,18 +107,43 @@ static int (*check_part[])(struct parsed_partitions *) > = { > NULL > }; > > +struct parsed_partitions *allocate_partitions(int nr) > +{ > + struct parsed_partitions *state; > + > + state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL); I personally prefer sizefo(*state) here. It means the reader doesn't have to scroll back to check things. > + if (!state) > + return NULL; > + > + state->parts = vzalloc(nr * sizeof(state->parts[0])); > + if (!state->parts) { > + kfree(state); > + return NULL; > + } It doesn't really need to be this complex - we could just vmalloc the entire `struct parsed_partitions'. But I see that your change will cause us to allcoate much less memory in many situations, which is good. It should be mentioned in the changelog! -- 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: Page allocation failure on v3.8-rc5
On Fri, Feb 1, 2013 at 7:43 AM, Andrew Morton wrote: > On Wed, 30 Jan 2013 19:53:22 +0800 > Ming Lei wrote: > >> The allocation failure is caused by the big sizeof(struct parsed_partitions), >> which is 64K in my 32bit box, > > Geeze. > > We could fix that nicely by making parsed_partitions.parts an array of > pointers to a single `struct parsed_partition' and allocating those > on-demand. > > But given the short-lived nature of this storage and the infrequency of > check_partition(), that isn't necessary. > >> could you test the blow patch to see >> if it can fix the allocation failure? > > (The patch is wordwrapped) Sorry for that, I send out it for test. > >> ... >> >> @@ -106,18 +107,43 @@ static int (*check_part[])(struct parsed_partitions *) >> = { >> NULL >> }; >> >> +struct parsed_partitions *allocate_partitions(int nr) >> +{ >> + struct parsed_partitions *state; >> + >> + state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL); > > I personally prefer sizefo(*state) here. It means the reader doesn't > have to scroll back to check things. OK, will use sizeof(*state). >> + if (!state) >> + return NULL; >> + >> + state->parts = vzalloc(nr * sizeof(state->parts[0])); >> + if (!state->parts) { >> + kfree(state); >> + return NULL; >> + } > > It doesn't really need to be this complex - we could just vmalloc the > entire `struct parsed_partitions'. But I see that your change will The above approach can save one 32K allocation approximately. > cause us to allcoate much less memory in many situations, which is > good. It should be mentioned in the changelog! OK, I will add the changelog later. Thanks, -- Ming Lei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH,RFC] usb: add devicetree helpers for determining dr_mode and phy_type
On Thu, Jan 31, 2013 at 11:29:13AM +0100, Sascha Hauer wrote: > On Thu, Jan 31, 2013 at 10:05:44AM +0800, Peter Chen wrote: > > On Wed, Jan 30, 2013 at 03:00:15PM +0100, Sascha Hauer wrote: > > > On Wed, Jan 30, 2013 at 10:06:28AM +0800, Peter Chen wrote: > > > > On Tue, Jan 29, 2013 at 01:55:04PM +0200, Alexander Shishkin wrote: > > > > > Sascha Hauer writes: > > > > > > > > > > > From: Michael Grzeschik > > > > > > > > > > > > This adds two little devicetree helper functions for determining the > > > > > > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from > > > > > > the devicetree. > > > > > > > > > > > > Signed-off-by: Michael Grzeschik > > > > > > Signed-off-by: Marc Kleine-Budde > > > > > > --- > > > > > > > > > > > > The properties and their values have been taken from the fsl-mph-dr > > > > > > driver. > > > > > > This binding is also documented (though currently not used) for the > > > > > > tegra > > > > > > ehci driver > > > > > > (Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt). > > > > > > This is a first attempt to parse these bindings at a common place > > > > > > so that > > > > > > others can make use of it. > > > > > > > > > > > > Basically I want to know whether this binding is recommended for > > > > > > new drivers > > > > > > since normally the devicetree uses '-' instead of '_', and maybe > > > > > > there are > > > > > > other problems with it. > > > > > > > > > > > > I need this binding for the chipidea driver. I suspect that the > > > > > > fsl-mph-dr > > > > > > driver also really handles a chipidea core. > > > > > > > > > > As far as I know, it is a chipidea core. Adding Peter to Cc list, he > > > > > can > > > > > probably confirm. > > > > > > > > The fsl-mph-dr can't be used for chipdiea as it handles three platform > > > > drivers for three roles (peripheral , host, otg). But chipidea only has > > > > two platform drivers, one is the chipidea core, the other is related > > > > controller wrapper. > > > > > > What do you mean by 'three platform drivers'? That's only how the driver > > > is built, no? I was talking about the hardware the fsl-mph-dr driver > > > handles which definitely smells like chipidea. > > > > It creates host/device/otg platform device according to dr_mode from > > the device tree. > > Again, that's software specific. What I'd like to know is whether the > *hardware* could be handled by the chipidea driver. not understand u, you mean the DT information at there? Those DT information may not be used for i.mx hardware. > > Sascha > > > -- > Pengutronix e.K. | | > Industrial Linux Solutions | http://www.pengutronix.de/ | > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | > -- Best Regards, Peter Chen -- 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/2] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
On Thu, Jan 31, 2013 at 07:43:27PM +0530, kishon wrote: > Hi, > > On Thursday 31 January 2013 05:02 PM, Sascha Hauer wrote: > >Signed-off-by: Sascha Hauer > Some maintainers don't accept patches without a commit message. > > Apart from that you can add, > Reviewed-by: Kishon Vijay Abraham I Reviewed-by: Peter Chen > > Thanks > Kishon > -- Best Regards, Peter Chen -- 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 mxs-phy: Register phy with framework
On Thu, Jan 31, 2013 at 12:32:16PM +0100, Sascha Hauer wrote: > We now have usb_add_phy_dev(), so use it to register with the framework > to be able to find the phy from the USB driver. > > Signed-off-by: Sascha Hauer > --- > drivers/usb/otg/mxs-phy.c |9 + > 1 file changed, 9 insertions(+) > > diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c > index 5158332..5b39885 100644 > --- a/drivers/usb/otg/mxs-phy.c > +++ b/drivers/usb/otg/mxs-phy.c > @@ -127,6 +127,7 @@ static int mxs_phy_probe(struct platform_device *pdev) > void __iomem *base; > struct clk *clk; > struct mxs_phy *mxs_phy; > + int ret; > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > if (!res) { > @@ -166,11 +167,19 @@ static int mxs_phy_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, &mxs_phy->phy); > > + ret = usb_add_phy_dev(&mxs_phy->phy); > + if (ret) > + return ret; > + > return 0; > } > > static int mxs_phy_remove(struct platform_device *pdev) > { > + struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); > + > + usb_remove_phy(&mxs_phy->phy); > + > platform_set_drvdata(pdev, NULL); > > return 0; Reviewed-by: Peter Chen -- Best Regards, Peter Chen -- 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
USB Ooops PL2303 when unplug while use (linux v3.7.3)
Hi, I file a report for you, please have a look when you have time. with kind regards Chris report attached -- GTSYS Limited RFID Technology Unit 958 , KITEC - 1 Trademart Drive - Kowloon Bay - Hong Kong Fax (852) 8167 4060 - Tel (852) 3598 9488 Disclaimer: http://www.gtsys.com.hk/email/classified.html This is a script-generated kernel bug report. The system administrator/developer should provide additional information where appropriate. kernel-bug-report: : 1.3 $ : 2000/05/13 07:48:36 $ : root $ [1.] One line summary of the problem: PROBLEM: oops when unplug pl2303 usb2serial adapter while in use [2.] Full description of the problem/report: Kernel Oops when unplug a Polific USB to Serial Adapter while terminal program (minicom) still running. Old port becomes unuseable when replug the adapter bring set it to /dev/ttyUSB1 original /dev/ttyUSB0 is locked. [3.] Keywords (i.e., modules, networking, kernel): kernel, usb [4.] Kernel version (from /proc/version): Linux version 3.7.3 (chris@ws-chris64) (gcc version 4.4.5 (Debian 4.4.5-8) ) #3 SMP Sun Jan 20 17:07:00 HKT 2013 [5.] Output of Oops.. message [171977.391986] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0 [171977.392001] pl2303 2-1.2:1.0: device disconnected [171977.489723] BUG: unable to handle kernel NULL pointer dereference at (null) [171977.489788] IP: [] __ticket_spin_lock+0x5/0x1b [171977.489837] PGD 944ef067 PUD 944ee067 PMD 0 [171977.489874] Oops: 0002 [#1] SMP [171977.489901] Modules linked in: usblp pl2303 usbserial tun ip6table_filter ip6_tables iptable_filter ip_tables ebtable_nat ebtables x_tables ppdev lp bnep rfcomm bluetooth cpufreq_userspace cpufreq_conservative cpufreq_stats cpufreq_powersave xfrm4_tunnel tunnel4 ipcomp xfrm_ipcomp esp4 ah4 binfmt_misc deflate zlib_deflate ctr twofish_generic twofish_avx_x86_64 twofish_x86_64_3way twofish_x86_64 twofish_common serpent_sse2_x86_64 glue_helper lrw serpent_generic xts gf128mul blowfish_x86_64 blowfish_common cast5_avx_x86_64 ablk_helper cryptd cast5_generic des_generic cbc ecb sha512_generic sha256_generic sha1_ssse3 sha1_generic hmac af_key fuse bridge stp llc loop snd_hda_codec_realtek i915 drm_kms_helper snd_hda_intel snd_hda_codec drm snd_hwdep snd_pcm snd_seq snd_timer acpi_cpufreq i2c_algo_bit snd_seq_device kvm_intel snd parport_pc soundcore psmouse video mperf processor thermal_sys button hid_generic wmi parport pcspkr snd_page_alloc serio_raw kvm i2c_i801 i2c_core joydev evdev tpm_tis tpm tpm_bios hid_logitech_dj ext4 mbcache jbd2 crc16 dm_mod usb_storage nbd usbhid hid sd_mod crc_t10dif ahci libahci ehci_hcd libata scsi_mod usbcore usb_common r8169 mii [171977.490824] CPU 0 [171977.490842] Pid: 9298, comm: minicom Not tainted 3.7.3 #3 LENOVO 1652A7B/To be filled by O.E.M. [171977.490901] RIP: 0010:[] [] __ticket_spin_lock+0x5/0x1b [171977.490960] RSP: 0018:88004a427aa0 EFLAGS: 00010082 [171977.490996] RAX: 0001 RBX: 0282 RCX: [171977.491043] RDX: 88012d7b1000 RSI: 0282 RDI: [171977.491090] RBP: 88012d7b1000 R08: R09: 0282 [171977.491136] R10: 0282 R11: 813150a6 R12: [171977.491185] R13: 0282 R14: 88003d745d00 R15: 88003d745d00 [171977.491232] FS: 7fc23503d700() GS:88013fa0() knlGS: [171977.491287] CS: 0010 DS: ES: CR0: 80050033 [171977.491325] CR2: CR3: 9493c000 CR4: 000427e0 [171977.491371] DR0: DR1: DR2: [171977.491418] DR3: DR6: 0ff0 DR7: 0400 [171977.491465] Process minicom (pid: 9298, threadinfo 88004a426000, task 880139a84600) [171977.491518] Stack: [171977.491533] 81022176 813150a6 0282 [171977.491590] a0518454 88012d7b1008 88012d7b6800 88012d7b1018 [171977.491647] 811f4881 88012d7b1008 88012d7b6800 [171977.491703] Call Trace: [171977.491724] [] ? default_spin_lock_flags+0x5/0xb [171977.491768] [] ? _raw_spin_lock_irqsave+0x1e/0x26 [171977.491815] [] ? pl2303_dtr_rts+0x21/0x53 [pl2303] [171977.491861] [] ? tty_port_close_start+0x16a/0x178 [171977.491905] [] ? tty_port_close+0x11/0x43 [171977.491944] [] ? tty_release+0x16d/0x4b9 [171977.491984] [] ? __pollwait+0xd0/0xd0 [171977.492021] [] ? mutex_lock+0xd/0x2b [171977.492059] [] ? serial_activate+0x52/0x7c [usbserial] [171977.492104] [] ? __pollwait+0xd0/0xd0 [171977.492141] [] ? tty_open+0x33a/0x46a [171977.492178] [] ? chrdev_open+0x12e/0x149 [171977.492216] [] ? cdev_put+0x1a/0x1a [171977.492253] [] ? do_dentry_open+0x171/0x217 [171977.492293] [] ? finish_open+0x2c/0x35 [171977.492331] [] ? do_last+0x897/0xa38 [171977.492367] [] ? __inode_permission+0x62/0xa3 [171977.4
Re: [PATCH RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
Hi, On Thursday 31 January 2013 09:08 PM, Felipe Balbi wrote: On Thu, Jan 31, 2013 at 09:00:37PM +0530, Vivek Gautam wrote: Hi Felipe, On Thu, Jan 31, 2013 at 8:55 PM, Felipe Balbi wrote: Hi, On Thu, Jan 31, 2013 at 08:53:27PM +0530, Vivek Gautam wrote: Moreover, SoCs having multiple dwc3 controllers will have multiple PHYs, which eventually be added using usb_add_phy_dev(), and not using usb_add_phy(). So each dwc3 controller won't be able to get PHYs by simply calling devm_usb_get_phy() also. No. We have added usb_get_phy_dev() for that purpose in the case of non-dt. I think, instead you can have a patch to use devm_usb_get_phy_dev() here and in exynos platform specific code use usb_bind_phy() to bind the phy and controller till you change it to dt. We have dt support for dwc3-exynos, in such case we should go ahead with of_platform_populate(), right ? But if when i use of_platform_populate() i will not be able to set dma_mask to dwc3->dev. :-( You can do something like this static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32); static int dwc3_exynos_set_dmamask(struct device *dev, void *c) { dev->dma_mask = &dwc3_exynos_dma_mask; return 0; } And in your probe after of_platform_populate, you can add device_for_each_child(&pdev->dev, NULL, dwc3_exynos_set_dmamask); Here pdev is the platform device of dwc3-exynos. By this way all the children of dwc3-exynos will have dma_mask set to the required value. I'm not sure if there is any other better way to achieve the same (without patching of.c ;-)) Thanks Kishon -- 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: Not enough resource for old configuration after USB bus reset
Hi, According to xHCI spec Rev1 page 125, Endpoint context state diagram. When reset device, the endpoint state transit to disabled state. Do I make some mistake? I'll try to figure out the endopint state transitions during the reset flow, and update information later. Thanks for the direction. Soar From: Alan Stern [mailto:st...@rowland.harvard.edu] Sent: Thursday, January 31, 2013 12:22 AM To: 洪崇耕 Cc: linux-usb@vger.kernel.org Subject: RE: Not enough resource for old configuration after USB bus reset On Wed, 30 Jan 2013, [big5] x R wrote: > Hi all, > > We try to reproduce the problem on general desktop with ubuntu 12.04.1 and > 12.10, and got some information below: > > 1. If we use xHci with Ti TUSB7340 chip, do bus reset or plug/unplug 1000+ > times, the host fail to configure the device. > If we use xHci with Fresco chip, it operats without error. > > 2. If the usb device contains only Control/Bulk type endpoints, it's all > right. > If it contains interrupt/isoc (periodic) endpoint, it will fail with > bandwidth error. > I check the source and find that the bandwidth_error is the > TRB_completion_code of configure_endpoint command. > > In addition, I try to study the usb_reset_and_verify_device and want to > consult the following question. > > When reseting a device, hcd will invoke usb_hcd_alloc_bandwidth, this > function will drop the endpoints and add the endpoints. > > When executing drop_endpoint, the function shows error message xHCI called > with disabled ep. > And I confirm that ep_state of end point context is in disabled state this > time. Why is the endpoint already disabled? It shouldn't be. > Then usb_hcd_alloc_bandwidth invokes add_endpoint. > Last, sending a configure endpoint command to complete the change. > > The xHCI spec says configure endpoint should ignore disabled endpoints drop > flag and do nothing. > So the source is correct according to spec. > But the overall behavior is adding the endpoint without dropping the old > endpoint. > > Is this what we want? Don't we need dropping endpoints to release the > bandwidth and/or resource before the endpoints goes to disabled state without > freeing bandwidth? Yes. It would work okay if the endpoint wasn't already disabled. Can you figure out how the endpoint became disabled in the first place? Alan Stern N�妓緶r��y���匒淅炮カv傂�)瑎{.n�+�極�{捱〇�傂n�r←屹��螐�刻俾&p埂��嶭�(剝���摃j"���m翯z嫡��僠fㄑ搬��坍�m�
Re: [PATCH RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
Hi Kishon, On Fri, Feb 1, 2013 at 10:51 AM, kishon wrote: > Hi, > > > On Thursday 31 January 2013 09:08 PM, Felipe Balbi wrote: >> >> On Thu, Jan 31, 2013 at 09:00:37PM +0530, Vivek Gautam wrote: >>> >>> Hi Felipe, >>> >>> >>> On Thu, Jan 31, 2013 at 8:55 PM, Felipe Balbi wrote: Hi, On Thu, Jan 31, 2013 at 08:53:27PM +0530, Vivek Gautam wrote: >>> >>> Moreover, SoCs having multiple dwc3 controllers will have multiple >>> PHYs, which eventually be added using usb_add_phy_dev(), and not >>> using usb_add_phy(). So each dwc3 controller won't be able to >>> get PHYs by simply calling devm_usb_get_phy() also. >> >> >> No. We have added usb_get_phy_dev() for that purpose in the case of >> non-dt. >> I think, instead you can have a patch to use devm_usb_get_phy_dev() >> here and >> in exynos platform specific code use usb_bind_phy() to bind the phy >> and >> controller till you change it to dt. >> > > We have dt support for dwc3-exynos, in such case we should go ahead > with > of_platform_populate(), right ? > But if when i use of_platform_populate() i will not be able to set > dma_mask to dwc3->dev. :-( > > > You can do something like this > > static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32); > > static int dwc3_exynos_set_dmamask(struct device *dev, void *c) > { > dev->dma_mask = &dwc3_exynos_dma_mask; > > return 0; > } > > And in your probe after of_platform_populate, you can add > > device_for_each_child(&pdev->dev, NULL, dwc3_exynos_set_dmamask); > > Here pdev is the platform device of dwc3-exynos. By this way all the > children of dwc3-exynos will have dma_mask set to the required value. > Nice idea, thanks :-) hmm.. so i can patch this now, and get things working ;-) > I'm not sure if there is any other better way to achieve the same (without > patching of.c ;-)) > -- Thanks & Regards Vivek -- 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 RFC] usb: dwc3: Get PHY from platform specific dwc3 dt node.
Hi Balbi, On Fri, Feb 1, 2013 at 11:52 AM, Vivek Gautam wrote: > Hi Kishon, > > > On Fri, Feb 1, 2013 at 10:51 AM, kishon wrote: >> Hi, >> >> >> On Thursday 31 January 2013 09:08 PM, Felipe Balbi wrote: >>> >>> On Thu, Jan 31, 2013 at 09:00:37PM +0530, Vivek Gautam wrote: Hi Felipe, On Thu, Jan 31, 2013 at 8:55 PM, Felipe Balbi wrote: > > Hi, > > On Thu, Jan 31, 2013 at 08:53:27PM +0530, Vivek Gautam wrote: Moreover, SoCs having multiple dwc3 controllers will have multiple PHYs, which eventually be added using usb_add_phy_dev(), and not using usb_add_phy(). So each dwc3 controller won't be able to get PHYs by simply calling devm_usb_get_phy() also. >>> >>> >>> No. We have added usb_get_phy_dev() for that purpose in the case of >>> non-dt. >>> I think, instead you can have a patch to use devm_usb_get_phy_dev() >>> here and >>> in exynos platform specific code use usb_bind_phy() to bind the phy >>> and >>> controller till you change it to dt. >>> >> >> We have dt support for dwc3-exynos, in such case we should go ahead >> with >> of_platform_populate(), right ? >> But if when i use of_platform_populate() i will not be able to set >> dma_mask to dwc3->dev. :-( >> >> >> You can do something like this >> >> static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32); >> >> static int dwc3_exynos_set_dmamask(struct device *dev, void *c) >> { >> dev->dma_mask = &dwc3_exynos_dma_mask; >> >> return 0; >> } >> >> And in your probe after of_platform_populate, you can add >> >> device_for_each_child(&pdev->dev, NULL, dwc3_exynos_set_dmamask); >> >> Here pdev is the platform device of dwc3-exynos. By this way all the >> children of dwc3-exynos will have dma_mask set to the required value. >> > > Nice idea, thanks :-) > hmm.. so i can patch this now, and get things working ;-) > If this is fine with you shall i go ahead and post a patch for the same ? ;-) >> I'm not sure if there is any other better way to achieve the same (without >> patching of.c ;-)) >> > -- Thanks & Regards Vivek -- 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,RFC] usb: add devicetree helpers for determining dr_mode and phy_type
On Fri, Feb 01, 2013 at 09:11:54AM +0800, Peter Chen wrote: > On Thu, Jan 31, 2013 at 11:29:13AM +0100, Sascha Hauer wrote: > > On Thu, Jan 31, 2013 at 10:05:44AM +0800, Peter Chen wrote: > > > On Wed, Jan 30, 2013 at 03:00:15PM +0100, Sascha Hauer wrote: > > > > On Wed, Jan 30, 2013 at 10:06:28AM +0800, Peter Chen wrote: > > > > > On Tue, Jan 29, 2013 at 01:55:04PM +0200, Alexander Shishkin wrote: > > > > > > Sascha Hauer writes: > > > > > > > > > > > > > From: Michael Grzeschik > > > > > > > > > > > > > > This adds two little devicetree helper functions for determining > > > > > > > the > > > > > > > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from > > > > > > > the devicetree. > > > > > > > > > > > > > > Signed-off-by: Michael Grzeschik > > > > > > > Signed-off-by: Marc Kleine-Budde > > > > > > > --- > > > > > > > > > > > > > > The properties and their values have been taken from the > > > > > > > fsl-mph-dr driver. > > > > > > > This binding is also documented (though currently not used) for > > > > > > > the tegra > > > > > > > ehci driver > > > > > > > (Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt). > > > > > > > This is a first attempt to parse these bindings at a common place > > > > > > > so that > > > > > > > others can make use of it. > > > > > > > > > > > > > > Basically I want to know whether this binding is recommended for > > > > > > > new drivers > > > > > > > since normally the devicetree uses '-' instead of '_', and maybe > > > > > > > there are > > > > > > > other problems with it. > > > > > > > > > > > > > > I need this binding for the chipidea driver. I suspect that the > > > > > > > fsl-mph-dr > > > > > > > driver also really handles a chipidea core. > > > > > > > > > > > > As far as I know, it is a chipidea core. Adding Peter to Cc list, > > > > > > he can > > > > > > probably confirm. > > > > > > > > > > The fsl-mph-dr can't be used for chipdiea as it handles three platform > > > > > drivers for three roles (peripheral , host, otg). But chipidea only > > > > > has > > > > > two platform drivers, one is the chipidea core, the other is related > > > > > controller wrapper. > > > > > > > > What do you mean by 'three platform drivers'? That's only how the driver > > > > is built, no? I was talking about the hardware the fsl-mph-dr driver > > > > handles which definitely smells like chipidea. > > > > > > It creates host/device/otg platform device according to dr_mode from > > > the device tree. > > > > Again, that's software specific. What I'd like to know is whether the > > *hardware* could be handled by the chipidea driver. > not understand u, you mean the DT information at there? Those DT information > may not be used for i.mx hardware. The original question was: There is a driver in the tree called fsl-mph-dr-of.c. Does this driver handle a hardware which is compatible to the hardware the chipidea driver handles? I think the answer is yes, because said driver registers a ehci device, or fsl-usb2-udc device (the same we used on i.MX). This hardware also has a PORTSC register. All this seems to suggest that drivers/usb/host/fsl-mph-dr-of.c drivers/usb/host/ehci-fsl.c drivers/usb/otg/fsl_otg.c drivers/usb/gadget/fsl_usb2_udc.h drivers/usb/gadget/fsl_udc_core.c Could be replaced by the chipidea driver. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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: Linux USB file storage gadget with new UDC
Hi, >> i have list_add_tail() in my ep_queue() function. Prior to ep1 >> receiving data, my ep_queue() is called to send 0x00 to ep0. then it >> is not called. how to make it to be called by file gadget, in order to >> queue the request before ep1 interrupt? > > This should happen when get_next_command() calls start_transfer(), > which calls usb_ep_queue(). I put printk in fsg_main_thread. After insmod g_file_storage, the fsg_main_thread goes to fsg->running. Then it sleeps. When ep1 receives data, get_next_command() is not called, so start_transfer() is not called. The fsg_main_thread is sleeping in sleep_thread(). How to make it wake up? is there anything udc driver has to do to wake up fsg_main_thread? thanks, victor -- 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 chipidea i.MX: use framework phy handling
On Thu, Jan 31, 2013 at 12:32:15PM +0100, Sascha Hauer wrote: > This series switches the mxs phy and the i.MX chipidea support > from homegrew phy support to use usb_add_phy_dev/devm_usb_get_phy_by_phandle. > > Based on > > [PATCH v2] Add USB of helpers and use them in the chipidea driver > > But I think this could also be applied separately if necessary. Kishon, Peter, Thanks for reviewing these, but I'm afraid I must send another iteration for these. These patches do not handle -EPROBE_DEFER correctly. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- 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 7/9] como fec wip
Signed-off-by: Sascha Hauer --- Documentation/devicetree/bindings/net/fsl-fec.txt | 20 ++ drivers/net/ethernet/freescale/fec.c | 77 - drivers/net/ethernet/freescale/fec.h |1 + 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt index d536392..ec7060b 100644 --- a/Documentation/devicetree/bindings/net/fsl-fec.txt +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt @@ -15,6 +15,9 @@ Optional properties: only if property "phy-reset-gpios" is available. Missing the property will have the duration be 1 millisecond. Numbers greater than 1000 are invalid and 1 millisecond will be used instead. +- phy : a phandle for the PHY device used for the fec. Used to specify an + external phy or to specify a particular address if the mdio bus has multiple + phys on it. Example: @@ -26,3 +29,20 @@ ethernet@83fec000 { phy-reset-gpios = <&gpio2 14 0>; /* GPIO2_14 */ local-mac-address = [00 04 9F 01 1B B9]; }; + +Example with specific phy address: + +ethernet@83fec000 { + compatible = "fsl,imx51-fec", "fsl,imx27-fec"; + reg = <0x83fec000 0x4000>; + interrupts = <87>; + phy-mode = "mii"; + phy-reset-gpios = <&gpio2 14 0>; /* GPIO2_14 */ + local-mac-address = [00 04 9F 01 1B B9]; + phy = &phy3; + + phy3: ethernet-phy@3 { + reg = <3>; + device_type = "ethernet-phy"; + }; +}; diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index 0704bca..54a8506 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -950,31 +951,38 @@ static int fec_enet_mii_probe(struct net_device *ndev) fep->phy_dev = NULL; - /* check for attached phy */ - for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) { - if ((fep->mii_bus->phy_mask & (1 << phy_id))) - continue; - if (fep->mii_bus->phy_map[phy_id] == NULL) - continue; - if (fep->mii_bus->phy_map[phy_id]->phy_id == 0) - continue; - if (dev_id--) - continue; - strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE); - break; - } + if (fep->phy_node) { + phy_dev = of_phy_connect(ndev, fep->phy_node, &fec_enet_adjust_link, 0, + fep->phy_interface); + } else { + /* check for attached phy */ + for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) { + if ((fep->mii_bus->phy_mask & (1 << phy_id))) + continue; + if (fep->mii_bus->phy_map[phy_id] == NULL) + continue; + if (fep->mii_bus->phy_map[phy_id]->phy_id == 0) + continue; + if (dev_id--) + continue; + strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE); + break; + } - if (phy_id >= PHY_MAX_ADDR) { - printk(KERN_INFO - "%s: no PHY, assuming direct connection to switch\n", - ndev->name); - strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); - phy_id = 0; + if (phy_id >= PHY_MAX_ADDR) { + printk(KERN_INFO + "%s: no PHY, assuming direct connection to switch\n", + ndev->name); + strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); + phy_id = 0; + } + + snprintf(phy_name, sizeof(phy_name), PHY_ID_FMT, mdio_bus_id, phy_id); + + phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link, 0, + fep->phy_interface); } - snprintf(phy_name, sizeof(phy_name), PHY_ID_FMT, mdio_bus_id, phy_id); - phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link, 0, - fep->phy_interface); if (IS_ERR(phy_dev)) { printk(KERN_ERR "%s: could not attach to PHY\n", ndev->name); return PTR_ERR(phy_dev); @@ -1076,7 +1084,12 @@ static int fec_enet_mii_init(struct platform_device *pdev) for (i = 0; i < PHY_MAX_ADDR; i++) fep->mii_bus->irq[i] = PHY_POLL; - if (mdiobus_register(fep->mii_bus)) + if (fep->phy_node) + err = of_mdiobus_register(fep->mii_bus, pdev->dev.of_node); + else + err = mdiobus_register(fep->mii_bus); + +
[PATCH 5/9] USB chipidea: introduce dual role mode pdata flags
Even if a chipidea core is otg capable the board may not. This allows to explicitly set the core to host/peripheral mode. Without these flags the driver falls back to the old behaviour. Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/core.c | 21 +++-- include/linux/usb/chipidea.h |2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index a3ec29d..b2dbf55 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -435,6 +435,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) struct resource *res; void __iomem*base; int ret; + int dr_mode; if (!dev->platform_data) { dev_err(dev, "platform data missing\n"); @@ -487,14 +488,22 @@ static int ci_hdrc_probe(struct platform_device *pdev) return -ENODEV; } + dr_mode = ci->platdata->dr_mode; + if (dr_mode == USB_DR_MODE_UNKNOWN) + dr_mode = USB_DR_MODE_OTG; + /* initialize role(s) before the interrupt is requested */ - ret = ci_hdrc_host_init(ci); - if (ret) - dev_info(dev, "doesn't support host\n"); + if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) { + ret = ci_hdrc_host_init(ci); + if (ret) + dev_info(dev, "doesn't support host\n"); + } - ret = ci_hdrc_gadget_init(ci); - if (ret) - dev_info(dev, "doesn't support gadget\n"); + if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) { + ret = ci_hdrc_gadget_init(ci); + if (ret) + dev_info(dev, "doesn't support gadget\n"); + } if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { dev_err(dev, "no supported roles\n"); diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index 1a2aa18..b314647 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -20,7 +20,7 @@ struct ci13xxx_platform_data { #define CI13XXX_REQUIRE_TRANSCEIVERBIT(1) #define CI13XXX_PULLUP_ON_VBUS BIT(2) #define CI13XXX_DISABLE_STREAMING BIT(3) - + enum usb_dr_modedr_mode; #define CI13XXX_CONTROLLER_RESET_EVENT 0 #define CI13XXX_CONTROLLER_STOPPED_EVENT 1 void(*notify_event) (struct ci13xxx *ci, unsigned event); -- 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 3/9] USB: chipidea: ci13xxx-imx: create dynamic platformdata
From: Michael Grzeschik This patch removes the limitation of having only one instance of the ci13xxx-imx platformdata and makes different configurations possible. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer Reviewed-by: Peter Chen --- drivers/usb/chipidea/ci13xxx_imx.c | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index 8c29122..69024e0 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data); /* End of common functions shared by usbmisc drivers*/ -static struct ci13xxx_platform_data ci13xxx_imx_platdata = { - .name = "ci13xxx_imx", - .flags = CI13XXX_REQUIRE_TRANSCEIVER | - CI13XXX_PULLUP_ON_VBUS | - CI13XXX_DISABLE_STREAMING, - .capoffset = DEF_CAPOFFSET, -}; - static int ci13xxx_imx_probe(struct platform_device *pdev) { struct ci13xxx_imx_data *data; + struct ci13xxx_platform_data *pdata; struct platform_device *plat_ci, *phy_pdev; struct device_node *phy_np; struct resource *res; @@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) && !usbmisc_ops) return -EPROBE_DEFER; + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n"); + return -ENOMEM; + } + + pdata->name = "ci13xxx_imx"; + pdata->capoffset = DEF_CAPOFFSET; + pdata->flags = CI13XXX_REQUIRE_TRANSCEIVER | + CI13XXX_PULLUP_ON_VBUS | + CI13XXX_DISABLE_STREAMING; + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); @@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) reg_vbus = NULL; } - ci13xxx_imx_platdata.phy = data->phy; + pdata->phy = data->phy; if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = devm_kzalloc(&pdev->dev, @@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) plat_ci = ci13xxx_add_device(&pdev->dev, pdev->resource, pdev->num_resources, - &ci13xxx_imx_platdata); + pdata); if (IS_ERR(plat_ci)) { ret = PTR_ERR(plat_ci); dev_err(&pdev->dev, -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/9] USB: add devicetree helpers for determining dr_mode and phy_type
From: Michael Grzeschik This adds two little devicetree helper functions for determining the dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from the devicetree. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- drivers/usb/phy/Makefile |1 + drivers/usb/phy/of.c | 47 ++ drivers/usb/usb-common.c | 36 +++ include/linux/usb/of.h | 27 ++ include/linux/usb/otg.h |7 +++ include/linux/usb/phy.h |9 + 6 files changed, 127 insertions(+) create mode 100644 drivers/usb/phy/of.c create mode 100644 include/linux/usb/of.h diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 9fa6327..e1be1e8 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -5,6 +5,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG obj-$(CONFIG_USB_OTG_UTILS)+= phy.o +obj-$(CONFIG_OF) += of.o obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o obj-$(CONFIG_OMAP_USB3)+= omap-usb3.o obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c new file mode 100644 index 000..e6f3b74 --- /dev/null +++ b/drivers/usb/phy/of.c @@ -0,0 +1,47 @@ +/* + * USB of helper code + * + * 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. + */ + +#include +#include +#include +#include +#include + +static const char *usbphy_modes[] = { + [USBPHY_INTERFACE_MODE_UNKNOWN] = "", + [USBPHY_INTERFACE_MODE_UTMI]= "utmi", + [USBPHY_INTERFACE_MODE_UTMIW] = "utmi_wide", + [USBPHY_INTERFACE_MODE_ULPI]= "ulpi", + [USBPHY_INTERFACE_MODE_SERIAL] = "serial", + [USBPHY_INTERFACE_MODE_HSIC]= "hsic", +}; + +/** + * of_usb_get_phy_mode - Get phy mode for given device_node + * @np:Pointer to the given device_node + * + * The function gets phy interface string from property 'phy_type', + * and returns the correspondig enum usb_phy_interface + */ +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) +{ + const char *phy_type; + int err, i; + + err = of_property_read_string(np, "phy_type", &phy_type); + if (err < 0) + return USBPHY_INTERFACE_MODE_UNKNOWN; + + for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++) + if (!strcmp(phy_type, usbphy_modes[i])) + return i; + + return USBPHY_INTERFACE_MODE_UNKNOWN; +} +EXPORT_SYMBOL_GPL(of_usb_get_phy_mode); diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c index d29503e..ad4d87d 100644 --- a/drivers/usb/usb-common.c +++ b/drivers/usb/usb-common.c @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include const char *usb_speed_string(enum usb_device_speed speed) { @@ -32,4 +35,37 @@ const char *usb_speed_string(enum usb_device_speed speed) } EXPORT_SYMBOL_GPL(usb_speed_string); +#ifdef CONFIG_OF +static const char *usb_dr_modes[] = { + [USB_DR_MODE_UNKNOWN] = "", + [USB_DR_MODE_HOST] = "host", + [USB_DR_MODE_PERIPHERAL]= "peripheral", + [USB_DR_MODE_OTG] = "otg", +}; + +/** + * of_usb_get_dr_mode - Get dual role mode for given device_node + * @np:Pointer to the given device_node + * + * The function gets phy interface string from property 'dr_mode', + * and returns the correspondig enum usb_dr_mode + */ +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) +{ + const char *dr_mode; + int err, i; + + err = of_property_read_string(np, "dr_mode", &dr_mode); + if (err < 0) + return USB_DR_MODE_UNKNOWN; + + for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) + if (!strcmp(dr_mode, usb_dr_modes[i])) + return i; + + return USB_DR_MODE_UNKNOWN; +} +EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); +#endif + MODULE_LICENSE("GPL"); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h new file mode 100644 index 000..4681a20 --- /dev/null +++ b/include/linux/usb/of.h @@ -0,0 +1,27 @@ +/* + * OF helpers for usb devices. + * + * This file is released under the GPLv2 + */ + +#ifndef __LINUX_USB_OF_H +#define __LINUX_USB_OF_H + +#include + +#ifdef CONFIG_OF +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np); +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); +#else +static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np) +{ + return USBPHY_INTERFACE_MODE_UNKNOWN; +} + +static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) +{ + return USB_DR_MODE_
[PATCH 8/9] USB mxs-phy: Register phy with framework
We now have usb_add_phy_dev(), so use it to register with the framework to be able to find the phy from the USB driver. Signed-off-by: Sascha Hauer --- drivers/usb/otg/mxs-phy.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c index 5158332..5b39885 100644 --- a/drivers/usb/otg/mxs-phy.c +++ b/drivers/usb/otg/mxs-phy.c @@ -127,6 +127,7 @@ static int mxs_phy_probe(struct platform_device *pdev) void __iomem *base; struct clk *clk; struct mxs_phy *mxs_phy; + int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -166,11 +167,19 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &mxs_phy->phy); + ret = usb_add_phy_dev(&mxs_phy->phy); + if (ret) + return ret; + return 0; } static int mxs_phy_remove(struct platform_device *pdev) { + struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); + + usb_remove_phy(&mxs_phy->phy); + platform_set_drvdata(pdev, NULL); return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3] USB: add devicetree helpers for determining dr_mode and phy_type
(resend because I got the linux-usb address wrong) Here's another round of the dr_mode/phy_type patches. I think they should be ready for merging now. Greg, will you apply them should there be no problems anymore? Sascha changes since v2: - fix adding of GPL Header was in wrong patch - add missing hunk for new file of.c changes since v1: - move phy specific of helper to drivers/usb/phy/of.c - use strcmp instead of strcasecmp for matching property values - change usb_phy_dr_mode to usb_dr_mode - change USBPHY_INTERFACE_MODE_NA to USBPHY_INTERFACE_MODE_UNKNOWN - add copyright header to new files - chipidea: drop mdelay at end of PTS/PTW setup - chipidea: implement lpm core type handling for PTS/PTW The following changes since commit 7b8bc3aad0deabf3bc50cd2fe29bce29be5681fe: USB: chipidea: ci13xxx_imx: Remove sparse warning (2013-01-30 00:17:39 -0500) are available in the git repository at: git://git.pengutronix.de/git/imx/linux-2.6.git tags/usb-chipidea-for-next for you to fetch changes up to b82b92ba281add3e4d67bf6704052c0fd8c5c7f0: USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy (2013-01-31 12:27:36 +0100) USB Chipidea patches for v3.9 These add OF helpers for handling the dr_mode and phy_type property and makes use of them in the chipidea driver. Michael Grzeschik (3): USB: add devicetree helpers for determining dr_mode and phy_type USB: chipidea: ci13xxx-imx: create dynamic platformdata USB: chipidea: add PTW and PTS handling Sascha Hauer (6): USB: move bulk of otg/otg.c to phy/phy.c USB chipidea: introduce dual role mode pdata flags USB chipidea i.MX: introduce dr_mode property como fec wip USB mxs-phy: Register phy with framework USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Documentation/devicetree/bindings/net/fsl-fec.txt | 20 + .../devicetree/bindings/usb/ci13xxx-imx.txt|6 + drivers/net/ethernet/freescale/fec.c | 77 ++-- drivers/net/ethernet/freescale/fec.h |1 + drivers/usb/chipidea/bits.h| 14 +- drivers/usb/chipidea/ci13xxx_imx.c | 60 ++- drivers/usb/chipidea/core.c| 60 ++- drivers/usb/otg/mxs-phy.c |9 + drivers/usb/otg/otg.c | 423 --- drivers/usb/phy/Makefile |2 + drivers/usb/phy/of.c | 47 +++ drivers/usb/phy/phy.c | 434 drivers/usb/usb-common.c | 36 ++ include/linux/usb/chipidea.h |3 +- include/linux/usb/of.h | 27 ++ include/linux/usb/otg.h|7 + include/linux/usb/phy.h|9 + 17 files changed, 742 insertions(+), 493 deletions(-) create mode 100644 drivers/usb/phy/of.c create mode 100644 drivers/usb/phy/phy.c create mode 100644 include/linux/usb/of.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 4/9] USB: chipidea: add PTW and PTS handling
From: Michael Grzeschik This patch makes it possible to configure the PTW and PTS bits inside the portsc register for host and device mode before the driver starts and the phy can be addressed as hardware implementation is designed. Signed-off-by: Michael Grzeschik Signed-off-by: Marc Kleine-Budde Signed-off-by: Sascha Hauer --- .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +++ drivers/usb/chipidea/bits.h| 14 ++- drivers/usb/chipidea/ci13xxx_imx.c |3 ++ drivers/usb/chipidea/core.c| 39 include/linux/usb/chipidea.h |1 + 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt index 5778b9c..dd42ccd 100644 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt @@ -5,6 +5,11 @@ Required properties: - reg: Should contain registers location and length - interrupts: Should contain controller interrupt +Recommended properies: +- phy_type: the type of the phy connected to the core. Should be one + of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this + property the PORTSC register won't be touched + Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port - fsl,usbmisc: phandler of non-core register device, with one argument diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h index 050de85..d8ffc2f 100644 --- a/drivers/usb/chipidea/bits.h +++ b/drivers/usb/chipidea/bits.h @@ -48,10 +48,22 @@ #define PORTSC_SUSP BIT(7) #define PORTSC_HSPBIT(9) #define PORTSC_PTC(0x0FUL << 16) +/* PTS and PTW for non lpm version only */ +#define PORTSC_PTS(d) d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0)) +#define PORTSC_PTWBIT(28) /* DEVLC */ #define DEVLC_PSPD(0x03UL << 25) -#defineDEVLC_PSPD_HS (0x02UL << 25) +#define DEVLC_PSPD_HS (0x02UL << 25) +#define DEVLC_PTW BIT(27) +#define DEVLC_STS BIT(28) +#define DEVLC_PTS(d) (((d) & 0x7) << 29) + +/* Encoding for DEVLC_PTS and PORTSC_PTS */ +#define PTS_UTMI 0 +#define PTS_ULPI 2 +#define PTS_SERIAL3 +#define PTS_HSIC 4 /* OTGSC */ #define OTGSC_IDPU BIT(5) diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index 69024e0..ebc1148 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "ci.h" #include "ci13xxx_imx.h" @@ -112,6 +113,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) CI13XXX_PULLUP_ON_VBUS | CI13XXX_DISABLE_STREAMING; + pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node); + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n"); diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 57cae1f..a3ec29d 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -67,6 +67,8 @@ #include #include #include +#include +#include #include "ci.h" #include "udc.h" @@ -211,6 +213,41 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base) return 0; } +static void hw_phymode_configure(struct ci13xxx *ci) +{ + u32 portsc, lpm; + + switch (ci->platdata->phy_mode) { + case USBPHY_INTERFACE_MODE_UTMI: + portsc = PORTSC_PTS(PTS_UTMI); + lpm = DEVLC_PTS(PTS_UTMI); + break; + case USBPHY_INTERFACE_MODE_UTMIW: + portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW; + lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW; + break; + case USBPHY_INTERFACE_MODE_ULPI: + portsc = PORTSC_PTS(PTS_ULPI); + lpm = DEVLC_PTS(PTS_ULPI); + break; + case USBPHY_INTERFACE_MODE_SERIAL: + portsc = PORTSC_PTS(PTS_SERIAL); + lpm = DEVLC_PTS(PTS_SERIAL); + break; + case USBPHY_INTERFACE_MODE_HSIC: + portsc = PORTSC_PTS(PTS_HSIC); + lpm = DEVLC_PTS(PTS_HSIC); + break; + default: + return; + } + + if (ci->hw_bank.lpm) + hw_write(ci, OP_PORTSC, DEVLC_PTS(7) | DEVLC_PTW, lpm); + else + hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc); +} + /** * hw_device_reset: resets chip (execute without interruption) * @ci: the controller @@ -476,6 +513,8 @@ static int ci_hdrc_probe(struct platform_device *pdev) : CI_ROLE_GAD
[PATCH 6/9] USB chipidea i.MX: introduce dr_mode property
The dr_mode devicetree property allows to explicitly specify the host/peripheral/otg mode. This is necessary for boards without proper ID pin handling. Signed-off-by: Sascha Hauer Reviewed-by: Peter Chen --- Documentation/devicetree/bindings/usb/ci13xxx-imx.txt |1 + drivers/usb/chipidea/ci13xxx_imx.c|1 + 2 files changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt index dd42ccd..493a414 100644 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt @@ -9,6 +9,7 @@ Recommended properies: - phy_type: the type of the phy connected to the core. Should be one of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this property the PORTSC register won't be touched +- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index ebc1148..b598bb8f 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -114,6 +114,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) CI13XXX_DISABLE_STREAMING; pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node); + pdata->dr_mode = of_usb_get_dr_mode(pdev->dev.of_node); data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { -- 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 9/9] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
Signed-off-by: Sascha Hauer --- drivers/usb/chipidea/ci13xxx_imx.c | 31 ++- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index b598bb8f..1df4b41 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c @@ -30,7 +30,6 @@ ((struct usb_phy *)platform_get_drvdata(pdev)) struct ci13xxx_imx_data { - struct device_node *phy_np; struct usb_phy *phy; struct platform_device *ci_pdev; struct clk *clk; @@ -90,12 +89,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) { struct ci13xxx_imx_data *data; struct ci13xxx_platform_data *pdata; - struct platform_device *plat_ci, *phy_pdev; - struct device_node *phy_np; + struct platform_device *plat_ci; struct resource *res; struct regulator *reg_vbus; struct pinctrl *pinctrl; int ret; + struct usb_phy *phy; if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL) && !usbmisc_ops) @@ -147,18 +146,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) return ret; } - phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0); - if (phy_np) { - data->phy_np = phy_np; - phy_pdev = of_find_device_by_node(phy_np); - if (phy_pdev) { - struct usb_phy *phy; - phy = pdev_to_phy(phy_pdev); - if (phy && - try_module_get(phy_pdev->dev.driver->owner)) { - usb_phy_init(phy); - data->phy = phy; - } + phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0); + if (!IS_ERR(phy)) { + ret = usb_phy_init(phy); + if (ret) { + dev_err(&pdev->dev, "unable to init phy: %d\n", ret); + goto err_clk; } } @@ -170,7 +163,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to enable vbus regulator, err=%d\n", ret); - goto put_np; + goto err_clk; } data->reg_vbus = reg_vbus; } else { @@ -222,9 +215,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) err: if (reg_vbus) regulator_disable(reg_vbus); -put_np: - if (phy_np) - of_node_put(phy_np); +err_clk: clk_disable_unprepare(data->clk); return ret; } @@ -244,8 +235,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev) module_put(data->phy->dev->driver->owner); } - of_node_put(data->phy_np); - clk_disable_unprepare(data->clk); platform_set_drvdata(pdev, NULL); -- 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 1/9] USB: move bulk of otg/otg.c to phy/phy.c
Most of otg/otg.c is not otg specific, but phy specific, so move it to the phy directory. Signed-off-by: Sascha Hauer Reported-by: Kishon Vijay Abraham I Cc: Felipe Balbi --- drivers/usb/otg/otg.c| 423 drivers/usb/phy/Makefile |1 + drivers/usb/phy/phy.c| 434 ++ 3 files changed, 435 insertions(+), 423 deletions(-) create mode 100644 drivers/usb/phy/phy.c diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c index e181439..358cfd9 100644 --- a/drivers/usb/otg/otg.c +++ b/drivers/usb/otg/otg.c @@ -8,432 +8,9 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ - -#include #include -#include -#include -#include -#include -#include - #include -static LIST_HEAD(phy_list); -static LIST_HEAD(phy_bind_list); -static DEFINE_SPINLOCK(phy_lock); - -static struct usb_phy *__usb_find_phy(struct list_head *list, - enum usb_phy_type type) -{ - struct usb_phy *phy = NULL; - - list_for_each_entry(phy, list, head) { - if (phy->type != type) - continue; - - return phy; - } - - return ERR_PTR(-ENODEV); -} - -static struct usb_phy *__usb_find_phy_dev(struct device *dev, - struct list_head *list, u8 index) -{ - struct usb_phy_bind *phy_bind = NULL; - - list_for_each_entry(phy_bind, list, list) { - if (!(strcmp(phy_bind->dev_name, dev_name(dev))) && - phy_bind->index == index) { - if (phy_bind->phy) - return phy_bind->phy; - else - return ERR_PTR(-EPROBE_DEFER); - } - } - - return ERR_PTR(-ENODEV); -} - -static struct usb_phy *__of_usb_find_phy(struct device_node *node) -{ - struct usb_phy *phy; - - list_for_each_entry(phy, &phy_list, head) { - if (node != phy->dev->of_node) - continue; - - return phy; - } - - return ERR_PTR(-ENODEV); -} - -static void devm_usb_phy_release(struct device *dev, void *res) -{ - struct usb_phy *phy = *(struct usb_phy **)res; - - usb_put_phy(phy); -} - -static int devm_usb_phy_match(struct device *dev, void *res, void *match_data) -{ - return res == match_data; -} - -/** - * devm_usb_get_phy - find the USB PHY - * @dev - device that requests this phy - * @type - the type of the phy the controller requires - * - * Gets the phy using usb_get_phy(), and associates a device with it using - * devres. On driver detach, release function is invoked on the devres data, - * then, devres data is freed. - * - * For use by USB host and peripheral drivers. - */ -struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type) -{ - struct usb_phy **ptr, *phy; - - ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return NULL; - - phy = usb_get_phy(type); - if (!IS_ERR(phy)) { - *ptr = phy; - devres_add(dev, ptr); - } else - devres_free(ptr); - - return phy; -} -EXPORT_SYMBOL(devm_usb_get_phy); - -/** - * usb_get_phy - find the USB PHY - * @type - the type of the phy the controller requires - * - * Returns the phy driver, after getting a refcount to it; or - * -ENODEV if there is no such phy. The caller is responsible for - * calling usb_put_phy() to release that count. - * - * For use by USB host and peripheral drivers. - */ -struct usb_phy *usb_get_phy(enum usb_phy_type type) -{ - struct usb_phy *phy = NULL; - unsigned long flags; - - spin_lock_irqsave(&phy_lock, flags); - - phy = __usb_find_phy(&phy_list, type); - if (IS_ERR(phy)) { - pr_err("unable to find transceiver of type %s\n", - usb_phy_type_string(type)); - goto err0; - } - - get_device(phy->dev); - -err0: - spin_unlock_irqrestore(&phy_lock, flags); - - return phy; -} -EXPORT_SYMBOL(usb_get_phy); - - /** - * devm_usb_get_phy_by_phandle - find the USB PHY by phandle - * @dev - device that requests this phy - * @phandle - name of the property holding the phy phandle value - * @index - the index of the phy - * - * Returns the phy driver associated with the given phandle value, - * after getting a refcount to it, -ENODEV if there is no such phy or - * -EPROBE_DEFER if there is a phandle to the phy, but the device is - * not yet loaded. While at that, it also associates the device with - * the phy using devres. On driver detach, release function is invoked - * on the devres data, then, devres data is freed. - * - * For use by USB host and peripheral drivers. - */ -struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev, - const char *phandle, u8 index) -