mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-12 21:46:05 -04:00
Merge branch 'next' of git://git.denx.de/u-boot-net into next
* '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>
This commit is contained in:
commit
0878222fed
@ -32,7 +32,11 @@ Correct flow of setting up the MAC address (summarized):
|
|||||||
|
|
||||||
1. Read from hardware in initialize() function
|
1. Read from hardware in initialize() function
|
||||||
2. Read from environment in net/eth.c after initialize()
|
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:
|
4. Program the address into hardware if the following conditions are met:
|
||||||
a) The relevant driver has a 'write_addr' function
|
a) The relevant driver has a 'write_addr' function
|
||||||
b) The user hasn't set an 'ethmacskip' environment variable
|
b) The user hasn't set an 'ethmacskip' environment variable
|
||||||
|
@ -171,8 +171,8 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
|
|||||||
writel(FIXEDBURST | PRIORXTX_41 | BURST_16,
|
writel(FIXEDBURST | PRIORXTX_41 | BURST_16,
|
||||||
&dma_p->busmode);
|
&dma_p->busmode);
|
||||||
|
|
||||||
writel(FLUSHTXFIFO | readl(&dma_p->opmode), &dma_p->opmode);
|
writel(readl(&dma_p->opmode) | FLUSHTXFIFO | STOREFORWARD |
|
||||||
writel(STOREFORWARD | TXSECONDFRAME, &dma_p->opmode);
|
TXSECONDFRAME, &dma_p->opmode);
|
||||||
|
|
||||||
conf = FRAMEBURSTENABLE | DISABLERXOWN;
|
conf = FRAMEBURSTENABLE | DISABLERXOWN;
|
||||||
|
|
||||||
|
@ -510,7 +510,13 @@ static int fec_open(struct eth_device *edev)
|
|||||||
fec_eth_phy_config(edev);
|
fec_eth_phy_config(edev);
|
||||||
if (fec->phydev) {
|
if (fec->phydev) {
|
||||||
/* Start up the PHY */
|
/* 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;
|
speed = fec->phydev->speed;
|
||||||
} else {
|
} else {
|
||||||
speed = _100BASET;
|
speed = _100BASET;
|
||||||
|
@ -363,6 +363,9 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)
|
|||||||
{
|
{
|
||||||
struct fm_eth *fm_eth;
|
struct fm_eth *fm_eth;
|
||||||
struct fsl_enet_mac *mac;
|
struct fsl_enet_mac *mac;
|
||||||
|
#ifdef CONFIG_PHYLIB
|
||||||
|
int ret;
|
||||||
|
#endif
|
||||||
|
|
||||||
fm_eth = (struct fm_eth *)dev->priv;
|
fm_eth = (struct fm_eth *)dev->priv;
|
||||||
mac = fm_eth->mac;
|
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);
|
fmc_tx_port_graceful_stop_disable(fm_eth);
|
||||||
|
|
||||||
#ifdef CONFIG_PHYLIB
|
#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
|
#else
|
||||||
fm_eth->phydev->speed = SPEED_1000;
|
fm_eth->phydev->speed = SPEED_1000;
|
||||||
fm_eth->phydev->link = 1;
|
fm_eth->phydev->link = 1;
|
||||||
|
@ -35,6 +35,12 @@ static struct phy_driver KSZ804_driver = {
|
|||||||
.shutdown = &genphy_shutdown,
|
.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 = {
|
static struct phy_driver KS8721_driver = {
|
||||||
.name = "Micrel KS8721BL",
|
.name = "Micrel KS8721BL",
|
||||||
.uid = 0x221610,
|
.uid = 0x221610,
|
||||||
@ -44,7 +50,9 @@ static struct phy_driver KS8721_driver = {
|
|||||||
.startup = &genphy_startup,
|
.startup = &genphy_startup,
|
||||||
.shutdown = &genphy_shutdown,
|
.shutdown = &genphy_shutdown,
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PHY_MICREL_KSZ9021
|
||||||
/* ksz9021 PHY Registers */
|
/* ksz9021 PHY Registers */
|
||||||
#define MII_KSZ9021_EXTENDED_CTRL 0x0b
|
#define MII_KSZ9021_EXTENDED_CTRL 0x0b
|
||||||
#define MII_KSZ9021_EXTENDED_DATAW 0x0c
|
#define MII_KSZ9021_EXTENDED_DATAW 0x0c
|
||||||
@ -127,12 +135,15 @@ static struct phy_driver ksz9021_driver = {
|
|||||||
.startup = &ksz9021_startup,
|
.startup = &ksz9021_startup,
|
||||||
.shutdown = &genphy_shutdown,
|
.shutdown = &genphy_shutdown,
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int phy_micrel_init(void)
|
int phy_micrel_init(void)
|
||||||
{
|
{
|
||||||
phy_register(&KSZ804_driver);
|
phy_register(&KSZ804_driver);
|
||||||
phy_register(&KS8721_driver);
|
#ifdef CONFIG_PHY_MICREL_KSZ9021
|
||||||
phy_register(&ksz9021_driver);
|
phy_register(&ksz9021_driver);
|
||||||
|
#else
|
||||||
|
phy_register(&KS8721_driver);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -723,10 +723,13 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
|
|||||||
return phydev;
|
return phydev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start the PHY. Returns 0 on success, or a negative error code.
|
||||||
|
*/
|
||||||
int phy_startup(struct phy_device *phydev)
|
int phy_startup(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
if (phydev->drv->startup)
|
if (phydev->drv->startup)
|
||||||
phydev->drv->startup(phydev);
|
return phydev->drv->startup(phydev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)
|
|||||||
goto err_phy_cfg;
|
goto err_phy_cfg;
|
||||||
}
|
}
|
||||||
phy = port_info->phydev;
|
phy = port_info->phydev;
|
||||||
phy_startup(phy);
|
ret = phy_startup(phy);
|
||||||
|
if (ret) {
|
||||||
|
printf(SHETHER_NAME ": phy startup failure\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
|
@ -480,6 +480,7 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)
|
|||||||
int i;
|
int i;
|
||||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||||
tsec_t *regs = priv->regs;
|
tsec_t *regs = priv->regs;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Make sure the controller is stopped */
|
/* Make sure the controller is stopped */
|
||||||
tsec_halt(dev);
|
tsec_halt(dev);
|
||||||
@ -511,7 +512,12 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)
|
|||||||
startup_tsec(dev);
|
startup_tsec(dev);
|
||||||
|
|
||||||
/* Start up the PHY */
|
/* 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);
|
adjust_link(priv, priv->phydev);
|
||||||
|
|
||||||
|
@ -272,7 +272,11 @@ static int setup_phy(struct eth_device *dev)
|
|||||||
phydev->advertising = phydev->supported;
|
phydev->advertising = phydev->supported;
|
||||||
priv->phydev = phydev;
|
priv->phydev = phydev;
|
||||||
phy_config(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) {
|
switch (phydev->speed) {
|
||||||
case 1000:
|
case 1000:
|
||||||
|
@ -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)
|
static int ll_temac_init(struct eth_device *dev, bd_t *bis)
|
||||||
{
|
{
|
||||||
struct ll_temac *ll_temac = dev->priv;
|
struct ll_temac *ll_temac = dev->priv;
|
||||||
|
int ret;
|
||||||
|
|
||||||
printf("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08X.\n",
|
printf("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08X.\n",
|
||||||
dev->name, dev->index, dev->iobase);
|
dev->name, dev->index, dev->iobase);
|
||||||
@ -240,7 +241,12 @@ static int ll_temac_init(struct eth_device *dev, bd_t *bis)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Start up the PHY */
|
/* 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)) {
|
if (!ll_temac_adjust_link(dev)) {
|
||||||
ll_temac_halt(dev);
|
ll_temac_halt(dev);
|
||||||
|
@ -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)
|
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_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);
|
asix_set_hw_mii(dev);
|
||||||
|
|
||||||
debug("asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
|
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
|
static void
|
||||||
asix_mdio_write(struct ueth_data *dev, int phy_id, int loc, int val)
|
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",
|
debug("asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
|
||||||
phy_id, loc, val);
|
phy_id, loc, val);
|
||||||
asix_set_sw_mii(dev);
|
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);
|
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)
|
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);
|
int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
|
||||||
|
|
||||||
debug("asix_get_phy_addr()\n");
|
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)
|
static u16 asix_read_rx_ctl(struct ueth_data *dev)
|
||||||
{
|
{
|
||||||
__le16 v;
|
ALLOC_CACHE_ALIGN_BUFFER(__le16, v, 1);
|
||||||
int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v);
|
|
||||||
|
int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, v);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
debug("Error reading RX_CTL register: %02x\n", ret);
|
debug("Error reading RX_CTL register: %02x\n", ret);
|
||||||
else
|
else
|
||||||
ret = le16_to_cpu(v);
|
ret = le16_to_cpu(*v);
|
||||||
return ret;
|
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)
|
static int asix_init(struct eth_device *eth, bd_t *bd)
|
||||||
{
|
{
|
||||||
int embd_phy;
|
int embd_phy;
|
||||||
unsigned char buf[ETH_ALEN];
|
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
|
||||||
u16 rx_ctl;
|
u16 rx_ctl;
|
||||||
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
@ -425,7 +428,8 @@ static int asix_send(struct eth_device *eth, void *packet, int length)
|
|||||||
int err;
|
int err;
|
||||||
u32 packet_len;
|
u32 packet_len;
|
||||||
int actual_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);
|
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)
|
static int asix_recv(struct eth_device *eth)
|
||||||
{
|
{
|
||||||
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
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;
|
unsigned char *buf_ptr;
|
||||||
int err;
|
int err;
|
||||||
int actual_len;
|
int actual_len;
|
||||||
|
@ -104,6 +104,7 @@
|
|||||||
#define CONFIG_FEC_MXC_PHYADDR 6
|
#define CONFIG_FEC_MXC_PHYADDR 6
|
||||||
#define CONFIG_PHYLIB
|
#define CONFIG_PHYLIB
|
||||||
#define CONFIG_PHY_MICREL
|
#define CONFIG_PHY_MICREL
|
||||||
|
#define CONFIG_PHY_MICREL_KSZ9021
|
||||||
|
|
||||||
/* USB Configs */
|
/* USB Configs */
|
||||||
#define CONFIG_CMD_USB
|
#define CONFIG_CMD_USB
|
||||||
|
14
net/eth.c
14
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);
|
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)
|
static int eth_mac_skip(int index)
|
||||||
{
|
{
|
||||||
char enetvar[15];
|
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);
|
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 &&
|
if (dev->write_hwaddr &&
|
||||||
|
@ -156,7 +156,7 @@ mcast_cleanup(void)
|
|||||||
#endif /* CONFIG_MCAST_TFTP */
|
#endif /* CONFIG_MCAST_TFTP */
|
||||||
|
|
||||||
static inline void
|
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 offset = block * TftpBlkSize + TftpBlockWrapOffset;
|
||||||
ulong newsize = offset + len;
|
ulong newsize = offset + len;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user