devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Prisk <linux@prisktech.co.nz>
To: Hans de Goede <hdegoede@redhat.com>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: devicetree <devicetree@vger.kernel.org>,
	linux-sunxi@googlegroups.com,
	linux-usb <linux-usb@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 1/2] ohci-platform: Add support for devicetree instantiation
Date: Sat, 11 Jan 2014 21:37:40 +1300	[thread overview]
Message-ID: <52D102D4.4090302@prisktech.co.nz> (raw)
In-Reply-To: <1389393980-21183-2-git-send-email-hdegoede@redhat.com>

On 11/01/14 11:46, Hans de Goede wrote:
> Add support for ohci-platform instantiation from devicetree, including
> optionally getting clks and a phy from devicetree, and enabling / disabling
> those on power_on / off.
>
> This should allow using ohci-platform from devicetree in various cases.
> Specifically after this commit it can be used for the ohci controller found
> on Allwinner sunxi SoCs.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>   .../devicetree/bindings/usb/mmio-ohci.txt          |  22 +++
>   drivers/usb/host/ohci-platform.c                   | 164 ++++++++++++++++++---
>   2 files changed, 162 insertions(+), 24 deletions(-)
>   create mode 100644 Documentation/devicetree/bindings/usb/mmio-ohci.txt
>
> diff --git a/Documentation/devicetree/bindings/usb/mmio-ohci.txt b/Documentation/devicetree/bindings/usb/mmio-ohci.txt
> new file mode 100644
> index 0000000..9c776ed
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/mmio-ohci.txt
> @@ -0,0 +1,22 @@
> +Generic MMIO OHCI controller
> +
> +Required properties:
> +- compatible : "mmio-ohci"
> +- reg : ohci controller register range (address and length)
> +- interrupts : ohci controller interrupt
> +
> +Optional properties:
> +- clocks : a list of phandle + clock specifier pairs
> +- phys : phandle + phy specifier pair
> +- phy-names : "usb"
> +
> +Example:
> +
> +	ohci0: ohci@0x01c14400 {
> +		compatible = "mmio-ohci";
> +		reg = <0x01c14400 0x100>;
> +		interrupts = <64>;
> +		clocks = <&usb_clk 6>, <&ahb_gates 2>;
> +		phys = <&usbphy 1>;
> +		phy-names = "usb";
> +	};
>
> ... <snip> ....
>
> @@ -83,17 +156,40 @@ static int ohci_platform_probe(struct platform_device *dev)
>   		return -ENXIO;
>   	}
>   
> +	hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
> +			dev_name(&dev->dev));
> +	if (!hcd)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(dev, hcd);
> +	dev->dev.platform_data = pdata;
> +	priv = hcd_to_ohci_priv(hcd);
> +
> +	if (pdata == &ohci_platform_defaults && dev->dev.of_node) {
> +		priv->phy = devm_phy_get(&dev->dev, "usb");
> +		if (IS_ERR(priv->phy)) {
> +			err = PTR_ERR(priv->phy);
> +			if (err == -EPROBE_DEFER)
> +				goto err_put_hcd;
> +			priv->phy = NULL;
> +		}
> +
> +		for (clk = 0; clk < OHCI_MAX_CLKS; clk++) {
> +			priv->clks[clk] = of_clk_get(dev->dev.of_node, clk);
> +			if (IS_ERR(priv->clks[clk])) {
> +				err = PTR_ERR(priv->clks[clk]);
> +				if (err == -EPROBE_DEFER)
> +					goto err_put_clks;
> +				priv->clks[clk] = NULL;
> +				break;
> +			}
> +		}
> +	}
>

Given that you have limited the clock parsing to OHCI_MAX_CLKS, there 
should be some kind of warning/error message if the DT contains more 
than OHCI_MAX_CLKS - otherwise you have silent failures when the clocks 
aren't configured.

There is also no note in the binding to indicate this limitation and you 
shouldn't expect people writing DT files to go digging through the 
source to check for this.

Regards
Tony P

  reply	other threads:[~2014-01-11  8:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10 22:46 [PATCH v4 0/2] ohci and ehci-platform clks, phy and dt support Hans de Goede
     [not found] ` <1389393980-21183-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-10 22:46   ` [PATCH v4 1/2] ohci-platform: Add support for devicetree instantiation Hans de Goede
2014-01-11  8:37     ` Tony Prisk [this message]
     [not found]       ` <52D102D4.4090302-ci5G2KO2hbZ+pU9mqzGVBQ@public.gmane.org>
2014-01-12  9:17         ` Hans de Goede
2014-01-10 22:46   ` [PATCH v4 2/2] ehci-platform: Add support for clks and phy passed through devicetree Hans de Goede
2014-01-10 23:50   ` [PATCH v4 0/2] ohci and ehci-platform clks, phy and dt support Sergei Shtylyov
     [not found]     ` <52D0875B.9040102-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2014-01-10 22:52       ` Hans de Goede
2014-01-10 23:08         ` Bjørn Mork
     [not found]           ` <878uun1llt.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2014-01-11  0:19             ` Sergei Shtylyov
2014-01-10 23:45               ` Bjørn Mork
     [not found]         ` <52D0799B.3030401-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-11  0:10           ` Sergei Shtylyov
     [not found]             ` <52D08BF8.9090709-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2014-01-10 23:24               ` Hans de Goede
     [not found]                 ` <52D08122.606-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-11  1:03                   ` Sergei Shtylyov
2014-01-11 22:30           ` Alan Stern
     [not found]             ` <Pine.LNX.4.44L0.1401111728150.16586-100000-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org>
2014-01-12  3:04               ` Tony Prisk
     [not found]                 ` <52D2064B.3010103-ci5G2KO2hbZ+pU9mqzGVBQ@public.gmane.org>
2014-01-12 13:04                   ` Tomasz Figa
     [not found]                     ` <52D292DA.8010709-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-13 15:54                       ` Hans de Goede
     [not found]                         ` <52D40C42.2050408-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-01-13 16:06                           ` Alan Stern

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=52D102D4.4090302@prisktech.co.nz \
    --to=linux@prisktech.co.nz \
    --cc=devicetree@vger.kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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).