]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/at91_emac.c
at91_emac.c: fix 'Warning: eth device name has a space!'
[karo-tx-uboot.git] / drivers / net / at91_emac.c
index 239956998dab1f59d5c44bca5c1596110860dea6..009a275f66864dd259832ee1b0937ddc013a53db 100644 (file)
        Please decrease the CONFIG_SYS_RX_ETH_BUFFER value
 #endif
 
+#ifndef CONFIG_DRIVER_AT91EMAC_PHYADDR
+#define CONFIG_DRIVER_AT91EMAC_PHYADDR 0
+#endif
+
 /* MDIO clock must not exceed 2.5 MHz, so enable MCK divider */
 #if (AT91C_MASTER_CLOCK > 80000000)
        #define HCLK_DIV        AT91_EMAC_CFG_MCLK_64
@@ -158,7 +162,7 @@ int  at91emac_write(at91_emac_t *at91mac, unsigned char addr,
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
 
-at91_emac_t *get_emacbase_by_name(char *devname)
+at91_emac_t *get_emacbase_by_name(const char *devname)
 {
        struct eth_device *netdev;
 
@@ -166,7 +170,7 @@ at91_emac_t *get_emacbase_by_name(char *devname)
        return (at91_emac_t *) netdev->iobase;
 }
 
-int  at91emac_mii_read(char *devname, unsigned char addr,
+int  at91emac_mii_read(const char *devname, unsigned char addr,
                unsigned char reg, unsigned short *value)
 {
        at91_emac_t *emac;
@@ -177,7 +181,7 @@ int  at91emac_mii_read(char *devname, unsigned char addr,
 }
 
 
-int  at91emac_mii_write(char *devname, unsigned char addr,
+int  at91emac_mii_write(const char *devname, unsigned char addr,
                unsigned char reg, unsigned short value)
 {
        at91_emac_t *emac;
@@ -198,12 +202,15 @@ static int at91emac_phy_reset(struct eth_device *netdev)
        emac = (at91_emac_t *) netdev->iobase;
 
        adv = ADVERTISE_CSMA | ADVERTISE_ALL;
-       at91emac_write(emac, 0, MII_ADVERTISE, adv);
+       at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+               MII_ADVERTISE, adv);
        VERBOSEP("%s: Starting autonegotiation...\n", netdev->name);
-       at91emac_write(emac, 0, MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
+       at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMCR,
+               (BMCR_ANENABLE | BMCR_ANRESTART));
 
        for (i = 0; i < 100000 / 100; i++) {
-               at91emac_read(emac, 0, MII_BMSR, &status);
+               at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+                       MII_BMSR, &status);
                if (status & BMSR_ANEGCOMPLETE)
                        break;
                udelay(100);
@@ -229,13 +236,15 @@ static int at91emac_phy_init(struct eth_device *netdev)
        emac = (at91_emac_t *) netdev->iobase;
 
        /* Check if the PHY is up to snuff... */
-       at91emac_read(emac, 0, MII_PHYSID1, &phy_id);
+       at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+               MII_PHYSID1, &phy_id);
        if (phy_id == 0xffff) {
                printf("%s: No PHY present\n", netdev->name);
                return 1;
        }
 
-       at91emac_read(emac, 0, MII_BMSR, &status);
+       at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+               MII_BMSR, &status);
 
        if (!(status & BMSR_LSTATUS)) {
                /* Try to re-negotiate if we don't have link already. */
@@ -243,7 +252,8 @@ static int at91emac_phy_init(struct eth_device *netdev)
                        return 2;
 
                for (i = 0; i < 100000 / 100; i++) {
-                       at91emac_read(emac, 0, MII_BMSR, &status);
+                       at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+                               MII_BMSR, &status);
                        if (status & BMSR_LSTATUS)
                                break;
                        udelay(100);
@@ -253,8 +263,10 @@ static int at91emac_phy_init(struct eth_device *netdev)
                VERBOSEP("%s: link down\n", netdev->name);
                return 3;
        } else {
-               at91emac_read(emac, 0, MII_ADVERTISE, &adv);
-               at91emac_read(emac, 0, MII_LPA, &lpa);
+               at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+                       MII_ADVERTISE, &adv);
+               at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+                       MII_LPA, &lpa);
                media = mii_nway_result(lpa & adv);
                speed = (media & (ADVERTISE_100FULL | ADVERTISE_100HALF)
                         ? 1 : 0);
@@ -271,7 +283,7 @@ int at91emac_UpdateLinkSpeed(at91_emac_t *emac)
 {
        unsigned short stat1;
 
-       at91emac_read(emac, 0, MII_BMSR, &stat1);
+       at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR, &stat1);
 
        if (!(stat1 & BMSR_LSTATUS))    /* link status up? */
                return 1;
@@ -348,14 +360,6 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
        writel(1 << AT91_ID_EMAC, &pmc->pcer);
        writel(readl(&emac->ctl) | AT91_EMAC_CTL_CSR, &emac->ctl);
 
-       DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
-               cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
-               cpu_to_le32(*((u32 *)netdev->enetaddr)));
-       writel(cpu_to_le32(*((u32 *)netdev->enetaddr)), &emac->sa2l);
-       writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), &emac->sa2h);
-       DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
-               readl(&emac->sa2h), readl(&emac->sa2l));
-
        /* Init Ethernet buffers */
        for (i = 0; i < RBF_FRAMEMAX; i++) {
                dev->rbfdt[i].addr = (unsigned long) NetRxPackets[i];
@@ -372,7 +376,7 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
        value = AT91_EMAC_CFG_CAF |     AT91_EMAC_CFG_NBC |
                HCLK_DIV;
 #ifdef CONFIG_RMII
-       value |= AT91C_EMAC_RMII;
+       value |= AT91_EMAC_CFG_RMII;
 #endif
        writel(value, &emac->cfg);
 
@@ -456,6 +460,25 @@ static int at91emac_recv(struct eth_device *netdev)
        return 0;
 }
 
+static int at91emac_write_hwaddr(struct eth_device *netdev)
+{
+       emac_device *dev;
+       at91_emac_t *emac;
+       at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
+       emac = (at91_emac_t *) netdev->iobase;
+       dev = (emac_device *) netdev->priv;
+
+       writel(1 << AT91_ID_EMAC, &pmc->pcer);
+       DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
+               cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
+               cpu_to_le32(*((u32 *)netdev->enetaddr)));
+       writel(cpu_to_le32(*((u32 *)netdev->enetaddr)), &emac->sa2l);
+       writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), &emac->sa2h);
+       DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
+               readl(&emac->sa2h), readl(&emac->sa2l));
+       return 0;
+}
+
 int at91emac_register(bd_t *bis, unsigned long iobase)
 {
        emac_device *emac;
@@ -477,17 +500,14 @@ int at91emac_register(bd_t *bis, unsigned long iobase)
        memset(emacfix, 0, sizeof(emac_device));
 
        memset(dev, 0, sizeof(*dev));
-#ifndef CONFIG_RMII
-       sprintf(dev->name, "AT91 EMAC");
-#else
-       sprintf(dev->name, "AT91 EMAC RMII");
-#endif
+       sprintf(dev->name, "emac");
        dev->iobase = iobase;
        dev->priv = emacfix;
        dev->init = at91emac_init;
        dev->halt = at91emac_halt;
        dev->send = at91emac_send;
        dev->recv = at91emac_recv;
+       dev->write_hwaddr = at91emac_write_hwaddr;
 
        eth_register(dev);