Lines Matching +full:bit +full:- +full:banged

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
112 * Use power-down feature of the chip
197 spin_lock_irqsave(&lp->lock, smc_enable_flags); \
201 spin_unlock_irqrestore(&lp->lock, smc_enable_flags); \
208 spin_lock_irqsave(&lp->lock, smc_disable_flags); \
212 spin_unlock_irqrestore(&lp->lock, smc_disable_flags); \
241 void __iomem *ioaddr = lp->base; in smc_reset()
248 spin_lock_irq(&lp->lock); in smc_reset()
251 pending_skb = lp->pending_tx_skb; in smc_reset()
252 lp->pending_tx_skb = NULL; in smc_reset()
253 spin_unlock_irq(&lp->lock); in smc_reset()
258 dev->stats.tx_errors++; in smc_reset()
259 dev->stats.tx_aborted_errors++; in smc_reset()
283 if (lp->cfg.flags & SMC91X_NOWAIT) in smc_reset()
287 * Release from possible power-down state in smc_reset()
296 * elaborate? What does the chip _need_? --jgarzik in smc_reset()
300 * info/determined empirically. --rmk in smc_reset()
335 void __iomem *ioaddr = lp->base; in smc_enable()
342 SMC_SET_TCR(lp, lp->tcr_cur_mode); in smc_enable()
343 SMC_SET_RCR(lp, lp->rcr_cur_mode); in smc_enable()
346 SMC_SET_MAC_ADDR(lp, dev->dev_addr); in smc_enable()
350 if (lp->version >= (CHIP_91100 << 4)) in smc_enable()
369 void __iomem *ioaddr = lp->base; in smc_shutdown()
375 spin_lock_irq(&lp->lock); in smc_shutdown()
378 pending_skb = lp->pending_tx_skb; in smc_shutdown()
379 lp->pending_tx_skb = NULL; in smc_shutdown()
380 spin_unlock_irq(&lp->lock); in smc_shutdown()
401 void __iomem *ioaddr = lp->base; in smc_rcv()
436 dev->stats.rx_errors++; in smc_rcv()
438 dev->stats.rx_frame_errors++; in smc_rcv()
440 dev->stats.rx_length_errors++; in smc_rcv()
442 dev->stats.rx_crc_errors++; in smc_rcv()
450 dev->stats.multicast++; in smc_rcv()
453 * Actual payload is packet_len - 6 (or 5 if odd byte). in smc_rcv()
457 * multiple of 4 bytes on 32 bit buses. in smc_rcv()
458 * Hence packet_len - 6 + 2 + 2 + 2. in smc_rcv()
464 dev->stats.rx_dropped++; in smc_rcv()
471 /* BUG: the LAN91C111 rev A never sets this bit. Force it. */ in smc_rcv()
472 if (lp->version == 0x90) in smc_rcv()
476 * If odd length: packet_len - 5, in smc_rcv()
477 * otherwise packet_len - 6. in smc_rcv()
478 * With the trailing ctrl byte it's packet_len - 4. in smc_rcv()
480 data_len = packet_len - ((status & RS_ODDFRAME) ? 5 : 6); in smc_rcv()
482 SMC_PULL_DATA(lp, data, packet_len - 4); in smc_rcv()
487 PRINT_PKT(data, packet_len - 4); in smc_rcv()
489 skb->protocol = eth_type_trans(skb, dev); in smc_rcv()
491 dev->stats.rx_packets++; in smc_rcv()
492 dev->stats.rx_bytes += data_len; in smc_rcv()
541 struct net_device *dev = lp->dev; in smc_hardware_send_pkt()
542 void __iomem *ioaddr = lp->base; in smc_hardware_send_pkt()
550 if (!smc_special_trylock(&lp->lock, flags)) { in smc_hardware_send_pkt()
552 tasklet_schedule(&lp->tx_task); in smc_hardware_send_pkt()
556 skb = lp->pending_tx_skb; in smc_hardware_send_pkt()
558 smc_special_unlock(&lp->lock, flags); in smc_hardware_send_pkt()
561 lp->pending_tx_skb = NULL; in smc_hardware_send_pkt()
566 dev->stats.tx_errors++; in smc_hardware_send_pkt()
567 dev->stats.tx_fifo_errors++; in smc_hardware_send_pkt()
568 smc_special_unlock(&lp->lock, flags); in smc_hardware_send_pkt()
576 buf = skb->data; in smc_hardware_send_pkt()
577 len = skb->len; in smc_hardware_send_pkt()
592 SMC_outw(lp, ((len & 1) ? (0x2000 | buf[len - 1]) : 0), ioaddr, in smc_hardware_send_pkt()
608 smc_special_unlock(&lp->lock, flags); in smc_hardware_send_pkt()
611 dev->stats.tx_packets++; in smc_hardware_send_pkt()
612 dev->stats.tx_bytes += len; in smc_hardware_send_pkt()
632 void __iomem *ioaddr = lp->base; in smc_hard_start_xmit()
638 BUG_ON(lp->pending_tx_skb != NULL); in smc_hard_start_xmit()
651 numPages = ((skb->len & ~1) + (6 - 1)) >> 8; in smc_hard_start_xmit()
654 dev->stats.tx_errors++; in smc_hard_start_xmit()
655 dev->stats.tx_dropped++; in smc_hard_start_xmit()
660 smc_special_lock(&lp->lock, flags); in smc_hard_start_xmit()
676 } while (--poll_count); in smc_hard_start_xmit()
678 smc_special_unlock(&lp->lock, flags); in smc_hard_start_xmit()
680 lp->pending_tx_skb = skb; in smc_hard_start_xmit()
691 smc_hardware_send_pkt(&lp->tx_task); in smc_hard_start_xmit()
699 * - a TX error occurred, or
700 * - CTL_AUTO_RELEASE is not set and TX of a packet completed.
705 void __iomem *ioaddr = lp->base; in smc_tx()
729 dev->stats.tx_errors++; in smc_tx()
732 dev->stats.tx_carrier_errors++; in smc_tx()
738 dev->stats.tx_window_errors++; in smc_tx()
739 if (!(dev->stats.tx_window_errors & 63) && net_ratelimit()) { in smc_tx()
748 /* Don't restore Packet Number Reg until busy bit is cleared */ in smc_tx()
752 /* re-enable transmit */ in smc_tx()
754 SMC_SET_TCR(lp, lp->tcr_cur_mode); in smc_tx()
759 /*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/
764 void __iomem *ioaddr = lp->base; in smc_mii_out()
770 for (mask = 1 << (bits - 1); mask; mask >>= 1) { in smc_mii_out()
786 void __iomem *ioaddr = lp->base; in smc_mii_in()
792 for (mask = 1 << (bits - 1), val = 0; mask; mask >>= 1) { in smc_mii_in()
811 void __iomem *ioaddr = lp->base; in smc_phy_read()
816 /* Idle - 32 ones */ in smc_phy_read()
842 void __iomem *ioaddr = lp->base; in smc_phy_write()
846 /* Idle - 32 ones */ in smc_phy_write()
871 lp->phy_type = 0; in smc_phy_detect()
891 lp->mii.phy_id = phyaddr & 31; in smc_phy_detect()
892 lp->phy_type = id1 << 16 | id2; in smc_phy_detect()
904 void __iomem *ioaddr = lp->base; in smc_phy_fixed()
905 int phyaddr = lp->mii.phy_id; in smc_phy_fixed()
917 * Disable auto-negotiation in smc_phy_fixed()
921 if (lp->ctl_rfduplx) in smc_phy_fixed()
924 if (lp->ctl_rspeed == 100) in smc_phy_fixed()
930 /* Re-Configure the Receive/Phy Control register */ in smc_phy_fixed()
932 SMC_SET_RPC(lp, lp->rpc_cur_mode); in smc_phy_fixed()
939 * smc_phy_reset - reset the phy
949 * Must be called with lp->lock locked.
959 for (timeout = 2; timeout; timeout--) { in smc_phy_reset()
960 spin_unlock_irq(&lp->lock); in smc_phy_reset()
962 spin_lock_irq(&lp->lock); in smc_phy_reset()
973 * smc_phy_powerdown - powerdown phy
982 int phy = lp->mii.phy_id; in smc_phy_powerdown()
984 if (lp->phy_type == 0) in smc_phy_powerdown()
990 cancel_work_sync(&lp->phy_configure); in smc_phy_powerdown()
997 * smc_phy_check_media - check the media status and adjust TCR
1007 void __iomem *ioaddr = lp->base; in smc_phy_check_media()
1009 if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) { in smc_phy_check_media()
1011 if (lp->mii.full_duplex) { in smc_phy_check_media()
1012 lp->tcr_cur_mode |= TCR_SWFDUP; in smc_phy_check_media()
1014 lp->tcr_cur_mode &= ~TCR_SWFDUP; in smc_phy_check_media()
1018 SMC_SET_TCR(lp, lp->tcr_cur_mode); in smc_phy_check_media()
1026 * If RPC ANEG bit is set, the media selection is dependent purely on
1028 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection
1035 struct net_device *dev = lp->dev; in smc_phy_configure()
1036 void __iomem *ioaddr = lp->base; in smc_phy_configure()
1037 int phyaddr = lp->mii.phy_id; in smc_phy_configure()
1043 spin_lock_irq(&lp->lock); in smc_phy_configure()
1048 if (lp->phy_type == 0) in smc_phy_configure()
1067 SMC_SET_RPC(lp, lp->rpc_cur_mode); in smc_phy_configure()
1070 if (lp->mii.force_media) { in smc_phy_configure()
1098 if (lp->ctl_rspeed != 100) in smc_phy_configure()
1101 if (!lp->ctl_rfduplx) in smc_phy_configure()
1104 /* Update our Auto-Neg Advertisement Register */ in smc_phy_configure()
1106 lp->mii.advertising = my_ad_caps; in smc_phy_configure()
1110 * auto-negotiation is restarted, sometimes it isn't ready and in smc_phy_configure()
1118 /* Restart auto-negotiation process in order to advertise my caps */ in smc_phy_configure()
1125 spin_unlock_irq(&lp->lock); in smc_phy_configure()
1137 int phyaddr = lp->mii.phy_id; in smc_phy_interrupt()
1142 if (lp->phy_type == 0) in smc_phy_interrupt()
1155 /*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/
1160 void __iomem *ioaddr = lp->base; in smc_10bt_check_media()
1184 void __iomem *ioaddr = lp->base; in smc_eph_interrupt()
1204 void __iomem *ioaddr = lp->base; in smc_interrupt()
1210 spin_lock(&lp->lock); in smc_interrupt()
1250 tasklet_hi_schedule(&lp->tx_task); in smc_interrupt()
1262 dev->stats.collisions += card_stats & 0xF; in smc_interrupt()
1266 dev->stats.collisions += card_stats & 0xF; in smc_interrupt()
1273 dev->stats.rx_errors++; in smc_interrupt()
1274 dev->stats.rx_fifo_errors++; in smc_interrupt()
1284 } while (--timeout); in smc_interrupt()
1289 spin_unlock(&lp->lock); in smc_interrupt()
1297 MAX_IRQ_LOOPS - timeout); in smc_interrupt()
1312 * Polling receive - used by netconsole and other diagnostic tools
1317 disable_irq(dev->irq); in smc_poll_controller()
1318 smc_interrupt(dev->irq, dev); in smc_poll_controller()
1319 enable_irq(dev->irq); in smc_poll_controller()
1327 void __iomem *ioaddr = lp->base; in smc_timeout()
1332 spin_lock_irq(&lp->lock); in smc_timeout()
1340 spin_unlock_irq(&lp->lock); in smc_timeout()
1352 if (lp->phy_type != 0) in smc_timeout()
1353 schedule_work(&lp->phy_configure); in smc_timeout()
1369 void __iomem *ioaddr = lp->base; in smc_set_multicast_list()
1375 if (dev->flags & IFF_PROMISC) { in smc_set_multicast_list()
1377 lp->rcr_cur_mode |= RCR_PRMS; in smc_set_multicast_list()
1390 else if (dev->flags & IFF_ALLMULTI || netdev_mc_count(dev) > 16) { in smc_set_multicast_list()
1392 lp->rcr_cur_mode |= RCR_ALMUL; in smc_set_multicast_list()
1400 * address are the offset into the table. If that bit is 1, then the in smc_set_multicast_list()
1404 * the number of the 8 bit register, while the low 3 bits are the bit in smc_set_multicast_list()
1420 position = crc32_le(~0, ha->addr, 6) & 0x3f; in smc_set_multicast_list()
1422 /* do some messy swapping to put the bit in the right spot */ in smc_set_multicast_list()
1428 lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL); in smc_set_multicast_list()
1434 lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL); in smc_set_multicast_list()
1444 spin_lock_irq(&lp->lock); in smc_set_multicast_list()
1446 SMC_SET_RCR(lp, lp->rcr_cur_mode); in smc_set_multicast_list()
1452 spin_unlock_irq(&lp->lock); in smc_set_multicast_list()
1469 lp->tcr_cur_mode = TCR_DEFAULT; in smc_open()
1470 lp->rcr_cur_mode = RCR_DEFAULT; in smc_open()
1471 lp->rpc_cur_mode = RPC_DEFAULT | in smc_open()
1472 lp->cfg.leda << RPC_LSXA_SHFT | in smc_open()
1473 lp->cfg.ledb << RPC_LSXB_SHFT; in smc_open()
1479 if (lp->phy_type == 0) in smc_open()
1480 lp->tcr_cur_mode |= TCR_MON_CSN; in smc_open()
1487 if (lp->phy_type != 0) in smc_open()
1488 smc_phy_configure(&lp->phy_configure); in smc_open()
1490 spin_lock_irq(&lp->lock); in smc_open()
1492 spin_unlock_irq(&lp->lock); in smc_open()
1517 tasklet_kill(&lp->tx_task); in smc_close()
1531 if (lp->phy_type != 0) { in smc_ethtool_get_link_ksettings()
1532 spin_lock_irq(&lp->lock); in smc_ethtool_get_link_ksettings()
1533 mii_ethtool_get_link_ksettings(&lp->mii, cmd); in smc_ethtool_get_link_ksettings()
1534 spin_unlock_irq(&lp->lock); in smc_ethtool_get_link_ksettings()
1540 if (lp->ctl_rspeed == 10) in smc_ethtool_get_link_ksettings()
1541 cmd->base.speed = SPEED_10; in smc_ethtool_get_link_ksettings()
1542 else if (lp->ctl_rspeed == 100) in smc_ethtool_get_link_ksettings()
1543 cmd->base.speed = SPEED_100; in smc_ethtool_get_link_ksettings()
1545 cmd->base.autoneg = AUTONEG_DISABLE; in smc_ethtool_get_link_ksettings()
1546 cmd->base.port = 0; in smc_ethtool_get_link_ksettings()
1547 cmd->base.duplex = lp->tcr_cur_mode & TCR_SWFDUP ? in smc_ethtool_get_link_ksettings()
1551 cmd->link_modes.supported, supported); in smc_ethtool_get_link_ksettings()
1564 if (lp->phy_type != 0) { in smc_ethtool_set_link_ksettings()
1565 spin_lock_irq(&lp->lock); in smc_ethtool_set_link_ksettings()
1566 ret = mii_ethtool_set_link_ksettings(&lp->mii, cmd); in smc_ethtool_set_link_ksettings()
1567 spin_unlock_irq(&lp->lock); in smc_ethtool_set_link_ksettings()
1569 if (cmd->base.autoneg != AUTONEG_DISABLE || in smc_ethtool_set_link_ksettings()
1570 cmd->base.speed != SPEED_10 || in smc_ethtool_set_link_ksettings()
1571 (cmd->base.duplex != DUPLEX_HALF && in smc_ethtool_set_link_ksettings()
1572 cmd->base.duplex != DUPLEX_FULL) || in smc_ethtool_set_link_ksettings()
1573 (cmd->base.port != PORT_TP && cmd->base.port != PORT_AUI)) in smc_ethtool_set_link_ksettings()
1574 return -EINVAL; in smc_ethtool_set_link_ksettings()
1576 // lp->port = cmd->base.port; in smc_ethtool_set_link_ksettings()
1577 lp->ctl_rfduplx = cmd->base.duplex == DUPLEX_FULL; in smc_ethtool_set_link_ksettings()
1591 strscpy(info->driver, CARDNAME, sizeof(info->driver)); in smc_ethtool_getdrvinfo()
1592 strscpy(info->version, version, sizeof(info->version)); in smc_ethtool_getdrvinfo()
1593 strscpy(info->bus_info, dev_name(dev->dev.parent), in smc_ethtool_getdrvinfo()
1594 sizeof(info->bus_info)); in smc_ethtool_getdrvinfo()
1600 int ret = -EINVAL; in smc_ethtool_nwayreset()
1602 if (lp->phy_type != 0) { in smc_ethtool_nwayreset()
1603 spin_lock_irq(&lp->lock); in smc_ethtool_nwayreset()
1604 ret = mii_nway_restart(&lp->mii); in smc_ethtool_nwayreset()
1605 spin_unlock_irq(&lp->lock); in smc_ethtool_nwayreset()
1614 return lp->msg_enable; in smc_ethtool_getmsglevel()
1620 lp->msg_enable = level; in smc_ethtool_setmsglevel()
1627 void __iomem *ioaddr = lp->base; in smc_write_eeprom_word()
1629 spin_lock_irq(&lp->lock); in smc_write_eeprom_word()
1647 spin_unlock_irq(&lp->lock); in smc_write_eeprom_word()
1655 void __iomem *ioaddr = lp->base; in smc_read_eeprom_word()
1657 spin_lock_irq(&lp->lock); in smc_read_eeprom_word()
1675 spin_unlock_irq(&lp->lock); in smc_read_eeprom_word()
1691 eeprom->len, eeprom->offset, eeprom->offset); in smc_ethtool_geteeprom()
1693 for (i = 0; i < eeprom->len; i += 2) { in smc_ethtool_geteeprom()
1696 int offset = i + eeprom->offset; in smc_ethtool_geteeprom()
1716 eeprom->len, eeprom->offset, eeprom->offset); in smc_ethtool_seteeprom()
1718 for (i = 0; i < eeprom->len; i += 2) { in smc_ethtool_seteeprom()
1721 int offset = i + eeprom->offset; in smc_ethtool_seteeprom()
1764 * This routine has a simple purpose -- make the SMC chip generate an
1765 * interrupt, so an auto-detect routine can detect it, and find the IRQ,
1771 * --jgarzik
1775 void __iomem *ioaddr = lp->base; in smc_findirq()
1779 DBG(2, lp->dev, "%s: %s\n", CARDNAME, __func__); in smc_findirq()
1807 } while (--timeout); in smc_findirq()
1865 "%s: Detected possible byte-swapped interface at IOADDR %p\n", in smc_probe()
1868 retval = -ENODEV; in smc_probe()
1879 retval = -ENODEV; in smc_probe()
1911 retval = -ENODEV; in smc_probe()
1919 dev->base_addr = (unsigned long)ioaddr; in smc_probe()
1920 lp->base = ioaddr; in smc_probe()
1921 lp->version = revision_register & 0xff; in smc_probe()
1922 spin_lock_init(&lp->lock); in smc_probe()
1933 * If dev->irq is 0, then the device has to be banged on to see in smc_probe()
1941 * because the card that I have uses a non-standard method of accessing in smc_probe()
1947 if (dev->irq < 1) { in smc_probe()
1951 while (trials--) { in smc_probe()
1952 dev->irq = smc_findirq(lp); in smc_probe()
1953 if (dev->irq) in smc_probe()
1959 if (dev->irq == 0) { in smc_probe()
1961 retval = -ENODEV; in smc_probe()
1964 dev->irq = irq_canonicalize(dev->irq); in smc_probe()
1966 dev->watchdog_timeo = msecs_to_jiffies(watchdog); in smc_probe()
1967 dev->netdev_ops = &smc_netdev_ops; in smc_probe()
1968 dev->ethtool_ops = &smc_ethtool_ops; in smc_probe()
1970 tasklet_setup(&lp->tx_task, smc_hardware_send_pkt); in smc_probe()
1971 INIT_WORK(&lp->phy_configure, smc_phy_configure); in smc_probe()
1972 lp->dev = dev; in smc_probe()
1973 lp->mii.phy_id_mask = 0x1f; in smc_probe()
1974 lp->mii.reg_num_mask = 0x1f; in smc_probe()
1975 lp->mii.force_media = 0; in smc_probe()
1976 lp->mii.full_duplex = 0; in smc_probe()
1977 lp->mii.dev = dev; in smc_probe()
1978 lp->mii.mdio_read = smc_phy_read; in smc_probe()
1979 lp->mii.mdio_write = smc_phy_write; in smc_probe()
1984 if (lp->version >= (CHIP_91100 << 4)) in smc_probe()
1992 lp->msg_enable = NETIF_MSG_LINK; in smc_probe()
1993 lp->ctl_rfduplx = 0; in smc_probe()
1994 lp->ctl_rspeed = 10; in smc_probe()
1996 if (lp->version >= (CHIP_91100 << 4)) { in smc_probe()
1997 lp->ctl_rfduplx = 1; in smc_probe()
1998 lp->ctl_rspeed = 100; in smc_probe()
2002 retval = request_irq(dev->irq, smc_interrupt, irq_flags, dev->name, dev); in smc_probe()
2008 lp->cfg.flags |= SMC91X_USE_DMA; in smc_probe()
2010 if (lp->cfg.flags & SMC91X_USE_DMA) { in smc_probe()
2015 lp->dma_chan = dma_request_channel(mask, NULL, NULL); in smc_probe()
2024 lp->base, dev->irq); in smc_probe()
2026 if (lp->dma_chan) in smc_probe()
2027 pr_cont(" DMA %p", lp->dma_chan); in smc_probe()
2030 lp->cfg.flags & SMC91X_NOWAIT ? " [nowait]" : "", in smc_probe()
2033 if (!is_valid_ether_addr(dev->dev_addr)) { in smc_probe()
2038 dev->dev_addr); in smc_probe()
2041 if (lp->phy_type == 0) { in smc_probe()
2043 } else if ((lp->phy_type & 0xfffffff0) == 0x0016f840) { in smc_probe()
2045 } else if ((lp->phy_type & 0xfffffff0) == 0x02821c50) { in smc_probe()
2052 if (retval && lp->dma_chan) in smc_probe()
2053 dma_release_channel(lp->dma_chan); in smc_probe()
2067 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); in smc_enable_device()
2074 addr = ioremap(res->start, ATTRIB_SIZE); in smc_enable_device()
2076 return -ENOMEM; in smc_enable_device()
2093 * The device will ignore all writes to the enable bit while in smc_enable_device()
2094 * reset is asserted, even if the reset bit is cleared in the in smc_enable_device()
2124 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); in smc_request_attrib()
2130 if (!request_mem_region(res->start, ATTRIB_SIZE, CARDNAME)) in smc_request_attrib()
2131 return -EBUSY; in smc_request_attrib()
2139 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); in smc_release_attrib()
2143 release_mem_region(res->start, ATTRIB_SIZE); in smc_release_attrib()
2149 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32"); in smc_request_datacs()
2155 if(!request_mem_region(res->start, SMC_DATA_EXTENT, CARDNAME)) { in smc_request_datacs()
2161 lp->datacs = ioremap(res->start, SMC_DATA_EXTENT); in smc_request_datacs()
2169 struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32"); in smc_release_datacs()
2171 if (lp->datacs) in smc_release_datacs()
2172 iounmap(lp->datacs); in smc_release_datacs()
2174 lp->datacs = NULL; in smc_release_datacs()
2177 release_mem_region(res->start, SMC_DATA_EXTENT); in smc_release_datacs()
2196 * try_toggle_control_gpio - configure a gpio if it exists
2230 * dev->base_addr == 0, try to find all possible locations
2231 * dev->base_addr > 0x1ff, this is the address to check
2232 * dev->base_addr == <anything else>, return failure code
2235 * 0 --> there is a device
2240 struct smc91x_platdata *pd = dev_get_platdata(&pdev->dev); in smc_drv_probe()
2252 ret = -ENOMEM; in smc_drv_probe()
2255 SET_NETDEV_DEV(ndev, &pdev->dev); in smc_drv_probe()
2262 lp->cfg.flags = 0; in smc_drv_probe()
2265 memcpy(&lp->cfg, pd, sizeof(lp->cfg)); in smc_drv_probe()
2266 lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); in smc_drv_probe()
2269 dev_err(&pdev->dev, in smc_drv_probe()
2270 "at least one of 8-bit or 16-bit access support is required.\n"); in smc_drv_probe()
2271 ret = -ENXIO; in smc_drv_probe()
2277 match = of_match_device(of_match_ptr(smc91x_match), &pdev->dev); in smc_drv_probe()
2282 ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio, in smc_drv_probe()
2291 ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio, in smc_drv_probe()
2300 if (lp->reset_gpio) in smc_drv_probe()
2303 /* Combination of IO widths supported, default to 16-bit */ in smc_drv_probe()
2304 if (!device_property_read_u32(&pdev->dev, "reg-io-width", in smc_drv_probe()
2307 lp->cfg.flags |= SMC91X_USE_8BIT; in smc_drv_probe()
2309 lp->cfg.flags |= SMC91X_USE_16BIT; in smc_drv_probe()
2311 lp->cfg.flags |= SMC91X_USE_32BIT; in smc_drv_probe()
2313 lp->cfg.flags |= SMC91X_USE_16BIT; in smc_drv_probe()
2315 if (!device_property_read_u32(&pdev->dev, "reg-shift", in smc_drv_probe()
2317 lp->io_shift = val; in smc_drv_probe()
2318 lp->cfg.pxa_u16_align4 = in smc_drv_probe()
2319 device_property_read_bool(&pdev->dev, "pxa-u16-align4"); in smc_drv_probe()
2324 lp->cfg.flags |= (SMC_CAN_USE_8BIT) ? SMC91X_USE_8BIT : 0; in smc_drv_probe()
2325 lp->cfg.flags |= (SMC_CAN_USE_16BIT) ? SMC91X_USE_16BIT : 0; in smc_drv_probe()
2326 lp->cfg.flags |= (SMC_CAN_USE_32BIT) ? SMC91X_USE_32BIT : 0; in smc_drv_probe()
2327 lp->cfg.flags |= (nowait) ? SMC91X_NOWAIT : 0; in smc_drv_probe()
2330 if (!lp->cfg.leda && !lp->cfg.ledb) { in smc_drv_probe()
2331 lp->cfg.leda = RPC_LSA_DEFAULT; in smc_drv_probe()
2332 lp->cfg.ledb = RPC_LSB_DEFAULT; in smc_drv_probe()
2335 ndev->dma = (unsigned char)-1; in smc_drv_probe()
2337 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); in smc_drv_probe()
2341 ret = -ENODEV; in smc_drv_probe()
2346 if (!request_mem_region(res->start, SMC_IO_EXTENT, CARDNAME)) { in smc_drv_probe()
2347 ret = -EBUSY; in smc_drv_probe()
2351 ndev->irq = platform_get_irq(pdev, 0); in smc_drv_probe()
2352 if (ndev->irq < 0) { in smc_drv_probe()
2353 ret = ndev->irq; in smc_drv_probe()
2361 irq_resflags = irqd_get_trigger_type(irq_get_irq_data(ndev->irq)); in smc_drv_probe()
2362 if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK) in smc_drv_probe()
2377 addr = ioremap(res->start, SMC_IO_EXTENT); in smc_drv_probe()
2379 ret = -ENOMEM; in smc_drv_probe()
2386 lp->device = &pdev->dev; in smc_drv_probe()
2387 lp->physaddr = res->start; in smc_drv_probe()
2405 release_mem_region(res->start, SMC_IO_EXTENT); in smc_drv_probe()
2422 free_irq(ndev->irq, ndev); in smc_drv_remove()
2425 if (lp->dma_chan) in smc_drv_remove()
2426 dma_release_channel(lp->dma_chan); in smc_drv_remove()
2428 iounmap(lp->base); in smc_drv_remove()
2433 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); in smc_drv_remove()
2436 release_mem_region(res->start, SMC_IO_EXTENT); in smc_drv_remove()
2468 if (lp->phy_type != 0) in smc_drv_resume()
2469 smc_phy_configure(&lp->phy_configure); in smc_drv_resume()