1 --- a/drivers/net/ethernet/dec/tulip/Kconfig
2 +++ b/drivers/net/ethernet/dec/tulip/Kconfig
3 @@ -60,6 +60,14 @@ config TULIP_PCI
4 To compile this driver as a module, choose M here. The module will
8 + tristate "DECchip Tulip (dc2114x) Platform support"
13 + This driver is for the platform variant.
16 bool "New bus configuration"
18 --- a/drivers/net/ethernet/dec/tulip/tulip_core.c
19 +++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
21 #include <linux/init.h>
22 #include <linux/interrupt.h>
23 #include <linux/etherdevice.h>
24 +#include <linux/platform_device.h>
25 +#include <linux/platform_data/tulip.h>
26 #include <linux/delay.h>
27 #include <linux/mii.h>
28 #include <linux/crc32.h>
29 @@ -204,6 +206,9 @@ struct tulip_chip_table tulip_tbl[] = {
30 { "Conexant LANfinity", 256, 0x0001ebef,
31 HAS_MII | HAS_ACPI, tulip_timer, tulip_media_task },
33 + { "Infineon ADM8668", 256, 0x0001a451,
34 + MC_HASH_ONLY | COMET_MAC_ADDR, tulip_timer, tulip_media_task, },
39 @@ -377,6 +382,11 @@ static void tulip_up(struct net_device *
40 sizeof(tp->setup_frame),
43 +#ifdef CONFIG_TULIP_PLATFORM
44 + mapping = dma_map_single(&tp->pldev->dev, tp->setup_frame,
45 + sizeof(tp->setup_frame),
48 tp->tx_buffers[tp->cur_tx].skb = NULL;
49 tp->tx_buffers[tp->cur_tx].mapping = mapping;
51 @@ -396,6 +406,7 @@ static void tulip_up(struct net_device *
53 if (tp->mtable == NULL)
57 int looking_for = tulip_media_cap[dev->if_port] & MediaIsMII ? 11 :
58 (dev->if_port == 12 ? 0 : dev->if_port);
59 @@ -489,6 +500,10 @@ media_picked:
60 iowrite32(ioread32(ioaddr + 0x88) | 1, ioaddr + 0x88);
61 dev->if_port = tp->mii_cnt ? 11 : 0;
62 tp->csr6 = 0x00040000;
63 + } else if (tp->chip_id == ADM8668) {
64 + /* Enable automatic Tx underrun recovery. */
65 + iowrite32(ioread32(ioaddr + 0x88) | 1, ioaddr + 0x88);
66 + tp->csr6 = 0x00040000;
67 } else if (tp->chip_id == AX88140) {
68 tp->csr6 = tp->mii_cnt ? 0x00040100 : 0x00000100;
70 @@ -660,6 +675,10 @@ static void tulip_init_ring(struct net_d
71 mapping = pci_map_single(tp->pdev, skb->data,
72 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
74 +#ifdef CONFIG_TULIP_PLATFORM
75 + mapping = dma_map_single(&tp->pldev->dev, skb->data,
76 + PKT_BUF_SZ, DMA_FROM_DEVICE);
78 tp->rx_buffers[i].mapping = mapping;
79 tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
80 tp->rx_ring[i].buffer1 = cpu_to_le32(mapping);
81 @@ -696,6 +715,11 @@ tulip_start_xmit(struct sk_buff *skb, st
82 mapping = pci_map_single(tp->pdev, skb->data,
83 skb->len, PCI_DMA_TODEVICE);
85 +#ifdef CONFIG_TULIP_PLATFORM
86 + mapping = dma_map_single(&tp->pldev->dev, skb->data,
90 tp->tx_buffers[entry].mapping = mapping;
91 tp->tx_ring[entry].buffer1 = cpu_to_le32(mapping);
93 @@ -752,6 +776,13 @@ static void tulip_clean_tx_ring(struct t
94 sizeof(tp->setup_frame),
97 +#ifdef CONFIG_TULIP_PLATFORM
98 + dma_unmap_single(&tp->pldev->dev,
99 + tp->tx_buffers[entry].mapping,
100 + sizeof(tp->setup_frame),
106 #ifdef CONFIG_TULIP_PCI
107 @@ -759,6 +790,11 @@ static void tulip_clean_tx_ring(struct t
108 tp->tx_buffers[entry].skb->len,
111 +#ifdef CONFIG_TULIP_PLATFORM
112 + dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[entry].mapping,
113 + tp->tx_buffers[entry].skb->len,
117 /* Free the original skb. */
118 dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
119 @@ -836,6 +872,10 @@ static void tulip_free_ring (struct net_
120 pci_unmap_single(tp->pdev, mapping, PKT_BUF_SZ,
123 +#ifdef CONFIG_TULIP_PLATFORM
124 + dma_unmap_single(&tp->pldev->dev, mapping, PKT_BUF_SZ,
130 @@ -848,6 +888,10 @@ static void tulip_free_ring (struct net_
131 pci_unmap_single(tp->pdev, tp->tx_buffers[i].mapping,
132 skb->len, PCI_DMA_TODEVICE);
134 +#ifdef CONFIG_TULIP_PLATFORM
135 + dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[i].mapping,
136 + skb->len, DMA_TO_DEVICE);
140 tp->tx_buffers[i].skb = NULL;
141 @@ -902,6 +946,9 @@ static void tulip_get_drvinfo(struct net
142 #ifdef CONFIG_TULIP_PCI
143 strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
145 +#ifdef CONFIG_TULIP_PLATFORM
146 + strlcpy(info->bus_info, "platform", sizeof(info->bus_info));
151 @@ -917,6 +964,9 @@ static int tulip_ethtool_set_wol(struct
152 #ifdef CONFIG_TULIP_PCI
153 device_set_wakeup_enable(tp->kdev, tp->wolinfo.wolopts);
155 +#ifdef CONFIG_TULIP_PLATFORM
156 + device_set_wakeup_enable(&tp->pldev->dev, tp->wolinfo.wolopts);
161 @@ -1192,13 +1242,20 @@ static void set_rx_mode(struct net_devic
165 +#ifdef CONFIG_TULIP_PCI
166 tp->tx_buffers[entry].skb = NULL;
167 tp->tx_buffers[entry].mapping =
168 -#ifdef CONFIG_TULIP_PCI
169 pci_map_single(tp->pdev, tp->setup_frame,
170 sizeof(tp->setup_frame),
173 +#ifdef CONFIG_TULIP_PLATFORM
174 + tp->tx_buffers[entry].skb = NULL;
175 + tp->tx_buffers[entry].mapping =
176 + dma_map_single(&tp->pldev->dev, tp->setup_frame,
177 + sizeof(tp->setup_frame),
180 /* Put the setup frame on the Tx list. */
181 if (entry == TX_RING_SIZE-1)
182 tx_flags |= DESC_RING_WRAP; /* Wrap ring. */
183 @@ -1218,6 +1275,9 @@ static void set_rx_mode(struct net_devic
184 spin_unlock_irqrestore(&tp->lock, flags);
187 + if (tp->chip_id == ADM8668)
188 + csr6 |= (1 << 9); /* force 100Mbps full duplex */
190 iowrite32(csr6, ioaddr + CSR6);
193 @@ -1984,6 +2044,126 @@ static void tulip_remove_one(struct pci_
195 #endif /* CONFIG_TULIP_PCI */
197 +#ifdef CONFIG_TULIP_PLATFORM
198 +static int tulip_probe(struct platform_device *pdev)
200 + struct tulip_private *tp;
201 + struct tulip_platform_data *pdata;
202 + struct net_device *dev;
203 + struct resource *res;
204 + void __iomem *ioaddr;
207 + if (pdev->id < 0 || pdev->id >= MAX_UNITS)
210 + if (!(res = platform_get_resource(pdev, IORESOURCE_IRQ, 0)))
213 + if (!(res = platform_get_resource(pdev, IORESOURCE_MEM, 0)))
215 + if (!(ioaddr = ioremap(res->start, res->end - res->start)))
218 + pdata = pdev->dev.platform_data;
222 + if (!(dev = alloc_etherdev(sizeof (*tp))))
225 + /* setup net dev */
226 + dev->base_addr = (unsigned long)res->start;
228 + SET_NETDEV_DEV(dev, &pdev->dev);
230 + /* tulip private struct */
231 + tp = netdev_priv(dev);
233 + tp->base_addr = ioaddr;
236 + tp->kdev = &pdev->dev;
238 + tp->rx_ring = dma_alloc_coherent(&pdev->dev,
239 + sizeof(struct tulip_rx_desc) * RX_RING_SIZE +
240 + sizeof(struct tulip_tx_desc) * TX_RING_SIZE,
241 + &tp->rx_ring_dma, GFP_KERNEL);
244 + tp->tx_ring = (struct tulip_tx_desc *)(tp->rx_ring + RX_RING_SIZE);
245 + tp->tx_ring_dma = tp->rx_ring_dma + sizeof(struct tulip_rx_desc) * RX_RING_SIZE;
247 + tp->chip_id = pdata->chip_id;
248 + tp->flags = tulip_tbl[tp->chip_id].flags;
250 + spin_lock_init(&tp->lock);
251 + spin_lock_init(&tp->mii_lock);
253 + init_timer(&tp->timer);
254 + tp->timer.data = (unsigned long)dev;
255 + tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
257 + INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
259 + /* Stop the chip's Tx and Rx processes. */
260 + tulip_stop_rxtx(tp);
262 + /* Clear the missed-packet counter. */
263 + ioread32(ioaddr + CSR8);
265 + if (!is_valid_ether_addr(pdata->mac)) {
266 + dev_info(&pdev->dev, "generating random ethernet MAC\n");
267 + random_ether_addr(dev->dev_addr);
269 + memcpy(dev->dev_addr, pdata->mac, ETH_ALEN);
271 + /* The Tulip-specific entries in the device structure. */
272 + dev->netdev_ops = &tulip_netdev_ops;
273 + dev->watchdog_timeo = TX_TIMEOUT;
274 + netif_napi_add(dev, &tp->napi, tulip_poll, 16);
275 + dev->ethtool_ops = &ops;
277 + if (register_netdev(dev))
278 + goto err_out_free_ring;
280 + dev_info(&dev->dev,
281 + "tulip_platform (%s) at MMIO %#lx %pM, IRQ %d\n",
282 + tulip_tbl[tp->chip_id].chip_name,
283 + (unsigned long)dev->base_addr, dev->dev_addr, irq);
285 + platform_set_drvdata(pdev, dev);
289 + dma_free_coherent(&pdev->dev,
290 + sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
291 + sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
292 + tp->rx_ring, tp->rx_ring_dma);
296 +static int tulip_remove(struct platform_device *pdev)
298 + struct net_device *dev = platform_get_drvdata (pdev);
299 + struct tulip_private *tp;
304 + tp = netdev_priv(dev);
305 + unregister_netdev(dev);
306 + dma_free_coherent(&pdev->dev,
307 + sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
308 + sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
309 + tp->rx_ring, tp->rx_ring_dma);
310 + iounmap(tp->base_addr);
312 + platform_set_drvdata(pdev, NULL);
317 #ifdef CONFIG_NET_POLL_CONTROLLER
319 * Polling 'interrupt' - used by things like netconsole to send skbs
320 @@ -2017,6 +2197,17 @@ static struct pci_driver tulip_pci_drive
324 +#ifdef CONFIG_TULIP_PLATFORM
325 +static struct platform_driver tulip_platform_driver = {
326 + .probe = tulip_probe,
327 + .remove = tulip_remove,
329 + .owner = THIS_MODULE,
336 static int __init tulip_init (void)
338 @@ -2033,6 +2224,9 @@ static int __init tulip_init (void)
339 #ifdef CONFIG_TULIP_PCI
340 ret = pci_register_driver(&tulip_pci_driver);
342 +#ifdef CONFIG_TULIP_PLATFORM
343 + ret = platform_driver_register(&tulip_platform_driver);
348 @@ -2042,6 +2236,9 @@ static void __exit tulip_cleanup (void)
349 #ifdef CONFIG_TULIP_PCI
350 pci_unregister_driver (&tulip_pci_driver);
352 +#ifdef CONFIG_TULIP_PLATFORM
353 + platform_driver_unregister (&tulip_platform_driver);
358 --- a/drivers/net/ethernet/dec/tulip/tulip.h
359 +++ b/drivers/net/ethernet/dec/tulip/tulip.h
361 #include <linux/timer.h>
362 #include <linux/delay.h>
363 #include <linux/pci.h>
364 +#include <linux/platform_device.h>
365 +#include <linux/platform_data/tulip.h>
368 #include <asm/unaligned.h>
369 @@ -69,28 +71,6 @@ enum tbl_flag {
373 -/* chip types. careful! order is VERY IMPORTANT here, as these
374 - * are used throughout the driver as indices into arrays */
375 -/* Note 21142 == 21143. */
380 - DC21142 = 3, DC21143 = 3,
398 @@ -446,7 +426,12 @@ struct tulip_private {
399 struct mediatable *mtable;
400 int cur_index; /* Current media index. */
402 +#ifdef CONFIG_TULIP_PCI
403 struct pci_dev *pdev;
405 +#ifdef CONFIG_TULIP_PLATFORM
406 + struct platform_device *pldev;
411 --- a/drivers/net/ethernet/dec/tulip/interrupt.c
412 +++ b/drivers/net/ethernet/dec/tulip/interrupt.c
413 @@ -77,6 +77,10 @@ int tulip_refill_rx(struct net_device *d
414 mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
417 +#ifdef CONFIG_TULIP_PLATFORM
418 + mapping = dma_map_single(&tp->pldev->dev, skb->data, PKT_BUF_SZ,
421 if (dma_mapping_error(tp->kdev, mapping)) {
423 tp->rx_buffers[entry].skb = NULL;
424 @@ -204,8 +208,7 @@ int tulip_poll(struct napi_struct *napi,
425 dev->stats.rx_fifo_errors++;
428 - struct sk_buff *skb;
430 + struct sk_buff *skb;
431 /* Check if the packet is long enough to accept without copying
432 to a minimally-sized skbuff. */
433 if (pkt_len < tulip_rx_copybreak &&
434 @@ -248,6 +251,10 @@ int tulip_poll(struct napi_struct *napi,
435 pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
436 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
438 +#ifdef CONFIG_TULIP_PLATFORM
439 + dma_unmap_single(&tp->pldev->dev, tp->rx_buffers[entry].mapping,
440 + PKT_BUF_SZ, DMA_FROM_DEVICE);
443 tp->rx_buffers[entry].skb = NULL;
444 tp->rx_buffers[entry].mapping = 0;
445 @@ -641,6 +648,11 @@ irqreturn_t tulip_interrupt(int irq, voi
446 tp->tx_buffers[entry].skb->len,
449 +#ifdef CONFIG_TULIP_PLATFORM
450 + dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[entry].mapping,
451 + tp->tx_buffers[entry].skb->len,
455 /* Free the original skb. */
456 dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
458 +++ b/include/linux/platform_data/tulip.h
460 +#ifndef _LINUX_TULIP_PDATA_H
461 +#define _LINUX_TULIP_PDATA_H
463 +/* chip types. careful! order is VERY IMPORTANT here, as these
464 + * are used throughout the driver as indices into arrays */
465 +/* Note 21142 == 21143. */
470 + DC21142 = 3, DC21143 = 3,
485 +struct tulip_platform_data {
487 + enum chips chip_id;