Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1582560 > unrolled thread

[PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

Started byRoger Quadros <rogerq@ti.com>
First post2017-02-16 14:10 +0100
Last post2017-02-28 16:20 +0100
Articles 10 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode Roger Quadros <rogerq@ti.com> - 2017-02-16 14:10 +0100
    Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-02-23 09:40 +0100
      Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on  dra7 in dual-role mode Peter Chen <hzpeterchen@gmail.com> - 2017-02-24 02:10 +0100
        Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-02-24 04:20 +0100
      Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Roger Quadros <rogerq@ti.com> - 2017-02-24 13:10 +0100
        Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Chanwoo Choi <cwchoi00@gmail.com> - 2017-02-25 04:50 +0100
          Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Chanwoo Choi <cwchoi00@gmail.com> - 2017-02-25 05:00 +0100
            Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-02-28 15:10 +0100
    Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Chanwoo Choi <cwchoi00@gmail.com> - 2017-02-25 04:40 +0100
      Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7  in dual-role mode Roger Quadros <rogerq@ti.com> - 2017-02-28 16:20 +0100

#1582560 — [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromRoger Quadros <rogerq@ti.com>
Date2017-02-16 14:10 +0100
Subject[PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<tbtYS-6zA-9@gated-at.bofh.it>
dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
when we're operating in dual-role.

We work around that by bypassing the OTG core and reading the
extcon framework directly for ID/VBUS events.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
 drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
 drivers/usb/dwc3/core.h                        |   5 +
 3 files changed, 170 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
index e3e6983..9955c0d 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -53,6 +53,8 @@ Optional properties:
  - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
 	register for post-silicon frame length adjustment when the
 	fladj_30mhz_sdbnd signal is invalid or incorrect.
+ - extcon: phandle to the USB connector extcon device. If present, extcon
+	device will be used to get USB cable events instead of OTG controller.
 
  - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
 
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 619fa7c..b02d911 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -918,6 +918,19 @@ static void dwc3_otg_fsm_sync(struct dwc3 *dwc)
 	if (dwc->otg_prevent_sync)
 		return;
 
+	if (dwc->edev) {
+		/* get ID */
+		id = extcon_get_state(dwc->edev, EXTCON_USB_HOST);
+		/* Host means ID == 0 */
+		id = !id;
+
+		/* get VBUS */
+		vbus = extcon_get_state(dwc->edev, EXTCON_USB);
+		dwc3_drd_statemachine(dwc, id, vbus);
+
+		return;
+	}
+
 	reg = dwc3_readl(dwc->regs, DWC3_OSTS);
 	id = !!(reg & DWC3_OSTS_CONIDSTS);
 	vbus = !!(reg & DWC3_OSTS_BSESVLD);
@@ -934,6 +947,17 @@ static void dwc3_drd_work(struct work_struct *work)
 	spin_unlock(&dwc->lock);
 }
 
+static int dwc3_drd_notifier(struct notifier_block *nb,
+			     unsigned long event, void *ptr)
+{
+	struct dwc3 *dwc = container_of(nb, struct dwc3, edev_nb);
+
+	if (!dwc->otg_prevent_sync)
+		queue_work(system_power_efficient_wq, &dwc->otg_work);
+
+	return NOTIFY_DONE;
+}
+
 static void dwc3_otg_disable_events(struct dwc3 *dwc, u32 disable_mask)
 {
 	dwc->oevten &= ~(disable_mask);
@@ -1040,6 +1064,27 @@ static int dwc3_drd_start_host(struct dwc3 *dwc, int on, bool skip)
 {
 	u32 reg;
 
+	if (!dwc->edev)
+		goto otg;
+
+	if (on)
+		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
+
+	if (!skip) {
+		spin_unlock(&dwc->lock);
+
+		/* start or stop the HCD */
+		if (on)
+			dwc3_host_init(dwc);
+		else
+			dwc3_host_exit(dwc);
+
+		spin_lock(&dwc->lock);
+	}
+
+	return 0;
+
+otg:
 	/* switch OTG core */
 	if (on) {
 		/* As per Figure 11-10 A-Device Flow Diagram */
@@ -1133,6 +1178,33 @@ static int dwc3_drd_start_gadget(struct dwc3 *dwc, int on)
 	if (on)
 		dwc3_event_buffers_setup(dwc);
 
+	if (!dwc->edev)
+		goto otg;
+
+	if (on) {
+		dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
+		/* start the Peripheral driver  */
+		if (dwc->gadget_driver) {
+			__dwc3_gadget_start(dwc);
+			if (dwc->gadget_pullup)
+				dwc3_gadget_run_stop(dwc, true, false);
+		}
+	} else {
+		/* stop the Peripheral driver */
+		if (dwc->gadget_driver) {
+			if (dwc->gadget_pullup)
+				dwc3_gadget_run_stop(dwc, false, false);
+			spin_unlock(&dwc->lock);
+			if (dwc->gadget_driver->disconnect)
+				dwc->gadget_driver->disconnect(&dwc->gadget);
+			spin_lock(&dwc->lock);
+			__dwc3_gadget_stop(dwc);
+		}
+	}
+
+	return 0;
+
+otg:
 	if (on) {
 		/* As per Figure 11-20 B-Device Flow Diagram */
 
@@ -1251,6 +1323,13 @@ static void dwc3_otg_core_init(struct dwc3 *dwc)
 {
 	u32 reg;
 
+	/* force drd state machine update the first time */
+	dwc->otg_fsm.b_sess_vld = -1;
+	dwc->otg_fsm.id = -1;
+
+	if (dwc->edev)
+		return;
+
 	/*
 	 * As per Figure 11-4 OTG Driver Overall Programming Flow,
 	 * block "Initialize GCTL for OTG operation".
@@ -1264,15 +1343,14 @@ static void dwc3_otg_core_init(struct dwc3 *dwc)
 
 	/* Initialize OTG registers */
 	dwc3_otgregs_init(dwc);
-
-	/* force drd state machine update the first time */
-	dwc->otg_fsm.b_sess_vld = -1;
-	dwc->otg_fsm.id = -1;
 }
 
 /* dwc->lock must be held */
 static void dwc3_otg_core_exit(struct dwc3 *dwc)
 {
+	if (dwc->edev)
+		return;
+
 	/* disable all otg irqs */
 	dwc3_otg_disable_events(dwc, DWC3_OTG_ALL_EVENTS);
 	/* clear all events */
@@ -1286,6 +1364,57 @@ static int dwc3_drd_init(struct dwc3 *dwc)
 
 	INIT_WORK(&dwc->otg_work, dwc3_drd_work);
 
+	/* If extcon device is present we don't rely on OTG core for ID event */
+	if (dwc->edev) {
+		int id, vbus;
+
+		dwc->edev_nb.notifier_call = dwc3_drd_notifier;
+		ret = extcon_register_notifier(dwc->edev, EXTCON_USB,
+					       &dwc->edev_nb);
+		if (ret < 0) {
+			dev_err(dwc->dev, "Couldn't register USB cable notifier\n");
+			return -ENODEV;
+		}
+
+		ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
+					       &dwc->edev_nb);
+		if (ret < 0) {
+			dev_err(dwc->dev, "Couldn't register USB-HOST cable notifier\n");
+			ret = -ENODEV;
+			goto extcon_fail;
+		}
+
+		/* sanity check id & vbus states */
+		id = extcon_get_state(dwc->edev, EXTCON_USB_HOST);
+		vbus = extcon_get_state(dwc->edev, EXTCON_USB);
+		if (id < 0 || vbus < 0) {
+			dev_err(dwc->dev, "Invalid USB cable state. id %d, vbus %d\n",
+				id, vbus);
+			ret = -ENODEV;
+			goto fail;
+		}
+
+		ret = dwc3_gadget_init(dwc);
+		if (ret)
+			goto fail;
+
+		spin_lock_irqsave(&dwc->lock, flags);
+		dwc3_otg_core_init(dwc);
+		spin_unlock_irqrestore(&dwc->lock, flags);
+		queue_work(system_power_efficient_wq, &dwc->otg_work);
+
+		return 0;
+
+fail:
+		extcon_unregister_notifier(dwc->edev, EXTCON_USB_HOST,
+					   &dwc->edev_nb);
+extcon_fail:
+		extcon_unregister_notifier(dwc->edev, EXTCON_USB,
+					   &dwc->edev_nb);
+
+		return ret;
+	}
+
 	irq = dwc3_otg_get_irq(dwc);
 	if (irq < 0)
 		return irq;
@@ -1326,13 +1455,24 @@ static void dwc3_drd_exit(struct dwc3 *dwc)
 {
 	unsigned long flags;
 
+	spin_lock(&dwc->lock);
+	dwc->otg_prevent_sync = true;
+	spin_unlock(&dwc->lock);
 	cancel_work_sync(&dwc->otg_work);
+
 	spin_lock_irqsave(&dwc->lock, flags);
 	dwc3_otg_core_exit(dwc);
 	if (dwc->otg_fsm.protocol == PROTO_HOST)
 		dwc3_drd_start_host(dwc, 0, 0);
 	dwc->otg_fsm.protocol = PROTO_UNDEF;
-	free_irq(dwc->otg_irq, dwc);
+	if (dwc->edev) {
+		extcon_unregister_notifier(dwc->edev, EXTCON_USB_HOST,
+					   &dwc->edev_nb);
+		extcon_unregister_notifier(dwc->edev, EXTCON_USB,
+					   &dwc->edev_nb);
+	} else {
+		free_irq(dwc->otg_irq, dwc);
+	}
 	spin_unlock_irqrestore(&dwc->lock, flags);
 
 	dwc3_gadget_exit(dwc);
@@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
 
 	dwc3_get_properties(dwc);
 
+	if (dev->of_node) {
+		if (of_property_read_bool(dev->of_node, "extcon"))
+			dwc->edev = extcon_get_edev_by_phandle(dev, 0);
+
+		if (IS_ERR(dwc->edev))
+			return PTR_ERR(dwc->edev);
+	}
+
 	platform_set_drvdata(pdev, dwc);
 	dwc3_cache_hwparams(dwc);
 
@@ -1743,6 +1891,13 @@ static int dwc3_resume_common(struct dwc3 *dwc)
 	if (ret)
 		return ret;
 
+	if (dwc->dr_mode == USB_DR_MODE_OTG &&
+	    dwc->edev) {
+		if (dwc->otg_fsm.protocol == PROTO_HOST)
+			dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
+		else if (dwc->otg_fsm.protocol == PROTO_GADGET)
+			dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
+	}
 	spin_lock_irqsave(&dwc->lock, flags);
 
 	switch (dwc->dr_mode) {
@@ -1771,8 +1926,10 @@ static int dwc3_resume_common(struct dwc3 *dwc)
 
 	if (dwc->dr_mode == USB_DR_MODE_OTG) {
 		dwc3_otg_core_init(dwc);
-		if (dwc->otg_fsm.protocol == PROTO_HOST)
+		if ((dwc->otg_fsm.protocol == PROTO_HOST) &&
+		    !dwc->edev) {
 			dwc3_drd_start_host(dwc, true, 1);
+		}
 	}
 
 	spin_unlock_irqrestore(&dwc->lock, flags);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index bf8951d..fc060ae 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -38,6 +38,7 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/otg-fsm.h>
 
+#include <linux/extcon.h>
 #include <linux/workqueue.h>
 
 #define DWC3_MSG_MAX	500
@@ -869,6 +870,8 @@ struct dwc3_scratchpad_array {
  * @current_mode: current mode of operation written to PRTCAPDIR
  * @otg_work: work struct for otg/dual-role
  * @otg_needs_host_start: flag that OTG controller needs to start host
+ * @edev: extcon handle
+ * @edev_nb: extcon notifier
  * @fladj: frame length adjustment
  * @irq_gadget: peripheral controller's IRQ number
  * @otg_irq: IRQ number for OTG IRQs
@@ -1007,6 +1010,8 @@ struct dwc3 {
 	u32			current_mode;
 	struct work_struct	otg_work;
 	bool			otg_needs_host_start;
+	struct extcon_dev	*edev;
+	struct notifier_block	edev_nb;
 
 	enum usb_phy_interface	hsphy_mode;
 
-- 
2.7.4

[toc] | [next] | [standalone]


#1586737 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromVivek Gautam <vivek.gautam@codeaurora.org>
Date2017-02-23 09:40 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<tdX6q-7c9-19@gated-at.bofh.it>
In reply to#1582560

On 02/16/2017 06:36 PM, Roger Quadros wrote:
> dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
> when we're operating in dual-role.
>
> We work around that by bypassing the OTG core and reading the
> extcon framework directly for ID/VBUS events.
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> ---
>   Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>   drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
>   drivers/usb/dwc3/core.h                        |   5 +
>   3 files changed, 170 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
> index e3e6983..9955c0d 100644
> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> @@ -53,6 +53,8 @@ Optional properties:
>    - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
>   	register for post-silicon frame length adjustment when the
>   	fladj_30mhz_sdbnd signal is invalid or incorrect.
> + - extcon: phandle to the USB connector extcon device. If present, extcon
> +	device will be used to get USB cable events instead of OTG controller.
>   
>    - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
>   
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 619fa7c..b02d911 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c

[snip]

> @@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
>   
>   	dwc3_get_properties(dwc);
>   
> +	if (dev->of_node) {
> +		if (of_property_read_bool(dev->of_node, "extcon"))
> +			dwc->edev = extcon_get_edev_by_phandle(dev, 0);

Don't we want separate edev's for vbus and id ?
One can have separate pins connected to them and in that case
we can't get the events out of one pin only.

> +
> +		if (IS_ERR(dwc->edev))
> +			return PTR_ERR(dwc->edev);

  Took me a while to get to this. :)

                 if (IS_ERR(dwc->edev)) {
                        ret = PTR_ERR(dwc->edev);
                        goto err0;
                 }

We want to reset the res->start back to its original offset.

Testing this series currently. Will get back with my results.


Regards
Vivek

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1587217 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromPeter Chen <hzpeterchen@gmail.com>
Date2017-02-24 02:10 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<tecyt-Yd-1@gated-at.bofh.it>
In reply to#1586737
On Thu, Feb 23, 2017 at 02:04:50PM +0530, Vivek Gautam wrote:
> 
> 
> On 02/16/2017 06:36 PM, Roger Quadros wrote:
> >dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
> >when we're operating in dual-role.
> >
> >We work around that by bypassing the OTG core and reading the
> >extcon framework directly for ID/VBUS events.
> >
> >Signed-off-by: Roger Quadros <rogerq@ti.com>
> >---
> >  Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
> >  drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
> >  drivers/usb/dwc3/core.h                        |   5 +
> >  3 files changed, 170 insertions(+), 6 deletions(-)
> >
> >diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
> >index e3e6983..9955c0d 100644
> >--- a/Documentation/devicetree/bindings/usb/dwc3.txt
> >+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> >@@ -53,6 +53,8 @@ Optional properties:
> >   - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
> >  	register for post-silicon frame length adjustment when the
> >  	fladj_30mhz_sdbnd signal is invalid or incorrect.
> >+ - extcon: phandle to the USB connector extcon device. If present, extcon
> >+	device will be used to get USB cable events instead of OTG controller.
> >   - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
> >diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> >index 619fa7c..b02d911 100644
> >--- a/drivers/usb/dwc3/core.c
> >+++ b/drivers/usb/dwc3/core.c
> 
> [snip]
> 
> >@@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
> >  	dwc3_get_properties(dwc);
> >+	if (dev->of_node) {
> >+		if (of_property_read_bool(dev->of_node, "extcon"))
> >+			dwc->edev = extcon_get_edev_by_phandle(dev, 0);
> 
> Don't we want separate edev's for vbus and id ?
> One can have separate pins connected to them and in that case
> we can't get the events out of one pin only.
> 

Current extcon-usb-gpio driver supports id and vbus at the same time,
that means there are two optional gpios under one extcon node.

-- 

Best Regards,
Peter Chen

[toc] | [prev] | [next] | [standalone]


#1587251 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromVivek Gautam <vivek.gautam@codeaurora.org>
Date2017-02-24 04:20 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<teeAh-2ue-1@gated-at.bofh.it>
In reply to#1587217

On 02/24/2017 06:27 AM, Peter Chen wrote:
> On Thu, Feb 23, 2017 at 02:04:50PM +0530, Vivek Gautam wrote:
>>
>> On 02/16/2017 06:36 PM, Roger Quadros wrote:
>>> dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
>>> when we're operating in dual-role.
>>>
>>> We work around that by bypassing the OTG core and reading the
>>> extcon framework directly for ID/VBUS events.
>>>
>>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>>> ---
>>>   Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>>   drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
>>>   drivers/usb/dwc3/core.h                        |   5 +
>>>   3 files changed, 170 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> index e3e6983..9955c0d 100644
>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> @@ -53,6 +53,8 @@ Optional properties:
>>>    - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
>>>   	register for post-silicon frame length adjustment when the
>>>   	fladj_30mhz_sdbnd signal is invalid or incorrect.
>>> + - extcon: phandle to the USB connector extcon device. If present, extcon
>>> +	device will be used to get USB cable events instead of OTG controller.
>>>    - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
>>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>>> index 619fa7c..b02d911 100644
>>> --- a/drivers/usb/dwc3/core.c
>>> +++ b/drivers/usb/dwc3/core.c
>> [snip]
>>
>>> @@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
>>>   	dwc3_get_properties(dwc);
>>> +	if (dev->of_node) {
>>> +		if (of_property_read_bool(dev->of_node, "extcon"))
>>> +			dwc->edev = extcon_get_edev_by_phandle(dev, 0);
>> Don't we want separate edev's for vbus and id ?
>> One can have separate pins connected to them and in that case
>> we can't get the events out of one pin only.
>>
> Current extcon-usb-gpio driver supports id and vbus at the same time,
> that means there are two optional gpios under one extcon node.
>

Right, and we would want to leverage that by providing couple
of phandles for vbus and id, and requesting the two in driver.


Regards
Vivek

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1587547 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromRoger Quadros <rogerq@ti.com>
Date2017-02-24 13:10 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<temRb-8oy-5@gated-at.bofh.it>
In reply to#1586737
+Chanwoo

Hi Vivek,

On 23/02/17 10:34, Vivek Gautam wrote:
> 
> 
> On 02/16/2017 06:36 PM, Roger Quadros wrote:
>> dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
>> when we're operating in dual-role.
>>
>> We work around that by bypassing the OTG core and reading the
>> extcon framework directly for ID/VBUS events.
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> ---
>>   Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>   drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
>>   drivers/usb/dwc3/core.h                        |   5 +
>>   3 files changed, 170 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
>> index e3e6983..9955c0d 100644
>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>> @@ -53,6 +53,8 @@ Optional properties:
>>    - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
>>       register for post-silicon frame length adjustment when the
>>       fladj_30mhz_sdbnd signal is invalid or incorrect.
>> + - extcon: phandle to the USB connector extcon device. If present, extcon
>> +    device will be used to get USB cable events instead of OTG controller.
>>      - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
>>   diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 619fa7c..b02d911 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
> 
> [snip]
> 
>> @@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
>>         dwc3_get_properties(dwc);
>>   +    if (dev->of_node) {
>> +        if (of_property_read_bool(dev->of_node, "extcon"))
>> +            dwc->edev = extcon_get_edev_by_phandle(dev, 0);
> 
> Don't we want separate edev's for vbus and id ?
> One can have separate pins connected to them and in that case
> we can't get the events out of one pin only.

Is such kind of hardware really there? Ideally one extcon device
represents one connector. So VBUS and ID events of a single USB
port should come on one extcon device.
If it doesn't then you need to fix your platforms extcon driver
so that it does.
Chanwoo can correct me if I'm wrong on this understanding.

Currently, if VBUS and ID come on GPIOs the extcon-usb-gpio driver
takes care of both.

> 
>> +
>> +        if (IS_ERR(dwc->edev))
>> +            return PTR_ERR(dwc->edev);
> 
>  Took me a while to get to this. :)
> 
>                 if (IS_ERR(dwc->edev)) {
>                        ret = PTR_ERR(dwc->edev);
>                        goto err0;
>                 }
> 
> We want to reset the res->start back to its original offset.
> 
> Testing this series currently. Will get back with my results.
> 
> 
Thanks :)

-- 
cheers,
-roger

[toc] | [prev] | [next] | [standalone]


#1588053 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromChanwoo Choi <cwchoi00@gmail.com>
Date2017-02-25 04:50 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<teBwR-1TQ-1@gated-at.bofh.it>
In reply to#1587547
Hi,

2017-02-24 21:02 GMT+09:00 Roger Quadros <rogerq@ti.com>:
> +Chanwoo
>
> Hi Vivek,
>
> On 23/02/17 10:34, Vivek Gautam wrote:
>>
>>
>> On 02/16/2017 06:36 PM, Roger Quadros wrote:
>>> dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
>>> when we're operating in dual-role.
>>>
>>> We work around that by bypassing the OTG core and reading the
>>> extcon framework directly for ID/VBUS events.
>>>
>>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>>> ---
>>>   Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>>   drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
>>>   drivers/usb/dwc3/core.h                        |   5 +
>>>   3 files changed, 170 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> index e3e6983..9955c0d 100644
>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> @@ -53,6 +53,8 @@ Optional properties:
>>>    - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
>>>       register for post-silicon frame length adjustment when the
>>>       fladj_30mhz_sdbnd signal is invalid or incorrect.
>>> + - extcon: phandle to the USB connector extcon device. If present, extcon
>>> +    device will be used to get USB cable events instead of OTG controller.
>>>      - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
>>>   diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>>> index 619fa7c..b02d911 100644
>>> --- a/drivers/usb/dwc3/core.c
>>> +++ b/drivers/usb/dwc3/core.c
>>
>> [snip]
>>
>>> @@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
>>>         dwc3_get_properties(dwc);
>>>   +    if (dev->of_node) {
>>> +        if (of_property_read_bool(dev->of_node, "extcon"))
>>> +            dwc->edev = extcon_get_edev_by_phandle(dev, 0);
>>
>> Don't we want separate edev's for vbus and id ?
>> One can have separate pins connected to them and in that case
>> we can't get the events out of one pin only.
>
> Is such kind of hardware really there? Ideally one extcon device
> represents one connector. So VBUS and ID events of a single USB
> port should come on one extcon device.
> If it doesn't then you need to fix your platforms extcon driver
> so that it does.
> Chanwoo can correct me if I'm wrong on this understanding.
>
> Currently, if VBUS and ID come on GPIOs the extcon-usb-gpio driver
> takes care of both.

Basically, one extcon device driver can support the multiple
external connectors if the detection h/w or port is same.

One extcon device with extcon-usb-gpio.c can support the detection
of both ID and VBUS.

But, if there is any issue of h/w schematic, we need to consider
how to use the extcon device.

>
>>
>>> +
>>> +        if (IS_ERR(dwc->edev))
>>> +            return PTR_ERR(dwc->edev);
>>
>>  Took me a while to get to this. :)
>>
>>                 if (IS_ERR(dwc->edev)) {
>>                        ret = PTR_ERR(dwc->edev);
>>                        goto err0;
>>                 }
>>
>> We want to reset the res->start back to its original offset.
>>
>> Testing this series currently. Will get back with my results.
>>
>>
> Thanks :)
>
> --
> cheers,
> -roger

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

[toc] | [prev] | [next] | [standalone]


#1588055 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromChanwoo Choi <cwchoi00@gmail.com>
Date2017-02-25 05:00 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<teBGy-1Xd-5@gated-at.bofh.it>
In reply to#1588053
2017-02-25 12:46 GMT+09:00 Chanwoo Choi <cwchoi00@gmail.com>:
> Hi,
>
> 2017-02-24 21:02 GMT+09:00 Roger Quadros <rogerq@ti.com>:
>> +Chanwoo
>>
>> Hi Vivek,
>>
>> On 23/02/17 10:34, Vivek Gautam wrote:
>>>
>>>
>>> On 02/16/2017 06:36 PM, Roger Quadros wrote:
>>>> dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
>>>> when we're operating in dual-role.
>>>>
>>>> We work around that by bypassing the OTG core and reading the
>>>> extcon framework directly for ID/VBUS events.
>>>>
>>>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>>>> ---
>>>>   Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>>>   drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
>>>>   drivers/usb/dwc3/core.h                        |   5 +
>>>>   3 files changed, 170 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
>>>> index e3e6983..9955c0d 100644
>>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>>> @@ -53,6 +53,8 @@ Optional properties:
>>>>    - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
>>>>       register for post-silicon frame length adjustment when the
>>>>       fladj_30mhz_sdbnd signal is invalid or incorrect.
>>>> + - extcon: phandle to the USB connector extcon device. If present, extcon
>>>> +    device will be used to get USB cable events instead of OTG controller.
>>>>      - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
>>>>   diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>>>> index 619fa7c..b02d911 100644
>>>> --- a/drivers/usb/dwc3/core.c
>>>> +++ b/drivers/usb/dwc3/core.c
>>>
>>> [snip]
>>>
>>>> @@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
>>>>         dwc3_get_properties(dwc);
>>>>   +    if (dev->of_node) {
>>>> +        if (of_property_read_bool(dev->of_node, "extcon"))
>>>> +            dwc->edev = extcon_get_edev_by_phandle(dev, 0);
>>>
>>> Don't we want separate edev's for vbus and id ?
>>> One can have separate pins connected to them and in that case
>>> we can't get the events out of one pin only.
>>
>> Is such kind of hardware really there? Ideally one extcon device
>> represents one connector. So VBUS and ID events of a single USB
>> port should come on one extcon device.
>> If it doesn't then you need to fix your platforms extcon driver
>> so that it does.
>> Chanwoo can correct me if I'm wrong on this understanding.
>>
>> Currently, if VBUS and ID come on GPIOs the extcon-usb-gpio driver
>> takes care of both.
>
> Basically, one extcon device driver can support the multiple
> external connectors if the detection h/w or port is same.
>
> One extcon device with extcon-usb-gpio.c can support the detection
> of both ID and VBUS.
>
> But, if there is any issue of h/w schematic, we need to consider
> how to use the extcon device.

Additionally, the extcon-usb-gpio.c use the two gpio pins
to detect both ID and VBUS pins. We can check it on documentation[1]
of extcon-usb-gpio driver.

[1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/tree/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

[toc] | [prev] | [next] | [standalone]


#1589485 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromVivek Gautam <vivek.gautam@codeaurora.org>
Date2017-02-28 15:10 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<tfQDv-5uI-5@gated-at.bofh.it>
In reply to#1588055
On Sat, Feb 25, 2017 at 9:20 AM, Chanwoo Choi <cwchoi00@gmail.com> wrote:
> 2017-02-25 12:46 GMT+09:00 Chanwoo Choi <cwchoi00@gmail.com>:
>> Hi,
>>
>> 2017-02-24 21:02 GMT+09:00 Roger Quadros <rogerq@ti.com>:
>>> +Chanwoo
>>>
>>> Hi Vivek,
>>>
>>> On 23/02/17 10:34, Vivek Gautam wrote:
>>>>
>>>>
>>>> On 02/16/2017 06:36 PM, Roger Quadros wrote:
>>>>> dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
>>>>> when we're operating in dual-role.
>>>>>
>>>>> We work around that by bypassing the OTG core and reading the
>>>>> extcon framework directly for ID/VBUS events.
>>>>>
>>>>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>>>>> ---
>>>>>   Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>>>>   drivers/usb/dwc3/core.c                        | 169 ++++++++++++++++++++++++-
>>>>>   drivers/usb/dwc3/core.h                        |   5 +
>>>>>   3 files changed, 170 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
>>>>> index e3e6983..9955c0d 100644
>>>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>>>> @@ -53,6 +53,8 @@ Optional properties:
>>>>>    - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
>>>>>       register for post-silicon frame length adjustment when the
>>>>>       fladj_30mhz_sdbnd signal is invalid or incorrect.
>>>>> + - extcon: phandle to the USB connector extcon device. If present, extcon
>>>>> +    device will be used to get USB cable events instead of OTG controller.
>>>>>      - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
>>>>>   diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>>>>> index 619fa7c..b02d911 100644
>>>>> --- a/drivers/usb/dwc3/core.c
>>>>> +++ b/drivers/usb/dwc3/core.c
>>>>
>>>> [snip]
>>>>
>>>>> @@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
>>>>>         dwc3_get_properties(dwc);
>>>>>   +    if (dev->of_node) {
>>>>> +        if (of_property_read_bool(dev->of_node, "extcon"))
>>>>> +            dwc->edev = extcon_get_edev_by_phandle(dev, 0);
>>>>
>>>> Don't we want separate edev's for vbus and id ?
>>>> One can have separate pins connected to them and in that case
>>>> we can't get the events out of one pin only.
>>>
>>> Is such kind of hardware really there? Ideally one extcon device
>>> represents one connector. So VBUS and ID events of a single USB
>>> port should come on one extcon device.
>>> If it doesn't then you need to fix your platforms extcon driver
>>> so that it does.

Right, i see it now. One edev for one connector.

>>> Chanwoo can correct me if I'm wrong on this understanding.
>>>
>>> Currently, if VBUS and ID come on GPIOs the extcon-usb-gpio driver
>>> takes care of both.
>>
>> Basically, one extcon device driver can support the multiple
>> external connectors if the detection h/w or port is same.
>>
>> One extcon device with extcon-usb-gpio.c can support the detection
>> of both ID and VBUS.
>>
>> But, if there is any issue of h/w schematic, we need to consider
>> how to use the extcon device.
>
> Additionally, the extcon-usb-gpio.c use the two gpio pins
> to detect both ID and VBUS pins. We can check it on documentation[1]
> of extcon-usb-gpio driver.
>
> [1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/tree/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt

Thanks Chanwoo, i understand it now. The extcon-usb-gpio supports
both vbus and id gpio, and updates the state of the edev likewise.

>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


regards
Vivek
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1588052 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromChanwoo Choi <cwchoi00@gmail.com>
Date2017-02-25 04:40 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<teBnb-1Oq-1@gated-at.bofh.it>
In reply to#1582560
Hi Roger,

[snip]

>  /* dwc->lock must be held */
>  static void dwc3_otg_core_exit(struct dwc3 *dwc)
>  {
> +       if (dwc->edev)
> +               return;
> +
>         /* disable all otg irqs */
>         dwc3_otg_disable_events(dwc, DWC3_OTG_ALL_EVENTS);
>         /* clear all events */
> @@ -1286,6 +1364,57 @@ static int dwc3_drd_init(struct dwc3 *dwc)
>
>         INIT_WORK(&dwc->otg_work, dwc3_drd_work);
>
> +       /* If extcon device is present we don't rely on OTG core for ID event */
> +       if (dwc->edev) {
> +               int id, vbus;
> +
> +               dwc->edev_nb.notifier_call = dwc3_drd_notifier;
> +               ret = extcon_register_notifier(dwc->edev, EXTCON_USB,
> +                                              &dwc->edev_nb);

I recommend that you better to use the devm_extcon_register_notifier()

> +               if (ret < 0) {
> +                       dev_err(dwc->dev, "Couldn't register USB cable notifier\n");
> +                       return -ENODEV;
> +               }
> +
> +               ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
> +                                              &dwc->edev_nb);

Ditto.

[snip]

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

[toc] | [prev] | [next] | [standalone]


#1589549 — Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

FromRoger Quadros <rogerq@ti.com>
Date2017-02-28 16:20 +0100
SubjectRe: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode
Message-ID<tfRJf-6ds-11@gated-at.bofh.it>
In reply to#1588052
On 25/02/17 05:35, Chanwoo Choi wrote:
> Hi Roger,
> 
> [snip]
> 
>>  /* dwc->lock must be held */
>>  static void dwc3_otg_core_exit(struct dwc3 *dwc)
>>  {
>> +       if (dwc->edev)
>> +               return;
>> +
>>         /* disable all otg irqs */
>>         dwc3_otg_disable_events(dwc, DWC3_OTG_ALL_EVENTS);
>>         /* clear all events */
>> @@ -1286,6 +1364,57 @@ static int dwc3_drd_init(struct dwc3 *dwc)
>>
>>         INIT_WORK(&dwc->otg_work, dwc3_drd_work);
>>
>> +       /* If extcon device is present we don't rely on OTG core for ID event */
>> +       if (dwc->edev) {
>> +               int id, vbus;
>> +
>> +               dwc->edev_nb.notifier_call = dwc3_drd_notifier;
>> +               ret = extcon_register_notifier(dwc->edev, EXTCON_USB,
>> +                                              &dwc->edev_nb);
> 
> I recommend that you better to use the devm_extcon_register_notifier()

Got it.

> 
>> +               if (ret < 0) {
>> +                       dev_err(dwc->dev, "Couldn't register USB cable notifier\n");
>> +                       return -ENODEV;
>> +               }
>> +
>> +               ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
>> +                                              &dwc->edev_nb);
> 
> Ditto.
> 
> [snip]
> 

-- 
cheers,
-roger

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web