summaryrefslogtreecommitdiffstats
path: root/drivers/net/macb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/macb.c')
-rw-r--r--drivers/net/macb.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 4feeed0ba1..df3b6af843 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -44,11 +44,11 @@
#include <malloc.h>
#include <xfuncs.h>
#include <init.h>
-#include <miiphy.h>
+#include <miidev.h>
#include <errno.h>
#include <asm/io.h>
#include <mach/board.h>
-#include <mach/clk.h>
+#include <linux/clk.h>
#include "macb.h"
@@ -98,7 +98,7 @@ struct macb_device {
const struct device *dev;
struct eth_device netdev;
- struct miiphy_device miiphy;
+ struct mii_device miidev;
unsigned int flags;
};
@@ -214,8 +214,8 @@ static int macb_open(struct eth_device *edev)
debug("%s\n", __func__);
- miiphy_wait_aneg(&macb->miiphy);
- miiphy_print_status(&macb->miiphy);
+ miidev_wait_aneg(&macb->miidev);
+ miidev_print_status(&macb->miidev);
ncfgr = readl(macb->regs + MACB_NCFGR);
ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
@@ -293,8 +293,7 @@ static void macb_halt(struct eth_device *edev)
writel(MACB_BIT(CLRSTAT), macb->regs + MACB_NCR);
}
-static int macb_phy_read(struct miiphy_device *mdev, uint8_t addr,
- uint8_t reg, uint16_t * value)
+static int macb_phy_read(struct mii_device *mdev, int addr, int reg)
{
struct eth_device *edev = mdev->edev;
struct macb_device *macb = edev->priv;
@@ -303,6 +302,7 @@ static int macb_phy_read(struct miiphy_device *mdev, uint8_t addr,
unsigned long netstat;
unsigned long frame;
int iflag;
+ int value;
uint64_t start;
debug("%s\n", __func__);
@@ -331,7 +331,7 @@ static int macb_phy_read(struct miiphy_device *mdev, uint8_t addr,
} while (!(netstat & MACB_BIT(IDLE)));
frame = readl(macb->regs + MACB_MAN);
- *value = MACB_BFEXT(DATA, frame);
+ value = MACB_BFEXT(DATA, frame);
iflag = disable_interrupts();
netctl = readl(macb->regs + MACB_NCR);
@@ -340,11 +340,10 @@ static int macb_phy_read(struct miiphy_device *mdev, uint8_t addr,
if (iflag)
enable_interrupts();
- return 0;
+ return value;
}
-static int macb_phy_write(struct miiphy_device *mdev, uint8_t addr,
- uint8_t reg, uint16_t value)
+static int macb_phy_write(struct mii_device *mdev, int addr, int reg, int value)
{
struct eth_device *edev = mdev->edev;
struct macb_device *macb = edev->priv;
@@ -412,6 +411,9 @@ static int macb_probe(struct device_d *dev)
unsigned long macb_hz;
u32 ncfgr;
struct at91_ether_platform_data *pdata;
+#if defined(CONFIG_ARCH_AT91)
+ struct clk *pclk;
+#endif
if (!dev->platform_data) {
printf("macb: no platform_data\n");
@@ -432,12 +434,12 @@ static int macb_probe(struct device_d *dev)
edev->get_ethaddr = macb_get_ethaddr;
edev->set_ethaddr = macb_set_ethaddr;
- macb->miiphy.read = macb_phy_read;
- macb->miiphy.write = macb_phy_write;
- macb->miiphy.address = pdata->phy_addr;
- macb->miiphy.flags = pdata->flags & AT91SAM_ETHER_FORCE_LINK ?
- MIIPHY_FORCE_LINK : 0;
- macb->miiphy.edev = edev;
+ macb->miidev.read = macb_phy_read;
+ macb->miidev.write = macb_phy_write;
+ macb->miidev.address = pdata->phy_addr;
+ macb->miidev.flags = pdata->flags & AT91SAM_ETHER_FORCE_LINK ?
+ MIIDEV_FORCE_LINK : 0;
+ macb->miidev.edev = edev;
macb->flags = pdata->flags;
macb->rx_buffer = xmalloc(CFG_MACB_RX_BUFFER_SIZE);
@@ -450,7 +452,13 @@ static int macb_probe(struct device_d *dev)
* Do some basic initialization so that we at least can talk
* to the PHY
*/
+#if defined(CONFIG_ARCH_AT91)
+ pclk = clk_get(dev, "macb_clk");
+ clk_enable(pclk);
+ macb_hz = clk_get_rate(pclk);
+#else
macb_hz = get_macb_pclk_rate(0);
+#endif
if (macb_hz < 20000000)
ncfgr = MACB_BF(CLK, MACB_CLK_DIV8);
else if (macb_hz < 40000000)
@@ -462,7 +470,7 @@ static int macb_probe(struct device_d *dev)
writel(ncfgr, macb->regs + MACB_NCFGR);
- miiphy_register(&macb->miiphy);
+ mii_register(&macb->miidev);
eth_register(edev);
return 0;