mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-24 00:21:05 +08:00
Merge pull request #4628 from yangjie11/remove-bsp
[bsp][qemu]更换 smc911 驱动头文件
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -46,12 +46,12 @@ int mdelay(int value)
|
||||
#if defined (CONFIG_SMC911X_32_BIT)
|
||||
rt_inline uint32_t smc911x_reg_read(struct eth_device_smc911x *dev, uint32_t offset)
|
||||
{
|
||||
return *(volatile uint32_t*)(dev->iobase + offset);
|
||||
return *(volatile uint32_t *)(dev->iobase + offset);
|
||||
}
|
||||
|
||||
rt_inline void smc911x_reg_write(struct eth_device_smc911x *dev, uint32_t offset, uint32_t val)
|
||||
{
|
||||
*(volatile uint32_t*)(dev->iobase + offset) = val;
|
||||
*(volatile uint32_t *)(dev->iobase + offset) = val;
|
||||
}
|
||||
|
||||
#elif defined (CONFIG_SMC911X_16_BIT)
|
||||
@@ -78,47 +78,47 @@ struct chip_id
|
||||
|
||||
static const struct chip_id chip_ids[] =
|
||||
{
|
||||
{ CHIP_89218,"LAN89218" },
|
||||
{ CHIP_9115, "LAN9115" },
|
||||
{ CHIP_9116, "LAN9116" },
|
||||
{ CHIP_9117, "LAN9117" },
|
||||
{ CHIP_9118, "LAN9118" },
|
||||
{ CHIP_9211, "LAN9211" },
|
||||
{ CHIP_9215, "LAN9215" },
|
||||
{ CHIP_9216, "LAN9216" },
|
||||
{ CHIP_9217, "LAN9217" },
|
||||
{ CHIP_9218, "LAN9218" },
|
||||
{ CHIP_9220, "LAN9220" },
|
||||
{ CHIP_9221, "LAN9221" },
|
||||
{ LAN9118_ID_89218, "LAN89218" },
|
||||
{ LAN9118_ID_9115, "LAN9115" },
|
||||
{ LAN9118_ID_9116, "LAN9116" },
|
||||
{ LAN9118_ID_9117, "LAN9117" },
|
||||
{ LAN9118_ID_9118, "LAN9118" },
|
||||
{ LAN9210_ID_9211, "LAN9211" },
|
||||
{ LAN9218_ID_9215, "LAN9215" },
|
||||
{ LAN9218_ID_9216, "LAN9216" },
|
||||
{ LAN9218_ID_9217, "LAN9217" },
|
||||
{ LAN9218_ID_9218, "LAN9218" },
|
||||
{ LAN9220_ID_9220, "LAN9220" },
|
||||
{ LAN9220_ID_9221, "LAN9221" },
|
||||
{ 0, RT_NULL },
|
||||
};
|
||||
|
||||
static uint32_t smc911x_get_mac_csr(struct eth_device_smc911x *dev, uint8_t reg)
|
||||
{
|
||||
while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY) ;
|
||||
while (smc911x_reg_read(dev, LAN9118_MAC_CSR_CMD) & LAN9118_MAC_CSR_CMD_BUSY) ;
|
||||
|
||||
smc911x_reg_write(dev, MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | MAC_CSR_CMD_R_NOT_W | reg);
|
||||
smc911x_reg_write(dev, LAN9118_MAC_CSR_CMD, LAN9118_MAC_CSR_CMD_BUSY | LAN9118_MAC_CSR_CMD_R | reg);
|
||||
|
||||
while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY) ;
|
||||
while (smc911x_reg_read(dev, LAN9118_MAC_CSR_CMD) & LAN9118_MAC_CSR_CMD_BUSY) ;
|
||||
|
||||
return smc911x_reg_read(dev, MAC_CSR_DATA);
|
||||
return smc911x_reg_read(dev, LAN9118_MAC_CSR_DATA);
|
||||
}
|
||||
|
||||
static void smc911x_set_mac_csr(struct eth_device_smc911x *dev, uint8_t reg, uint32_t data)
|
||||
{
|
||||
while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY) ;
|
||||
while (smc911x_reg_read(dev, LAN9118_MAC_CSR_CMD) & LAN9118_MAC_CSR_CMD_BUSY) ;
|
||||
|
||||
smc911x_reg_write(dev, MAC_CSR_DATA, data);
|
||||
smc911x_reg_write(dev, MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | reg);
|
||||
smc911x_reg_write(dev, LAN9118_MAC_CSR_DATA, data);
|
||||
smc911x_reg_write(dev, LAN9118_MAC_CSR_CMD, LAN9118_MAC_CSR_CMD_BUSY | reg);
|
||||
|
||||
while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY) ;
|
||||
while (smc911x_reg_read(dev, LAN9118_MAC_CSR_CMD) & LAN9118_MAC_CSR_CMD_BUSY) ;
|
||||
}
|
||||
|
||||
static int smc911x_detect_chip(struct eth_device_smc911x *dev)
|
||||
{
|
||||
unsigned long val, i;
|
||||
|
||||
val = smc911x_reg_read(dev, BYTE_TEST);
|
||||
val = smc911x_reg_read(dev, LAN9118_BYTE_TEST);
|
||||
if (val == 0xffffffff)
|
||||
{
|
||||
/* Special case -- no chip present */
|
||||
@@ -130,7 +130,7 @@ static int smc911x_detect_chip(struct eth_device_smc911x *dev)
|
||||
return -1;
|
||||
}
|
||||
|
||||
val = smc911x_reg_read(dev, ID_REV) >> 16;
|
||||
val = smc911x_reg_read(dev, LAN9118_ID_REV) >> 16;
|
||||
for (i = 0; chip_ids[i].id != 0; i++)
|
||||
{
|
||||
if (chip_ids[i].id == val) break;
|
||||
@@ -151,16 +151,16 @@ static void smc911x_reset(struct eth_device_smc911x *dev)
|
||||
|
||||
/*
|
||||
* Take out of PM setting first
|
||||
* Device is already wake up if PMT_CTRL_READY bit is set
|
||||
* Device is already wake up if LAN9118_PMT_CTRL_READY bit is set
|
||||
*/
|
||||
if ((smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY) == 0)
|
||||
if ((smc911x_reg_read(dev, LAN9118_PMT_CTRL) & LAN9118_PMT_CTRL_READY) == 0)
|
||||
{
|
||||
/* Write to the bytetest will take out of powerdown */
|
||||
smc911x_reg_write(dev, BYTE_TEST, 0x0);
|
||||
smc911x_reg_write(dev, LAN9118_BYTE_TEST, 0x0);
|
||||
|
||||
timeout = 10;
|
||||
|
||||
while (timeout-- && !(smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY))
|
||||
while (timeout-- && !(smc911x_reg_read(dev, LAN9118_PMT_CTRL) & LAN9118_PMT_CTRL_READY))
|
||||
udelay(10);
|
||||
|
||||
if (timeout < 0)
|
||||
@@ -172,11 +172,11 @@ static void smc911x_reset(struct eth_device_smc911x *dev)
|
||||
}
|
||||
|
||||
/* Disable interrupts */
|
||||
smc911x_reg_write(dev, INT_EN, 0);
|
||||
smc911x_reg_write(dev, HW_CFG, HW_CFG_SRST);
|
||||
smc911x_reg_write(dev, LAN9118_INT_EN, 0);
|
||||
smc911x_reg_write(dev, LAN9118_HW_CFG, LAN9118_HW_CFG_SRST);
|
||||
|
||||
timeout = 1000;
|
||||
while (timeout-- && smc911x_reg_read(dev, E2P_CMD) & E2P_CMD_EPC_BUSY)
|
||||
while (timeout-- && smc911x_reg_read(dev, LAN9118_E2P_CMD) & LAN9118_E2P_CMD)
|
||||
udelay(10);
|
||||
|
||||
if (timeout < 0)
|
||||
@@ -186,11 +186,11 @@ static void smc911x_reset(struct eth_device_smc911x *dev)
|
||||
}
|
||||
|
||||
/* Reset the FIFO level and flow control settings */
|
||||
smc911x_set_mac_csr(dev, FLOW, FLOW_FCPT | FLOW_FCEN);
|
||||
smc911x_reg_write(dev, AFC_CFG, 0x0050287F);
|
||||
smc911x_set_mac_csr(dev, LAN9118_FLOW, LAN9118_FLOW_FCPT(0xffff) | LAN9118_FLOW_FCEN);
|
||||
smc911x_reg_write(dev, LAN9118_AFC_CFG, 0x0050287F);
|
||||
|
||||
/* Set to LED outputs */
|
||||
smc911x_reg_write(dev, GPIO_CFG, 0x70070000);
|
||||
smc911x_reg_write(dev, LAN9118_GPIO_CFG, 0x70070000);
|
||||
}
|
||||
|
||||
static void smc911x_handle_mac_address(struct eth_device_smc911x *dev)
|
||||
@@ -201,20 +201,20 @@ static void smc911x_handle_mac_address(struct eth_device_smc911x *dev)
|
||||
addrl = m[0] | (m[1] << 8) | (m[2] << 16) | (m[3] << 24);
|
||||
addrh = m[4] | (m[5] << 8);
|
||||
|
||||
smc911x_set_mac_csr(dev, ADDRL, addrl);
|
||||
smc911x_set_mac_csr(dev, ADDRH, addrh);
|
||||
smc911x_set_mac_csr(dev, LAN9118_ADDRL, addrl);
|
||||
smc911x_set_mac_csr(dev, LAN9118_ADDRH, addrh);
|
||||
}
|
||||
|
||||
static int smc911x_eth_phy_read(struct eth_device_smc911x *dev,
|
||||
uint8_t phy, uint8_t reg, uint16_t *val)
|
||||
{
|
||||
while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY) ;
|
||||
while (smc911x_get_mac_csr(dev, LAN9118_MII_ACC) & LAN9118_MII_ACC_MIIBZY) ;
|
||||
|
||||
smc911x_set_mac_csr(dev, MII_ACC, phy << 11 | reg << 6 | MII_ACC_MII_BUSY);
|
||||
smc911x_set_mac_csr(dev, LAN9118_MII_ACC, phy << 11 | reg << 6 | LAN9118_MII_ACC_MIIBZY);
|
||||
|
||||
while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY) ;
|
||||
while (smc911x_get_mac_csr(dev, LAN9118_MII_ACC) & LAN9118_MII_ACC_MIIBZY) ;
|
||||
|
||||
*val = smc911x_get_mac_csr(dev, MII_DATA);
|
||||
*val = smc911x_get_mac_csr(dev, LAN9118_MII_DATA);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -222,14 +222,14 @@ static int smc911x_eth_phy_read(struct eth_device_smc911x *dev,
|
||||
static int smc911x_eth_phy_write(struct eth_device_smc911x *dev,
|
||||
uint8_t phy, uint8_t reg, uint16_t val)
|
||||
{
|
||||
while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
|
||||
while (smc911x_get_mac_csr(dev, LAN9118_MII_ACC) & LAN9118_MII_ACC_MIIBZY)
|
||||
;
|
||||
|
||||
smc911x_set_mac_csr(dev, MII_DATA, val);
|
||||
smc911x_set_mac_csr(dev, MII_ACC,
|
||||
phy << 11 | reg << 6 | MII_ACC_MII_BUSY | MII_ACC_MII_WRITE);
|
||||
smc911x_set_mac_csr(dev, LAN9118_MII_DATA, val);
|
||||
smc911x_set_mac_csr(dev, LAN9118_MII_ACC,
|
||||
phy << 11 | reg << 6 | LAN9118_MII_ACC_MIIBZY | LAN9118_MII_ACC_MIIWNR);
|
||||
|
||||
while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
|
||||
while (smc911x_get_mac_csr(dev, LAN9118_MII_ACC) & LAN9118_MII_ACC_MIIBZY)
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
@@ -238,10 +238,10 @@ static int smc911x_phy_reset(struct eth_device_smc911x *dev)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = smc911x_reg_read(dev, PMT_CTRL);
|
||||
reg = smc911x_reg_read(dev, LAN9118_PMT_CTRL);
|
||||
reg &= ~0xfffff030;
|
||||
reg |= PMT_CTRL_PHY_RST;
|
||||
smc911x_reg_write(dev, PMT_CTRL, reg);
|
||||
reg |= LAN9118_PMT_CTRL_PHY_RST;
|
||||
smc911x_reg_write(dev, LAN9118_PMT_CTRL, reg);
|
||||
|
||||
mdelay(100);
|
||||
|
||||
@@ -255,10 +255,10 @@ static void smc911x_phy_configure(struct eth_device_smc911x *dev)
|
||||
|
||||
smc911x_phy_reset(dev);
|
||||
|
||||
smc911x_eth_phy_write(dev, 1, MII_BMCR, BMCR_RESET);
|
||||
smc911x_eth_phy_write(dev, 1, LAN9118_MII_BMCR, LAN9118_BMCR_RESET);
|
||||
mdelay(1);
|
||||
smc911x_eth_phy_write(dev, 1, MII_ADVERTISE, 0x01e1);
|
||||
smc911x_eth_phy_write(dev, 1, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
|
||||
smc911x_eth_phy_write(dev, 1, LAN9118_MII_ADVERTISE, 0x01e1);
|
||||
smc911x_eth_phy_write(dev, 1, LAN9118_MII_BMCR, LAN9118_BMCR_ANENABLE | LAN9118_BMCR_ANRESTART);
|
||||
|
||||
timeout = 5000;
|
||||
do
|
||||
@@ -267,10 +267,10 @@ static void smc911x_phy_configure(struct eth_device_smc911x *dev)
|
||||
if ((timeout--) == 0)
|
||||
goto err_out;
|
||||
|
||||
if (smc911x_eth_phy_read(dev, 1, MII_BMSR, &status) != 0)
|
||||
if (smc911x_eth_phy_read(dev, 1, LAN9118_MII_BMSR, &status) != 0)
|
||||
goto err_out;
|
||||
}
|
||||
while (!(status & BMSR_LSTATUS));
|
||||
while (!(status & LAN9118_BMSR_LSTATUS));
|
||||
|
||||
return;
|
||||
|
||||
@@ -281,17 +281,17 @@ err_out:
|
||||
static void smc911x_enable(struct eth_device_smc911x *dev)
|
||||
{
|
||||
/* Enable TX */
|
||||
smc911x_reg_write(dev, HW_CFG, 8 << 16 | HW_CFG_SF);
|
||||
smc911x_reg_write(dev, LAN9118_HW_CFG, 8 << 16 | LAN9118_HW_CFG_SF);
|
||||
|
||||
smc911x_reg_write(dev, GPT_CFG, GPT_CFG_TIMER_EN | 10000);
|
||||
smc911x_reg_write(dev, LAN9118_GPT_CFG, LAN9118_GPT_CFG_TIMER_EN | 10000);
|
||||
|
||||
smc911x_reg_write(dev, TX_CFG, TX_CFG_TX_ON);
|
||||
smc911x_reg_write(dev, LAN9118_TX_CFG, LAN9118_TX_CFG_TX_ON);
|
||||
|
||||
/* no padding to start of packets */
|
||||
smc911x_reg_write(dev, RX_CFG, 0);
|
||||
smc911x_reg_write(dev, LAN9118_RX_CFG, 0);
|
||||
|
||||
smc911x_set_mac_csr(dev, MAC_CR, MAC_CR_TXEN | MAC_CR_RXEN |
|
||||
MAC_CR_HBDIS);
|
||||
smc911x_set_mac_csr(dev, LAN9118_MAC_CR, LAN9118_MAC_CR_TXEN | LAN9118_MAC_CR_RXEN |
|
||||
LAN9118_MAC_CR_HBDIS);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
|
||||
@@ -329,13 +329,13 @@ static void smc911x_isr(int vector, void *param)
|
||||
|
||||
emac = SMC911X_EMAC_DEVICE(param);
|
||||
|
||||
status = smc911x_reg_read(emac, INT_STS);
|
||||
|
||||
if (status & INT_STS_RSFL)
|
||||
status = smc911x_reg_read(emac, LAN9118_INT_STS);
|
||||
|
||||
if (status & LAN9118_INT_STS_RSFL)
|
||||
{
|
||||
eth_device_ready(&emac->parent);
|
||||
}
|
||||
smc911x_reg_write(emac, INT_STS, status);
|
||||
smc911x_reg_write(emac, LAN9118_INT_STS, status);
|
||||
|
||||
return ;
|
||||
}
|
||||
@@ -359,18 +359,18 @@ static rt_err_t smc911x_emac_init(rt_device_t dev)
|
||||
|
||||
#if 1
|
||||
/* Interrupt on every received packet */
|
||||
smc911x_reg_write(emac, FIFO_INT, 0x01 << 8);
|
||||
smc911x_reg_write(emac, INT_EN, INT_EN_RDFL_EN | INT_EN_RSFL_EN);
|
||||
smc911x_reg_write(emac, LAN9118_FIFO_INT, 0x01 << 8);
|
||||
smc911x_reg_write(emac, LAN9118_INT_EN, LAN9118_INT_EN_RDFL_EN | LAN9118_INT_RSFL);
|
||||
|
||||
/* enable interrupt */
|
||||
smc911x_reg_write(emac, INT_CFG, INT_CFG_IRQ_EN | INT_CFG_IRQ_POL | INT_CFG_IRQ_TYPE);
|
||||
smc911x_reg_write(emac, LAN9118_IRQ_CFG, LAN9118_IRQ_CFG_IRQ_EN | LAN9118_IRQ_CFG_IRQ_POL | LAN9118_IRQ_CFG_IRQ_TYPE);
|
||||
#else
|
||||
|
||||
/* disable interrupt */
|
||||
smc911x_reg_write(emac, INT_EN, 0);
|
||||
value = smc911x_reg_read(emac, INT_CFG);
|
||||
value &= ~INT_CFG_IRQ_EN;
|
||||
smc911x_reg_write(emac, INT_CFG, value);
|
||||
smc911x_reg_write(emac, LAN9118_INT_EN, 0);
|
||||
value = smc911x_reg_read(emac, LAN9118_IRQ_CFG);
|
||||
value &= ~LAN9118_IRQ_CFG_IRQ_EN;
|
||||
smc911x_reg_write(emac, LAN9118_IRQ_CFG, value);
|
||||
#endif
|
||||
|
||||
rt_hw_interrupt_install(emac->irqno, smc911x_isr, emac, "smc911x");
|
||||
@@ -386,11 +386,11 @@ static rt_err_t smc911x_emac_control(rt_device_t dev, int cmd, void *args)
|
||||
emac = SMC911X_EMAC_DEVICE(dev);
|
||||
RT_ASSERT(emac != RT_NULL);
|
||||
|
||||
switch(cmd)
|
||||
switch (cmd)
|
||||
{
|
||||
case NIOCTL_GADDR:
|
||||
/* get MAC address */
|
||||
if(args) rt_memcpy(args, emac->enetaddr, 6);
|
||||
if (args) rt_memcpy(args, emac->enetaddr, 6);
|
||||
else return -RT_ERROR;
|
||||
break;
|
||||
default :
|
||||
@@ -402,7 +402,7 @@ static rt_err_t smc911x_emac_control(rt_device_t dev, int cmd, void *args)
|
||||
/* Ethernet device interface */
|
||||
/* transmit packet. */
|
||||
static uint8_t tx_buf[2048];
|
||||
rt_err_t smc911x_emac_tx(rt_device_t dev, struct pbuf* p)
|
||||
rt_err_t smc911x_emac_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
struct eth_device_smc911x *emac;
|
||||
|
||||
@@ -418,36 +418,36 @@ rt_err_t smc911x_emac_tx(rt_device_t dev, struct pbuf* p)
|
||||
pbuf_copy_partial(p, tx_buf, p->tot_len, 0);
|
||||
|
||||
/* send it out */
|
||||
data = (uint32_t*)tx_buf;
|
||||
data = (uint32_t *)tx_buf;
|
||||
length = p->tot_len;
|
||||
|
||||
smc911x_reg_write(emac, TX_DATA_FIFO, TX_CMD_A_INT_FIRST_SEG | TX_CMD_A_INT_LAST_SEG | length);
|
||||
smc911x_reg_write(emac, TX_DATA_FIFO, length);
|
||||
smc911x_reg_write(emac, LAN9118_TXDFIFOP, LAN9118_TXC_A_FS | LAN9118_TXC_A_LS | length);
|
||||
smc911x_reg_write(emac, LAN9118_TXDFIFOP, length);
|
||||
|
||||
tmplen = (length + 3) / 4;
|
||||
while (tmplen--)
|
||||
{
|
||||
smc911x_reg_write(emac, TX_DATA_FIFO, *data++);
|
||||
smc911x_reg_write(emac, LAN9118_TXDFIFOP, *data++);
|
||||
}
|
||||
|
||||
/* wait for transmission */
|
||||
while (!((smc911x_reg_read(emac, TX_FIFO_INF) & TX_FIFO_INF_TSUSED) >> 16));
|
||||
while (!(LAN9118_TX_FIFO_INF_TXSUSED(smc911x_reg_read(emac, LAN9118_TX_FIFO_INF))));
|
||||
|
||||
/* get status. Ignore 'no carrier' error, it has no meaning for
|
||||
* full duplex operation
|
||||
*/
|
||||
status = smc911x_reg_read(emac, TX_STATUS_FIFO) &
|
||||
(TX_STS_LOC | TX_STS_LATE_COLL | TX_STS_MANY_COLL |
|
||||
TX_STS_MANY_DEFER | TX_STS_UNDERRUN);
|
||||
status = smc911x_reg_read(emac, LAN9118_TXSFIFOP) &
|
||||
(LAN9118_TXS_LOC | LAN9118_TXS_LCOL | LAN9118_TXS_ECOL |
|
||||
LAN9118_TXS_ED | LAN9118_TX_STS_UNDERRUN);
|
||||
|
||||
if (!status) return 0;
|
||||
|
||||
rt_kprintf(DRIVERNAME ": failed to send packet: %s%s%s%s%s\n",
|
||||
status & TX_STS_LOC ? "TX_STS_LOC " : "",
|
||||
status & TX_STS_LATE_COLL ? "TX_STS_LATE_COLL " : "",
|
||||
status & TX_STS_MANY_COLL ? "TX_STS_MANY_COLL " : "",
|
||||
status & TX_STS_MANY_DEFER ? "TX_STS_MANY_DEFER " : "",
|
||||
status & TX_STS_UNDERRUN ? "TX_STS_UNDERRUN" : "");
|
||||
status & LAN9118_TXS_LOC ? "LAN9118_TXS_LOC " : "",
|
||||
status & LAN9118_TXS_LCOL ? "LAN9118_TXS_LCOL " : "",
|
||||
status & LAN9118_TXS_ECOL ? "LAN9118_TXS_ECOL " : "",
|
||||
status & LAN9118_TXS_ED ? "LAN9118_TXS_ED " : "",
|
||||
status & LAN9118_TX_STS_UNDERRUN ? "LAN9118_TX_STS_UNDERRUN" : "");
|
||||
|
||||
return -RT_EIO;
|
||||
}
|
||||
@@ -455,24 +455,24 @@ rt_err_t smc911x_emac_tx(rt_device_t dev, struct pbuf* p)
|
||||
/* reception packet. */
|
||||
struct pbuf *smc911x_emac_rx(rt_device_t dev)
|
||||
{
|
||||
struct pbuf* p = RT_NULL;
|
||||
struct pbuf *p = RT_NULL;
|
||||
struct eth_device_smc911x *emac;
|
||||
|
||||
emac = SMC911X_EMAC_DEVICE(dev);
|
||||
RT_ASSERT(emac != RT_NULL);
|
||||
|
||||
/* take the emac buffer to the pbuf */
|
||||
if ((smc911x_reg_read(emac, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED) >> 16)
|
||||
if (LAN9118_RX_FIFO_INF_RXSUSED(smc911x_reg_read(emac, LAN9118_RX_FIFO_INF)))
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t pktlen, tmplen;
|
||||
|
||||
status = smc911x_reg_read(emac, RX_STATUS_FIFO);
|
||||
status = smc911x_reg_read(emac, LAN9118_RXSFIFOP);
|
||||
|
||||
/* get frame length */
|
||||
pktlen = (status & RX_STS_PKT_LEN) >> 16;
|
||||
pktlen = (status & LAN9118_RX_STS_PKT_LEN) >> 16;
|
||||
|
||||
smc911x_reg_write(emac, RX_CFG, 0);
|
||||
smc911x_reg_write(emac, LAN9118_RX_CFG, 0);
|
||||
|
||||
tmplen = (pktlen + 3) / 4;
|
||||
|
||||
@@ -483,11 +483,11 @@ struct pbuf *smc911x_emac_rx(rt_device_t dev)
|
||||
uint32_t *data = (uint32_t *)p->payload;
|
||||
while (tmplen--)
|
||||
{
|
||||
*data++ = smc911x_reg_read(emac, RX_DATA_FIFO);
|
||||
*data++ = smc911x_reg_read(emac, LAN9118_RXDFIFOP);
|
||||
}
|
||||
}
|
||||
|
||||
if (status & RX_STS_ES)
|
||||
if (status & LAN9118_RXS_ES)
|
||||
{
|
||||
rt_kprintf(DRIVERNAME ": dropped bad packet. Status: 0x%08x\n", status);
|
||||
}
|
||||
@@ -497,7 +497,7 @@ struct pbuf *smc911x_emac_rx(rt_device_t dev)
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops smc911x_emac_ops =
|
||||
const static struct rt_device_ops smc911x_emac_ops =
|
||||
{
|
||||
smc911x_emac_init,
|
||||
RT_NULL,
|
||||
@@ -520,7 +520,7 @@ int smc911x_emac_hw_init(void)
|
||||
}
|
||||
|
||||
/* set INT CFG */
|
||||
smc911x_reg_write(&_emac, INT_CFG, INT_CFG_IRQ_POL | INT_CFG_IRQ_TYPE);
|
||||
smc911x_reg_write(&_emac, LAN9118_IRQ_CFG, LAN9118_IRQ_CFG_IRQ_POL | LAN9118_IRQ_CFG_IRQ_TYPE);
|
||||
|
||||
/* test MAC address */
|
||||
_emac.enetaddr[0] = AUTOMAC0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user