From: Peter Chen <hzpeterchen@gmail.com>
To: Rob Herring <robh@kernel.org>
Cc: "Peter Chen" <peter.chen@nxp.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Alan Stern" <stern@rowland.harvard.edu>,
"Ulf Hansson" <ulf.hansson@linaro.org>,
"Mark Brown" <broonie@kernel.org>,
"Sebastian Reichel" <sre@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"Krzysztof Kozłowski" <k.kozlowski@samsung.com>,
"Stephen Boyd" <stephen.boyd@linaro.org>,
oscar@naiandei.net, "Arnd Bergmann" <arnd@arndb.de>,
"Pawel Moll" <pawel.moll@arm.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Linux USB List" <linux-usb@vger.kernel.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
"Maciej S. Szmigiero" <mail@maciej.szmigiero.name>,
troy.kisky@boundarydevices.com,
"Javier Martinez Canillas" <javier@osg.samsung.com>,
"Philipp Zabel" <p.zabel@pengutronix.>
Subject: Re: [PATCH 08/12] doc: binding: pwrseq-usb-generic: add binding doc for generic usb power sequence driver
Date: Tue, 21 Jun 2016 10:11:17 +0800 [thread overview]
Message-ID: <20160621021117.GD26936@shlinux2> (raw)
In-Reply-To: <20160620161607.GA11427@rob-hp-laptop>
On Mon, Jun 20, 2016 at 11:16:07AM -0500, Rob Herring wrote:
> On Mon, Jun 20, 2016 at 07:26:51PM +0800, Peter Chen wrote:
> > On Fri, Jun 17, 2016 at 12:16:48PM -0500, Rob Herring wrote:
> > > On Fri, Jun 17, 2016 at 5:09 AM, Peter Chen <peter.chen@nxp.com> wrote:
> > > > Add binding doc for generic usb power sequence driver, and update
> > > > generic usb device binding-doc accordingly.
> > > >
> > > > Signed-off-by: Peter Chen <peter.chen@nxp.com>
> > > > ---
> > > > .../bindings/power/pwrseq/pwrseq-usb-generic.txt | 31 ++++++++++++++++++++++
> > > > .../devicetree/bindings/usb/usb-device.txt | 2 ++
> > > > 2 files changed, 33 insertions(+)
> > > > create mode 100644 Documentation/devicetree/bindings/power/pwrseq/pwrseq-usb-generic.txt
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-usb-generic.txt b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-usb-generic.txt
> > > > new file mode 100644
> > > > index 0000000..8ad98382
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-usb-generic.txt
> > > > @@ -0,0 +1,31 @@
> > > > +The power sequence for generic USB Devices
> > > > +
> > > > +Some hard-wired USB devices need to do power sequence to let the
> > > > +device work normally, the typical power sequence like: enable USB
> > > > +PHY clock, toggle reset pin, etc. But current Linux USB driver
> > > > +lacks of such code to do it, it may cause some hard-wired USB devices
> > > > +works abnormal or can't be recognized by controller at all. The
> > > > +power sequence will be done before this device can be found at USB
> > > > +bus.
> > > > +
> > > > +Required properties:
> > > > +- compatible : contains "usb-pwrseq-generic".
> > >
> > > In case I have not been clear, no.
> > >
> > > I am not going to accept anything along the lines of the current mmc
> > > pwrseq. I am basically okay with Krzysztof's proposal as it is *only*
> > > an added property and not a duplication of information. I'd suggest
> > > you figure out how to make the kernel work with that rather than
> > > trying to work-around whatever kernel limitations there are.
> > >
> >
> > I see.
> >
> > Would you agree with below:
>
> In general, yes. There are some points being discussed in the other
> thread.
>
> > &usbotg1 {
> > vbus-supply = <®_usb_otg1_vbus>;
> > pinctrl-names = "default";
> > pinctrl-0 = <&pinctrl_usb_otg1_id>;
> > status = "okay";
> >
> > #address-cells = <1>;
> > #size-cells = <0>;
> > hub: genesys@1 {
> > compatible = "usb5e3,608";
> > reg = <1>;
> >
> > power-sequence;
> > reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */
> > reset-duration-us = <10>;
>
> I wonder if this really needs to be specified. A sufficiently long
> default should be good enough for 90 something % of devices.
>
This property is optional, there is a default value in pwrseq driver.
> > clocks = <&clks IMX6SX_CLK_CKO>;
> >
> > #address-cells = <1>;
> > #size-cells = <0>;
> > ethernet: asix@1 {
> > compatible = "usbb95,1708";
> > reg = <1>;
> >
> > power-sequence;
> > reset-gpios = <&gpio4 6 GPIO_ACTIVE_LOW>; /* ethernet_rst */
> > reset-duration-us = <15>;
> > clocks = <&clks IMX6SX_CLK_IPG>;
> > };
> > };
> > };
> >
> > If the node has property "power-sequence", the pwrseq core will create
> > related platform device, and the driver under pwrseq driver will handle
> > power sequence stuffs.
>
> This I have issue with. If you are creating a platform device here, you
> are trying to work-around limitations in the linux driver model.
My current solution like below, but it seems you didn't agree with that.
I just double confirm here, if you don't, I give up the solution for
using generic power sequence framework.
In drivers/usb/core/hub.c
for_each_child_of_node(parent->of_node, node) {
hdev_pwrseq = pwrseq_alloc(node, "usb_pwrseq_generic");
if (!IS_ERR_OR_NULL(hdev_pwrseq)) {
pwrseq_node = kzalloc(sizeof(pwrseq_node), GFP_KERNEL);
if (!pwrseq_node) {
ret = -ENOMEM;
goto err1;
}
/* power on sequence */
ret = pwrseq_pre_power_on(hdev_pwrseq);
if (ret)
goto err2;
pwrseq_node->pwrseq_on = hdev_pwrseq;
list_add(&pwrseq_node->list, &hub->pwrseq_list);
} else if (IS_ERR(hdev_pwrseq)) {
return PTR_ERR(hdev_pwrseq);
}
}
In drivers/power/pwrseq/core.c
struct pwrseq *pwrseq_alloc(struct device_node *np, const char *dev_name)
{
struct pwrseq *p, *pwrseq = NULL;
bool created;
/* If there is no device is associated with this node, create it */
if (!of_find_device_by_node(np)) {
if (of_platform_device_create(np, dev_name, NULL))
created = true;
else
return ERR_PTR(-ENODEV);
}
mutex_lock(&pwrseq_list_mutex);
list_for_each_entry(p, &pwrseq_list, pwrseq_node) {
if (p->dev->of_node == np) {
if (!try_module_get(p->owner))
dev_err(p->dev,
"increasing module refcount failed\n");
else
pwrseq = p;
break;
}
}
And there is a platform driver at drivers/power/pwrseq/pwrseq_usb_generic.c
to handle these pwrseq properties, see my patch 9/12.
> Either
> we need some sort of pre-probe hook to the drivers to call or each
> parent node driver is responsible for checking and calling pwr-seq
> functions for child nodes. e.g. The host controller calls pwr-seq for
> the hub, the hub driver calls the power seq for the asix chip. Soon as
> we have a case too complex for the generic pwr-seq, we're going to need
> the pre-probe hook as I don't want to see a continual expansion of
> generic pwr-seq binding for ever more complex cases.
>
How the driver know what it needs to handle (eg, gpio, clock) if there
is no device for it? The most important we need to consider is which
device owns there power sequence properties, then the corresponding
driver can handle it.
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2016-06-21 2:11 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 10:09 [PATCH 00/12] power: add generic power sequence framework Peter Chen
2016-06-17 10:09 ` [PATCH 01/12] power/mmc: Move pwrseq drivers to power/pwrseq Peter Chen
2016-06-17 10:09 ` [PATCH 02/12] MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq Peter Chen
2016-06-17 10:09 ` [PATCH 03/12] power: pwrseq: Enable COMPILE_TEST for drivers Peter Chen
2016-06-17 10:09 ` [PATCH 05/12] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Peter Chen
2016-06-17 10:09 ` [PATCH 06/12] power: pwrseq: change common helpers as generic Peter Chen
2016-06-17 10:09 ` [PATCH 07/12] power: pwrseq: rename file name for generic driver Peter Chen
2016-06-20 12:48 ` Krzysztof Kozlowski
2016-06-21 2:19 ` Peter Chen
[not found] ` <1466158165-9380-1-git-send-email-peter.chen-3arQi8VN3Tc@public.gmane.org>
2016-06-17 10:09 ` [PATCH 04/12] power: pwrseq: Remove mmc prefix from mmc_pwrseq Peter Chen
2016-06-17 10:09 ` [PATCH 08/12] doc: binding: pwrseq-usb-generic: add binding doc for generic usb power sequence driver Peter Chen
2016-06-17 17:16 ` Rob Herring
2016-06-20 11:26 ` Peter Chen
2016-06-20 12:29 ` Chen-Yu Tsai
2016-06-21 2:14 ` Peter Chen
2016-06-20 16:16 ` Rob Herring
2016-06-20 17:06 ` Mark Brown
2016-06-21 2:11 ` Peter Chen [this message]
2016-06-21 21:26 ` Rob Herring
2016-06-22 1:14 ` Peter Chen
2016-06-22 9:09 ` Ulf Hansson
2016-06-24 15:25 ` Rob Herring
2016-06-17 10:09 ` [PATCH 10/12] usb: core: add power sequence handling for USB devices Peter Chen
[not found] ` <1466158165-9380-11-git-send-email-peter.chen-3arQi8VN3Tc@public.gmane.org>
2016-06-17 16:12 ` Alan Stern
2016-06-17 10:09 ` [PATCH 12/12] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property Peter Chen
2016-06-17 10:09 ` [PATCH 09/12] power: pwrseq: pwrseq_usb_generic: add generic power sequence support for USB deivces Peter Chen
2016-06-17 10:09 ` [PATCH 11/12] usb: chipidea: host: let the hcd know's parent device node Peter Chen
2016-06-17 23:29 ` [PATCH 00/12] power: add generic power sequence framework Maciej S. Szmigiero
2016-06-20 11:27 ` Peter Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160621021117.GD26936@shlinux2 \
--to=hzpeterchen@gmail.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=javier@osg.samsung.com \
--cc=k.kozlowski@samsung.com \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mail@maciej.szmigiero.name \
--cc=mark.rutland@arm.com \
--cc=oscar@naiandei.net \
--cc=p.zabel@pengutronix. \
--cc=pawel.moll@arm.com \
--cc=peter.chen@nxp.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sre@kernel.org \
--cc=stephen.boyd@linaro.org \
--cc=stern@rowland.harvard.edu \
--cc=troy.kisky@boundarydevices.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).