linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 25/39] usb: musb: ux500: add device tree probing support
Date: Wed, 15 May 2013 10:51:48 +0100	[thread overview]
Message-ID: <1368611522-9984-26-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1368611522-9984-1-git-send-email-lee.jones@linaro.org>

This patch will allow ux500-musb to be probed and configured solely from
configuration found in Device Tree.

Cc: Felipe Balbi <balbi@ti.com>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: linux-usb at vger.kernel.org
Cc: devicetree-discuss at lists.ozlabs.org
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 .../devicetree/bindings/usb/ux500-usb.txt          |   50 +++++++++++++++++++
 drivers/usb/musb/ux500.c                           |   51 ++++++++++++++++++++
 2 files changed, 101 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ux500-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/ux500-usb.txt b/Documentation/devicetree/bindings/usb/ux500-usb.txt
new file mode 100644
index 0000000..330d6ec
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ux500-usb.txt
@@ -0,0 +1,50 @@
+Ux500 MUSB
+
+Required properties:
+ - compatible : Should be "stericsson,db8500-musb"
+ - reg        : Offset and length of registers
+ - interrupts : Interrupt; mode, number and trigger
+ - dr_mode    : Dual-role; either host mode "host", peripheral mode "peripheral"
+                or both "otg"
+
+Optional properties:
+ - dmas       : A list of dma channels;
+                dma-controller, event-line, fixed-channel, flags
+ - dma-names  : An ordered list of channel names affiliated to the above
+
+Example:
+
+usb_per5 at a03e0000 {
+	compatible = "stericsson,db8500-musb", "mentor,musb";
+	reg = <0xa03e0000 0x10000>;
+	interrupts = <0 23 0x4>;
+	interrupt-names = "mc";
+
+	dr_mode = "otg";
+
+	dmas = <&dma 38 0 0x2>, /* Logical - DevToMem */
+	       <&dma 38 0 0x0>, /* Logical - MemToDev */
+	       <&dma 37 0 0x2>, /* Logical - DevToMem */
+	       <&dma 37 0 0x0>, /* Logical - MemToDev */
+	       <&dma 36 0 0x2>, /* Logical - DevToMem */
+	       <&dma 36 0 0x0>, /* Logical - MemToDev */
+	       <&dma 19 0 0x2>, /* Logical - DevToMem */
+	       <&dma 19 0 0x0>, /* Logical - MemToDev */
+	       <&dma 18 0 0x2>, /* Logical - DevToMem */
+	       <&dma 18 0 0x0>, /* Logical - MemToDev */
+	       <&dma 17 0 0x2>, /* Logical - DevToMem */
+	       <&dma 17 0 0x0>, /* Logical - MemToDev */
+	       <&dma 16 0 0x2>, /* Logical - DevToMem */
+	       <&dma 16 0 0x0>, /* Logical - MemToDev */
+	       <&dma 39 0 0x2>, /* Logical - DevToMem */
+	       <&dma 39 0 0x0>; /* Logical - MemToDev */
+
+	dma-names = "iep_1_9",  "oep_1_9",
+		    "iep_2_10", "oep_2_10",
+		    "iep_3_11", "oep_3_11",
+		    "iep_4_12", "oep_4_12",
+		    "iep_5_13", "oep_5_13",
+		    "iep_6_14", "oep_6_14",
+		    "iep_7_15", "oep_7_15",
+		    "iep_8",    "oep_8";
+};
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 3cf10bc..f0beee7 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/usb/musb-ux500.h>
 
@@ -194,14 +195,57 @@ static const struct musb_platform_ops ux500_ops = {
 	.set_vbus	= ux500_musb_set_vbus,
 };
 
+static struct musb_hdrc_platform_data *
+ux500_of_probe(struct platform_device *pdev, struct device_node *np)
+{
+	struct musb_hdrc_platform_data *pdata;
+	const char *mode;
+	int strlen;
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return NULL;
+
+	mode = of_get_property(np, "dr_mode", &strlen);
+	if (!mode) {
+		dev_err(&pdev->dev, "No 'dr_mode' property found\n");
+		return NULL;
+	}
+
+	if (strlen > 0) {
+		if (!strcmp(mode, "host"))
+			pdata->mode = MUSB_HOST;
+		if (!strcmp(mode, "otg"))
+			pdata->mode = MUSB_OTG;
+		if (!strcmp(mode, "peripheral"))
+			pdata->mode = MUSB_PERIPHERAL;
+	}
+
+	return pdata;
+}
+
 static int ux500_probe(struct platform_device *pdev)
 {
 	struct musb_hdrc_platform_data	*pdata = pdev->dev.platform_data;
+	struct device_node		*np = pdev->dev.of_node;
 	struct platform_device		*musb;
 	struct ux500_glue		*glue;
 	struct clk			*clk;
 	int				ret = -ENOMEM;
 
+	if (!pdata) {
+		if (np) {
+			pdata = ux500_of_probe(pdev, np);
+			if (!pdata)
+				goto err0;
+
+			pdev->dev.platform_data = pdata;
+		} else {
+			dev_err(&pdev->dev, "no pdata or device tree found\n");
+			goto err0;
+		}
+	}
+
 	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "failed to allocate glue context\n");
@@ -230,6 +274,7 @@ static int ux500_probe(struct platform_device *pdev)
 	musb->dev.parent		= &pdev->dev;
 	musb->dev.dma_mask		= &pdev->dev.coherent_dma_mask;
 	musb->dev.coherent_dma_mask	= pdev->dev.coherent_dma_mask;
+	musb->dev.of_node		= pdev->dev.of_node;
 
 	glue->dev			= &pdev->dev;
 	glue->musb			= musb;
@@ -328,12 +373,18 @@ static const struct dev_pm_ops ux500_pm_ops = {
 #define DEV_PM_OPS	NULL
 #endif
 
+static const struct of_device_id ux500_match[] = {
+        { .compatible = "stericsson,db8500-musb", },
+        {}
+};
+
 static struct platform_driver ux500_driver = {
 	.probe		= ux500_probe,
 	.remove		= ux500_remove,
 	.driver		= {
 		.name	= "musb-ux500",
 		.pm	= DEV_PM_OPS,
+		.of_match_table = ux500_match,
 	},
 };
 
-- 
1.7.10.4

  parent reply	other threads:[~2013-05-15  9:51 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15  9:51 [PATCH 00/39] Continuation of DMA changes in ux500 based drivers Lee Jones
2013-05-15  9:51 ` [PATCH 01/39] dmaengine: ste_dma40: Separate Logical Global Interrupt Mask (GIM) unmasking Lee Jones
2013-05-15 16:29   ` Linus Walleij
2013-05-16  6:35     ` Vinod Koul
2013-05-16  7:26       ` Lee Jones
2013-05-15  9:51 ` [PATCH 02/39] dmaengine: ste_dma40: Remove unnecessary call to d40_phy_cfg() Lee Jones
2013-05-15 16:33   ` Linus Walleij
2013-05-16  6:35   ` Vinod Koul
2013-05-16  7:25     ` Lee Jones
2013-05-16  9:40       ` Vinod Koul
2013-05-16 10:59         ` Lee Jones
2013-05-20 12:01           ` Linus Walleij
2013-05-15  9:51 ` [PATCH 03/39] dmaengine: ste_dma40: Don't configure runtime configurable setup during allocate Lee Jones
2013-05-15 16:44   ` Linus Walleij
2013-05-16  6:36   ` Vinod Koul
2013-05-15  9:51 ` [PATCH 04/39] ARM: ux500: Stop passing UART's platform data for Device Tree boots Lee Jones
2013-05-15 16:48   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 05/39] ARM: ux500: Stop passing MMC's " Lee Jones
2013-05-15 16:50   ` Linus Walleij
2013-06-10  9:15     ` Lee Jones
2013-06-11  9:31       ` Linus Walleij
2013-05-15  9:51 ` [PATCH 06/39] ARM: ux500: Move SDI (MMC) and UART devices under more descriptive heading Lee Jones
2013-05-15 16:51   ` Linus Walleij
2013-06-10  9:17     ` Lee Jones
2013-06-11  9:40       ` Linus Walleij
2013-05-15  9:51 ` [PATCH 07/39] dmaengine: ste_dma40: Only use addresses passed as configuration information Lee Jones
2013-05-15 16:54   ` Linus Walleij
2013-05-16  6:40   ` Vinod Koul
2013-05-15  9:51 ` [PATCH 08/39] dmaengine: ste_dma40: Remove redundant address fetching function Lee Jones
2013-05-15 16:56   ` Linus Walleij
2013-05-16  6:41   ` Vinod Koul
2013-05-15  9:51 ` [PATCH 09/39] ARM: ux500: Remove DMA address look-up table Lee Jones
2013-05-15 17:03   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 10/39] dmaengine: ste_dma40: Correct copy/paste error Lee Jones
2013-05-15 17:04   ` Linus Walleij
2013-05-16  6:42   ` Vinod Koul
2013-05-15  9:51 ` [PATCH 11/39] ARM: ux500: Remove unnecessary attributes from DMA channel request pdata Lee Jones
2013-05-15 17:05   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 12/39] crypto: ux500/hash - Prepare clock before enabling it Lee Jones
2013-05-15 17:07   ` Linus Walleij
2013-05-16  6:53     ` Lee Jones
2013-05-16  7:00       ` Herbert Xu
2013-05-20 12:05   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 13/39] crypto: ux500/hash - Set DMA configuration though dma_slave_config() Lee Jones
2013-05-15 17:09   ` Linus Walleij
2013-05-16  7:01   ` Herbert Xu
2013-05-20 12:06   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 14/39] ARM: ux500: Stop passing Hash DMA channel config information though pdata Lee Jones
2013-05-20 12:09   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 15/39] crypto: ux500/cryp - Prepare clock before enabling it Lee Jones
2013-05-15 17:11   ` Linus Walleij
2013-05-16  7:01   ` Herbert Xu
2013-05-20 12:10   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 16/39] crypto: ux500/cryp - Set DMA configuration though dma_slave_config() Lee Jones
2013-05-16  7:01   ` Herbert Xu
2013-05-20 12:12   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 17/39] ARM: ux500: Stop passing Cryp DMA channel config information though pdata Lee Jones
2013-05-15  9:51 ` [PATCH 18/39] crypto: ux500/[cryp|hash] - Show successful start-up in the bootlog Lee Jones
2013-05-16  7:02   ` Herbert Xu
2013-05-20 12:15   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 19/39] ARM: ux500: Register Cyrp and Hash platform drivers on Snowball Lee Jones
2013-05-20 12:17   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 20/39] usb: musb: ux500: move channel number knowledge into the driver Lee Jones
2013-05-15 17:18   ` Linus Walleij
2013-05-15 20:14     ` Fabio Baltieri
2013-05-17  6:35       ` Linus Walleij
2013-05-28 16:27     ` Felipe Balbi
2013-05-28 16:48       ` Lee Jones
2013-05-29 11:57       ` Linus Walleij
2013-05-20 12:19   ` Linus Walleij
2013-05-29 17:57   ` Felipe Balbi
2013-05-30  7:48     ` Linus Walleij
2013-05-30  8:12       ` Lee Jones
2013-05-30 19:06         ` Felipe Balbi
2013-05-30  7:44   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 21/39] usb: musb: ux500: move the MUSB HDRC configuration " Lee Jones
2013-05-30  8:30   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 22/39] usb: musb: ux500: take the dma_mask from coherent_dma_mask Lee Jones
2013-05-30  8:32   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 23/39] usb: musb: ux500: harden checks for platform data Lee Jones
2013-05-30  8:34   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 24/39] usb: musb: ux500: attempt to find channels by name before using pdata Lee Jones
2013-05-30  8:35   ` Linus Walleij
2013-05-15  9:51 ` Lee Jones [this message]
2013-05-30  8:38   ` [PATCH 25/39] usb: musb: ux500: add device tree probing support Linus Walleij
2013-05-15  9:51 ` [PATCH 26/39] ARM: ux500: Add an auxdata entry for MUSB for clock-name look-up Lee Jones
2013-05-30  8:42   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 27/39] ARM: ux500: Remove ux500-musb platform registation when booting with DT Lee Jones
2013-05-30  8:44   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 28/39] ARM: ux500: Remove empty function u8500_of_init_devices() Lee Jones
2013-05-30  8:45   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 29/39] dmaengine: ste_dma40: Use the BIT macro to replace ugly '(1 << x)'s Lee Jones
2013-05-30  8:47   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 30/39] ARM: ux500: Replace ST-E's home-brew DMA direction definition with the generic one Lee Jones
2013-05-30  8:52   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 31/39] dmaengine: ste_dma40: Replace ST-E's home-brew DMA direction defs with generic ones Lee Jones
2013-05-16  5:17   ` Vinod Koul
2013-05-16  7:06     ` Lee Jones
2013-05-16  6:43       ` Vinod Koul
2013-05-30  8:54   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 32/39] ARM: ux500: Remove recently unused stedma40_xfer_dir enums Lee Jones
2013-05-30  8:56   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 33/39] dmaengine: ste_dma40_ll: Use the BIT macro to replace ugly '(1 << x)'s Lee Jones
2013-05-16  5:13   ` Vinod Koul
2013-05-30  8:58   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 34/39] dmaengine: ste_dma40: Convert data_width from register bit format to value Lee Jones
2013-05-16  6:32   ` Vinod Koul
2013-05-16  7:35     ` Lee Jones
2013-05-16  9:41       ` Vinod Koul
2013-05-30  9:01   ` Linus Walleij
2013-05-15  9:51 ` [PATCH 35/39] dmaengine: ste_dma40_ll: Replace meaningless register set with comment Lee Jones
2013-05-16  5:18   ` Vinod Koul
2013-05-16  6:58     ` Lee Jones
2013-05-30  9:04   ` Linus Walleij
2013-05-30 17:56     ` Vinod Koul
2013-05-15  9:51 ` [PATCH 36/39] dmaengine: ste_dma40: Allow memcpy channels to be configured from DT Lee Jones
2013-05-16  5:05   ` Vinod Koul
2013-05-30  9:06   ` Linus Walleij
2013-05-15  9:52 ` [PATCH 37/39] ARM: ux500: Stop passing DMA platform data though AUXDATA Lee Jones
2013-05-30  9:12   ` Linus Walleij
2013-05-15  9:52 ` [PATCH 38/39] dmaengine: ste_dma40: Fetch the number of physical channels from DT Lee Jones
2013-05-16  6:34   ` Vinod Koul
2013-05-30  9:15   ` Linus Walleij
2013-05-15  9:52 ` [PATCH 39/39] dmaengine: ste_dma40: Fetch disabled " Lee Jones
2013-05-16  6:08   ` Vinod Koul
2013-05-30  9:16   ` Linus Walleij

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=1368611522-9984-26-git-send-email-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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).