From: mkl@pengutronix.de (Marc Kleine-Budde)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/4] usb: chipidea: ci13xxx-imx: add "dr_mode" property to device tree bindings
Date: Thu, 28 Jun 2012 15:53:48 +0200 [thread overview]
Message-ID: <1340891629-13145-4-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1340891629-13145-1-git-send-email-mkl@pengutronix.de>
This patch allows the device tree to limit the chipidea to host or
peripheral mode only.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
.../devicetree/bindings/usb/ci13xxx-imx.txt | 3 ++
drivers/usb/chipidea/ci13xxx_imx.c | 3 ++
drivers/usb/chipidea/core.c | 41 +++++++++++++++++---
include/linux/usb/chipidea.h | 9 +++++
4 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 5a0ad66..67f97f56 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -4,6 +4,8 @@ Required properties:
- compatible: Should be "fsl,imx27-usb"
- reg: Should contain registers location and length
- interrupts: Should contain controller interrupt
+- dr_mode: indicates the working mode for compatible controllers. Can
+ be "host", "peripheral", or "otg". Defaults to "otg" if not defined.
Optional properties:
- fsl,usbphy: phandler of usb phy that connects to the only one port
@@ -14,4 +16,5 @@ usb at 02184000 { /* USB OTG */
reg = <0x02184000 0x200>;
interrupts = <0 43 0x04>;
fsl,usbphy = <&usbphy1>;
+ dr_mode= "otg";
};
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index efae2be..8e926fb 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -120,6 +120,9 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
*pdev->dev.dma_mask = DMA_BIT_MASK(32);
dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask);
}
+
+ ci13xxx_get_dr_mode(pdev->dev.of_node, &ci13xxx_imx_platdata);
+
plat_ci = ci13xxx_add_device(&pdev->dev,
pdev->resource, pdev->num_resources,
&ci13xxx_imx_platdata);
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 1083585..aa8b1856 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -63,6 +63,8 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/usb/otg.h>
@@ -386,6 +388,23 @@ void ci13xxx_remove_device(struct platform_device *pdev)
}
EXPORT_SYMBOL_GPL(ci13xxx_remove_device);
+void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata)
+{
+ const unsigned char *dr_mode;
+
+ dr_mode = of_get_property(of_node, "dr_mode", NULL);
+ if (!dr_mode)
+ return;
+
+ if (!strcmp(dr_mode, "host"))
+ pdata->flags |= CI13XXX_DR_MODE_HOST;
+ else if (!strcmp(dr_mode, "peripheral"))
+ pdata->flags |= CI13XXX_DR_MODE_PERIPHERAL;
+ else if (!strcmp(dr_mode, "otg"))
+ pdata->flags |= CI13XXX_DR_MODE_OTG;
+}
+EXPORT_SYMBOL_GPL(ci13xxx_get_dr_mode);
+
static int __devinit ci_hdrc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -446,13 +465,23 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
}
/* initialize role(s) before the interrupt is requested */
- ret = ci_hdrc_host_init(ci);
- if (ret)
- dev_info(dev, "doesn't support host\n");
+ /* default to otg */
+ if (!(ci->platdata->flags & CI13XXX_DR_MODE_MASK))
+ ci->platdata->flags |= CI13XXX_DR_MODE_OTG;
+
+ if (ci->platdata->flags &
+ (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_OTG)) {
+ ret = ci_hdrc_host_init(ci);
+ if (ret)
+ dev_info(dev, "doesn't support host\n");
+ }
- ret = ci_hdrc_gadget_init(ci);
- if (ret)
- dev_info(dev, "doesn't support gadget\n");
+ if (ci->platdata->flags &
+ (CI13XXX_DR_MODE_PERIPHERAL | CI13XXX_DR_MODE_OTG)) {
+ ret = ci_hdrc_gadget_init(ci);
+ if (ret)
+ dev_info(dev, "doesn't support gadget\n");
+ }
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
dev_err(dev, "no supported roles\n");
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 544825d..29ad908 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -19,6 +19,12 @@ struct ci13xxx_platform_data {
#define CI13XXX_REQUIRE_TRANSCEIVER BIT(1)
#define CI13XXX_PULLUP_ON_VBUS BIT(2)
#define CI13XXX_DISABLE_STREAMING BIT(3)
+#define CI13XXX_DR_MODE_HOST BIT(4)
+#define CI13XXX_DR_MODE_PERIPHERAL BIT(5)
+#define CI13XXX_DR_MODE_OTG BIT(6)
+#define CI13XXX_DR_MODE_MASK \
+ (CI13XXX_DR_MODE_HOST | CI13XXX_DR_MODE_PERIPHERAL | \
+ CI13XXX_DR_MODE_OTG)
#define CI13XXX_CONTROLLER_RESET_EVENT 0
#define CI13XXX_CONTROLLER_STOPPED_EVENT 1
@@ -35,4 +41,7 @@ struct platform_device *ci13xxx_add_device(struct device *dev,
/* Remove ci13xxx device */
void ci13xxx_remove_device(struct platform_device *pdev);
+/* Parse of-tree "dr_mode" property */
+void ci13xxx_get_dr_mode(struct device_node *of_node, struct ci13xxx_platform_data *pdata);
+
#endif
--
1.7.10
next prev parent reply other threads:[~2012-06-28 13:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-28 13:53 [PATCH v2 0/4] usb: chipidea: fix error handling and add dr_role property Marc Kleine-Budde
2012-06-28 13:53 ` [PATCH v2 1/4] usb: chipidea: pci: make platformdata static Marc Kleine-Budde
2012-06-28 14:06 ` Richard Zhao
2012-07-08 15:10 ` Richard Zhao
2012-07-08 17:48 ` Russell King - ARM Linux
2012-07-09 1:20 ` Richard Zhao
2012-06-28 13:53 ` [PATCH v2 2/4] usb: chipidea: udc: fix error path in udc_start() Marc Kleine-Budde
2012-06-28 13:53 ` Marc Kleine-Budde [this message]
2012-06-29 1:43 ` [PATCH v2 3/4] usb: chipidea: ci13xxx-imx: add "dr_mode" property to device tree bindings Richard Zhao
2012-06-29 7:47 ` Marc Kleine-Budde
2012-06-29 8:45 ` Richard Zhao
2012-06-29 9:29 ` Marc Kleine-Budde
2012-06-30 1:40 ` Richard Zhao
2012-06-29 15:51 ` Stephen Warren
2012-06-30 1:19 ` Richard Zhao
2012-07-02 20:04 ` Stephen Warren
2012-07-03 2:22 ` Peter Chen
2012-07-03 3:00 ` Richard Zhao
2012-07-03 7:02 ` Lothar Waßmann
2012-07-03 7:10 ` Richard Zhao
2012-06-30 1:33 ` Richard Zhao
2012-06-30 21:57 ` Sergei Shtylyov
2012-06-28 13:53 ` [PATCH v2 4/4] ARM: dts: imx23,28: limit usb to host role Marc Kleine-Budde
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=1340891629-13145-4-git-send-email-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--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).