Signed-off-by: Florian Fainelli <florian@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36059
3c298f89-4303-0410-b956-
a3cf2f4a3e73
+ eth0: ethernet@40084000 {
+ phy = <&phy0>;
+ phy-mode = "mii";
+
+ phy0: ethernet-phy@0 {
+ reg = <8>;
+ };
+ };
adc {
sdram: memory@0,0 {
adc {
sdram: memory@0,0 {
ranges;
eth0: ethernet@40084000 {
ranges;
eth0: ethernet@40084000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
compatible = "moschip,nuport-mac";
reg = <0x40084000 0xd8 // mac
0x40080000 0x58>; // dma channels
compatible = "moschip,nuport-mac";
reg = <0x40084000 0xd8 // mac
0x40080000 0x58>; // dma channels
vci {
eth0: ethernet@40084000 {
nuport-mac,link-activity = <0x01>;
vci {
eth0: ethernet@40084000 {
nuport-mac,link-activity = <0x01>;
+ phy = <&phy0>;
+ phy-mode = "mii";
+
+ phy0: ethernet-phy@0 {
+ reg = <1>;
+ };
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#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>
#include <linux/irq.h>
#include <linux/err.h>
#include <linux/phy.h>
struct platform_device *pdev;
struct mii_bus *mii_bus;
struct phy_device *phydev;
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;
int old_link;
int old_duplex;
u32 msg_level;
- phydev = phy_connect(dev, dev_name(&phydev->dev),
+ phydev = of_phy_connect(dev, priv->phy_node,
nuport_mac_adjust_link, 0,
nuport_mac_adjust_link, 0,
- PHY_INTERFACE_MODE_MII);
if (IS_ERR(phydev)) {
netdev_err(dev, "could not attach PHY\n");
ret = PTR_ERR(phydev);
if (IS_ERR(phydev)) {
netdev_err(dev, "could not attach PHY\n");
ret = PTR_ERR(phydev);
netif_napi_add(dev, &priv->napi, nuport_mac_poll, 64);
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");
priv->mii_bus = mdiobus_alloc();
if (!priv->mii_bus) {
dev_err(&pdev->dev, "mii bus allocation failed\n");
for (i = 0; i < PHY_MAX_ADDR; i++)
priv->mii_bus->irq[i] = PHY_IGNORE_INTERRUPT;
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;
if (ret) {
dev_err(&pdev->dev, "failed to register mii_bus\n");
goto out_mdio_irq;