kernel: refresh patches
[openwrt/openwrt.git] / target / linux / adm8668 / patches-3.14 / 004-tulip_pci_split.patch
1 --- a/drivers/net/ethernet/dec/tulip/tulip_core.c
2 +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
3 @@ -206,7 +206,7 @@ struct tulip_chip_table tulip_tbl[] = {
4
5 };
6
7 -
8 +#ifdef CONFIG_TULIP_PCI
9 static DEFINE_PCI_DEVICE_TABLE(tulip_pci_tbl) = {
10 { 0x1011, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
11 { 0x1011, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21143 },
12 @@ -250,7 +250,7 @@ static DEFINE_PCI_DEVICE_TABLE(tulip_pci
13 { } /* terminate list */
14 };
15 MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
16 -
17 +#endif
18
19 /* A full-duplex map for media types. */
20 const char tulip_media_cap[32] =
21 @@ -268,11 +268,14 @@ static void tulip_down(struct net_device
22 static struct net_device_stats *tulip_get_stats(struct net_device *dev);
23 static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
24 static void set_rx_mode(struct net_device *dev);
25 +#ifdef CONFIG_TULIP_PCI
26 static void tulip_set_wolopts(struct pci_dev *pdev, u32 wolopts);
27 +#endif
28 #ifdef CONFIG_NET_POLL_CONTROLLER
29 static void poll_tulip(struct net_device *dev);
30 #endif
31
32 +#ifdef CONFIG_TULIP_PCI
33 static void tulip_set_power_state (struct tulip_private *tp,
34 int sleep, int snooze)
35 {
36 @@ -289,7 +292,7 @@ static void tulip_set_power_state (struc
37 }
38
39 }
40 -
41 +#endif
42
43 static void tulip_up(struct net_device *dev)
44 {
45 @@ -303,6 +306,7 @@ static void tulip_up(struct net_device *
46 napi_enable(&tp->napi);
47 #endif
48
49 +#ifdef CONFIG_TULIP_PCI
50 /* Wake the chip from sleep/snooze mode. */
51 tulip_set_power_state (tp, 0, 0);
52
53 @@ -310,6 +314,7 @@ static void tulip_up(struct net_device *
54 pci_enable_wake(tp->pdev, PCI_D3hot, 0);
55 pci_enable_wake(tp->pdev, PCI_D3cold, 0);
56 tulip_set_wolopts(tp->pdev, 0);
57 +#endif
58
59 /* On some chip revs we must set the MII/SYM port before the reset!? */
60 if (tp->mii_cnt || (tp->mtable && tp->mtable->has_mii))
61 @@ -317,18 +322,22 @@ static void tulip_up(struct net_device *
62
63 /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
64 iowrite32(0x00000001, ioaddr + CSR0);
65 +#ifdef CONFIG_TULIP_PCI
66 pci_read_config_dword(tp->pdev, PCI_COMMAND, &reg); /* flush write */
67 +#endif
68 udelay(100);
69
70 /* Deassert reset.
71 Wait the specified 50 PCI cycles after a reset by initializing
72 Tx and Rx queues and the address filter list. */
73 iowrite32(tp->csr0, ioaddr + CSR0);
74 +#ifdef CONFIG_TULIP_PCI
75 pci_read_config_dword(tp->pdev, PCI_COMMAND, &reg); /* flush write */
76 +#endif
77 udelay(100);
78
79 if (tulip_debug > 1)
80 - netdev_dbg(dev, "tulip_up(), irq==%d\n", tp->pdev->irq);
81 + netdev_dbg(dev, "tulip_up(), irq==%d\n", tp->irq);
82
83 iowrite32(tp->rx_ring_dma, ioaddr + CSR3);
84 iowrite32(tp->tx_ring_dma, ioaddr + CSR4);
85 @@ -362,9 +371,11 @@ static void tulip_up(struct net_device *
86 *setup_frm++ = eaddrs[1]; *setup_frm++ = eaddrs[1];
87 *setup_frm++ = eaddrs[2]; *setup_frm++ = eaddrs[2];
88
89 +#ifdef CONFIG_TULIP_PCI
90 mapping = pci_map_single(tp->pdev, tp->setup_frame,
91 sizeof(tp->setup_frame),
92 PCI_DMA_TODEVICE);
93 +#endif
94 tp->tx_buffers[tp->cur_tx].skb = NULL;
95 tp->tx_buffers[tp->cur_tx].mapping = mapping;
96
97 @@ -520,7 +531,7 @@ tulip_open(struct net_device *dev)
98
99 tulip_init_ring (dev);
100
101 - retval = request_irq(tp->pdev->irq, tulip_interrupt, IRQF_SHARED,
102 + retval = request_irq(tp->irq, tulip_interrupt, IRQF_SHARED,
103 dev->name, dev);
104 if (retval)
105 goto free_ring;
106 @@ -644,8 +655,10 @@ static void tulip_init_ring(struct net_d
107 tp->rx_buffers[i].skb = skb;
108 if (skb == NULL)
109 break;
110 +#ifdef CONFIG_TULIP_PCI
111 mapping = pci_map_single(tp->pdev, skb->data,
112 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
113 +#endif
114 tp->rx_buffers[i].mapping = mapping;
115 tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
116 tp->rx_ring[i].buffer1 = cpu_to_le32(mapping);
117 @@ -678,8 +691,10 @@ tulip_start_xmit(struct sk_buff *skb, st
118 entry = tp->cur_tx % TX_RING_SIZE;
119
120 tp->tx_buffers[entry].skb = skb;
121 +#ifdef CONFIG_TULIP_PCI
122 mapping = pci_map_single(tp->pdev, skb->data,
123 skb->len, PCI_DMA_TODEVICE);
124 +#endif
125 tp->tx_buffers[entry].mapping = mapping;
126 tp->tx_ring[entry].buffer1 = cpu_to_le32(mapping);
127
128 @@ -730,16 +745,19 @@ static void tulip_clean_tx_ring(struct t
129 if (tp->tx_buffers[entry].skb == NULL) {
130 /* test because dummy frames not mapped */
131 if (tp->tx_buffers[entry].mapping)
132 +#ifdef CONFIG_TULIP_PCI
133 pci_unmap_single(tp->pdev,
134 tp->tx_buffers[entry].mapping,
135 sizeof(tp->setup_frame),
136 PCI_DMA_TODEVICE);
137 +#endif
138 continue;
139 }
140 -
141 +#ifdef CONFIG_TULIP_PCI
142 pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
143 tp->tx_buffers[entry].skb->len,
144 PCI_DMA_TODEVICE);
145 +#endif
146
147 /* Free the original skb. */
148 dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
149 @@ -790,7 +808,9 @@ static void tulip_down (struct net_devic
150 dev->if_port = tp->saved_if_port;
151
152 /* Leave the driver in snooze, not sleep, mode. */
153 +#ifdef CONFIG_TULIP_PCI
154 tulip_set_power_state (tp, 0, 1);
155 +#endif
156 }
157
158 static void tulip_free_ring (struct net_device *dev)
159 @@ -811,8 +831,10 @@ static void tulip_free_ring (struct net_
160 /* An invalid address. */
161 tp->rx_ring[i].buffer1 = cpu_to_le32(0xBADF00D0);
162 if (skb) {
163 +#ifdef CONFIG_TULIP_PCI
164 pci_unmap_single(tp->pdev, mapping, PKT_BUF_SZ,
165 PCI_DMA_FROMDEVICE);
166 +#endif
167 dev_kfree_skb (skb);
168 }
169 }
170 @@ -821,8 +843,10 @@ static void tulip_free_ring (struct net_
171 struct sk_buff *skb = tp->tx_buffers[i].skb;
172
173 if (skb != NULL) {
174 +#ifdef CONFIG_TULIP_PCI
175 pci_unmap_single(tp->pdev, tp->tx_buffers[i].mapping,
176 skb->len, PCI_DMA_TODEVICE);
177 +#endif
178 dev_kfree_skb (skb);
179 }
180 tp->tx_buffers[i].skb = NULL;
181 @@ -843,7 +867,7 @@ static int tulip_close (struct net_devic
182 netdev_dbg(dev, "Shutting down ethercard, status was %02x\n",
183 ioread32 (ioaddr + CSR5));
184
185 - free_irq (tp->pdev->irq, dev);
186 + free_irq (tp->irq, dev);
187
188 tulip_free_ring (dev);
189
190 @@ -874,7 +898,9 @@ static void tulip_get_drvinfo(struct net
191 struct tulip_private *np = netdev_priv(dev);
192 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
193 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
194 +#ifdef CONFIG_TULIP_PCI
195 strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
196 +#endif
197 }
198
199
200 @@ -887,7 +913,9 @@ static int tulip_ethtool_set_wol(struct
201 return -EOPNOTSUPP;
202
203 tp->wolinfo.wolopts = wolinfo->wolopts;
204 - device_set_wakeup_enable(&tp->pdev->dev, tp->wolinfo.wolopts);
205 +#ifdef CONFIG_TULIP_PCI
206 + device_set_wakeup_enable(tp->kdev, tp->wolinfo.wolopts);
207 +#endif
208 return 0;
209 }
210
211 @@ -1165,9 +1193,11 @@ static void set_rx_mode(struct net_devic
212
213 tp->tx_buffers[entry].skb = NULL;
214 tp->tx_buffers[entry].mapping =
215 +#ifdef CONFIG_TULIP_PCI
216 pci_map_single(tp->pdev, tp->setup_frame,
217 sizeof(tp->setup_frame),
218 PCI_DMA_TODEVICE);
219 +#endif
220 /* Put the setup frame on the Tx list. */
221 if (entry == TX_RING_SIZE-1)
222 tx_flags |= DESC_RING_WRAP; /* Wrap ring. */
223 @@ -1264,19 +1294,22 @@ out:
224 netdev_dbg(dev, "MWI config cacheline=%d, csr0=%08x\n",
225 cache, csr0);
226 }
227 -#endif
228
229 /*
230 * Chips that have the MRM/reserved bit quirk and the burst quirk. That
231 * is the DM910X and the on chip ULi devices
232 */
233 +#endif
234
235 +#ifdef CONFIG_TULIP_PCI
236 static int tulip_uli_dm_quirk(struct pci_dev *pdev)
237 {
238 if (pdev->vendor == 0x1282 && pdev->device == 0x9102)
239 return 1;
240 return 0;
241 }
242 +#endif
243 +
244
245 static const struct net_device_ops tulip_netdev_ops = {
246 .ndo_open = tulip_open,
247 @@ -1294,6 +1327,7 @@ static const struct net_device_ops tulip
248 #endif
249 };
250
251 +#ifdef CONFIG_TULIP_PCI
252 DEFINE_PCI_DEVICE_TABLE(early_486_chipsets) = {
253 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82424) },
254 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496) },
255 @@ -1471,6 +1505,8 @@ static int tulip_init_one(struct pci_dev
256 }
257 }
258 tp->pdev = pdev;
259 + tp->kdev = &pdev->dev;
260 + tp->irq = irq;
261 tp->base_addr = ioaddr;
262 tp->revision = pdev->revision;
263 tp->csr0 = csr0;
264 @@ -1801,6 +1837,7 @@ err_out_free_netdev:
265 }
266
267
268 +#ifdef CONFIG_TULIP_PCI
269 /* set the registers according to the given wolopts */
270 static void tulip_set_wolopts (struct pci_dev *pdev, u32 wolopts)
271 {
272 @@ -1829,6 +1866,7 @@ static void tulip_set_wolopts (struct pc
273 iowrite32(tmp, ioaddr + CSR13);
274 }
275 }
276 +#endif
277
278 #ifdef CONFIG_PM
279
280 @@ -1943,6 +1981,7 @@ static void tulip_remove_one(struct pci_
281
282 /* pci_power_off (pdev, -1); */
283 }
284 +#endif /* CONFIG_TULIP_PCI */
285
286 #ifdef CONFIG_NET_POLL_CONTROLLER
287 /*
288 @@ -1964,7 +2003,8 @@ static void poll_tulip (struct net_devic
289 }
290 #endif
291
292 -static struct pci_driver tulip_driver = {
293 +#ifdef CONFIG_TULIP_PCI
294 +static struct pci_driver tulip_pci_driver = {
295 .name = DRV_NAME,
296 .id_table = tulip_pci_tbl,
297 .probe = tulip_init_one,
298 @@ -1974,10 +2014,12 @@ static struct pci_driver tulip_driver =
299 .resume = tulip_resume,
300 #endif /* CONFIG_PM */
301 };
302 +#endif
303
304
305 static int __init tulip_init (void)
306 {
307 + int ret = 0;
308 #ifdef MODULE
309 pr_info("%s", version);
310 #endif
311 @@ -1987,13 +2029,18 @@ static int __init tulip_init (void)
312 tulip_max_interrupt_work = max_interrupt_work;
313
314 /* probe for and init boards */
315 - return pci_register_driver(&tulip_driver);
316 +#ifdef CONFIG_TULIP_PCI
317 + ret = pci_register_driver(&tulip_pci_driver);
318 +#endif
319 + return ret;
320 }
321
322
323 static void __exit tulip_cleanup (void)
324 {
325 - pci_unregister_driver (&tulip_driver);
326 +#ifdef CONFIG_TULIP_PCI
327 + pci_unregister_driver (&tulip_pci_driver);
328 +#endif
329 }
330
331
332 --- a/drivers/net/ethernet/dec/tulip/interrupt.c
333 +++ b/drivers/net/ethernet/dec/tulip/interrupt.c
334 @@ -73,10 +73,11 @@ int tulip_refill_rx(struct net_device *d
335 netdev_alloc_skb(dev, PKT_BUF_SZ);
336 if (skb == NULL)
337 break;
338 -
339 +#ifdef CONFIG_TULIP_PCI
340 mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
341 PCI_DMA_FROMDEVICE);
342 - if (dma_mapping_error(&tp->pdev->dev, mapping)) {
343 +#endif
344 + if (dma_mapping_error(tp->kdev, mapping)) {
345 dev_kfree_skb(skb);
346 tp->rx_buffers[entry].skb = NULL;
347 break;
348 @@ -210,9 +211,11 @@ int tulip_poll(struct napi_struct *napi,
349 if (pkt_len < tulip_rx_copybreak &&
350 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
351 skb_reserve(skb, 2); /* 16 byte align the IP header */
352 +#ifdef CONFIG_TULIP_PCI
353 pci_dma_sync_single_for_cpu(tp->pdev,
354 tp->rx_buffers[entry].mapping,
355 pkt_len, PCI_DMA_FROMDEVICE);
356 +#endif
357 #if ! defined(__alpha__)
358 skb_copy_to_linear_data(skb, tp->rx_buffers[entry].skb->data,
359 pkt_len);
360 @@ -222,9 +225,11 @@ int tulip_poll(struct napi_struct *napi,
361 tp->rx_buffers[entry].skb->data,
362 pkt_len);
363 #endif
364 +#ifdef CONFIG_TULIP_PCI
365 pci_dma_sync_single_for_device(tp->pdev,
366 tp->rx_buffers[entry].mapping,
367 pkt_len, PCI_DMA_FROMDEVICE);
368 +#endif
369 } else { /* Pass up the skb already on the Rx ring. */
370 char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
371 pkt_len);
372 @@ -239,9 +244,10 @@ int tulip_poll(struct napi_struct *napi,
373 skb->head, temp);
374 }
375 #endif
376 -
377 +#ifdef CONFIG_TULIP_PCI
378 pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
379 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
380 +#endif
381
382 tp->rx_buffers[entry].skb = NULL;
383 tp->rx_buffers[entry].mapping = 0;
384 @@ -597,10 +603,12 @@ irqreturn_t tulip_interrupt(int irq, voi
385 if (tp->tx_buffers[entry].skb == NULL) {
386 /* test because dummy frames not mapped */
387 if (tp->tx_buffers[entry].mapping)
388 +#ifdef CONFIG_TULIP_PCI
389 pci_unmap_single(tp->pdev,
390 tp->tx_buffers[entry].mapping,
391 sizeof(tp->setup_frame),
392 PCI_DMA_TODEVICE);
393 +#endif
394 continue;
395 }
396
397 @@ -628,10 +636,11 @@ irqreturn_t tulip_interrupt(int irq, voi
398 dev->stats.collisions += (status >> 3) & 15;
399 dev->stats.tx_packets++;
400 }
401 -
402 +#ifdef CONFIG_TULIP_PCI
403 pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
404 tp->tx_buffers[entry].skb->len,
405 PCI_DMA_TODEVICE);
406 +#endif
407
408 /* Free the original skb. */
409 dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
410 --- a/drivers/net/ethernet/dec/tulip/Kconfig
411 +++ b/drivers/net/ethernet/dec/tulip/Kconfig
412 @@ -40,8 +40,12 @@ config DE2104X_DSL
413 Default is 0, and range is 0 to 31.
414
415 config TULIP
416 + tristate
417 +
418 +config TULIP_PCI
419 tristate "DECchip Tulip (dc2114x) PCI support"
420 depends on PCI
421 + select TULIP
422 select CRC32
423 ---help---
424 This driver is developed for the SMC EtherPower series Ethernet
425 @@ -58,7 +62,7 @@ config TULIP
426
427 config TULIP_MWI
428 bool "New bus configuration"
429 - depends on TULIP
430 + depends on TULIP_PCI
431 ---help---
432 This configures your Tulip card specifically for the card and
433 system cache line size type you are using.
434 @@ -69,7 +73,7 @@ config TULIP_MWI
435
436 config TULIP_MMIO
437 bool "Use PCI shared mem for NIC registers"
438 - depends on TULIP
439 + depends on TULIP_PCI
440 ---help---
441 Use PCI shared memory for the NIC registers, rather than going through
442 the Tulip's PIO (programmed I/O ports). Faster, but could produce
443 --- a/drivers/net/ethernet/dec/tulip/tulip.h
444 +++ b/drivers/net/ethernet/dec/tulip/tulip.h
445 @@ -447,6 +447,8 @@ struct tulip_private {
446 int cur_index; /* Current media index. */
447 int saved_if_port;
448 struct pci_dev *pdev;
449 + struct device *kdev;
450 + int irq;
451 int ttimer;
452 int susp_rx;
453 unsigned long nir;