[PATCH] smc91x: add devicetree support

Subsystems: networking drivers, the rest

STALE5743d

10 messages, 4 authors, 2011-01-26 · open the first message on its own page

[PATCH] smc91x: add devicetree support

From: Thomas Chou <hidden>
Date: 2011-01-25 05:57:19

Signed-off-by: Thomas Chou <redacted>
---
 drivers/net/smc91x.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 726df61..d29e18d 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/workqueue.h>
+#include <linux/of.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -2394,6 +2395,12 @@ static int smc_drv_resume(struct device *dev)
 	return 0;
 }
 
+static const struct of_device_id smc91x_match[] = {
+	{ .compatible = "smsc,smc91x", },
+	{},
+}
+MODULE_DEVICE_TABLE(of, smc91x_match);
+
 static struct dev_pm_ops smc_drv_pm_ops = {
 	.suspend	= smc_drv_suspend,
 	.resume		= smc_drv_resume,
@@ -2406,6 +2413,9 @@ static struct platform_driver smc_driver = {
 		.name	= CARDNAME,
 		.owner	= THIS_MODULE,
 		.pm	= &smc_drv_pm_ops,
+#ifdef CONFIG_OF
+		.of_match_table = smc91x_match,
+#endif
 	},
 };
 
-- 
1.7.3.5

Re: [PATCH] smc91x: add devicetree support

From: Grant Likely <hidden>
Date: 2011-01-25 06:24:39

On Mon, Jan 24, 2011 at 10:59 PM, Thomas Chou [off-list ref] wrote:
quoted hunk
Signed-off-by: Thomas Chou <redacted>
---
 drivers/net/smc91x.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 726df61..d29e18d 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/workqueue.h>
+#include <linux/of.h>

 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -2394,6 +2395,12 @@ static int smc_drv_resume(struct device *dev)
       return 0;
 }

+static const struct of_device_id smc91x_match[] = {
+       { .compatible = "smsc,smc91x", },
Be specific.  What *exact* smsc device are you adding support for?
Wildcards like smc91x tend to cause problems in the future.
quoted hunk
+       {},
+}
+MODULE_DEVICE_TABLE(of, smc91x_match);
+
 static struct dev_pm_ops smc_drv_pm_ops = {
       .suspend        = smc_drv_suspend,
       .resume         = smc_drv_resume,
@@ -2406,6 +2413,9 @@ static struct platform_driver smc_driver = {
               .name   = CARDNAME,
               .owner  = THIS_MODULE,
               .pm     = &smc_drv_pm_ops,
+#ifdef CONFIG_OF
+               .of_match_table = smc91x_match,
+#endif
       },
 };

--
1.7.3.5


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

[PATCH v2] smc91x: add devicetree support

From: Thomas Chou <hidden>
Date: 2011-01-25 07:07:37

Signed-off-by: Thomas Chou <redacted>
---
v2 specify part numbers in compat as Grant suggested.

 drivers/net/smc91x.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 726df61..de48ebd 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/workqueue.h>
+#include <linux/of.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -2394,6 +2395,13 @@ static int smc_drv_resume(struct device *dev)
 	return 0;
 }
 
+static const struct of_device_id smc91x_match[] = {
+	{ .compatible = "smsc,smc91c94", },
+	{ .compatible = "smsc,smc91c111", },
+	{},
+}
+MODULE_DEVICE_TABLE(of, smc91x_match);
+
 static struct dev_pm_ops smc_drv_pm_ops = {
 	.suspend	= smc_drv_suspend,
 	.resume		= smc_drv_resume,
@@ -2406,6 +2414,9 @@ static struct platform_driver smc_driver = {
 		.name	= CARDNAME,
 		.owner	= THIS_MODULE,
 		.pm	= &smc_drv_pm_ops,
+#ifdef CONFIG_OF
+		.of_match_table = smc91x_match,
+#endif
 	},
 };
 
-- 
1.7.3.5

[PATCH v3] smc91x: add devicetree support

From: Thomas Chou <hidden>
Date: 2011-01-25 12:11:52

Signed-off-by: Thomas Chou <redacted>
---
v2 specify part numbers in compat as Grant suggested.
v3 more specific part name.

 drivers/net/smc91x.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 726df61..65b2a70 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/workqueue.h>
+#include <linux/of.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -2394,6 +2395,13 @@ static int smc_drv_resume(struct device *dev)
 	return 0;
 }
 
+static const struct of_device_id smc91x_match[] = {
+	{ .compatible = "smsc,lan91c94", },
+	{ .compatible = "smsc,lan91c111", },
+	{},
+}
+MODULE_DEVICE_TABLE(of, smc91x_match);
+
 static struct dev_pm_ops smc_drv_pm_ops = {
 	.suspend	= smc_drv_suspend,
 	.resume		= smc_drv_resume,
@@ -2406,6 +2414,9 @@ static struct platform_driver smc_driver = {
 		.name	= CARDNAME,
 		.owner	= THIS_MODULE,
 		.pm	= &smc_drv_pm_ops,
+#ifdef CONFIG_OF
+		.of_match_table = smc91x_match,
+#endif
 	},
 };
 
-- 
1.7.3.5

Re: [PATCH v3] smc91x: add devicetree support

From: David Miller <davem@davemloft.net>
Date: 2011-01-26 03:44:59

From: Thomas Chou <redacted>
Date: Tue, 25 Jan 2011 20:11:48 +0800
quoted hunk
@@ -2394,6 +2395,13 @@ static int smc_drv_resume(struct device *dev)
 	return 0;
 }
 
+static const struct of_device_id smc91x_match[] = {
+	{ .compatible = "smsc,lan91c94", },
+	{ .compatible = "smsc,lan91c111", },
+	{},
+}
+MODULE_DEVICE_TABLE(of, smc91x_match);
+
 static struct dev_pm_ops smc_drv_pm_ops = {
 	.suspend	= smc_drv_suspend,
 	.resume		= smc_drv_resume,
You should not unconditionally put the 'of' device table into the
module image, otherwise the module will be marked as being able to
support OF based devices but the code to support that won't actually
be comiled into the module.

[PATCH v4] smc91x: add devicetree support

From: Thomas Chou <hidden>
Date: 2011-01-26 05:19:48

Signed-off-by: Thomas Chou <redacted>
---
v2 specify part numbers in compat as Grant suggested.
v3 more specific part name.
v4 include match table only for OF as David suggested.

 drivers/net/smc91x.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 726df61..43654a3 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/workqueue.h>
+#include <linux/of.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -2394,6 +2395,15 @@ static int smc_drv_resume(struct device *dev)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id smc91x_match[] = {
+	{ .compatible = "smsc,lan91c94", },
+	{ .compatible = "smsc,lan91c111", },
+	{},
+}
+MODULE_DEVICE_TABLE(of, smc91x_match);
+#endif
+
 static struct dev_pm_ops smc_drv_pm_ops = {
 	.suspend	= smc_drv_suspend,
 	.resume		= smc_drv_resume,
@@ -2406,6 +2416,9 @@ static struct platform_driver smc_driver = {
 		.name	= CARDNAME,
 		.owner	= THIS_MODULE,
 		.pm	= &smc_drv_pm_ops,
+#ifdef CONFIG_OF
+		.of_match_table = smc91x_match,
+#endif
 	},
 };
 
-- 
1.7.3.5

Re: [PATCH v4] smc91x: add devicetree support

From: Grant Likely <hidden>
Date: 2011-01-26 05:52:58

On Tue, Jan 25, 2011 at 10:22 PM, Thomas Chou [off-list ref] wrote:
Signed-off-by: Thomas Chou <redacted>
---
v2 specify part numbers in compat as Grant suggested.
v3 more specific part name.
v4 include match table only for OF as David suggested.

 drivers/net/smc91x.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Looks okay to me.

Reviewed-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
quoted hunk
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 726df61..43654a3 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/workqueue.h>
+#include <linux/of.h>

 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -2394,6 +2395,15 @@ static int smc_drv_resume(struct device *dev)
       return 0;
 }

+#ifdef CONFIG_OF
+static const struct of_device_id smc91x_match[] = {
+       { .compatible = "smsc,lan91c94", },
+       { .compatible = "smsc,lan91c111", },
+       {},
+}
+MODULE_DEVICE_TABLE(of, smc91x_match);
+#endif
+
 static struct dev_pm_ops smc_drv_pm_ops = {
       .suspend        = smc_drv_suspend,
       .resume         = smc_drv_resume,
@@ -2406,6 +2416,9 @@ static struct platform_driver smc_driver = {
               .name   = CARDNAME,
               .owner  = THIS_MODULE,
               .pm     = &smc_drv_pm_ops,
+#ifdef CONFIG_OF
+               .of_match_table = smc91x_match,
+#endif
       },
 };

--
1.7.3.5


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

Re: [PATCH v4] smc91x: add devicetree support

From: David Miller <davem@davemloft.net>
Date: 2011-01-26 06:41:36

From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Date: Tue, 25 Jan 2011 22:52:36 -0700
On Tue, Jan 25, 2011 at 10:22 PM, Thomas Chou [off-list ref] wrote:
quoted
Signed-off-by: Thomas Chou <redacted>
---
v2 specify part numbers in compat as Grant suggested.
v3 more specific part name.
v4 include match table only for OF as David suggested.

 drivers/net/smc91x.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Looks okay to me.

Reviewed-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Applied to net-next-2.6, thanks.

Re: [PATCH v4] smc91x: add devicetree support

From: Nicolas Pitre <nico@fluxnic.net>
Date: 2011-01-26 15:17:38

On Wed, 26 Jan 2011, Thomas Chou wrote:
Signed-off-by: Thomas Chou <redacted>
---
v2 specify part numbers in compat as Grant suggested.
v3 more specific part name.
v4 include match table only for OF as David suggested.
The smc91x driver relies on many parameters which are platform specific, 
such as the bus width capabilities, register spacing due to special bus 
wiring, interrupt signal level, LED configuration, whether or not to 
configure the chip with a wait state, etc.  Will the device tree support 
take care of those things?


Nicolas

Re: [PATCH v4] smc91x: add devicetree support

From: Grant Likely <hidden>
Date: 2011-01-26 15:33:17

On Wed, Jan 26, 2011 at 8:17 AM, Nicolas Pitre [off-list ref] wrote:
On Wed, 26 Jan 2011, Thomas Chou wrote:
quoted
Signed-off-by: Thomas Chou <redacted>
---
v2 specify part numbers in compat as Grant suggested.
v3 more specific part name.
v4 include match table only for OF as David suggested.
The smc91x driver relies on many parameters which are platform specific,
such as the bus width capabilities, register spacing due to special bus
wiring, interrupt signal level, LED configuration, whether or not to
configure the chip with a wait state, etc.  Will the device tree support
take care of those things?
Short answer, yes

In general bindings are written and documented as they are needed.  In
this specific case,yes the device configuration should be encoded into
the device tree node.  It is okay for now to not wire up any of that
configuration if the defaults work for Thomas' platform, but to be
useful in the long run they do need to be added.

Typically a block or function call is added to the drivers .probe hook
to decode device tree data if the of_node pointer is set.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help