adds 2 ASC related patches to lantiq
[openwrt.git] / target / linux / lantiq / patches-2.6.39 / 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 @@ -125,6 +126,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 @@ -855,6 +858,8 @@ static void dm9000_timeout(struct net_de
21         netif_stop_queue(dev);
22         dm9000_reset(db);
23         dm9000_init_dm9000(dev);
24 +       dm9000_reset(db);
25 +       dm9000_init_dm9000(dev);
26         /* We can accept TX packets again */
27         dev->trans_start = jiffies; /* prevent tx timeout */
28         netif_wake_queue(dev);
29 @@ -926,6 +931,12 @@ dm9000_start_xmit(struct sk_buff *skb, s
30         /* free this SKB */
31         dev_kfree_skb(skb);
32  
33 +       /* directly poll afterwards */
34 +       if (dev->irq == -1) {
35 +               cancel_delayed_work(&db->irq_poll);
36 +               schedule_delayed_work(&db->irq_poll, 1);
37 +       }
38 +
39         return NETDEV_TX_OK;
40  }
41  
42 @@ -1167,6 +1178,18 @@ static void dm9000_poll_controller(struc
43  }
44  #endif
45  
46 +static void dm9000_poll_irq(struct work_struct *w)
47 +{
48 +       struct delayed_work *dw = to_delayed_work(w);
49 +       board_info_t *db = container_of(dw, board_info_t, irq_poll);
50 +       struct net_device *ndev = db->ndev;
51 +
52 +       dm9000_interrupt(0, ndev);
53 +
54 +       if (netif_running(ndev))
55 +               schedule_delayed_work(&db->irq_poll, HZ /100);
56 +}
57 +
58  /*
59   *  Open the interface.
60   *  The interface is opened whenever "ifconfig" actives it.
61 @@ -1180,17 +1203,18 @@ dm9000_open(struct net_device *dev)
62         if (netif_msg_ifup(db))
63                 dev_dbg(db->dev, "enabling %s\n", dev->name);
64  
65 -       /* If there is no IRQ type specified, default to something that
66 -        * may work, and tell the user that this is a problem */
67 +       if (dev->irq != -1) {
68 +               /* If there is no IRQ type specified, default to something that
69 +                * may work, and tell the user that this is a problem */
70  
71 -       if (irqflags == IRQF_TRIGGER_NONE)
72 -               dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
73 +               if (irqflags == IRQF_TRIGGER_NONE)
74 +                       dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
75  
76 -       irqflags |= IRQF_SHARED;
77 -
78 -       if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
79 -               return -EAGAIN;
80 +               irqflags |= IRQF_SHARED;
81  
82 +               if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
83 +                       return -EAGAIN;
84 +       }
85         /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
86         iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
87         mdelay(1); /* delay needs by DM9000B */
88 @@ -1198,13 +1222,19 @@ dm9000_open(struct net_device *dev)
89         /* Initialize DM9000 board */
90         dm9000_reset(db);
91         dm9000_init_dm9000(dev);
92 +       /* testing: init a second time */
93 +       dm9000_reset(db);
94 +       dm9000_init_dm9000(dev);
95  
96         /* Init driver variable */
97         db->dbug_cnt = 0;
98  
99         mii_check_media(&db->mii, netif_msg_link(db), 1);
100         netif_start_queue(dev);
101 -       
102 +
103 +       if (dev->irq == -1)
104 +               schedule_delayed_work(&db->irq_poll, HZ / 100);
105 +
106         dm9000_schedule_poll(db);
107  
108         return 0;
109 @@ -1401,6 +1431,7 @@ dm9000_probe(struct platform_device *pde
110         mutex_init(&db->addr_lock);
111  
112         INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
113 +       INIT_DELAYED_WORK(&db->irq_poll, dm9000_poll_irq);
114  
115         db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
116         db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);