summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/4xx_enet.c3
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/at91_emac.c2
-rw-r--r--drivers/net/davinci_emac.c24
-rw-r--r--drivers/net/e1000.c6
-rw-r--r--drivers/net/e1000.h11
-rw-r--r--drivers/net/enc28j60.c8
-rw-r--r--drivers/net/fec_mxc.c44
-rw-r--r--drivers/net/fm/fm.c3
-rw-r--r--drivers/net/rtl8019.c271
-rw-r--r--drivers/net/rtl8019.h114
-rw-r--r--drivers/net/smc911x.h7
-rw-r--r--drivers/net/tsec.c93
13 files changed, 165 insertions, 422 deletions
diff --git a/drivers/net/4xx_enet.c b/drivers/net/4xx_enet.c
index a7711390b0..73700dd0df 100644
--- a/drivers/net/4xx_enet.c
+++ b/drivers/net/4xx_enet.c
@@ -92,6 +92,7 @@
#include <asm/ppc4xx-mal.h>
#include <miiphy.h>
#include <malloc.h>
+#include <linux/compiler.h>
#if !(defined(CONFIG_MII) || defined(CONFIG_CMD_MII))
#error "CONFIG_MII has to be defined!"
@@ -872,7 +873,7 @@ static int ppc_4xx_eth_init (struct eth_device *dev, bd_t * bis)
defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
defined(CONFIG_405EX)
- int ethgroup = -1;
+ __maybe_unused int ethgroup = -1;
#endif
#endif
u32 bd_cached;
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 15eee8d8c4..d3df82ee39 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -63,7 +63,6 @@ COBJS-$(CONFIG_NETCONSOLE) += netconsole.o
COBJS-$(CONFIG_NS8382X) += ns8382x.o
COBJS-$(CONFIG_PCNET) += pcnet.o
COBJS-$(CONFIG_PLB2800_ETHER) += plb2800_eth.o
-COBJS-$(CONFIG_DRIVER_RTL8019) += rtl8019.o
COBJS-$(CONFIG_RTL8139) += rtl8139.o
COBJS-$(CONFIG_RTL8169) += rtl8169.o
COBJS-$(CONFIG_SH_ETHER) += sh_eth.o
diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index 97d273999a..9bda1fc695 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -474,11 +474,9 @@ static int at91emac_recv(struct eth_device *netdev)
static int at91emac_write_hwaddr(struct eth_device *netdev)
{
- emac_device *dev;
at91_emac_t *emac;
at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
emac = (at91_emac_t *) netdev->iobase;
- dev = (emac_device *) netdev->priv;
writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
DEBUG_AT91EMAC("init MAC-ADDR %02x:%02x:%02x:%02x:%02x:%02x\n",
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index fa31159a0e..36c33af662 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -85,15 +85,17 @@ static int emac_rx_queue_active = 0;
/* Receive packet buffers */
static unsigned char emac_rx_buffers[EMAC_MAX_RX_BUFFERS * (EMAC_MAX_ETHERNET_PKT_SIZE + EMAC_PKT_ALIGN)];
-#define MAX_PHY 3
+#ifndef CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT
+#define CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT 3
+#endif
/* PHY address for a discovered PHY (0xff - not found) */
-static u_int8_t active_phy_addr[MAX_PHY] = { 0xff, 0xff, 0xff };
+static u_int8_t active_phy_addr[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT];
/* number of PHY found active */
static u_int8_t num_phy;
-phy_t phy[MAX_PHY];
+phy_t phy[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT];
static int davinci_eth_set_mac_addr(struct eth_device *dev)
{
@@ -160,9 +162,8 @@ static int davinci_eth_phy_detect(void)
int j;
unsigned int count = 0;
- active_phy_addr[0] = 0xff;
- active_phy_addr[1] = 0xff;
- active_phy_addr[2] = 0xff;
+ for (i = 0; i < CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT; i++)
+ active_phy_addr[i] = 0xff;
udelay(1000);
phy_act_state = readl(&adap_mdio->ALIVE);
@@ -175,7 +176,14 @@ static int davinci_eth_phy_detect(void)
for (i = 0, j = 0; i < 32; i++)
if (phy_act_state & (1 << i)) {
count++;
- active_phy_addr[j++] = i;
+ if (count < CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT) {
+ active_phy_addr[j++] = i;
+ } else {
+ printf("%s: to many PHYs detected.\n",
+ __func__);
+ count = 0;
+ break;
+ }
}
num_phy = count;
@@ -752,7 +760,7 @@ int davinci_emac_initialize(void)
if (!ret)
return(0);
else
- printf(" %d ETH PHY detected\n", ret);
+ debug_emac(" %d ETH PHY detected\n", ret);
/* Get PHY ID and initialize phy_ops for a detected PHY */
for (i = 0; i < num_phy; i++) {
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 6eab7b2cfb..6b71bd901e 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -1370,7 +1370,6 @@ e1000_reset_hw(struct e1000_hw *hw)
{
uint32_t ctrl;
uint32_t ctrl_ext;
- uint32_t icr;
uint32_t manc;
uint32_t pba = 0;
@@ -1443,7 +1442,7 @@ e1000_reset_hw(struct e1000_hw *hw)
E1000_WRITE_REG(hw, IMC, 0xffffffff);
/* Clear any pending interrupt events. */
- icr = E1000_READ_REG(hw, ICR);
+ E1000_READ_REG(hw, ICR);
/* If MWI was previously enabled, reenable it. */
if (hw->mac_type == e1000_82542_rev2_0) {
@@ -4447,7 +4446,8 @@ e1000_phy_init_script(struct e1000_hw *hw)
mdelay(20);
/* Now enable the transmitter */
- e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
+ if (!ret_val)
+ e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
if (hw->mac_type == e1000_82547) {
uint16_t fused, fine, coarse;
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index d8400d4590..fd1d8f8717 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -1678,14 +1678,6 @@ struct e1000_hw {
#define EEPROM_EWEN_OPCODE 0x13 /* EERPOM erase/write enable */
#define EEPROM_EWDS_OPCODE 0x10 /* EERPOM erast/write disable */
-/* EEPROM Word Offsets */
-#define EEPROM_COMPAT 0x0003
-#define EEPROM_ID_LED_SETTINGS 0x0004
-#define EEPROM_INIT_CONTROL1_REG 0x000A
-#define EEPROM_INIT_CONTROL2_REG 0x000F
-#define EEPROM_FLASH_VERSION 0x0032
-#define EEPROM_CHECKSUM_REG 0x003F
-
/* Word definitions for ID LED Settings */
#define ID_LED_RESERVED_0000 0x0000
#define ID_LED_RESERVED_FFFF 0xFFFF
@@ -2479,7 +2471,6 @@ struct e1000_hw {
#define ADVERTISE_100_FULL 0x0008
#define ADVERTISE_1000_HALF 0x0010
#define ADVERTISE_1000_FULL 0x0020
-#define AUTONEG_ADVERTISE_SPEED_DEFAULT 0x002F /* Everything but 1000-Half */
#define ICH_FLASH_GFPREG 0x0000
#define ICH_FLASH_HSFSTS 0x0004
@@ -2504,7 +2495,6 @@ struct e1000_hw {
#define ICH_GFPREG_BASE_MASK 0x1FFF
#define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
-#define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */
#define E1000_SW_FW_SYNC 0x05B5C /* Software-Firmware Synchronization - RW */
/* SPI EEPROM Status Register */
@@ -2599,7 +2589,6 @@ struct e1000_hw {
#define PHY_CFG_TIMEOUT 100
#define DEFAULT_80003ES2LAN_TIPG_IPGT_10_100 0x00000009
#define DEFAULT_80003ES2LAN_TIPG_IPGT_1000 0x00000008
-#define E1000_TXDMAC_DPP 0x00000001
#define AUTO_ALL_MODES 0
#ifndef E1000_MASTER_SLAVE
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index d55cacdac8..e2011aef4a 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -432,7 +432,6 @@ static void enc_receive(enc_dev_t *enc)
u16 pkt_len;
u16 copy_len;
u16 status;
- u8 eir_reg;
u8 pkt_cnt = 0;
u16 rxbuf_rdpt;
u8 hbuf[6];
@@ -476,7 +475,7 @@ static void enc_receive(enc_dev_t *enc)
/* read pktcnt */
pkt_cnt = enc_r8(enc, CTL_REG_EPKTCNT);
if (copy_len == 0) {
- eir_reg = enc_r8(enc, CTL_REG_EIR);
+ (void)enc_r8(enc, CTL_REG_EIR);
enc_reset_rx(enc);
printf("%s: receive copy_len=0\n", enc->dev->name);
continue;
@@ -489,7 +488,7 @@ static void enc_receive(enc_dev_t *enc)
NetReceive(packet, pkt_len);
if (enc_claim_bus(enc))
return;
- eir_reg = enc_r8(enc, CTL_REG_EIR);
+ (void)enc_r8(enc, CTL_REG_EIR);
} while (pkt_cnt);
/* Use EPKTCNT not EIR.PKTIF flag, see errata pt. 6 */
}
@@ -500,14 +499,13 @@ static void enc_receive(enc_dev_t *enc)
static void enc_poll(enc_dev_t *enc)
{
u8 eir_reg;
- u8 estat_reg;
u8 pkt_cnt;
#ifdef CONFIG_USE_IRQ
/* clear global interrupt enable bit in enc28j60 */
enc_bclr(enc, CTL_REG_EIE, ENC_EIE_INTIE);
#endif
- estat_reg = enc_r8(enc, CTL_REG_ESTAT);
+ (void)enc_r8(enc, CTL_REG_ESTAT);
eir_reg = enc_r8(enc, CTL_REG_EIR);
if (eir_reg & ENC_EIR_TXIF) {
/* clear TXIF bit in EIR */
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 0c0c7cd2c7..b05a4c0c9a 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -42,6 +42,14 @@ DECLARE_GLOBAL_DATA_PTR;
#define CONFIG_FEC_XCV_TYPE MII100
#endif
+/*
+ * The i.MX28 operates with packets in big endian. We need to swap them before
+ * sending and after receiving.
+ */
+#ifdef CONFIG_MX28
+#define CONFIG_FEC_MXC_SWAP_PACKET
+#endif
+
#undef DEBUG
struct nbuf {
@@ -51,6 +59,32 @@ struct nbuf {
uint8_t head[16]; /**< MAC header(6 + 6 + 2) + 2(aligned) */
};
+#ifdef CONFIG_FEC_MXC_SWAP_PACKET
+static void swap_packet(uint32_t *packet, int length)
+{
+ int i;
+
+ for (i = 0; i < DIV_ROUND_UP(length, 4); i++)
+ packet[i] = __swab32(packet[i]);
+}
+#endif
+
+/*
+ * The i.MX28 has two ethernet interfaces, but they are not equal.
+ * Only the first one can access the MDIO bus.
+ */
+#ifdef CONFIG_MX28
+static inline struct ethernet_regs *fec_miiphy_fec_to_eth(struct fec_priv *fec)
+{
+ return (struct ethernet_regs *)MXS_ENET0_BASE;
+}
+#else
+static inline struct ethernet_regs *fec_miiphy_fec_to_eth(struct fec_priv *fec)
+{
+ return fec->eth;
+}
+#endif
+
/*
* MII-interface related functions
*/
@@ -59,7 +93,7 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr,
{
struct eth_device *edev = eth_get_dev_by_name(dev);
struct fec_priv *fec = (struct fec_priv *)edev->priv;
- struct ethernet_regs *eth = fec->eth;
+ struct ethernet_regs *eth = fec_miiphy_fec_to_eth(fec);
uint32_t reg; /* convenient holder for the PHY register */
uint32_t phy; /* convenient holder for the PHY */
@@ -117,7 +151,7 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr,
{
struct eth_device *edev = eth_get_dev_by_name(dev);
struct fec_priv *fec = (struct fec_priv *)edev->priv;
- struct ethernet_regs *eth = fec->eth;
+ struct ethernet_regs *eth = fec_miiphy_fec_to_eth(fec);
uint32_t reg; /* convenient holder for the PHY register */
uint32_t phy; /* convenient holder for the PHY */
@@ -572,6 +606,9 @@ static int fec_send(struct eth_device *dev, volatile void* packet, int length)
* Note: We are always using the first buffer for transmission,
* the second will be empty and only used to stop the DMA engine
*/
+#ifdef CONFIG_FEC_MXC_SWAP_PACKET
+ swap_packet((uint32_t *)packet, length);
+#endif
writew(length, &fec->tbd_base[fec->tbd_index].data_length);
writel((uint32_t)packet, &fec->tbd_base[fec->tbd_index].data_pointer);
/*
@@ -668,6 +705,9 @@ static int fec_recv(struct eth_device *dev)
/*
* Fill the buffer and pass it to upper layers
*/
+#ifdef CONFIG_FEC_MXC_SWAP_PACKET
+ swap_packet((uint32_t *)frame->data, frame_length);
+#endif
memcpy(buff, frame->data, frame_length);
NetReceive(buff, frame_length);
len = frame_length;
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 23ef14baf4..846c37249b 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -395,7 +395,6 @@ int fm_init_common(int index, struct ccsr_fman *reg)
int dev = CONFIG_SYS_MMC_ENV_DEV;
void *addr = malloc(CONFIG_SYS_FMAN_FW_LENGTH);
u32 cnt = CONFIG_SYS_FMAN_FW_LENGTH / 512;
- u32 n;
u32 blk = CONFIG_SYS_QE_FW_IN_MMC / 512;
struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
@@ -405,7 +404,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
printf("\nMMC read: dev # %u, block # %u, count %u ...\n",
dev, blk, cnt);
mmc_init(mmc);
- n = mmc->block_dev.block_read(dev, blk, cnt, addr);
+ (void)mmc->block_dev.block_read(dev, blk, cnt, addr);
/* flush cache after read */
flush_cache((ulong)addr, cnt * 512);
}
diff --git a/drivers/net/rtl8019.c b/drivers/net/rtl8019.c
deleted file mode 100644
index f516afe6b0..0000000000
--- a/drivers/net/rtl8019.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Realtek 8019AS Ethernet
- * (C) Copyright 2002-2003
- * Xue Ligong(lgxue@hotmail.com),Wang Kehao, ESLAB, whut.edu.cn
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-/*
- * This code works in 8bit mode.
- * If you need to work in 16bit mode, PLS change it!
- */
-
-#include <common.h>
-#include <command.h>
-#include "rtl8019.h"
-#include <net.h>
-
-/* packet page register access functions */
-
-static unsigned char get_reg (unsigned int regno)
-{
- return (*(unsigned char *) regno);
-}
-
-static void put_reg (unsigned int regno, unsigned char val)
-{
- *(volatile unsigned char *) regno = val;
-}
-
-static void eth_reset (void)
-{
- unsigned char ucTemp;
-
- /* reset NIC */
- ucTemp = get_reg (RTL8019_RESET);
- put_reg (RTL8019_RESET, ucTemp);
- put_reg (RTL8019_INTERRUPTSTATUS, 0xff);
- udelay (2000); /* wait for 2ms */
-}
-
-void rtl8019_get_enetaddr (uchar * addr)
-{
- unsigned char i;
- unsigned char temp;
-
- eth_reset ();
-
- put_reg (RTL8019_COMMAND, RTL8019_REMOTEDMARD);
- put_reg (RTL8019_DATACONFIGURATION, 0x48);
- put_reg (RTL8019_REMOTESTARTADDRESS0, 0x00);
- put_reg (RTL8019_REMOTESTARTADDRESS1, 0x00);
- put_reg (RTL8019_REMOTEBYTECOUNT0, 12);
- put_reg (RTL8019_REMOTEBYTECOUNT1, 0x00);
- put_reg (RTL8019_COMMAND, RTL8019_REMOTEDMARD);
- printf ("MAC: ");
- for (i = 0; i < 6; i++) {
- temp = get_reg (RTL8019_DMA_DATA);
- *addr++ = temp;
- temp = get_reg (RTL8019_DMA_DATA);
- printf ("%x:", temp);
- }
-
- while ((!get_reg (RTL8019_INTERRUPTSTATUS) & 0x40));
- printf ("\b \n");
- put_reg (RTL8019_REMOTEBYTECOUNT0, 0x00);
- put_reg (RTL8019_REMOTEBYTECOUNT1, 0x00);
- put_reg (RTL8019_COMMAND, RTL8019_PAGE0);
-}
-
-void eth_halt (void)
-{
- put_reg (RTL8019_COMMAND, 0x01);
-}
-
-int eth_init (bd_t * bd)
-{
- uchar enetaddr[6];
- eth_reset ();
- put_reg (RTL8019_COMMAND, RTL8019_PAGE0STOP);
- put_reg (RTL8019_DATACONFIGURATION, 0x48);
- put_reg (RTL8019_REMOTEBYTECOUNT0, 0x00);
- put_reg (RTL8019_REMOTEBYTECOUNT1, 0x00);
- put_reg (RTL8019_RECEIVECONFIGURATION, 0x00); /*00; */
- put_reg (RTL8019_TRANSMITPAGE, RTL8019_TPSTART);
- put_reg (RTL8019_TRANSMITCONFIGURATION, 0x02);
- put_reg (RTL8019_PAGESTART, RTL8019_PSTART);
- put_reg (RTL8019_BOUNDARY, RTL8019_PSTART);
- put_reg (RTL8019_PAGESTOP, RTL8019_PSTOP);
- put_reg (RTL8019_INTERRUPTSTATUS, 0xff);
- put_reg (RTL8019_INTERRUPTMASK, 0x11); /*b; */
- put_reg (RTL8019_COMMAND, RTL8019_PAGE1STOP);
- eth_getenv_enetaddr("ethaddr", enetaddr);
- put_reg (RTL8019_PHYSICALADDRESS0, enetaddr[0]);
- put_reg (RTL8019_PHYSICALADDRESS1, enetaddr[1]);
- put_reg (RTL8019_PHYSICALADDRESS2, enetaddr[2]);
- put_reg (RTL8019_PHYSICALADDRESS3, enetaddr[3]);
- put_reg (RTL8019_PHYSICALADDRESS4, enetaddr[4]);
- put_reg (RTL8019_PHYSICALADDRESS5, enetaddr[5]);
- put_reg (RTL8019_MULTIADDRESS0, 0x00);
- put_reg (RTL8019_MULTIADDRESS1, 0x00);
- put_reg (RTL8019_MULTIADDRESS2, 0x00);
- put_reg (RTL8019_MULTIADDRESS3, 0x00);
- put_reg (RTL8019_MULTIADDRESS4, 0x00);
- put_reg (RTL8019_MULTIADDRESS5, 0x00);
- put_reg (RTL8019_MULTIADDRESS6, 0x00);
- put_reg (RTL8019_MULTIADDRESS7, 0x00);
- put_reg (RTL8019_CURRENT, RTL8019_PSTART);
- put_reg (RTL8019_COMMAND, RTL8019_PAGE0);
- put_reg (RTL8019_TRANSMITCONFIGURATION, 0xe0); /*58; */
-
- return 0;
-}
-
-static unsigned char nic_to_pc (void)
-{
- unsigned char rec_head_status;
- unsigned char next_packet_pointer;
- unsigned char packet_length0;
- unsigned char packet_length1;
- unsigned short rxlen = 0;
- unsigned int i = 4;
- unsigned char current_point;
- unsigned char *addr;
-
- /*
- * The RTL8019's first 4B is packet status,page of next packet
- * and packet length(2B).So we receive the fist 4B.
- */
- put_reg (RTL8019_REMOTESTARTADDRESS1, get_reg (RTL8019_BOUNDARY));
- put_reg (RTL8019_REMOTESTARTADDRESS0, 0x00);
- put_reg (RTL8019_REMOTEBYTECOUNT1, 0x00);
- put_reg (RTL8019_REMOTEBYTECOUNT0, 0x04);
-
- put_reg (RTL8019_COMMAND, RTL8019_REMOTEDMARD);
-
- rec_head_status = get_reg (RTL8019_DMA_DATA);
- next_packet_pointer = get_reg (RTL8019_DMA_DATA);
- packet_length0 = get_reg (RTL8019_DMA_DATA);
- packet_length1 = get_reg (RTL8019_DMA_DATA);
-
- put_reg (RTL8019_COMMAND, RTL8019_PAGE0);
- /*Packet length is in two 8bit registers */
- rxlen = packet_length1;
- rxlen = (((rxlen << 8) & 0xff00) + packet_length0);
- rxlen -= 4;
-
- if (rxlen > PKTSIZE_ALIGN + PKTALIGN)
- printf ("packet too big!\n");
-
- /*Receive the packet */
- put_reg (RTL8019_REMOTESTARTADDRESS0, 0x04);
- put_reg (RTL8019_REMOTESTARTADDRESS1, get_reg (RTL8019_BOUNDARY));
-
- put_reg (RTL8019_REMOTEBYTECOUNT0, (rxlen & 0xff));
- put_reg (RTL8019_REMOTEBYTECOUNT1, ((rxlen >> 8) & 0xff));
-
-
- put_reg (RTL8019_COMMAND, RTL8019_REMOTEDMARD);
-
- for (addr = (unsigned char *) NetRxPackets[0], i = rxlen; i > 0; i--)
- *addr++ = get_reg (RTL8019_DMA_DATA);
- /* Pass the packet up to the protocol layers. */
- NetReceive (NetRxPackets[0], rxlen);
-
- while (!(get_reg (RTL8019_INTERRUPTSTATUS)) & 0x40); /* wait for the op. */
-
- /*
- * To test whether the packets are all received,get the
- * location of current point
- */
- put_reg (RTL8019_COMMAND, RTL8019_PAGE1);
- current_point = get_reg (RTL8019_CURRENT);
- put_reg (RTL8019_COMMAND, RTL8019_PAGE0);
- put_reg (RTL8019_BOUNDARY, next_packet_pointer);
- return current_point;
-}
-
-/* Get a data block via Ethernet */
-extern int eth_rx (void)
-{
- unsigned char temp, current_point;
-
- put_reg (RTL8019_COMMAND, RTL8019_PAGE0);
-
- while (1) {
- temp = get_reg (RTL8019_INTERRUPTSTATUS);
-
- if (temp & 0x90) {
- /*overflow */
- put_reg (RTL8019_COMMAND, RTL8019_PAGE0STOP);
- udelay (2000);
- put_reg (RTL8019_REMOTEBYTECOUNT0, 0);
- put_reg (RTL8019_REMOTEBYTECOUNT1, 0);
- put_reg (RTL8019_TRANSMITCONFIGURATION, 2);
- do {
- current_point = nic_to_pc ();
- } while (get_reg (RTL8019_BOUNDARY) != current_point);
-
- put_reg (RTL8019_TRANSMITCONFIGURATION, 0xe0);
- }
-
- if (temp & 0x1) {
- /*packet received */
- do {
- put_reg (RTL8019_INTERRUPTSTATUS, 0x01);
- current_point = nic_to_pc ();
- } while (get_reg (RTL8019_BOUNDARY) != current_point);
- }
-
- if (!(temp & 0x1))
- return 0;
- /* done and exit. */
- }
-}
-
-/* Send a data block via Ethernet. */
-extern int eth_send (volatile void *packet, int length)
-{
- volatile unsigned char *p;
- unsigned int pn;
-
- pn = length;
- p = (volatile unsigned char *) packet;
-
- while (get_reg (RTL8019_COMMAND) == RTL8019_TRANSMIT);
-
- put_reg (RTL8019_REMOTESTARTADDRESS0, 0);
- put_reg (RTL8019_REMOTESTARTADDRESS1, RTL8019_TPSTART);
- put_reg (RTL8019_REMOTEBYTECOUNT0, (pn & 0xff));
- put_reg (RTL8019_REMOTEBYTECOUNT1, ((pn >> 8) & 0xff));
-
- put_reg (RTL8019_COMMAND, RTL8019_REMOTEDMAWR);
- while (pn > 0) {
- put_reg (RTL8019_DMA_DATA, *p++);
- pn--;
- }
-
- pn = length;
-
- while (pn < 60) { /*Padding */
- put_reg (RTL8019_DMA_DATA, 0);
- pn++;
- }
-
- while (!(get_reg (RTL8019_INTERRUPTSTATUS)) & 0x40);
-
- put_reg (RTL8019_INTERRUPTSTATUS, 0x40);
- put_reg (RTL8019_TRANSMITPAGE, RTL8019_TPSTART);
- put_reg (RTL8019_TRANSMITBYTECOUNT0, (pn & 0xff));
- put_reg (RTL8019_TRANSMITBYTECOUNT1, ((pn >> 8 & 0xff)));
- put_reg (RTL8019_COMMAND, RTL8019_TRANSMIT);
-
- return 0;
-}
diff --git a/drivers/net/rtl8019.h b/drivers/net/rtl8019.h
deleted file mode 100644
index ae5163c431..0000000000
--- a/drivers/net/rtl8019.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Realtek 8019AS Ethernet
- * (C) Copyright 2002-2003
- * Xue Ligong(lgxue@hotmail.com),Wang Kehao, ESLAB, whut.edu.cn
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-/*
- * This code works in 8bit mode.
- * If you need to work in 16bit mode, PLS change it!
- */
-
-#include <asm/types.h>
-#include <config.h>
-
-#ifdef CONFIG_DRIVER_RTL8019
-
-#define RTL8019_REG_00 (RTL8019_BASE + 0x00)
-#define RTL8019_REG_01 (RTL8019_BASE + 0x01)
-#define RTL8019_REG_02 (RTL8019_BASE + 0x02)
-#define RTL8019_REG_03 (RTL8019_BASE + 0x03)
-#define RTL8019_REG_04 (RTL8019_BASE + 0x04)
-#define RTL8019_REG_05 (RTL8019_BASE + 0x05)
-#define RTL8019_REG_06 (RTL8019_BASE + 0x06)
-#define RTL8019_REG_07 (RTL8019_BASE + 0x07)
-#define RTL8019_REG_08 (RTL8019_BASE + 0x08)
-#define RTL8019_REG_09 (RTL8019_BASE + 0x09)
-#define RTL8019_REG_0a (RTL8019_BASE + 0x0a)
-#define RTL8019_REG_0b (RTL8019_BASE + 0x0b)
-#define RTL8019_REG_0c (RTL8019_BASE + 0x0c)
-#define RTL8019_REG_0d (RTL8019_BASE + 0x0d)
-#define RTL8019_REG_0e (RTL8019_BASE + 0x0e)
-#define RTL8019_REG_0f (RTL8019_BASE + 0x0f)
-#define RTL8019_REG_10 (RTL8019_BASE + 0x10)
-#define RTL8019_REG_1f (RTL8019_BASE + 0x1f)
-
-#define RTL8019_COMMAND RTL8019_REG_00
-#define RTL8019_PAGESTART RTL8019_REG_01
-#define RTL8019_PAGESTOP RTL8019_REG_02
-#define RTL8019_BOUNDARY RTL8019_REG_03
-#define RTL8019_TRANSMITSTATUS RTL8019_REG_04
-#define RTL8019_TRANSMITPAGE RTL8019_REG_04
-#define RTL8019_TRANSMITBYTECOUNT0 RTL8019_REG_05
-#define RTL8019_NCR RTL8019_REG_05
-#define RTL8019_TRANSMITBYTECOUNT1 RTL8019_REG_06
-#define RTL8019_INTERRUPTSTATUS RTL8019_REG_07
-#define RTL8019_CURRENT RTL8019_REG_07
-#define RTL8019_REMOTESTARTADDRESS0 RTL8019_REG_08
-#define RTL8019_CRDMA0 RTL8019_REG_08
-#define RTL8019_REMOTESTARTADDRESS1 RTL8019_REG_09
-#define RTL8019_CRDMA1 RTL8019_REG_09
-#define RTL8019_REMOTEBYTECOUNT0 RTL8019_REG_0a
-#define RTL8019_REMOTEBYTECOUNT1 RTL8019_REG_0b
-#define RTL8019_RECEIVESTATUS RTL8019_REG_0c
-#define RTL8019_RECEIVECONFIGURATION RTL8019_REG_0c
-#define RTL8019_TRANSMITCONFIGURATION RTL8019_REG_0d
-#define RTL8019_FAE_TALLY RTL8019_REG_0d
-#define RTL8019_DATACONFIGURATION RTL8019_REG_0e
-#define RTL8019_CRC_TALLY RTL8019_REG_0e
-#define RTL8019_INTERRUPTMASK RTL8019_REG_0f
-#define RTL8019_MISS_PKT_TALLY RTL8019_REG_0f
-#define RTL8019_PHYSICALADDRESS0 RTL8019_REG_01
-#define RTL8019_PHYSICALADDRESS1 RTL8019_REG_02
-#define RTL8019_PHYSICALADDRESS2 RTL8019_REG_03
-#define RTL8019_PHYSICALADDRESS3 RTL8019_REG_04
-#define RTL8019_PHYSICALADDRESS4 RTL8019_REG_05
-#define RTL8019_PHYSICALADDRESS5 RTL8019_REG_06
-#define RTL8019_MULTIADDRESS0 RTL8019_REG_08
-#define RTL8019_MULTIADDRESS1 RTL8019_REG_09
-#define RTL8019_MULTIADDRESS2 RTL8019_REG_0a
-#define RTL8019_MULTIADDRESS3 RTL8019_REG_0b
-#define RTL8019_MULTIADDRESS4 RTL8019_REG_0c
-#define RTL8019_MULTIADDRESS5 RTL8019_REG_0d
-#define RTL8019_MULTIADDRESS6 RTL8019_REG_0e
-#define RTL8019_MULTIADDRESS7 RTL8019_REG_0f
-#define RTL8019_DMA_DATA RTL8019_REG_10
-#define RTL8019_RESET RTL8019_REG_1f
-
-#define RTL8019_PAGE0 0x22
-#define RTL8019_PAGE1 0x62
-#define RTL8019_PAGE0DMAWRITE 0x12
-#define RTL8019_PAGE2DMAWRITE 0x92
-#define RTL8019_REMOTEDMAWR 0x12
-#define RTL8019_REMOTEDMARD 0x0A
-#define RTL8019_ABORTDMAWR 0x32
-#define RTL8019_ABORTDMARD 0x2A
-#define RTL8019_PAGE0STOP 0x21
-#define RTL8019_PAGE1STOP 0x61
-#define RTL8019_TRANSMIT 0x26
-#define RTL8019_TXINPROGRESS 0x04
-#define RTL8019_SEND 0x1A
-
-#define RTL8019_PSTART 0x4c
-#define RTL8019_PSTOP 0x80
-#define RTL8019_TPSTART 0x40
-
-#endif /*end of CONFIG_DRIVER_RTL8019*/
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index 8ce08a91e2..a290073bb8 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -471,8 +471,11 @@ static void smc911x_reset(struct eth_device *dev)
{
int timeout;
- /* Take out of PM setting first */
- if (smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY) {
+ /*
+ * Take out of PM setting first
+ * Device is already wake up if PMT_CTRL_READY bit is set
+ */
+ if ((smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY) == 0) {
/* Write to the bytetest will take out of powerdown */
smc911x_reg_write(dev, BYTE_TEST, 0x0);
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 78ffc95c53..160bc0597d 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -19,6 +19,7 @@
#include <tsec.h>
#include <fsl_mdio.h>
#include <asm/errno.h>
+#include <asm/processor.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -43,6 +44,9 @@ static RTXBD rtx __attribute__ ((aligned(8)));
#error "rtx must be 64-bit aligned"
#endif
+static int tsec_send(struct eth_device *dev,
+ volatile void *packet, int length);
+
/* Default initializations for TSEC controllers. */
static struct tsec_info_struct tsec_info[] = {
@@ -236,6 +240,87 @@ static void adjust_link(struct tsec_private *priv, struct phy_device *phydev)
(phydev->port == PORT_FIBRE) ? ", fiber mode" : "");
}
+#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
+/*
+ * When MACCFG1[Rx_EN] is enabled during system boot as part
+ * of the eTSEC port initialization sequence,
+ * the eTSEC Rx logic may not be properly initialized.
+ */
+void redundant_init(struct eth_device *dev)
+{
+ struct tsec_private *priv = dev->priv;
+ tsec_t *regs = priv->regs;
+ uint t, count = 0;
+ int fail = 1;
+ static const u8 pkt[] = {
+ 0x00, 0x1e, 0x4f, 0x12, 0xcb, 0x2c, 0x00, 0x25,
+ 0x64, 0xbb, 0xd1, 0xab, 0x08, 0x00, 0x45, 0x00,
+ 0x00, 0x5c, 0xdd, 0x22, 0x00, 0x00, 0x80, 0x01,
+ 0x1f, 0x71, 0x0a, 0xc1, 0x14, 0x22, 0x0a, 0xc1,
+ 0x14, 0x6a, 0x08, 0x00, 0xef, 0x7e, 0x02, 0x00,
+ 0x94, 0x05, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
+ 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
+ 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
+ 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+ 0x71, 0x72};
+
+ /* Enable promiscuous mode */
+ setbits_be32(&regs->rctrl, 0x8);
+ /* Enable loopback mode */
+ setbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
+ /* Enable transmit and receive */
+ setbits_be32(&regs->maccfg1, MACCFG1_RX_EN | MACCFG1_TX_EN);
+
+ /* Tell the DMA it is clear to go */
+ setbits_be32(&regs->dmactrl, DMACTRL_INIT_SETTINGS);
+ out_be32(&regs->tstat, TSTAT_CLEAR_THALT);
+ out_be32(&regs->rstat, RSTAT_CLEAR_RHALT);
+ clrbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
+
+ do {
+ tsec_send(dev, (void *)pkt, sizeof(pkt));
+
+ /* Wait for buffer to be received */
+ for (t = 0; rtx.rxbd[rxIdx].status & RXBD_EMPTY; t++) {
+ if (t >= 10 * TOUT_LOOP) {
+ printf("%s: tsec: rx error\n", dev->name);
+ break;
+ }
+ }
+
+ if (!memcmp(pkt, (void *)NetRxPackets[rxIdx], sizeof(pkt)))
+ fail = 0;
+
+ rtx.rxbd[rxIdx].length = 0;
+ rtx.rxbd[rxIdx].status =
+ RXBD_EMPTY | (((rxIdx + 1) == PKTBUFSRX) ? RXBD_WRAP : 0);
+ rxIdx = (rxIdx + 1) % PKTBUFSRX;
+
+ if (in_be32(&regs->ievent) & IEVENT_BSY) {
+ out_be32(&regs->ievent, IEVENT_BSY);
+ out_be32(&regs->rstat, RSTAT_CLEAR_RHALT);
+ }
+ if (fail) {
+ printf("loopback recv packet error!\n");
+ clrbits_be32(&regs->maccfg1, MACCFG1_RX_EN);
+ udelay(1000);
+ setbits_be32(&regs->maccfg1, MACCFG1_RX_EN);
+ }
+ } while ((count++ < 4) && (fail == 1));
+
+ if (fail)
+ panic("eTSEC init fail!\n");
+ /* Disable promiscuous mode */
+ clrbits_be32(&regs->rctrl, 0x8);
+ /* Disable loopback mode */
+ clrbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
+}
+#endif
+
/* Set up the buffers and their descriptors, and bring up the
* interface
*/
@@ -248,6 +333,9 @@ static void startup_tsec(struct eth_device *dev)
/* reset the indices to zero */
rxIdx = 0;
txIdx = 0;
+#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
+ uint svr;
+#endif
/* Point to the buffer descriptors */
out_be32(&regs->tbase, (unsigned int)(&rtx.txbd[txIdx]));
@@ -269,6 +357,11 @@ static void startup_tsec(struct eth_device *dev)
}
rtx.txbd[TX_BUF_CNT - 1].status |= TXBD_WRAP;
+#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
+ svr = get_svr();
+ if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
+ redundant_init(dev);
+#endif
/* Enable Transmit and Receive */
setbits_be32(&regs->maccfg1, MACCFG1_RX_EN | MACCFG1_TX_EN);