1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Davicom DM9000 Fast Ethernet driver for Linux.
4 * Copyright (C) 1997 Sten Wang
6 * (C) Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
8 * Additional updates, Copyright:
9 * Ben Dooks <ben@simtec.co.uk>
10 * Sascha Hauer <s.hauer@pengutronix.de>
13 #include <linux/module.h>
14 #include <linux/ioport.h>
15 #include <linux/netdevice.h>
16 #include <linux/etherdevice.h>
17 #include <linux/interrupt.h>
18 #include <linux/skbuff.h>
19 #include <linux/spinlock.h>
20 #include <linux/crc32.h>
21 #include <linux/mii.h>
23 #include <linux/of_net.h>
24 #include <linux/ethtool.h>
25 #include <linux/dm9000.h>
26 #include <linux/delay.h>
27 #include <linux/platform_device.h>
28 #include <linux/irq.h>
29 #include <linux/slab.h>
30 #include <linux/regulator/consumer.h>
31 #include <linux/gpio.h>
32 #include <linux/of_gpio.h>
34 #include <asm/delay.h>
40 /* Board/System/Debug information/definition ---------------- */
42 #define DM9000_PHY 0x40 /* PHY address 0x01 */
44 #define CARDNAME "dm9000"
47 * Transmit timeout, default 5 seconds.
49 static int watchdog = 5000;
50 module_param(watchdog, int, 0400);
51 MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
54 * Debug messages level
57 module_param(debug, int, 0644);
58 MODULE_PARM_DESC(debug, "dm9000 debug level (0-6)");
60 /* DM9000 register address locking.
62 * The DM9000 uses an address register to control where data written
63 * to the data register goes. This means that the address register
64 * must be preserved over interrupts or similar calls.
66 * During interrupt and other critical calls, a spinlock is used to
67 * protect the system, but the calls themselves save the address
68 * in the address register in case they are interrupting another
69 * access to the device.
71 * For general accesses a lock is provided so that calls which are
72 * allowed to sleep are serialised so that the address register does
73 * not need to be saved. This lock also serves to serialise access
74 * to the EEPROM and PHY access registers which are shared between
78 /* The driver supports the original DM9000E, and now the two newer
79 * devices, DM9000A and DM9000B.
83 TYPE_DM9000E, /* original DM9000 */
88 /* Structure/enum declaration ------------------------------- */
91 void __iomem *io_addr; /* Register I/O base address */
92 void __iomem *io_data; /* Data I/O address */
100 u8 io_mode; /* 0:word, 2:byte */
105 unsigned int in_timeout:1;
106 unsigned int in_suspend:1;
107 unsigned int wake_supported:1;
109 enum dm9000_type type;
111 void (*inblk)(void __iomem *port, void *data, int length);
112 void (*outblk)(void __iomem *port, void *data, int length);
113 void (*dumpblk)(void __iomem *port, int length);
115 struct device *dev; /* parent device */
117 struct resource *addr_res; /* resources found */
118 struct resource *data_res;
119 struct resource *addr_req; /* resources requested */
120 struct resource *data_req;
124 struct mutex addr_lock; /* phy and eeprom access lock */
126 struct delayed_work phy_poll;
127 struct net_device *ndev;
131 struct mii_if_info mii;
140 #define dm9000_dbg(db, lev, msg...) do { \
141 if ((lev) < debug) { \
142 dev_dbg(db->dev, msg); \
146 static inline struct board_info *to_dm9000_board(struct net_device *dev)
148 return netdev_priv(dev);
151 /* DM9000 network board routine ---------------------------- */
154 * Read a byte from I/O port
157 ior(struct board_info *db, int reg)
159 writeb(reg, db->io_addr);
160 return readb(db->io_data);
164 * Write a byte to I/O port
168 iow(struct board_info *db, int reg, int value)
170 writeb(reg, db->io_addr);
171 writeb(value, db->io_data);
175 dm9000_reset(struct board_info *db)
177 dev_dbg(db->dev, "resetting device\n");
179 /* Reset DM9000, see DM9000 Application Notes V1.22 Jun 11, 2004 page 29
180 * The essential point is that we have to do a double reset, and the
181 * instruction is to set LBK into MAC internal loopback mode.
183 iow(db, DM9000_NCR, NCR_RST | NCR_MAC_LBK);
184 udelay(100); /* Application note says at least 20 us */
185 if (ior(db, DM9000_NCR) & 1)
186 dev_err(db->dev, "dm9000 did not respond to first reset\n");
188 iow(db, DM9000_NCR, 0);
189 iow(db, DM9000_NCR, NCR_RST | NCR_MAC_LBK);
191 if (ior(db, DM9000_NCR) & 1)
192 dev_err(db->dev, "dm9000 did not respond to second reset\n");
195 /* routines for sending block to chip */
197 static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
199 iowrite8_rep(reg, data, count);
202 static void dm9000_outblk_16bit(void __iomem *reg, void *data, int count)
204 iowrite16_rep(reg, data, (count+1) >> 1);
207 static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count)
209 iowrite32_rep(reg, data, (count+3) >> 2);
212 /* input block from chip to memory */
214 static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count)
216 ioread8_rep(reg, data, count);
220 static void dm9000_inblk_16bit(void __iomem *reg, void *data, int count)
222 ioread16_rep(reg, data, (count+1) >> 1);
225 static void dm9000_inblk_32bit(void __iomem *reg, void *data, int count)
227 ioread32_rep(reg, data, (count+3) >> 2);
230 /* dump block from chip to null */
232 static void dm9000_dumpblk_8bit(void __iomem *reg, int count)
237 for (i = 0; i < count; i++)
241 static void dm9000_dumpblk_16bit(void __iomem *reg, int count)
246 count = (count + 1) >> 1;
248 for (i = 0; i < count; i++)
252 static void dm9000_dumpblk_32bit(void __iomem *reg, int count)
257 count = (count + 3) >> 2;
259 for (i = 0; i < count; i++)
264 * Sleep, either by using msleep() or if we are suspending, then
265 * use mdelay() to sleep.
267 static void dm9000_msleep(struct board_info *db, unsigned int ms)
269 if (db->in_suspend || db->in_timeout)
275 /* Read a word from phyxcer */
277 dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
279 struct board_info *db = netdev_priv(dev);
281 unsigned int reg_save;
284 mutex_lock(&db->addr_lock);
286 spin_lock_irqsave(&db->lock, flags);
288 /* Save previous register address */
289 reg_save = readb(db->io_addr);
291 /* Fill the phyxcer register into REG_0C */
292 iow(db, DM9000_EPAR, DM9000_PHY | reg);
294 /* Issue phyxcer read command */
295 iow(db, DM9000_EPCR, EPCR_ERPRR | EPCR_EPOS);
297 writeb(reg_save, db->io_addr);
298 spin_unlock_irqrestore(&db->lock, flags);
300 dm9000_msleep(db, 1); /* Wait read complete */
302 spin_lock_irqsave(&db->lock, flags);
303 reg_save = readb(db->io_addr);
305 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer read command */
307 /* The read data keeps on REG_0D & REG_0E */
308 ret = (ior(db, DM9000_EPDRH) << 8) | ior(db, DM9000_EPDRL);
310 /* restore the previous address */
311 writeb(reg_save, db->io_addr);
312 spin_unlock_irqrestore(&db->lock, flags);
314 mutex_unlock(&db->addr_lock);
316 dm9000_dbg(db, 5, "phy_read[%02x] -> %04x\n", reg, ret);
320 /* Write a word to phyxcer */
322 dm9000_phy_write(struct net_device *dev,
323 int phyaddr_unused, int reg, int value)
325 struct board_info *db = netdev_priv(dev);
327 unsigned long reg_save;
329 dm9000_dbg(db, 5, "phy_write[%02x] = %04x\n", reg, value);
331 mutex_lock(&db->addr_lock);
333 spin_lock_irqsave(&db->lock, flags);
335 /* Save previous register address */
336 reg_save = readb(db->io_addr);
338 /* Fill the phyxcer register into REG_0C */
339 iow(db, DM9000_EPAR, DM9000_PHY | reg);
341 /* Fill the written data into REG_0D & REG_0E */
342 iow(db, DM9000_EPDRL, value);
343 iow(db, DM9000_EPDRH, value >> 8);
345 /* Issue phyxcer write command */
346 iow(db, DM9000_EPCR, EPCR_EPOS | EPCR_ERPRW);
348 writeb(reg_save, db->io_addr);
349 spin_unlock_irqrestore(&db->lock, flags);
351 dm9000_msleep(db, 1); /* Wait write complete */
353 spin_lock_irqsave(&db->lock, flags);
354 reg_save = readb(db->io_addr);
356 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */
358 /* restore the previous address */
359 writeb(reg_save, db->io_addr);
361 spin_unlock_irqrestore(&db->lock, flags);
363 mutex_unlock(&db->addr_lock);
368 * select the specified set of io routines to use with the
372 static void dm9000_set_io(struct board_info *db, int byte_width)
374 /* use the size of the data resource to work out what IO
375 * routines we want to use
378 switch (byte_width) {
380 db->dumpblk = dm9000_dumpblk_8bit;
381 db->outblk = dm9000_outblk_8bit;
382 db->inblk = dm9000_inblk_8bit;
387 dev_dbg(db->dev, ": 3 byte IO, falling back to 16bit\n");
390 db->dumpblk = dm9000_dumpblk_16bit;
391 db->outblk = dm9000_outblk_16bit;
392 db->inblk = dm9000_inblk_16bit;
397 db->dumpblk = dm9000_dumpblk_32bit;
398 db->outblk = dm9000_outblk_32bit;
399 db->inblk = dm9000_inblk_32bit;
404 static void dm9000_schedule_poll(struct board_info *db)
406 if (db->type == TYPE_DM9000E)
407 schedule_delayed_work(&db->phy_poll, HZ * 2);
410 static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
412 struct board_info *dm = to_dm9000_board(dev);
414 if (!netif_running(dev))
417 return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL);
421 dm9000_read_locked(struct board_info *db, int reg)
426 spin_lock_irqsave(&db->lock, flags);
428 spin_unlock_irqrestore(&db->lock, flags);
433 static int dm9000_wait_eeprom(struct board_info *db)
436 int timeout = 8; /* wait max 8msec */
438 /* The DM9000 data sheets say we should be able to
439 * poll the ERRE bit in EPCR to wait for the EEPROM
440 * operation. From testing several chips, this bit
441 * does not seem to work.
443 * We attempt to use the bit, but fall back to the
444 * timeout (which is why we do not return an error
445 * on expiry) to say that the EEPROM operation has
450 status = dm9000_read_locked(db, DM9000_EPCR);
452 if ((status & EPCR_ERRE) == 0)
458 dev_dbg(db->dev, "timeout waiting EEPROM\n");
467 * Read a word data from EEPROM
470 dm9000_read_eeprom(struct board_info *db, int offset, u8 *to)
474 if (db->flags & DM9000_PLATF_NO_EEPROM) {
480 mutex_lock(&db->addr_lock);
482 spin_lock_irqsave(&db->lock, flags);
484 iow(db, DM9000_EPAR, offset);
485 iow(db, DM9000_EPCR, EPCR_ERPRR);
487 spin_unlock_irqrestore(&db->lock, flags);
489 dm9000_wait_eeprom(db);
491 /* delay for at-least 150uS */
494 spin_lock_irqsave(&db->lock, flags);
496 iow(db, DM9000_EPCR, 0x0);
498 to[0] = ior(db, DM9000_EPDRL);
499 to[1] = ior(db, DM9000_EPDRH);
501 spin_unlock_irqrestore(&db->lock, flags);
503 mutex_unlock(&db->addr_lock);
507 * Write a word data to SROM
510 dm9000_write_eeprom(struct board_info *db, int offset, u8 *data)
514 if (db->flags & DM9000_PLATF_NO_EEPROM)
517 mutex_lock(&db->addr_lock);
519 spin_lock_irqsave(&db->lock, flags);
520 iow(db, DM9000_EPAR, offset);
521 iow(db, DM9000_EPDRH, data[1]);
522 iow(db, DM9000_EPDRL, data[0]);
523 iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
524 spin_unlock_irqrestore(&db->lock, flags);
526 dm9000_wait_eeprom(db);
528 mdelay(1); /* wait at least 150uS to clear */
530 spin_lock_irqsave(&db->lock, flags);
531 iow(db, DM9000_EPCR, 0);
532 spin_unlock_irqrestore(&db->lock, flags);
534 mutex_unlock(&db->addr_lock);
539 static void dm9000_get_drvinfo(struct net_device *dev,
540 struct ethtool_drvinfo *info)
542 struct board_info *dm = to_dm9000_board(dev);
544 strlcpy(info->driver, CARDNAME, sizeof(info->driver));
545 strlcpy(info->bus_info, to_platform_device(dm->dev)->name,
546 sizeof(info->bus_info));
549 static u32 dm9000_get_msglevel(struct net_device *dev)
551 struct board_info *dm = to_dm9000_board(dev);
553 return dm->msg_enable;
556 static void dm9000_set_msglevel(struct net_device *dev, u32 value)
558 struct board_info *dm = to_dm9000_board(dev);
560 dm->msg_enable = value;
563 static int dm9000_get_link_ksettings(struct net_device *dev,
564 struct ethtool_link_ksettings *cmd)
566 struct board_info *dm = to_dm9000_board(dev);
568 mii_ethtool_get_link_ksettings(&dm->mii, cmd);
572 static int dm9000_set_link_ksettings(struct net_device *dev,
573 const struct ethtool_link_ksettings *cmd)
575 struct board_info *dm = to_dm9000_board(dev);
577 return mii_ethtool_set_link_ksettings(&dm->mii, cmd);
580 static int dm9000_nway_reset(struct net_device *dev)
582 struct board_info *dm = to_dm9000_board(dev);
583 return mii_nway_restart(&dm->mii);
586 static int dm9000_set_features(struct net_device *dev,
587 netdev_features_t features)
589 struct board_info *dm = to_dm9000_board(dev);
590 netdev_features_t changed = dev->features ^ features;
593 if (!(changed & NETIF_F_RXCSUM))
596 spin_lock_irqsave(&dm->lock, flags);
597 iow(dm, DM9000_RCSR, (features & NETIF_F_RXCSUM) ? RCSR_CSUM : 0);
598 spin_unlock_irqrestore(&dm->lock, flags);
603 static u32 dm9000_get_link(struct net_device *dev)
605 struct board_info *dm = to_dm9000_board(dev);
608 if (dm->flags & DM9000_PLATF_EXT_PHY)
609 ret = mii_link_ok(&dm->mii);
611 ret = dm9000_read_locked(dm, DM9000_NSR) & NSR_LINKST ? 1 : 0;
616 #define DM_EEPROM_MAGIC (0x444D394B)
618 static int dm9000_get_eeprom_len(struct net_device *dev)
623 static int dm9000_get_eeprom(struct net_device *dev,
624 struct ethtool_eeprom *ee, u8 *data)
626 struct board_info *dm = to_dm9000_board(dev);
627 int offset = ee->offset;
631 /* EEPROM access is aligned to two bytes */
633 if ((len & 1) != 0 || (offset & 1) != 0)
636 if (dm->flags & DM9000_PLATF_NO_EEPROM)
639 ee->magic = DM_EEPROM_MAGIC;
641 for (i = 0; i < len; i += 2)
642 dm9000_read_eeprom(dm, (offset + i) / 2, data + i);
647 static int dm9000_set_eeprom(struct net_device *dev,
648 struct ethtool_eeprom *ee, u8 *data)
650 struct board_info *dm = to_dm9000_board(dev);
651 int offset = ee->offset;
655 /* EEPROM access is aligned to two bytes */
657 if (dm->flags & DM9000_PLATF_NO_EEPROM)
660 if (ee->magic != DM_EEPROM_MAGIC)
664 if (len & 1 || offset & 1) {
665 int which = offset & 1;
668 dm9000_read_eeprom(dm, offset / 2, tmp);
670 dm9000_write_eeprom(dm, offset / 2, tmp);
674 dm9000_write_eeprom(dm, offset / 2, data);
686 static void dm9000_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
688 struct board_info *dm = to_dm9000_board(dev);
690 memset(w, 0, sizeof(struct ethtool_wolinfo));
692 /* note, we could probably support wake-phy too */
693 w->supported = dm->wake_supported ? WAKE_MAGIC : 0;
694 w->wolopts = dm->wake_state;
697 static int dm9000_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
699 struct board_info *dm = to_dm9000_board(dev);
701 u32 opts = w->wolopts;
704 if (!dm->wake_supported)
707 if (opts & ~WAKE_MAGIC)
710 if (opts & WAKE_MAGIC)
713 mutex_lock(&dm->addr_lock);
715 spin_lock_irqsave(&dm->lock, flags);
716 iow(dm, DM9000_WCR, wcr);
717 spin_unlock_irqrestore(&dm->lock, flags);
719 mutex_unlock(&dm->addr_lock);
721 if (dm->wake_state != opts) {
722 /* change in wol state, update IRQ state */
725 irq_set_irq_wake(dm->irq_wake, 1);
726 else if (dm->wake_state && !opts)
727 irq_set_irq_wake(dm->irq_wake, 0);
730 dm->wake_state = opts;
734 static const struct ethtool_ops dm9000_ethtool_ops = {
735 .get_drvinfo = dm9000_get_drvinfo,
736 .get_msglevel = dm9000_get_msglevel,
737 .set_msglevel = dm9000_set_msglevel,
738 .nway_reset = dm9000_nway_reset,
739 .get_link = dm9000_get_link,
740 .get_wol = dm9000_get_wol,
741 .set_wol = dm9000_set_wol,
742 .get_eeprom_len = dm9000_get_eeprom_len,
743 .get_eeprom = dm9000_get_eeprom,
744 .set_eeprom = dm9000_set_eeprom,
745 .get_link_ksettings = dm9000_get_link_ksettings,
746 .set_link_ksettings = dm9000_set_link_ksettings,
749 static void dm9000_show_carrier(struct board_info *db,
750 unsigned carrier, unsigned nsr)
753 struct net_device *ndev = db->ndev;
754 struct mii_if_info *mii = &db->mii;
755 unsigned ncr = dm9000_read_locked(db, DM9000_NCR);
758 lpa = mii->mdio_read(mii->dev, mii->phy_id, MII_LPA);
760 "%s: link up, %dMbps, %s-duplex, lpa 0x%04X\n",
761 ndev->name, (nsr & NSR_SPEED) ? 10 : 100,
762 (ncr & NCR_FDX) ? "full" : "half", lpa);
764 dev_info(db->dev, "%s: link down\n", ndev->name);
769 dm9000_poll_work(struct work_struct *w)
771 struct delayed_work *dw = to_delayed_work(w);
772 struct board_info *db = container_of(dw, struct board_info, phy_poll);
773 struct net_device *ndev = db->ndev;
775 if (db->flags & DM9000_PLATF_SIMPLE_PHY &&
776 !(db->flags & DM9000_PLATF_EXT_PHY)) {
777 unsigned nsr = dm9000_read_locked(db, DM9000_NSR);
778 unsigned old_carrier = netif_carrier_ok(ndev) ? 1 : 0;
779 unsigned new_carrier;
781 new_carrier = (nsr & NSR_LINKST) ? 1 : 0;
783 if (old_carrier != new_carrier) {
784 if (netif_msg_link(db))
785 dm9000_show_carrier(db, new_carrier, nsr);
788 netif_carrier_off(ndev);
790 netif_carrier_on(ndev);
793 mii_check_media(&db->mii, netif_msg_link(db), 0);
795 if (netif_running(ndev))
796 dm9000_schedule_poll(db);
799 /* dm9000_release_board
801 * release a board, and any mapped resources
805 dm9000_release_board(struct platform_device *pdev, struct board_info *db)
807 /* unmap our resources */
809 iounmap(db->io_addr);
810 iounmap(db->io_data);
812 /* release the resources */
815 release_resource(db->data_req);
819 release_resource(db->addr_req);
823 static unsigned char dm9000_type_to_char(enum dm9000_type type)
826 case TYPE_DM9000E: return 'e';
827 case TYPE_DM9000A: return 'a';
828 case TYPE_DM9000B: return 'b';
835 * Set DM9000 multicast address
838 dm9000_hash_table_unlocked(struct net_device *dev)
840 struct board_info *db = netdev_priv(dev);
841 struct netdev_hw_addr *ha;
844 u16 hash_table[4] = { 0, 0, 0, 0x8000 }; /* broadcast address */
845 u8 rcr = RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN;
847 dm9000_dbg(db, 1, "entering %s\n", __func__);
849 for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
850 iow(db, oft, dev->dev_addr[i]);
852 if (dev->flags & IFF_PROMISC)
855 if (dev->flags & IFF_ALLMULTI)
858 /* the multicast address in Hash Table : 64 bits */
859 netdev_for_each_mc_addr(ha, dev) {
860 hash_val = ether_crc_le(6, ha->addr) & 0x3f;
861 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
864 /* Write the hash table to MAC MD table */
865 for (i = 0, oft = DM9000_MAR; i < 4; i++) {
866 iow(db, oft++, hash_table[i]);
867 iow(db, oft++, hash_table[i] >> 8);
870 iow(db, DM9000_RCR, rcr);
874 dm9000_hash_table(struct net_device *dev)
876 struct board_info *db = netdev_priv(dev);
879 spin_lock_irqsave(&db->lock, flags);
880 dm9000_hash_table_unlocked(dev);
881 spin_unlock_irqrestore(&db->lock, flags);
885 dm9000_mask_interrupts(struct board_info *db)
887 iow(db, DM9000_IMR, IMR_PAR);
891 dm9000_unmask_interrupts(struct board_info *db)
893 iow(db, DM9000_IMR, db->imr_all);
897 * Initialize dm9000 board
900 dm9000_init_dm9000(struct net_device *dev)
902 struct board_info *db = netdev_priv(dev);
906 dm9000_dbg(db, 1, "entering %s\n", __func__);
909 dm9000_mask_interrupts(db);
912 db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */
915 if (dev->hw_features & NETIF_F_RXCSUM)
917 (dev->features & NETIF_F_RXCSUM) ? RCSR_CSUM : 0);
919 iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */
920 iow(db, DM9000_GPR, 0);
922 /* If we are dealing with DM9000B, some extra steps are required: a
923 * manual phy reset, and setting init params.
925 if (db->type == TYPE_DM9000B) {
926 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET);
927 dm9000_phy_write(dev, 0, MII_DM_DSPCR, DSPCR_INIT_PARAM);
930 ncr = (db->flags & DM9000_PLATF_EXT_PHY) ? NCR_EXT_PHY : 0;
932 /* if wol is needed, then always set NCR_WAKEEN otherwise we end
933 * up dumping the wake events if we disable this. There is already
934 * a wake-mask in DM9000_WCR */
935 if (db->wake_supported)
938 iow(db, DM9000_NCR, ncr);
940 /* Program operating register */
941 iow(db, DM9000_TCR, 0); /* TX Polling clear */
942 iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
943 iow(db, DM9000_FCR, 0xff); /* Flow Control */
944 iow(db, DM9000_SMCR, 0); /* Special Mode */
945 /* clear TX status */
946 iow(db, DM9000_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END);
947 iow(db, DM9000_ISR, ISR_CLR_STATUS); /* Clear interrupt status */
949 /* Set address filter table */
950 dm9000_hash_table_unlocked(dev);
952 imr = IMR_PAR | IMR_PTM | IMR_PRM;
953 if (db->type != TYPE_DM9000E)
958 /* Init Driver variable */
960 db->queue_pkt_len = 0;
961 netif_trans_update(dev);
964 /* Our watchdog timed out. Called by the networking layer */
965 static void dm9000_timeout(struct net_device *dev, unsigned int txqueue)
967 struct board_info *db = netdev_priv(dev);
971 /* Save previous register address */
972 spin_lock_irqsave(&db->lock, flags);
974 reg_save = readb(db->io_addr);
976 netif_stop_queue(dev);
977 dm9000_init_dm9000(dev);
978 dm9000_unmask_interrupts(db);
979 /* We can accept TX packets again */
980 netif_trans_update(dev); /* prevent tx timeout */
981 netif_wake_queue(dev);
983 /* Restore previous register address */
984 writeb(reg_save, db->io_addr);
986 spin_unlock_irqrestore(&db->lock, flags);
989 static void dm9000_send_packet(struct net_device *dev,
993 struct board_info *dm = to_dm9000_board(dev);
995 /* The DM9000 is not smart enough to leave fragmented packets alone. */
996 if (dm->ip_summed != ip_summed) {
997 if (ip_summed == CHECKSUM_NONE)
998 iow(dm, DM9000_TCCR, 0);
1000 iow(dm, DM9000_TCCR, TCCR_IP | TCCR_UDP | TCCR_TCP);
1001 dm->ip_summed = ip_summed;
1004 /* Set TX length to DM9000 */
1005 iow(dm, DM9000_TXPLL, pkt_len);
1006 iow(dm, DM9000_TXPLH, pkt_len >> 8);
1008 /* Issue TX polling command */
1009 iow(dm, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
1013 * Hardware start transmission.
1014 * Send a packet to media from the upper layer.
1017 dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
1019 unsigned long flags;
1020 struct board_info *db = netdev_priv(dev);
1022 dm9000_dbg(db, 3, "%s:\n", __func__);
1024 if (db->tx_pkt_cnt > 1)
1025 return NETDEV_TX_BUSY;
1027 spin_lock_irqsave(&db->lock, flags);
1029 /* Move data to DM9000 TX RAM */
1030 writeb(DM9000_MWCMD, db->io_addr);
1032 (db->outblk)(db->io_data, skb->data, skb->len);
1033 dev->stats.tx_bytes += skb->len;
1036 /* TX control: First packet immediately send, second packet queue */
1037 if (db->tx_pkt_cnt == 1) {
1038 dm9000_send_packet(dev, skb->ip_summed, skb->len);
1041 db->queue_pkt_len = skb->len;
1042 db->queue_ip_summed = skb->ip_summed;
1043 netif_stop_queue(dev);
1046 spin_unlock_irqrestore(&db->lock, flags);
1049 dev_consume_skb_any(skb);
1051 return NETDEV_TX_OK;
1055 * DM9000 interrupt handler
1056 * receive the packet to upper layer, free the transmitted packet
1059 static void dm9000_tx_done(struct net_device *dev, struct board_info *db)
1061 int tx_status = ior(db, DM9000_NSR); /* Got TX status */
1063 if (tx_status & (NSR_TX2END | NSR_TX1END)) {
1064 /* One packet sent complete */
1066 dev->stats.tx_packets++;
1068 if (netif_msg_tx_done(db))
1069 dev_dbg(db->dev, "tx done, NSR %02x\n", tx_status);
1071 /* Queue packet check & send */
1072 if (db->tx_pkt_cnt > 0)
1073 dm9000_send_packet(dev, db->queue_ip_summed,
1075 netif_wake_queue(dev);
1079 struct dm9000_rxhdr {
1086 * Received a packet and pass to upper layer
1089 dm9000_rx(struct net_device *dev)
1091 struct board_info *db = netdev_priv(dev);
1092 struct dm9000_rxhdr rxhdr;
1093 struct sk_buff *skb;
1098 /* Check packet ready or not */
1100 ior(db, DM9000_MRCMDX); /* Dummy read */
1102 /* Get most updated data */
1103 rxbyte = readb(db->io_data);
1105 /* Status check: this byte must be 0 or 1 */
1106 if (rxbyte & DM9000_PKT_ERR) {
1107 dev_warn(db->dev, "status check fail: %d\n", rxbyte);
1108 iow(db, DM9000_RCR, 0x00); /* Stop Device */
1112 if (!(rxbyte & DM9000_PKT_RDY))
1115 /* A packet ready now & Get status/length */
1117 writeb(DM9000_MRCMD, db->io_addr);
1119 (db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
1121 RxLen = le16_to_cpu(rxhdr.RxLen);
1123 if (netif_msg_rx_status(db))
1124 dev_dbg(db->dev, "RX: status %02x, length %04x\n",
1125 rxhdr.RxStatus, RxLen);
1127 /* Packet Status check */
1130 if (netif_msg_rx_err(db))
1131 dev_dbg(db->dev, "RX: Bad Packet (runt)\n");
1134 if (RxLen > DM9000_PKT_MAX) {
1135 dev_dbg(db->dev, "RST: RX Len:%x\n", RxLen);
1138 /* rxhdr.RxStatus is identical to RSR register. */
1139 if (rxhdr.RxStatus & (RSR_FOE | RSR_CE | RSR_AE |
1140 RSR_PLE | RSR_RWTO |
1141 RSR_LCS | RSR_RF)) {
1143 if (rxhdr.RxStatus & RSR_FOE) {
1144 if (netif_msg_rx_err(db))
1145 dev_dbg(db->dev, "fifo error\n");
1146 dev->stats.rx_fifo_errors++;
1148 if (rxhdr.RxStatus & RSR_CE) {
1149 if (netif_msg_rx_err(db))
1150 dev_dbg(db->dev, "crc error\n");
1151 dev->stats.rx_crc_errors++;
1153 if (rxhdr.RxStatus & RSR_RF) {
1154 if (netif_msg_rx_err(db))
1155 dev_dbg(db->dev, "length error\n");
1156 dev->stats.rx_length_errors++;
1160 /* Move data from DM9000 */
1162 ((skb = netdev_alloc_skb(dev, RxLen + 4)) != NULL)) {
1163 skb_reserve(skb, 2);
1164 rdptr = skb_put(skb, RxLen - 4);
1166 /* Read received packet from RX SRAM */
1168 (db->inblk)(db->io_data, rdptr, RxLen);
1169 dev->stats.rx_bytes += RxLen;
1171 /* Pass to upper layer */
1172 skb->protocol = eth_type_trans(skb, dev);
1173 if (dev->features & NETIF_F_RXCSUM) {
1174 if ((((rxbyte & 0x1c) << 3) & rxbyte) == 0)
1175 skb->ip_summed = CHECKSUM_UNNECESSARY;
1177 skb_checksum_none_assert(skb);
1180 dev->stats.rx_packets++;
1183 /* need to dump the packet's data */
1185 (db->dumpblk)(db->io_data, RxLen);
1187 } while (rxbyte & DM9000_PKT_RDY);
1190 static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
1192 struct net_device *dev = dev_id;
1193 struct board_info *db = netdev_priv(dev);
1195 unsigned long flags;
1198 dm9000_dbg(db, 3, "entering %s\n", __func__);
1200 /* A real interrupt coming */
1202 /* holders of db->lock must always block IRQs */
1203 spin_lock_irqsave(&db->lock, flags);
1205 /* Save previous register address */
1206 reg_save = readb(db->io_addr);
1208 dm9000_mask_interrupts(db);
1209 /* Got DM9000 interrupt status */
1210 int_status = ior(db, DM9000_ISR); /* Got ISR */
1211 iow(db, DM9000_ISR, int_status); /* Clear ISR status */
1213 if (netif_msg_intr(db))
1214 dev_dbg(db->dev, "interrupt status %02x\n", int_status);
1216 /* Received the coming packet */
1217 if (int_status & ISR_PRS)
1220 /* Transmit Interrupt check */
1221 if (int_status & ISR_PTS)
1222 dm9000_tx_done(dev, db);
1224 if (db->type != TYPE_DM9000E) {
1225 if (int_status & ISR_LNKCHNG) {
1226 /* fire a link-change request */
1227 schedule_delayed_work(&db->phy_poll, 1);
1231 dm9000_unmask_interrupts(db);
1232 /* Restore previous register address */
1233 writeb(reg_save, db->io_addr);
1235 spin_unlock_irqrestore(&db->lock, flags);
1240 static irqreturn_t dm9000_wol_interrupt(int irq, void *dev_id)
1242 struct net_device *dev = dev_id;
1243 struct board_info *db = netdev_priv(dev);
1244 unsigned long flags;
1247 spin_lock_irqsave(&db->lock, flags);
1249 nsr = ior(db, DM9000_NSR);
1250 wcr = ior(db, DM9000_WCR);
1252 dev_dbg(db->dev, "%s: NSR=0x%02x, WCR=0x%02x\n", __func__, nsr, wcr);
1254 if (nsr & NSR_WAKEST) {
1255 /* clear, so we can avoid */
1256 iow(db, DM9000_NSR, NSR_WAKEST);
1258 if (wcr & WCR_LINKST)
1259 dev_info(db->dev, "wake by link status change\n");
1260 if (wcr & WCR_SAMPLEST)
1261 dev_info(db->dev, "wake by sample packet\n");
1262 if (wcr & WCR_MAGICST)
1263 dev_info(db->dev, "wake by magic packet\n");
1264 if (!(wcr & (WCR_LINKST | WCR_SAMPLEST | WCR_MAGICST)))
1265 dev_err(db->dev, "wake signalled with no reason? "
1266 "NSR=0x%02x, WSR=0x%02x\n", nsr, wcr);
1269 spin_unlock_irqrestore(&db->lock, flags);
1271 return (nsr & NSR_WAKEST) ? IRQ_HANDLED : IRQ_NONE;
1274 #ifdef CONFIG_NET_POLL_CONTROLLER
1278 static void dm9000_poll_controller(struct net_device *dev)
1280 disable_irq(dev->irq);
1281 dm9000_interrupt(dev->irq, dev);
1282 enable_irq(dev->irq);
1287 * Open the interface.
1288 * The interface is opened whenever "ifconfig" actives it.
1291 dm9000_open(struct net_device *dev)
1293 struct board_info *db = netdev_priv(dev);
1294 unsigned int irq_flags = irq_get_trigger_type(dev->irq);
1296 if (netif_msg_ifup(db))
1297 dev_dbg(db->dev, "enabling %s\n", dev->name);
1299 /* If there is no IRQ type specified, tell the user that this is a
1302 if (irq_flags == IRQF_TRIGGER_NONE)
1303 dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
1305 irq_flags |= IRQF_SHARED;
1307 /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
1308 iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
1309 mdelay(1); /* delay needs by DM9000B */
1311 /* Initialize DM9000 board */
1312 dm9000_init_dm9000(dev);
1314 if (request_irq(dev->irq, dm9000_interrupt, irq_flags, dev->name, dev))
1316 /* Now that we have an interrupt handler hooked up we can unmask
1319 dm9000_unmask_interrupts(db);
1321 /* Init driver variable */
1324 mii_check_media(&db->mii, netif_msg_link(db), 1);
1325 netif_start_queue(dev);
1327 /* Poll initial link status */
1328 schedule_delayed_work(&db->phy_poll, 1);
1334 dm9000_shutdown(struct net_device *dev)
1336 struct board_info *db = netdev_priv(dev);
1339 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
1340 iow(db, DM9000_GPR, 0x01); /* Power-Down PHY */
1341 dm9000_mask_interrupts(db);
1342 iow(db, DM9000_RCR, 0x00); /* Disable RX */
1346 * Stop the interface.
1347 * The interface is stopped when it is brought.
1350 dm9000_stop(struct net_device *ndev)
1352 struct board_info *db = netdev_priv(ndev);
1354 if (netif_msg_ifdown(db))
1355 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
1357 cancel_delayed_work_sync(&db->phy_poll);
1359 netif_stop_queue(ndev);
1360 netif_carrier_off(ndev);
1362 /* free interrupt */
1363 free_irq(ndev->irq, ndev);
1365 dm9000_shutdown(ndev);
1370 static const struct net_device_ops dm9000_netdev_ops = {
1371 .ndo_open = dm9000_open,
1372 .ndo_stop = dm9000_stop,
1373 .ndo_start_xmit = dm9000_start_xmit,
1374 .ndo_tx_timeout = dm9000_timeout,
1375 .ndo_set_rx_mode = dm9000_hash_table,
1376 .ndo_do_ioctl = dm9000_ioctl,
1377 .ndo_set_features = dm9000_set_features,
1378 .ndo_validate_addr = eth_validate_addr,
1379 .ndo_set_mac_address = eth_mac_addr,
1380 #ifdef CONFIG_NET_POLL_CONTROLLER
1381 .ndo_poll_controller = dm9000_poll_controller,
1385 static struct dm9000_plat_data *dm9000_parse_dt(struct device *dev)
1387 struct dm9000_plat_data *pdata;
1388 struct device_node *np = dev->of_node;
1389 const void *mac_addr;
1391 if (!IS_ENABLED(CONFIG_OF) || !np)
1392 return ERR_PTR(-ENXIO);
1394 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
1396 return ERR_PTR(-ENOMEM);
1398 if (of_find_property(np, "davicom,ext-phy", NULL))
1399 pdata->flags |= DM9000_PLATF_EXT_PHY;
1400 if (of_find_property(np, "davicom,no-eeprom", NULL))
1401 pdata->flags |= DM9000_PLATF_NO_EEPROM;
1403 mac_addr = of_get_mac_address(np);
1404 if (!IS_ERR(mac_addr))
1405 ether_addr_copy(pdata->dev_addr, mac_addr);
1406 else if (PTR_ERR(mac_addr) == -EPROBE_DEFER)
1407 return ERR_CAST(mac_addr);
1413 * Search DM9000 board, allocate space and register it
1416 dm9000_probe(struct platform_device *pdev)
1418 struct dm9000_plat_data *pdata = dev_get_platdata(&pdev->dev);
1419 struct board_info *db; /* Point a board information structure */
1420 struct net_device *ndev;
1421 struct device *dev = &pdev->dev;
1422 const unsigned char *mac_src;
1428 enum of_gpio_flags flags;
1429 struct regulator *power;
1430 bool inv_mac_addr = false;
1432 power = devm_regulator_get(dev, "vcc");
1433 if (IS_ERR(power)) {
1434 if (PTR_ERR(power) == -EPROBE_DEFER)
1435 return -EPROBE_DEFER;
1436 dev_dbg(dev, "no regulator provided\n");
1438 ret = regulator_enable(power);
1441 "Failed to enable power regulator: %d\n", ret);
1444 dev_dbg(dev, "regulator enabled\n");
1447 reset_gpios = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0,
1449 if (gpio_is_valid(reset_gpios)) {
1450 ret = devm_gpio_request_one(dev, reset_gpios, flags,
1453 dev_err(dev, "failed to request reset gpio %d: %d\n",
1458 /* According to manual PWRST# Low Period Min 1ms */
1460 gpio_set_value(reset_gpios, 1);
1461 /* Needs 3ms to read eeprom when PWRST is deasserted */
1466 pdata = dm9000_parse_dt(&pdev->dev);
1468 return PTR_ERR(pdata);
1471 /* Init network device */
1472 ndev = alloc_etherdev(sizeof(struct board_info));
1476 SET_NETDEV_DEV(ndev, &pdev->dev);
1478 dev_dbg(&pdev->dev, "dm9000_probe()\n");
1480 /* setup board info structure */
1481 db = netdev_priv(ndev);
1483 db->dev = &pdev->dev;
1486 spin_lock_init(&db->lock);
1487 mutex_init(&db->addr_lock);
1489 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
1491 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1492 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1494 if (!db->addr_res || !db->data_res) {
1495 dev_err(db->dev, "insufficient resources addr=%p data=%p\n",
1496 db->addr_res, db->data_res);
1501 ndev->irq = platform_get_irq(pdev, 0);
1502 if (ndev->irq < 0) {
1507 db->irq_wake = platform_get_irq(pdev, 1);
1508 if (db->irq_wake >= 0) {
1509 dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake);
1511 ret = request_irq(db->irq_wake, dm9000_wol_interrupt,
1512 IRQF_SHARED, dev_name(db->dev), ndev);
1514 dev_err(db->dev, "cannot get wakeup irq (%d)\n", ret);
1517 /* test to see if irq is really wakeup capable */
1518 ret = irq_set_irq_wake(db->irq_wake, 1);
1520 dev_err(db->dev, "irq %d cannot set wakeup (%d)\n",
1524 irq_set_irq_wake(db->irq_wake, 0);
1525 db->wake_supported = 1;
1530 iosize = resource_size(db->addr_res);
1531 db->addr_req = request_mem_region(db->addr_res->start, iosize,
1534 if (db->addr_req == NULL) {
1535 dev_err(db->dev, "cannot claim address reg area\n");
1540 db->io_addr = ioremap(db->addr_res->start, iosize);
1542 if (db->io_addr == NULL) {
1543 dev_err(db->dev, "failed to ioremap address reg\n");
1548 iosize = resource_size(db->data_res);
1549 db->data_req = request_mem_region(db->data_res->start, iosize,
1552 if (db->data_req == NULL) {
1553 dev_err(db->dev, "cannot claim data reg area\n");
1558 db->io_data = ioremap(db->data_res->start, iosize);
1560 if (db->io_data == NULL) {
1561 dev_err(db->dev, "failed to ioremap data reg\n");
1566 /* fill in parameters for net-dev structure */
1567 ndev->base_addr = (unsigned long)db->io_addr;
1569 /* ensure at least we have a default set of IO routines */
1570 dm9000_set_io(db, iosize);
1572 /* check to see if anything is being over-ridden */
1573 if (pdata != NULL) {
1574 /* check to see if the driver wants to over-ride the
1575 * default IO width */
1577 if (pdata->flags & DM9000_PLATF_8BITONLY)
1578 dm9000_set_io(db, 1);
1580 if (pdata->flags & DM9000_PLATF_16BITONLY)
1581 dm9000_set_io(db, 2);
1583 if (pdata->flags & DM9000_PLATF_32BITONLY)
1584 dm9000_set_io(db, 4);
1586 /* check to see if there are any IO routine
1589 if (pdata->inblk != NULL)
1590 db->inblk = pdata->inblk;
1592 if (pdata->outblk != NULL)
1593 db->outblk = pdata->outblk;
1595 if (pdata->dumpblk != NULL)
1596 db->dumpblk = pdata->dumpblk;
1598 db->flags = pdata->flags;
1601 #ifdef CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL
1602 db->flags |= DM9000_PLATF_SIMPLE_PHY;
1607 /* try multiple times, DM9000 sometimes gets the read wrong */
1608 for (i = 0; i < 8; i++) {
1609 id_val = ior(db, DM9000_VIDL);
1610 id_val |= (u32)ior(db, DM9000_VIDH) << 8;
1611 id_val |= (u32)ior(db, DM9000_PIDL) << 16;
1612 id_val |= (u32)ior(db, DM9000_PIDH) << 24;
1614 if (id_val == DM9000_ID)
1616 dev_err(db->dev, "read wrong id 0x%08x\n", id_val);
1619 if (id_val != DM9000_ID) {
1620 dev_err(db->dev, "wrong id: 0x%08x\n", id_val);
1625 /* Identify what type of DM9000 we are working on */
1627 id_val = ior(db, DM9000_CHIPR);
1628 dev_dbg(db->dev, "dm9000 revision 0x%02x\n", id_val);
1632 db->type = TYPE_DM9000A;
1635 db->type = TYPE_DM9000B;
1638 dev_dbg(db->dev, "ID %02x => defaulting to DM9000E\n", id_val);
1639 db->type = TYPE_DM9000E;
1642 /* dm9000a/b are capable of hardware checksum offload */
1643 if (db->type == TYPE_DM9000A || db->type == TYPE_DM9000B) {
1644 ndev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
1645 ndev->features |= ndev->hw_features;
1648 /* from this point we assume that we have found a DM9000 */
1650 ndev->netdev_ops = &dm9000_netdev_ops;
1651 ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
1652 ndev->ethtool_ops = &dm9000_ethtool_ops;
1654 db->msg_enable = NETIF_MSG_LINK;
1655 db->mii.phy_id_mask = 0x1f;
1656 db->mii.reg_num_mask = 0x1f;
1657 db->mii.force_media = 0;
1658 db->mii.full_duplex = 0;
1660 db->mii.mdio_read = dm9000_phy_read;
1661 db->mii.mdio_write = dm9000_phy_write;
1665 /* try reading the node address from the attached EEPROM */
1666 for (i = 0; i < 6; i += 2)
1667 dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
1669 if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
1670 mac_src = "platform data";
1671 memcpy(ndev->dev_addr, pdata->dev_addr, ETH_ALEN);
1674 if (!is_valid_ether_addr(ndev->dev_addr)) {
1675 /* try reading from mac */
1678 for (i = 0; i < 6; i++)
1679 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
1682 if (!is_valid_ether_addr(ndev->dev_addr)) {
1683 inv_mac_addr = true;
1684 eth_hw_addr_random(ndev);
1689 platform_set_drvdata(pdev, ndev);
1690 ret = register_netdev(ndev);
1694 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please set using ip\n",
1696 printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %pM (%s)\n",
1697 ndev->name, dm9000_type_to_char(db->type),
1698 db->io_addr, db->io_data, ndev->irq,
1699 ndev->dev_addr, mac_src);
1704 dev_err(db->dev, "not found (%d).\n", ret);
1706 dm9000_release_board(pdev, db);
1713 dm9000_drv_suspend(struct device *dev)
1715 struct net_device *ndev = dev_get_drvdata(dev);
1716 struct board_info *db;
1719 db = netdev_priv(ndev);
1722 if (!netif_running(ndev))
1725 netif_device_detach(ndev);
1727 /* only shutdown if not using WoL */
1728 if (!db->wake_state)
1729 dm9000_shutdown(ndev);
1735 dm9000_drv_resume(struct device *dev)
1737 struct net_device *ndev = dev_get_drvdata(dev);
1738 struct board_info *db = netdev_priv(ndev);
1741 if (netif_running(ndev)) {
1742 /* reset if we were not in wake mode to ensure if
1743 * the device was powered off it is in a known state */
1744 if (!db->wake_state) {
1745 dm9000_init_dm9000(ndev);
1746 dm9000_unmask_interrupts(db);
1749 netif_device_attach(ndev);
1757 static const struct dev_pm_ops dm9000_drv_pm_ops = {
1758 .suspend = dm9000_drv_suspend,
1759 .resume = dm9000_drv_resume,
1763 dm9000_drv_remove(struct platform_device *pdev)
1765 struct net_device *ndev = platform_get_drvdata(pdev);
1767 unregister_netdev(ndev);
1768 dm9000_release_board(pdev, netdev_priv(ndev));
1769 free_netdev(ndev); /* free device structure */
1771 dev_dbg(&pdev->dev, "released and freed device\n");
1776 static const struct of_device_id dm9000_of_matches[] = {
1777 { .compatible = "davicom,dm9000", },
1780 MODULE_DEVICE_TABLE(of, dm9000_of_matches);
1783 static struct platform_driver dm9000_driver = {
1786 .pm = &dm9000_drv_pm_ops,
1787 .of_match_table = of_match_ptr(dm9000_of_matches),
1789 .probe = dm9000_probe,
1790 .remove = dm9000_drv_remove,
1793 module_platform_driver(dm9000_driver);
1795 MODULE_AUTHOR("Sascha Hauer, Ben Dooks");
1796 MODULE_DESCRIPTION("Davicom DM9000 network driver");
1797 MODULE_LICENSE("GPL");
1798 MODULE_ALIAS("platform:dm9000");