ARM: nomadik: convert SMSC91x ethernet to device tree
authorLinus Walleij <linus.walleij@linaro.org>
Sun, 6 Jan 2013 00:02:42 +0000 (01:02 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 28 Jan 2013 22:24:40 +0000 (23:24 +0100)
This converts the SMSC91x ethernet controller to use device
tree. The existing solution from the board file, to request the
GPIO triggering the ethernet IRQ from the board file is kept
for the time being, but the GPIO number assignment is moved
over to the device tree.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Documentation/devicetree/bindings/arm/ste-nomadik.txt
arch/arm/boot/dts/ste-nomadik-s8815.dts
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi
arch/arm/mach-nomadik/board-nhk8815.c
arch/arm/mach-nomadik/cpu-8815.c

index 23f32bddebf9729f5532f453278097cf388b6ab6..a97316073afef24dda669f4c88723c5cb61d167e 100644 (file)
@@ -16,4 +16,9 @@ Required node: usb-s8815
 Example:
 
 usb-s8815 {
+               ethernet-gpio {
+                       gpios = <&gpio3 19 0x1>;
+                       interrupts = <19 0x1>;
+                       interrupt-parent = <&gpio3>;
+               };
 };
index 97b7d1df5aaa5941de3996c49afcaaa9c016b63a..cc777109f98f95b762128bcf0f71f384a9a97169 100644 (file)
 
        /* Custom board node with GPIO pins to active etc */
        usb-s8815 {
+               /* The S8815 is using this very GPIO pin for the SMSC91x IRQs */
+               ethernet-gpio {
+                       gpios = <&gpio3 19 0x1>;
+                       interrupts = <19 0x1>;
+                       interrupt-parent = <&gpio3>;
+               };
        };
 };
index 2c8aaa5c6ac42aa9dd7014c2fc8e5e7b18c886d0..f129425883a44c36bce478243173480689123773 100644 (file)
                };
        };
 
+       external-bus@34000000 {
+               compatible = "simple-bus";
+               reg = <0x34000000 0x1000000>;
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges = <0 0x34000000 0x1000000>;
+               ethernet@300 {
+                       compatible = "smsc,lan91c111";
+                       reg = <0x300 0x0fd00>;
+               };
+       };
+
        amba {
                compatible = "arm,amba-bus";
                #address-cells = <1>;
index 2f2c96bee7dfb9fac94163893392d1861e877348..e7b216cb6802a45583ec2bbca913d2e3076ecdbd 100644 (file)
@@ -239,6 +239,8 @@ static int __init nhk8815_eth_init(void)
        int gpio_nr = 115; /* hardwired in the board */
        int err;
 
+       if (!machine_is_nomadik())
+               return 0;
        err = gpio_request(gpio_nr, "eth_irq");
        if (!err) err = gpio_direction_input(gpio_nr);
        if (err)
index 3a59459d6e9a98f81dd5ca8d7aba40a03f08c9c4..339496f151386948ca754071cad2778f75e1cc18 100644 (file)
 #include <linux/pinctrl/machine.h>
 #include <linux/platform_data/clocksource-nomadik-mtu.h>
 #include <linux/of_irq.h>
+#include <linux/of_gpio.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/mtd/fsmc.h>
+#include <linux/gpio.h>
 
 #include <mach/hardware.h>
 #include <mach/irqs.h>
@@ -263,6 +265,38 @@ static struct fsmc_nand_platform_data cpu8815_nand_data = {
        .nand_timings = &cpu8815_nand_timings,
 };
 
+/*
+ * The SMSC911x IRQ is connected to a GPIO pin, but the driver expects
+ * to simply request an IRQ passed as a resource. So the GPIO pin needs
+ * to be requested by this hog and set as input.
+ */
+static int __init cpu8815_eth_init(void)
+{
+       struct device_node *eth;
+       int gpio, irq, err;
+
+       eth = of_find_node_by_path("/usb-s8815/ethernet-gpio");
+       if (!eth) {
+               pr_info("could not find any ethernet GPIO\n");
+               return 0;
+       }
+       gpio = of_get_gpio(eth, 0);
+       err = gpio_request(gpio, "eth_irq");
+       if (err) {
+               pr_info("failed to request ethernet GPIO\n");
+               return -ENODEV;
+       }
+       err = gpio_direction_input(gpio);
+       if (err) {
+               pr_info("failed to set ethernet GPIO as input\n");
+               return -ENODEV;
+       }
+       irq = gpio_to_irq(gpio);
+       pr_info("enabled USB-S8815 ethernet GPIO %d, IRQ %d\n", gpio, irq);
+       return 0;
+}
+device_initcall(cpu8815_eth_init);
+
 /* These are mostly to get the right device names for the clock lookups */
 static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = {
        OF_DEV_AUXDATA("st,nomadik-gpio", NOMADIK_GPIO0_BASE,