DORMANTno replies

[PATCH] net: add device tree support for davinci mdio

From: <hidden>
Date: 2012-06-01 18:38:50
Also in: netdev
Subsystem: networking drivers, open firmware and flattened device tree bindings, the rest, ti ethernet switch driver (cpsw) · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Torvalds

From: Sandeep Paulraj <redacted>

This patch adds device tree support in the DaVinci MDIO driver.
The driver is currently being used in DaVinci and OMAP based SOCs; not all of
which have device tree support.
The davinci mdio driver has a way to set the bus frequency
using platform data. There is however no way to pass this information
from device tree.
This patch first looks for a device tree node; if it finds
a node then it looks for the bus frequency from the device tree
bindings. Else it tries to obtain this from platform data.

The new bindings are also explained in the the Documentation for
davini_mdio

Signed-off-by: Sandeep Paulraj <redacted>
---
 .../devicetree/bindings/net/davinci_mdio.txt       |   16 ++++++++++++++++
 drivers/net/ethernet/ti/davinci_mdio.c             |   19 ++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/davinci_mdio.txt
diff --git a/Documentation/devicetree/bindings/net/davinci_mdio.txt b/Documentation/devicetree/bindings/net/davinci_mdio.txt
new file mode 100644
index 0000000..545e216
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/davinci_mdio.txt
@@ -0,0 +1,16 @@
+MDIO on DaVinci SOCs
+
+Currently defined compatibles:
+- ti,davinci-mdio
+
+Required properties:
+- bus-frequency: The operating frequency of the mdio bus
+
+Example:
+
+mdio: mdio@2090300 {
+			compatible	= "ti,davinci-mdio";
+			reg		= <0x2090300 0x100>;
+			bus-frequency	= <50000000>;
+		};
+
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index af8b8fc..efa13c5 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -34,6 +34,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/of.h>
 #include <linux/davinci_emac.h>
 
 /*
@@ -286,11 +287,13 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id,
 static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 {
 	struct mdio_platform_data *pdata = pdev->dev.platform_data;
+	struct device_node *node = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	struct davinci_mdio_data *data;
 	struct resource *res;
 	struct phy_device *phy;
 	int ret, addr;
+	u32 bus_freq;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
@@ -298,7 +301,15 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	data->pdata = pdata ? (*pdata) : default_pdata;
+	if (node) {
+		ret = of_property_read_u32(node, "bus-frequency", &bus_freq);
+		if (ret < 0) {
+			dev_info(&pdev->dev, "Using default bus frequency\n");
+			bus_freq = 50000000;
+		}
+		data->pdata.bus_freq = bus_freq;
+	} else
+		data->pdata = pdata ? (*pdata) : default_pdata;
 
 	data->bus = mdiobus_alloc();
 	if (!data->bus) {
@@ -450,11 +461,17 @@ static const struct dev_pm_ops davinci_mdio_pm_ops = {
 	.resume		= davinci_mdio_resume,
 };
 
+static struct of_device_id __devinitdata of_match[] = {
+	{ .compatible = "ti,davinci-mdio", },
+	{},
+};
+
 static struct platform_driver davinci_mdio_driver = {
 	.driver = {
 		.name	 = "davinci_mdio",
 		.owner	 = THIS_MODULE,
 		.pm	 = &davinci_mdio_pm_ops,
+		.of_match_table	= of_match,
 	},
 	.probe = davinci_mdio_probe,
 	.remove = __devexit_p(davinci_mdio_remove),
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help