]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/macb.c
net/macb: Add arch specific routine to get mdio control
[karo-tx-uboot.git] / drivers / net / macb.c
index 6a58a374b2e97c08f77f94de8967c45506d111aa..6b49f0e3e129a1f8f9b88e6705ddc11a3b2bc84e 100644 (file)
@@ -51,8 +51,6 @@
 
 #include "macb.h"
 
-#define barrier() asm volatile("" ::: "memory")
-
 #define CONFIG_SYS_MACB_RX_BUFFER_SIZE         4096
 #define CONFIG_SYS_MACB_RX_RING_SIZE           (CONFIG_SYS_MACB_RX_BUFFER_SIZE / 128)
 #define CONFIG_SYS_MACB_TX_RING_SIZE           16
@@ -165,9 +163,14 @@ static u16 macb_mdio_read(struct macb_device *macb, u8 reg)
        return MACB_BFEXT(DATA, frame);
 }
 
+static void __weak arch_get_mdio_control(const char *name)
+{
+       return;
+}
+
 #if defined(CONFIG_CMD_MII)
 
-int macb_miiphy_read(char *devname, u8 phy_adr, u8 reg, u16 *value)
+int macb_miiphy_read(const char *devname, u8 phy_adr, u8 reg, u16 *value)
 {
        struct eth_device *dev = eth_get_dev_by_name(devname);
        struct macb_device *macb = to_macb(dev);
@@ -175,12 +178,13 @@ int macb_miiphy_read(char *devname, u8 phy_adr, u8 reg, u16 *value)
        if ( macb->phy_addr != phy_adr )
                return -1;
 
+       arch_get_mdio_control(devname);
        *value = macb_mdio_read(macb, reg);
 
        return 0;
 }
 
-int macb_miiphy_write(char *devname, u8 phy_adr, u8 reg, u16 value)
+int macb_miiphy_write(const char *devname, u8 phy_adr, u8 reg, u16 value)
 {
        struct eth_device *dev = eth_get_dev_by_name(devname);
        struct macb_device *macb = to_macb(dev);
@@ -188,6 +192,7 @@ int macb_miiphy_write(char *devname, u8 phy_adr, u8 reg, u16 value)
        if ( macb->phy_addr != phy_adr )
                return -1;
 
+       arch_get_mdio_control(devname);
        macb_mdio_write(macb, reg, value);
 
        return 0;
@@ -197,8 +202,7 @@ int macb_miiphy_write(char *devname, u8 phy_adr, u8 reg, u16 value)
 
 #if defined(CONFIG_CMD_NET)
 
-static int macb_send(struct eth_device *netdev, volatile void *packet,
-                    int length)
+static int macb_send(struct eth_device *netdev, void *packet, int length)
 {
        struct macb_device *macb = to_macb(netdev);
        unsigned long paddr, ctrl;
@@ -365,7 +369,7 @@ static int macb_phy_find(struct macb_device *macb)
        }
 
        /* PHY isn't up to snuff */
-       printf("%s: PHY not found", macb->netdev.name);
+       printf("%s: PHY not found\n", macb->netdev.name);
 
        return 0;
 }
@@ -380,6 +384,7 @@ static int macb_phy_init(struct macb_device *macb)
        int media, speed, duplex;
        int i;
 
+       arch_get_mdio_control(netdev->name);
 #ifdef CONFIG_MACB_SEARCH_PHY
        /* Auto-detect phy_addr */
        if (!macb_phy_find(macb)) {
@@ -469,17 +474,19 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
 
        /* choose RMII or MII mode. This depends on the board */
 #ifdef CONFIG_RMII
-#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
-    defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
-       defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#if    defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
+       defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
+       defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+       defined(CONFIG_AT91SAM9XE) || defined(CONFIG_AT91SAM9X5)
        macb_writel(macb, USRIO, MACB_BIT(RMII) | MACB_BIT(CLKEN));
 #else
        macb_writel(macb, USRIO, 0);
 #endif
 #else
-#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
-    defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
-       defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#if    defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
+       defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
+       defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+       defined(CONFIG_AT91SAM9XE) || defined(CONFIG_AT91SAM9X5)
        macb_writel(macb, USRIO, MACB_BIT(CLKEN));
 #else
        macb_writel(macb, USRIO, MACB_BIT(MII));
@@ -520,9 +527,10 @@ static int macb_write_hwaddr(struct eth_device *dev)
        u16 hwaddr_top;
 
        /* set hardware address */
-       hwaddr_bottom = cpu_to_le32(*((u32 *)dev->enetaddr));
+       hwaddr_bottom = dev->enetaddr[0] | dev->enetaddr[1] << 8 |
+                       dev->enetaddr[2] << 16 | dev->enetaddr[3] << 24;
        macb_writel(macb, SA1B, hwaddr_bottom);
-       hwaddr_top = cpu_to_le16(*((u16 *)(dev->enetaddr + 4)));
+       hwaddr_top = dev->enetaddr[4] | dev->enetaddr[5] << 8;
        macb_writel(macb, SA1T, hwaddr_top);
        return 0;
 }