* [PATCH 0/2] net: smc91x: add DT flags for legacy platforms
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree, linux-omap, netdev
Cc: linux-doc, linux-kernel, linux-arm-kernel, Benoît Cousson,
Tony Lindgren, Nishanth Menon
Hi,
SMC91x driver has been converted to device tree, however users of
older lan91c94 based platform need description provided previously by
platform_data. Without this, ethernet fails to function on these platforms.
For example, on SDP2430:
Before: http://pastebin.mozilla.org/3753793
After: http://pastebin.mozilla.org/3753792
Nishanth Menon (2):
net: smc91x: Read hardware behavior flags from device tree
ARM: dts: omap2430-sdp: add flags for ethernet functionality
Documentation/devicetree/bindings/net/smsc91x.txt | 45 +++++++++
arch/arm/boot/dts/omap2430-sdp.dts | 5 +
drivers/net/ethernet/smsc/smc91x.c | 106 ++++++++++++++++++++-
3 files changed, 155 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/smsc91x.txt
Regards,
Nishanth Menon
--
1.7.9.5
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 0/2] net: smc91x: add DT flags for legacy platforms
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Benoît Cousson, Tony Lindgren, Nishanth Menon
Hi,
SMC91x driver has been converted to device tree, however users of
older lan91c94 based platform need description provided previously by
platform_data. Without this, ethernet fails to function on these platforms.
For example, on SDP2430:
Before: http://pastebin.mozilla.org/3753793
After: http://pastebin.mozilla.org/3753792
Nishanth Menon (2):
net: smc91x: Read hardware behavior flags from device tree
ARM: dts: omap2430-sdp: add flags for ethernet functionality
Documentation/devicetree/bindings/net/smsc91x.txt | 45 +++++++++
arch/arm/boot/dts/omap2430-sdp.dts | 5 +
drivers/net/ethernet/smsc/smc91x.c | 106 ++++++++++++++++++++-
3 files changed, 155 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/smsc91x.txt
Regards,
Nishanth Menon
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 0/2] net: smc91x: add DT flags for legacy platforms
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Benoît Cousson, Tony Lindgren, Nishanth Menon
Hi,
SMC91x driver has been converted to device tree, however users of
older lan91c94 based platform need description provided previously by
platform_data. Without this, ethernet fails to function on these platforms.
For example, on SDP2430:
Before: http://pastebin.mozilla.org/3753793
After: http://pastebin.mozilla.org/3753792
Nishanth Menon (2):
net: smc91x: Read hardware behavior flags from device tree
ARM: dts: omap2430-sdp: add flags for ethernet functionality
Documentation/devicetree/bindings/net/smsc91x.txt | 45 +++++++++
arch/arm/boot/dts/omap2430-sdp.dts | 5 +
drivers/net/ethernet/smsc/smc91x.c | 106 ++++++++++++++++++++-
3 files changed, 155 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/smsc91x.txt
Regards,
Nishanth Menon
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 0/2] net: smc91x: add DT flags for legacy platforms
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
SMC91x driver has been converted to device tree, however users of
older lan91c94 based platform need description provided previously by
platform_data. Without this, ethernet fails to function on these platforms.
For example, on SDP2430:
Before: http://pastebin.mozilla.org/3753793
After: http://pastebin.mozilla.org/3753792
Nishanth Menon (2):
net: smc91x: Read hardware behavior flags from device tree
ARM: dts: omap2430-sdp: add flags for ethernet functionality
Documentation/devicetree/bindings/net/smsc91x.txt | 45 +++++++++
arch/arm/boot/dts/omap2430-sdp.dts | 5 +
drivers/net/ethernet/smsc/smc91x.c | 106 ++++++++++++++++++++-
3 files changed, 155 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/smsc91x.txt
Regards,
Nishanth Menon
--
1.7.9.5
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
2013-12-11 10:21 ` Nishanth Menon
(?)
@ 2013-12-11 10:21 ` Nishanth Menon
-1 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree, linux-omap, netdev
Cc: linux-doc, linux-kernel, linux-arm-kernel, Benoît Cousson,
Tony Lindgren, Nishanth Menon
commit 682a169 (smc91x: add devicetree support) introduced basic
device tree support in the form of identifier match. However,
platform_data flags equivalent was not introduced, nor was an
appropriate bindings document introduced.
In many legacy platforms such as Texas Instrument's SDP2430,
platform_data flags have been used to describe the hardware behavior.
So, introduce the legacy equivalent flags and bindings document to
handle the transition to device tree enabled boot.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
I am open to the suggestion to make smsc,leda|b macro based value instead of
the current string based option.
If it is prefered, i could move the bindings off to it's own patch as
well. Currently this is squashed as it makes more sense to read in
context.
Documentation/devicetree/bindings/net/smsc91x.txt | 45 +++++++++
drivers/net/ethernet/smsc/smc91x.c | 106 ++++++++++++++++++++-
2 files changed, 150 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/smsc91x.txt
diff --git a/Documentation/devicetree/bindings/net/smsc91x.txt b/Documentation/devicetree/bindings/net/smsc91x.txt
new file mode 100644
index 0000000..389b807
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/smsc91x.txt
@@ -0,0 +1,45 @@
+* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
+
+Required properties:
+- compatible : Should be one of:
+ "smsc,lan91c94"
+ "smsc,lan91c111"
+- reg : Address and length of the io space for SMSC LAN
+- interrupts : Should contain SMSC LAN interrupt line
+- interrupt-parent : Should be the phandle for the interrupt controller
+ that services interrupts for this device
+
+Optional properties:
+- reg-shift : Specify the quantity to shift the register offsets by
+- reg-io-width : Specify the size (in bytes) of the IO accesses that
+ should be performed on the device. Valid value for SMSC LAN is
+ 1, 2 or 4.
+- smsc,nowait : bool for fast accesses and no extra wait cycles
+- "smsc,leda" "smsc,ledb": string indicating when to glow led a or b, one of:
+ "100_10" : 100Mbps OR's with 10Mbps link detect
+ "10" : 10Mbps link detect
+ "100" : 100Mbps link detect
+ "FD" : Full Duplex Mode
+ "TX_RX" : TX or RX packet occurred
+ "TX" : TX packet occurred
+ "RX" : RX packet occurred
+
+Examples:
+
+ethernet@gpmc {
+ compatible = "smsc,lan91c94";
+ reg = <5 0x300 0xf>;
+ reg-io-width = <2>;
+ interrupt-parent = <&gpio5>;
+ interrupts = <21 IRQ_TYPE_LEVEL_LOW>; /* gpio149 */
+ smsc,nowait;
+ smsc,leda = "100_10";
+ smsc,ledb = "TX_RX";
+};
+
+ethernet@c8000000 {
+ compatible = "smsc,lan91c111";
+ reg = <0xc8000000 0x10>;
+ interrupt-parent = <&pic>;
+ interrupts = <27>;
+};
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 0c9b5d9..98ed8c5 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2184,6 +2184,101 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
}
}
+#if ENABLED(CONFIG_OF)
+static int smc_of_led_string(const char *val)
+{
+ if (!strcmp(val, "100_10"))
+ return RPC_LED_100_10;
+ else if (!strcmp(val, "10"))
+ return RPC_LED_10;
+ else if (!strcmp(val, "100"))
+ return RPC_LED_100;
+ else if (!strcmp(val, "FD"))
+ return RPC_LED_FD;
+ else if (!strcmp(val, "TX_RX"))
+ return RPC_LED_TX_RX;
+ else if (!strcmp(val, "TX"))
+ return RPC_LED_TX;
+ else if (!strcmp(val, "RX"))
+ return RPC_LED_RX;
+
+ return -1;
+}
+
+static struct smc91x_platdata *smc_of_pdata(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ unsigned long flags = 0;
+ int io_shift, io_width;
+ int led_a = -1, led_b = -1;
+ const char *led_prop;
+ struct smc91x_platdata *pd = NULL;
+
+ if (!of_property_read_u32(np, "reg-io-width", &io_width)) {
+ switch (io_width) {
+ case 1:
+ flags |= SMC91X_USE_8BIT;
+ break;
+ case 2:
+ flags |= SMC91X_USE_16BIT;
+ break;
+ case 4:
+ flags |= SMC91X_USE_32BIT;
+ break;
+ default:
+ dev_err(dev, "reg-io-width %d should be 1, 2 or 4\n",
+ io_width);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
+ if (!of_property_read_u32(np, "reg-shift", &io_shift)) {
+ if (io_shift > 3) {
+ dev_err(dev, "reg-shift %d should be <= 3\n",
+ io_shift);
+ return ERR_PTR(-EINVAL);
+ }
+ flags |= io_shift << 4;
+ }
+
+ flags |= of_property_read_bool(np, "smsc,nowait") ? SMC91X_NOWAIT : 0;
+
+ if (!of_property_read_string(np, "smsc,leda", &led_prop)) {
+ led_a = smc_of_led_string(led_prop);
+ if (led_a < 0) {
+ dev_err(dev, "smsc,leda %s unknown value\n", led_prop);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+ if (!of_property_read_string(np, "smsc,ledb", &led_prop)) {
+ led_b = smc_of_led_string(led_prop);
+ if (led_a < 0) {
+ dev_err(dev, "smsc,ledb %s unknown value\n", led_prop);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
+ if (flags || led_a >= 0 || led_b >= 0) {
+ pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return ERR_PTR(-ENOMEM);
+
+ pd->flags = flags;
+ if (led_a >= 0)
+ pd->leda = led_a;
+ if (led_b >= 0)
+ pd->ledb = led_b;
+ }
+
+ return pd;
+}
+#else
+static inline struct smc91x_platdata *smc_of_pdata(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
/*
* smc_init(void)
* Input parameters:
@@ -2197,7 +2292,8 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
*/
static int smc_drv_probe(struct platform_device *pdev)
{
- struct smc91x_platdata *pd = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct smc91x_platdata *pd = dev_get_platdata(dev);
struct smc_local *lp;
struct net_device *ndev;
struct resource *res, *ires;
@@ -2205,6 +2301,14 @@ static int smc_drv_probe(struct platform_device *pdev)
unsigned long irq_flags = SMC_IRQ_FLAGS;
int ret;
+ if (dev->of_node) {
+ pd = smc_of_pdata(dev);
+ if (IS_ERR(pd)) {
+ ret = PTR_ERR(pd);
+ goto out;
+ }
+ }
+
ndev = alloc_etherdev(sizeof(struct smc_local));
if (!ndev) {
ret = -ENOMEM;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree, linux-omap, netdev
Cc: linux-doc, linux-kernel, linux-arm-kernel, Benoît Cousson,
Tony Lindgren, Nishanth Menon
commit 682a169 (smc91x: add devicetree support) introduced basic
device tree support in the form of identifier match. However,
platform_data flags equivalent was not introduced, nor was an
appropriate bindings document introduced.
In many legacy platforms such as Texas Instrument's SDP2430,
platform_data flags have been used to describe the hardware behavior.
So, introduce the legacy equivalent flags and bindings document to
handle the transition to device tree enabled boot.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
I am open to the suggestion to make smsc,leda|b macro based value instead of
the current string based option.
If it is prefered, i could move the bindings off to it's own patch as
well. Currently this is squashed as it makes more sense to read in
context.
Documentation/devicetree/bindings/net/smsc91x.txt | 45 +++++++++
drivers/net/ethernet/smsc/smc91x.c | 106 ++++++++++++++++++++-
2 files changed, 150 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/smsc91x.txt
diff --git a/Documentation/devicetree/bindings/net/smsc91x.txt b/Documentation/devicetree/bindings/net/smsc91x.txt
new file mode 100644
index 0000000..389b807
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/smsc91x.txt
@@ -0,0 +1,45 @@
+* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
+
+Required properties:
+- compatible : Should be one of:
+ "smsc,lan91c94"
+ "smsc,lan91c111"
+- reg : Address and length of the io space for SMSC LAN
+- interrupts : Should contain SMSC LAN interrupt line
+- interrupt-parent : Should be the phandle for the interrupt controller
+ that services interrupts for this device
+
+Optional properties:
+- reg-shift : Specify the quantity to shift the register offsets by
+- reg-io-width : Specify the size (in bytes) of the IO accesses that
+ should be performed on the device. Valid value for SMSC LAN is
+ 1, 2 or 4.
+- smsc,nowait : bool for fast accesses and no extra wait cycles
+- "smsc,leda" "smsc,ledb": string indicating when to glow led a or b, one of:
+ "100_10" : 100Mbps OR's with 10Mbps link detect
+ "10" : 10Mbps link detect
+ "100" : 100Mbps link detect
+ "FD" : Full Duplex Mode
+ "TX_RX" : TX or RX packet occurred
+ "TX" : TX packet occurred
+ "RX" : RX packet occurred
+
+Examples:
+
+ethernet@gpmc {
+ compatible = "smsc,lan91c94";
+ reg = <5 0x300 0xf>;
+ reg-io-width = <2>;
+ interrupt-parent = <&gpio5>;
+ interrupts = <21 IRQ_TYPE_LEVEL_LOW>; /* gpio149 */
+ smsc,nowait;
+ smsc,leda = "100_10";
+ smsc,ledb = "TX_RX";
+};
+
+ethernet@c8000000 {
+ compatible = "smsc,lan91c111";
+ reg = <0xc8000000 0x10>;
+ interrupt-parent = <&pic>;
+ interrupts = <27>;
+};
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 0c9b5d9..98ed8c5 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2184,6 +2184,101 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
}
}
+#if ENABLED(CONFIG_OF)
+static int smc_of_led_string(const char *val)
+{
+ if (!strcmp(val, "100_10"))
+ return RPC_LED_100_10;
+ else if (!strcmp(val, "10"))
+ return RPC_LED_10;
+ else if (!strcmp(val, "100"))
+ return RPC_LED_100;
+ else if (!strcmp(val, "FD"))
+ return RPC_LED_FD;
+ else if (!strcmp(val, "TX_RX"))
+ return RPC_LED_TX_RX;
+ else if (!strcmp(val, "TX"))
+ return RPC_LED_TX;
+ else if (!strcmp(val, "RX"))
+ return RPC_LED_RX;
+
+ return -1;
+}
+
+static struct smc91x_platdata *smc_of_pdata(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ unsigned long flags = 0;
+ int io_shift, io_width;
+ int led_a = -1, led_b = -1;
+ const char *led_prop;
+ struct smc91x_platdata *pd = NULL;
+
+ if (!of_property_read_u32(np, "reg-io-width", &io_width)) {
+ switch (io_width) {
+ case 1:
+ flags |= SMC91X_USE_8BIT;
+ break;
+ case 2:
+ flags |= SMC91X_USE_16BIT;
+ break;
+ case 4:
+ flags |= SMC91X_USE_32BIT;
+ break;
+ default:
+ dev_err(dev, "reg-io-width %d should be 1, 2 or 4\n",
+ io_width);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
+ if (!of_property_read_u32(np, "reg-shift", &io_shift)) {
+ if (io_shift > 3) {
+ dev_err(dev, "reg-shift %d should be <= 3\n",
+ io_shift);
+ return ERR_PTR(-EINVAL);
+ }
+ flags |= io_shift << 4;
+ }
+
+ flags |= of_property_read_bool(np, "smsc,nowait") ? SMC91X_NOWAIT : 0;
+
+ if (!of_property_read_string(np, "smsc,leda", &led_prop)) {
+ led_a = smc_of_led_string(led_prop);
+ if (led_a < 0) {
+ dev_err(dev, "smsc,leda %s unknown value\n", led_prop);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+ if (!of_property_read_string(np, "smsc,ledb", &led_prop)) {
+ led_b = smc_of_led_string(led_prop);
+ if (led_a < 0) {
+ dev_err(dev, "smsc,ledb %s unknown value\n", led_prop);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
+ if (flags || led_a >= 0 || led_b >= 0) {
+ pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return ERR_PTR(-ENOMEM);
+
+ pd->flags = flags;
+ if (led_a >= 0)
+ pd->leda = led_a;
+ if (led_b >= 0)
+ pd->ledb = led_b;
+ }
+
+ return pd;
+}
+#else
+static inline struct smc91x_platdata *smc_of_pdata(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
/*
* smc_init(void)
* Input parameters:
@@ -2197,7 +2292,8 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
*/
static int smc_drv_probe(struct platform_device *pdev)
{
- struct smc91x_platdata *pd = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct smc91x_platdata *pd = dev_get_platdata(dev);
struct smc_local *lp;
struct net_device *ndev;
struct resource *res, *ires;
@@ -2205,6 +2301,14 @@ static int smc_drv_probe(struct platform_device *pdev)
unsigned long irq_flags = SMC_IRQ_FLAGS;
int ret;
+ if (dev->of_node) {
+ pd = smc_of_pdata(dev);
+ if (IS_ERR(pd)) {
+ ret = PTR_ERR(pd);
+ goto out;
+ }
+ }
+
ndev = alloc_etherdev(sizeof(struct smc_local));
if (!ndev) {
ret = -ENOMEM;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: linux-arm-kernel
commit 682a169 (smc91x: add devicetree support) introduced basic
device tree support in the form of identifier match. However,
platform_data flags equivalent was not introduced, nor was an
appropriate bindings document introduced.
In many legacy platforms such as Texas Instrument's SDP2430,
platform_data flags have been used to describe the hardware behavior.
So, introduce the legacy equivalent flags and bindings document to
handle the transition to device tree enabled boot.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
I am open to the suggestion to make smsc,leda|b macro based value instead of
the current string based option.
If it is prefered, i could move the bindings off to it's own patch as
well. Currently this is squashed as it makes more sense to read in
context.
Documentation/devicetree/bindings/net/smsc91x.txt | 45 +++++++++
drivers/net/ethernet/smsc/smc91x.c | 106 ++++++++++++++++++++-
2 files changed, 150 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/net/smsc91x.txt
diff --git a/Documentation/devicetree/bindings/net/smsc91x.txt b/Documentation/devicetree/bindings/net/smsc91x.txt
new file mode 100644
index 0000000..389b807
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/smsc91x.txt
@@ -0,0 +1,45 @@
+* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
+
+Required properties:
+- compatible : Should be one of:
+ "smsc,lan91c94"
+ "smsc,lan91c111"
+- reg : Address and length of the io space for SMSC LAN
+- interrupts : Should contain SMSC LAN interrupt line
+- interrupt-parent : Should be the phandle for the interrupt controller
+ that services interrupts for this device
+
+Optional properties:
+- reg-shift : Specify the quantity to shift the register offsets by
+- reg-io-width : Specify the size (in bytes) of the IO accesses that
+ should be performed on the device. Valid value for SMSC LAN is
+ 1, 2 or 4.
+- smsc,nowait : bool for fast accesses and no extra wait cycles
+- "smsc,leda" "smsc,ledb": string indicating when to glow led a or b, one of:
+ "100_10" : 100Mbps OR's with 10Mbps link detect
+ "10" : 10Mbps link detect
+ "100" : 100Mbps link detect
+ "FD" : Full Duplex Mode
+ "TX_RX" : TX or RX packet occurred
+ "TX" : TX packet occurred
+ "RX" : RX packet occurred
+
+Examples:
+
+ethernet at gpmc {
+ compatible = "smsc,lan91c94";
+ reg = <5 0x300 0xf>;
+ reg-io-width = <2>;
+ interrupt-parent = <&gpio5>;
+ interrupts = <21 IRQ_TYPE_LEVEL_LOW>; /* gpio149 */
+ smsc,nowait;
+ smsc,leda = "100_10";
+ smsc,ledb = "TX_RX";
+};
+
+ethernet at c8000000 {
+ compatible = "smsc,lan91c111";
+ reg = <0xc8000000 0x10>;
+ interrupt-parent = <&pic>;
+ interrupts = <27>;
+};
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 0c9b5d9..98ed8c5 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2184,6 +2184,101 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
}
}
+#if ENABLED(CONFIG_OF)
+static int smc_of_led_string(const char *val)
+{
+ if (!strcmp(val, "100_10"))
+ return RPC_LED_100_10;
+ else if (!strcmp(val, "10"))
+ return RPC_LED_10;
+ else if (!strcmp(val, "100"))
+ return RPC_LED_100;
+ else if (!strcmp(val, "FD"))
+ return RPC_LED_FD;
+ else if (!strcmp(val, "TX_RX"))
+ return RPC_LED_TX_RX;
+ else if (!strcmp(val, "TX"))
+ return RPC_LED_TX;
+ else if (!strcmp(val, "RX"))
+ return RPC_LED_RX;
+
+ return -1;
+}
+
+static struct smc91x_platdata *smc_of_pdata(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ unsigned long flags = 0;
+ int io_shift, io_width;
+ int led_a = -1, led_b = -1;
+ const char *led_prop;
+ struct smc91x_platdata *pd = NULL;
+
+ if (!of_property_read_u32(np, "reg-io-width", &io_width)) {
+ switch (io_width) {
+ case 1:
+ flags |= SMC91X_USE_8BIT;
+ break;
+ case 2:
+ flags |= SMC91X_USE_16BIT;
+ break;
+ case 4:
+ flags |= SMC91X_USE_32BIT;
+ break;
+ default:
+ dev_err(dev, "reg-io-width %d should be 1, 2 or 4\n",
+ io_width);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
+ if (!of_property_read_u32(np, "reg-shift", &io_shift)) {
+ if (io_shift > 3) {
+ dev_err(dev, "reg-shift %d should be <= 3\n",
+ io_shift);
+ return ERR_PTR(-EINVAL);
+ }
+ flags |= io_shift << 4;
+ }
+
+ flags |= of_property_read_bool(np, "smsc,nowait") ? SMC91X_NOWAIT : 0;
+
+ if (!of_property_read_string(np, "smsc,leda", &led_prop)) {
+ led_a = smc_of_led_string(led_prop);
+ if (led_a < 0) {
+ dev_err(dev, "smsc,leda %s unknown value\n", led_prop);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+ if (!of_property_read_string(np, "smsc,ledb", &led_prop)) {
+ led_b = smc_of_led_string(led_prop);
+ if (led_a < 0) {
+ dev_err(dev, "smsc,ledb %s unknown value\n", led_prop);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
+ if (flags || led_a >= 0 || led_b >= 0) {
+ pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return ERR_PTR(-ENOMEM);
+
+ pd->flags = flags;
+ if (led_a >= 0)
+ pd->leda = led_a;
+ if (led_b >= 0)
+ pd->ledb = led_b;
+ }
+
+ return pd;
+}
+#else
+static inline struct smc91x_platdata *smc_of_pdata(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
/*
* smc_init(void)
* Input parameters:
@@ -2197,7 +2292,8 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
*/
static int smc_drv_probe(struct platform_device *pdev)
{
- struct smc91x_platdata *pd = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct smc91x_platdata *pd = dev_get_platdata(dev);
struct smc_local *lp;
struct net_device *ndev;
struct resource *res, *ires;
@@ -2205,6 +2301,14 @@ static int smc_drv_probe(struct platform_device *pdev)
unsigned long irq_flags = SMC_IRQ_FLAGS;
int ret;
+ if (dev->of_node) {
+ pd = smc_of_pdata(dev);
+ if (IS_ERR(pd)) {
+ ret = PTR_ERR(pd);
+ goto out;
+ }
+ }
+
ndev = alloc_etherdev(sizeof(struct smc_local));
if (!ndev) {
ret = -ENOMEM;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] ARM: dts: omap2430-sdp: add flags for ethernet functionality
2013-12-11 10:21 ` Nishanth Menon
(?)
(?)
@ 2013-12-11 10:21 ` Nishanth Menon
-1 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree, linux-omap, netdev
Cc: linux-doc, linux-kernel, linux-arm-kernel, Benoît Cousson,
Tony Lindgren, Nishanth Menon
Ethernet transition from board file to dts missed the required pdata
conversion. So fix the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/boot/dts/omap2430-sdp.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/omap2430-sdp.dts b/arch/arm/boot/dts/omap2430-sdp.dts
index 2c90d29..ec9263a 100644
--- a/arch/arm/boot/dts/omap2430-sdp.dts
+++ b/arch/arm/boot/dts/omap2430-sdp.dts
@@ -39,6 +39,11 @@
ranges = <5 0 0x08000000 0x01000000>;
ethernet@gpmc {
compatible = "smsc,lan91c94";
+ reg-io-width = <2>;
+ smsc,nowait;
+ smsc,leda = "100_10";
+ smsc,ledb = "TX_RX";
+
interrupt-parent = <&gpio5>;
interrupts = <21 IRQ_TYPE_LEVEL_LOW>; /* gpio149 */
reg = <5 0x300 0xf>;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] ARM: dts: omap2430-sdp: add flags for ethernet functionality
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree, linux-omap, netdev
Cc: Nishanth Menon, linux-doc, Tony Lindgren, linux-kernel,
Benoît Cousson, linux-arm-kernel
Ethernet transition from board file to dts missed the required pdata
conversion. So fix the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/boot/dts/omap2430-sdp.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/omap2430-sdp.dts b/arch/arm/boot/dts/omap2430-sdp.dts
index 2c90d29..ec9263a 100644
--- a/arch/arm/boot/dts/omap2430-sdp.dts
+++ b/arch/arm/boot/dts/omap2430-sdp.dts
@@ -39,6 +39,11 @@
ranges = <5 0 0x08000000 0x01000000>;
ethernet@gpmc {
compatible = "smsc,lan91c94";
+ reg-io-width = <2>;
+ smsc,nowait;
+ smsc,leda = "100_10";
+ smsc,ledb = "TX_RX";
+
interrupt-parent = <&gpio5>;
interrupts = <21 IRQ_TYPE_LEVEL_LOW>; /* gpio149 */
reg = <5 0x300 0xf>;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] ARM: dts: omap2430-sdp: add flags for ethernet functionality
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: devicetree, linux-omap, netdev
Cc: Nishanth Menon, linux-doc, Tony Lindgren, linux-kernel,
Benoît Cousson, linux-arm-kernel
Ethernet transition from board file to dts missed the required pdata
conversion. So fix the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/boot/dts/omap2430-sdp.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/omap2430-sdp.dts b/arch/arm/boot/dts/omap2430-sdp.dts
index 2c90d29..ec9263a 100644
--- a/arch/arm/boot/dts/omap2430-sdp.dts
+++ b/arch/arm/boot/dts/omap2430-sdp.dts
@@ -39,6 +39,11 @@
ranges = <5 0 0x08000000 0x01000000>;
ethernet@gpmc {
compatible = "smsc,lan91c94";
+ reg-io-width = <2>;
+ smsc,nowait;
+ smsc,leda = "100_10";
+ smsc,ledb = "TX_RX";
+
interrupt-parent = <&gpio5>;
interrupts = <21 IRQ_TYPE_LEVEL_LOW>; /* gpio149 */
reg = <5 0x300 0xf>;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/2] ARM: dts: omap2430-sdp: add flags for ethernet functionality
@ 2013-12-11 10:21 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 10:21 UTC (permalink / raw)
To: linux-arm-kernel
Ethernet transition from board file to dts missed the required pdata
conversion. So fix the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/boot/dts/omap2430-sdp.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/omap2430-sdp.dts b/arch/arm/boot/dts/omap2430-sdp.dts
index 2c90d29..ec9263a 100644
--- a/arch/arm/boot/dts/omap2430-sdp.dts
+++ b/arch/arm/boot/dts/omap2430-sdp.dts
@@ -39,6 +39,11 @@
ranges = <5 0 0x08000000 0x01000000>;
ethernet at gpmc {
compatible = "smsc,lan91c94";
+ reg-io-width = <2>;
+ smsc,nowait;
+ smsc,leda = "100_10";
+ smsc,ledb = "TX_RX";
+
interrupt-parent = <&gpio5>;
interrupts = <21 IRQ_TYPE_LEVEL_LOW>; /* gpio149 */
reg = <5 0x300 0xf>;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
2013-12-11 10:21 ` Nishanth Menon
@ 2013-12-11 16:04 ` Tony Lindgren
-1 siblings, 0 replies; 16+ messages in thread
From: Tony Lindgren @ 2013-12-11 16:04 UTC (permalink / raw)
To: Nishanth Menon
Cc: devicetree, linux-omap, netdev, linux-doc, linux-kernel,
linux-arm-kernel, Benoît Cousson
* Nishanth Menon <nm@ti.com> [131211 02:23]:
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/smsc91x.txt
> @@ -0,0 +1,45 @@
> +* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
> +
> +Required properties:
> +- compatible : Should be one of:
> + "smsc,lan91c94"
> + "smsc,lan91c111"
> +- reg : Address and length of the io space for SMSC LAN
> +- interrupts : Should contain SMSC LAN interrupt line
> +- interrupt-parent : Should be the phandle for the interrupt controller
> + that services interrupts for this device
> +
> +Optional properties:
> +- reg-shift : Specify the quantity to shift the register offsets by
> +- reg-io-width : Specify the size (in bytes) of the IO accesses that
> + should be performed on the device. Valid value for SMSC LAN is
> + 1, 2 or 4.
I posted a minimal regression fix for this a few weeks ago that we
should merge to the v3.13-rc cycle:
http://www.spinics.net/lists/netdev/msg258913.html
Care to ack that one? Then if that works for you, maybe rebase these on
that one for the upcoming merge window?
Note that for the -rc cycle we don't need these extra properties as we
can get the interrupts from the struct resource after fix
4a43d686fe336c (of/irq: Pass trigger type in IRQ resource flags)
got merged.
Regards,
Tony
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
@ 2013-12-11 16:04 ` Tony Lindgren
0 siblings, 0 replies; 16+ messages in thread
From: Tony Lindgren @ 2013-12-11 16:04 UTC (permalink / raw)
To: linux-arm-kernel
* Nishanth Menon <nm@ti.com> [131211 02:23]:
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/smsc91x.txt
> @@ -0,0 +1,45 @@
> +* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
> +
> +Required properties:
> +- compatible : Should be one of:
> + "smsc,lan91c94"
> + "smsc,lan91c111"
> +- reg : Address and length of the io space for SMSC LAN
> +- interrupts : Should contain SMSC LAN interrupt line
> +- interrupt-parent : Should be the phandle for the interrupt controller
> + that services interrupts for this device
> +
> +Optional properties:
> +- reg-shift : Specify the quantity to shift the register offsets by
> +- reg-io-width : Specify the size (in bytes) of the IO accesses that
> + should be performed on the device. Valid value for SMSC LAN is
> + 1, 2 or 4.
I posted a minimal regression fix for this a few weeks ago that we
should merge to the v3.13-rc cycle:
http://www.spinics.net/lists/netdev/msg258913.html
Care to ack that one? Then if that works for you, maybe rebase these on
that one for the upcoming merge window?
Note that for the -rc cycle we don't need these extra properties as we
can get the interrupts from the struct resource after fix
4a43d686fe336c (of/irq: Pass trigger type in IRQ resource flags)
got merged.
Regards,
Tony
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
@ 2013-12-11 18:27 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 18:27 UTC (permalink / raw)
To: Tony Lindgren
Cc: dt list, linux-doc, netdev, lkml, Benoît Cousson,
linux-omap, linux-arm-kernel
On Wed, Dec 11, 2013 at 10:04 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Nishanth Menon <nm@ti.com> [131211 02:23]:
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/smsc91x.txt
>> @@ -0,0 +1,45 @@
>> +* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
>> +
>> +Required properties:
>> +- compatible : Should be one of:
>> + "smsc,lan91c94"
>> + "smsc,lan91c111"
>> +- reg : Address and length of the io space for SMSC LAN
>> +- interrupts : Should contain SMSC LAN interrupt line
>> +- interrupt-parent : Should be the phandle for the interrupt controller
>> + that services interrupts for this device
>> +
>> +Optional properties:
>> +- reg-shift : Specify the quantity to shift the register offsets by
>> +- reg-io-width : Specify the size (in bytes) of the IO accesses that
>> + should be performed on the device. Valid value for SMSC LAN is
>> + 1, 2 or 4.
>
> I posted a minimal regression fix for this a few weeks ago that we
> should merge to the v3.13-rc cycle:
>
> http://www.spinics.net/lists/netdev/msg258913.html
>
> Care to ack that one?
Done.
> Then if that works for you, maybe rebase these on
> that one for the upcoming merge window?
it seems like omap is the only folks who are currently using this
driver in dt form, I kinda proposed to do these as add on changes to
your patch, lets see if anyone cares about it.
but I agree to drop my series at this point,
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
@ 2013-12-11 18:27 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 18:27 UTC (permalink / raw)
To: Tony Lindgren
Cc: dt list, linux-doc-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA, lkml, Benoît Cousson,
linux-omap, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Wed, Dec 11, 2013 at 10:04 AM, Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> wrote:
> * Nishanth Menon <nm-l0cyMroinI0@public.gmane.org> [131211 02:23]:
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/smsc91x.txt
>> @@ -0,0 +1,45 @@
>> +* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
>> +
>> +Required properties:
>> +- compatible : Should be one of:
>> + "smsc,lan91c94"
>> + "smsc,lan91c111"
>> +- reg : Address and length of the io space for SMSC LAN
>> +- interrupts : Should contain SMSC LAN interrupt line
>> +- interrupt-parent : Should be the phandle for the interrupt controller
>> + that services interrupts for this device
>> +
>> +Optional properties:
>> +- reg-shift : Specify the quantity to shift the register offsets by
>> +- reg-io-width : Specify the size (in bytes) of the IO accesses that
>> + should be performed on the device. Valid value for SMSC LAN is
>> + 1, 2 or 4.
>
> I posted a minimal regression fix for this a few weeks ago that we
> should merge to the v3.13-rc cycle:
>
> http://www.spinics.net/lists/netdev/msg258913.html
>
> Care to ack that one?
Done.
> Then if that works for you, maybe rebase these on
> that one for the upcoming merge window?
it seems like omap is the only folks who are currently using this
driver in dt form, I kinda proposed to do these as add on changes to
your patch, lets see if anyone cares about it.
but I agree to drop my series at this point,
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree
@ 2013-12-11 18:27 ` Nishanth Menon
0 siblings, 0 replies; 16+ messages in thread
From: Nishanth Menon @ 2013-12-11 18:27 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Dec 11, 2013 at 10:04 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Nishanth Menon <nm@ti.com> [131211 02:23]:
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/smsc91x.txt
>> @@ -0,0 +1,45 @@
>> +* Smart Mixed-Signal Connectivity (SMSC) LAN91c94/91c111 Controller
>> +
>> +Required properties:
>> +- compatible : Should be one of:
>> + "smsc,lan91c94"
>> + "smsc,lan91c111"
>> +- reg : Address and length of the io space for SMSC LAN
>> +- interrupts : Should contain SMSC LAN interrupt line
>> +- interrupt-parent : Should be the phandle for the interrupt controller
>> + that services interrupts for this device
>> +
>> +Optional properties:
>> +- reg-shift : Specify the quantity to shift the register offsets by
>> +- reg-io-width : Specify the size (in bytes) of the IO accesses that
>> + should be performed on the device. Valid value for SMSC LAN is
>> + 1, 2 or 4.
>
> I posted a minimal regression fix for this a few weeks ago that we
> should merge to the v3.13-rc cycle:
>
> http://www.spinics.net/lists/netdev/msg258913.html
>
> Care to ack that one?
Done.
> Then if that works for you, maybe rebase these on
> that one for the upcoming merge window?
it seems like omap is the only folks who are currently using this
driver in dt form, I kinda proposed to do these as add on changes to
your patch, lets see if anyone cares about it.
but I agree to drop my series at this point,
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2013-12-11 18:27 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-11 10:21 [PATCH 0/2] net: smc91x: add DT flags for legacy platforms Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
2013-12-11 10:21 ` [PATCH 1/2] net: smc91x: Read hardware behavior flags from device tree Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
2013-12-11 16:04 ` Tony Lindgren
2013-12-11 16:04 ` Tony Lindgren
2013-12-11 18:27 ` Nishanth Menon
2013-12-11 18:27 ` Nishanth Menon
2013-12-11 18:27 ` Nishanth Menon
2013-12-11 10:21 ` [PATCH 2/2] ARM: dts: omap2430-sdp: add flags for ethernet functionality Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
2013-12-11 10:21 ` Nishanth Menon
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.