From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/10 v2] usb: musb: ux500: add device tree probing support
Date: Wed, 24 Apr 2013 08:43:36 +0100 [thread overview]
Message-ID: <20130424074336.GD17416@gmail.com> (raw)
In-Reply-To: <1366729394-11406-7-git-send-email-lee.jones@linaro.org>
usb: musb: ux500: add device tree probing support
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: linux-usb at vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
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 7ddb132..5ff304c 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 "musb_core.h"
@@ -88,14 +89,57 @@ static const struct musb_platform_ops ux500_ops = {
.exit = ux500_musb_exit,
};
+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");
@@ -124,6 +168,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;
@@ -222,12 +267,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,
},
};
next prev parent reply other threads:[~2013-04-24 7:43 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-23 15:03 [PATCH 00/10] usb: musb: ux500: pathe the way for Device Tree enablement Lee Jones
2013-04-23 15:03 ` [PATCH 01/10] usb: musb: ux500: move channel number knowledge into the driver Lee Jones
2013-04-25 13:01 ` Linus Walleij
2013-04-23 15:03 ` [PATCH 02/10] usb: musb: ux500: move the MUSB HDRC configuration " Lee Jones
2013-04-25 13:02 ` Linus Walleij
2013-04-23 15:03 ` [PATCH 03/10] usb: musb: ux500: take the dma_mask from coherent_dma_mask Lee Jones
2013-04-25 13:04 ` Linus Walleij
2013-04-23 15:03 ` [PATCH 04/10] usb: musb: ux500: harden checks for platform data Lee Jones
2013-04-23 20:03 ` Sergei Shtylyov
2013-04-24 6:53 ` Lee Jones
2013-04-24 14:00 ` Sergei Shtylyov
2013-04-24 14:26 ` Felipe Balbi
[not found] ` <CAF2Aj3ga7R3Vti4YB-83T_AsanB3iL34aysAN3MiMWZBvB=z2Q@mail.gmail.com>
2013-04-24 14:56 ` Arnd Bergmann
2013-04-24 15:04 ` [PATCH 04/10 v2] " Lee Jones
2013-04-25 13:06 ` Linus Walleij
2013-04-23 15:03 ` [PATCH 05/10] usb: musb: ux500: attempt to find channels by name before using pdata Lee Jones
2013-04-24 15:05 ` [PATCH 05/10 v2] " Lee Jones
2013-04-25 13:08 ` Linus Walleij
2013-04-23 15:03 ` [PATCH 06/10] usb: musb: ux500: add device tree probing support Lee Jones
2013-04-23 15:14 ` Arnd Bergmann
2013-04-23 15:15 ` Felipe Balbi
2013-04-23 15:27 ` Arnd Bergmann
2013-04-23 15:29 ` Felipe Balbi
2013-04-24 7:43 ` Lee Jones [this message]
2013-04-25 13:12 ` [PATCH 06/10 v2] " Linus Walleij
2013-04-23 15:03 ` [PATCH 07/10] ARM: ux500: Add an auxdata entry for MUSB for clock-name look-up Lee Jones
2013-04-25 13:13 ` Linus Walleij
2013-04-23 15:03 ` [PATCH 08/10] ARM: ux500: Populate the ux500-musb Device Tree entry Lee Jones
2013-04-24 7:41 ` [PATCH 08/10 v2] " Lee Jones
2013-04-25 13:14 ` Linus Walleij
2013-04-23 15:03 ` [PATCH 09/10] ARM: ux500: Remove ux500-musb platform registation when booting with DT Lee Jones
2013-04-25 13:15 ` Linus Walleij
2013-05-02 10:52 ` Lee Jones
2013-04-23 15:03 ` [PATCH 10/10] ARM: ux500: Remove empty function u8500_of_init_devices() Lee Jones
2013-04-25 13:16 ` Linus Walleij
2013-05-02 10:52 ` Lee Jones
2013-04-23 15:16 ` [PATCH 00/10] usb: musb: ux500: pathe the way for Device Tree enablement Arnd Bergmann
2013-04-26 13:49 ` Fabio Baltieri
2013-04-26 15:19 ` Lee Jones
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=20130424074336.GD17416@gmail.com \
--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).