usb gadget update for OTG 2.0
v5 cover usb gadget update for OTG 2.0
Changes for v5:
- By default otg feature are enabled if usb controller can support it. use of_usb_set_otg_caps to set otg_rev and disable features by DT.
- Update legacy drivers, allocate and init otg descriptor in bind function, free it in unbind, to make alloation and free are symmetric.
- Add Roger's reviewed-by.
Changes for v4:
- Add usb_otg_caps structure for all otg related capability attributes.
- Use one interface: of_usb_get_otg_caps to get all otg capabilities from DT, including otg_rev, hnp/srp/adp support.
- Add usb_otg_descriptor_alloc interface to allocate otg descriptor for better code sharing.
- Improve description of dt-binding doc.
This is a follow-up of Macpaul Lin's previous patchset to resolve usb gadget driver working with OTG 2.0, and set otg features by not only usb driver config but also usb hardware property in DT, main changes:
1. Add usb_otg20_descriptor definition for OTG 2.0 which introduces bcdOTG field for otg revision, bcdOTG can be passed via device tree.
2. OTG features(SRP/HNP/ADP) can be decided by combination of usb HW properties and usb driver config.
3. Change the chipidea usb driver to use the updated mechanism.
4. Remove static usb otg descriptor definition, but allocate and init it according to otg capabilities in each gadget driver, if otg capabilities is not defined for legacy platforms, the usb otg descriptor content is kept the same as current static definition.
Li Jun (19):
usb: otg: add usb_otg_caps structure for otg capabilities
doc: dt-binding: usb: add otg related properties
usb: common: add API to set usb otg capabilities by device tree
usb: chipidea: set usb gadeget's otg capabilities
usb: chipidea: update ci_otg_is_fsm_mode conditions
usb: gadget: add usb otg descriptor allocate and init interface
usb: gadget: configfs: allocate and init otg descriptor by otg
capabilities
usb: gadget: ether: allocate and init otg descriptor by otg
capabilities
usb: gadget: acm_ms: allocate and init otg descriptor by otg
capabilities
usb: gadget: audio: allocate and init otg descriptor by otg
capabilities
usb: gadget: cdc2: allocate and init otg descriptor by otg
capabilities
usb: gadget: g_ffs: allocate and init otg descriptor by otg
capabilities
usb: gadget: hid: allocate and init otg descriptor by otg capabilities
usb: gadget: mass_storage: allocate and init otg descriptor by otg
capabilities
usb: gadget: multi: allocate and init otg descriptor by otg
capabilities
usb: gadget: ncm: allocate and init otg descriptor by otg capabilities
usb: gadget: printer: allocate and init otg descriptor by otg
capabilities
usb: gadget: serial: allocate and init otg descriptor by otg
capabilities
usb: gadget: zero: allocate and init otg descriptor by otg
capabilities
Macpaul Lin (4):
usb: add usb_otg20_descriptor for OTG 2.0 and above
usb: add USB_OTG_ADP definition
usb: add usb_otg_caps to usb_gadget structure.
usb: gadget: composite: add USB_DT_OTG request handling
Documentation/devicetree/bindings/usb/generic.txt | 15 ++++++ drivers/usb/chipidea/ci.h | 5 +- drivers/usb/chipidea/core.c | 8 ++++ drivers/usb/chipidea/debug.c | 1 + drivers/usb/chipidea/udc.c | 7 ++- drivers/usb/common/common.c | 28 ++++++++++++ drivers/usb/gadget/composite.c | 27 +++++++++++ drivers/usb/gadget/config.c | 56 +++++++++++++++++++++++ drivers/usb/gadget/configfs.c | 29 ++++++++---- drivers/usb/gadget/legacy/acm_ms.c | 44 +++++++++--------- drivers/usb/gadget/legacy/audio.c | 43 +++++++++-------- drivers/usb/gadget/legacy/cdc2.c | 44 +++++++++--------- drivers/usb/gadget/legacy/ether.c | 52 ++++++++++----------- drivers/usb/gadget/legacy/g_ffs.c | 42 +++++++++-------- drivers/usb/gadget/legacy/hid.c | 45 +++++++++--------- drivers/usb/gadget/legacy/mass_storage.c | 44 +++++++++--------- drivers/usb/gadget/legacy/multi.c | 39 ++++++++++------ drivers/usb/gadget/legacy/ncm.c | 43 +++++++++-------- drivers/usb/gadget/legacy/printer.c | 35 +++++++------- drivers/usb/gadget/legacy/serial.c | 29 ++++++------ drivers/usb/gadget/legacy/zero.c | 32 ++++++------- include/linux/usb/chipidea.h | 1 + include/linux/usb/gadget.h | 6 +++ include/linux/usb/of.h | 7 +++ include/linux/usb/otg.h | 15 ++++++ include/uapi/linux/usb/ch9.h | 12 +++++ 26 files changed, 465 insertions(+), 244 deletions(-)
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1434541230-15090-1-git-send-email-jun.li-KZfg59tc24xl57MIdRCFDg@public.gmane.org
PATCH v5 1/23 usb: add usb_otg20_descriptor for OTG 2.0 and above
From: Macpaul Lin <[email protected]>
OTG 2.0 introduces bcdOTG in otg descriptor to identify the OTG and EH supplement release number with which the OTG device is compliant, this patch adds structure usb_otg20_descriptor for OTG 2.0 and above.
--- include/uapi/linux/usb/ch9.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/uapi/linux/usb/ch9.h +11 -0
@@ -674,6 +674,17 @@ struct usb_otg_descriptor {__u8 bmAttributes;/* support for HNP, SRP, etc */ } __attribute__ ((packed)); +/* USB_DT_OTG (from OTG 2.0 supplement) */ +struct usb_otg20_descriptor { +__u8 bLength; +__u8 bDescriptorType; + +__u8 bmAttributes;/* support for HNP, SRP and ADP, etc */ +__le16 bcdOTG;/* OTG and EH supplement release number +* in binary-coded decimal(i.e. 2.0 is 0200H) +*/ +} __attribute__ ((packed)); +/* from usb_otg_descriptor.bmAttributes */ #define USB_OTG_SRP (1 << 0)#define USB_OTG_HNP (1 << 1)/* swap host/device roles */
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 2/23 usb: add USB_OTG_ADP definition
In reply to a message not in the archiveFrom: Macpaul Lin <[email protected]>
Add USB_OTG_ADP definition for usb_otg_descriptor.bmAttributes.
--- include/uapi/linux/usb/ch9.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/usb/ch9.h +1 -0
@@ -688,6 +688,7 @@ struct usb_otg20_descriptor {/* from usb_otg_descriptor.bmAttributes */ #define USB_OTG_SRP (1 << 0)#define USB_OTG_HNP (1 << 1)/* swap host/device roles */ +#define USB_OTG_ADP (1 << 2)/* support ADP */ /*-------------------------------------------------------------------------*/
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 3/23 usb: otg: add usb_otg_caps structure for otg capabilities
In reply to a message not in the archiveThis patch adds a structure usb_otg_caps to cover all otg related capabilities of the device, including otg revision, and if hnp/srp/adp is supported.
--- include/linux/usb/otg.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/linux/usb/otg.h +15 -0
@@ -41,6 +41,21 @@ struct usb_otg { }; +/** +* struct usb_otg_caps - describes the otg capabilities of the device +* @otg_rev: The OTG revision number the device is compliant with, it's +* in binary-coded decimal (i.e. 2.0 is 0200H). +* @hnp_support: Indicates if the device supports HNP. +* @srp_support: Indicates if the device supports SRP. +* @adp_support: Indicates if the device supports ADP. +*/ +struct usb_otg_caps { +u16 otg_rev; +bool hnp_support; +bool srp_support; +bool adp_support; +}; +extern const char *usb_otg_state_string (enum usb_otg_state state);/* Context: can sleep */
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 4/23 usb: add usb_otg_caps to usb_gadget structure.
In reply to a message not in the archiveFrom: Macpaul Lin <[email protected]>
Add usb_otg_caps pointer to usb_gadget structure to indicate its otg capabilities.
--- include/linux/usb/gadget.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/usb/gadget.h +2 -0
@@ -511,6 +511,7 @@ struct usb_gadget_ops {* @dev: Driver model state for this abstract device. * @out_epnum: last used out ep number * @in_epnum: last used in ep number +* @otg_caps: OTG capabilities of this gadget. * @sg_supported: true if we can handle scatter-gather * @is_otg: True if the USB device port uses a Mini-AB jack, so that the * gadget driver must provide a USB OTG descriptor.
@@ -559,6 +560,7 @@ struct usb_gadget {struct device dev;unsigned out_epnum;unsigned in_epnum; +struct usb_otg_caps *otg_caps; unsigned sg_supported:1; unsigned is_otg:1;
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 5/23 usb: gadget: composite: add USB_DT_OTG request handling
In reply to a message not in the archiveFrom: Macpaul Lin <[email protected]>
Copy usb_otg_descriptor from config's descriptor if host requests USB_DT_OTG.
--- drivers/usb/gadget/composite.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/usb/gadget/composite.c +27 -0
@@ -19,6 +19,7 @@#include <linux/utsname.h> #include <linux/usb/composite.h> +#include <linux/usb/otg.h> #include <asm/unaligned.h> #include "u_os_desc.h"
@@ -1534,6 +1535,32 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value =min (w_length, (u16 ) value); }break ; +case USB_DT_OTG : +if (gadget_is_otg (gadget)) { +struct usb_configuration *config; +int otg_desc_len =0 ; + +if (cdev->config) + config = cdev->config; +else + config =list_first_entry ( + &cdev->configs, + struct usb_configuration, list); +if (!config) + goto done; + +if (gadget->otg_caps && + (gadget->otg_caps->otg_rev >=0x0200 )) + otg_desc_len +=sizeof ( +struct usb_otg20_descriptor ); +else + otg_desc_len +=sizeof ( +struct usb_otg_descriptor ); + + value =min_t (int, w_length, otg_desc_len); +memcpy (req->buf, config->descriptors[0 ], value); + } +break ; }break ;
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 6/23 doc: dt-binding: usb: add otg related properties
In reply to a message not in the archiveAdd otg version, srp, hnp and adp support for usb OTG port, then those OTG features don't have to be decided by usb gadget drivers.
--- Documentation/devicetree/bindings/usb/generic.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Documentation/devicetree/bindings/usb/generic.txt +15 -0
@@ -11,6 +11,19 @@ Optional properties: "peripheral" and "otg". In case this attribute isn't passed via DT, USB DRD controllers should default to OTG. + - otg-rev: tells usb driver the release number of the OTG and EH supplement + with which the device and its descriptors are compliant, + in binary-coded decimal (i.e. 2.0 is 0200H). This + property is used if any real OTG features(HNP/SRP/ADP) + is enabled, if ADP is required, otg-rev should be + 0x0200 or above. + - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally HNP + is the basic function of real OTG except you want it + to be a srp-capable only B device. + - srp-disable: tells OTG controllers we want to disable OTG SRP, SRP is + optional for OTG device. + - adp-disable: tells OTG controllers we want to disable OTG ADP, ADP is + optional for OTG device. This is an attribute to a USB controller such as:
@@ -21,4 +34,6 @@ dwc3@4a030000 { usb-phy = <&usb2_phy>, <&usb3,phy>; maximum-speed = "super-speed"; dr_mode = "otg"; + otg-rev = <0x0200>; + adp-disable; };
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 7/23 usb: common: add API to set usb otg capabilities by device tree
In reply to a message not in the archiveCheck property of usb hardware to get otg version and if SRP, HNP and ADP are disabled.
--- drivers/usb/common/common.c | 28 ++++++++++++++++++++++++++++ include/linux/usb/of.h | 7 +++++++ 2 files changed, 35 insertions(+)
drivers/usb/common/common.c +28 -0
@@ -154,6 +154,34 @@ bool of_usb_host_tpl_support(struct device_node *np) return false; }EXPORT_SYMBOL_GPL (of_usb_host_tpl_support); + +/** +* of_usb_get_set_caps - to set usb otg capabilities according to +* the passed properties in DT. +* @np: Pointer to the given device_node +* @otg_caps: Pointer to the target usb_otg_caps to be set +* +* The function gets and sets the otg capabilities +*/ +void of_usb_set_otg_caps (struct device_node *np,struct usb_otg_caps *otg_caps) +{ +u32 otg_rev; + +if (!otg_caps) +return ; + +if (!of_property_read_u32 (np,"otg-rev" , &otg_rev)) { + otg_caps->otg_rev = otg_rev; +if (of_find_property (np,"hnp-disable" ,NULL )) + otg_caps->hnp_support = false; +if (of_find_property (np,"srp-disable" ,NULL )) + otg_caps->srp_support = false; +if (of_find_property (np,"adp-disable" ,NULL )) + otg_caps->adp_support = false; + } +} +EXPORT_SYMBOL_GPL (of_usb_set_otg_caps); +#endif MODULE_LICENSE ("GPL" );
include/linux/usb/of.h +7 -0
@@ -15,6 +15,8 @@enum usb_dr_mode of_usb_get_dr_mode (struct device_node *np);enum usb_device_speed of_usb_get_maximum_speed (struct device_node *np);bool of_usb_host_tpl_support (struct device_node *np); +void of_usb_set_otg_caps (struct device_node *np, +struct usb_otg_caps *otg_caps);#else static inline enum usb_dr_mode of_usb_get_dr_mode (struct device_node *np) {
@@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct device_node *np) {return false; } +static inline void of_usb_set_otg_caps (struct device_node *np, +struct usb_otg_caps *otg_caps) +{ + +}#endif #if IS_ENABLED (CONFIG_OF ) &&IS_ENABLED (CONFIG_USB_SUPPORT )
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 8/23 usb: chipidea: set usb gadeget's otg capabilities
In reply to a message not in the archiveSet gadget's otg capabilities according to controller's capability and otg properties in device tree.
--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)
drivers/usb/chipidea/core.c +8 -0
@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node); } +if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps); + } +if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;
drivers/usb/chipidea/udc.c +6 -1
@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);
@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);
include/linux/usb/chipidea.h +1 -0
@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1434541230-15090-9-git-send-email-jun.li-KZfg59tc24xl57MIdRCFDg@public.gmane.org
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Typo in subject
gadeget's -> gadget's
Quoted 15 lines · On Wed, 17 Jun 2015 19:40:15 +0800 Li Jun…
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0
drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 596
Quoted 9 lines
drivers/usb/chipidea/core.c +6
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node); } +if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps);
we're not tackling the legacy platform case.
i.e. when otg-rev is not present in DT.
one way could be that of_usb_set_otg_caps sets otg-rev to 0 if it is not present in DT.
Quoted 46 lines
drivers/usb/chipidea/core.c +2
-0+ } +if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };Signature · 1 line
1.9.1
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20150618103935.cfbd94c8c37c5c3298c55272-l0cyMroinI0@public.gmane.org
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Quoted 24 lines · Roger Quadros
Typo in subject
gadeget's -> gadget'sQuoted 18 lines · On Wed, 17 Jun 2015 19:40:15 +0800 Li Jun…
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node); }
Quoted 10 lines
drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 596
Quoted 6 lines
drivers/usb/chipidea/core.c +6
-0+if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps);we're not tackling the legacy platform case.
i.e. when otg-rev is not present in DT.
Legacy platforms with chipidea controller can use otg HNP and SRP without any otg properties passed, so I keep hnp and srp to be true.
Quoted 3 lines
one way could be that
of_usb_set_otg_capssets otg-rev to 0 if it is not present in DT.
otg-rev should be 0 as initial value if it's not present in DT, isn't it?
Quoted 43 lines
Quoted 43 lines
drivers/usb/chipidea/core.c +2
-0+ } +if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };
Quoted 6 lines
Quoted 3 lines
Signature · 1 line
1.9.1cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Quoted 35 lines · On Thu, 18 Jun 2015 16:20:30 +0800 Li Jun…
Quoted 24 lines · Roger Quadros
Typo in subject
gadeget's -> gadget'sQuoted 18 lines · On Wed, 17 Jun 2015 19:40:15 +0800 Li Jun…
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node); }Quoted 10 lines
drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 596
Quoted 6 lines
drivers/usb/chipidea/core.c +6
-0+if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps);we're not tackling the legacy platform case.
i.e. when otg-rev is not present in DT.
Quoted 2 lines
Legacy platforms with chipidea controller can use otg HNP and SRP without any otg properties passed, so I keep hnp and srp to be true.
I was thinking that controller should set whatever it supports regardless of legacy platforms.
e.g. if chipidea controller supports ADP then it should set it to true here before calling of_usb_update_otg_caps().
And it should also set the best OTG version it supports and not leave it to 0.
of_usb_update_otg_caps() should then take the decision based on controller otg_caps and DT otg flags as to what must be done.
Quoted 5 lines
Quoted 4 lines
one way could be that
of_usb_set_otg_capssets otg-rev to 0 if it is not present in DT.otg-rev should be 0 as initial value if it's not present in DT, isn't it?
That's because you didn't set the otg-rev that chipidea controller supports.
This will break for example if DT passes otg-rev 3.0 and controller supports only otg-rev 2.0 but we didn't bother to check :)
Let's do whatever common functionality we can in of_usb_update_otg_caps() rather than depending on controller drivers and inviting more errors.
cheers,
-roger
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
drivers/usb/chipidea/core.c +2
-0+ } +if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Signature · 1 line
1.9.1cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20150618150627.d7e81ca1d6bdf7dba94c4eff-l0cyMroinI0@public.gmane.org
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Quoted 38 lines · Roger Quadros
Quoted 35 lines · On Thu, 18 Jun 2015 16:20:30 +0800 Li Jun…
Quoted 34 lines · Roger Quadros
Typo in subject
gadeget's -> gadget'sQuoted 15 lines · On Wed, 17 Jun 2015 19:40:15 +0800 Li Jun…
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 596
Quoted 9 lines
drivers/usb/chipidea/core.c +6
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node); } +if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps);we're not tackling the legacy platform case.
i.e. when otg-rev is not present in DT.
Quoted 8 lines
Quoted 2 lines
Legacy platforms with chipidea controller can use otg HNP and SRP without any otg properties passed, so I keep hnp and srp to be true.
I was thinking that controller should set whatever it supports regardless of legacy platforms.
e.g. if chipidea controller supports ADP then it should set it to true here before callingof_usb_update_otg_caps().
Now chipidea only support HNP and SRP, that's the best capability.
Quoted 2 lines
And it should also set the best OTG version it supports and not leave it to 0.
Best version is 2.0 for chipidea.
But I cannot find the real case to use the best version(as initial setting) by controller in the end, anyway for a OTG device, the otg-rev should be passed and the dt value should be used.
Quoted 3 lines
of_usb_update_otg_caps()should then take the decision based on controllerotg_capsand DT otg flags as to what must be done.
The decision some how depends on controller drivers. Can not be fixed.
Quoted 11 lines
Quoted 5 lines
Quoted 4 lines
one way could be that
of_usb_set_otg_capssets otg-rev to 0 if it is not present in DT.otg-rev should be 0 as initial value if it's not present in DT, isn't it?
That's because you didn't set the otg-rev that chipidea controller supports.
This will break for example if DT passes otg-rev 3.0 and controller supports only otg-rev 2.0 but we didn't bother to check :)
okay, another crazy dt user, I see the usage of initial setting of otg-rev here, we can use it to decide the final version if a wrong value is passed.
Quoted 3 lines
Let's do whatever common functionality we can in
of_usb_update_otg_caps()rather than depending on controller drivers and inviting more errors.
The only question is: if none of 4 flags passed, we should set what kind of otg capability in of_usb_update_otg_caps?
there are 2 kind legacy platforms, one is some really can support HNP. the other one is it cannot support any real OTG.
Li Jun
Quoted 53 lines
cheers,
-rogerQuoted 50 lines
Quoted 50 lines
Quoted 47 lines
drivers/usb/chipidea/core.c +2
-0+ } +if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };Signature · 1 line
1.9.1cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
In reply to a message not in the archiveQuoted 16 lines · Li Jun
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node);
drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 598
Quoted 10 lines
drivers/usb/chipidea/core.c +8
-0} +if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps); + } +
For current dual-role supported platforms (through ID pin), their dts has nothing with otg capabilities, what will happen if we set .hnp_support as true?
For non-dt platform (eg i686), how it changes otg capabilities through their platform data?
Peter
Quoted 44 lines
drivers/usb/chipidea/core.c +0
-0if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };Signature · 1 line
1.9.1
Signature · 6 lines
Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Quoted 19 lines · Peter Chen
Quoted 18 lines · Li Jun
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node); }
Quoted 12 lines
drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 598
Quoted 8 lines
drivers/usb/chipidea/core.c +8
-0+if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps); + } +For current dual-role supported platforms (through ID pin), their dts has nothing with otg capabilities, what will happen if we set .hnp_support as true?
No impact for them, those platforms will continue work as before(i.e. otg descriptor with HNP&SRP enabled if CONFIG_USB_OTG is selected, no otg fsm if CONFIG_USB_OTG_FSM is not selected).
Quoted 3 lines
For non-dt platform (eg i686), how it changes otg capabilities through their platform data?
Directly override platdata->ci_otg_caps in its platform driver after ci_hdrc_add_device().
Quoted 42 lines
Peter
Quoted 41 lines
drivers/usb/chipidea/core.c +0
-0if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };
Quoted 8 lines
Quoted 3 lines
Signature · 1 line
1.9.1Signature · 2 lines
Best Regards, Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Quoted 32 lines · Li Jun
Quoted 19 lines · Peter Chen
Quoted 18 lines · Li Jun
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node); }Quoted 12 lines
drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 598
Quoted 8 lines
drivers/usb/chipidea/core.c +8
-0+if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps); + } +For current dual-role supported platforms (through ID pin), their dts has nothing with otg capabilities, what will happen if we set .hnp_support as true?
Quoted 3 lines
No impact for them, those platforms will continue work as before(i.e. otg descriptor with HNP&SRP enabled if
CONFIG_USB_OTGis selected, no otg fsm ifCONFIG_USB_OTG_FSMis not selected).
So if CONFIG_USB_OTG is not chosen, even platdata->ci_otg_caps.hnp_support is true, it will be act as pure host or peripheral, right?
Quoted 6 lines
Quoted 4 lines
For non-dt platform (eg i686), how it changes otg capabilities through their platform data?
Directly override
platdata->ci_otg_capsin its platform driver afterci_hdrc_add_device().
After ci_hdrc_add_device, the device may begin to enumerate, we need to make sure otg capabilities before the device goes to work.
Peter
Quoted 51 lines
Quoted 51 lines
Peter
Quoted 44 lines
drivers/usb/chipidea/core.c +0
-0if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };Signature · 1 line
1.9.1Signature · 2 lines
Best Regards, Peter Chen
Signature · 6 lines
Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Quoted 33 lines · Peter Chen
Quoted 32 lines · Li Jun
Quoted 31 lines · Peter Chen
Quoted 16 lines · Li Jun
Set gadget's otg capabilities according to controller's capability and otg properties in device tree.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/core.c | 8 ++++++++ drivers/usb/chipidea/udc.c | 7 ++++++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)drivers/usb/chipidea/core.c +0
-0@@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev,of_usb_host_tpl_support (dev->of_node);drivers/usb/chipidea/core.c static int ci_get_platdata(struct device *dev, · line 598
Quoted 10 lines
drivers/usb/chipidea/core.c +8
-0} +if (platdata->dr_mode ==USB_DR_MODE_OTG ) { +/* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; +/* Update otg capabilities by DT properties */ +of_usb_set_otg_caps (dev->of_node, &platdata->ci_otg_caps); + } +For current dual-role supported platforms (through ID pin), their dts has nothing with otg capabilities, what will happen if we set .hnp_support as true?
Quoted 7 lines
Quoted 3 lines
No impact for them, those platforms will continue work as before(i.e. otg descriptor with HNP&SRP enabled if
CONFIG_USB_OTGis selected, no otg fsm ifCONFIG_USB_OTG_FSMis not selected).So if
CONFIG_USB_OTGis not chosen, evenplatdata->ci_otg_caps.hnp_supportis true, it will be act as pure host or peripheral, right?
Yes.
Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
For non-dt platform (eg i686), how it changes otg capabilities through their platform data?
Directly override
platdata->ci_otg_capsin its platform driver afterci_hdrc_add_device().After
ci_hdrc_add_device, the device may begin to enumerate, we need to make sure otg capabilities before the device goes to work.Peter
How about add a flag for platdata->flags like
if (platdata->flags & CI_HDRC_USE_PREDEF_OTG_CAPS == 0) {
... ...
}then non-dt platform driver can set CI_HDRC_USE_PREDEF_OTG_CAPS flag and pre-define otg caps before call to ci_hdrc_add_device().
Li Jun
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
For current dual-role supported platforms (through ID pin), their dts has nothing
Peter
Quoted 41 lines
drivers/usb/chipidea/core.c +0
-0if (of_usb_get_maximum_speed (dev->of_node) ==USB_SPEED_FULL ) platdata->flags |=CI_HDRC_FORCE_FULLSPEED ;drivers/usb/chipidea/udc.c +6
-1@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)static int udc_start (struct ci_hdrc *ci) {struct device *dev = ci->dev; +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;int retval =0 ;spin_lock_init (&ci->lock);@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed =USB_SPEED_UNKNOWN ; ci->gadget.max_speed =USB_SPEED_HIGH ; - ci->gadget.is_otg = ci->is_otg ?1 :0 ; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + +if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg =1 ;INIT_LIST_HEAD (&ci->gadget.ep_list);include/linux/usb/chipidea.h +1
-0@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci_hdrc *ci,unsigned event);struct regulator *reg_vbus; +struct usb_otg_caps ci_otg_caps;bool tpl_support; };
Quoted 13 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Signature · 1 line
1.9.1Signature · 2 lines
Best Regards, Peter ChenSignature · 2 lines
Best Regards, Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Quoted 6 lines
For non-dt platform (eg i686), how it changes otg capabilities through their platform data?
Directly override
platdata->ci_otg_capsin its platform driver afterci_hdrc_add_device().After
ci_hdrc_add_device, the device may begin to enumerate, we need to make sure otg capabilities before the device goes to work.
Quoted 9 lines
Quoted 1 line
Peter
How about add a flag for
platdata->flagslike if (platdata->flags&CI_HDRC_USE_PREDEF_OTG_CAPS == 0) { ... ... }then non-dt platform driver can set
CI_HDRC_USE_PREDEF_OTG_CAPSflag and pre-define otg caps before call toci_hdrc_add_device().
Add Andy Shevchenko.
I think the current i686 platforms does not support full otg, you may not need to consider this to avoid unnecessary complexities, unless someone wants.
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 9/23 usb: chipidea: update ci_otg_is_fsm_mode conditions
In reply to a message not in the archiveAfter introduce usb otg properties, update ci_otg_is_fsm_mode conditions to be depending on both usb hardware properties and usb driver config, also resolve a compile issue in debug.c after the API change.
--- drivers/usb/chipidea/ci.h | 5 ++++- drivers/usb/chipidea/debug.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/usb/chipidea/ci.h +4 -1
@@ -406,8 +406,11 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, enum ci_hw_regs reg,static inline bool ci_otg_is_fsm_mode (struct ci_hdrc *ci) {#ifdef CONFIG_USB_OTG_FSM +struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; +return ci->is_otg && ci->roles[CI_ROLE_HOST ] && - ci->roles[CI_ROLE_GADGET ]; + ci->roles[CI_ROLE_GADGET ] && (otg_caps->srp_support || + otg_caps->hnp_support || otg_caps->adp_support);#else return false;#endif
drivers/usb/chipidea/debug.c +1 -0
@@ -10,6 +10,7 @@#include <linux/usb/phy.h> #include <linux/usb/otg.h> #include <linux/usb/otg-fsm.h> +#include <linux/usb/chipidea.h> #include "ci.h" #include "udc.h"
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 10/23 usb: gadget: add usb otg descriptor allocate and init interface
In reply to a message not in the archiveAllocate usb otg descriptor and initialize it according to gadget's otg capabilities, if usb_otg_caps is not set, keep settings as current gadget drivers. With this 2 new interfaces, gadget can use usb_otg_descriptor for OTG 1.x, and usb_otg20_descriptor for OTG 2.0 or above, and otg features can be decided by the combination of usb hardware property and driver config.
--- drivers/usb/gadget/config.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/gadget.h | 4 ++++ 2 files changed, 60 insertions(+)
drivers/usb/gadget/config.c +56 -0
@@ -20,6 +20,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/composite.h> +#include <linux/usb/otg.h> /** * usb_descriptor_fillbuf - fill buffer with descriptors
@@ -195,3 +196,58 @@ void usb_free_all_descriptors(struct usb_function *f)usb_free_descriptors (f->ss_descriptors); }EXPORT_SYMBOL_GPL (usb_free_all_descriptors); + +struct usb_descriptor_header *usb_otg_descriptor_alloc ( +struct usb_gadget *gadget) +{ +struct usb_descriptor_header *otg_desc; +unsigned length =0 ; + +if (gadget->otg_caps && (gadget->otg_caps->otg_rev >=0x0200 )) + length =sizeof (struct usb_otg20_descriptor ); +else + length =sizeof (struct usb_otg_descriptor ); + + otg_desc =kzalloc (length,GFP_KERNEL ); +return otg_desc; +} +EXPORT_SYMBOL_GPL (usb_otg_descriptor_alloc); + +int usb_otg_descriptor_init (struct usb_gadget *gadget, +struct usb_descriptor_header *otg_desc) +{ +struct usb_otg_descriptor *otg1x_desc; +struct usb_otg20_descriptor *otg20_desc; +struct usb_otg_caps *otg_caps = gadget->otg_caps; +u8 otg_attributes =0 ; + +if (!otg_desc) +return -EINVAL ; + +if (otg_caps && otg_caps->otg_rev) { +if (otg_caps->hnp_support) + otg_attributes |=USB_OTG_HNP ; +if (otg_caps->srp_support) + otg_attributes |=USB_OTG_SRP ; +if (otg_caps->adp_support && (otg_caps->otg_rev >=0x0200 )) + otg_attributes |=USB_OTG_ADP ; + }else { + otg_attributes =USB_OTG_SRP |USB_OTG_HNP ; + } + +if (otg_caps && (otg_caps->otg_rev >=0x0200 )) { + otg20_desc = (struct usb_otg20_descriptor *)otg_desc; + otg20_desc->bLength =sizeof (struct usb_otg20_descriptor ); + otg20_desc->bDescriptorType =USB_DT_OTG ; + otg20_desc->bmAttributes = otg_attributes; + otg20_desc->bcdOTG =cpu_to_le16 (otg_caps->otg_rev); + }else { + otg1x_desc = (struct usb_otg_descriptor *)otg_desc; + otg1x_desc->bLength =sizeof (struct usb_otg_descriptor ); + otg1x_desc->bDescriptorType =USB_DT_OTG ; + otg1x_desc->bmAttributes = otg_attributes; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (usb_otg_descriptor_init);
include/linux/usb/gadget.h +4 -0
@@ -1004,6 +1004,10 @@ int usb_assign_descriptors(struct usb_function *f, struct usb_descriptor_header **ss);void usb_free_all_descriptors (struct usb_function *f); +struct usb_descriptor_header *usb_otg_descriptor_alloc ( +struct usb_gadget *gadget); +int usb_otg_descriptor_init (struct usb_gadget *gadget, +struct usb_descriptor_header *otg_desc);/*-------------------------------------------------------------------------*/ /* utility to simplify map/unmap of usb_requests to/from DMA */
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 11/23 usb: gadget: configfs: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while composite unbind. If otg capability is not defined, keep its otg descriptor unchanged.
--- drivers/usb/gadget/configfs.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/usb/gadget/configfs.c +20 -8
@@ -41,6 +41,8 @@ int check_user_usb_string(const char *name,#define MAX_NAME_LEN 40#define MAX_USB_STRING_LANGS 2 +static const struct usb_descriptor_header *otg_desc[2 ]; +struct gadget_info {struct config_group group;struct config_group functions_group;
@@ -55,9 +57,6 @@ struct gadget_info {struct list_head available_func;const char *udc_name; -#ifdef CONFIG_USB_OTG -struct usb_otg_descriptor otg; -#endif struct usb_composite_driver composite;struct usb_composite_dev cdev;bool use_os_desc;
@@ -1376,6 +1375,19 @@ static int configfs_composite_bind(struct usb_gadget *gadget,memcpy (cdev->qw_sign, gi->qw_sign,OS_STRING_QW_SIGN_LEN ); } +if (gadget_is_otg (gadget) && !otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) { + ret = -ENOMEM ; + goto err_comp_cleanup; + } +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } +/* Go through all configs, attach all functions */ list_for_each_entry (c, &gi->cdev.configs, list) {struct config_usb_cfg *cfg;
@@ -1383,6 +1395,9 @@ static int configfs_composite_bind(struct usb_gadget *gadget,struct usb_function *tmp;struct gadget_config_name *cn; +if (gadget_is_otg (gadget)) + c->descriptors = otg_desc; + cfg = container_of(c, struct config_usb_cfg, c);if (!list_empty (&cfg->string_list)) { i =0 ;
@@ -1437,6 +1452,8 @@ static void configfs_composite_unbind(struct usb_gadget *gadget) cdev =get_gadget_data (gadget); gi = container_of(cdev, struct gadget_info, cdev); +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ;purge_configs_funcs (gi);composite_dev_cleanup (cdev);usb_ep_autoconfig_reset (cdev->gadget);
@@ -1510,12 +1527,6 @@ static struct config_group *gadgets_make(if (!gi->composite.gadget_driver.function) goto err; -#ifdef CONFIG_USB_OTG - gi->otg.bLength =sizeof (struct usb_otg_descriptor ); - gi->otg.bDescriptorType =USB_DT_OTG ; - gi->otg.bmAttributes =USB_OTG_SRP |USB_OTG_HNP ; -#endif
PATCH v5 12/23 usb: gadget: ether: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while ether unbind. If otg capability is not defined, keep its otg descriptor unchanged.
--- drivers/usb/gadget/legacy/ether.c | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/usb/gadget/legacy/ether.c +26 -26
@@ -171,20 +171,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX ].s ="" ,
@@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } - f_rndis =usb_get_function (fi_rndis);if (IS_ERR (f_rndis))return PTR_ERR (f_rndis);
@@ -270,11 +252,6 @@ static int eth_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } -if (use_eem) { f_eem =usb_get_function (fi_eem);if (IS_ERR (f_eem))
@@ -416,17 +393,34 @@ static int eth_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) + goto fail1; +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + rndis_config_driver.descriptors = otg_desc; + rndis_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + eth_config_driver.descriptors = otg_desc; + eth_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } +/* register our configuration(s); RNDIS first, if it's used */ if (has_rndis ()) { status =usb_add_config (cdev, &rndis_config_driver, rndis_do_config);if (status <0 ) - goto fail1; + goto fail2; } status =usb_add_config (cdev, ð_config_driver, eth_do_config);if (status <0 ) - goto fail1; + goto fail2;usb_composite_overwrite_options (cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
@@ -434,6 +428,9 @@ static int eth_bind(struct usb_composite_dev *cdev)return 0 ; +fail2: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail1:if (has_rndis ())usb_put_function_instance (fi_rndis);
@@ -463,6 +460,9 @@ static int eth_unbind(struct usb_composite_dev *cdev)usb_put_function (f_geth);usb_put_function_instance (fi_geth); } +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1434541230-15090-13-git-send-email-jun.li-KZfg59tc24xl57MIdRCFDg@public.gmane.org
Re: [PATCH v5 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities
Quoted 37 lines · On Wed, 17 Jun 2015 19:40:19 +0800 Li Jun…
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while ether unbind. If otg capability is not defined, keep its otg descriptor unchanged.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/gadget/legacy/ether.c | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-)drivers/usb/gadget/legacy/ether.c +1
-14@@ -171,20 +171,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX ].s ="" ,
drivers/usb/gadget/legacy/ether.c static int rndis_do_config(struct usb_configuration *c) · line 232
Quoted 5 lines
drivers/usb/gadget/legacy/ether.c +0
-2@@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc;
If you remove this who is setting c->descriptors to otg_desc?
drivers/usb/gadget/legacy/ether.c static int rndis_do_config(struct usb_configuration *c) · line 233
Quoted 1 line
drivers/usb/gadget/legacy/ether.c +0
-1- c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ;
Why are you removing this? won't it change gadget behaviour?
drivers/usb/gadget/legacy/ether.c static int eth_do_config(struct usb_configuration *c) · line 275
Quoted 12 lines
drivers/usb/gadget/legacy/ether.c +0
-5- } - f_rndis =usb_get_function (fi_rndis);if (IS_ERR (f_rndis))return PTR_ERR (f_rndis);@@ -270,11 +252,6 @@ static int eth_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ;
same here
Quoted 65 lines
drivers/usb/gadget/legacy/ether.c +25
-4- } -if (use_eem) { f_eem =usb_get_function (fi_eem);if (IS_ERR (f_eem))@@ -416,17 +393,34 @@ static int eth_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) + goto fail1; +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + rndis_config_driver.descriptors = otg_desc; + rndis_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + eth_config_driver.descriptors = otg_desc; + eth_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } +/* register our configuration(s); RNDIS first, if it's used */ if (has_rndis ()) { status =usb_add_config (cdev, &rndis_config_driver, rndis_do_config);if (status <0 ) - goto fail1; + goto fail2; } status =usb_add_config (cdev, ð_config_driver, eth_do_config);if (status <0 ) - goto fail1; + goto fail2;usb_composite_overwrite_options (cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",@@ -434,6 +428,9 @@ static int eth_bind(struct usb_composite_dev *cdev)return 0 ; +fail2: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail1:if (has_rndis ())usb_put_function_instance (fi_rndis);@@ -463,6 +460,9 @@ static int eth_unbind(struct usb_composite_dev *cdev)usb_put_function (f_geth);usb_put_function_instance (fi_geth); } +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }Signature · 1 line
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20150618104302.3da49bc854834b0257e3f703-l0cyMroinI0@public.gmane.org
Re: [PATCH v5 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities
Quoted 43 lines · On Thu, 18 Jun 2015 10:43:02 +0300 Roger Quadros…
Quoted 40 lines · On Wed, 17 Jun 2015 19:40:19 +0800 Li Jun…
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while ether unbind. If otg capability is not defined, keep its otg descriptor unchanged.
Signed-off-by Li Jun <[email protected]>--- drivers/usb/gadget/legacy/ether.c | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-)drivers/usb/gadget/legacy/ether.c +1
-14@@ -171,20 +171,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX ].s ="" ,@@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */
Quoted 8 lines
drivers/usb/gadget/legacy/ether.c static int rndis_do_config(struct usb_configuration *c) · line 232
Quoted 2 lines
drivers/usb/gadget/legacy/ether.c +0
-2-if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc;If you remove this who is setting
c->descriptorstootg_desc?drivers/usb/gadget/legacy/ether.c static int rndis_do_config(struct usb_configuration *c) · line 233
Quoted 1 line
drivers/usb/gadget/legacy/ether.c +0
-1- c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ;Why are you removing this? won't it change gadget behaviour?
OK. I see that you moved this bit to eth_bind. So it should be fine I guess. But this change was not necessary.
cheers,
-roger
Quoted 78 lines
drivers/usb/gadget/legacy/ether.c static int eth_do_config(struct usb_configuration *c) · line 275
Quoted 13 lines
drivers/usb/gadget/legacy/ether.c +0
-5- } - f_rndis =usb_get_function (fi_rndis);if (IS_ERR (f_rndis))return PTR_ERR (f_rndis);@@ -270,11 +252,6 @@ static int eth_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ;same here
Quoted 62 lines
drivers/usb/gadget/legacy/ether.c +25
-4- } -if (use_eem) { f_eem =usb_get_function (fi_eem);if (IS_ERR (f_eem))@@ -416,17 +393,34 @@ static int eth_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) + goto fail1; +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + rndis_config_driver.descriptors = otg_desc; + rndis_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + eth_config_driver.descriptors = otg_desc; + eth_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } +/* register our configuration(s); RNDIS first, if it's used */ if (has_rndis ()) { status =usb_add_config (cdev, &rndis_config_driver, rndis_do_config);if (status <0 ) - goto fail1; + goto fail2; } status =usb_add_config (cdev, ð_config_driver, eth_do_config);if (status <0 ) - goto fail1; + goto fail2;usb_composite_overwrite_options (cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",@@ -434,6 +428,9 @@ static int eth_bind(struct usb_composite_dev *cdev)return 0 ; +fail2: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail1:if (has_rndis ())usb_put_function_instance (fi_rndis);@@ -463,6 +460,9 @@ static int eth_unbind(struct usb_composite_dev *cdev)usb_put_function (f_geth);usb_put_function_instance (fi_geth); } +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Quoted 7 lines
Quoted 3 lines
Signature · 1 line
1.9.1--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20150618105148.cbf486831982d0244d499461-l0cyMroinI0@public.gmane.org
Re: [PATCH v5 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities
Quoted 15 lines · Roger Quadros
Quoted 12 lines · On Thu, 18 Jun 2015 10:43:02 +0300 Roger Quadros…
drivers/usb/gadget/legacy/ether.c static int rndis_do_config(struct usb_configuration *c) · line 232
Quoted 6 lines · On Wed, 17 Jun 2015 19:40:19 +0800 Li Jun…
drivers/usb/gadget/legacy/ether.c +0
-2@@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc;If you remove this who is setting
c->descriptorstootg_desc?
Quoted 7 lines
Quoted 3 lines
Review static int rndis_do_config(struct usb_configuration *c) · line 233
Quoted 1 line
(quoted diff) +0
-1- c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;Why are you removing this? won't it change gadget behaviour?
OK. I see that you moved this bit to
eth_bind. So it should be fine I guess. But this change was not necessary.
right, I will revert this change.
Li Jun
Quoted 7 lines
cheers,
-rogerQuoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 13/23 usb: gadget: acm_ms: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/acm_ms.c | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/usb/gadget/legacy/acm_ms.c +23 -21
@@ -58,21 +58,7 @@ static struct usb_device_descriptor device_desc = {/*.bNumConfigurations = DYNAMIC*/ }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];/* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = {
@@ -126,11 +112,6 @@ static int acm_ms_do_config(struct usb_configuration *c)struct fsg_opts *opts;int status; -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } - opts =fsg_opts_from_func_inst (fi_msg); f_acm =usb_get_function (f_acm_inst);
@@ -225,10 +206,25 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) + goto fail_string_ids; +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + acm_ms_config_driver.descriptors = otg_desc; + acm_ms_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } +/* register our configuration */ status =usb_add_config (cdev, &acm_ms_config_driver, acm_ms_do_config);if (status <0 ) - goto fail_string_ids; + goto fail_otg_desc;usb_composite_overwrite_options (cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
@@ -236,6 +232,9 @@ static int acm_ms_bind(struct usb_composite_dev *cdev)return 0 ;/* error recovery */ +fail_otg_desc: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail_string_ids:fsg_common_remove_luns (opts->common); fail_set_cdev:
@@ -255,6 +254,9 @@ static int acm_ms_unbind(struct usb_composite_dev *cdev)usb_put_function_instance (fi_msg);usb_put_function (f_acm);usb_put_function_instance (f_acm_inst); +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 14/23 usb: gadget: audio: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/audio.c | 43 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-)
drivers/usb/gadget/legacy/audio.c +23 -20
@@ -150,20 +150,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];/*-------------------------------------------------------------------------*/
@@ -173,11 +160,6 @@ static int audio_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } -#ifdef CONFIG_GADGET_UAC1 f_uac1 =usb_get_function (fi_uac1);if (IS_ERR (f_uac1)) {
@@ -259,14 +241,32 @@ static int audio_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (cdev->gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (cdev->gadget); +if (!usb_desc) + goto fail; +usb_otg_descriptor_init (cdev->gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + audio_config_driver.descriptors = otg_desc; + audio_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } + status =usb_add_config (cdev, &audio_config_driver, audio_do_config);if (status <0 ) - goto fail; + goto fail_otg_desc;usb_composite_overwrite_options (cdev, &coverwrite);INFO (cdev,"%s, version: %s\n" ,DRIVER_DESC ,DRIVER_VERSION );return 0 ; +fail_otg_desc: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail: #ifndef CONFIG_GADGET_UAC1usb_put_function_instance (fi_uac2 );
@@ -289,6 +289,9 @@ static int audio_unbind(struct usb_composite_dev *cdev)if (!IS_ERR_OR_NULL (fi_uac2))usb_put_function_instance (fi_uac2);#endif +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 15/23 usb: gadget: cdc2: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/cdc2.c | 44 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/usb/gadget/legacy/cdc2.c +23 -21
@@ -60,21 +60,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; - +static const struct usb_descriptor_header *otg_desc[2 ];/* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = {
@@ -108,11 +94,6 @@ static int cdc_do_config(struct usb_configuration *c) {int status; -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } - f_ecm =usb_get_function (fi_ecm);if (IS_ERR (f_ecm)) { status =PTR_ERR (f_ecm);
@@ -193,10 +174,25 @@ static int cdc_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) + goto fail1; +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + cdc_config_driver.descriptors = otg_desc; + cdc_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } +/* register our configuration */ status =usb_add_config (cdev, &cdc_config_driver, cdc_do_config);if (status <0 ) - goto fail1; + goto fail2;usb_composite_overwrite_options (cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
@@ -204,6 +200,9 @@ static int cdc_bind(struct usb_composite_dev *cdev)return 0 ; +fail2: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail1:usb_put_function_instance (fi_serial); fail:
@@ -219,6 +218,9 @@ static int cdc_unbind(struct usb_composite_dev *cdev)usb_put_function (f_ecm);if (!IS_ERR_OR_NULL (fi_ecm))usb_put_function_instance (fi_ecm); +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 16/23 usb: gadget: g_ffs: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/g_ffs.c | 42 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
drivers/usb/gadget/legacy/g_ffs.c +22 -19
@@ -88,21 +88,7 @@ MODULE_PARM_DESC(bDeviceProtocol, "USB Device protocol");module_param_array_named (functions, func_names, charp, &func_num,0 );MODULE_PARM_DESC (functions,"USB Functions list" ); -static const struct usb_descriptor_header *gfs_otg_desc[] = { - (const struct usb_descriptor_header *) - &(const struct usb_otg_descriptor ) { - .bLength =sizeof (struct usb_otg_descriptor ), - .bDescriptorType =USB_DT_OTG , - -/* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , - }, - -NULL -}; +static const struct usb_descriptor_header *gfs_otg_desc[2 ];/* String IDs are assigned dynamically */ static struct usb_string gfs_strings[] = {
@@ -410,6 +396,17 @@ static int gfs_bind(struct usb_composite_dev *cdev) goto error_rndis; gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (cdev->gadget) && !gfs_otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (cdev->gadget); +if (!usb_desc) + goto error_rndis; +usb_otg_descriptor_init (cdev->gadget, usb_desc); + gfs_otg_desc[0 ] = usb_desc; + gfs_otg_desc[1 ] =NULL ; + } +for (i =0 ; i <ARRAY_SIZE (gfs_configurations); ++i) {struct gfs_configuration *c = gfs_configurations + i;int sid =USB_GADGET_FIRST_AVAIL_IDX + i;
@@ -419,6 +416,11 @@ static int gfs_bind(struct usb_composite_dev *cdev) c->c.bConfigurationValue =1 + i; c->c.bmAttributes =USB_CONFIG_ATT_SELFPOWER ; +if (gadget_is_otg (cdev->gadget)) { + c->c.descriptors = gfs_otg_desc; + c->c.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } + c->num = i; ret =usb_add_config (cdev, &c->c, gfs_do_config);
@@ -430,6 +432,8 @@ static int gfs_bind(struct usb_composite_dev *cdev)/* TODO */ error_unbind: +kfree (gfs_otg_desc[0 ]); + gfs_otg_desc[0 ] =NULL ; error_rndis: #ifdef CONFIG_USB_FUNCTIONFS_RNDISusb_put_function_instance (fi_rndis );
@@ -471,6 +475,9 @@ static int gfs_unbind(struct usb_composite_dev *cdev)for (i =0 ; i <N_CONF * func_num; ++i)usb_put_function (*(f_ffs[0 ] + i)); +kfree (gfs_otg_desc[0 ]); + gfs_otg_desc[0 ] =NULL ; +return 0 ; }
@@ -488,11 +495,6 @@ static int gfs_do_config(struct usb_configuration *c)if (missing_funcs)return -ENODEV ; -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = gfs_otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - }
PATCH v5 17/23 usb: gadget: hid: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/hid.c | 45 ++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/usb/gadget/legacy/hid.c +24 -21
@@ -68,21 +68,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; - +static const struct usb_descriptor_header *otg_desc[2 ];/* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = {
@@ -111,11 +97,6 @@ static int do_config(struct usb_configuration *c)struct hidg_func_node *e, *n;int status =0 ; -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } -list_for_each_entry (e, &hidg_func_list, node) { e->f =usb_get_function (e->fi);if (IS_ERR (e->f))
@@ -186,16 +167,34 @@ static int hid_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) + goto put; +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + config_driver.descriptors = otg_desc; + config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } +/* register our configuration */ status =usb_add_config (cdev, &config_driver, do_config);if (status <0 ) - goto put; + goto free_otg_desc;usb_composite_overwrite_options (cdev, &coverwrite);dev_info (&gadget->dev,DRIVER_DESC ", version: " DRIVER_VERSION "\n" );return 0 ; +free_otg_desc: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; put:list_for_each_entry (m, &hidg_func_list, node) {if (m == n)
@@ -213,6 +212,10 @@ static int hid_unbind(struct usb_composite_dev *cdev)usb_put_function (n->f);usb_put_function_instance (n->fi); } + +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 18/23 usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/mass_storage.c | 44 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/usb/gadget/legacy/mass_storage.c +23 -21
@@ -64,21 +64,7 @@ static struct usb_device_descriptor msg_device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX ].s ="" ,
@@ -135,11 +121,6 @@ static int msg_do_config(struct usb_configuration *c)struct fsg_opts *opts;int ret; -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } - opts =fsg_opts_from_func_inst (fi_msg); f_msg =usb_get_function (fi_msg);
@@ -214,9 +195,24 @@ static int msg_bind(struct usb_composite_dev *cdev) goto fail_string_ids; msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (cdev->gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (cdev->gadget); +if (!usb_desc) + goto fail_string_ids; +usb_otg_descriptor_init (cdev->gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + msg_config_driver.descriptors = otg_desc; + msg_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } + status =usb_add_config (cdev, &msg_config_driver, msg_do_config);if (status <0 ) - goto fail_string_ids; + goto fail_otg_desc;usb_composite_overwrite_options (cdev, &coverwrite); dev_info(&cdev->gadget->dev,
@@ -224,6 +220,9 @@ static int msg_bind(struct usb_composite_dev *cdev)set_bit (0 , &msg_registered);return 0 ; +fail_otg_desc: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail_string_ids:fsg_common_remove_luns (opts->common); fail_set_cdev:
@@ -243,6 +242,9 @@ static int msg_unbind(struct usb_composite_dev *cdev)if (!IS_ERR (fi_msg))usb_put_function_instance (fi_msg); +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 19/23 usb: gadget: multi: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/multi.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
drivers/usb/gadget/legacy/multi.c +24 -15
@@ -78,21 +78,7 @@ static struct usb_device_descriptor device_desc = { .idProduct = cpu_to_le16(MULTI_PRODUCT_NUM), }; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &(struct usb_otg_descriptor ){ - .bLength =sizeof (struct usb_otg_descriptor ), - .bDescriptorType =USB_DT_OTG , - -/* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , - }, -NULL , -}; - +static const struct usb_descriptor_header *otg_desc[2 ];enum {MULTI_STRING_RNDIS_CONFIG_IDX =USB_GADGET_FIRST_AVAIL_IDX ,
@@ -155,6 +141,16 @@ static int rndis_do_config(struct usb_configuration *c)int ret;if (gadget_is_otg (c->cdev->gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (c->cdev->gadget); +if (!usb_desc) +return -ENOMEM ; +usb_otg_descriptor_init (c->cdev->gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } c->descriptors = otg_desc; c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; }
@@ -243,6 +239,16 @@ static int cdc_do_config(struct usb_configuration *c)int ret;if (gadget_is_otg (c->cdev->gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (c->cdev->gadget); +if (!usb_desc) +return -ENOMEM ; +usb_otg_descriptor_init (c->cdev->gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } c->descriptors = otg_desc; c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; }
@@ -490,6 +496,9 @@ static int multi_unbind(struct usb_composite_dev *cdev)usb_put_function (f_ecm);usb_put_function_instance (fi_ecm);#endif +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 20/23 usb: gadget: ncm: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/ncm.c | 43 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-)
drivers/usb/gadget/legacy/ncm.c +23 -20
@@ -69,20 +69,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];/* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = {
@@ -113,11 +100,6 @@ static int ncm_do_config(struct usb_configuration *c)/* FIXME alloc iConfiguration string, set it in c->strings */ -if (gadget_is_otg (c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } - f_ncm =usb_get_function (f_ncm_inst);if (IS_ERR (f_ncm)) { status =PTR_ERR (f_ncm);
@@ -171,16 +153,34 @@ static int gncm_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX ].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX ].id; +if (gadget_is_otg (gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (gadget); +if (!usb_desc) + goto fail; +usb_otg_descriptor_init (gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + ncm_config_driver.descriptors = otg_desc; + ncm_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } + status =usb_add_config (cdev, &ncm_config_driver, ncm_do_config);if (status <0 ) - goto fail; + goto fail1;usb_composite_overwrite_options (cdev, &coverwrite);dev_info (&gadget->dev,"%s\n" ,DRIVER_DESC );return 0 ; +fail1: +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; fail:usb_put_function_instance (f_ncm_inst);return status;
@@ -192,6 +192,9 @@ static int gncm_unbind(struct usb_composite_dev *cdev)usb_put_function (f_ncm);if (!IS_ERR_OR_NULL (f_ncm_inst))usb_put_function_instance (f_ncm_inst); +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 21/23 usb: gadget: printer: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/printer.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/usb/gadget/legacy/printer.c +19 -16
@@ -82,16 +82,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1 }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - .bmAttributes =USB_OTG_SRP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];/*-------------------------------------------------------------------------*/
@@ -135,12 +126,6 @@ static int printer_do_config(struct usb_configuration *c)usb_gadget_set_selfpowered (gadget); -if (gadget_is_otg (gadget)) { - otg_descriptor.bmAttributes |=USB_OTG_HNP ; - printer_cfg_driver.descriptors = otg_desc; - printer_cfg_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; - } - f_printer =usb_get_function (fi_printer);if (IS_ERR (f_printer))return PTR_ERR (f_printer);
@@ -182,6 +167,21 @@ static int printer_bind(struct usb_composite_dev *cdev) device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX ].id; device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX ].id; +if (gadget_is_otg (cdev->gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (cdev->gadget); +if (!usb_desc) +return -ENOMEM ; +usb_otg_descriptor_init (cdev->gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } + printer_cfg_driver.descriptors = otg_desc; + printer_cfg_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; + } + ret =usb_add_config (cdev, &printer_cfg_driver, printer_do_config);if (ret) {usb_put_function_instance (fi_printer);
@@ -196,6 +196,9 @@ static int printer_unbind(struct usb_composite_dev *cdev)usb_put_function (f_printer);usb_put_function_instance (fi_printer); +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 22/23 usb: gadget: serial: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/serial.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/usb/gadget/legacy/serial.c +15 -14
@@ -79,20 +79,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; +static const struct usb_descriptor_header *otg_desc[2 ];/*-------------------------------------------------------------------------*/
@@ -191,6 +178,16 @@ static int gs_bind(struct usb_composite_dev *cdev) serial_config_driver.iConfiguration = status;if (gadget_is_otg (cdev->gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (cdev->gadget); +if (!usb_desc) +return -ENOMEM ; +usb_otg_descriptor_init (cdev->gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } serial_config_driver.descriptors = otg_desc; serial_config_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; }
@@ -227,6 +224,10 @@ static int gs_unbind(struct usb_composite_dev *cdev)usb_put_function (f_serial[i]);usb_put_function_instance (fi_serial[i]); } + +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 23/23 usb: gadget: zero: allocate and init otg descriptor by otg capabilities
In reply to a message not in the archiveAllocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged.
--- drivers/usb/gadget/legacy/zero.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
drivers/usb/gadget/legacy/zero.c +14 -18
@@ -121,24 +121,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 2, }; -#ifdef CONFIG_USB_OTG -static struct usb_otg_descriptor otg_descriptor = { - .bLength =sizeof otg_descriptor, - .bDescriptorType =USB_DT_OTG , - -/* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes =USB_OTG_SRP |USB_OTG_HNP , -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, -NULL , -}; -#else -#define otg_desc NULL -#endif +static const struct usb_descriptor_header *otg_desc[2 ];/* string IDs are assigned dynamically */ /* default serial number takes at least two packets */
@@ -341,6 +324,16 @@ static int zero_bind(struct usb_composite_dev *cdev)/* support OTG systems */ if (gadget_is_otg (cdev->gadget)) { +if (!otg_desc[0 ]) { +struct usb_descriptor_header *usb_desc; + + usb_desc =usb_otg_descriptor_alloc (cdev->gadget); +if (!usb_desc) +return -ENOMEM ; +usb_otg_descriptor_init (cdev->gadget, usb_desc); + otg_desc[0 ] = usb_desc; + otg_desc[1 ] =NULL ; + } sourcesink_driver.descriptors = otg_desc; sourcesink_driver.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; loopback_driver.descriptors = otg_desc;
@@ -397,6 +390,9 @@ static int zero_unbind(struct usb_composite_dev *cdev)if (!IS_ERR_OR_NULL (func_lb))usb_put_function (func_lb);usb_put_function_instance (func_inst_lb); +kfree (otg_desc[0 ]); + otg_desc[0 ] =NULL ; +return 0 ; }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html