ar71xx: add diag support for the DB120 board
[openwrt.git] / target / linux / lantiq / patches-2.6.32 / 350-dm9000-polling.patch
1 --- a/drivers/net/dm9000.c
2 +++ b/drivers/net/dm9000.c
3 @@ -19,6 +19,7 @@
4 * Sascha Hauer <s.hauer@pengutronix.de>
5 */
6
7 +#define DEBUG
8 #include <linux/module.h>
9 #include <linux/ioport.h>
10 #include <linux/netdevice.h>
11 @@ -121,6 +122,8 @@ typedef struct board_info {
12 struct delayed_work phy_poll;
13 struct net_device *ndev;
14
15 + struct delayed_work irq_poll; /* for use in irq polling mode */
16 +
17 spinlock_t lock;
18
19 struct mii_if_info mii;
20 @@ -790,12 +793,14 @@ static void dm9000_timeout(struct net_de
21 unsigned long flags;
22
23 /* Save previous register address */
24 - reg_save = readb(db->io_addr);
25 spin_lock_irqsave(&db->lock, flags);
26 + reg_save = readb(db->io_addr);
27
28 netif_stop_queue(dev);
29 dm9000_reset(db);
30 dm9000_init_dm9000(dev);
31 + dm9000_reset(db);
32 + dm9000_init_dm9000(dev);
33 /* We can accept TX packets again */
34 dev->trans_start = jiffies;
35 netif_wake_queue(dev);
36 @@ -867,6 +872,12 @@ dm9000_start_xmit(struct sk_buff *skb, s
37 /* free this SKB */
38 dev_kfree_skb(skb);
39
40 + /* directly poll afterwards */
41 + if (dev->irq == -1) {
42 + cancel_delayed_work(&db->irq_poll);
43 + schedule_delayed_work(&db->irq_poll, 1);
44 + }
45 +
46 return NETDEV_TX_OK;
47 }
48
49 @@ -1073,6 +1084,18 @@ static void dm9000_poll_controller(struc
50 }
51 #endif
52
53 +static void dm9000_poll_irq(struct work_struct *w)
54 +{
55 + struct delayed_work *dw = to_delayed_work(w);
56 + board_info_t *db = container_of(dw, board_info_t, irq_poll);
57 + struct net_device *ndev = db->ndev;
58 +
59 + dm9000_interrupt(0, ndev);
60 +
61 + if (netif_running(ndev))
62 + schedule_delayed_work(&db->irq_poll, HZ /100);
63 +}
64 +
65 /*
66 * Open the interface.
67 * The interface is opened whenever "ifconfig" actives it.
68 @@ -1086,27 +1109,35 @@ dm9000_open(struct net_device *dev)
69 if (netif_msg_ifup(db))
70 dev_dbg(db->dev, "enabling %s\n", dev->name);
71
72 - /* If there is no IRQ type specified, default to something that
73 - * may work, and tell the user that this is a problem */
74 + if (dev->irq != -1) {
75 + /* If there is no IRQ type specified, default to something that
76 + * may work, and tell the user that this is a problem */
77
78 - if (irqflags == IRQF_TRIGGER_NONE)
79 - dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
80 + if (irqflags == IRQF_TRIGGER_NONE)
81 + dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
82
83 - irqflags |= IRQF_SHARED;
84 + irqflags |= IRQF_SHARED;
85
86 - if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
87 - return -EAGAIN;
88 + if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
89 + return -EAGAIN;
90 + }
91
92 /* Initialize DM9000 board */
93 dm9000_reset(db);
94 dm9000_init_dm9000(dev);
95 + /* workaround: init a second time */
96 + dm9000_reset(db);
97 + dm9000_init_dm9000(dev);
98
99 /* Init driver variable */
100 db->dbug_cnt = 0;
101
102 mii_check_media(&db->mii, netif_msg_link(db), 1);
103 netif_start_queue(dev);
104 -
105 +
106 + if (dev->irq == -1)
107 + schedule_delayed_work(&db->irq_poll, HZ / 100);
108 +
109 dm9000_schedule_poll(db);
110
111 return 0;
112 @@ -1303,6 +1334,7 @@ dm9000_probe(struct platform_device *pde
113 mutex_init(&db->addr_lock);
114
115 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
116 + INIT_DELAYED_WORK(&db->irq_poll, dm9000_poll_irq);
117
118 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
119 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
This page took 0.054932 seconds and 5 git commands to generate.