Lines Matching +full:revision +full:- +full:id2
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * This is a driver for SMSC's 91C9x/91C1xx single-chip Ethernet devices.
37 * 29/09/03 Russell King - add driver model support
38 * - ethtool support
39 * - convert to use generic MII interface
40 * - add link up/down notification
41 * - don't try to handle full negotiation in
43 * - clean up (and fix stack overrun) in PHY
113 * Use power-down feature of the chip
198 spin_lock_irqsave(&lp->lock, smc_enable_flags); \
202 spin_unlock_irqrestore(&lp->lock, smc_enable_flags); \
209 spin_lock_irqsave(&lp->lock, smc_disable_flags); \
213 spin_unlock_irqrestore(&lp->lock, smc_disable_flags); \
242 void __iomem *ioaddr = lp->base; in smc_reset()
249 spin_lock_irq(&lp->lock); in smc_reset()
252 pending_skb = lp->pending_tx_skb; in smc_reset()
253 lp->pending_tx_skb = NULL; in smc_reset()
254 spin_unlock_irq(&lp->lock); in smc_reset()
259 dev->stats.tx_errors++; in smc_reset()
260 dev->stats.tx_aborted_errors++; in smc_reset()
284 if (lp->cfg.flags & SMC91X_NOWAIT) in smc_reset()
288 * Release from possible power-down state in smc_reset()
297 * elaborate? What does the chip _need_? --jgarzik in smc_reset()
301 * info/determined empirically. --rmk in smc_reset()
336 void __iomem *ioaddr = lp->base; in smc_enable()
343 SMC_SET_TCR(lp, lp->tcr_cur_mode); in smc_enable()
344 SMC_SET_RCR(lp, lp->rcr_cur_mode); in smc_enable()
347 SMC_SET_MAC_ADDR(lp, dev->dev_addr); in smc_enable()
351 if (lp->version >= (CHIP_91100 << 4)) in smc_enable()
370 void __iomem *ioaddr = lp->base; in smc_shutdown()
376 spin_lock_irq(&lp->lock); in smc_shutdown()
379 pending_skb = lp->pending_tx_skb; in smc_shutdown()
380 lp->pending_tx_skb = NULL; in smc_shutdown()
381 spin_unlock_irq(&lp->lock); in smc_shutdown()
402 void __iomem *ioaddr = lp->base; in smc_rcv()
437 dev->stats.rx_errors++; in smc_rcv()
439 dev->stats.rx_frame_errors++; in smc_rcv()
441 dev->stats.rx_length_errors++; in smc_rcv()
443 dev->stats.rx_crc_errors++; in smc_rcv()
451 dev->stats.multicast++; in smc_rcv()
454 * Actual payload is packet_len - 6 (or 5 if odd byte). in smc_rcv()
459 * Hence packet_len - 6 + 2 + 2 + 2. in smc_rcv()
465 dev->stats.rx_dropped++; in smc_rcv()
473 if (lp->version == 0x90) in smc_rcv()
477 * If odd length: packet_len - 5, in smc_rcv()
478 * otherwise packet_len - 6. in smc_rcv()
479 * With the trailing ctrl byte it's packet_len - 4. in smc_rcv()
481 data_len = packet_len - ((status & RS_ODDFRAME) ? 5 : 6); in smc_rcv()
483 SMC_PULL_DATA(lp, data, packet_len - 4); in smc_rcv()
488 PRINT_PKT(data, packet_len - 4); in smc_rcv()
490 skb->protocol = eth_type_trans(skb, dev); in smc_rcv()
492 dev->stats.rx_packets++; in smc_rcv()
493 dev->stats.rx_bytes += data_len; in smc_rcv()
542 struct net_device *dev = lp->dev; in smc_hardware_send_pkt()
543 void __iomem *ioaddr = lp->base; in smc_hardware_send_pkt()
551 if (!smc_special_trylock(&lp->lock, flags)) { in smc_hardware_send_pkt()
553 tasklet_schedule(&lp->tx_task); in smc_hardware_send_pkt()
557 skb = lp->pending_tx_skb; in smc_hardware_send_pkt()
559 smc_special_unlock(&lp->lock, flags); in smc_hardware_send_pkt()
562 lp->pending_tx_skb = NULL; in smc_hardware_send_pkt()
567 dev->stats.tx_errors++; in smc_hardware_send_pkt()
568 dev->stats.tx_fifo_errors++; in smc_hardware_send_pkt()
569 smc_special_unlock(&lp->lock, flags); in smc_hardware_send_pkt()
577 buf = skb->data; in smc_hardware_send_pkt()
578 len = skb->len; in smc_hardware_send_pkt()
593 SMC_outw(lp, ((len & 1) ? (0x2000 | buf[len - 1]) : 0), ioaddr, in smc_hardware_send_pkt()
609 smc_special_unlock(&lp->lock, flags); in smc_hardware_send_pkt()
612 dev->stats.tx_packets++; in smc_hardware_send_pkt()
613 dev->stats.tx_bytes += len; in smc_hardware_send_pkt()
633 void __iomem *ioaddr = lp->base; in smc_hard_start_xmit()
639 BUG_ON(lp->pending_tx_skb != NULL); in smc_hard_start_xmit()
652 numPages = ((skb->len & ~1) + (6 - 1)) >> 8; in smc_hard_start_xmit()
655 dev->stats.tx_errors++; in smc_hard_start_xmit()
656 dev->stats.tx_dropped++; in smc_hard_start_xmit()
661 smc_special_lock(&lp->lock, flags); in smc_hard_start_xmit()
677 } while (--poll_count); in smc_hard_start_xmit()
679 smc_special_unlock(&lp->lock, flags); in smc_hard_start_xmit()
681 lp->pending_tx_skb = skb; in smc_hard_start_xmit()
692 smc_hardware_send_pkt(&lp->tx_task); in smc_hard_start_xmit()
700 * - a TX error occurred, or
701 * - CTL_AUTO_RELEASE is not set and TX of a packet completed.
706 void __iomem *ioaddr = lp->base; in smc_tx()
730 dev->stats.tx_errors++; in smc_tx()
733 dev->stats.tx_carrier_errors++; in smc_tx()
739 dev->stats.tx_window_errors++; in smc_tx()
740 if (!(dev->stats.tx_window_errors & 63) && net_ratelimit()) { in smc_tx()
753 /* re-enable transmit */ in smc_tx()
755 SMC_SET_TCR(lp, lp->tcr_cur_mode); in smc_tx()
760 /*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/
765 void __iomem *ioaddr = lp->base; in smc_mii_out()
771 for (mask = 1 << (bits - 1); mask; mask >>= 1) { in smc_mii_out()
787 void __iomem *ioaddr = lp->base; in smc_mii_in()
793 for (mask = 1 << (bits - 1), val = 0; mask; mask >>= 1) { in smc_mii_in()
812 void __iomem *ioaddr = lp->base; in smc_phy_read()
817 /* Idle - 32 ones */ in smc_phy_read()
843 void __iomem *ioaddr = lp->base; in smc_phy_write()
847 /* Idle - 32 ones */ in smc_phy_write()
872 lp->phy_type = 0; in smc_phy_detect()
879 unsigned int id1, id2; in smc_phy_detect() local
883 id2 = smc_phy_read(dev, phyaddr & 31, MII_PHYSID2); in smc_phy_detect()
886 id1, id2); in smc_phy_detect()
890 id2 != 0x0000 && id2 != 0xffff && id2 != 0x8000) { in smc_phy_detect()
892 lp->mii.phy_id = phyaddr & 31; in smc_phy_detect()
893 lp->phy_type = id1 << 16 | id2; in smc_phy_detect()
905 void __iomem *ioaddr = lp->base; in smc_phy_fixed()
906 int phyaddr = lp->mii.phy_id; in smc_phy_fixed()
918 * Disable auto-negotiation in smc_phy_fixed()
922 if (lp->ctl_rfduplx) in smc_phy_fixed()
925 if (lp->ctl_rspeed == 100) in smc_phy_fixed()
931 /* Re-Configure the Receive/Phy Control register */ in smc_phy_fixed()
933 SMC_SET_RPC(lp, lp->rpc_cur_mode); in smc_phy_fixed()
940 * smc_phy_reset - reset the phy
950 * Must be called with lp->lock locked.
960 for (timeout = 2; timeout; timeout--) { in smc_phy_reset()
961 spin_unlock_irq(&lp->lock); in smc_phy_reset()
963 spin_lock_irq(&lp->lock); in smc_phy_reset()
974 * smc_phy_powerdown - powerdown phy
983 int phy = lp->mii.phy_id; in smc_phy_powerdown()
985 if (lp->phy_type == 0) in smc_phy_powerdown()
991 cancel_work_sync(&lp->phy_configure); in smc_phy_powerdown()
998 * smc_phy_check_media - check the media status and adjust TCR
1008 void __iomem *ioaddr = lp->base; in smc_phy_check_media()
1010 if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) { in smc_phy_check_media()
1012 if (lp->mii.full_duplex) { in smc_phy_check_media()
1013 lp->tcr_cur_mode |= TCR_SWFDUP; in smc_phy_check_media()
1015 lp->tcr_cur_mode &= ~TCR_SWFDUP; in smc_phy_check_media()
1019 SMC_SET_TCR(lp, lp->tcr_cur_mode); in smc_phy_check_media()
1036 struct net_device *dev = lp->dev; in smc_phy_configure()
1037 void __iomem *ioaddr = lp->base; in smc_phy_configure()
1038 int phyaddr = lp->mii.phy_id; in smc_phy_configure()
1044 spin_lock_irq(&lp->lock); in smc_phy_configure()
1049 if (lp->phy_type == 0) in smc_phy_configure()
1068 SMC_SET_RPC(lp, lp->rpc_cur_mode); in smc_phy_configure()
1071 if (lp->mii.force_media) { in smc_phy_configure()
1099 if (lp->ctl_rspeed != 100) in smc_phy_configure()
1102 if (!lp->ctl_rfduplx) in smc_phy_configure()
1105 /* Update our Auto-Neg Advertisement Register */ in smc_phy_configure()
1107 lp->mii.advertising = my_ad_caps; in smc_phy_configure()
1111 * auto-negotiation is restarted, sometimes it isn't ready and in smc_phy_configure()
1119 /* Restart auto-negotiation process in order to advertise my caps */ in smc_phy_configure()
1126 spin_unlock_irq(&lp->lock); in smc_phy_configure()
1138 int phyaddr = lp->mii.phy_id; in smc_phy_interrupt()
1143 if (lp->phy_type == 0) in smc_phy_interrupt()
1156 /*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/
1161 void __iomem *ioaddr = lp->base; in smc_10bt_check_media()
1185 void __iomem *ioaddr = lp->base; in smc_eph_interrupt()
1205 void __iomem *ioaddr = lp->base; in smc_interrupt()
1211 spin_lock(&lp->lock); in smc_interrupt()
1251 tasklet_hi_schedule(&lp->tx_task); in smc_interrupt()
1263 dev->stats.collisions += card_stats & 0xF; in smc_interrupt()
1267 dev->stats.collisions += card_stats & 0xF; in smc_interrupt()
1274 dev->stats.rx_errors++; in smc_interrupt()
1275 dev->stats.rx_fifo_errors++; in smc_interrupt()
1285 } while (--timeout); in smc_interrupt()
1290 spin_unlock(&lp->lock); in smc_interrupt()
1298 MAX_IRQ_LOOPS - timeout); in smc_interrupt()
1313 * Polling receive - used by netconsole and other diagnostic tools
1318 disable_irq(dev->irq); in smc_poll_controller()
1319 smc_interrupt(dev->irq, dev); in smc_poll_controller()
1320 enable_irq(dev->irq); in smc_poll_controller()
1328 void __iomem *ioaddr = lp->base; in smc_timeout()
1333 spin_lock_irq(&lp->lock); in smc_timeout()
1341 spin_unlock_irq(&lp->lock); in smc_timeout()
1353 if (lp->phy_type != 0) in smc_timeout()
1354 schedule_work(&lp->phy_configure); in smc_timeout()
1370 void __iomem *ioaddr = lp->base; in smc_set_multicast_list()
1376 if (dev->flags & IFF_PROMISC) { in smc_set_multicast_list()
1378 lp->rcr_cur_mode |= RCR_PRMS; in smc_set_multicast_list()
1391 else if (dev->flags & IFF_ALLMULTI || netdev_mc_count(dev) > 16) { in smc_set_multicast_list()
1393 lp->rcr_cur_mode |= RCR_ALMUL; in smc_set_multicast_list()
1421 position = crc32_le(~0, ha->addr, 6) & 0x3f; in smc_set_multicast_list()
1429 lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL); in smc_set_multicast_list()
1435 lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL); in smc_set_multicast_list()
1445 spin_lock_irq(&lp->lock); in smc_set_multicast_list()
1447 SMC_SET_RCR(lp, lp->rcr_cur_mode); in smc_set_multicast_list()
1453 spin_unlock_irq(&lp->lock); in smc_set_multicast_list()
1470 lp->tcr_cur_mode = TCR_DEFAULT; in smc_open()
1471 lp->rcr_cur_mode = RCR_DEFAULT; in smc_open()
1472 lp->rpc_cur_mode = RPC_DEFAULT | in smc_open()
1473 lp->cfg.leda << RPC_LSXA_SHFT | in smc_open()
1474 lp->cfg.ledb << RPC_LSXB_SHFT; in smc_open()
1480 if (lp->phy_type == 0) in smc_open()
1481 lp->tcr_cur_mode |= TCR_MON_CSN; in smc_open()
1488 if (lp->phy_type != 0) in smc_open()
1489 smc_phy_configure(&lp->phy_configure); in smc_open()
1491 spin_lock_irq(&lp->lock); in smc_open()
1493 spin_unlock_irq(&lp->lock); in smc_open()
1518 tasklet_kill(&lp->tx_task); in smc_close()
1532 if (lp->phy_type != 0) { in smc_ethtool_get_link_ksettings()
1533 spin_lock_irq(&lp->lock); in smc_ethtool_get_link_ksettings()
1534 mii_ethtool_get_link_ksettings(&lp->mii, cmd); in smc_ethtool_get_link_ksettings()
1535 spin_unlock_irq(&lp->lock); in smc_ethtool_get_link_ksettings()
1541 if (lp->ctl_rspeed == 10) in smc_ethtool_get_link_ksettings()
1542 cmd->base.speed = SPEED_10; in smc_ethtool_get_link_ksettings()
1543 else if (lp->ctl_rspeed == 100) in smc_ethtool_get_link_ksettings()
1544 cmd->base.speed = SPEED_100; in smc_ethtool_get_link_ksettings()
1546 cmd->base.autoneg = AUTONEG_DISABLE; in smc_ethtool_get_link_ksettings()
1547 cmd->base.port = 0; in smc_ethtool_get_link_ksettings()
1548 cmd->base.duplex = lp->tcr_cur_mode & TCR_SWFDUP ? in smc_ethtool_get_link_ksettings()
1552 cmd->link_modes.supported, supported); in smc_ethtool_get_link_ksettings()
1565 if (lp->phy_type != 0) { in smc_ethtool_set_link_ksettings()
1566 spin_lock_irq(&lp->lock); in smc_ethtool_set_link_ksettings()
1567 ret = mii_ethtool_set_link_ksettings(&lp->mii, cmd); in smc_ethtool_set_link_ksettings()
1568 spin_unlock_irq(&lp->lock); in smc_ethtool_set_link_ksettings()
1570 if (cmd->base.autoneg != AUTONEG_DISABLE || in smc_ethtool_set_link_ksettings()
1571 cmd->base.speed != SPEED_10 || in smc_ethtool_set_link_ksettings()
1572 (cmd->base.duplex != DUPLEX_HALF && in smc_ethtool_set_link_ksettings()
1573 cmd->base.duplex != DUPLEX_FULL) || in smc_ethtool_set_link_ksettings()
1574 (cmd->base.port != PORT_TP && cmd->base.port != PORT_AUI)) in smc_ethtool_set_link_ksettings()
1575 return -EINVAL; in smc_ethtool_set_link_ksettings()
1577 lp->ctl_rfduplx = cmd->base.duplex == DUPLEX_FULL; in smc_ethtool_set_link_ksettings()
1588 strscpy(info->driver, CARDNAME, sizeof(info->driver)); in smc_ethtool_getdrvinfo()
1589 strscpy(info->version, version, sizeof(info->version)); in smc_ethtool_getdrvinfo()
1590 strscpy(info->bus_info, dev_name(dev->dev.parent), in smc_ethtool_getdrvinfo()
1591 sizeof(info->bus_info)); in smc_ethtool_getdrvinfo()
1597 int ret = -EINVAL; in smc_ethtool_nwayreset()
1599 if (lp->phy_type != 0) { in smc_ethtool_nwayreset()
1600 spin_lock_irq(&lp->lock); in smc_ethtool_nwayreset()
1601 ret = mii_nway_restart(&lp->mii); in smc_ethtool_nwayreset()
1602 spin_unlock_irq(&lp->lock); in smc_ethtool_nwayreset()
1611 return lp->msg_enable; in smc_ethtool_getmsglevel()
1617 lp->msg_enable = level; in smc_ethtool_setmsglevel()
1624 void __iomem *ioaddr = lp->base; in smc_write_eeprom_word()
1626 spin_lock_irq(&lp->lock); in smc_write_eeprom_word()
1644 spin_unlock_irq(&lp->lock); in smc_write_eeprom_word()
1652 void __iomem *ioaddr = lp->base; in smc_read_eeprom_word()
1654 spin_lock_irq(&lp->lock); in smc_read_eeprom_word()
1672 spin_unlock_irq(&lp->lock); in smc_read_eeprom_word()
1688 eeprom->len, eeprom->offset, eeprom->offset); in smc_ethtool_geteeprom()
1690 for (i = 0; i < eeprom->len; i += 2) { in smc_ethtool_geteeprom()
1693 int offset = i + eeprom->offset; in smc_ethtool_geteeprom()
1713 eeprom->len, eeprom->offset, eeprom->offset); in smc_ethtool_seteeprom()
1715 for (i = 0; i < eeprom->len; i += 2) { in smc_ethtool_seteeprom()
1718 int offset = i + eeprom->offset; in smc_ethtool_seteeprom()
1761 * This routine has a simple purpose -- make the SMC chip generate an
1762 * interrupt, so an auto-detect routine can detect it, and find the IRQ,
1768 * --jgarzik
1772 void __iomem *ioaddr = lp->base; in smc_findirq()
1776 DBG(2, lp->dev, "%s: %s\n", CARDNAME, __func__); in smc_findirq()
1804 } while (--timeout); in smc_findirq()
1862 "%s: Detected possible byte-swapped interface at IOADDR %p\n", in smc_probe()
1865 retval = -ENODEV; in smc_probe()
1876 retval = -ENODEV; in smc_probe()
1895 * check if the revision register is something that I in smc_probe()
1901 DBG(2, dev, "%s: revision = 0x%04x\n", CARDNAME, revision_register); in smc_probe()
1905 netdev_warn(dev, "%s: IO %p: Unrecognized revision register 0x%04x, Contact author.\n", in smc_probe()
1908 retval = -ENODEV; in smc_probe()
1916 dev->base_addr = (unsigned long)ioaddr; in smc_probe()
1917 lp->base = ioaddr; in smc_probe()
1918 lp->version = revision_register & 0xff; in smc_probe()
1919 spin_lock_init(&lp->lock); in smc_probe()
1930 * If dev->irq is 0, then the device has to be banged on to see in smc_probe()
1938 * because the card that I have uses a non-standard method of accessing in smc_probe()
1944 if (dev->irq < 1) { in smc_probe()
1948 while (trials--) { in smc_probe()
1949 dev->irq = smc_findirq(lp); in smc_probe()
1950 if (dev->irq) in smc_probe()
1956 if (dev->irq == 0) { in smc_probe()
1958 retval = -ENODEV; in smc_probe()
1961 dev->irq = irq_canonicalize(dev->irq); in smc_probe()
1963 dev->watchdog_timeo = msecs_to_jiffies(watchdog); in smc_probe()
1964 dev->netdev_ops = &smc_netdev_ops; in smc_probe()
1965 dev->ethtool_ops = &smc_ethtool_ops; in smc_probe()
1967 tasklet_setup(&lp->tx_task, smc_hardware_send_pkt); in smc_probe()
1968 INIT_WORK(&lp->phy_configure, smc_phy_configure); in smc_probe()
1969 lp->dev = dev; in smc_probe()
1970 lp->mii.phy_id_mask = 0x1f; in smc_probe()
1971 lp->mii.reg_num_mask = 0x1f; in smc_probe()
1972 lp->mii.force_media = 0; in smc_probe()
1973 lp->mii.full_duplex = 0; in smc_probe()
1974 lp->mii.dev = dev; in smc_probe()
1975 lp->mii.mdio_read = smc_phy_read; in smc_probe()
1976 lp->mii.mdio_write = smc_phy_write; in smc_probe()
1981 if (lp->version >= (CHIP_91100 << 4)) in smc_probe()
1989 lp->msg_enable = NETIF_MSG_LINK; in smc_probe()
1990 lp->ctl_rfduplx = 0; in smc_probe()
1991 lp->ctl_rspeed = 10; in smc_probe()
1993 if (lp->version >= (CHIP_91100 << 4)) { in smc_probe()
1994 lp->ctl_rfduplx = 1; in smc_probe()
1995 lp->ctl_rspeed = 100; in smc_probe()
1999 retval = request_irq(dev->irq, smc_interrupt, irq_flags, dev->name, dev); in smc_probe()
2005 lp->cfg.flags |= SMC91X_USE_DMA; in smc_probe()
2007 if (lp->cfg.flags & SMC91X_USE_DMA) { in smc_probe()
2012 lp->dma_chan = dma_request_channel(mask, NULL, NULL); in smc_probe()
2021 lp->base, dev->irq); in smc_probe()
2023 if (lp->dma_chan) in smc_probe()
2024 pr_cont(" DMA %p", lp->dma_chan); in smc_probe()
2027 lp->cfg.flags & SMC91X_NOWAIT ? " [nowait]" : "", in smc_probe()
2030 if (!is_valid_ether_addr(dev->dev_addr)) { in smc_probe()
2035 dev->dev_addr); in smc_probe()
2038 if (lp->phy_type == 0) { in smc_probe()
2040 } else if ((lp->phy_type & 0xfffffff0) == 0x0016f840) { in smc_probe()
2042 } else if ((lp->phy_type & 0xfffffff0) == 0x02821c50) { in smc_probe()
2049 if (retval && lp->dma_chan) in smc_probe()
2050 dma_release_channel(lp->dma_chan); in smc_probe()
2064 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); in smc_enable_device()
2071 addr = ioremap(res->start, ATTRIB_SIZE); in smc_enable_device()
2073 return -ENOMEM; in smc_enable_device()
2121 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); in smc_request_attrib()
2127 if (!request_mem_region(res->start, ATTRIB_SIZE, CARDNAME)) in smc_request_attrib()
2128 return -EBUSY; in smc_request_attrib()
2136 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); in smc_release_attrib()
2140 release_mem_region(res->start, ATTRIB_SIZE); in smc_release_attrib()
2146 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32"); in smc_request_datacs()
2152 if(!request_mem_region(res->start, SMC_DATA_EXTENT, CARDNAME)) { in smc_request_datacs()
2158 lp->datacs = ioremap(res->start, SMC_DATA_EXTENT); in smc_request_datacs()
2166 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32"); in smc_release_datacs()
2168 if (lp->datacs) in smc_release_datacs()
2169 iounmap(lp->datacs); in smc_release_datacs()
2171 lp->datacs = NULL; in smc_release_datacs()
2174 release_mem_region(res->start, SMC_DATA_EXTENT); in smc_release_datacs()
2193 * try_toggle_control_gpio - configure a gpio if it exists
2227 * dev->base_addr == 0, try to find all possible locations
2228 * dev->base_addr > 0x1ff, this is the address to check
2229 * dev->base_addr == <anything else>, return failure code
2232 * 0 --> there is a device
2237 struct smc91x_platdata *pd = dev_get_platdata(&pdev->dev); in smc_drv_probe()
2249 ret = -ENOMEM; in smc_drv_probe()
2252 SET_NETDEV_DEV(ndev, &pdev->dev); in smc_drv_probe()
2259 lp->cfg.flags = 0; in smc_drv_probe()
2262 memcpy(&lp->cfg, pd, sizeof(lp->cfg)); in smc_drv_probe()
2263 lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); in smc_drv_probe()
2266 dev_err(&pdev->dev, in smc_drv_probe()
2267 "at least one of 8-bit or 16-bit access support is required.\n"); in smc_drv_probe()
2268 ret = -ENXIO; in smc_drv_probe()
2274 match = of_match_device(of_match_ptr(smc91x_match), &pdev->dev); in smc_drv_probe()
2279 ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio, in smc_drv_probe()
2288 ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio, in smc_drv_probe()
2297 if (lp->reset_gpio) in smc_drv_probe()
2300 /* Combination of IO widths supported, default to 16-bit */ in smc_drv_probe()
2301 if (!device_property_read_u32(&pdev->dev, "reg-io-width", in smc_drv_probe()
2304 lp->cfg.flags |= SMC91X_USE_8BIT; in smc_drv_probe()
2306 lp->cfg.flags |= SMC91X_USE_16BIT; in smc_drv_probe()
2308 lp->cfg.flags |= SMC91X_USE_32BIT; in smc_drv_probe()
2310 lp->cfg.flags |= SMC91X_USE_16BIT; in smc_drv_probe()
2312 if (!device_property_read_u32(&pdev->dev, "reg-shift", in smc_drv_probe()
2314 lp->io_shift = val; in smc_drv_probe()
2315 lp->cfg.pxa_u16_align4 = in smc_drv_probe()
2316 device_property_read_bool(&pdev->dev, "pxa-u16-align4"); in smc_drv_probe()
2321 lp->cfg.flags |= (SMC_CAN_USE_8BIT) ? SMC91X_USE_8BIT : 0; in smc_drv_probe()
2322 lp->cfg.flags |= (SMC_CAN_USE_16BIT) ? SMC91X_USE_16BIT : 0; in smc_drv_probe()
2323 lp->cfg.flags |= (SMC_CAN_USE_32BIT) ? SMC91X_USE_32BIT : 0; in smc_drv_probe()
2324 lp->cfg.flags |= (nowait) ? SMC91X_NOWAIT : 0; in smc_drv_probe()
2327 if (!lp->cfg.leda && !lp->cfg.ledb) { in smc_drv_probe()
2328 lp->cfg.leda = RPC_LSA_DEFAULT; in smc_drv_probe()
2329 lp->cfg.ledb = RPC_LSB_DEFAULT; in smc_drv_probe()
2332 ndev->dma = (unsigned char)-1; in smc_drv_probe()
2334 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); in smc_drv_probe()
2338 ret = -ENODEV; in smc_drv_probe()
2343 if (!request_mem_region(res->start, SMC_IO_EXTENT, CARDNAME)) { in smc_drv_probe()
2344 ret = -EBUSY; in smc_drv_probe()
2348 ndev->irq = platform_get_irq(pdev, 0); in smc_drv_probe()
2349 if (ndev->irq < 0) { in smc_drv_probe()
2350 ret = ndev->irq; in smc_drv_probe()
2358 irq_resflags = irq_get_trigger_type(ndev->irq); in smc_drv_probe()
2359 if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK) in smc_drv_probe()
2374 addr = ioremap(res->start, SMC_IO_EXTENT); in smc_drv_probe()
2376 ret = -ENOMEM; in smc_drv_probe()
2383 lp->device = &pdev->dev; in smc_drv_probe()
2384 lp->physaddr = res->start; in smc_drv_probe()
2402 release_mem_region(res->start, SMC_IO_EXTENT); in smc_drv_probe()
2419 free_irq(ndev->irq, ndev); in smc_drv_remove()
2422 if (lp->dma_chan) in smc_drv_remove()
2423 dma_release_channel(lp->dma_chan); in smc_drv_remove()
2425 iounmap(lp->base); in smc_drv_remove()
2430 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); in smc_drv_remove()
2433 release_mem_region(res->start, SMC_IO_EXTENT); in smc_drv_remove()
2463 if (lp->phy_type != 0) in smc_drv_resume()
2464 smc_phy_configure(&lp->phy_configure); in smc_drv_resume()