[PATCH v3 3/7] net: moxa: connect to PHY
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP), connect to this PHY using OF. Signed-off-by: Jonas Jensen --- Notes: Thanks for reviewing, This time I'll avoid sending out the entire set, attaching it here directly to my reply. Because the DT example is directly imported from files in arch/arm/ those must be updated too. I'll submit those in a separate fixup patch. Changes since v3: 1. drop device_type property from DT example 2. replace "mac@" with "ethernet@" in DT example Applies to next-20140121 .../devicetree/bindings/net/moxa,moxart-mac.txt| 49 +++- drivers/net/ethernet/moxa/moxart_ether.c | 92 +- drivers/net/ethernet/moxa/moxart_ether.h | 2 + 3 files changed, 138 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt index 583418b..36d5185 100644 --- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt +++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt @@ -1,21 +1,62 @@ MOXA ART Ethernet Controller +Integrated MDIO bus node: + +- compatible: "moxa,moxart-mdio" +- Inherits from MDIO bus node binding[1] + +[1] Documentation/devicetree/bindings/net/phy.txt + + +Ethernet node: + Required properties: - compatible : Must be "moxa,moxart-mac" - reg : Should contain register location and length - interrupts : Should contain the mac interrupt number +Optional Properties: + +- phy-handle : the phandle to a PHY node + + Example: - mac0: mac@9090 { + mdio0: mdio@90900090 { + compatible = "moxa,moxart-mdio"; + reg = <0x90900090 0x8>; + #address-cells = <1>; + #size-cells = <0>; + + ethphy0: ethernet-phy@1 { + compatible = "moxa,moxart-rtl8201cp", "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + }; + + mdio1: mdio@9290 { + compatible = "moxa,moxart-mdio"; + reg = <0x9290 0x8>; + #address-cells = <1>; + #size-cells = <0>; + + ethphy1: ethernet-phy@1 { + compatible = "moxa,moxart-rtl8201cp", "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + }; + + mac0: ethernet@9090 { compatible = "moxa,moxart-mac"; - reg = <0x9090 0x100>; + reg = <0x9090 0x90>; interrupts = <25 0>; + phy-handle = <>; }; - mac1: mac@9200 { + mac1: ethernet@9200 { compatible = "moxa,moxart-mac"; - reg = <0x9200 0x100>; + reg = <0x9200 0x90>; interrupts = <27 0>; + phy-handle = <>; }; diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 17c9f0e..c19bff2 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include "moxart_ether.h" @@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, void *addr) return 0; } +static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return -EINVAL; + + return phy_mii_ioctl(priv->phy_dev, ir, cmd); +} + static void moxart_mac_free_memory(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev) writel(priv->reg_maccr, priv->base + REG_MAC_CTRL); } +static void moxart_mac_update_duplex(struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + priv->reg_maccr &= ~(FULLDUP | ENRX_IN_HALFTX); + if (priv->duplex) + priv->reg_maccr |= FULLDUP; + else + priv->reg_maccr |= ENRX_IN_HALFTX; + + writel(priv->reg_maccr, priv->base + REG_MAC_CTRL); +} + static void moxart_mac_setup_desc_ring(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev) moxart_update_mac_address(ndev); moxart_mac_setup_desc_ring(ndev); moxart_mac_enable(ndev); + + phy_start(priv->phy_dev); + netif_start_queue(ndev); netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n", @@ -183,6 +212,8 @@ static int moxart_mac_stop(struct net_device *ndev) napi_disable(>napi); + phy_stop(priv->phy_dev); + netif_stop_queue(ndev); /* disable all
[PATCH v3 3/7] net: moxa: connect to PHY
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP), connect to this PHY using OF. Signed-off-by: Jonas Jensen jonas.jen...@gmail.com --- Notes: Thanks for reviewing, This time I'll avoid sending out the entire set, attaching it here directly to my reply. Because the DT example is directly imported from files in arch/arm/ those must be updated too. I'll submit those in a separate fixup patch. Changes since v3: 1. drop device_type property from DT example 2. replace mac@ with ethernet@ in DT example Applies to next-20140121 .../devicetree/bindings/net/moxa,moxart-mac.txt| 49 +++- drivers/net/ethernet/moxa/moxart_ether.c | 92 +- drivers/net/ethernet/moxa/moxart_ether.h | 2 + 3 files changed, 138 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt index 583418b..36d5185 100644 --- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt +++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt @@ -1,21 +1,62 @@ MOXA ART Ethernet Controller +Integrated MDIO bus node: + +- compatible: moxa,moxart-mdio +- Inherits from MDIO bus node binding[1] + +[1] Documentation/devicetree/bindings/net/phy.txt + + +Ethernet node: + Required properties: - compatible : Must be moxa,moxart-mac - reg : Should contain register location and length - interrupts : Should contain the mac interrupt number +Optional Properties: + +- phy-handle : the phandle to a PHY node + + Example: - mac0: mac@9090 { + mdio0: mdio@90900090 { + compatible = moxa,moxart-mdio; + reg = 0x90900090 0x8; + #address-cells = 1; + #size-cells = 0; + + ethphy0: ethernet-phy@1 { + compatible = moxa,moxart-rtl8201cp, ethernet-phy-ieee802.3-c22; + reg = 1; + }; + }; + + mdio1: mdio@9290 { + compatible = moxa,moxart-mdio; + reg = 0x9290 0x8; + #address-cells = 1; + #size-cells = 0; + + ethphy1: ethernet-phy@1 { + compatible = moxa,moxart-rtl8201cp, ethernet-phy-ieee802.3-c22; + reg = 1; + }; + }; + + mac0: ethernet@9090 { compatible = moxa,moxart-mac; - reg = 0x9090 0x100; + reg = 0x9090 0x90; interrupts = 25 0; + phy-handle = ethphy0; }; - mac1: mac@9200 { + mac1: ethernet@9200 { compatible = moxa,moxart-mac; - reg = 0x9200 0x100; + reg = 0x9200 0x90; interrupts = 27 0; + phy-handle = ethphy1; }; diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 17c9f0e..c19bff2 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c @@ -25,6 +25,9 @@ #include linux/of_irq.h #include linux/crc32.h #include linux/crc32c.h +#include linux/phy.h +#include linux/of_mdio.h +#include linux/of_net.h #include moxart_ether.h @@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, void *addr) return 0; } +static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return -EINVAL; + + return phy_mii_ioctl(priv-phy_dev, ir, cmd); +} + static void moxart_mac_free_memory(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev) writel(priv-reg_maccr, priv-base + REG_MAC_CTRL); } +static void moxart_mac_update_duplex(struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + priv-reg_maccr = ~(FULLDUP | ENRX_IN_HALFTX); + if (priv-duplex) + priv-reg_maccr |= FULLDUP; + else + priv-reg_maccr |= ENRX_IN_HALFTX; + + writel(priv-reg_maccr, priv-base + REG_MAC_CTRL); +} + static void moxart_mac_setup_desc_ring(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev) moxart_update_mac_address(ndev); moxart_mac_setup_desc_ring(ndev); moxart_mac_enable(ndev); + + phy_start(priv-phy_dev); + netif_start_queue(ndev); netdev_dbg(ndev, %s: IMR=0x%x, MACCR=0x%x\n, @@ -183,6 +212,8 @@ static int moxart_mac_stop(struct net_device *ndev) napi_disable(priv-napi); + phy_stop(priv-phy_dev); +
Re: [PATCH v3 3/7] net: moxa: connect to PHY
On Mon, Jan 20, 2014 at 5:13 AM, Jonas Jensen wrote: > The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP), > connect to this PHY using OF. > > Signed-off-by: Jonas Jensen > --- > > Notes: > Applies to next-20140120 > > .../devicetree/bindings/net/moxa,moxart-mac.txt| 47 ++- > drivers/net/ethernet/moxa/moxart_ether.c | 92 > +- > drivers/net/ethernet/moxa/moxart_ether.h | 2 + > 3 files changed, 138 insertions(+), 3 deletions(-) > > diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt > b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt > index 583418b..94c1f3b 100644 > --- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt > +++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt > @@ -1,21 +1,64 @@ > MOXA ART Ethernet Controller > > +Integrated MDIO bus node: > + > +- compatible: "moxa,moxart-mdio" > +- Inherits from MDIO bus node binding[1] > + > +[1] Documentation/devicetree/bindings/net/phy.txt > + > + > +Ethernet node: > + > Required properties: > > - compatible : Must be "moxa,moxart-mac" > - reg : Should contain register location and length > - interrupts : Should contain the mac interrupt number > > +Optional Properties: > + > +- phy-handle : the phandle to a PHY node > + > + > Example: > > + mdio0: mdio@90900090 { > + compatible = "moxa,moxart-mdio"; > + reg = <0x90900090 0x8>; > + #address-cells = <1>; > + #size-cells = <0>; > + > + ethphy0: ethernet-phy@1 { > + device_type = "ethernet-phy"; Drop this. device_type is only for real OpenFirmware. > + compatible = "moxa,moxart-rtl8201cp", > "ethernet-phy-ieee802.3-c22"; > + reg = <1>; > + }; > + }; > + > + mdio1: mdio@9290 { > + compatible = "moxa,moxart-mdio"; > + reg = <0x9290 0x8>; > + #address-cells = <1>; > + #size-cells = <0>; > + > + ethphy1: ethernet-phy@1 { > + device_type = "ethernet-phy"; > + compatible = "moxa,moxart-rtl8201cp", > "ethernet-phy-ieee802.3-c22"; > + reg = <1>; > + }; > + }; > + > mac0: mac@9090 { Not part of this patch, but this should really be ethernet@... > compatible = "moxa,moxart-mac"; > - reg = <0x9090 0x100>; > + reg = <0x9090 0x90>; > interrupts = <25 0>; > + phy-handle = <>; > }; > > mac1: mac@9200 { > compatible = "moxa,moxart-mac"; > - reg = <0x9200 0x100>; > + reg = <0x9200 0x90>; > interrupts = <27 0>; > + phy-handle = <>; > }; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 3/7] net: moxa: connect to PHY
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP), connect to this PHY using OF. Signed-off-by: Jonas Jensen --- Notes: Applies to next-20140120 .../devicetree/bindings/net/moxa,moxart-mac.txt| 47 ++- drivers/net/ethernet/moxa/moxart_ether.c | 92 +- drivers/net/ethernet/moxa/moxart_ether.h | 2 + 3 files changed, 138 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt index 583418b..94c1f3b 100644 --- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt +++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt @@ -1,21 +1,64 @@ MOXA ART Ethernet Controller +Integrated MDIO bus node: + +- compatible: "moxa,moxart-mdio" +- Inherits from MDIO bus node binding[1] + +[1] Documentation/devicetree/bindings/net/phy.txt + + +Ethernet node: + Required properties: - compatible : Must be "moxa,moxart-mac" - reg : Should contain register location and length - interrupts : Should contain the mac interrupt number +Optional Properties: + +- phy-handle : the phandle to a PHY node + + Example: + mdio0: mdio@90900090 { + compatible = "moxa,moxart-mdio"; + reg = <0x90900090 0x8>; + #address-cells = <1>; + #size-cells = <0>; + + ethphy0: ethernet-phy@1 { + device_type = "ethernet-phy"; + compatible = "moxa,moxart-rtl8201cp", "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + }; + + mdio1: mdio@9290 { + compatible = "moxa,moxart-mdio"; + reg = <0x9290 0x8>; + #address-cells = <1>; + #size-cells = <0>; + + ethphy1: ethernet-phy@1 { + device_type = "ethernet-phy"; + compatible = "moxa,moxart-rtl8201cp", "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + }; + mac0: mac@9090 { compatible = "moxa,moxart-mac"; - reg = <0x9090 0x100>; + reg = <0x9090 0x90>; interrupts = <25 0>; + phy-handle = <>; }; mac1: mac@9200 { compatible = "moxa,moxart-mac"; - reg = <0x9200 0x100>; + reg = <0x9200 0x90>; interrupts = <27 0>; + phy-handle = <>; }; diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 17c9f0e..c19bff2 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include "moxart_ether.h" @@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, void *addr) return 0; } +static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return -EINVAL; + + return phy_mii_ioctl(priv->phy_dev, ir, cmd); +} + static void moxart_mac_free_memory(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev) writel(priv->reg_maccr, priv->base + REG_MAC_CTRL); } +static void moxart_mac_update_duplex(struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + priv->reg_maccr &= ~(FULLDUP | ENRX_IN_HALFTX); + if (priv->duplex) + priv->reg_maccr |= FULLDUP; + else + priv->reg_maccr |= ENRX_IN_HALFTX; + + writel(priv->reg_maccr, priv->base + REG_MAC_CTRL); +} + static void moxart_mac_setup_desc_ring(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev) moxart_update_mac_address(ndev); moxart_mac_setup_desc_ring(ndev); moxart_mac_enable(ndev); + + phy_start(priv->phy_dev); + netif_start_queue(ndev); netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n", @@ -183,6 +212,8 @@ static int moxart_mac_stop(struct net_device *ndev) napi_disable(>napi); + phy_stop(priv->phy_dev); + netif_stop_queue(ndev); /* disable all interrupts */ @@ -435,12 +466,49 @@ static struct net_device_ops moxart_netdev_ops = { .ndo_set_mac_address= moxart_set_mac_address, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = eth_change_mtu, + .ndo_do_ioctl = moxart_do_ioctl, }; +static void moxart_adjust_link(struct net_device *ndev) +{ + struct
Re: [PATCH v3 3/7] net: moxa: connect to PHY
On Mon, Jan 20, 2014 at 5:13 AM, Jonas Jensen jonas.jen...@gmail.com wrote: The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP), connect to this PHY using OF. Signed-off-by: Jonas Jensen jonas.jen...@gmail.com --- Notes: Applies to next-20140120 .../devicetree/bindings/net/moxa,moxart-mac.txt| 47 ++- drivers/net/ethernet/moxa/moxart_ether.c | 92 +- drivers/net/ethernet/moxa/moxart_ether.h | 2 + 3 files changed, 138 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt index 583418b..94c1f3b 100644 --- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt +++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt @@ -1,21 +1,64 @@ MOXA ART Ethernet Controller +Integrated MDIO bus node: + +- compatible: moxa,moxart-mdio +- Inherits from MDIO bus node binding[1] + +[1] Documentation/devicetree/bindings/net/phy.txt + + +Ethernet node: + Required properties: - compatible : Must be moxa,moxart-mac - reg : Should contain register location and length - interrupts : Should contain the mac interrupt number +Optional Properties: + +- phy-handle : the phandle to a PHY node + + Example: + mdio0: mdio@90900090 { + compatible = moxa,moxart-mdio; + reg = 0x90900090 0x8; + #address-cells = 1; + #size-cells = 0; + + ethphy0: ethernet-phy@1 { + device_type = ethernet-phy; Drop this. device_type is only for real OpenFirmware. + compatible = moxa,moxart-rtl8201cp, ethernet-phy-ieee802.3-c22; + reg = 1; + }; + }; + + mdio1: mdio@9290 { + compatible = moxa,moxart-mdio; + reg = 0x9290 0x8; + #address-cells = 1; + #size-cells = 0; + + ethphy1: ethernet-phy@1 { + device_type = ethernet-phy; + compatible = moxa,moxart-rtl8201cp, ethernet-phy-ieee802.3-c22; + reg = 1; + }; + }; + mac0: mac@9090 { Not part of this patch, but this should really be ethernet@... compatible = moxa,moxart-mac; - reg = 0x9090 0x100; + reg = 0x9090 0x90; interrupts = 25 0; + phy-handle = ethphy0; }; mac1: mac@9200 { compatible = moxa,moxart-mac; - reg = 0x9200 0x100; + reg = 0x9200 0x90; interrupts = 27 0; + phy-handle = ethphy1; }; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 3/7] net: moxa: connect to PHY
The kernel now has a MDIO bus driver and a phy_driver (RTL8201CP), connect to this PHY using OF. Signed-off-by: Jonas Jensen jonas.jen...@gmail.com --- Notes: Applies to next-20140120 .../devicetree/bindings/net/moxa,moxart-mac.txt| 47 ++- drivers/net/ethernet/moxa/moxart_ether.c | 92 +- drivers/net/ethernet/moxa/moxart_ether.h | 2 + 3 files changed, 138 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt index 583418b..94c1f3b 100644 --- a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt +++ b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt @@ -1,21 +1,64 @@ MOXA ART Ethernet Controller +Integrated MDIO bus node: + +- compatible: moxa,moxart-mdio +- Inherits from MDIO bus node binding[1] + +[1] Documentation/devicetree/bindings/net/phy.txt + + +Ethernet node: + Required properties: - compatible : Must be moxa,moxart-mac - reg : Should contain register location and length - interrupts : Should contain the mac interrupt number +Optional Properties: + +- phy-handle : the phandle to a PHY node + + Example: + mdio0: mdio@90900090 { + compatible = moxa,moxart-mdio; + reg = 0x90900090 0x8; + #address-cells = 1; + #size-cells = 0; + + ethphy0: ethernet-phy@1 { + device_type = ethernet-phy; + compatible = moxa,moxart-rtl8201cp, ethernet-phy-ieee802.3-c22; + reg = 1; + }; + }; + + mdio1: mdio@9290 { + compatible = moxa,moxart-mdio; + reg = 0x9290 0x8; + #address-cells = 1; + #size-cells = 0; + + ethphy1: ethernet-phy@1 { + device_type = ethernet-phy; + compatible = moxa,moxart-rtl8201cp, ethernet-phy-ieee802.3-c22; + reg = 1; + }; + }; + mac0: mac@9090 { compatible = moxa,moxart-mac; - reg = 0x9090 0x100; + reg = 0x9090 0x90; interrupts = 25 0; + phy-handle = ethphy0; }; mac1: mac@9200 { compatible = moxa,moxart-mac; - reg = 0x9200 0x100; + reg = 0x9200 0x90; interrupts = 27 0; + phy-handle = ethphy1; }; diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 17c9f0e..c19bff2 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c @@ -25,6 +25,9 @@ #include linux/of_irq.h #include linux/crc32.h #include linux/crc32c.h +#include linux/phy.h +#include linux/of_mdio.h +#include linux/of_net.h #include moxart_ether.h @@ -60,6 +63,16 @@ static int moxart_set_mac_address(struct net_device *ndev, void *addr) return 0; } +static int moxart_do_ioctl(struct net_device *ndev, struct ifreq *ir, int cmd) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return -EINVAL; + + return phy_mii_ioctl(priv-phy_dev, ir, cmd); +} + static void moxart_mac_free_memory(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -109,6 +122,19 @@ static void moxart_mac_enable(struct net_device *ndev) writel(priv-reg_maccr, priv-base + REG_MAC_CTRL); } +static void moxart_mac_update_duplex(struct net_device *ndev) +{ + struct moxart_mac_priv_t *priv = netdev_priv(ndev); + + priv-reg_maccr = ~(FULLDUP | ENRX_IN_HALFTX); + if (priv-duplex) + priv-reg_maccr |= FULLDUP; + else + priv-reg_maccr |= ENRX_IN_HALFTX; + + writel(priv-reg_maccr, priv-base + REG_MAC_CTRL); +} + static void moxart_mac_setup_desc_ring(struct net_device *ndev) { struct moxart_mac_priv_t *priv = netdev_priv(ndev); @@ -168,6 +194,9 @@ static int moxart_mac_open(struct net_device *ndev) moxart_update_mac_address(ndev); moxart_mac_setup_desc_ring(ndev); moxart_mac_enable(ndev); + + phy_start(priv-phy_dev); + netif_start_queue(ndev); netdev_dbg(ndev, %s: IMR=0x%x, MACCR=0x%x\n, @@ -183,6 +212,8 @@ static int moxart_mac_stop(struct net_device *ndev) napi_disable(priv-napi); + phy_stop(priv-phy_dev); + netif_stop_queue(ndev); /* disable all interrupts */ @@ -435,12 +466,49 @@ static struct net_device_ops moxart_netdev_ops = { .ndo_set_mac_address= moxart_set_mac_address, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = eth_change_mtu, + .ndo_do_ioctl = moxart_do_ioctl, }; +static void