]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'next' of git://git.denx.de/u-boot-net into next
authorWolfgang Denk <wd@denx.de>
Thu, 12 Jul 2012 06:23:58 +0000 (08:23 +0200)
committerWolfgang Denk <wd@denx.de>
Thu, 12 Jul 2012 06:23:58 +0000 (08:23 +0200)
* 'next' of git://git.denx.de/u-boot-net:
  net: Inline the new eth_setenv_enetaddr_by_index function
  net: allow setting env enetaddr from net device setting
  net/designware: Consecutive writes to the same register to be avoided
  CACHE: net: asix: Fix asix driver to work with data cache on
  net: phy: micrel: make ksz9021 phy accessible
  net: abort network initialization if the PHY driver fails
  phylib: phy_startup() should return an error code on failure
  net: tftp: fix type of block arg to store_block

Signed-off-by: Wolfgang Denk <wd@denx.de>
14 files changed:
doc/README.enetaddr
drivers/net/designware.c
drivers/net/fec_mxc.c
drivers/net/fm/eth.c
drivers/net/phy/micrel.c
drivers/net/phy/phy.c
drivers/net/sh_eth.c
drivers/net/tsec.c
drivers/net/xilinx_axi_emac.c
drivers/net/xilinx_ll_temac.c
drivers/usb/eth/asix.c
include/configs/mx6qsabrelite.h
net/eth.c
net/tftp.c

index 2d8e24f5cb4df128dcf5fdba00ed244614791f25..1eaeaf9416efb5c76a81a202390f4bf110b11adc 100644 (file)
@@ -32,7 +32,11 @@ Correct flow of setting up the MAC address (summarized):
 
 1. Read from hardware in initialize() function
 2. Read from environment in net/eth.c after initialize()
-3. Give priority to the value in the environment if a conflict
+3. The environment variable will be compared to the driver initialized
+   struct eth_device->enetaddr. If they differ, a warning is printed, and the
+   environment variable will be used unchanged.
+   If the environment variable is not set, it will be initialized from
+   eth_device->enetaddr, and a warning will be printed.
 4. Program the address into hardware if the following conditions are met:
        a) The relevant driver has a 'write_addr' function
        b) The user hasn't set an 'ethmacskip' environment variable
index 326d550c1f26c7f72e6234ec6774dbc8c0b4a739..bf21a08bdf475afb81d6335f51cfb84cf4a7e8f9 100644 (file)
@@ -171,8 +171,8 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
        writel(FIXEDBURST | PRIORXTX_41 | BURST_16,
                        &dma_p->busmode);
 
-       writel(FLUSHTXFIFO | readl(&dma_p->opmode), &dma_p->opmode);
-       writel(STOREFORWARD | TXSECONDFRAME, &dma_p->opmode);
+       writel(readl(&dma_p->opmode) | FLUSHTXFIFO | STOREFORWARD |
+               TXSECONDFRAME, &dma_p->opmode);
 
        conf = FRAMEBURSTENABLE | DISABLERXOWN;
 
index eee41d7c8b77f42c810739166a7b2790a69c098a..57005521899eaa6bb83c25b944b58726309ed4ea 100644 (file)
@@ -510,7 +510,13 @@ static int fec_open(struct eth_device *edev)
                fec_eth_phy_config(edev);
        if (fec->phydev) {
                /* Start up the PHY */
-               phy_startup(fec->phydev);
+               int ret = phy_startup(fec->phydev);
+
+               if (ret) {
+                       printf("Could not initialize PHY %s\n",
+                              fec->phydev->dev->name);
+                       return ret;
+               }
                speed = fec->phydev->speed;
        } else {
                speed = _100BASET;
index f34f4db6b605da1173df86f19a4c06a9182762cd..2b616adb6e545803307ed53104fd2f8966cf919a 100644 (file)
@@ -363,6 +363,9 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)
 {
        struct fm_eth *fm_eth;
        struct fsl_enet_mac *mac;
+#ifdef CONFIG_PHYLIB
+       int ret;
+#endif
 
        fm_eth = (struct fm_eth *)dev->priv;
        mac = fm_eth->mac;
@@ -384,7 +387,11 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)
        fmc_tx_port_graceful_stop_disable(fm_eth);
 
 #ifdef CONFIG_PHYLIB
-       phy_startup(fm_eth->phydev);
+       ret = phy_startup(fm_eth->phydev);
+       if (ret) {
+               printf("%s: Could not initialize\n", fm_eth->phydev->dev->name);
+               return ret;
+       }
 #else
        fm_eth->phydev->speed = SPEED_1000;
        fm_eth->phydev->link = 1;
index e3043dfa207c8d75916c4cce49fd9e0e3b76521c..30f3264897479c35f49cc53c3600b7f5ca46665b 100644 (file)
@@ -35,6 +35,12 @@ static struct phy_driver KSZ804_driver = {
        .shutdown = &genphy_shutdown,
 };
 
+#ifndef CONFIG_PHY_MICREL_KSZ9021
+/*
+ * I can't believe Micrel used the exact same part number
+ * for the KSZ9021
+ * Shame Micrel, Shame!!!!!
+ */
 static struct phy_driver KS8721_driver = {
        .name = "Micrel KS8721BL",
        .uid = 0x221610,
@@ -44,7 +50,9 @@ static struct phy_driver KS8721_driver = {
        .startup = &genphy_startup,
        .shutdown = &genphy_shutdown,
 };
+#endif
 
+#ifdef CONFIG_PHY_MICREL_KSZ9021
 /* ksz9021 PHY Registers */
 #define MII_KSZ9021_EXTENDED_CTRL      0x0b
 #define MII_KSZ9021_EXTENDED_DATAW     0x0c
@@ -127,12 +135,15 @@ static struct phy_driver ksz9021_driver = {
        .startup = &ksz9021_startup,
        .shutdown = &genphy_shutdown,
 };
+#endif
 
 int phy_micrel_init(void)
 {
        phy_register(&KSZ804_driver);
-       phy_register(&KS8721_driver);
+#ifdef CONFIG_PHY_MICREL_KSZ9021
        phy_register(&ksz9021_driver);
-
+#else
+       phy_register(&KS8721_driver);
+#endif
        return 0;
 }
index 7d327f766a2cf23bbfd622de4f0b7e4bae8c4226..baef60f827466c8bf2d1227da0c850907774768c 100644 (file)
@@ -723,10 +723,13 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
        return phydev;
 }
 
+/*
+ * Start the PHY.  Returns 0 on success, or a negative error code.
+ */
 int phy_startup(struct phy_device *phydev)
 {
        if (phydev->drv->startup)
-               phydev->drv->startup(phydev);
+               return phydev->drv->startup(phydev);
 
        return 0;
 }
index bb57e4d53a03a2c82f326479bdd6893d475456a3..268d88428c0227490d3e6e8e9f030883c71ea5d3 100644 (file)
@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
                goto err_phy_cfg;
        }
        phy = port_info->phydev;
-       phy_startup(phy);
+       ret = phy_startup(phy);
+       if (ret) {
+               printf(SHETHER_NAME ": phy startup failure\n");
+               return ret;
+       }
 
        val = 0;
 
index 3c1c8f0799c4177a1a4371e7cda27855510e61ec..f5e314b9ee06c366ae1360bc4b6b1f0452aa3eb6 100644 (file)
@@ -480,6 +480,7 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)
        int i;
        struct tsec_private *priv = (struct tsec_private *)dev->priv;
        tsec_t *regs = priv->regs;
+       int ret;
 
        /* Make sure the controller is stopped */
        tsec_halt(dev);
@@ -511,7 +512,12 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)
        startup_tsec(dev);
 
        /* Start up the PHY */
-       phy_startup(priv->phydev);
+       ret = phy_startup(priv->phydev);
+       if (ret) {
+               printf("Could not initialize PHY %s\n",
+                      priv->phydev->dev->name);
+               return ret;
+       }
 
        adjust_link(priv, priv->phydev);
 
index 7854a04cae1b7908b8bd43a480190915eab398aa..d77714440ad420f132d9d9af478d91b4af4a5624 100644 (file)
@@ -272,7 +272,11 @@ static int setup_phy(struct eth_device *dev)
        phydev->advertising = phydev->supported;
        priv->phydev = phydev;
        phy_config(phydev);
-       phy_startup(phydev);
+       if (phy_startup(phydev)) {
+               printf("axiemac: could not initialize PHY %s\n",
+                      phydev->dev->name);
+               return 0;
+       }
 
        switch (phydev->speed) {
        case 1000:
index 27dafc15c00e8d54573dff7b1df3e137845c2ee6..b67153bec89d2004cc02a9d89653831340f764b3 100644 (file)
@@ -232,6 +232,7 @@ static void ll_temac_halt(struct eth_device *dev)
 static int ll_temac_init(struct eth_device *dev, bd_t *bis)
 {
        struct ll_temac *ll_temac = dev->priv;
+       int ret;
 
        printf("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08X.\n",
                dev->name, dev->index, dev->iobase);
@@ -240,7 +241,12 @@ static int ll_temac_init(struct eth_device *dev, bd_t *bis)
                return -1;
 
        /* Start up the PHY */
-       phy_startup(ll_temac->phydev);
+       ret = phy_startup(ll_temac->phydev);
+       if (ret) {
+               printf("%s: Could not initialize PHY %s\n",
+                      dev->name, ll_temac->phydev->dev->name);
+               return ret;
+       }
 
        if (!ll_temac_adjust_link(dev)) {
                ll_temac_halt(dev);
index a3bf51a64d71e3fdea918b5438a785e6b6c833ca..8fb7fc8c90e5a0e79d8241f2b4b6da39d0c4c74d 100644 (file)
@@ -168,27 +168,28 @@ static inline int asix_set_hw_mii(struct ueth_data *dev)
 
 static int asix_mdio_read(struct ueth_data *dev, int phy_id, int loc)
 {
-       __le16 res;
+       ALLOC_CACHE_ALIGN_BUFFER(__le16, res, 1);
 
        asix_set_sw_mii(dev);
-       asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res);
+       asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, res);
        asix_set_hw_mii(dev);
 
        debug("asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
-                       phy_id, loc, le16_to_cpu(res));
+                       phy_id, loc, le16_to_cpu(*res));
 
-       return le16_to_cpu(res);
+       return le16_to_cpu(*res);
 }
 
 static void
 asix_mdio_write(struct ueth_data *dev, int phy_id, int loc, int val)
 {
-       __le16 res = cpu_to_le16(val);
+       ALLOC_CACHE_ALIGN_BUFFER(__le16, res, 1);
+       *res = cpu_to_le16(val);
 
        debug("asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
                        phy_id, loc, val);
        asix_set_sw_mii(dev);
-       asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
+       asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, res);
        asix_set_hw_mii(dev);
 }
 
@@ -210,7 +211,8 @@ static int asix_sw_reset(struct ueth_data *dev, u8 flags)
 
 static inline int asix_get_phy_addr(struct ueth_data *dev)
 {
-       u8 buf[2];
+       ALLOC_CACHE_ALIGN_BUFFER(u8, buf, 2);
+
        int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
 
        debug("asix_get_phy_addr()\n");
@@ -242,13 +244,14 @@ static int asix_write_medium_mode(struct ueth_data *dev, u16 mode)
 
 static u16 asix_read_rx_ctl(struct ueth_data *dev)
 {
-       __le16 v;
-       int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v);
+       ALLOC_CACHE_ALIGN_BUFFER(__le16, v, 1);
+
+       int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, v);
 
        if (ret < 0)
                debug("Error reading RX_CTL register: %02x\n", ret);
        else
-               ret = le16_to_cpu(v);
+               ret = le16_to_cpu(*v);
        return ret;
 }
 
@@ -313,7 +316,7 @@ static int mii_nway_restart(struct ueth_data *dev)
 static int asix_init(struct eth_device *eth, bd_t *bd)
 {
        int embd_phy;
-       unsigned char buf[ETH_ALEN];
+       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
        u16 rx_ctl;
        struct ueth_data        *dev = (struct ueth_data *)eth->priv;
        int timeout = 0;
@@ -425,7 +428,8 @@ static int asix_send(struct eth_device *eth, void *packet, int length)
        int err;
        u32 packet_len;
        int actual_len;
-       unsigned char msg[PKTSIZE + sizeof(packet_len)];
+       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, msg,
+               PKTSIZE + sizeof(packet_len));
 
        debug("** %s(), len %d\n", __func__, length);
 
@@ -452,7 +456,7 @@ static int asix_send(struct eth_device *eth, void *packet, int length)
 static int asix_recv(struct eth_device *eth)
 {
        struct ueth_data *dev = (struct ueth_data *)eth->priv;
-       static unsigned char  recv_buf[AX_RX_URB_SIZE];
+       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, recv_buf, AX_RX_URB_SIZE);
        unsigned char *buf_ptr;
        int err;
        int actual_len;
index fbd10d670f8c80d1ea1748b37d717807dc88bc56..e42fe6b00b445e2ea0623fb682cb758fdf09c586 100644 (file)
 #define CONFIG_FEC_MXC_PHYADDR         6
 #define CONFIG_PHYLIB
 #define CONFIG_PHY_MICREL
+#define CONFIG_PHY_MICREL_KSZ9021
 
 /* USB Configs */
 #define CONFIG_CMD_USB
index d526264fa659309c1a568b4c9d8c555974452983..1a11ce10277e591eee26acc493475514eba5b72b 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -62,6 +62,15 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index,
        return eth_getenv_enetaddr(enetvar, enetaddr);
 }
 
+static inline int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+                                uchar *enetaddr)
+{
+       char enetvar[32];
+       sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index);
+       return eth_setenv_enetaddr(enetvar, enetaddr);
+}
+
+
 static int eth_mac_skip(int index)
 {
        char enetvar[15];
@@ -205,6 +214,11 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
                }
 
                memcpy(dev->enetaddr, env_enetaddr, 6);
+       } else if (is_valid_ether_addr(dev->enetaddr)) {
+               eth_setenv_enetaddr_by_index(base_name, eth_number,
+                                            dev->enetaddr);
+               printf("\nWarning: %s using MAC address from net device\n",
+                       dev->name);
        }
 
        if (dev->write_hwaddr &&
index b2e08b4bfb3d3daba64328c24e84ecbe9afc6970..59a8ebb3cf339b3c40ff24846c13406e5dc0b9a4 100644 (file)
@@ -156,7 +156,7 @@ mcast_cleanup(void)
 #endif /* CONFIG_MCAST_TFTP */
 
 static inline void
-store_block(unsigned block, uchar *src, unsigned len)
+store_block(int block, uchar *src, unsigned len)
 {
        ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
        ulong newsize = offset + len;