/* Reads a packet out of the RX_DATA_FIFO */ staticinlinevoid
smsc911x_rx_readfifo(struct smsc911x_data *pdata, unsignedint *buf, unsignedint wordcount)
{ unsignedlong flags;
spin_lock_irqsave(&pdata->dev_lock, flags);
if (pdata->config.flags & SMSC911X_SWAP_FIFO) { while (wordcount--)
*buf++ = swab32(__smsc911x_reg_read(pdata,
RX_DATA_FIFO)); goto out;
}
/* Reads a packet out of the RX_DATA_FIFO - shifted version */ staticinlinevoid
smsc911x_rx_readfifo_shift(struct smsc911x_data *pdata, unsignedint *buf, unsignedint wordcount)
{ unsignedlong flags;
spin_lock_irqsave(&pdata->dev_lock, flags);
if (pdata->config.flags & SMSC911X_SWAP_FIFO) { while (wordcount--)
*buf++ = swab32(__smsc911x_reg_read_shift(pdata,
RX_DATA_FIFO)); goto out;
}
/* * enable regulator and clock resources.
*/ staticint smsc911x_enable_resources(struct platform_device *pdev)
{ struct net_device *ndev = platform_get_drvdata(pdev); struct smsc911x_data *pdata = netdev_priv(ndev); int ret = 0;
ret = regulator_bulk_enable(ARRAY_SIZE(pdata->supplies),
pdata->supplies); if (ret)
netdev_err(ndev, "failed to enable regulators %d\n",
ret);
if (!IS_ERR(pdata->clk)) {
ret = clk_prepare_enable(pdata->clk); if (ret < 0)
netdev_err(ndev, "failed to enable clock %d\n", ret);
}
return ret;
}
/* * disable resources, currently just regulators.
*/ staticint smsc911x_disable_resources(struct platform_device *pdev)
{ struct net_device *ndev = platform_get_drvdata(pdev); struct smsc911x_data *pdata = netdev_priv(ndev); int ret = 0;
ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies),
pdata->supplies);
if (!IS_ERR(pdata->clk))
clk_disable_unprepare(pdata->clk);
return ret;
}
/* * Request resources, currently just regulators. * * The SMSC911x has two power pins: vddvario and vdd33a, in designs where * these are not always-on we need to request regulators to be turned on * before we can try to access the device registers.
*/ staticint smsc911x_request_resources(struct platform_device *pdev)
{ struct net_device *ndev = platform_get_drvdata(pdev); struct smsc911x_data *pdata = netdev_priv(ndev); int ret = 0;
/* Request regulators */
pdata->supplies[0].supply = "vdd33a";
pdata->supplies[1].supply = "vddvario";
ret = regulator_bulk_get(&pdev->dev,
ARRAY_SIZE(pdata->supplies),
pdata->supplies); if (ret) { /* * Retry on deferrals, else just report the error * and try to continue.
*/ if (ret == -EPROBE_DEFER) return ret;
netdev_err(ndev, "couldn't get regulators %d\n",
ret);
}
/* waits for MAC not busy, with timeout. Only called by smsc911x_mac_read
* and smsc911x_mac_write, so assumes mac_lock is held */ staticint smsc911x_mac_complete(struct smsc911x_data *pdata)
{ int i;
u32 val;
SMSC_ASSERT_MAC_LOCK(pdata);
for (i = 0; i < 40; i++) {
val = smsc911x_reg_read(pdata, MAC_CSR_CMD); if (!(val & MAC_CSR_CMD_CSR_BUSY_)) return 0;
}
SMSC_WARN(pdata, hw, "Timed out waiting for MAC not BUSY. " "MAC_CSR_CMD: 0x%08X", val); return -EIO;
}
/* Fetches a MAC register value. Assumes mac_lock is acquired */ static u32 smsc911x_mac_read(struct smsc911x_data *pdata, unsignedint offset)
{ unsignedint temp;
SMSC_ASSERT_MAC_LOCK(pdata);
temp = smsc911x_reg_read(pdata, MAC_CSR_CMD); if (unlikely(temp & MAC_CSR_CMD_CSR_BUSY_)) {
SMSC_WARN(pdata, hw, "MAC busy at entry"); return 0xFFFFFFFF;
}
/* Send the MAC cmd */
smsc911x_reg_write(pdata, MAC_CSR_CMD, ((offset & 0xFF) |
MAC_CSR_CMD_CSR_BUSY_ | MAC_CSR_CMD_R_NOT_W_));
/* Wait for the read to complete */ if (likely(smsc911x_mac_complete(pdata) == 0)) return smsc911x_reg_read(pdata, MAC_CSR_DATA);
SMSC_WARN(pdata, hw, "MAC busy after read"); return 0xFFFFFFFF;
}
/* Set a mac register, mac_lock must be acquired before calling */ staticvoid smsc911x_mac_write(struct smsc911x_data *pdata, unsignedint offset, u32 val)
{ unsignedint temp;
SMSC_ASSERT_MAC_LOCK(pdata);
temp = smsc911x_reg_read(pdata, MAC_CSR_CMD); if (unlikely(temp & MAC_CSR_CMD_CSR_BUSY_)) {
SMSC_WARN(pdata, hw, "smsc911x_mac_write failed, MAC busy at entry"); return;
}
/* Send data to write */
smsc911x_reg_write(pdata, MAC_CSR_DATA, val);
/* Write the actual data */
smsc911x_reg_write(pdata, MAC_CSR_CMD, ((offset & 0xFF) |
MAC_CSR_CMD_CSR_BUSY_));
/* Wait for the write to complete */ if (likely(smsc911x_mac_complete(pdata) == 0)) return;
SMSC_WARN(pdata, hw, "smsc911x_mac_write failed, MAC busy after write");
}
/* Get a phy register */ staticint smsc911x_mii_read(struct mii_bus *bus, int phyaddr, int regidx)
{ struct smsc911x_data *pdata = bus->priv; unsignedlong flags; unsignedint addr; int i, reg;
/* Confirm MII not busy */ if (unlikely(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
SMSC_WARN(pdata, hw, "MII is busy in smsc911x_mii_read???");
reg = -EIO; goto out;
}
/* Set the address, index & direction (read from PHY) */
addr = ((phyaddr & 0x1F) << 11) | ((regidx & 0x1F) << 6);
smsc911x_mac_write(pdata, MII_ACC, addr);
/* Wait for read to complete w/ timeout */ for (i = 0; i < 100; i++) if (!(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
reg = smsc911x_mac_read(pdata, MII_DATA); goto out;
}
SMSC_WARN(pdata, hw, "Timed out waiting for MII read to finish");
reg = -EIO;
/* Set a phy register */ staticint smsc911x_mii_write(struct mii_bus *bus, int phyaddr, int regidx,
u16 val)
{ struct smsc911x_data *pdata = bus->priv; unsignedlong flags; unsignedint addr; int i, reg;
/* Confirm MII not busy */ if (unlikely(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
SMSC_WARN(pdata, hw, "MII is busy in smsc911x_mii_write???");
reg = -EIO; goto out;
}
/* Put the data to write in the MAC */
smsc911x_mac_write(pdata, MII_DATA, val);
/* Set the address, index & direction (write to PHY) */
addr = ((phyaddr & 0x1F) << 11) | ((regidx & 0x1F) << 6) |
MII_ACC_MII_WRITE_;
smsc911x_mac_write(pdata, MII_ACC, addr);
/* Wait for write to complete w/ timeout */ for (i = 0; i < 100; i++) if (!(smsc911x_mac_read(pdata, MII_ACC) & MII_ACC_MII_BUSY_)) {
reg = 0; goto out;
}
SMSC_WARN(pdata, hw, "Timed out waiting for MII write to finish");
reg = -EIO;
/* Switch to external phy. Assumes tx and rx are stopped. */ staticvoid smsc911x_phy_enable_external(struct smsc911x_data *pdata)
{ unsignedint hwcfg = smsc911x_reg_read(pdata, HW_CFG);
/* Disable phy clocks to the MAC */
hwcfg &= (~HW_CFG_PHY_CLK_SEL_);
hwcfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS_;
smsc911x_reg_write(pdata, HW_CFG, hwcfg);
udelay(10); /* Enough time for clocks to stop */
/* Enable phy clocks to the MAC */
hwcfg &= (~HW_CFG_PHY_CLK_SEL_);
hwcfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY_;
smsc911x_reg_write(pdata, HW_CFG, hwcfg);
udelay(10); /* Enough time for clocks to restart */
/* Autodetects and enables external phy if present on supported chips. * autodetection can be overridden by specifying SMSC911X_FORCE_INTERNAL_PHY
* or SMSC911X_FORCE_EXTERNAL_PHY in the platform_data flags. */ staticvoid smsc911x_phy_initialise_external(struct smsc911x_data *pdata)
{ unsignedint hwcfg = smsc911x_reg_read(pdata, HW_CFG);
/* Fetches a tx status out of the status fifo */ staticunsignedint smsc911x_tx_get_txstatus(struct smsc911x_data *pdata)
{ unsignedint result =
smsc911x_reg_read(pdata, TX_FIFO_INF) & TX_FIFO_INF_TSUSED_;
if (result != 0)
result = smsc911x_reg_read(pdata, TX_STATUS_FIFO);
return result;
}
/* Fetches the next rx status */ staticunsignedint smsc911x_rx_get_rxstatus(struct smsc911x_data *pdata)
{ unsignedint result =
smsc911x_reg_read(pdata, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED_;
if (result != 0)
result = smsc911x_reg_read(pdata, RX_STATUS_FIFO);
if (unlikely(temp & PMT_CTRL_PHY_RST_)) {
SMSC_WARN(pdata, hw, "PHY reset failed to complete"); return -EIO;
} /* Extra delay required because the phy may not be completed with * its reset when BMCR_RESET is cleared. Specs say 256 uS is
* enough delay but using 1ms here to be safe */
msleep(1);
return 0;
}
staticint smsc911x_phy_loopbacktest(struct net_device *dev)
{ struct smsc911x_data *pdata = netdev_priv(dev); struct phy_device *phy_dev = dev->phydev; int result = -EIO; unsignedint i, val; unsignedlong flags;
/* Initialise tx packet using broadcast destination address */
eth_broadcast_addr(pdata->loopback_tx_pkt);
/* Use incrementing source address */ for (i = 6; i < 12; i++)
pdata->loopback_tx_pkt[i] = (char)i;
/* Set length type field */
pdata->loopback_tx_pkt[12] = 0x00;
pdata->loopback_tx_pkt[13] = 0x00;
for (i = 14; i < MIN_PACKET_SIZE; i++)
pdata->loopback_tx_pkt[i] = (char)i;
val = smsc911x_reg_read(pdata, HW_CFG);
val &= HW_CFG_TX_FIF_SZ_;
val |= HW_CFG_SF_;
smsc911x_reg_write(pdata, HW_CFG, val);
for (i = 0; i < 10; i++) { /* Set PHY to 10/FD, no ANEG, and loopback mode */
smsc911x_mii_write(phy_dev->mdio.bus, phy_dev->mdio.addr,
MII_BMCR, BMCR_LOOPBACK | BMCR_FULLDPLX);
/* Update link mode if anything has changed. Called periodically when the
* PHY is in polling mode, even if nothing has changed. */ staticvoid smsc911x_phy_adjust_link(struct net_device *dev)
{ struct smsc911x_data *pdata = netdev_priv(dev); struct phy_device *phy_dev = dev->phydev; unsignedlong flags; int carrier;
if (phy_dev->duplex != pdata->last_duplex) { unsignedint mac_cr;
SMSC_TRACE(pdata, hw, "duplex state has changed");
spin_lock_irqsave(&pdata->mac_lock, flags);
mac_cr = smsc911x_mac_read(pdata, MAC_CR); if (phy_dev->duplex) {
SMSC_TRACE(pdata, hw, "configuring for full duplex mode");
mac_cr |= MAC_CR_FDPX_;
} else {
SMSC_TRACE(pdata, hw, "configuring for half duplex mode");
mac_cr &= ~MAC_CR_FDPX_;
}
smsc911x_mac_write(pdata, MAC_CR, mac_cr);
spin_unlock_irqrestore(&pdata->mac_lock, flags);
/* Gets the number of tx statuses in the fifo */ staticunsignedint smsc911x_tx_get_txstatcount(struct smsc911x_data *pdata)
{ return (smsc911x_reg_read(pdata, TX_FIFO_INF)
& TX_FIFO_INF_TSUSED_) >> 16;
}
while ((tx_stat = smsc911x_tx_get_txstatus(pdata)) != 0) { if (unlikely(tx_stat & 0x80000000)) { /* In this driver the packet tag is used as the packet * length. Since a packet length can never reach the * size of 0x8000, this bit is reserved. It is worth * noting that the "reserved bit" in the warning above * does not reference a hardware defined reserved bit * but rather a driver defined one.
*/
SMSC_WARN(pdata, hw, "Packet tag reserved bit is high");
} else { if (unlikely(tx_stat & TX_STS_ES_)) {
dev->stats.tx_errors++;
} else {
dev->stats.tx_packets++;
dev->stats.tx_bytes += (tx_stat >> 16);
} if (unlikely(tx_stat & TX_STS_EXCESS_COL_)) {
dev->stats.collisions += 16;
dev->stats.tx_aborted_errors += 1;
} else {
dev->stats.collisions +=
((tx_stat >> 3) & 0xF);
} if (unlikely(tx_stat & TX_STS_LOST_CARRIER_))
dev->stats.tx_carrier_errors += 1; if (unlikely(tx_stat & TX_STS_LATE_COL_)) {
dev->stats.collisions++;
dev->stats.tx_aborted_errors++;
}
}
}
}
/* Increments the Rx error counters */ staticvoid
smsc911x_rx_counterrors(struct net_device *dev, unsignedint rxstat)
{ int crc_err = 0;
if (unlikely(rxstat & RX_STS_ES_)) {
dev->stats.rx_errors++; if (unlikely(rxstat & RX_STS_CRC_ERR_)) {
dev->stats.rx_crc_errors++;
crc_err = 1;
}
} if (likely(!crc_err)) { if (unlikely((rxstat & RX_STS_FRAME_TYPE_) &&
(rxstat & RX_STS_LENGTH_ERR_)))
dev->stats.rx_length_errors++; if (rxstat & RX_STS_MCAST_)
dev->stats.multicast++;
}
}
/* Quickly dumps bad packets */ staticvoid
smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsignedint pktwords)
{ if (likely(pktwords >= 4)) { unsignedint timeout = 500; unsignedint val;
smsc911x_reg_write(pdata, RX_DP_CTRL, RX_DP_CTRL_RX_FFWD_); do {
udelay(1);
val = smsc911x_reg_read(pdata, RX_DP_CTRL);
} while ((val & RX_DP_CTRL_RX_FFWD_) && --timeout);
if (unlikely(timeout == 0))
SMSC_WARN(pdata, hw, "Timed out waiting for " "RX FFWD to finish, RX_DP_CTRL: 0x%08X", val);
} else { while (pktwords--)
smsc911x_reg_read(pdata, RX_DATA_FIFO);
}
}
/* NAPI poll function */ staticint smsc911x_poll(struct napi_struct *napi, int budget)
{ struct smsc911x_data *pdata =
container_of(napi, struct smsc911x_data, napi); struct net_device *dev = pdata->dev; int npackets = 0;
if (unlikely(rxstat & RX_STS_ES_)) {
SMSC_WARN(pdata, rx_err, "Discarding packet with error bit set"); /* Packet has an error, discard it and continue with
* the next */
smsc911x_rx_fastforward(pdata, pktwords);
dev->stats.rx_dropped++; continue;
}
skb = netdev_alloc_skb(dev, pktwords << 2); if (unlikely(!skb)) {
SMSC_WARN(pdata, rx_err, "Unable to allocate skb for rx packet"); /* Drop the packet and stop this polling iteration */
smsc911x_rx_fastforward(pdata, pktwords);
dev->stats.rx_dropped++; break;
}
/* Return total received packets */ return npackets;
}
/* Returns hash bit number for given MAC address * Example:
* 01 00 5E 00 00 01 -> returns bit number 31 */ staticunsignedint smsc911x_hash(char addr[ETH_ALEN])
{ return (ether_crc(ETH_ALEN, addr) >> 26) & 0x3f;
}
staticvoid smsc911x_rx_multicast_update(struct smsc911x_data *pdata)
{ /* Performs the multicast & mac_cr update. This is called when
* safe on the current hardware, and with the mac_lock held */ unsignedint mac_cr;
/* This function is only called for older LAN911x devices * (revA or revB), where MAC_CR, HASHH and HASHL should not * be modified during Rx - newer devices immediately update the * registers. *
* This is called from interrupt context */
spin_lock(&pdata->mac_lock);
/* Check Rx has stopped */ if (smsc911x_mac_read(pdata, MAC_CR) & MAC_CR_RXEN_)
SMSC_WARN(pdata, drv, "Rx not stopped");
/* Perform the update - safe to do now Rx has stopped */
smsc911x_rx_multicast_update(pdata);
/* If the internal PHY is in General Power-Down mode, all, except the * management interface, is powered-down and stays in that condition as * long as Phy register bit 0.11 is HIGH. * * In that case, clear the bit 0.11, so the PHY powers up and we can * access to the phy registers.
*/
rc = phy_read(phy_dev, MII_BMCR); if (rc < 0) {
SMSC_WARN(pdata, drv, "Failed reading PHY control reg"); return rc;
}
/* If the PHY general power-down bit is not set is not necessary to * disable the general power down-mode.
*/ if (rc & BMCR_PDOWN) {
rc = phy_write(phy_dev, MII_BMCR, rc & ~BMCR_PDOWN); if (rc < 0) {
SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); return rc;
}
if (rc < 0) {
SMSC_WARN(pdata, drv, "Failed reading PHY control reg"); return rc;
}
/* Only disable if energy detect mode is already enabled */ if (rc & MII_LAN83C185_EDPWRDOWN) { /* Disable energy detect mode for this SMSC Transceivers */
rc = phy_write(phy_dev, MII_LAN83C185_CTRL_STATUS,
rc & (~MII_LAN83C185_EDPWRDOWN));
if (rc < 0) {
SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); return rc;
} /* Allow PHY to wakeup */
mdelay(2);
}
if (rc < 0) {
SMSC_WARN(pdata, drv, "Failed reading PHY control reg"); return rc;
}
/* Only enable if energy detect mode is already disabled */ if (!(rc & MII_LAN83C185_EDPWRDOWN)) { /* Enable energy detect mode for this SMSC Transceivers */
rc = phy_write(phy_dev, MII_LAN83C185_CTRL_STATUS,
rc | MII_LAN83C185_EDPWRDOWN);
if (rc < 0) {
SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); return rc;
}
} return 0;
}
/* * Make sure to power-up the PHY chip before doing a reset, otherwise * the reset fails.
*/
ret = smsc911x_phy_general_power_up(pdata); if (ret) {
SMSC_WARN(pdata, drv, "Failed to power-up the PHY chip"); return ret;
}
/* * LAN9210/LAN9211/LAN9220/LAN9221 chips have an internal PHY that * are initialized in a Energy Detect Power-Down mode that prevents * the MAC chip to be software reseted. So we have to wakeup the PHY * before.
*/ if (pdata->generation == 4) {
ret = smsc911x_phy_disable_energy_detect(pdata);
if (ret) {
SMSC_WARN(pdata, drv, "Failed to wakeup the PHY chip"); return ret;
}
}
if ((pdata->idrev & 0xFFFF0000) == LAN9250) { /* special reset for LAN9250 */
reset_offset = RESET_CTL;
reset_mask = RESET_CTL_DIGITAL_RST_;
}
/* Reset the LAN911x */
smsc911x_reg_write(pdata, reset_offset, reset_mask);
/* verify reset bit is cleared */
timeout = 10; do {
udelay(10);
temp = smsc911x_reg_read(pdata, reset_offset);
} while ((--timeout) && (temp & reset_mask));
if (unlikely(temp & reset_mask)) {
SMSC_WARN(pdata, drv, "Failed to complete reset"); return -EIO;
}
if (pdata->generation == 4) {
ret = smsc911x_phy_enable_energy_detect(pdata);
if (ret) {
SMSC_WARN(pdata, drv, "Failed to wakeup the PHY chip"); return ret;
}
}
return 0;
}
/* Sets the device MAC address to dev_addr, called with mac_lock held */ staticvoid
smsc911x_set_hw_mac_address(struct smsc911x_data *pdata, const u8 dev_addr[6])
{
u32 mac_high16 = (dev_addr[5] << 8) | dev_addr[4];
u32 mac_low32 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
(dev_addr[1] << 8) | dev_addr[0];
if (unlikely(intsts & inten & INT_STS_RXSTOP_INT_)) { /* Called when there is a multicast update scheduled and
* it is now safe to complete the update */
SMSC_TRACE(pdata, intr, "RX Stop interrupt");
smsc911x_reg_write(pdata, INT_STS, INT_STS_RXSTOP_INT_); if (pdata->multicast_update_pending)
smsc911x_rx_multicast_update_workaround(pdata);
serviced = IRQ_HANDLED;
}
/* Increase the legal frame size of VLAN tagged frames to 1522 bytes */
spin_lock_irq(&pdata->mac_lock);
smsc911x_mac_write(pdata, VLAN1, ETH_P_8021Q);
spin_unlock_irq(&pdata->mac_lock);
/* Make sure EEPROM has finished loading before setting GPIO_CFG */
timeout = 50; while ((smsc911x_reg_read(pdata, E2P_CMD) & E2P_CMD_EPC_BUSY_) &&
--timeout) {
udelay(10);
}
if (unlikely(timeout == 0))
SMSC_WARN(pdata, ifup, "Timed out waiting for EEPROM busy bit to clear");
smsc911x_reg_write(pdata, GPIO_CFG, 0x70070000);
/* The soft reset above cleared the device's MAC address,
* restore it from local copy (set in probe) */
spin_lock_irq(&pdata->mac_lock);
smsc911x_set_hw_mac_address(pdata, dev->dev_addr);
spin_unlock_irq(&pdata->mac_lock);
/* Initialise irqs, but leave all sources disabled */
smsc911x_disable_irq_chip(dev);
/* Set interrupt deassertion to 100uS */
intcfg = ((10 << 24) | INT_CFG_IRQ_EN_);
if (pdata->config.irq_polarity) {
SMSC_TRACE(pdata, ifup, "irq polarity: active high");
intcfg |= INT_CFG_IRQ_POL_;
} else {
SMSC_TRACE(pdata, ifup, "irq polarity: active low");
}
/* Stop Tx and Rx polling */
netif_stop_queue(dev);
napi_disable(&pdata->napi);
/* At this point all Rx and Tx activity is stopped */
dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
smsc911x_tx_update_txcounters(dev);
free_irq(dev->irq, dev);
/* Bring the PHY down */ if (dev->phydev) {
phy_stop(dev->phydev);
phy_disconnect(dev->phydev);
}
netif_carrier_off(dev);
pm_runtime_put(dev->dev.parent);
if (pdata->generation <= 1) { /* Older hardware revision - cannot change these flags while
* receiving data */ if (!pdata->multicast_update_pending) { unsignedint temp;
SMSC_TRACE(pdata, hw, "scheduling mcast update");
pdata->multicast_update_pending = 1;
/* Request the hardware to stop, then perform the
* update when we get an RX_STOP interrupt */
temp = smsc911x_mac_read(pdata, MAC_CR);
temp &= ~(MAC_CR_RXEN_);
smsc911x_mac_write(pdata, MAC_CR, temp);
} else { /* There is another update pending, this should now
* use the newer values */
}
} else { /* Newer hardware revision - can write immediately */
smsc911x_rx_multicast_update(pdata);
}
/* On older hardware revisions we cannot change the mac address * registers while receiving data. Newer devices can safely change
* this at any time. */ if (pdata->generation <= 1 && netif_running(dev)) return -EBUSY;
if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL;
len = min(eeprom->len, SMSC911X_EEPROM_SIZE); for (i = 0; i < len; i++) { int ret = smsc911x_eeprom_read_location(pdata, i, eeprom_data); if (ret < 0) {
eeprom->len = 0; return ret;
}
}
/* The first mac_read in some setups can incorrectly read 0. Re-read it * to get the full MAC if this is observed.
*/ if (mac_high16 == 0) {
SMSC_TRACE(pdata, probe, "Re-read MAC ADDRH\n");
mac_high16 = smsc911x_mac_read(pdata, ADDRH);
}
/* * poll the READY bit in PMT_CTRL. Any other access to the device is * forbidden while this bit isn't set. Try for 100ms * * Note that this test is done before the WORD_SWAP register is * programmed. So in some configurations the READY bit is at 16 before * WORD_SWAP is written to. This issue is worked around by waiting * until either bit 0 or bit 16 gets set in PMT_CTRL. * * SMSC has confirmed that checking bit 16 (marked as reserved in * the datasheet) is fine since these bits "will either never be set * or can only go high after READY does (so also indicate the device * is ready)".
*/
if (byte_test != 0x87654321) {
SMSC_WARN(pdata, drv, "BYTE_TEST: 0x%08X", byte_test); if (((byte_test >> 16) & 0xFFFF) == (byte_test & 0xFFFF)) {
SMSC_WARN(pdata, probe, "top 16 bits equal to bottom 16 bits");
SMSC_TRACE(pdata, probe, "This may mean the chip is set " "for 32 bit while the bus is reading 16 bit");
} return -ENODEV;
}
/* Default generation to zero (all workarounds apply) */
pdata->generation = 0;
pdata->idrev = smsc911x_reg_read(pdata, ID_REV); switch (pdata->idrev & 0xFFFF0000) { case LAN9118: case LAN9117: case LAN9116: case LAN9115: case LAN89218: /* LAN911[5678] family */
pdata->generation = pdata->idrev & 0x0000FFFF; break;
case LAN9218: case LAN9217: case LAN9216: case LAN9215: /* LAN921[5678] family */
pdata->generation = 3; break;
case LAN9210: case LAN9211: case LAN9220: case LAN9221: case LAN9250: /* LAN9210/LAN9211/LAN9220/LAN9221/LAN9250 */
pdata->generation = 4; break;
if (pdata->generation == 0)
SMSC_WARN(pdata, probe, "This driver is not intended for this chip revision");
/* workaround for platforms without an eeprom, where the mac address * is stored elsewhere and set by the bootloader. This saves the
* mac address before resetting the device */ if (pdata->config.flags & SMSC911X_SAVE_MAC_ADDRESS) {
spin_lock_irq(&pdata->mac_lock);
smsc911x_read_mac_address(dev);
spin_unlock_irq(&pdata->mac_lock);
}
/* Reset the LAN911x */ if (smsc911x_phy_reset(pdata) || smsc911x_soft_reset(pdata)) return -ENODEV;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.