Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1497343

[PATCH/RFT 10/12] USB: ohci-da8xx: Add device tree support

Path csiph.com!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From ahaslam@baylibre.com
Newsgroups linux.kernel
Subject [PATCH/RFT 10/12] USB: ohci-da8xx: Add device tree support
Date Fri, 07 Oct 2016 18:50:02 +0200
Message-ID <spGvo-3aK-45@gated-at.bofh.it> (permalink)
References <spGvn-3aK-7@gated-at.bofh.it>
X-Original-To gregkh@linuxfoundation.org, robh+dt@kernel.org, nsekhar@ti.com, stern@rowland.harvard.edu, khilman@baylibre.com, sshtylyov@ru.mvista.com, david@lechnology.com
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lltienq596QGKiDlz+ufGkbUitGWu8ocXsiHdKkIf3A=; b=BOjbbzu6OeFbLt5JAZ68oKsT09PWUKUtnzg5mHOBiLm/kvcfc40CHD/J9gkLRyhnHt LOp5w6ekJj10cvX1TdyTAHVmeMns3X2qpxFsehWH+mG9TobIa1Qvv3FBZEmsVii9i+o0 dsl7ZJu6RAChFS5E/xrBINRmHQ5BbbFoB2XyrlRXiNhQYl9UKqTGR/V+4xqPlkB8hkV5 J0uBHE6aWHG55afWDeeA+vwlqaL59aPzT3HfxBXZrLRxsyzkufYhMJi+vc/2GlpXMoxK AfV7vY5IXLBYAWyX56IRXMFoeKz5C4AL9h0E8Ohsad7MWH4de258m99KBCNc8yv4zX9l j+9w==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lltienq596QGKiDlz+ufGkbUitGWu8ocXsiHdKkIf3A=; b=APung219L4/V4KEetTaqPde5cG01VqW07+1XnMf1yZZESmtqzjfU7T/U6bAmsDFk1V y5fWpSL/E+xfHttoSyU3XkbCFnK7/QlJgnbQxOWuOshD26yU7IEoGP57px1Ciyk4uBtX 2mduuLwyfaxMpf9lItAYxYOuLKhIZ3uzIaYmXCq/8ExZVTx5tX26MKjXqBohqAH2nLTR rXzWS6rNALIjav6SYK3w5B1B4BiaSBfT6wzNbQ9rHS8izCf3sEXIOP73XY0qrkzPIzw3 A7G++DsgKF/av9Narp2ZuqR/XjA0HyPBYX1IDfbUwFYkWwQ47kWa6X2FE4BP9o2DSWJx NY/g==
X-Gm-Message-State AA6/9RkBGC0kJDgSMehQnql1IQkiS1CSVXLxkBj1mrGjPfjUfGrsx8hO8OctyOAj5NIHtb56
X-Received by 10.28.41.131 with SMTP id p125mr14590445wmp.15.1475858590361; Fri, 07 Oct 2016 09:43:10 -0700 (PDT)
X-Mailer git-send-email 2.7.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 99
Organization linux.* mail to news gateway
X-Original-Cc linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Axel Haslam <ahaslam@baylibre.com>
X-Original-Date Fri, 7 Oct 2016 18:42:55 +0200
X-Original-Message-ID <1475858577-10366-11-git-send-email-ahaslam@baylibre.com>
X-Original-References <1475858577-10366-1-git-send-email-ahaslam@baylibre.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1497343

Show key headers only | View raw


From: Axel Haslam <ahaslam@baylibre.com>

This allows the controller to be specified via device tree.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 52 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index d7a0f11..10db421 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -18,6 +18,7 @@
 #include <linux/phy/phy.h>
 #include <linux/platform_data/usb-davinci.h>
 #include <linux/gpio.h>
+#include <linux/of_gpio.h>
 
 #ifndef CONFIG_ARCH_DAVINCI_DA8XX
 #error "This file is DA8xx bus glue.  Define CONFIG_ARCH_DAVINCI_DA8XX."
@@ -311,6 +312,47 @@ static const struct hc_driver ohci_da8xx_hc_driver = {
 
 /*-------------------------------------------------------------------------*/
 
+#ifdef CONFIG_OF
+static const struct of_device_id da8xx_ohci_ids[] = {
+	{ .compatible = "ti,da830-ohci" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, da8xx_ohci_ids);
+
+static int ohci_da8xx_of_init(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct da8xx_ohci_platform_data *pdata;
+	u32 tmp;
+
+	if (!np)
+		return 0;
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
+
+	pdata->gpio_vbus = of_get_named_gpio(np, "vbus-gpio", 0);
+	if (pdata->gpio_vbus >= 0)
+		pdata->flags |= DA8XX_OHCI_FLAG_GPIO_VBUS;
+
+	pdata->gpio_overcurrent = of_get_named_gpio(np, "oci-gpio", 0);
+	if (pdata->gpio_overcurrent >= 0)
+		pdata->flags |= DA8XX_OHCI_FLAG_GPIO_OCI;
+
+	if (!of_property_read_u32(np, "power-on-delay", &tmp))
+		pdata->potpgt = tmp;
+
+	pdev->dev.platform_data = pdata;
+
+	return 0;
+}
+#else
+static int ohci_da8xx_of_init(struct platform_device *pdev)
+{
+	return 0;
+}
+#endif
 
 /**
  * usb_hcd_da8xx_probe - initialize DA8xx-based HCDs
@@ -323,12 +365,17 @@ static const struct hc_driver ohci_da8xx_hc_driver = {
 static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
 			       struct platform_device *pdev)
 {
-	struct da8xx_ohci_platform_data *pdata	= dev_get_platdata(&pdev->dev);
+	struct da8xx_ohci_platform_data *pdata;
 	struct usb_hcd	*hcd;
 	struct resource *mem;
 	int error, irq;
 
-	if (pdata == NULL)
+	error = ohci_da8xx_of_init(pdev);
+	if (error)
+		pr_err("error initializing platform data: %d\n", error);
+
+	pdata  = dev_get_platdata(&pdev->dev);
+	if (!pdata)
 		return -ENODEV;
 
 	usb11_clk = devm_clk_get(&pdev->dev, "usb11");
@@ -498,6 +545,7 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
 #endif
 	.driver		= {
 		.name	= "ohci",
+		.of_match_table = da8xx_ohci_ids,
 	},
 };
 
-- 
2.7.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH/RFT 10/12] USB: ohci-da8xx: Add device tree support ahaslam@baylibre.com - 2016-10-07 18:50 +0200

csiph-web