USB OTG Targeted Peripheral List changes
Subsystems (6)
cover USB OTG Targeted Peripheral List changes
Hi all,
The following patches changes the behavior of otg tpl and makes it more compliant to otg specs.
The 5th patch shouldn't be applied and is against musb driver which you can find in linux-omap git tree. It's here just to show another feature that could be done with otg tpl; make it come from platform_data.
Any comments are welcome.
Best regards,
Felipe Balbi
[email protected]
PATCH 1/4 USB: OTG: Introduce new otg.c code
This patch creates moves code from otg_whitelist.h to otg.c in order to add support for configuring OTG options during the runtime in following patches.
No functional changes, only clean-up whitespace on few occasions.
--- drivers/usb/core/Makefile | 4 + drivers/usb/core/otg.c | 120 ++++++++++++++++++++++++++++++++++++++ drivers/usb/core/otg_whitelist.h | 102 ++------------------------------ 3 files changed, 129 insertions(+), 97 deletions(-) create mode 100644 drivers/usb/core/otg.c
drivers/usb/core/Makefile +4 -0
@@ -6,6 +6,10 @@ usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \ config.o file.o buffer.o sysfs.o endpoint.o \ devio.o notify.o generic.o quirks.o +ifeq ($(CONFIG_USB_OTG),y) + usbcore-objs += otg.o +endif + ifeq ($(CONFIG_PCI),y) usbcore-objs += hcd-pci.o endif
drivers/usb/core/otg.c new file +120 -0
120 lines not on this page · raw message
drivers/usb/core/otg_whitelist.h +5 -97
109 lines not on this page · raw message
Signature · 1 line
1.5.4.rc3.24.gb53139
PATCH 2/4 USB: OTG: Make otg_get_transceiver() and otg_set_transceiver() generic
From: Tony Lidgren <[email protected]>
Move otg_get_transceiver() and otg_set_transceiver() from omap specific code to common otg.c so other upcoming drivers can share them.
--- arch/arm/plat-omap/usb.c | 32 -------------------------------- drivers/usb/core/otg.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 32 deletions(-)
drivers/usb/core/otg.c +20 -0
@@ -14,9 +14,29 @@#include <linux/byteorder/generic.h> #include <linux/gfp.h> #include <linux/usb.h> +#include <linux/usb/otg.h> #include "otg_whitelist.h" +static struct otg_transceiver *xceiv; + +int otg_set_transceiver (struct otg_transceiver *x) +{ +if (xceiv && x) +return -EBUSY ; + xceiv = x; +return 0 ; +} +EXPORT_SYMBOL (otg_set_transceiver); + +struct otg_transceiver *otg_get_transceiver (void ) +{ +if (xceiv) +get_device (xceiv->dev); +return xceiv; +} +EXPORT_SYMBOL (otg_get_transceiver); +#ifdef CONFIG_USB_OTG_WHITELIST /*
arch/arm/plat-omap/usb.c +0 -32
@@ -76,38 +76,6 @@/*-------------------------------------------------------------------------*/ -#ifdef CONFIG_ARCH_OMAP_OTG - -static struct otg_transceiver *xceiv; - -/** -* otg_get_transceiver - find the (single) OTG transceiver driver -* -* Returns the transceiver driver, after getting a refcount to it; or -* null if there is no such transceiver. The caller is responsible for -* releasing that count. -*/ -struct otg_transceiver *otg_get_transceiver (void ) -{ -if (xceiv) -get_device (xceiv->dev); -return xceiv; -} -EXPORT_SYMBOL (otg_get_transceiver); - -int otg_set_transceiver (struct otg_transceiver *x) -{ -if (xceiv && x) -return -EBUSY ; - xceiv = x; -return 0 ; -} -EXPORT_SYMBOL (otg_set_transceiver); - -#endif - -/*-------------------------------------------------------------------------*/ -#if defined(CONFIG_ARCH_OMAP_OTG ) || defined(CONFIG_ARCH_OMAP15XX )static u32 __init omap_usb0_init (unsigned nwires,unsigned is_device)
Signature · 1 line
1.5.4.rc3.24.gb53139
PATCH 3/4 USB: OTG: Start using new otg tpl.
Introduces otg_set_error and start using it when we want to show otg_errors.
Based on previous patch from Tony Lindgren <[email protected]>
--- drivers/usb/core/hub.c | 16 ++++- drivers/usb/core/otg.c | 127 ++++++++++++++++++++++++++++++++----- drivers/usb/core/otg_whitelist.h | 20 ------ drivers/usb/core/sysfs.c | 131 ++++++++++++++++++++++++++++++++++++++ include/linux/usb/otg.h | 19 ++++++ 5 files changed, 273 insertions(+), 40 deletions(-) delete mode 100644 drivers/usb/core/otg_whitelist.h
drivers/usb/core/hub.c +12 -4
@@ -23,6 +23,8 @@#include <linux/mutex.h> #include <linux/freezer.h> +#include <linux/usb/otg.h> +#include <asm/semaphore.h> #include <asm/uaccess.h> #include <asm/byteorder.h>
@@ -1252,6 +1254,7 @@ static int usb_configure_device_otg(struct usb_device *udev) le16_to_cpu(udev->config[0].desc.wTotalLength), USB_DT_OTG, (void **) &desc) == 0) {if (desc->bmAttributes &USB_OTG_HNP ) { +struct otg_transceiver *xceiv =otg_get_transceiver ();unsigned port1 = udev->portnum; dev_info(&udev->dev,
@@ -1270,19 +1273,23 @@ static int usb_configure_device_otg(struct usb_device *udev) : USB_DEVICE_A_ALT_HNP_SUPPORT, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);if (err <0 ) { -/* OTG MESSAGE: report errors here, -* customize to match your product. -*/ +otg_set_error (xceiv, +OTG_ERR_DEVICE_NOT_RESPONDING );dev_info (&udev->dev,"can't set HNP mode; %d\n" , err); bus->b_hnp_enable =0 ; } + tpl_enabled = xceiv->tpl_enabled; +put_device (xceiv->dev); } } } -if (!is_targeted (udev)) { +if (err ==0 ) + err =otg_targeted (udev); + +if (err !=OTG_ERR_DEVICE_SUPPORTED && tpl_enabled) {/* Maybe it can talk to us, though we can't talk to it. * (Includes HNP test device.)
@@ -1316,6 +1323,7 @@ fail:static int usb_configure_device (struct usb_device *udev) {int err; +unsigned tpl_enabled =0 ;if (udev->config ==NULL ) { err =usb_get_configuration (udev);
drivers/usb/core/otg.c +111 -16
186 lines not on this page · raw message
drivers/usb/core/otg_whitelist.h deleted +0 -20
@@ -1,20 +0,0 @@ -/* -* drivers/usb/core/otg_whitelist.h -* -* 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. -*/ - -#ifdef CONFIG_USB_OTG_WHITELIST -extern int is_targeted (struct usb_device *); -#else -static inline int is_targeted (struct usb_device *d) -{ -return 0 ; -} -#endif -
drivers/usb/core/sysfs.c +131 -0
155 lines not on this page · raw message
include/linux/usb/otg.h +19 -0
@@ -31,6 +31,13 @@ enum usb_otg_state { OTG_STATE_A_VBUS_ERR, }; +enum usb_otg_error { +OTG_ERR_DEVICE_SUPPORTED , +OTG_ERR_DEVICE_NOT_SUPPORTED , +OTG_ERR_DEVICE_NOT_RESPONDING , +OTG_ERR_HUB_NOT_SUPPORTED , +}; +/* * the otg driver needs to interact with both device side and host side * usb controllers. it decides which controller is active at a given
@@ -42,7 +49,10 @@ struct otg_transceiver {const char *label;u8 default_a; + unsigned tpl_enabled:1; +enum usb_otg_state state; +enum usb_otg_error last_error;struct usb_bus *host;struct usb_gadget *gadget;
@@ -89,6 +99,7 @@ otg_start_hnp(struct otg_transceiver *otg)return otg->start_hnp (otg); } +extern void otg_set_error (struct otg_transceiver *otg,enum usb_otg_error );/* for HCDs */ static inline int
@@ -129,3 +140,11 @@ otg_start_srp(struct otg_transceiver *otg)/* for OTG controller drivers (and maybe other stuff) */ extern int usb_bus_start_enum (struct usb_bus *bus,unsigned port_num); + +#ifdef CONFIG_USB_OTG_WHITELIST +struct usb_device ; +extern int otg_targeted (struct usb_device *dev); +extern ssize_t otg_print_whitelist (char *buf); +#else +#define otg_targeted (x) OTG_ERR_IS_TARGETED +#endif
Signature · 1 line
1.5.4.rc3.24.gb53139
PATCH 4/4 USB: OTG: Add check for roothub initialization
From: Tony Lindgren <[email protected]>
Roothub may not be initialized if no gadget is loaded on musb for example. Add check for roothub initialization. Also make comment more accurate.
--- drivers/usb/core/otg.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
drivers/usb/core/otg.c +10 -1
@@ -33,16 +33,25 @@ struct otg_transceiver *otg_get_transceiver(void) }EXPORT_SYMBOL (otg_get_transceiver); -/* OTG MESSAGE: report errors here, customize to match your product */ +/* +* OTG MESSAGE: report errors here, customize to match your product +* See also otg_last_error_show(). +*/ void otg_set_error (struct otg_transceiver *x,enum usb_otg_error errno) {if (!x)return ; +if (!x->tpl_enabled) x->last_error =OTG_ERR_DEVICE_SUPPORTED ;else x->last_error = errno; +if (!x->host->root_hub) { +printk (KERN_WARNING "OTG: root hub not yet initialized\n" ); +return ; + } +sysfs_notify (&x->host->root_hub->dev.kobj,NULL ,"otg_last_error" ); }EXPORT_SYMBOL (otg_set_error);
Signature · 1 line
1.5.4.rc3.24.gb53139
PATCH 1/1 USB: OTG: Make otg_tpl come from platform_data
This is applicable to n8X0. It makes otg tpl come from musb_platform_data and be initialized in otg.c
This provides a better code style and better handling of otg capable devices.
--- arch/arm/mach-omap2/board-n800-usb.c | 14 +++++++++++ drivers/usb/core/otg.c | 43 ++++------------------------------ drivers/usb/musb/musb_core.c | 4 +++ include/linux/usb/musb.h | 5 ++++ include/linux/usb/otg.h | 5 ++++ 5 files changed, 33 insertions(+), 38 deletions(-)
arch/arm/mach-omap2/board-n800-usb.c +14 -0
@@ -15,6 +15,7 @@#include <linux/clk.h> #include <linux/err.h> #include <linux/usb/musb.h> +#include <linux/usb.h> #include <asm/arch/gpmc.h> #include <asm/arch/gpio.h> #include <asm/arch/pm.h>
@@ -35,6 +36,16 @@ static int tusb_set_clock(struct clk *osc_ck, int state);# define BOARD_MODE MUSB_HOST#endif +#ifdef CONFIG_USB_OTG_WHITELIST +struct usb_device_id otg_tpl[]__initdata = { +/* Support known mass storage devices */ + {USB_DEVICE (0x0421 ,0x0431 ), },/* N770 */ + {USB_DEVICE (0x0421 ,0x04c3 ), },/* N800 */ + {USB_DEVICE (0x0421 ,0x0096 ), },/* RX44 */ + { }/* Terminating entry */ +}; +#endif +static struct musb_hdrc_platform_data tusb_data = { .mode =BOARD_MODE , .multipoint =1 ,
@@ -43,6 +54,9 @@ static struct musb_hdrc_platform_data tusb_data = { .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */ .power = 100, /* Max 100 mA VBUS for host mode */ .clock = "osc_ck", +#ifdef CONFIG_USB_OTG_WHITELIST + .otg_tpl = otg_tpl, +#endif };/*
drivers/usb/core/otg.c +5 -38
64 lines not on this page · raw message
drivers/usb/musb/musb_core.c +4 -0
@@ -1939,6 +1939,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) musb->set_clock = plat->set_clock; musb->min_power = plat->min_power; +#ifdef CONFIG_USB_OTG_WHITELIST + musb->xceiv.otg_tpl = plat->otg_tpl; +#endif +/* Clock usage is chip-specific ... functional clock (DaVinci, * OMAP2430), or PHY ref (some TUSB6010 boards). All this core * code does is make sure a clock handle is available; platform
include/linux/usb/musb.h +5 -0
@@ -7,6 +7,8 @@* key configuration differences between boards. */ +#include <linux/mod_devicetable.h> +/* The USB role is defined by the connector used on the board, so long as * standards are being followed. (Developer boards sometimes won't.) */
@@ -26,6 +28,9 @@ struct musb_hdrc_platform_data {/* for clk_get() */ const char *clock; +/* OTG Targeted Peripheral List */ +struct usb_device_id *otg_tpl; +/* (HOST or OTG) switch VBUS on/off */ int (*set_vbus)(struct device *dev,int is_on);
include/linux/usb/otg.h +5 -0
@@ -1,5 +1,7 @@// include/linux/usb/otg.h +#include <linux/mod_devicetable.h> +/* * These APIs may be used between USB controllers. USB device drivers * (for either host or peripheral roles) don't use these calls; they
@@ -57,6 +59,9 @@ struct otg_transceiver {struct usb_bus *host;struct usb_gadget *gadget; +/* OTG Target Peripheral List */ +struct usb_device_id *otg_tpl; +/* to pass extra port status to the root hub */ u16 port_status;u16 port_change;
Signature · 1 line
1.5.4.rc3.24.gb53139
Re: [PATCH 2/4] USB: OTG: Make otg_get_transceiver() and otg_set_transceiver() generic
In reply to Felipe BalbiHi,
Quoted 92 lines · Felipe Balbi
From: Tony Lidgren <[email protected]>
Move
otg_get_transceiver()andotg_set_transceiver()from omap specific code to commonotg.cso other upcoming drivers can share them.Signed-off-by Tony Lindgren <[email protected]>Signed-off-by Felipe Balbi <[email protected]>--- arch/arm/plat-omap/usb.c | 32 -------------------------------- drivers/usb/core/otg.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 32 deletions(-)drivers/usb/core/otg.c +20
-0@@ -14,9 +14,29 @@#include <linux/byteorder/generic.h> #include <linux/gfp.h> #include <linux/usb.h> +#include <linux/usb/otg.h> #include "otg_whitelist.h" +static struct otg_transceiver *xceiv; + +int otg_set_transceiver (struct otg_transceiver *x) +{ +if (xceiv && x) +return -EBUSY ; + xceiv = x; +return 0 ; +} +EXPORT_SYMBOL (otg_set_transceiver); + +struct otg_transceiver *otg_get_transceiver (void ) +{ +if (xceiv) +get_device (xceiv->dev); +return xceiv; +} +EXPORT_SYMBOL (otg_get_transceiver); +#ifdef CONFIG_USB_OTG_WHITELIST /* arch/arm/plat-omap/usb.c +0
-33@@ -76,38 +76,6 @@/*-------------------------------------------------------------------------*/ -#ifdef CONFIG_ARCH_OMAP_OTG - -static struct otg_transceiver *xceiv; - -/** -* otg_get_transceiver - find the (single) OTG transceiver driver -* -* Returns the transceiver driver, after getting a refcount to it; or -* null if there is no such transceiver. The caller is responsible for -* releasing that count. -*/ -struct otg_transceiver *otg_get_transceiver (void ) -{ -if (xceiv) -get_device (xceiv->dev); -return xceiv; -} -EXPORT_SYMBOL (otg_get_transceiver); - -int otg_set_transceiver (struct otg_transceiver *x) -{ -if (xceiv && x) -return -EBUSY ; - xceiv = x; -return 0 ; -} -EXPORT_SYMBOL (otg_set_transceiver); - -#endif - -/*-------------------------------------------------------------------------*/ -#if defined(CONFIG_ARCH_OMAP_OTG ) || defined(CONFIG_ARCH_OMAP15XX )static u32 __init omap_usb0_init (unsigned nwires,unsigned is_device) --1.5.4.rc3.24.gb53139
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
what is the status of this patch? I guess moving otg_get/set_transceiver into usb core like this (and adding otg_put_transceiver) is better than duplicating this code for PXA and other architectures?
regards
Philipp
Re: [PATCH 2/4] USB: OTG: Make otg_get_transceiver() and otg_set_transceiver() generic
Quoted 4 lines · ext pHilipp Zabel
what is the status of this patch? I guess moving otg_get/set_transceiver into usb core like this (and adding
otg_put_transceiver) is better than duplicating this code for PXA and other architectures?
Yeah, this was never applied. I'll try to format the patches again, but it'll take a while since I'm really busy with work.
Signature · 1 line
balbi