All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: add device tree support for davinci mdio
@ 2012-06-01 18:38 ` s-paulraj-l0cyMroinI0
  0 siblings, 0 replies; 3+ messages in thread
From: s-paulraj-l0cyMroinI0 @ 2012-06-01 18:38 UTC (permalink / raw)
  To: grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

From: Sandeep Paulraj <s-paulraj-l0cyMroinI0@public.gmane.org>

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 <s-paulraj-l0cyMroinI0@public.gmane.org>
---
 .../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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] net: add device tree support for davinci mdio
@ 2012-06-01 18:38 ` s-paulraj-l0cyMroinI0
  0 siblings, 0 replies; 3+ messages in thread
From: s-paulraj-l0cyMroinI0 @ 2012-06-01 18:38 UTC (permalink / raw)
  To: grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

From: Sandeep Paulraj <s-paulraj-l0cyMroinI0@public.gmane.org>

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 <s-paulraj-l0cyMroinI0@public.gmane.org>
---
 .../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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] net: add device tree support for DaVinci MDIO
@ 2012-03-21 15:05 s-paulraj-l0cyMroinI0
  0 siblings, 0 replies; 3+ messages in thread
From: s-paulraj-l0cyMroinI0 @ 2012-03-21 15:05 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA,
	davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	grant.likely-s3s/WqlpOiPyB63q8FvJNQ

From: Sandeep Paulraj <s-paulraj-l0cyMroinI0@public.gmane.org>

This patch adds device tree support in the DaVinci MDIO driver.


Signed-off-by: Sandeep Paulraj <s-paulraj-l0cyMroinI0@public.gmane.org>
---
 .../devicetree/bindings/net/davinci_mdio.txt       |   12 ++++++++++++
 drivers/net/ethernet/ti/davinci_mdio.c             |    7 +++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
 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..cbe499f
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/davinci_mdio.txt
@@ -0,0 +1,12 @@
+MDIO on DaVinci SOCs
+
+Currently defined compatibles:
+- ti,davinci_mdio
+
+Example:
+
+mdio: mdio@2090300 {
+			compatible	= "ti,davinci_mdio";
+			reg		= <0x2090300 0x100>;
+		};
+
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 7615040..362644d 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>
 
 /*
@@ -449,11 +450,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.4.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-01 18:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-01 18:38 [PATCH] net: add device tree support for davinci mdio s-paulraj-l0cyMroinI0
2012-06-01 18:38 ` s-paulraj-l0cyMroinI0
  -- strict thread matches above, loose matches on Subject: below --
2012-03-21 15:05 [PATCH] net: add device tree support for DaVinci MDIO s-paulraj-l0cyMroinI0

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.