mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-22 23:21:31 +00:00
Ran lindent and cleaned up whitespace issues.
Format for 80-columns too.
This commit is contained in:
parent
333961ae70
commit
89875e96ba
1 changed files with 453 additions and 439 deletions
158
drivers/tsec.c
158
drivers/tsec.c
|
@ -1,5 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* tsec.c
|
|
||||||
* Freescale Three Speed Ethernet Controller driver
|
* Freescale Three Speed Ethernet Controller driver
|
||||||
*
|
*
|
||||||
* This software may be used and distributed according to the
|
* This software may be used and distributed according to the
|
||||||
|
@ -42,7 +41,6 @@ struct tsec_info_struct {
|
||||||
unsigned int phyregidx;
|
unsigned int phyregidx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* The tsec_info structure contains 3 values which the
|
/* The tsec_info structure contains 3 values which the
|
||||||
* driver uses to determine how to operate a given ethernet
|
* driver uses to determine how to operate a given ethernet
|
||||||
* device. The information needed is:
|
* device. The information needed is:
|
||||||
|
@ -111,7 +109,8 @@ static RTXBD rtx __attribute__ ((aligned(8)));
|
||||||
#error "rtx must be 64-bit aligned"
|
#error "rtx must be 64-bit aligned"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int tsec_send(struct eth_device* dev, volatile void *packet, int length);
|
static int tsec_send(struct eth_device *dev,
|
||||||
|
volatile void *packet, int length);
|
||||||
static int tsec_recv(struct eth_device *dev);
|
static int tsec_recv(struct eth_device *dev);
|
||||||
static int tsec_init(struct eth_device *dev, bd_t * bd);
|
static int tsec_init(struct eth_device *dev, bd_t * bd);
|
||||||
static void tsec_halt(struct eth_device *dev);
|
static void tsec_halt(struct eth_device *dev);
|
||||||
|
@ -153,7 +152,8 @@ int tsec_initialize(bd_t *bis, int index, char *devname)
|
||||||
privlist[index] = priv;
|
privlist[index] = priv;
|
||||||
priv->regs = (volatile tsec_t *)(TSEC_BASE_ADDR + index * TSEC_SIZE);
|
priv->regs = (volatile tsec_t *)(TSEC_BASE_ADDR + index * TSEC_SIZE);
|
||||||
priv->phyregs = (volatile tsec_t *)(TSEC_BASE_ADDR +
|
priv->phyregs = (volatile tsec_t *)(TSEC_BASE_ADDR +
|
||||||
tsec_info[index].phyregidx*TSEC_SIZE);
|
tsec_info[index].phyregidx *
|
||||||
|
TSEC_SIZE);
|
||||||
|
|
||||||
priv->phyaddr = tsec_info[index].phyaddr;
|
priv->phyaddr = tsec_info[index].phyaddr;
|
||||||
priv->flags = tsec_info[index].flags;
|
priv->flags = tsec_info[index].flags;
|
||||||
|
@ -172,7 +172,6 @@ int tsec_initialize(bd_t *bis, int index, char *devname)
|
||||||
|
|
||||||
eth_register(dev);
|
eth_register(dev);
|
||||||
|
|
||||||
|
|
||||||
/* Reset the MAC */
|
/* Reset the MAC */
|
||||||
priv->regs->maccfg1 |= MACCFG1_SOFT_RESET;
|
priv->regs->maccfg1 |= MACCFG1_SOFT_RESET;
|
||||||
priv->regs->maccfg1 &= ~(MACCFG1_SOFT_RESET);
|
priv->regs->maccfg1 &= ~(MACCFG1_SOFT_RESET);
|
||||||
|
@ -186,11 +185,11 @@ int tsec_initialize(bd_t *bis, int index, char *devname)
|
||||||
return init_phy(dev);
|
return init_phy(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Initializes data structures and registers for the controller,
|
/* Initializes data structures and registers for the controller,
|
||||||
* and brings the interface up. Returns the link status, meaning
|
* and brings the interface up. Returns the link status, meaning
|
||||||
* that it returns success if the link is up, failure otherwise.
|
* that it returns success if the link is up, failure otherwise.
|
||||||
* This allows u-boot to find the first active controller. */
|
* This allows u-boot to find the first active controller.
|
||||||
|
*/
|
||||||
int tsec_init(struct eth_device *dev, bd_t * bd)
|
int tsec_init(struct eth_device *dev, bd_t * bd)
|
||||||
{
|
{
|
||||||
uint tempval;
|
uint tempval;
|
||||||
|
@ -234,7 +233,6 @@ int tsec_init(struct eth_device* dev, bd_t * bd)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Write value to the device's PHY through the registers
|
/* Write value to the device's PHY through the registers
|
||||||
* specified in priv, modifying the register specified in regnum.
|
* specified in priv, modifying the register specified in regnum.
|
||||||
* It will wait for the write to be done (or for a timeout to
|
* It will wait for the write to be done (or for a timeout to
|
||||||
|
@ -254,7 +252,6 @@ void write_phy_reg(struct tsec_private *priv, uint regnum, uint value)
|
||||||
while ((regbase->miimind & MIIMIND_BUSY) && timeout--) ;
|
while ((regbase->miimind & MIIMIND_BUSY) && timeout--) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Reads register regnum on the device's PHY through the
|
/* Reads register regnum on the device's PHY through the
|
||||||
* registers specified in priv. It lowers and raises the read
|
* registers specified in priv. It lowers and raises the read
|
||||||
* command, and waits for the data to become valid (miimind
|
* command, and waits for the data to become valid (miimind
|
||||||
|
@ -288,7 +285,6 @@ uint read_phy_reg(struct tsec_private *priv, uint regnum)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Discover which PHY is attached to the device, and configure it
|
/* Discover which PHY is attached to the device, and configure it
|
||||||
* properly. If the PHY is not recognized, then return 0
|
* properly. If the PHY is not recognized, then return 0
|
||||||
* (failure). Otherwise, return 1
|
* (failure). Otherwise, return 1
|
||||||
|
@ -297,16 +293,13 @@ static int init_phy(struct eth_device *dev)
|
||||||
{
|
{
|
||||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||||
struct phy_info *curphy;
|
struct phy_info *curphy;
|
||||||
|
volatile tsec_t *regs = (volatile tsec_t *)(TSEC_BASE_ADDR);
|
||||||
|
|
||||||
/* Assign a Physical address to the TBI */
|
/* Assign a Physical address to the TBI */
|
||||||
|
|
||||||
{
|
|
||||||
volatile tsec_t *regs = (volatile tsec_t *)(TSEC_BASE_ADDR);
|
|
||||||
regs->tbipa = TBIPA_VALUE;
|
regs->tbipa = TBIPA_VALUE;
|
||||||
regs = (volatile tsec_t *)(TSEC_BASE_ADDR + TSEC_SIZE);
|
regs = (volatile tsec_t *)(TSEC_BASE_ADDR + TSEC_SIZE);
|
||||||
regs->tbipa = TBIPA_VALUE;
|
regs->tbipa = TBIPA_VALUE;
|
||||||
asm("sync");
|
asm("sync");
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset MII (due to new addresses) */
|
/* Reset MII (due to new addresses) */
|
||||||
priv->phyregs->miimcfg = MIIMCFG_RESET;
|
priv->phyregs->miimcfg = MIIMCFG_RESET;
|
||||||
|
@ -335,9 +328,10 @@ static int init_phy(struct eth_device *dev)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Returns which value to write to the control register. */
|
* Returns which value to write to the control register.
|
||||||
/* For 10/100, the value is slightly different */
|
* For 10/100, the value is slightly different
|
||||||
|
*/
|
||||||
uint mii_cr_init(uint mii_reg, struct tsec_private * priv)
|
uint mii_cr_init(uint mii_reg, struct tsec_private * priv)
|
||||||
{
|
{
|
||||||
if (priv->flags & TSEC_GIGABIT)
|
if (priv->flags & TSEC_GIGABIT)
|
||||||
|
@ -346,20 +340,23 @@ uint mii_cr_init(uint mii_reg, struct tsec_private *priv)
|
||||||
return MIIM_CR_INIT;
|
return MIIM_CR_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parse the status register for link, and then do
|
/* Parse the status register for link, and then do
|
||||||
* auto-negotiation */
|
* auto-negotiation
|
||||||
|
*/
|
||||||
uint mii_parse_sr(uint mii_reg, struct tsec_private * priv)
|
uint mii_parse_sr(uint mii_reg, struct tsec_private * priv)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Wait if PHY is capable of autonegotiation and autonegotiation is not complete
|
* Wait if PHY is capable of autonegotiation and autonegotiation
|
||||||
|
* is not complete.
|
||||||
*/
|
*/
|
||||||
mii_reg = read_phy_reg(priv, MIIM_STATUS);
|
mii_reg = read_phy_reg(priv, MIIM_STATUS);
|
||||||
if ((mii_reg & PHY_BMSR_AUTN_ABLE) && !(mii_reg & PHY_BMSR_AUTN_COMP)) {
|
if ((mii_reg & PHY_BMSR_AUTN_ABLE)
|
||||||
|
&& !(mii_reg & PHY_BMSR_AUTN_COMP)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
puts("Waiting for PHY auto negotiation to complete");
|
puts("Waiting for PHY auto negotiation to complete");
|
||||||
while (!((mii_reg & PHY_BMSR_AUTN_COMP) && (mii_reg & MIIM_STATUS_LINK))) {
|
while (!((mii_reg & PHY_BMSR_AUTN_COMP)
|
||||||
|
&& (mii_reg & MIIM_STATUS_LINK))) {
|
||||||
/*
|
/*
|
||||||
* Timeout reached ?
|
* Timeout reached ?
|
||||||
*/
|
*/
|
||||||
|
@ -385,9 +382,9 @@ uint mii_parse_sr(uint mii_reg, struct tsec_private *priv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parse the 88E1011's status register for speed and duplex
|
/* Parse the 88E1011's status register for speed and duplex
|
||||||
* information */
|
* information
|
||||||
|
*/
|
||||||
uint mii_parse_88E1011_psr(uint mii_reg, struct tsec_private * priv)
|
uint mii_parse_88E1011_psr(uint mii_reg, struct tsec_private * priv)
|
||||||
{
|
{
|
||||||
uint speed;
|
uint speed;
|
||||||
|
@ -441,9 +438,9 @@ uint mii_parse_88E1011_psr(uint mii_reg, struct tsec_private *priv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parse the cis8201's status register for speed and duplex
|
/* Parse the cis8201's status register for speed and duplex
|
||||||
* information */
|
* information
|
||||||
|
*/
|
||||||
uint mii_parse_cis8201(uint mii_reg, struct tsec_private * priv)
|
uint mii_parse_cis8201(uint mii_reg, struct tsec_private * priv)
|
||||||
{
|
{
|
||||||
uint speed;
|
uint speed;
|
||||||
|
@ -468,8 +465,10 @@ uint mii_parse_cis8201(uint mii_reg, struct tsec_private *priv)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the vsc8244's status register for speed and duplex
|
/* Parse the vsc8244's status register for speed and duplex
|
||||||
* information */
|
* information
|
||||||
|
*/
|
||||||
uint mii_parse_vsc8244(uint mii_reg, struct tsec_private * priv)
|
uint mii_parse_vsc8244(uint mii_reg, struct tsec_private * priv)
|
||||||
{
|
{
|
||||||
uint speed;
|
uint speed;
|
||||||
|
@ -495,9 +494,9 @@ uint mii_parse_vsc8244(uint mii_reg, struct tsec_private *priv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parse the DM9161's status register for speed and duplex
|
/* Parse the DM9161's status register for speed and duplex
|
||||||
* information */
|
* information
|
||||||
|
*/
|
||||||
uint mii_parse_dm9161_scsr(uint mii_reg, struct tsec_private * priv)
|
uint mii_parse_dm9161_scsr(uint mii_reg, struct tsec_private * priv)
|
||||||
{
|
{
|
||||||
if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_100H))
|
if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_100H))
|
||||||
|
@ -513,8 +512,9 @@ uint mii_parse_dm9161_scsr(uint mii_reg, struct tsec_private *priv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Hack to write all 4 PHYs with the LED values */
|
* Hack to write all 4 PHYs with the LED values
|
||||||
|
*/
|
||||||
uint mii_cis8204_fixled(uint mii_reg, struct tsec_private * priv)
|
uint mii_cis8204_fixled(uint mii_reg, struct tsec_private * priv)
|
||||||
{
|
{
|
||||||
uint phyid;
|
uint phyid;
|
||||||
|
@ -543,7 +543,8 @@ uint mii_cis8204_setmode(uint mii_reg, struct tsec_private *priv)
|
||||||
|
|
||||||
/* Initialized required registers to appropriate values, zeroing
|
/* Initialized required registers to appropriate values, zeroing
|
||||||
* those we don't care about (unless zero is bad, in which case,
|
* those we don't care about (unless zero is bad, in which case,
|
||||||
* choose a more appropriate value) */
|
* choose a more appropriate value)
|
||||||
|
*/
|
||||||
static void init_registers(volatile tsec_t * regs)
|
static void init_registers(volatile tsec_t * regs)
|
||||||
{
|
{
|
||||||
/* Clear IEVENT */
|
/* Clear IEVENT */
|
||||||
|
@ -586,9 +587,9 @@ static void init_registers(volatile tsec_t *regs)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Configure maccfg2 based on negotiated speed and duplex
|
/* Configure maccfg2 based on negotiated speed and duplex
|
||||||
* reported by PHY handling code */
|
* reported by PHY handling code
|
||||||
|
*/
|
||||||
static void adjust_link(struct eth_device *dev)
|
static void adjust_link(struct eth_device *dev)
|
||||||
{
|
{
|
||||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||||
|
@ -632,9 +633,9 @@ static void adjust_link(struct eth_device *dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Set up the buffers and their descriptors, and bring up the
|
/* Set up the buffers and their descriptors, and bring up the
|
||||||
* interface */
|
* interface
|
||||||
|
*/
|
||||||
static void startup_tsec(struct eth_device *dev)
|
static void startup_tsec(struct eth_device *dev)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -677,7 +678,8 @@ static void startup_tsec(struct eth_device *dev)
|
||||||
/* This returns the status bits of the device. The return value
|
/* This returns the status bits of the device. The return value
|
||||||
* is never checked, and this is what the 8260 driver did, so we
|
* is never checked, and this is what the 8260 driver did, so we
|
||||||
* do the same. Presumably, this would be zero if there were no
|
* do the same. Presumably, this would be zero if there were no
|
||||||
* errors */
|
* errors
|
||||||
|
*/
|
||||||
static int tsec_send(struct eth_device *dev, volatile void *packet, int length)
|
static int tsec_send(struct eth_device *dev, volatile void *packet, int length)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -695,7 +697,8 @@ static int tsec_send(struct eth_device* dev, volatile void *packet, int length)
|
||||||
|
|
||||||
rtx.txbd[txIdx].bufPtr = (uint) packet;
|
rtx.txbd[txIdx].bufPtr = (uint) packet;
|
||||||
rtx.txbd[txIdx].length = length;
|
rtx.txbd[txIdx].length = length;
|
||||||
rtx.txbd[txIdx].status |= (TXBD_READY | TXBD_LAST | TXBD_CRC | TXBD_INTERRUPT);
|
rtx.txbd[txIdx].status |=
|
||||||
|
(TXBD_READY | TXBD_LAST | TXBD_CRC | TXBD_INTERRUPT);
|
||||||
|
|
||||||
/* Tell the DMA to go */
|
/* Tell the DMA to go */
|
||||||
regs->tstat = TSTAT_CLEAR_THALT;
|
regs->tstat = TSTAT_CLEAR_THALT;
|
||||||
|
@ -735,7 +738,8 @@ static int tsec_recv(struct eth_device* dev)
|
||||||
rtx.rxbd[rxIdx].length = 0;
|
rtx.rxbd[rxIdx].length = 0;
|
||||||
|
|
||||||
/* Set the wrap bit if this is the last element in the list */
|
/* Set the wrap bit if this is the last element in the list */
|
||||||
rtx.rxbd[rxIdx].status = RXBD_EMPTY | (((rxIdx + 1) == PKTBUFSRX) ? RXBD_WRAP : 0);
|
rtx.rxbd[rxIdx].status =
|
||||||
|
RXBD_EMPTY | (((rxIdx + 1) == PKTBUFSRX) ? RXBD_WRAP : 0);
|
||||||
|
|
||||||
rxIdx = (rxIdx + 1) % PKTBUFSRX;
|
rxIdx = (rxIdx + 1) % PKTBUFSRX;
|
||||||
}
|
}
|
||||||
|
@ -749,7 +753,6 @@ static int tsec_recv(struct eth_device* dev)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Stop the interface */
|
/* Stop the interface */
|
||||||
static void tsec_halt(struct eth_device *dev)
|
static void tsec_halt(struct eth_device *dev)
|
||||||
{
|
{
|
||||||
|
@ -767,7 +770,6 @@ static void tsec_halt(struct eth_device* dev)
|
||||||
phy_run_commands(priv, priv->phyinfo->shutdown);
|
phy_run_commands(priv, priv->phyinfo->shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct phy_info phy_info_M88E1011S = {
|
struct phy_info phy_info_M88E1011S = {
|
||||||
0x01410c6,
|
0x01410c6,
|
||||||
"Marvell 88E1011S",
|
"Marvell 88E1011S",
|
||||||
|
@ -792,7 +794,8 @@ struct phy_info phy_info_M88E1011S = {
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
/* Read the status */
|
/* Read the status */
|
||||||
{MIIM_88E1011_PHY_STATUS, miim_read, &mii_parse_88E1011_psr},
|
{MIIM_88E1011_PHY_STATUS, miim_read,
|
||||||
|
&mii_parse_88E1011_psr},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -824,7 +827,8 @@ struct phy_info phy_info_M88E1111S = {
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
/* Read the status */
|
/* Read the status */
|
||||||
{MIIM_88E1011_PHY_STATUS, miim_read, &mii_parse_88E1011_psr},
|
{MIIM_88E1011_PHY_STATUS, miim_read,
|
||||||
|
&mii_parse_88E1011_psr},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -837,12 +841,10 @@ static unsigned int m88e1145_setmode(uint mii_reg, struct tsec_private *priv)
|
||||||
unsigned int temp;
|
unsigned int temp;
|
||||||
uint mii_data = read_phy_reg(priv, mii_reg);
|
uint mii_data = read_phy_reg(priv, mii_reg);
|
||||||
|
|
||||||
|
|
||||||
/* Setting MIIM_88E1145_PHY_EXT_CR */
|
/* Setting MIIM_88E1145_PHY_EXT_CR */
|
||||||
if (priv->flags & TSEC_REDUCED)
|
if (priv->flags & TSEC_REDUCED)
|
||||||
return mii_data |
|
return mii_data |
|
||||||
MIIM_M88E1145_RGMII_RX_DELAY |
|
MIIM_M88E1145_RGMII_RX_DELAY | MIIM_M88E1145_RGMII_TX_DELAY;
|
||||||
MIIM_M88E1145_RGMII_TX_DELAY;
|
|
||||||
else
|
else
|
||||||
return mii_data;
|
return mii_data;
|
||||||
}
|
}
|
||||||
|
@ -862,7 +864,8 @@ static struct phy_info phy_info_M88E1145 = {
|
||||||
{MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
|
{MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
|
||||||
{MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL},
|
{MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL},
|
||||||
{MIIM_ANAR, MIIM_ANAR_INIT, NULL},
|
{MIIM_ANAR, MIIM_ANAR_INIT, NULL},
|
||||||
{MIIM_88E1011_PHY_SCR, MIIM_88E1011_PHY_MDI_X_AUTO, NULL},
|
{MIIM_88E1011_PHY_SCR, MIIM_88E1011_PHY_MDI_X_AUTO,
|
||||||
|
NULL},
|
||||||
{MIIM_88E1145_PHY_EXT_CR, 0, &m88e1145_setmode},
|
{MIIM_88E1145_PHY_EXT_CR, 0, &m88e1145_setmode},
|
||||||
{MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
|
{MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
|
||||||
{MIIM_CONTROL, MIIM_CONTROL_INIT, NULL},
|
{MIIM_CONTROL, MIIM_CONTROL_INIT, NULL},
|
||||||
|
@ -873,9 +876,11 @@ static struct phy_info phy_info_M88E1145 = {
|
||||||
{MIIM_STATUS, miim_read, NULL},
|
{MIIM_STATUS, miim_read, NULL},
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
{MIIM_88E1111_PHY_LED_CONTROL, MIIM_88E1111_PHY_LED_DIRECT, NULL},
|
{MIIM_88E1111_PHY_LED_CONTROL,
|
||||||
|
MIIM_88E1111_PHY_LED_DIRECT, NULL},
|
||||||
/* Read the Status */
|
/* Read the Status */
|
||||||
{MIIM_88E1011_PHY_STATUS, miim_read, &mii_parse_88E1011_psr},
|
{MIIM_88E1011_PHY_STATUS, miim_read,
|
||||||
|
&mii_parse_88E1011_psr},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -883,18 +888,20 @@ static struct phy_info phy_info_M88E1145 = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct phy_info phy_info_cis8204 = {
|
struct phy_info phy_info_cis8204 = {
|
||||||
0x3f11,
|
0x3f11,
|
||||||
"Cicada Cis8204",
|
"Cicada Cis8204",
|
||||||
6,
|
6,
|
||||||
(struct phy_cmd[]){ /* config */
|
(struct phy_cmd[]){ /* config */
|
||||||
/* Override PHY config settings */
|
/* Override PHY config settings */
|
||||||
{MIIM_CIS8201_AUX_CONSTAT, MIIM_CIS8201_AUXCONSTAT_INIT, NULL},
|
{MIIM_CIS8201_AUX_CONSTAT,
|
||||||
|
MIIM_CIS8201_AUXCONSTAT_INIT, NULL},
|
||||||
/* Configure some basic stuff */
|
/* Configure some basic stuff */
|
||||||
{MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init},
|
{MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init},
|
||||||
{MIIM_CIS8204_SLED_CON, MIIM_CIS8204_SLEDCON_INIT, &mii_cis8204_fixled},
|
{MIIM_CIS8204_SLED_CON, MIIM_CIS8204_SLEDCON_INIT,
|
||||||
{MIIM_CIS8204_EPHY_CON, MIIM_CIS8204_EPHYCON_INIT, &mii_cis8204_setmode},
|
&mii_cis8204_fixled},
|
||||||
|
{MIIM_CIS8204_EPHY_CON, MIIM_CIS8204_EPHYCON_INIT,
|
||||||
|
&mii_cis8204_setmode},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* startup */
|
(struct phy_cmd[]){ /* startup */
|
||||||
|
@ -903,7 +910,8 @@ struct phy_info phy_info_cis8204 = {
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
/* Read the status */
|
/* Read the status */
|
||||||
{MIIM_CIS8201_AUX_CONSTAT, miim_read, &mii_parse_cis8201},
|
{MIIM_CIS8201_AUX_CONSTAT, miim_read,
|
||||||
|
&mii_parse_cis8201},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -918,9 +926,11 @@ struct phy_info phy_info_cis8201 = {
|
||||||
4,
|
4,
|
||||||
(struct phy_cmd[]){ /* config */
|
(struct phy_cmd[]){ /* config */
|
||||||
/* Override PHY config settings */
|
/* Override PHY config settings */
|
||||||
{MIIM_CIS8201_AUX_CONSTAT, MIIM_CIS8201_AUXCONSTAT_INIT, NULL},
|
{MIIM_CIS8201_AUX_CONSTAT,
|
||||||
|
MIIM_CIS8201_AUXCONSTAT_INIT, NULL},
|
||||||
/* Set up the interface mode */
|
/* Set up the interface mode */
|
||||||
{MIIM_CIS8201_EXT_CON1, MIIM_CIS8201_EXTCON1_INIT, NULL},
|
{MIIM_CIS8201_EXT_CON1, MIIM_CIS8201_EXTCON1_INIT,
|
||||||
|
NULL},
|
||||||
/* Configure some basic stuff */
|
/* Configure some basic stuff */
|
||||||
{MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init},
|
{MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
|
@ -931,7 +941,8 @@ struct phy_info phy_info_cis8201 = {
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
/* Read the status */
|
/* Read the status */
|
||||||
{MIIM_CIS8201_AUX_CONSTAT, miim_read, &mii_parse_cis8201},
|
{MIIM_CIS8201_AUX_CONSTAT, miim_read,
|
||||||
|
&mii_parse_cis8201},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -954,7 +965,8 @@ struct phy_info phy_info_VSC8244 = {
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
/* Read the status */
|
/* Read the status */
|
||||||
{MIIM_VSC8244_AUX_CONSTAT, miim_read, &mii_parse_vsc8244},
|
{MIIM_VSC8244_AUX_CONSTAT, miim_read,
|
||||||
|
&mii_parse_vsc8244},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -962,7 +974,6 @@ struct phy_info phy_info_VSC8244 = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct phy_info phy_info_dm9161 = {
|
struct phy_info phy_info_dm9161 = {
|
||||||
0x0181b88,
|
0x0181b88,
|
||||||
"Davicom DM9161E",
|
"Davicom DM9161E",
|
||||||
|
@ -972,7 +983,8 @@ struct phy_info phy_info_dm9161 = {
|
||||||
/* Do not bypass the scrambler/descrambler */
|
/* Do not bypass the scrambler/descrambler */
|
||||||
{MIIM_DM9161_SCR, MIIM_DM9161_SCR_INIT, NULL},
|
{MIIM_DM9161_SCR, MIIM_DM9161_SCR_INIT, NULL},
|
||||||
/* Clear 10BTCSR to default */
|
/* Clear 10BTCSR to default */
|
||||||
{MIIM_DM9161_10BTCSR, MIIM_DM9161_10BTCSR_INIT, NULL},
|
{MIIM_DM9161_10BTCSR, MIIM_DM9161_10BTCSR_INIT,
|
||||||
|
NULL},
|
||||||
/* Configure some basic stuff */
|
/* Configure some basic stuff */
|
||||||
{MIIM_CONTROL, MIIM_CR_INIT, NULL},
|
{MIIM_CONTROL, MIIM_CR_INIT, NULL},
|
||||||
/* Restart Auto Negotiation */
|
/* Restart Auto Negotiation */
|
||||||
|
@ -985,7 +997,8 @@ struct phy_info phy_info_dm9161 = {
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
/* Read the status */
|
/* Read the status */
|
||||||
{MIIM_DM9161_SCSR, miim_read, &mii_parse_dm9161_scsr},
|
{MIIM_DM9161_SCSR, miim_read,
|
||||||
|
&mii_parse_dm9161_scsr},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -1045,7 +1058,8 @@ static struct phy_info phy_info_lxt971 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Parse the DP83865's link and auto-neg status register for speed and duplex
|
/* Parse the DP83865's link and auto-neg status register for speed and duplex
|
||||||
* information */
|
* information
|
||||||
|
*/
|
||||||
uint mii_parse_dp83865_lanr(uint mii_reg, struct tsec_private *priv)
|
uint mii_parse_dp83865_lanr(uint mii_reg, struct tsec_private *priv)
|
||||||
{
|
{
|
||||||
switch (mii_reg & MIIM_DP83865_SPD_MASK) {
|
switch (mii_reg & MIIM_DP83865_SPD_MASK) {
|
||||||
|
@ -1086,7 +1100,8 @@ struct phy_info phy_info_dp83865 = {
|
||||||
/* Auto-negotiate */
|
/* Auto-negotiate */
|
||||||
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
{MIIM_STATUS, miim_read, &mii_parse_sr},
|
||||||
/* Read the link and auto-neg status */
|
/* Read the link and auto-neg status */
|
||||||
{MIIM_DP83865_LANR, miim_read, &mii_parse_dp83865_lanr},
|
{MIIM_DP83865_LANR, miim_read,
|
||||||
|
&mii_parse_dp83865_lanr},
|
||||||
{miim_end,}
|
{miim_end,}
|
||||||
},
|
},
|
||||||
(struct phy_cmd[]){ /* shutdown */
|
(struct phy_cmd[]){ /* shutdown */
|
||||||
|
@ -1109,10 +1124,10 @@ struct phy_info *phy_info[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Grab the identifier of the device's PHY, and search through
|
/* Grab the identifier of the device's PHY, and search through
|
||||||
* all of the known PHYs to see if one matches. If so, return
|
* all of the known PHYs to see if one matches. If so, return
|
||||||
* it, if not, return NULL */
|
* it, if not, return NULL
|
||||||
|
*/
|
||||||
struct phy_info *get_phy_info(struct eth_device *dev)
|
struct phy_info *get_phy_info(struct eth_device *dev)
|
||||||
{
|
{
|
||||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||||
|
@ -1135,8 +1150,7 @@ struct phy_info * get_phy_info(struct eth_device *dev)
|
||||||
theInfo = phy_info[i];
|
theInfo = phy_info[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(theInfo == NULL)
|
if (theInfo == NULL) {
|
||||||
{
|
|
||||||
printf("%s: PHY id %x is not supported!\n", dev->name, phy_ID);
|
printf("%s: PHY id %x is not supported!\n", dev->name, phy_ID);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1146,9 +1160,9 @@ struct phy_info * get_phy_info(struct eth_device *dev)
|
||||||
return theInfo;
|
return theInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Execute the given series of commands on the given device's
|
/* Execute the given series of commands on the given device's
|
||||||
* PHY, running functions as necessary*/
|
* PHY, running functions as necessary
|
||||||
|
*/
|
||||||
void phy_run_commands(struct tsec_private *priv, struct phy_cmd *cmd)
|
void phy_run_commands(struct tsec_private *priv, struct phy_cmd *cmd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -1181,7 +1195,6 @@ void phy_run_commands(struct tsec_private *priv, struct phy_cmd *cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Relocate the function pointers in the phy cmd lists */
|
/* Relocate the function pointers in the phy cmd lists */
|
||||||
static void relocate_cmds(void)
|
static void relocate_cmds(void)
|
||||||
{
|
{
|
||||||
|
@ -1209,7 +1222,9 @@ static void relocate_cmds(void)
|
||||||
j = 0;
|
j = 0;
|
||||||
for (; cmdlistptr <= &phy_info[i]->shutdown; cmdlistptr++) {
|
for (; cmdlistptr <= &phy_info[i]->shutdown; cmdlistptr++) {
|
||||||
k = 0;
|
k = 0;
|
||||||
for(cmd=*cmdlistptr;cmd->mii_reg != miim_end;cmd++) {
|
for (cmd = *cmdlistptr;
|
||||||
|
cmd->mii_reg != miim_end;
|
||||||
|
cmd++) {
|
||||||
/* Only relocate non-NULL pointers */
|
/* Only relocate non-NULL pointers */
|
||||||
if (cmd->funct)
|
if (cmd->funct)
|
||||||
cmd->funct += gd->reloc_off;
|
cmd->funct += gd->reloc_off;
|
||||||
|
@ -1223,7 +1238,6 @@ static void relocate_cmds(void)
|
||||||
relocated = 1;
|
relocated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII) \
|
#if defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII) \
|
||||||
&& !defined(BITBANGMII)
|
&& !defined(BITBANGMII)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue