* [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support
@ 2019-06-12 12:25 Nicolas Saenz Julienne
2019-06-12 12:25 ` [PATCH v2 2/2] dt-bindings: net: wiznet: add w5x00 support Nicolas Saenz Julienne
2019-06-12 16:52 ` [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2019-06-12 12:25 UTC (permalink / raw)
To: linux-kernel; +Cc: Nicolas Saenz Julienne, David S. Miller, netdev
The w5X00 chip provides an SPI to Ethernet inteface. This patch allows
platform devices to be defined through the device tree.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
drivers/net/ethernet/wiznet/w5100-spi.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/wiznet/w5100-spi.c b/drivers/net/ethernet/wiznet/w5100-spi.c
index 918b3e50850a..2b4126d2427d 100644
--- a/drivers/net/ethernet/wiznet/w5100-spi.c
+++ b/drivers/net/ethernet/wiznet/w5100-spi.c
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/of_net.h>
+#include <linux/of_device.h>
#include <linux/spi/spi.h>
#include "w5100.h"
@@ -409,14 +410,32 @@ static const struct w5100_ops w5500_ops = {
.init = w5500_spi_init,
};
+static const struct of_device_id w5100_of_match[] = {
+ { .compatible = "wiznet,w5100", .data = (const void*)W5100, },
+ { .compatible = "wiznet,w5200", .data = (const void*)W5200, },
+ { .compatible = "wiznet,w5500", .data = (const void*)W5500, },
+ { },
+};
+MODULE_DEVICE_TABLE(of, w5100_of_match);
+
static int w5100_spi_probe(struct spi_device *spi)
{
- const struct spi_device_id *id = spi_get_device_id(spi);
+ const struct of_device_id *of_id;
const struct w5100_ops *ops;
+ kernel_ulong_t driver_data;
int priv_size;
const void *mac = of_get_mac_address(spi->dev.of_node);
- switch (id->driver_data) {
+ if (spi->dev.of_node) {
+ of_id = of_match_device(w5100_of_match, &spi->dev);
+ if (!of_id)
+ return -ENODEV;
+ driver_data = (kernel_ulong_t)of_id->data;
+ } else {
+ driver_data = spi_get_device_id(spi)->driver_data;
+ }
+
+ switch (driver_data) {
case W5100:
ops = &w5100_spi_ops;
priv_size = 0;
@@ -453,6 +472,7 @@ static struct spi_driver w5100_spi_driver = {
.driver = {
.name = "w5100",
.pm = &w5100_pm_ops,
+ .of_match_table = w5100_of_match,
},
.probe = w5100_spi_probe,
.remove = w5100_spi_remove,
--
2.21.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] dt-bindings: net: wiznet: add w5x00 support
2019-06-12 12:25 [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support Nicolas Saenz Julienne
@ 2019-06-12 12:25 ` Nicolas Saenz Julienne
2019-06-12 16:52 ` David Miller
2019-06-12 16:52 ` [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2019-06-12 12:25 UTC (permalink / raw)
To: David S. Miller
Cc: Nicolas Saenz Julienne, Rob Herring, Mark Rutland, netdev,
devicetree, linux-kernel
Add bindings for Wiznet's w5x00 series of SPI interfaced Ethernet chips.
Based on the bindings for microchip,enc28j60.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
Changes since v1:
- one compatible sting per line
- use correct 'ethenet@0' phandle name
.../devicetree/bindings/net/wiznet,w5x00.txt | 51 +++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/wiznet,w5x00.txt
diff --git a/Documentation/devicetree/bindings/net/wiznet,w5x00.txt b/Documentation/devicetree/bindings/net/wiznet,w5x00.txt
new file mode 100644
index 000000000000..901946dea3de
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wiznet,w5x00.txt
@@ -0,0 +1,51 @@
+* Wiznet w5x00
+
+This is a standalone 10/100 MBit Ethernet controller with SPI interface.
+
+For each device connected to a SPI bus, define a child node within
+the SPI master node.
+
+Required properties:
+- compatible: Should be one of the following strings:
+ "wiznet,w5100"
+ "wiznet,w5200"
+ "wiznet,w5500"
+- reg: Specify the SPI chip select the chip is wired to.
+- interrupts: Specify the interrupt index within the interrupt controller (referred
+ to above in interrupt-parent) and interrupt type. w5x00 natively
+ generates falling edge interrupts, however, additional board logic
+ might invert the signal.
+- pinctrl-names: List of assigned state names, see pinctrl binding documentation.
+- pinctrl-0: List of phandles to configure the GPIO pin used as interrupt line,
+ see also generic and your platform specific pinctrl binding
+ documentation.
+
+Optional properties:
+- spi-max-frequency: Maximum frequency of the SPI bus when accessing the w5500.
+ According to the w5500 datasheet, the chip allows a maximum of 80 MHz, however,
+ board designs may need to limit this value.
+- local-mac-address: See ethernet.txt in the same directory.
+
+
+Example (for Raspberry Pi with pin control stuff for GPIO irq):
+
+&spi {
+ ethernet@0: w5500@0 {
+ compatible = "wiznet,w5500";
+ reg = <0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <ð1_pins>;
+ interrupt-parent = <&gpio>;
+ interrupts = <25 IRQ_TYPE_EDGE_FALLING>;
+ spi-max-frequency = <30000000>;
+ };
+};
+
+&gpio {
+ eth1_pins: eth1_pins {
+ brcm,pins = <25>;
+ brcm,function = <0>; /* in */
+ brcm,pull = <0>; /* none */
+ };
+};
+
--
2.21.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support
2019-06-12 12:25 [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support Nicolas Saenz Julienne
2019-06-12 12:25 ` [PATCH v2 2/2] dt-bindings: net: wiznet: add w5x00 support Nicolas Saenz Julienne
@ 2019-06-12 16:52 ` David Miller
2019-06-12 16:53 ` Nicolas Saenz Julienne
1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2019-06-12 16:52 UTC (permalink / raw)
To: nsaenzjulienne; +Cc: linux-kernel, netdev
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Date: Wed, 12 Jun 2019 14:25:25 +0200
> The w5X00 chip provides an SPI to Ethernet inteface. This patch allows
> platform devices to be defined through the device tree.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Applied to net-next.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] dt-bindings: net: wiznet: add w5x00 support
2019-06-12 12:25 ` [PATCH v2 2/2] dt-bindings: net: wiznet: add w5x00 support Nicolas Saenz Julienne
@ 2019-06-12 16:52 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-06-12 16:52 UTC (permalink / raw)
To: nsaenzjulienne; +Cc: robh+dt, mark.rutland, netdev, devicetree, linux-kernel
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Date: Wed, 12 Jun 2019 14:25:27 +0200
> Add bindings for Wiznet's w5x00 series of SPI interfaced Ethernet chips.
>
> Based on the bindings for microchip,enc28j60.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Applied to net-next.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support
2019-06-12 16:52 ` [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support David Miller
@ 2019-06-12 16:53 ` Nicolas Saenz Julienne
0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2019-06-12 16:53 UTC (permalink / raw)
To: David Miller; +Cc: linux-kernel, netdev
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
On Wed, 2019-06-12 at 09:52 -0700, David Miller wrote:
> From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Date: Wed, 12 Jun 2019 14:25:25 +0200
>
> > The w5X00 chip provides an SPI to Ethernet inteface. This patch allows
> > platform devices to be defined through the device tree.
> >
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> Applied to net-next.
Thanks!
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-12 16:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 12:25 [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support Nicolas Saenz Julienne
2019-06-12 12:25 ` [PATCH v2 2/2] dt-bindings: net: wiznet: add w5x00 support Nicolas Saenz Julienne
2019-06-12 16:52 ` David Miller
2019-06-12 16:52 ` [PATCH v2 1/2] net: ethernet: wiznet: w5X00 add device tree support David Miller
2019-06-12 16:53 ` Nicolas Saenz Julienne
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).