Root/target/linux/lantiq/patches-3.3/0022-owrt-dm9000-polling.patch

1From 3c7089199784e3d53054869108cfa5666b42e7ea Mon Sep 17 00:00:00 2001
2From: John Crispin <blogic@openwrt.org>
3Date: Fri, 3 Aug 2012 10:28:51 +0200
4Subject: [PATCH 22/25] owrt dm9000 polling
5
6---
7 drivers/net/ethernet/davicom/dm9000.c | 50 +++++++++++++++++++++++++++-----
8 1 files changed, 42 insertions(+), 8 deletions(-)
9
10diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
11index f801754..258a0c3 100644
12--- a/drivers/net/ethernet/davicom/dm9000.c
13+++ b/drivers/net/ethernet/davicom/dm9000.c
14@@ -19,6 +19,7 @@
15  * Sascha Hauer <s.hauer@pengutronix.de>
16  */
17 
18+#define DEBUG
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;
25 
26+ struct delayed_work irq_poll; /* for use in irq polling mode */
27+
28     spinlock_t lock;
29 
30     struct mii_if_info mii;
31@@ -845,6 +848,8 @@ static void dm9000_timeout(struct net_device *dev)
32     netif_stop_queue(dev);
33     dm9000_reset(db);
34     dm9000_init_dm9000(dev);
35+ dm9000_reset(db);
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)
41     /* free this SKB */
42     dev_kfree_skb(skb);
43 
44+ /* directly poll afterwards */
45+ if (dev->irq == -1) {
46+ cancel_delayed_work(&db->irq_poll);
47+ schedule_delayed_work(&db->irq_poll, 1);
48+ }
49+
50     return NETDEV_TX_OK;
51 }
52 
53@@ -1157,6 +1168,18 @@ static void dm9000_poll_controller(struct net_device *dev)
54 }
55 #endif
56 
57+static void dm9000_poll_irq(struct work_struct *w)
58+{
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;
62+
63+ dm9000_interrupt(0, ndev);
64+
65+ if (netif_running(ndev))
66+ schedule_delayed_work(&db->irq_poll, HZ /100);
67+}
68+
69 /*
70  * Open the interface.
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);
75 
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 */
81 
82- if (irqflags == IRQF_TRIGGER_NONE)
83- dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
84-
85- irqflags |= IRQF_SHARED;
86+ if (irqflags == IRQF_TRIGGER_NONE)
87+ dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
88 
89+ irqflags |= IRQF_SHARED;
90+ }
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)
95     dm9000_reset(db);
96     dm9000_init_dm9000(dev);
97 
98- if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
99- return -EAGAIN;
100+ /* testing: init a second time */
101+ dm9000_reset(db);
102+ dm9000_init_dm9000(dev);
103+
104+ if (dev->irq != -1) {
105+ if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
106+ return -EAGAIN;
107+ }
108 
109     /* Init driver variable */
110     db->dbug_cnt = 0;
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);
114     
115+ if (dev->irq == -1)
116+ schedule_delayed_work(&db->irq_poll, HZ / 100);
117+
118     dm9000_schedule_poll(db);
119 
120     return 0;
121@@ -1392,6 +1425,7 @@ dm9000_probe(struct platform_device *pdev)
122     mutex_init(&db->addr_lock);
123 
124     INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
125+ INIT_DELAYED_WORK(&db->irq_poll, dm9000_poll_irq);
126 
127     db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
128     db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
129--
1301.7.9.1
131
132

Archive Download this file



interactive