Merge git://git.denx.de/u-boot-net
This commit is contained in:
@@ -154,12 +154,6 @@ static int bcm_sf2_eth_open(struct eth_device *dev, bd_t *bt)
|
||||
|
||||
debug("Enabling BCM SF2 Ethernet.\n");
|
||||
|
||||
/* Set MAC address from env */
|
||||
if (bcm_sf2_eth_write_hwaddr(dev) != 0) {
|
||||
error("%s: MAC set error when opening !\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
eth->enable_mac();
|
||||
|
||||
/* enable tx and rx DMA */
|
||||
|
||||
@@ -243,10 +243,6 @@ static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
|
||||
mdelay(100);
|
||||
};
|
||||
|
||||
/* Soft reset above clears HW address registers.
|
||||
* So we have to set it here once again */
|
||||
_dw_write_hwaddr(priv, enetaddr);
|
||||
|
||||
rx_descs_init(priv);
|
||||
tx_descs_init(priv);
|
||||
|
||||
|
||||
@@ -343,13 +343,7 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd)
|
||||
|
||||
printf("MAC: %pM\n", dev->enetaddr);
|
||||
if (!is_valid_ethaddr(dev->enetaddr)) {
|
||||
#ifdef CONFIG_RANDOM_MACADDR
|
||||
printf("Bad MAC address (uninitialized EEPROM?), randomizing\n");
|
||||
net_random_ethaddr(dev->enetaddr);
|
||||
printf("MAC: %pM\n", dev->enetaddr);
|
||||
#else
|
||||
printf("WARNING: Bad MAC address (uninitialized EEPROM?)\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* fill device MAC address registers */
|
||||
|
||||
@@ -424,9 +424,6 @@ int ftmac110_initialize(bd_t *bis)
|
||||
dev->send = ftmac110_send;
|
||||
dev->recv = ftmac110_recv;
|
||||
|
||||
if (!eth_getenv_enetaddr_by_index("eth", card_nr, dev->enetaddr))
|
||||
net_random_ethaddr(dev->enetaddr);
|
||||
|
||||
/* allocate tx descriptors (it must be 16 bytes aligned) */
|
||||
chip->txd = dma_alloc_coherent(
|
||||
sizeof(struct ftmac110_desc) * CFG_TXDES_NUM, &chip->txd_dma);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <errno.h>
|
||||
#include <net.h>
|
||||
#include <netdev.h>
|
||||
#include <malloc.h>
|
||||
@@ -653,13 +654,8 @@ int greth_initialize(bd_t * bis)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* HW Address not found in environment, Set default HW address */
|
||||
addr[0] = GRETH_HWADDR_0; /* MSB */
|
||||
addr[1] = GRETH_HWADDR_1;
|
||||
addr[2] = GRETH_HWADDR_2;
|
||||
addr[3] = GRETH_HWADDR_3;
|
||||
addr[4] = GRETH_HWADDR_4;
|
||||
addr[5] = GRETH_HWADDR_5; /* LSB */
|
||||
/* No ethaddr set */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* set and remember MAC address */
|
||||
|
||||
@@ -725,12 +725,6 @@ static int smc_get_ethaddr(bd_t *bd, struct eth_device *dev)
|
||||
|
||||
static int get_rom_mac(struct eth_device *dev, unsigned char *v_rom_mac)
|
||||
{
|
||||
#ifdef HARDCODE_MAC /* used for testing or to supress run time warnings */
|
||||
char hw_mac_addr[] = { 0x02, 0x80, 0xad, 0x20, 0x31, 0xb8 };
|
||||
|
||||
memcpy (v_rom_mac, hw_mac_addr, 6);
|
||||
return (1);
|
||||
#else
|
||||
int i;
|
||||
SMC_SELECT_BANK(dev, 1);
|
||||
for (i=0; i<6; i++)
|
||||
@@ -738,7 +732,6 @@ static int get_rom_mac(struct eth_device *dev, unsigned char *v_rom_mac)
|
||||
v_rom_mac[i] = SMC_inb(dev, LAN91C96_IA0 + i);
|
||||
}
|
||||
return (1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Structure to detect the device IDs */
|
||||
|
||||
@@ -525,7 +525,6 @@ static int macb_phy_init(struct macb_device *macb)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int macb_write_hwaddr(struct eth_device *dev);
|
||||
static int macb_init(struct eth_device *netdev, bd_t *bd)
|
||||
{
|
||||
struct macb_device *macb = to_macb(netdev);
|
||||
@@ -594,14 +593,6 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
|
||||
#endif /* CONFIG_RMII */
|
||||
}
|
||||
|
||||
/* update the ethaddr */
|
||||
if (is_valid_ethaddr(netdev->enetaddr)) {
|
||||
macb_write_hwaddr(netdev);
|
||||
} else {
|
||||
printf("%s: mac address is not valid\n", netdev->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!macb_phy_init(macb))
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <linux/err.h>
|
||||
#include <linux/compiler.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
/* Generic PHY support and helper functions */
|
||||
|
||||
/**
|
||||
@@ -494,6 +496,20 @@ int phy_register(struct phy_driver *drv)
|
||||
INIT_LIST_HEAD(&drv->list);
|
||||
list_add_tail(&drv->list, &phy_drivers);
|
||||
|
||||
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
||||
if (drv->probe)
|
||||
drv->probe += gd->reloc_off;
|
||||
if (drv->config)
|
||||
drv->config += gd->reloc_off;
|
||||
if (drv->startup)
|
||||
drv->startup += gd->reloc_off;
|
||||
if (drv->shutdown)
|
||||
drv->shutdown += gd->reloc_off;
|
||||
if (drv->readext)
|
||||
drv->readext += gd->reloc_off;
|
||||
if (drv->writeext)
|
||||
drv->writeext += gd->reloc_off;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,19 @@
|
||||
/* RTL8211x PHY Interrupt Status Register */
|
||||
#define MIIM_RTL8211x_PHY_INSR 0x13
|
||||
|
||||
/* RTL8211F PHY Status Register */
|
||||
#define MIIM_RTL8211F_PHY_STATUS 0x1a
|
||||
#define MIIM_RTL8211F_AUTONEG_ENABLE 0x1000
|
||||
#define MIIM_RTL8211F_PHYSTAT_SPEED 0x0030
|
||||
#define MIIM_RTL8211F_PHYSTAT_GBIT 0x0020
|
||||
#define MIIM_RTL8211F_PHYSTAT_100 0x0010
|
||||
#define MIIM_RTL8211F_PHYSTAT_DUPLEX 0x0008
|
||||
#define MIIM_RTL8211F_PHYSTAT_SPDDONE 0x0800
|
||||
#define MIIM_RTL8211F_PHYSTAT_LINK 0x0004
|
||||
|
||||
#define MIIM_RTL8211F_PAGE_SELECT 0x1f
|
||||
#define MIIM_RTL8211F_TX_DELAY 0x100
|
||||
|
||||
/* RealTek RTL8211x */
|
||||
static int rtl8211x_config(struct phy_device *phydev)
|
||||
{
|
||||
@@ -48,6 +61,29 @@ static int rtl8211x_config(struct phy_device *phydev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl8211f_config(struct phy_device *phydev)
|
||||
{
|
||||
u16 reg;
|
||||
|
||||
phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
|
||||
|
||||
if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
|
||||
/* enable TXDLY */
|
||||
phy_write(phydev, MDIO_DEVAD_NONE,
|
||||
MIIM_RTL8211F_PAGE_SELECT, 0xd08);
|
||||
reg = phy_read(phydev, MDIO_DEVAD_NONE, 0x11);
|
||||
reg |= MIIM_RTL8211F_TX_DELAY;
|
||||
phy_write(phydev, MDIO_DEVAD_NONE, 0x11, reg);
|
||||
/* restore to default page 0 */
|
||||
phy_write(phydev, MDIO_DEVAD_NONE,
|
||||
MIIM_RTL8211F_PAGE_SELECT, 0x0);
|
||||
}
|
||||
|
||||
genphy_config_aneg(phydev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl8211x_parse_status(struct phy_device *phydev)
|
||||
{
|
||||
unsigned int speed;
|
||||
@@ -105,6 +141,51 @@ static int rtl8211x_parse_status(struct phy_device *phydev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl8211f_parse_status(struct phy_device *phydev)
|
||||
{
|
||||
unsigned int speed;
|
||||
unsigned int mii_reg;
|
||||
int i = 0;
|
||||
|
||||
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, 0xa43);
|
||||
mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PHY_STATUS);
|
||||
|
||||
phydev->link = 1;
|
||||
while (!(mii_reg & MIIM_RTL8211F_PHYSTAT_LINK)) {
|
||||
if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
|
||||
puts(" TIMEOUT !\n");
|
||||
phydev->link = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((i++ % 1000) == 0)
|
||||
putc('.');
|
||||
udelay(1000);
|
||||
mii_reg = phy_read(phydev, MDIO_DEVAD_NONE,
|
||||
MIIM_RTL8211F_PHY_STATUS);
|
||||
}
|
||||
|
||||
if (mii_reg & MIIM_RTL8211F_PHYSTAT_DUPLEX)
|
||||
phydev->duplex = DUPLEX_FULL;
|
||||
else
|
||||
phydev->duplex = DUPLEX_HALF;
|
||||
|
||||
speed = (mii_reg & MIIM_RTL8211F_PHYSTAT_SPEED);
|
||||
|
||||
switch (speed) {
|
||||
case MIIM_RTL8211F_PHYSTAT_GBIT:
|
||||
phydev->speed = SPEED_1000;
|
||||
break;
|
||||
case MIIM_RTL8211F_PHYSTAT_100:
|
||||
phydev->speed = SPEED_100;
|
||||
break;
|
||||
default:
|
||||
phydev->speed = SPEED_10;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl8211x_startup(struct phy_device *phydev)
|
||||
{
|
||||
/* Read the Status (2x to make sure link is right) */
|
||||
@@ -114,6 +195,15 @@ static int rtl8211x_startup(struct phy_device *phydev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl8211f_startup(struct phy_device *phydev)
|
||||
{
|
||||
/* Read the Status (2x to make sure link is right) */
|
||||
genphy_update_link(phydev);
|
||||
rtl8211f_parse_status(phydev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Support for RTL8211B PHY */
|
||||
static struct phy_driver RTL8211B_driver = {
|
||||
.name = "RealTek RTL8211B",
|
||||
@@ -147,10 +237,22 @@ static struct phy_driver RTL8211DN_driver = {
|
||||
.shutdown = &genphy_shutdown,
|
||||
};
|
||||
|
||||
/* Support for RTL8211F PHY */
|
||||
static struct phy_driver RTL8211F_driver = {
|
||||
.name = "RealTek RTL8211F",
|
||||
.uid = 0x1cc916,
|
||||
.mask = 0xffffff,
|
||||
.features = PHY_GBIT_FEATURES,
|
||||
.config = &rtl8211f_config,
|
||||
.startup = &rtl8211f_startup,
|
||||
.shutdown = &genphy_shutdown,
|
||||
};
|
||||
|
||||
int phy_realtek_init(void)
|
||||
{
|
||||
phy_register(&RTL8211B_driver);
|
||||
phy_register(&RTL8211E_driver);
|
||||
phy_register(&RTL8211F_driver);
|
||||
phy_register(&RTL8211DN_driver);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user