From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roger Quadros Subject: Re: [PATCH v2 05/22] doc: dt-binding: usb: add otg related properties Date: Fri, 12 Jun 2015 11:41:40 +0300 Message-ID: <20150612114140.52f87bc8@rockdesk> References: <20150609182931.1eda4111@rockdesk> <20150610120623.GA7678@shlinux2> <20150611103035.08967a37@rockdesk> <20150611083851.GB16101@shlinux2> <20150611155102.15b881fd@rockdesk> <20150611142208.GD16101@shlinux2> <20150611175557.724a14e5@rockdesk> <20150612014203.GE16101@shlinux2> <20150612110213.59286f9f@rockdesk> <20150612082358.GG16101@shlinux2> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <20150612082358.GG16101@shlinux2> Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Li Jun Cc: Felipe Balbi , Chen Peter-B29397 , Rob Herring , Li Jun-B47624 , Greg Kroah-Hartman , Linux USB List , "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Rob Herring , Pawel Moll , Mark Rutland , "macpaul-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" List-Id: devicetree@vger.kernel.org On Fri, 12 Jun 2015 16:23:59 +0800 Li Jun wrote: > On Fri, Jun 12, 2015 at 11:02:13AM +0300, Roger Quadros wrote: > >=20 > > On Fri, 12 Jun 2015 09:42:04 +0800 > > Li Jun wrote: > >=20 > > > On Thu, Jun 11, 2015 at 05:55:57PM +0300, Roger Quadros wrote: > > > > > > drivers/usb/core/hub.c > > > > > >=20 > > > > > > static int usb_enumerate_device_otg(struct usb_device *udev= ) > > > > > > { > > > > > > int err =3D 0; > > > > > >=20 > > > > > > #ifdef CONFIG_USB_OTG > > > > > > /* > > > > > > * OTG-aware devices on OTG-capable root hubs may be able = to use SRP, > > > > > > * to wake us after we've powered off VBUS; and HNP, switc= hing roles > > > > > > * "host" to "peripheral". The OTG descriptor helps figur= e this out. > > > > > > */ > > > > > > if (!udev->bus->is_b_host > > > > > > && udev->config > > > > > > && udev->parent =3D=3D udev->bus->root_hub) { > > > > > > struct usb_otg_descriptor *desc =3D NULL; > > > > > > struct usb_bus *bus =3D udev->bus; > > > > > >=20 > > > > > > /* descriptor may appear anywhere in config */ > > > > > > if (__usb_get_extra_descriptor (udev->rawdescriptors[0], > > > > > > le16_to_cpu(udev->config[0].desc.wTotalLength), > > > > > > USB_DT_OTG, (void **) &desc) =3D=3D 0) { > > > > > > if (desc->bmAttributes & USB_OTG_HNP) { > > > > > > unsigned port1 =3D udev->portnum; > > > > > >=20 > > > > > > dev_info(&udev->dev, > > > > > > "Dual-Role OTG device on %sHNP port\n", > > > > > > (port1 =3D=3D bus->otg_port) > > > > > > ? "" : "non-"); > > > > > >=20 > > > > > > /* enable HNP before suspend, it's simpler */ > > > > > > if (port1 =3D=3D bus->otg_port) > > > > > > bus->b_hnp_enable =3D 1; > > > > > > err =3D usb_control_msg(udev, > > > > > > usb_sndctrlpipe(udev, 0), > > > > > > USB_REQ_SET_FEATURE, 0, > > > > > > bus->b_hnp_enable > > > > > > ? USB_DEVICE_B_HNP_ENABLE > > > > > > : USB_DEVICE_A_ALT_HNP_SUPPORT, > > > > > > 0, NULL, 0, USB_CTRL_SET_TIMEOUT); > > > > > >=20 > > > > > > We're sending out this control request even if this host po= rt is not OTG. > > > > > > Isn't that wrong? > > > > >=20 > > > > > So send USB_DEVICE_A_ALT_HNP_SUPPORT request. > > > > > This is correct in OTG 1.x, its intention is to remind the us= er who is > > > > > connecting the HNP capable OTG device to a non-OTG port, He c= an change > > > > > to another port of this machine which is a OTG port(with HNP)= =2E > > > >=20 > > > > I didn't understand. > > > > If CONFIG_USB_OTG is enabled doesn't mean that this USB host po= rt is OTG host. > > > Yes, only CONFIG_USB_OTG enabled doesn't mean that this USB host = port > > > is a OTG port, there are might multiple usb host ports, but only = one > > > is a OTG port. > >=20 > > Not necessarily. Many systems don't have any OTG port so that reque= st cannot > > be sent even if CONFIG_USB_OTG is enabled. > >=20 > That's the fact, but we are talking the code only for those systems w= hich > have OTG port. If you think we need not cover the support for OTG 1.x= host, > we can simply remove it. We should not remove it but need to add the following check. Send that request only if the system has at least one OTG (v1.x) port t= hat is capable of HNP _and_ this port is not that HNP capable port _and_ the connected device is OTG (v1.x) >=20 > > > > So it should not send any OTG specific request to device. Right= ? > > > Non-otg port(in OTG 1.x protocol) + OTG 1.x device, should send, > > > otherwise, should not send. > >=20 > > What did you mean by Non-OTG port (in OTG 1.x protocol)? >=20 > Means host only port without HNP. >=20 > > If it is Non-OTG port it doesn't understand any OTG protocol. >=20 > With common sense, yes, but there is one exception. >=20 > > So Non-OTG port should not send any OTG request. > >=20 > see below from OTG 1.3: >=20 > 6.5.3 a_alt_hnp_support > Setting this feature indicates to the B-device that it is connected t= o > an A-device port that is not capable of HNP, but that the A-device do= es > have an alternate port that is capable of HNP. > The A-device is required to set this feature under the following cond= itions: > =E2=80=A2 the A-device has multiple receptacles > =E2=80=A2 the A-device port that connects to the B-device does not su= pport HNP > =E2=80=A2 the A-device has another port that does support HNP > ... ... Thanks for this info. I can't seem to find the OTG v1.3 spec. cheers, -roger >=20 > > >=20 > > > So the code you pasted here was right only for OTG 1.x, I assume > > > OTG 2.0 has not been released when it was designed. But now it's > > > out of date, it's wrong if you connect a OTG 2.0 device.=20 > > >=20 > >=20 > > The code is wrong for non-OTG ports when CONFIG_USB_OTG is set. > >=20 > > Peter/Felipe, any comments on this? > >=20 > > cheers, > > -roger > >=20 > > > >=20 > > > > >=20 > > > > > >=20 > > > > > > if (err < 0) { > > > > > > /* OTG MESSAGE: report errors here, > > > > > > * customize to match your product. > > > > > > */ > > > > > > dev_info(&udev->dev, > > > > > > "can't set HNP mode: %d\n", > > > > > > err); > > > > > > bus->b_hnp_enable =3D 0; > > > > > > } > > > > > >=20 > > > > > > Instead it should be moved inside the if (port1 =3D=3D bus-= >otg_port) condition. > > > > >=20 > > > > > Nope, as I explained above, this is really too detailed OTG p= rotocol:) > > > > > >=20 > > > > > > } > > > > > > } > > > > > > } > > > > > > #endif > > > > > > return err; > > > > > > } > > > > > >=20 > >=20 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html