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


Groups > linux.kernel > #1410913 > unrolled thread

[PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree

Started byKrzysztof Kozlowski <k.kozlowski@samsung.com>
First post2016-06-01 10:10 +0200
Last post2016-06-02 03:40 +0200
Articles 6 — 3 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 v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from  Device Tree Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-06-01 10:10 +0200
    Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from  Device Tree Stephen Boyd <stephen.boyd@linaro.org> - 2016-06-01 11:00 +0200
      Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle  from Device Tree Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-06-01 11:10 +0200
      Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle  from Device Tree Peter Chen <hzpeterchen@gmail.com> - 2016-06-01 14:20 +0200
        Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from  Device Tree Stephen Boyd <stephen.boyd@linaro.org> - 2016-06-01 20:20 +0200
          Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle  from Device Tree Peter Chen <hzpeterchen@gmail.com> - 2016-06-02 03:40 +0200

#1410913 — [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree

FromKrzysztof Kozlowski <k.kozlowski@samsung.com>
Date2016-06-01 10:10 +0200
Subject[PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
Message-ID<rF9nX-5Ug-15@gated-at.bofh.it>
Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
device.  The pwrseq device will be used by USB hub to cycle the power
before activating ports.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/usb/core/hub.h  |  3 +++
 drivers/usb/core/port.c | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 34c1a7e22aae..68ca89780d26 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -24,6 +24,8 @@
 #include <linux/usb/hcd.h>
 #include "usb.h"
 
+struct pwrseq;
+
 struct usb_hub {
 	struct device		*intfdev;	/* the "interface" device */
 	struct usb_device	*hdev;
@@ -101,6 +103,7 @@ struct usb_port {
 	struct usb_dev_state *port_owner;
 	struct usb_port *peer;
 	struct dev_pm_qos_request *req;
+	struct pwrseq *pwrseq;
 	enum usb_port_connect_type connect_type;
 	usb_port_location_t location;
 	struct mutex status_lock;
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 460c855be0d0..89b9bdfc7061 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -18,6 +18,8 @@
 
 #include <linux/slab.h>
 #include <linux/pm_qos.h>
+#include <linux/pwrseq.h>
+#include <linux/usb/of.h>
 
 #include "hub.h"
 
@@ -526,6 +528,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
 		return retval;
 	}
 
+	port_dev->dev.of_node = usb_of_get_child_node(hdev->dev.parent->of_node,
+						      port1);
+	port_dev->pwrseq = pwrseq_alloc(&port_dev->dev, "usb-pwrseq");
+	if (IS_ERR(port_dev->pwrseq)) {
+		device_unregister(&port_dev->dev);
+		return PTR_ERR(port_dev->pwrseq);
+	}
+
 	find_and_link_peer(hub, port1);
 
 	/*
@@ -567,8 +577,13 @@ void usb_hub_remove_port_device(struct usb_hub *hub, int port1)
 	struct usb_port *port_dev = hub->ports[port1 - 1];
 	struct usb_port *peer;
 
+	pwrseq_power_off(port_dev->pwrseq);
+
 	peer = port_dev->peer;
 	if (peer)
 		unlink_peers(port_dev, peer);
+
+	pwrseq_free(port_dev->pwrseq);
+	port_dev->pwrseq = NULL;
 	device_unregister(&port_dev->dev);
 }
-- 
1.9.1

[toc] | [next] | [standalone]


#1410996

FromStephen Boyd <stephen.boyd@linaro.org>
Date2016-06-01 11:00 +0200
Message-ID<rFaan-6aY-43@gated-at.bofh.it>
In reply to#1410913
Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> device.  The pwrseq device will be used by USB hub to cycle the power
> before activating ports.
> 
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Drive by review comment.

I was hoping this would help me with a problem I'm having where I have a
hub (smsc4604) that needs to be taken out of reset before my HSIC
controller sends a USB reset to it, but it seems this is more about
doing some sort of power on sequence after enumeration?

> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index 460c855be0d0..89b9bdfc7061 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -18,6 +18,8 @@
>  
>  #include <linux/slab.h>
>  #include <linux/pm_qos.h>
> +#include <linux/pwrseq.h>
> +#include <linux/usb/of.h>
>  
>  #include "hub.h"
>  
> @@ -526,6 +528,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
>                 return retval;
>         }
>  
> +       port_dev->dev.of_node = usb_of_get_child_node(hdev->dev.parent->of_node,
> +                                                     port1);
> +       port_dev->pwrseq = pwrseq_alloc(&port_dev->dev, "usb-pwrseq");
> +       if (IS_ERR(port_dev->pwrseq)) {
> +               device_unregister(&port_dev->dev);
> +               return PTR_ERR(port_dev->pwrseq);

Are we certain that port_dev hasn't been freed at this point? We just
called device_unregister() on it, so it seems safer to save away the
return value before calling device_unregister() here.

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


#1411004 — Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree

FromKrzysztof Kozlowski <k.kozlowski@samsung.com>
Date2016-06-01 11:10 +0200
SubjectRe: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
Message-ID<rFak1-6tA-11@gated-at.bofh.it>
In reply to#1410996
On 06/01/2016 10:57 AM, Stephen Boyd wrote:
> Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
>> Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
>> device.  The pwrseq device will be used by USB hub to cycle the power
>> before activating ports.
>>
>> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> 
> Drive by review comment.
> 
> I was hoping this would help me with a problem I'm having where I have a
> hub (smsc4604) that needs to be taken out of reset before my HSIC
> controller sends a USB reset to it, but it seems this is more about
> doing some sort of power on sequence after enumeration?

This example is not finished but from what you wrote, it might suit your
needs as well. The power sequence is done before enumeration because
without it, the device won't enumerate.

The exact power sequence for USB devices has to be still developed.
Comments are welcomed.

>> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
>> index 460c855be0d0..89b9bdfc7061 100644
>> --- a/drivers/usb/core/port.c
>> +++ b/drivers/usb/core/port.c
>> @@ -18,6 +18,8 @@
>>  
>>  #include <linux/slab.h>
>>  #include <linux/pm_qos.h>
>> +#include <linux/pwrseq.h>
>> +#include <linux/usb/of.h>
>>  
>>  #include "hub.h"
>>  
>> @@ -526,6 +528,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
>>                 return retval;
>>         }
>>  
>> +       port_dev->dev.of_node = usb_of_get_child_node(hdev->dev.parent->of_node,
>> +                                                     port1);
>> +       port_dev->pwrseq = pwrseq_alloc(&port_dev->dev, "usb-pwrseq");
>> +       if (IS_ERR(port_dev->pwrseq)) {
>> +               device_unregister(&port_dev->dev);
>> +               return PTR_ERR(port_dev->pwrseq);
> 
> Are we certain that port_dev hasn't been freed at this point? We just
> called device_unregister() on it, so it seems safer to save away the
> return value before calling device_unregister() here.

Right, good point. Thanks for feedback.

Best regards,
Krzysztof

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


#1411142 — Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree

FromPeter Chen <hzpeterchen@gmail.com>
Date2016-06-01 14:20 +0200
SubjectRe: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
Message-ID<rFdhT-8iE-9@gated-at.bofh.it>
In reply to#1410996
On Wed, Jun 01, 2016 at 01:57:23AM -0700, Stephen Boyd wrote:
> Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> > Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> > device.  The pwrseq device will be used by USB hub to cycle the power
> > before activating ports.
> > 
> > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> 
> Drive by review comment.
> 
> I was hoping this would help me with a problem I'm having where I have a
> hub (smsc4604) that needs to be taken out of reset before my HSIC
> controller sends a USB reset to it, but it seems this is more about
> doing some sort of power on sequence after enumeration?
> 

No, you may need to do reset before enumeration, the general purpose of
reset is eliminate unstable hardware state, and let the controller find
the device.

Try to do it at bootloader to see if it works for you.

-- 

Best Regards,
Peter Chen

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


#1411451

FromStephen Boyd <stephen.boyd@linaro.org>
Date2016-06-01 20:20 +0200
Message-ID<rFiUi-3wl-19@gated-at.bofh.it>
In reply to#1411142
Quoting Peter Chen (2016-06-01 05:05:20)
> On Wed, Jun 01, 2016 at 01:57:23AM -0700, Stephen Boyd wrote:
> > Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> > > Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> > > device.  The pwrseq device will be used by USB hub to cycle the power
> > > before activating ports.
> > > 
> > > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> > 
> > Drive by review comment.
> > 
> > I was hoping this would help me with a problem I'm having where I have a
> > hub (smsc4604) that needs to be taken out of reset before my HSIC
> > controller sends a USB reset to it, but it seems this is more about
> > doing some sort of power on sequence after enumeration?
> > 
> 
> No, you may need to do reset before enumeration, the general purpose of
> reset is eliminate unstable hardware state, and let the controller find
> the device.
> 
> Try to do it at bootloader to see if it works for you.
> 

Sorry the bootloader doesn't do this so that doesn't work for me.

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


#1411744 — Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree

FromPeter Chen <hzpeterchen@gmail.com>
Date2016-06-02 03:40 +0200
SubjectRe: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
Message-ID<rFpM5-7QO-13@gated-at.bofh.it>
In reply to#1411451
On Wed, Jun 01, 2016 at 11:16:34AM -0700, Stephen Boyd wrote:
> Quoting Peter Chen (2016-06-01 05:05:20)
> > On Wed, Jun 01, 2016 at 01:57:23AM -0700, Stephen Boyd wrote:
> > > Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> > > > Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> > > > device.  The pwrseq device will be used by USB hub to cycle the power
> > > > before activating ports.
> > > > 
> > > > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> > > 
> > > Drive by review comment.
> > > 
> > > I was hoping this would help me with a problem I'm having where I have a
> > > hub (smsc4604) that needs to be taken out of reset before my HSIC
> > > controller sends a USB reset to it, but it seems this is more about
> > > doing some sort of power on sequence after enumeration?
> > > 
> > 
> > No, you may need to do reset before enumeration, the general purpose of
> > reset is eliminate unstable hardware state, and let the controller find
> > the device.
> > 
> > Try to do it at bootloader to see if it works for you.
> > 
> 
> Sorry the bootloader doesn't do this so that doesn't work for me.

I mean try to see if the HUB can work if you reset it at bootloader.
If it works, it means you need to do reset before enumeration, and you
don't need to do anything after enumeration.

-- 

Best Regards,
Peter Chen

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web