97 #define dprintk(x...) do { } while (0)
99 #include <linux/module.h>
101 #include <linux/types.h>
102 #include <linux/pci.h>
104 #include <linux/netdevice.h>
110 #include <linux/ip.h>
111 #include <linux/in.h>
112 #include <linux/compiler.h>
113 #include <linux/prefetch.h>
114 #include <linux/ethtool.h>
115 #include <linux/sched.h>
117 #include <linux/if_vlan.h>
118 #include <linux/rtnetlink.h>
120 #include <linux/slab.h>
123 #include <asm/uaccess.h>
125 #define DRV_NAME "ns83820"
129 static int reset_phy = 0;
130 static int lnksts = 0;
134 #define Dprintk dprintk
137 #define RX_BUF_SIZE 1500
138 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
139 #define NS83820_VLAN_ACCEL_SUPPORT
143 #define NR_RX_DESC 64
144 #define NR_TX_DESC 128
147 #define REAL_RX_BUF_SIZE (RX_BUF_SIZE + 14)
149 #define MIN_TX_DESC_FREE 8
154 #define CR_TXE 0x00000001
155 #define CR_TXD 0x00000002
159 #define CR_RXE 0x00000004
160 #define CR_RXD 0x00000008
161 #define CR_TXR 0x00000010
162 #define CR_RXR 0x00000020
163 #define CR_SWI 0x00000080
164 #define CR_RST 0x00000100
166 #define PTSCR_EEBIST_FAIL 0x00000001
167 #define PTSCR_EEBIST_EN 0x00000002
168 #define PTSCR_EELOAD_EN 0x00000004
169 #define PTSCR_RBIST_FAIL 0x000001b8
170 #define PTSCR_RBIST_DONE 0x00000200
171 #define PTSCR_RBIST_EN 0x00000400
172 #define PTSCR_RBIST_RST 0x00002000
174 #define MEAR_EEDI 0x00000001
175 #define MEAR_EEDO 0x00000002
176 #define MEAR_EECLK 0x00000004
177 #define MEAR_EESEL 0x00000008
178 #define MEAR_MDIO 0x00000010
179 #define MEAR_MDDIR 0x00000020
180 #define MEAR_MDC 0x00000040
182 #define ISR_TXDESC3 0x40000000
183 #define ISR_TXDESC2 0x20000000
184 #define ISR_TXDESC1 0x10000000
185 #define ISR_TXDESC0 0x08000000
186 #define ISR_RXDESC3 0x04000000
187 #define ISR_RXDESC2 0x02000000
188 #define ISR_RXDESC1 0x01000000
189 #define ISR_RXDESC0 0x00800000
190 #define ISR_TXRCMP 0x00400000
191 #define ISR_RXRCMP 0x00200000
192 #define ISR_DPERR 0x00100000
193 #define ISR_SSERR 0x00080000
194 #define ISR_RMABT 0x00040000
195 #define ISR_RTABT 0x00020000
196 #define ISR_RXSOVR 0x00010000
197 #define ISR_HIBINT 0x00008000
198 #define ISR_PHY 0x00004000
199 #define ISR_PME 0x00002000
200 #define ISR_SWI 0x00001000
201 #define ISR_MIB 0x00000800
202 #define ISR_TXURN 0x00000400
203 #define ISR_TXIDLE 0x00000200
204 #define ISR_TXERR 0x00000100
205 #define ISR_TXDESC 0x00000080
206 #define ISR_TXOK 0x00000040
207 #define ISR_RXORN 0x00000020
208 #define ISR_RXIDLE 0x00000010
209 #define ISR_RXEARLY 0x00000008
210 #define ISR_RXERR 0x00000004
211 #define ISR_RXDESC 0x00000002
212 #define ISR_RXOK 0x00000001
214 #define TXCFG_CSI 0x80000000
215 #define TXCFG_HBI 0x40000000
216 #define TXCFG_MLB 0x20000000
217 #define TXCFG_ATP 0x10000000
218 #define TXCFG_ECRETRY 0x00800000
219 #define TXCFG_BRST_DIS 0x00080000
220 #define TXCFG_MXDMA1024 0x00000000
221 #define TXCFG_MXDMA512 0x00700000
222 #define TXCFG_MXDMA256 0x00600000
223 #define TXCFG_MXDMA128 0x00500000
224 #define TXCFG_MXDMA64 0x00400000
225 #define TXCFG_MXDMA32 0x00300000
226 #define TXCFG_MXDMA16 0x00200000
227 #define TXCFG_MXDMA8 0x00100000
229 #define CFG_LNKSTS 0x80000000
230 #define CFG_SPDSTS 0x60000000
231 #define CFG_SPDSTS1 0x40000000
232 #define CFG_SPDSTS0 0x20000000
233 #define CFG_DUPSTS 0x10000000
234 #define CFG_TBI_EN 0x01000000
235 #define CFG_MODE_1000 0x00400000
238 #define CFG_AUTO_1000 0x00200000
239 #define CFG_PINT_CTL 0x001c0000
240 #define CFG_PINT_DUPSTS 0x00100000
241 #define CFG_PINT_LNKSTS 0x00080000
242 #define CFG_PINT_SPDSTS 0x00040000
243 #define CFG_TMRTEST 0x00020000
244 #define CFG_MRM_DIS 0x00010000
245 #define CFG_MWI_DIS 0x00008000
246 #define CFG_T64ADDR 0x00004000
247 #define CFG_PCI64_DET 0x00002000
248 #define CFG_DATA64_EN 0x00001000
249 #define CFG_M64ADDR 0x00000800
250 #define CFG_PHY_RST 0x00000400
251 #define CFG_PHY_DIS 0x00000200
252 #define CFG_EXTSTS_EN 0x00000100
253 #define CFG_REQALG 0x00000080
254 #define CFG_SB 0x00000040
255 #define CFG_POW 0x00000020
256 #define CFG_EXD 0x00000010
257 #define CFG_PESEL 0x00000008
258 #define CFG_BROM_DIS 0x00000004
259 #define CFG_EXT_125 0x00000002
260 #define CFG_BEM 0x00000001
262 #define EXTSTS_UDPPKT 0x00200000
263 #define EXTSTS_TCPPKT 0x00080000
264 #define EXTSTS_IPPKT 0x00020000
265 #define EXTSTS_VPKT 0x00010000
266 #define EXTSTS_VTG_MASK 0x0000ffff
268 #define SPDSTS_POLARITY (CFG_SPDSTS1 | CFG_SPDSTS0 | CFG_DUPSTS | (lnksts ? CFG_LNKSTS : 0))
270 #define MIBC_MIBS 0x00000008
271 #define MIBC_ACLR 0x00000004
272 #define MIBC_FRZ 0x00000002
273 #define MIBC_WRN 0x00000001
275 #define PCR_PSEN (1 << 31)
276 #define PCR_PS_MCAST (1 << 30)
277 #define PCR_PS_DA (1 << 29)
278 #define PCR_STHI_8 (3 << 23)
279 #define PCR_STLO_4 (1 << 23)
280 #define PCR_FFHI_8K (3 << 21)
281 #define PCR_FFLO_4K (1 << 21)
282 #define PCR_PAUSE_CNT 0xFFFE
284 #define RXCFG_AEP 0x80000000
285 #define RXCFG_ARP 0x40000000
286 #define RXCFG_STRIPCRC 0x20000000
287 #define RXCFG_RX_FD 0x10000000
288 #define RXCFG_ALP 0x08000000
289 #define RXCFG_AIRL 0x04000000
290 #define RXCFG_MXDMA512 0x00700000
291 #define RXCFG_DRTH 0x0000003e
292 #define RXCFG_DRTH0 0x00000002
294 #define RFCR_RFEN 0x80000000
295 #define RFCR_AAB 0x40000000
296 #define RFCR_AAM 0x20000000
297 #define RFCR_AAU 0x10000000
298 #define RFCR_APM 0x08000000
299 #define RFCR_APAT 0x07800000
300 #define RFCR_APAT3 0x04000000
301 #define RFCR_APAT2 0x02000000
302 #define RFCR_APAT1 0x01000000
303 #define RFCR_APAT0 0x00800000
304 #define RFCR_AARP 0x00400000
305 #define RFCR_MHEN 0x00200000
306 #define RFCR_UHEN 0x00100000
307 #define RFCR_ULM 0x00080000
309 #define VRCR_RUDPE 0x00000080
310 #define VRCR_RTCPE 0x00000040
311 #define VRCR_RIPE 0x00000020
312 #define VRCR_IPEN 0x00000010
313 #define VRCR_DUTF 0x00000008
314 #define VRCR_DVTF 0x00000004
315 #define VRCR_VTREN 0x00000002
316 #define VRCR_VTDEN 0x00000001
318 #define VTCR_PPCHK 0x00000008
319 #define VTCR_GCHK 0x00000004
320 #define VTCR_VPPTI 0x00000002
321 #define VTCR_VGTI 0x00000001
358 #define TBICR_MR_AN_ENABLE 0x00001000
359 #define TBICR_MR_RESTART_AN 0x00000200
361 #define TBISR_MR_LINK_STATUS 0x00000020
362 #define TBISR_MR_AN_COMPLETE 0x00000004
364 #define TANAR_PS2 0x00000100
365 #define TANAR_PS1 0x00000080
366 #define TANAR_HALF_DUP 0x00000040
367 #define TANAR_FULL_DUP 0x00000020
369 #define GPIOR_GP5_OE 0x00000200
370 #define GPIOR_GP4_OE 0x00000100
371 #define GPIOR_GP3_OE 0x00000080
372 #define GPIOR_GP2_OE 0x00000040
373 #define GPIOR_GP1_OE 0x00000020
374 #define GPIOR_GP3_OUT 0x00000004
375 #define GPIOR_GP1_OUT 0x00000001
377 #define LINK_AUTONEGOTIATE 0x01
378 #define LINK_DOWN 0x02
381 #define HW_ADDR_LEN sizeof(dma_addr_t)
382 #define desc_addr_set(desc, addr) \
384 ((desc)[0] = cpu_to_le32(addr)); \
385 if (HW_ADDR_LEN == 8) \
386 (desc)[1] = cpu_to_le32(((u64)addr) >> 32); \
388 #define desc_addr_get(desc) \
389 (le32_to_cpu((desc)[0]) | \
390 (HW_ADDR_LEN == 8 ? ((dma_addr_t)le32_to_cpu((desc)[1]))<<32 : 0))
393 #define DESC_BUFPTR (DESC_LINK + HW_ADDR_LEN/4)
394 #define DESC_CMDSTS (DESC_BUFPTR + HW_ADDR_LEN/4)
395 #define DESC_EXTSTS (DESC_CMDSTS + 4/4)
397 #define CMDSTS_OWN 0x80000000
398 #define CMDSTS_MORE 0x40000000
399 #define CMDSTS_INTR 0x20000000
400 #define CMDSTS_ERR 0x10000000
401 #define CMDSTS_OK 0x08000000
402 #define CMDSTS_RUNT 0x00200000
403 #define CMDSTS_LEN_MASK 0x0000ffff
405 #define CMDSTS_DEST_MASK 0x01800000
406 #define CMDSTS_DEST_SELF 0x00800000
407 #define CMDSTS_DEST_MULTI 0x01000000
467 return netdev_priv(dev);
470 #define __kick_rx(dev) writel(CR_RXE, dev->base + CR)
475 dprintk(
"kick_rx: maybe kicking\n");
489 #define start_tx_okay(dev) \
490 (((NR_TX_DESC-2 + dev->tx_done_idx - dev->tx_free_idx) % NR_TX_DESC) > MIN_TX_DESC_FREE)
514 #define nr_rx_empty(dev) ((NR_RX_DESC-2 + dev->rx_info.next_rx - dev->rx_info.next_empty) % NR_RX_DESC)
522 next_empty = dev->
rx_info.next_empty;
531 dprintk(
"next_empty[%d] nr_used[%d] next_rx[%d]\n",
546 build_rx_desc(dev, sg, 0, buf, cmdsts, 0);
558 unsigned long flags = 0;
563 dprintk(
"rx_refill(%p)\n", ndev);
578 res = ns83820_add_rx_skb(dev, skb);
580 spin_unlock_irqrestore(&dev->
rx_info.lock, flags);
587 spin_unlock_irqrestore(&dev->
rx_info.lock, flags);
592 static void rx_refill_atomic(
struct net_device *ndev)
608 static inline void clear_rx_desc(
struct ns83820 *dev,
unsigned i)
616 static const char *speeds[] = {
"10",
"100",
"1000",
"1000(?)",
"1000F" };
618 u32 tbisr, tanar, tanlpar;
619 int speed, fullduplex, newlinkstate;
628 dprintk(
"phy_intr: tbisr=%08x, tanar=%08x, tanlpar=%08x\n",
629 tbisr, tanar, tanlpar);
632 (tanar & TANAR_FULL_DUP)) ) {
645 (tanar & TANAR_HALF_DUP)) ||
646 ((tanlpar & TANAR_FULL_DUP) &&
647 (tanar & TANAR_HALF_DUP)) ||
648 ((tanlpar & TANAR_HALF_DUP) &&
649 (tanar & TANAR_FULL_DUP))) {
705 netif_start_queue(ndev);
706 netif_wake_queue(ndev);
710 fullduplex ?
"full" :
"half");
713 netif_stop_queue(ndev);
720 static int ns83820_setup_rx(
struct net_device *ndev)
726 dprintk(
"ns83820_setup_rx(%p)\n", ndev);
734 clear_rx_desc(dev, i);
741 dprintk(
"starting receiver\n");
743 spin_lock_irq(&dev->
rx_info.lock);
773 spin_unlock_irq(&dev->
rx_info.lock);
778 static void ns83820_cleanup_rx(
struct ns83820 *dev)
783 dprintk(
"ns83820_cleanup_rx(%p)\n", dev);
789 spin_unlock_irqrestore(&dev->
misc_lock, flags);
805 clear_rx_desc(dev, i);
810 static void ns83820_rx_kick(
struct net_device *ndev)
815 rx_refill_atomic(ndev);
843 dprintk(
"rxdp: %08x, descs: %08lx next_rx[%d]: %p next_empty[%d]: %p\n",
845 (
long)(dev->
rx_info.phy_descs),
865 dprintk(
"cmdsts: %08x\n", cmdsts);
867 dprintk(
"extsts: %08x\n", extsts);
869 skb = info->
skbs[next_rx];
871 info->
next_rx = (next_rx + 1) % NR_RX_DESC;
874 clear_rx_desc(dev, next_rx);
876 pci_unmap_single(dev->
pci_dev, bufptr,
879 #ifdef NS83820_VLAN_ACCEL_SUPPORT
898 goto netdev_mangle_me_harder_failed;
900 ndev->
stats.multicast++;
901 ndev->
stats.rx_packets++;
903 if ((extsts & 0x002a0000) && !(extsts & 0x00540000)) {
906 skb_checksum_none_assert(skb);
909 #ifdef NS83820_VLAN_ACCEL_SUPPORT
914 __vlan_hwaccel_put_tag(skb, tag);
919 netdev_mangle_me_harder_failed:
920 ndev->
stats.rx_dropped++;
935 Dprintk(
"dazed: cmdsts_f: %08x\n", cmdsts);
938 spin_unlock_irqrestore(&info->
lock, flags);
941 static void rx_action(
unsigned long _dev)
954 ns83820_rx_kick(ndev);
959 static inline void kick_tx(
struct ns83820 *dev)
961 dprintk(
"kick_tx(%p): tx_idx=%d free_idx=%d\n",
969 static void do_tx_done(
struct net_device *ndev)
975 dprintk(
"do_tx_done(%p)\n", ndev);
979 dprintk(
"tx_done_idx=%d free_idx=%d cmdsts=%08x\n",
988 ndev->
stats.tx_errors++;
990 ndev->
stats.tx_packets++;
991 if (cmdsts & CMDSTS_OK)
992 ndev->
stats.tx_bytes += cmdsts & 0xffff;
994 dprintk(
"tx_done_idx=%d free_idx=%d cmdsts=%08x\n",
996 skb = dev->
tx_skbs[tx_done_idx];
1003 pci_unmap_single(dev->
pci_dev,
1015 tx_done_idx = (tx_done_idx + 1) %
NR_TX_DESC;
1026 dprintk(
"start_queue(%p)\n", ndev);
1027 netif_start_queue(ndev);
1028 netif_wake_queue(ndev);
1032 static void ns83820_cleanup_tx(
struct ns83820 *dev)
1041 pci_unmap_single(dev->
pci_dev,
1063 u32 free_idx, cmdsts, extsts;
1064 int nr_free, nr_frags;
1071 volatile __le32 *first_desc;
1073 dprintk(
"ns83820_hard_start_xmit\n");
1075 nr_frags = skb_shinfo(skb)->nr_frags;
1078 netif_stop_queue(ndev);
1081 netif_start_queue(ndev);
1086 nr_free = (tx_done_idx + NR_TX_DESC-2 - free_idx) % NR_TX_DESC;
1088 if (nr_free <= nr_frags) {
1089 dprintk(
"stop_queue - not enough(%p)\n", ndev);
1090 netif_stop_queue(ndev);
1094 dprintk(
"restart queue(%p)\n", ndev);
1095 netif_start_queue(ndev);
1106 nr_free -= nr_frags;
1108 dprintk(
"stop_queue - last entry(%p)\n", ndev);
1109 netif_stop_queue(ndev);
1113 frag = skb_shinfo(skb)->frags;
1125 #ifdef NS83820_VLAN_ACCEL_SUPPORT
1146 dprintk(
"frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len,
1147 (
unsigned long long)buf);
1148 last_idx = free_idx;
1149 free_idx = (free_idx + 1) % NR_TX_DESC;
1155 cmdsts |= (desc == first_desc) ? 0 :
CMDSTS_OWN;
1162 buf = skb_frag_dma_map(&dev->
pci_dev->dev, frag, 0,
1164 dprintk(
"frag: buf=%08Lx page=%08lx offset=%08lx\n",
1167 len = skb_frag_size(frag);
1178 spin_unlock_irq(&dev->
tx_lock);
1184 netif_start_queue(ndev);
1189 static void ns83820_update_stats(
struct ns83820 *dev)
1195 ndev->
stats.rx_errors +=
readl(base + 0x60) & 0xffff;
1196 ndev->
stats.rx_crc_errors +=
readl(base + 0x64) & 0xffff;
1197 ndev->
stats.rx_missed_errors +=
readl(base + 0x68) & 0xffff;
1198 ndev->
stats.rx_frame_errors +=
readl(base + 0x6c) & 0xffff;
1200 ndev->
stats.rx_length_errors +=
readl(base + 0x74) & 0xffff;
1201 ndev->
stats.rx_length_errors +=
readl(base + 0x78) & 0xffff;
1205 ndev->
stats.tx_carrier_errors +=
readl(base + 0x88) & 0xff;
1214 ns83820_update_stats(dev);
1217 return &ndev->
stats;
1221 static int ns83820_get_settings(
struct net_device *ndev,
1275 ethtool_cmd_speed_set(cmd,
SPEED_10);
1284 static int ns83820_set_settings(
struct net_device *ndev,
1289 int have_optical = 0;
1310 if (cmd->
duplex != fullduplex) {
1352 cmd->
autoneg ?
"ENABLED" :
"DISABLED");
1375 return cfg & CFG_LNKSTS ? 1 : 0;
1379 .get_settings = ns83820_get_settings,
1380 .set_settings = ns83820_set_settings,
1381 .get_drvinfo = ns83820_get_drvinfo,
1382 .get_link = ns83820_get_link
1385 static inline void ns83820_disable_interrupts(
struct ns83820 *dev)
1393 static void ns83820_mib_isr(
struct ns83820 *dev)
1395 unsigned long flags;
1397 ns83820_update_stats(dev);
1398 spin_unlock_irqrestore(&dev->
misc_lock, flags);
1407 dprintk(
"ns83820_irq(%p)\n", ndev);
1413 ns83820_do_isr(ndev, isr);
1420 unsigned long flags;
1424 Dprintk(
"odd isr? 0x%08x\n", isr);
1429 Dprintk(
"oh dear, we are idle\n");
1430 ns83820_rx_kick(ndev);
1439 spin_unlock_irqrestore(&dev->
misc_lock, flags);
1447 ns83820_rx_kick(ndev);
1451 ndev->
stats.rx_fifo_errors++;
1456 ndev->
stats.rx_fifo_errors++;
1465 dprintk(
"txdp: %08x\n", txdp);
1468 if (dev->
tx_idx >= NR_TX_DESC) {
1487 spin_unlock_irqrestore(&dev->
tx_lock, flags);
1496 spin_unlock_irqrestore(&dev->
misc_lock, flags);
1510 spin_unlock_irqrestore(&dev->
misc_lock, flags);
1515 ns83820_mib_isr(dev);
1527 static void ns83820_do_reset(
struct ns83820 *dev,
u32 which)
1529 Dprintk(
"resetting chip...\n");
1537 static int ns83820_stop(
struct net_device *ndev)
1544 ns83820_disable_interrupts(dev);
1549 ns83820_do_reset(dev,
CR_RST);
1557 ns83820_cleanup_rx(dev);
1558 ns83820_cleanup_tx(dev);
1563 static void ns83820_tx_timeout(
struct net_device *ndev)
1568 unsigned long flags;
1575 printk(
KERN_INFO "%s: tx_timeout: tx_done_idx=%d free_idx=%d cmdsts=%08x\n",
1584 ns83820_do_isr(ndev, isr);
1593 printk(
KERN_INFO "%s: after: tx_done_idx=%d free_idx=%d cmdsts=%08x\n",
1597 spin_unlock_irqrestore(&dev->
tx_lock, flags);
1600 static void ns83820_tx_watch(
unsigned long data)
1606 printk(
"ns83820_tx_watch: %u %u %d\n",
1617 ns83820_tx_timeout(ndev);
1623 static int ns83820_open(
struct net_device *ndev)
1634 ret = ns83820_setup_rx(ndev);
1643 + ((i+1) % NR_TX_DESC) *
DESC_SIZE * 4);
1657 netif_start_queue(ndev);
1666 static void ns83820_getmac(
struct ns83820 *dev,
u8 *
mac)
1669 for (i=0; i<3; i++) {
1683 static int ns83820_change_mtu(
struct net_device *ndev,
int new_mtu)
1687 ndev->
mtu = new_mtu;
1691 static void ns83820_set_multicast(
struct net_device *ndev)
1695 u32 and_mask = 0xffffffff;
1710 val = (
readl(rfcr) & and_mask) | or_mask;
1721 unsigned long start;
1733 if (!(status & enable))
1748 ndev->
name, name, status, fail);
1751 ndev->
name, name, status);
1753 dprintk(
"%s: done %s in %d loops\n", ndev->
name, name, loops);
1756 #ifdef PHY_CODE_IS_FINISHED
1757 static void ns83820_mii_write_bit(
struct ns83820 *dev,
int bit)
1787 static int ns83820_mii_read_bit(
struct ns83820 *dev)
1811 static unsigned ns83820_mii_read_reg(
struct ns83820 *dev,
unsigned phy,
unsigned reg)
1817 for (i=0; i<64; i++)
1818 ns83820_mii_read_bit(dev);
1820 ns83820_mii_write_bit(dev, 0);
1821 ns83820_mii_write_bit(dev, 1);
1822 ns83820_mii_write_bit(dev, 1);
1823 ns83820_mii_write_bit(dev, 0);
1827 ns83820_mii_write_bit(dev, phy & (0x10 >> i));
1831 ns83820_mii_write_bit(dev, reg & (0x10 >> i));
1833 ns83820_mii_read_bit(dev);
1834 ns83820_mii_read_bit(dev);
1837 for (i=0; i<16; i++) {
1839 data |= ns83820_mii_read_bit(dev);
1845 static unsigned ns83820_mii_write_reg(
struct ns83820 *dev,
unsigned phy,
unsigned reg,
unsigned data)
1850 for (i=0; i<64; i++)
1851 ns83820_mii_read_bit(dev);
1853 ns83820_mii_write_bit(dev, 0);
1854 ns83820_mii_write_bit(dev, 1);
1855 ns83820_mii_write_bit(dev, 0);
1856 ns83820_mii_write_bit(dev, 1);
1860 ns83820_mii_write_bit(dev, phy & (0x10 >> i));
1864 ns83820_mii_write_bit(dev, reg & (0x10 >> i));
1866 ns83820_mii_read_bit(dev);
1867 ns83820_mii_read_bit(dev);
1870 for (i=0; i<16; i++)
1871 ns83820_mii_write_bit(dev, (data >> (15 - i)) & 1);
1876 static void ns83820_probe_phy(
struct net_device *ndev)
1881 #define MII_PHYIDR1 0x02
1882 #define MII_PHYIDR2 0x03
1887 ns83820_mii_read_reg(dev, 1, 0x09);
1888 ns83820_mii_write_reg(dev, 1, 0x10, 0x0d3e);
1890 tmp = ns83820_mii_read_reg(dev, 1, 0x00);
1891 ns83820_mii_write_reg(dev, 1, 0x00, tmp | 0x8000);
1893 ns83820_mii_read_reg(dev, 1, 0x09);
1898 for (i=1; i<2; i++) {
1901 a = ns83820_mii_read_reg(dev, i, MII_PHYIDR1);
1902 b = ns83820_mii_read_reg(dev, i, MII_PHYIDR2);
1907 for (j=0; j<0x16; j+=4) {
1908 dprintk(
"%s: [0x%02x] %04x %04x %04x %04x\n",
1910 ns83820_mii_read_reg(dev, i, 0 + j),
1911 ns83820_mii_read_reg(dev, i, 1 + j),
1912 ns83820_mii_read_reg(dev, i, 2 + j),
1913 ns83820_mii_read_reg(dev, i, 3 + j)
1920 ns83820_mii_write_reg(dev, 1, 0x16, 0x000d);
1921 ns83820_mii_write_reg(dev, 1, 0x1e, 0x810e);
1922 a = ns83820_mii_read_reg(dev, 1, 0x1d);
1924 ns83820_mii_write_reg(dev, 1, 0x16, 0x000d);
1925 ns83820_mii_write_reg(dev, 1, 0x1e, 0x810e);
1926 b = ns83820_mii_read_reg(dev, 1, 0x1d);
1927 dprintk(
"version: 0x%04x 0x%04x\n", a, b);
1933 .ndo_open = ns83820_open,
1934 .ndo_stop = ns83820_stop,
1935 .ndo_start_xmit = ns83820_hard_start_xmit,
1936 .ndo_get_stats = ns83820_get_stats,
1937 .ndo_change_mtu = ns83820_change_mtu,
1938 .ndo_set_rx_mode = ns83820_set_multicast,
1941 .ndo_tx_timeout = ns83820_tx_timeout,
1957 }
else if (!pci_set_dma_mask(pci_dev,
DMA_BIT_MASK(32))) {
1960 dev_warn(&pci_dev->
dev,
"pci_set_dma_mask failed!\n");
1964 ndev = alloc_etherdev(
sizeof(
struct ns83820));
1984 dev_info(&pci_dev->
dev,
"pci_enable_dev failed: %d\n", err);
1999 dprintk(
"%p: %08lx %p: %08lx\n",
2003 ns83820_disable_interrupts(dev);
2010 dev_info(&pci_dev->
dev,
"unable to register irq %d, err %d\n",
2025 dev_info(&pci_dev->
dev,
"unable to get netdev name: %d\n", err);
2029 printk(
"%s: ns83820.c: 0x22c: %08x, subsystem: %04x:%04x\n",
2036 pci_set_drvdata(pci_dev, ndev);
2038 ns83820_do_reset(dev,
CR_RST);
2089 | TANAR_HALF_DUP | TANAR_FULL_DUP,
2126 | ((1600 / 32) * 0x100),
2161 #ifdef NS83820_VLAN_ACCEL_SUPPORT
2162 #define VRCR_INIT_VALUE (VRCR_IPEN|VRCR_VTDEN|VRCR_VTREN)
2164 #define VRCR_INIT_VALUE (VRCR_IPEN|VRCR_VTDEN)
2172 #ifdef NS83820_VLAN_ACCEL_SUPPORT
2173 #define VTCR_INIT_VALUE (VTCR_PPCHK|VTCR_VPPTI)
2175 #define VTCR_INIT_VALUE VTCR_PPCHK
2188 ns83820_getmac(dev, ndev->
dev_addr);
2194 #ifdef NS83820_VLAN_ACCEL_SUPPORT
2213 #ifdef PHY_CODE_IS_FINISHED
2214 ns83820_probe_phy(ndev);
2227 ns83820_disable_interrupts(dev);
2239 pci_set_drvdata(pci_dev,
NULL);
2244 static void __devexit ns83820_remove_one(
struct pci_dev *pci_dev)
2246 struct net_device *ndev = pci_get_drvdata(pci_dev);
2252 ns83820_disable_interrupts(dev);
2263 pci_set_drvdata(pci_dev,
NULL);
2273 .id_table = ns83820_pci_tbl,
2274 .probe = ns83820_init_one,
2283 static int __init ns83820_init(
void)
2285 printk(
KERN_INFO "ns83820.c: National Semiconductor DP83820 10/100/1000 driver.\n");
2286 return pci_register_driver(&driver);
2289 static void __exit ns83820_exit(
void)
2304 MODULE_PARM_DESC(ihr,
"Time in 100 us increments to delay interrupts (range 0-127)");