devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 2/5] usb: gadget: pxa27x_udc: add devicetree support
       [not found] ` <1411155986-14895-1-git-send-email-robert.jarzmik-GANU6spQydw@public.gmane.org>
@ 2014-09-19 19:46   ` Robert Jarzmik
  2014-09-19 19:46   ` [PATCH v6 3/5] usb: gadget: pxa27x_udc device-tree documentation Robert Jarzmik
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Jarzmik @ 2014-09-19 19:46 UTC (permalink / raw)
  To: Felipe Balbi, Mark Rutland
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, Robert Jarzmik,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add support for device-tree device discovery. If devicetree is not
provided, fallback to legacy platform data "discovery".

Signed-off-by: Robert Jarzmik <robert.jarzmik-GANU6spQydw@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

---
Since V1: change OF id mrvl,pxa27x_udc -> marvell,pxa27x-udc
          This is a consequence of other DT reviews on the marvell
          namings.
Since V2: address Mark's comments:
            - wildcard pxa27x becomes pxa270
            - pullup gpio is described as standard dt gpio
            - bool XXX_probe_dt becomes int XXX_probe_dt
Since v5: split out into 2 patches, this one being the second
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 44 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index 0e356c0..42f4929 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -26,6 +26,8 @@
 #include <linux/prefetch.h>
 #include <linux/byteorder/generic.h>
 #include <linux/platform_data/pxa2xx_udc.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 
 #include <linux/usb.h>
 #include <linux/usb/ch9.h>
@@ -2405,6 +2407,41 @@ static struct pxa_udc memory = {
 	}
 };
 
+static struct of_device_id udc_pxa_dt_ids[] = {
+	{ .compatible = "marvell,pxa270-udc" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, udc_pxa_dt_ids);
+
+/**
+ * pxa_udc_probe_dt - device tree specific probe
+ * @pdev: platform data
+ * @udc: pxa_udc structure to fill
+ *
+ * Fills udc from platform data out of device tree.
+ *
+ * Returns 0 if DT found, 1 if DT not found, and <0 on error
+ */
+static int pxa_udc_probe_dt(struct platform_device *pdev, struct pxa_udc *udc)
+{
+	struct device_node *np = pdev->dev.of_node;
+	const struct of_device_id *of_id =
+			of_match_device(udc_pxa_dt_ids, &pdev->dev);
+	u32 gpio_pullup;
+	enum of_gpio_flags flags;
+
+	if (!np || !of_id)
+		return 1;
+	pdev->id = -1;
+
+	gpio_pullup = of_get_gpio_flags(np, 0, &flags);
+	if (gpio_pullup >= 0) {
+		udc->gpio_pullup = gpio_pullup;
+		udc->gpio_pullup_inverted = (flags & OF_GPIO_ACTIVE_LOW);
+	}
+	return 0;
+}
+
 /**
  * pxa_udc_probe_pdata - legacy platform data probe
  * @pdev: platform device
@@ -2433,7 +2470,11 @@ static int pxa_udc_probe(struct platform_device *pdev)
 	struct pxa_udc *udc = &memory;
 	int retval = 0;
 
-	pxa_udc_probe_pdata(pdev, udc);
+	retval = pxa_udc_probe_dt(pdev, udc);
+	if (retval < 0)
+		return retval;
+	if (retval > 0)
+		pxa_udc_probe_pdata(pdev, udc);
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!regs)
@@ -2633,6 +2674,7 @@ static struct platform_driver udc_driver = {
 	.driver		= {
 		.name	= "pxa27x-udc",
 		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(udc_pxa_dt_ids),
 	},
 	.probe		= pxa_udc_probe,
 	.remove		= pxa_udc_remove,
-- 
2.0.0.rc2

--
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v6 3/5] usb: gadget: pxa27x_udc device-tree documentation
       [not found] ` <1411155986-14895-1-git-send-email-robert.jarzmik-GANU6spQydw@public.gmane.org>
  2014-09-19 19:46   ` [PATCH v6 2/5] usb: gadget: pxa27x_udc: add devicetree support Robert Jarzmik
@ 2014-09-19 19:46   ` Robert Jarzmik
       [not found]     ` <1411155986-14895-3-git-send-email-robert.jarzmik-GANU6spQydw@public.gmane.org>
  1 sibling, 1 reply; 3+ messages in thread
From: Robert Jarzmik @ 2014-09-19 19:46 UTC (permalink / raw)
  To: Felipe Balbi, Mark Rutland
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, Robert Jarzmik,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add documentation for device-tree binding of arm PXA 27x udc (usb
device) driver.

Signed-off-by: Robert Jarzmik <robert.jarzmik-GANU6spQydw@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

---
Since V1: change OF id mrvl,pxa27x_udc -> marvell,pxa27x-udc
          This is a consequence of other DT reviews on the marvell
          namings.
Since V2: Mark's review
          - described standard properties
          - use standard gpio bindings for pullup gpio
Since V3: Arnd's review
          - removed clock-names
---
 Documentation/devicetree/bindings/usb/pxa-usb.txt | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/pxa-usb.txt b/Documentation/devicetree/bindings/usb/pxa-usb.txt
index 79729a9..9c33179 100644
--- a/Documentation/devicetree/bindings/usb/pxa-usb.txt
+++ b/Documentation/devicetree/bindings/usb/pxa-usb.txt
@@ -29,3 +29,25 @@ Example:
 		marvell,port-mode = <2>; /* PMM_GLOBAL_MODE */
 	};
 
+UDC
+
+Required properties:
+ - compatible: Should be "marvell,pxa270-udc" for USB controllers
+   used in device mode.
+ - reg: usb device MMIO address space
+ - interrupts: single interrupt generated by the UDC IP
+ - clocks: input clock of the UDC IP (see clock-bindings.txt)
+
+Optional properties:
+ - gpios:
+   - gpio activated to control the USB D+ pullup (see gpio.txt)
+
+Example:
+
+		pxa27x_udc: udc@40600000 {
+			compatible = "marvell,pxa270-udc";
+			reg = <0x40600000 0x10000>;
+			interrupts = <11>;
+			clocks = <&pxa2xx_clks 11>;
+			gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
+		};
-- 
2.0.0.rc2

--
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v6 3/5] usb: gadget: pxa27x_udc device-tree documentation
       [not found]     ` <1411155986-14895-3-git-send-email-robert.jarzmik-GANU6spQydw@public.gmane.org>
@ 2014-09-22  7:11       ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2014-09-22  7:11 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: Felipe Balbi, Mark Rutland, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Friday 19 September 2014 21:46:24 Robert Jarzmik wrote:
> Add documentation for device-tree binding of arm PXA 27x udc (usb
> device) driver.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik-GANU6spQydw@public.gmane.org>
> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> 
> ---
> Since V1: change OF id mrvl,pxa27x_udc -> marvell,pxa27x-udc
>           This is a consequence of other DT reviews on the marvell
>           namings.
> Since V2: Mark's review
>           - described standard properties
>           - use standard gpio bindings for pullup gpio
> Since V3: Arnd's review
>           - removed clock-names
> 

Acked-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-22  7:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1411155986-14895-1-git-send-email-robert.jarzmik@free.fr>
     [not found] ` <1411155986-14895-1-git-send-email-robert.jarzmik-GANU6spQydw@public.gmane.org>
2014-09-19 19:46   ` [PATCH v6 2/5] usb: gadget: pxa27x_udc: add devicetree support Robert Jarzmik
2014-09-19 19:46   ` [PATCH v6 3/5] usb: gadget: pxa27x_udc device-tree documentation Robert Jarzmik
     [not found]     ` <1411155986-14895-3-git-send-email-robert.jarzmik-GANU6spQydw@public.gmane.org>
2014-09-22  7:11       ` Arnd Bergmann

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).