netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <s-paulraj-l0cyMroinI0@public.gmane.org>
To: <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	<davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org>,
	<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: [PATCH] net: add device tree support for davinci mdio
Date: Fri, 1 Jun 2012 14:38:50 -0400	[thread overview]
Message-ID: <1338575930-32075-1-git-send-email-s-paulraj@ti.com> (raw)

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

             reply	other threads:[~2012-06-01 18:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-01 18:38 s-paulraj-l0cyMroinI0 [this message]
  -- 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

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=1338575930-32075-1-git-send-email-s-paulraj@ti.com \
    --to=s-paulraj-l0cymroini0@public.gmane.org \
    --cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).