]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/altera_tse.c
powerpc/p3060: remove all references to RCW bits EC1_EXT, EC2_EXT, and EC3
[u-boot] / drivers / net / altera_tse.c
index 59279049aa380fee24ccf908e9908ef086f0a3dd..54a944bfc4f221df510d55eb497f5b97f2884ed6 100644 (file)
@@ -426,7 +426,7 @@ static int tse_mdio_write(struct altera_tse_priv *priv, unsigned int regnum,
 
 /* MDIO access to phy */
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) && !defined(BITBANGMII)
-static int altera_tse_miiphy_write(char *devname, unsigned char addr,
+static int altera_tse_miiphy_write(const char *devname, unsigned char addr,
                                   unsigned char reg, unsigned short value)
 {
        struct eth_device *dev;
@@ -439,7 +439,7 @@ static int altera_tse_miiphy_write(char *devname, unsigned char addr,
        return 0;
 }
 
-static int altera_tse_miiphy_read(char *devname, unsigned char addr,
+static int altera_tse_miiphy_read(const char *devname, unsigned char addr,
                                  unsigned char reg, unsigned short *value)
 {
        struct eth_device *dev;
@@ -475,12 +475,12 @@ static uint mii_parse_sr(uint mii_reg, struct altera_tse_priv *priv)
         */
        mii_reg = tse_mdio_read(priv, MIIM_STATUS);
 
-       if (!(mii_reg & MIIM_STATUS_LINK) && (mii_reg & PHY_BMSR_AUTN_ABLE)
-           && !(mii_reg & PHY_BMSR_AUTN_COMP)) {
+       if (!(mii_reg & MIIM_STATUS_LINK) && (mii_reg & BMSR_ANEGCAPABLE)
+           && !(mii_reg & BMSR_ANEGCOMPLETE)) {
                int i = 0;
 
                puts("Waiting for PHY auto negotiation to complete");
-               while (!(mii_reg & PHY_BMSR_AUTN_COMP)) {
+               while (!(mii_reg & BMSR_ANEGCOMPLETE)) {
                        /*
                         * Timeout reached ?
                         */
@@ -643,13 +643,13 @@ static struct phy_info phy_info_generic = {
        "Unknown/Generic PHY",
        32,
        (struct phy_cmd[]){     /* config */
-                          {PHY_BMCR, PHY_BMCR_RESET, NULL},
-                          {PHY_BMCR, PHY_BMCR_AUTON | PHY_BMCR_RST_NEG, NULL},
+                          {MII_BMCR, BMCR_RESET, NULL},
+                          {MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART, NULL},
                           {miim_end,}
                           },
        (struct phy_cmd[]){     /* startup */
-                          {PHY_BMSR, miim_read, NULL},
-                          {PHY_BMSR, miim_read, &mii_parse_sr},
+                          {MII_BMSR, miim_read, NULL},
+                          {MII_BMSR, miim_read, &mii_parse_sr},
                           {miim_end,}
                           },
        (struct phy_cmd[]){     /* shutdown */
@@ -752,6 +752,40 @@ static int init_phy(struct eth_device *dev)
        return 1;
 }
 
+static int tse_set_mac_address(struct eth_device *dev)
+{
+       struct altera_tse_priv *priv = dev->priv;
+       volatile struct alt_tse_mac *mac_dev = priv->mac_dev;
+
+       debug("Setting MAC address to 0x%02x%02x%02x%02x%02x%02x\n",
+             dev->enetaddr[5], dev->enetaddr[4],
+             dev->enetaddr[3], dev->enetaddr[2],
+             dev->enetaddr[1], dev->enetaddr[0]);
+       mac_dev->mac_addr_0 = ((dev->enetaddr[3]) << 24 |
+                              (dev->enetaddr[2]) << 16 |
+                              (dev->enetaddr[1]) << 8 | (dev->enetaddr[0]));
+
+       mac_dev->mac_addr_1 = ((dev->enetaddr[5] << 8 |
+                               (dev->enetaddr[4])) & 0xFFFF);
+
+       /* Set the MAC address */
+       mac_dev->supp_mac_addr_0_0 = mac_dev->mac_addr_0;
+       mac_dev->supp_mac_addr_0_1 = mac_dev->mac_addr_1;
+
+       /* Set the MAC address */
+       mac_dev->supp_mac_addr_1_0 = mac_dev->mac_addr_0;
+       mac_dev->supp_mac_addr_1_1 = mac_dev->mac_addr_1;
+
+       /* Set the MAC address */
+       mac_dev->supp_mac_addr_2_0 = mac_dev->mac_addr_0;
+       mac_dev->supp_mac_addr_2_1 = mac_dev->mac_addr_1;
+
+       /* Set the MAC address */
+       mac_dev->supp_mac_addr_3_0 = mac_dev->mac_addr_0;
+       mac_dev->supp_mac_addr_3_1 = mac_dev->mac_addr_1;
+       return 0;
+}
+
 static int tse_eth_init(struct eth_device *dev, bd_t * bd)
 {
        int dat;
@@ -829,34 +863,6 @@ static int tse_eth_init(struct eth_device *dev, bd_t * bd)
 
        mac_dev->command_config.image = dat;
 
-       /* Set the MAC address */
-       debug("Setting MAC address to 0x%x%x%x%x%x%x\n",
-             dev->enetaddr[5], dev->enetaddr[4],
-             dev->enetaddr[3], dev->enetaddr[2],
-             dev->enetaddr[1], dev->enetaddr[0]);
-       mac_dev->mac_addr_0 = ((dev->enetaddr[3]) << 24 |
-                              (dev->enetaddr[2]) << 16 |
-                              (dev->enetaddr[1]) << 8 | (dev->enetaddr[0]));
-
-       mac_dev->mac_addr_1 = ((dev->enetaddr[5] << 8 |
-                               (dev->enetaddr[4])) & 0xFFFF);
-
-       /* Set the MAC address */
-       mac_dev->supp_mac_addr_0_0 = mac_dev->mac_addr_0;
-       mac_dev->supp_mac_addr_0_1 = mac_dev->mac_addr_1;
-
-       /* Set the MAC address */
-       mac_dev->supp_mac_addr_1_0 = mac_dev->mac_addr_0;
-       mac_dev->supp_mac_addr_1_1 = mac_dev->mac_addr_1;
-
-       /* Set the MAC address */
-       mac_dev->supp_mac_addr_2_0 = mac_dev->mac_addr_0;
-       mac_dev->supp_mac_addr_2_1 = mac_dev->mac_addr_1;
-
-       /* Set the MAC address */
-       mac_dev->supp_mac_addr_3_0 = mac_dev->mac_addr_0;
-       mac_dev->supp_mac_addr_3_1 = mac_dev->mac_addr_1;
-
        /* configure the TSE core  */
        /*  -- output clocks,  */
        /*  -- and later config stuff for SGMII */
@@ -920,6 +926,7 @@ int altera_tse_initialize(u8 dev_num, int mac_base,
        dev->halt = tse_eth_halt;
        dev->send = tse_eth_send;
        dev->recv = tse_eth_rx;
+       dev->write_hwaddr = tse_set_mac_address;
        sprintf(dev->name, "%s-%hu", "ALTERA_TSE", dev_num);
 
        eth_register(dev);