1 From 3c7089199784e3d53054869108cfa5666b42e7ea Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 3 Aug 2012 10:28:51 +0200
4 Subject: [PATCH 22/25] owrt dm9000 polling
7 drivers/net/ethernet/davicom/dm9000.c | 50 +++++++++++++++++++++++++++-----
8 1 files changed, 42 insertions(+), 8 deletions(-)
10 diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
11 index f801754..258a0c3 100644
12 --- a/drivers/net/ethernet/davicom/dm9000.c
13 +++ b/drivers/net/ethernet/davicom/dm9000.c
15 * Sascha Hauer <s.hauer@pengutronix.de>
19 #include <linux/module.h>
20 #include <linux/ioport.h>
21 #include <linux/netdevice.h>
22 @@ -132,6 +133,8 @@ typedef struct board_info {
23 struct delayed_work phy_poll;
24 struct net_device *ndev;
26 + struct delayed_work irq_poll; /* for use in irq polling mode */
30 struct mii_if_info mii;
31 @@ -845,6 +848,8 @@ static void dm9000_timeout(struct net_device *dev)
32 netif_stop_queue(dev);
34 dm9000_init_dm9000(dev);
36 + dm9000_init_dm9000(dev);
37 /* We can accept TX packets again */
38 dev->trans_start = jiffies; /* prevent tx timeout */
39 netif_wake_queue(dev);
40 @@ -916,6 +921,12 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
44 + /* directly poll afterwards */
45 + if (dev->irq == -1) {
46 + cancel_delayed_work(&db->irq_poll);
47 + schedule_delayed_work(&db->irq_poll, 1);
53 @@ -1157,6 +1168,18 @@ static void dm9000_poll_controller(struct net_device *dev)
57 +static void dm9000_poll_irq(struct work_struct *w)
59 + struct delayed_work *dw = to_delayed_work(w);
60 + board_info_t *db = container_of(dw, board_info_t, irq_poll);
61 + struct net_device *ndev = db->ndev;
63 + dm9000_interrupt(0, ndev);
65 + if (netif_running(ndev))
66 + schedule_delayed_work(&db->irq_poll, HZ /100);
71 * The interface is opened whenever "ifconfig" actives it.
72 @@ -1170,14 +1193,15 @@ dm9000_open(struct net_device *dev)
73 if (netif_msg_ifup(db))
74 dev_dbg(db->dev, "enabling %s\n", dev->name);
76 - /* If there is no IRQ type specified, default to something that
77 - * may work, and tell the user that this is a problem */
78 + if (dev->irq != -1) {
79 + /* If there is no IRQ type specified, default to something that
80 + * may work, and tell the user that this is a problem */
82 - if (irqflags == IRQF_TRIGGER_NONE)
83 - dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
85 - irqflags |= IRQF_SHARED;
86 + if (irqflags == IRQF_TRIGGER_NONE)
87 + dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
89 + irqflags |= IRQF_SHARED;
91 /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
92 iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
93 mdelay(1); /* delay needs by DM9000B */
94 @@ -1186,8 +1210,14 @@ dm9000_open(struct net_device *dev)
96 dm9000_init_dm9000(dev);
98 - if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
100 + /* testing: init a second time */
102 + dm9000_init_dm9000(dev);
104 + if (dev->irq != -1) {
105 + if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
109 /* Init driver variable */
111 @@ -1195,6 +1225,9 @@ dm9000_open(struct net_device *dev)
112 mii_check_media(&db->mii, netif_msg_link(db), 1);
113 netif_start_queue(dev);
115 + if (dev->irq == -1)
116 + schedule_delayed_work(&db->irq_poll, HZ / 100);
118 dm9000_schedule_poll(db);
121 @@ -1392,6 +1425,7 @@ dm9000_probe(struct platform_device *pdev)
122 mutex_init(&db->addr_lock);
124 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
125 + INIT_DELAYED_WORK(&db->irq_poll, dm9000_poll_irq);
127 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
128 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);