mcs814x: use the standard device tree binding to represent a PHY node
authorFlorian Fainelli <florian@openwrt.org>
Sat, 16 Mar 2013 22:25:41 +0000 (22:25 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Sat, 16 Mar 2013 22:25:41 +0000 (22:25 +0000)
Signed-off-by: Florian Fainelli <florian@openwrt.org>
SVN-Revision: 36059

target/linux/mcs814x/files-3.3/arch/arm/boot/dts/dlan-usb-extender.dts
target/linux/mcs814x/files-3.3/arch/arm/boot/dts/mcs8140.dtsi
target/linux/mcs814x/files-3.3/arch/arm/boot/dts/rbt-832.dts
target/linux/mcs814x/files-3.3/drivers/net/ethernet/mcs8140/nuport_mac.c

index c8611deab714290ccd1dd0d6b62046c3dc20f733..0c85b94c0aa2bdfe7fb8dd4bf485ac3e1957fa34 100644 (file)
 
        ahb {
                vci {
+                       eth0: ethernet@40084000 {
+                               phy = <&phy0>;
+                               phy-mode = "mii";
+
+                               phy0: ethernet-phy@0 {
+                                       reg = <8>;
+                               };
+                       };
 
                        adc {
                                sdram: memory@0,0 {
index ad52d9277b69ec69dc07e7d83e0d231403c9fcd4..c52107c7dbf0d3cb64cde6687514dc4792c262aa 100644 (file)
@@ -37,6 +37,9 @@
                        ranges;
 
                        eth0: ethernet@40084000 {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
                                compatible = "moschip,nuport-mac";
                                reg = <0x40084000 0xd8          // mac
                                        0x40080000 0x58>;       // dma channels
index cc7fab8ed1d82654776f8008733633a931e3fdf5..9949c8ecf3db7a44cbc3085adc956c972aced2ef 100644 (file)
                vci {
                        eth0: ethernet@40084000 {
                                nuport-mac,link-activity = <0x01>;
+                               phy = <&phy0>;
+                               phy-mode = "mii";
+
+                               phy0: ethernet-phy@0 {
+                                       reg = <1>;
+                               };
                        };
 
                        adc {
index 2dc23751598d629ec79e94c2bd0960fa0082e409..511d261d0d86b9850227a26ba132d60909d86833 100644 (file)
@@ -19,6 +19,8 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/of_mdio.h>
+#include <linux/of_net.h>
 #include <linux/irq.h>
 #include <linux/err.h>
 #include <linux/phy.h>
@@ -168,6 +170,8 @@ struct nuport_mac_priv {
        struct platform_device  *pdev;
        struct mii_bus          *mii_bus;
        struct phy_device       *phydev;
+       struct device_node      *phy_node;
+       phy_interface_t         phy_interface;
        int                     old_link;
        int                     old_duplex;
        u32                     msg_level;
@@ -898,9 +902,9 @@ static int nuport_mac_mii_probe(struct net_device *dev)
                goto out;
        }
 
-       phydev = phy_connect(dev, dev_name(&phydev->dev),
+       phydev = of_phy_connect(dev, priv->phy_node,
                        nuport_mac_adjust_link, 0,
-                       PHY_INTERFACE_MODE_MII);
+                       priv->phy_interface);
        if (IS_ERR(phydev)) {
                netdev_err(dev, "could not attach PHY\n");
                ret = PTR_ERR(phydev);
@@ -1082,6 +1086,20 @@ static int __init nuport_mac_probe(struct platform_device *pdev)
 
        netif_napi_add(dev, &priv->napi, nuport_mac_poll, 64);
 
+       priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy", 0);
+       if (!priv->phy_node) {
+               dev_err(&pdev->dev, "no associated PHY\n");
+               ret = -ENODEV;
+               goto out;
+       }
+
+       priv->phy_interface = of_get_phy_mode(pdev->dev.of_node);
+       if (priv->phy_interface < 0) {
+               dev_err(&pdev->dev, "invalid PHY mode\n");
+               ret = -EINVAL;
+               goto out;
+       }
+
        priv->mii_bus = mdiobus_alloc();
        if (!priv->mii_bus) {
                dev_err(&pdev->dev, "mii bus allocation failed\n");
@@ -1106,7 +1124,7 @@ static int __init nuport_mac_probe(struct platform_device *pdev)
        for (i = 0; i < PHY_MAX_ADDR; i++)
                priv->mii_bus->irq[i] = PHY_IGNORE_INTERRUPT;
 
-       ret = mdiobus_register(priv->mii_bus);
+       ret = of_mdiobus_register(priv->mii_bus, pdev->dev.of_node);
        if (ret) {
                dev_err(&pdev->dev, "failed to register mii_bus\n");
                goto out_mdio_irq;