From: rogerq@ti•com (Roger Quadros)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 01/13] usb: phy: nop: Add device tree support and binding information
Date: Tue, 12 Mar 2013 11:09:24 +0200 [thread overview]
Message-ID: <513EF0C4.9080402@ti.com> (raw)
In-Reply-To: <513DFDD7.7000801@pengutronix.de>
On 03/11/2013 05:52 PM, Marc Kleine-Budde wrote:
> On 02/05/2013 08:26 AM, Felipe Balbi wrote:
>> Hi,
>>
>> On Mon, Feb 04, 2013 at 05:58:48PM +0200, Roger Quadros wrote:
>>> The PHY clock, clock rate, VCC regulator and RESET regulator
>>> can now be provided via device tree.
>>>
>>> Signed-off-by: Roger Quadros <rogerq@ti•com>
>>> ---
>>> .../devicetree/bindings/usb/usb-nop-xceiv.txt | 34 ++++++++++++++++++++
>>> drivers/usb/otg/nop-usb-xceiv.c | 31 ++++++++++++++++++
>>> 2 files changed, 65 insertions(+), 0 deletions(-)
>>> create mode 100644 Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
>>> new file mode 100644
>>> index 0000000..d7e2726
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
>>> @@ -0,0 +1,34 @@
>>> +USB NOP PHY
>>> +
>>> +Required properties:
>>> +- compatible: should be usb-nop-xceiv
>>> +
>>> +Optional properties:
>>> +- clocks: phandle to the PHY clock. Use as per Documentation/devicetree
>>> + /bindings/clock/clock-bindings.txt
>>> + This property is required if clock-frequency is specified.
>>> +
>>> +- clock-names: Should be "main_clk"
>>> +
>>> +- clock-frequency: the clock frequency (in Hz) that the PHY clock must
>>> + be configured to.
>>> +
>>> +- vcc-supply: phandle to the regulator that provides RESET to the PHY.
>>> +
>>> +- reset-supply: phandle to the regulator that provides power to the PHY.
>>> +
>>> +Example:
>>> +
>>> + hsusb1_phy {
>>> + compatible = "usb-nop-xceiv";
>>> + clock-frequency = <19200000>;
>>> + clocks = <&osc 0>;
>>> + clock-names = "main_clk";
>>> + vcc-supply = <&hsusb1_vcc_regulator>;
>>> + reset-supply = <&hsusb1_reset_regulator>;
>>> + };
>>> +
>>> +hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator
>>> +and expects that clock to be configured to 19.2MHz by the NOP PHY driver.
>>> +hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator
>>> +controls RESET.
>>> diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
>>> index ac027a1..adbb7ab 100644
>>> --- a/drivers/usb/otg/nop-usb-xceiv.c
>>> +++ b/drivers/usb/otg/nop-usb-xceiv.c
>>> @@ -34,6 +34,7 @@
>>> #include <linux/slab.h>
>>> #include <linux/clk.h>
>>> #include <linux/regulator/consumer.h>
>>> +#include <linux/of.h>
>>>
>>> struct nop_usb_xceiv {
>>> struct usb_phy phy;
>>> @@ -138,8 +139,19 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
>>> return 0;
>>> }
>>>
>>> +static void nop_xeiv_get_dt_pdata(struct device *dev,
>>
>> asking to remove, but xeiv != xceiv :-)
>>
>>> + struct nop_usb_xceiv_platform_data *pdata)
>>> +{
>>> + struct device_node *node = dev->of_node;
>>> + u32 clk_rate;
>>> +
>>> + if (!of_property_read_u32(node, "clock-frequency", &clk_rate))
>>> + pdata->clk_rate = clk_rate;
>>> +}
>>> +
>>> static int nop_usb_xceiv_probe(struct platform_device *pdev)
>>> {
>>> + struct device *dev = &pdev->dev;
>>> struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data;
>>> struct nop_usb_xceiv *nop;
>>> enum usb_phy_type type = USB_PHY_TYPE_USB2;
>>> @@ -153,6 +165,17 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
>>> if (!nop->phy.otg)
>>> return -ENOMEM;
>>>
>>> + if (dev->of_node) {
>>> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>>> + if (!pdata) {
>>> + dev_err(dev, "Memory allocation failure\n");
>>> + return -ENOMEM;
>>> + }
>>> + nop_xeiv_get_dt_pdata(dev, pdata);
>>
>> actually, I would prefer to not create pdata at all. I mean, ideally
>> pdata would be used to initialize fields in your own structure, so first
>> move clk_rate to your own private structure, copy pdata's clk_rate value
>> to that, then you don't need this hackery when using DT.
>
> As far as I can see, clk_rate is never used, but in the probe function.
> Why should it be saved into the private data structure at all?
>
Yes you are right. I'll fix it up.
Thanks.
cheers,
-roger
next prev parent reply other threads:[~2013-03-12 9:09 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-04 15:58 [PATCH 00/13] Device tree support for OMAP HS USB Host Roger Quadros
2013-02-04 15:58 ` [PATCH 01/13] usb: phy: nop: Add device tree support and binding information Roger Quadros
2013-02-05 7:26 ` Felipe Balbi
2013-02-05 8:30 ` Roger Quadros
2013-02-05 9:07 ` Felipe Balbi
2013-03-11 15:52 ` Marc Kleine-Budde
2013-03-12 9:09 ` Roger Quadros [this message]
2013-03-08 10:46 ` Marc Kleine-Budde
2013-03-08 15:04 ` Roger Quadros
2013-03-08 15:45 ` Marc Kleine-Budde
2013-03-11 8:40 ` Roger Quadros
2013-03-11 15:53 ` Marc Kleine-Budde
2013-02-04 15:58 ` [PATCH 02/13] USB: phy: nop: Defer probe if device needs VCC/RESET Roger Quadros
2013-02-05 5:54 ` kishon
2013-02-05 8:44 ` Roger Quadros
2013-02-05 9:09 ` Felipe Balbi
2013-02-05 9:43 ` Roger Quadros
2013-03-11 15:58 ` Marc Kleine-Budde
2013-03-12 9:10 ` Roger Quadros
2013-02-04 15:58 ` [PATCH 03/13] mfd: omap-usb-tll: move configuration code to omap_tll_init() Roger Quadros
2013-02-04 15:58 ` [PATCH 04/13] mfd: omap-usb-tll: Add device tree support Roger Quadros
2013-02-05 6:04 ` kishon
2013-02-05 8:46 ` Roger Quadros
2013-02-04 15:58 ` [PATCH 05/13] USB: ehci-omap: Get platform resources by index rather than by name Roger Quadros
2013-02-04 21:12 ` Alan Stern
2013-02-04 15:58 ` [PATCH 06/13] USB: ohci-omap3: " Roger Quadros
2013-02-04 21:12 ` Alan Stern
2013-02-04 15:58 ` [PATCH 07/13] USB: ohci-omap3: Add device tree support and binding information Roger Quadros
2013-02-04 21:14 ` Alan Stern
2013-02-04 15:58 ` [PATCH 08/13] USB: ehci-omap: " Roger Quadros
2013-02-04 21:15 ` Alan Stern
2013-02-05 12:33 ` Mark Rutland
2013-02-05 12:46 ` Roger Quadros
2013-02-04 15:58 ` [PATCH 09/13] mfd: omap-usb-host: " Roger Quadros
2013-02-05 6:16 ` kishon
2013-02-05 8:50 ` Roger Quadros
2013-02-05 10:58 ` Roger Quadros
2013-02-05 12:11 ` kishon
2013-02-05 12:27 ` Roger Quadros
2013-02-05 14:20 ` Mark Rutland
2013-02-05 14:42 ` Roger Quadros
2013-02-05 16:11 ` Mark Rutland
2013-02-06 8:56 ` Roger Quadros
2013-02-04 15:58 ` [PATCH 10/13] ARM: dts: OMAP4: Add HS USB Host IP nodes Roger Quadros
2013-02-05 6:24 ` kishon
2013-02-05 8:54 ` Roger Quadros
2013-02-05 8:57 ` kishon
2013-02-05 7:41 ` Felipe Balbi
2013-02-05 8:57 ` Roger Quadros
2013-02-04 15:58 ` [PATCH 11/13] ARM: dts: omap4-panda: Add USB Host support Roger Quadros
[not found] ` <5110D229.1000808@ti.com>
2013-02-05 11:15 ` how to specify an OMAP clock in device tree? Rajendra Nayak
2013-02-05 13:46 ` Roger Quadros
2013-02-05 14:13 ` Rajendra Nayak
2013-02-05 14:18 ` Roger Quadros
2013-02-05 14:21 ` Rajendra Nayak
2013-02-05 14:29 ` Roger Quadros
2013-02-05 14:36 ` Rajendra Nayak
2013-02-05 14:52 ` Roger Quadros
2013-02-06 10:21 ` Rajendra Nayak
2013-02-06 10:39 ` Roger Quadros
2013-02-04 15:58 ` [PATCH 12/13] ARM: dts: OMAP3: Add HS USB Host IP nodes Roger Quadros
2013-02-04 15:59 ` [PATCH 13/13] ARM: dts: omap3-beagle: Add USB Host support Roger Quadros
2013-02-05 11:25 ` [PATCH 00/13] Device tree support for OMAP HS USB Host Rajendra Nayak
2013-02-05 11:32 ` Roger Quadros
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=513EF0C4.9080402@ti.com \
--to=rogerq@ti$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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