devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
To: kishon <kishon-l0cyMroinI0@public.gmane.org>
Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org,
	b-cousson-l0cyMroinI0@public.gmane.org,
	balbi-l0cyMroinI0@public.gmane.org,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org,
	linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	rnayak-l0cyMroinI0@public.gmane.org,
	paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org,
	Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information
Date: Tue, 5 Feb 2013 10:50:45 +0200	[thread overview]
Message-ID: <5110C7E5.8030402@ti.com> (raw)
In-Reply-To: <5110A3C6.6040808-l0cyMroinI0@public.gmane.org>

On 02/05/2013 08:16 AM, kishon wrote:
> On Monday 04 February 2013 09:28 PM, Roger Quadros wrote:
>> Allows the OMAP HS USB host controller to be specified
>> via device tree.
>>
>> CC: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>> Signed-off-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
>> ---
>>   .../devicetree/bindings/mfd/omap-usb-host.txt      |   68 ++++++++++++++++
>>   drivers/mfd/omap-usb-host.c                        |   83 ++++++++++++++++++--
>>   2 files changed, 145 insertions(+), 6 deletions(-)
>>   create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mfd/omap-usb-host.txt b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
>> new file mode 100644
>> index 0000000..2196893
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mfd/omap-usb-host.txt
>> @@ -0,0 +1,68 @@
>> +OMAP HS USB Host
>> +
>> +Required properties:
>> +
>> +- compatible: should be "ti,usbhs-host"
>> +- reg: should contain one register range i.e. start and length
>> +- ti,hwmods: must contain "usb_host_hs"
>> +
>> +Optional properties:
>> +
>> +- nports: number of USB ports. Usually this is automatically detected
>> +  from the IP's revision register but can be overridden by specifying
>> +  this property.
>> +
>> +- portN_mode: Integer specifying the port mode for port N, where N can be
>> +  from 1 to nports. The port mode must be as per enum usbhs_omap_port_mode
>> +  in include/linux/platform_data/usb-omap.h
>> +  If the port mode is not specified, that port is treated as unused.
>> +
>> +- single_ulpi_bypass: Must be present if the controller contains a single
>> +  ULPI bypass control bit. e.g. OMAP3 silicon <= ES2.1
>> +
>> +Required properties if child node exists:
>> +
>> +- #address-cells: Must be 1
>> +- #size-cells: Must be 1
>> +- ranges: must be present
>> +
>> +Properties for children:
>> +
>> +The OMAP HS USB Host subsystem contains EHCI and OHCI controllers.
>> +See Documentation/devicetree/bindings/usb/omap-ehci.txt and
>> +omap3-ohci.txt
>> +
>> +Example for OMAP4:
>> +
>> +usbhshost: usbhshost@0x4a064000 {
>> +    compatible = "ti,usbhs-host";
>> +    reg = <0x4a064000 0x800>;
>> +    ti,hwmods = "usb_host_hs";
>> +    #address-cells = <1>;
>> +    #size-cells = <1>;
>> +    ranges;
>> +
>> +    usbhsohci: ohci@0x4a064800 {
>> +        compatible = "ti,omap3-ohci", "usb-ohci";
>> +        reg = <0x4a064800 0x400>;
>> +        interrupt-parent = <&gic>;
>> +        interrupts = <0 76 0x4>;
>> +    };
>> +
>> +    usbhsehci: ehci@0x4a064c00 {
>> +        compatible = "ti,omap-ehci", "usb-ehci";
>> +        reg = <0x4a064c00 0x400>;
>> +        interrupt-parent = <&gic>;
>> +        interrupts = <0 77 0x4>;
>> +    };
>> +};
>> +
>> +&usbhshost {
>> +    port1_mode = <1>; /* OMAP_EHCI_PORT_MODE_PHY */
>> +    port2_mode = <2>; /* OMAP_EHCI_PORT_MODE_TLL */
>> +    port3_mode = <1>; /* OMAP_EHCI_PORT_MODE_PHY */
>> +};
>> +
>> +&usbhsehci {
>> +    phy = <&hsusb1_phy 0 &hsusb3_phy>;
>> +};
>> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
>> index f8ed08e..0f67856 100644
>> --- a/drivers/mfd/omap-usb-host.c
>> +++ b/drivers/mfd/omap-usb-host.c
>> @@ -1,8 +1,9 @@
>>   /**
>>    * omap-usb-host.c - The USBHS core driver for OMAP EHCI & OHCI
>>    *
>> - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
>> + * Copyright (C) 2011-2013 Texas Instruments Incorporated - http://www.ti.com
>>    * Author: Keshava Munegowda <keshava_mgowda-l0cyMroinI0@public.gmane.org>
>> + * Author: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
>>    *
>>    * This program is free software: you can redistribute it and/or modify
>>    * it under the terms of the GNU General Public License version 2  of
>> @@ -27,6 +28,8 @@
>>   #include <linux/platform_device.h>
>>   #include <linux/platform_data/usb-omap.h>
>>   #include <linux/pm_runtime.h>
>> +#include <linux/of.h>
>> +#include <linux/of_platform.h>
>>
>>   #include "omap-usb.h"
>>
>> @@ -464,6 +467,37 @@ static void omap_usbhs_init(struct device *dev)
>>       pm_runtime_put_sync(dev);
>>   }
>>
>> +static int usbhs_omap_get_dt_pdata(struct device_node *node,
>> +                    struct usbhs_omap_platform_data *pdata)
>> +{
>> +    int ret, i;
>> +
>> +    ret = of_property_read_u32(node, "nports", &pdata->nports);
>> +    if (ret)
>> +        pdata->nports = 0;
>> +
>> +    /* get port modes */
>> +    for (i = 0; i < OMAP3_HS_USB_PORTS; i++) {
>> +        char prop[11];
>> +
>> +        snprintf(prop, sizeof(prop), "port%d_mode", i + 1);
>> +        ret = of_property_read_u32(node, prop, &pdata->port_mode[i]);
>> +        if (ret)
>> +            pdata->port_mode[i] = OMAP_USBHS_PORT_MODE_UNUSED;
>> +    }
>> +
>> +    /* get flags */
>> +    pdata->single_ulpi_bypass = of_property_read_bool(node,
>> +                        "single_ulpi_bypass");
>> +    return 0;
>> +}
>> +
>> +static struct of_device_id usbhs_child_match_table[] __initdata = {
>> +    { .compatible = "ti,omap-ehci", },
>> +    { .compatible = "ti,omap-ohci", },
>> +    { }
>> +};
>> +
>>   /**
>>    * usbhs_omap_probe - initialize TI-based HCDs
>>    *
>> @@ -479,6 +513,21 @@ static int usbhs_omap_probe(struct platform_device *pdev)
>>       int                i;
>>       bool                need_logic_fck;
>>
>> +    if (dev->of_node) {
>> +        /* For DT boot we populate platform data from OF node */
>> +        pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>> +        if (!pdata)
>> +            return -ENOMEM;
>> +
>> +        if (usbhs_omap_get_dt_pdata(dev->of_node, pdata)) {
>> +            dev_err(dev,
>> +                "Error getting platform data from DT node\n");
>> +            return -ENODEV;
>> +        }
>> +
>> +        dev->platform_data = pdata;
>> +    }
>> +
>>       if (!pdata) {
>>           dev_err(dev, "Missing platform data\n");
>>           return -ENODEV;
>> @@ -490,7 +539,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
>>           return -ENOMEM;
>>       }
>>
>> -    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
>> +    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>       omap->uhh_base = devm_request_and_ioremap(dev, res);
>>       if (!omap->uhh_base) {
>>           dev_err(dev, "Resource request/ioremap failed\n");
>> @@ -661,10 +710,23 @@ static int usbhs_omap_probe(struct platform_device *pdev)
>>       }
>>
>>       omap_usbhs_init(dev);
>> -    ret = omap_usbhs_alloc_children(pdev);
>> -    if (ret) {
>> -        dev_err(dev, "omap_usbhs_alloc_children failed\n");
>> -        goto err_alloc;
>> +
>> +    if (dev->of_node) {
>> +        ret = of_platform_populate(dev->of_node,
>> +                usbhs_child_match_table, NULL, dev);
>> +
>> +        if (ret) {
>> +            dev_err(dev, "Failed to create DT children: %d\n", ret);
>> +            goto err_alloc;
>> +        }
>> +
>> +    } else {
>> +        ret = omap_usbhs_alloc_children(pdev);
>> +        if (ret) {
>> +            dev_err(dev, "omap_usbhs_alloc_children failed: %d\n",
>> +                        ret);
>> +            goto err_alloc;
>> +        }
> These child devices should be destroyed on driver remove..no?
> 
Indeed. good catch :).

cheers,
-roger

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-02-05  8:50 UTC|newest]

Thread overview: 65+ 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
     [not found]       ` <5110C339.7080109-l0cyMroinI0@public.gmane.org>
2013-02-05  9:07         ` Felipe Balbi
     [not found]     ` <20130205072637.GA32118-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-03-11 15:52       ` Marc Kleine-Budde
     [not found]         ` <513DFDD7.7000801-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-03-12  9:09           ` Roger Quadros
2013-03-08 10:46   ` Marc Kleine-Budde
2013-03-08 15:04     ` Roger Quadros
     [not found]     ` <5139C174.7030401-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-03-08 15:45       ` Marc Kleine-Budde
     [not found]         ` <513A079A.1020106-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-03-11  8:40           ` Roger Quadros
2013-03-11 15:53             ` Marc Kleine-Budde
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
     [not found]   ` <1359993540-20780-8-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
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
     [not found]     ` <20130205123346.GB26842-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-02-05 12:46       ` Roger Quadros
     [not found] ` <1359993540-20780-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-02-04 15:58   ` [PATCH 02/13] USB: phy: nop: Defer probe if device needs VCC/RESET Roger Quadros
     [not found]     ` <1359993540-20780-3-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
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
     [not found]               ` <5110D45A.3040007-l0cyMroinI0@public.gmane.org>
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
     [not found]       ` <5110A0DF.7050609-l0cyMroinI0@public.gmane.org>
2013-02-05  8:46         ` Roger Quadros
2013-02-04 15:58   ` [PATCH 09/13] mfd: omap-usb-host: Add device tree support and binding information Roger Quadros
     [not found]     ` <1359993540-20780-10-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-02-05  6:16       ` kishon
     [not found]         ` <5110A3C6.6040808-l0cyMroinI0@public.gmane.org>
2013-02-05  8:50           ` Roger Quadros [this message]
2013-02-05 10:58           ` Roger Quadros
     [not found]             ` <5110E5C4.1000501-l0cyMroinI0@public.gmane.org>
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
     [not found]             ` <20130205161141.GD26842-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-02-06  8:56               ` Roger Quadros
2013-02-04 15:59   ` [PATCH 13/13] ARM: dts: omap3-beagle: Add USB Host support Roger Quadros
2013-02-04 15:58 ` [PATCH 10/13] ARM: dts: OMAP4: Add HS USB Host IP nodes Roger Quadros
     [not found]   ` <1359993540-20780-11-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-02-05  6:24     ` kishon
2013-02-05  8:54       ` Roger Quadros
     [not found]         ` <5110C8CE.2020606-l0cyMroinI0@public.gmane.org>
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]   ` <1359993540-20780-12-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-02-05  9:34     ` how to specify an OMAP clock in device tree? Roger Quadros
     [not found]       ` <5110D229.1000808-l0cyMroinI0@public.gmane.org>
2013-02-05 11:15         ` Rajendra Nayak
2013-02-05 13:46           ` Roger Quadros
     [not found]             ` <51110D4B.50904-l0cyMroinI0@public.gmane.org>
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
     [not found]                       ` <51111739.2050805-l0cyMroinI0@public.gmane.org>
2013-02-05 14:36                         ` Rajendra Nayak
2013-02-05 14:52                           ` Roger Quadros
2013-02-06 10:21                             ` Rajendra Nayak
     [not found]                               ` <51122EC0.3040804-l0cyMroinI0@public.gmane.org>
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-05 11:25 ` [PATCH 00/13] Device tree support for OMAP HS USB Host Rajendra Nayak
     [not found]   ` <5110EC0D.40609-l0cyMroinI0@public.gmane.org>
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=5110C7E5.8030402@ti.com \
    --to=rogerq-l0cymroini0@public.gmane.org \
    --cc=b-cousson-l0cyMroinI0@public.gmane.org \
    --cc=balbi-l0cyMroinI0@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=kishon-l0cyMroinI0@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \
    --cc=rnayak-l0cyMroinI0@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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).