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, },
38 #ifdef CONFIG_TULIP_PCI
39 @@ -395,6 +400,7 @@ static void tulip_up(struct net_device *
41 if (tp->mtable == NULL)
45 int looking_for = tulip_media_cap[dev->if_port] & MediaIsMII ? 11 :
46 (dev->if_port == 12 ? 0 : dev->if_port);
47 @@ -488,6 +494,10 @@ media_picked:
48 iowrite32(ioread32(ioaddr + 0x88) | 1, ioaddr + 0x88);
49 dev->if_port = tp->mii_cnt ? 11 : 0;
50 tp->csr6 = 0x00040000;
51 + } else if (tp->chip_id == ADM8668) {
52 + /* Enable automatic Tx underrun recovery. */
53 + iowrite32(ioread32(ioaddr + 0x88) | 1, ioaddr + 0x88);
54 + tp->csr6 = 0x00040000;
55 } else if (tp->chip_id == AX88140) {
56 tp->csr6 = tp->mii_cnt ? 0x00040100 : 0x00000100;
58 @@ -659,6 +669,10 @@ static void tulip_init_ring(struct net_d
59 mapping = pci_map_single(tp->pdev, skb->data,
60 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
62 +#ifdef CONFIG_TULIP_PLATFORM
63 + mapping = dma_map_single(&tp->pldev->dev, skb->data,
64 + PKT_BUF_SZ, DMA_FROM_DEVICE);
66 tp->rx_buffers[i].mapping = mapping;
67 tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
68 tp->rx_ring[i].buffer1 = cpu_to_le32(mapping);
69 @@ -695,6 +709,11 @@ tulip_start_xmit(struct sk_buff *skb, st
70 mapping = pci_map_single(tp->pdev, skb->data,
71 skb->len, PCI_DMA_TODEVICE);
73 +#ifdef CONFIG_TULIP_PLATFORM
74 + mapping = dma_map_single(&tp->pldev->dev, skb->data,
78 tp->tx_buffers[entry].mapping = mapping;
79 tp->tx_ring[entry].buffer1 = cpu_to_le32(mapping);
81 @@ -758,6 +777,11 @@ static void tulip_clean_tx_ring(struct t
82 tp->tx_buffers[entry].skb->len,
85 +#ifdef CONFIG_TULIP_PLATFORM
86 + dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[entry].mapping,
87 + tp->tx_buffers[entry].skb->len,
91 /* Free the original skb. */
92 dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
93 @@ -835,6 +859,10 @@ static void tulip_free_ring (struct net_
94 pci_unmap_single(tp->pdev, mapping, PKT_BUF_SZ,
97 +#ifdef CONFIG_TULIP_PLATFORM
98 + dma_unmap_single(&tp->pldev->dev, mapping, PKT_BUF_SZ,
104 @@ -847,6 +875,10 @@ static void tulip_free_ring (struct net_
105 pci_unmap_single(tp->pdev, tp->tx_buffers[i].mapping,
106 skb->len, PCI_DMA_TODEVICE);
108 +#ifdef CONFIG_TULIP_PLATFORM
109 + dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[i].mapping,
110 + skb->len, DMA_TO_DEVICE);
114 tp->tx_buffers[i].skb = NULL;
115 @@ -901,6 +933,9 @@ static void tulip_get_drvinfo(struct net
116 #ifdef CONFIG_TULIP_PCI
117 strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
119 +#ifdef CONFIG_TULIP_PLATFORM
120 + strlcpy(info->bus_info, "platform", sizeof(info->bus_info));
125 @@ -916,6 +951,9 @@ static int tulip_ethtool_set_wol(struct
126 #ifdef CONFIG_TULIP_PCI
127 device_set_wakeup_enable(tp->kdev, tp->wolinfo.wolopts);
129 +#ifdef CONFIG_TULIP_PLATFORM
130 + device_set_wakeup_enable(&tp->pldev->dev, tp->wolinfo.wolopts);
135 @@ -1191,9 +1229,9 @@ static void set_rx_mode(struct net_devic
139 +#ifdef CONFIG_TULIP_PCI
140 tp->tx_buffers[entry].skb = NULL;
141 tp->tx_buffers[entry].mapping =
142 -#ifdef CONFIG_TULIP_PCI
143 pci_map_single(tp->pdev, tp->setup_frame,
144 sizeof(tp->setup_frame),
146 @@ -1217,6 +1255,9 @@ static void set_rx_mode(struct net_devic
147 spin_unlock_irqrestore(&tp->lock, flags);
150 + if (tp->chip_id == ADM8668)
151 + csr6 |= (1 << 9); /* force 100Mbps full duplex */
153 iowrite32(csr6, ioaddr + CSR6);
156 @@ -1983,6 +2024,126 @@ static void tulip_remove_one(struct pci_
158 #endif /* CONFIG_TULIP_PCI */
160 +#ifdef CONFIG_TULIP_PLATFORM
161 +static int tulip_probe(struct platform_device *pdev)
163 + struct tulip_private *tp;
164 + struct tulip_platform_data *pdata;
165 + struct net_device *dev;
166 + struct resource *res;
167 + void __iomem *ioaddr;
170 + if (pdev->id < 0 || pdev->id >= MAX_UNITS)
173 + if (!(res = platform_get_resource(pdev, IORESOURCE_IRQ, 0)))
176 + if (!(res = platform_get_resource(pdev, IORESOURCE_MEM, 0)))
178 + if (!(ioaddr = ioremap(res->start, res->end - res->start)))
181 + pdata = pdev->dev.platform_data;
185 + if (!(dev = alloc_etherdev(sizeof (*tp))))
188 + /* setup net dev */
189 + dev->base_addr = (unsigned long)res->start;
191 + SET_NETDEV_DEV(dev, &pdev->dev);
193 + /* tulip private struct */
194 + tp = netdev_priv(dev);
196 + tp->base_addr = ioaddr;
199 + tp->kdev = &pdev->dev;
201 + tp->rx_ring = dma_alloc_coherent(&pdev->dev,
202 + sizeof(struct tulip_rx_desc) * RX_RING_SIZE +
203 + sizeof(struct tulip_tx_desc) * TX_RING_SIZE,
204 + &tp->rx_ring_dma, GFP_KERNEL);
207 + tp->tx_ring = (struct tulip_tx_desc *)(tp->rx_ring + RX_RING_SIZE);
208 + tp->tx_ring_dma = tp->rx_ring_dma + sizeof(struct tulip_rx_desc) * RX_RING_SIZE;
210 + tp->chip_id = pdata->chip_id;
211 + tp->flags = tulip_tbl[tp->chip_id].flags;
213 + spin_lock_init(&tp->lock);
214 + spin_lock_init(&tp->mii_lock);
216 + init_timer(&tp->timer);
217 + tp->timer.data = (unsigned long)dev;
218 + tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
220 + INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
222 + /* Stop the chip's Tx and Rx processes. */
223 + tulip_stop_rxtx(tp);
225 + /* Clear the missed-packet counter. */
226 + ioread32(ioaddr + CSR8);
228 + if (!is_valid_ether_addr(pdata->mac)) {
229 + dev_info(&pdev->dev, "generating random ethernet MAC\n");
230 + random_ether_addr(dev->dev_addr);
232 + memcpy(dev->dev_addr, pdata->mac, ETH_ALEN);
234 + /* The Tulip-specific entries in the device structure. */
235 + dev->netdev_ops = &tulip_netdev_ops;
236 + dev->watchdog_timeo = TX_TIMEOUT;
237 + netif_napi_add(dev, &tp->napi, tulip_poll, 16);
238 + SET_ETHTOOL_OPS(dev, &ops);
240 + if (register_netdev(dev))
241 + goto err_out_free_ring;
243 + dev_info(&dev->dev,
244 + "tulip_platform (%s) at MMIO %#lx %pM, IRQ %d\n",
245 + tulip_tbl[tp->chip_id].chip_name,
246 + (unsigned long)dev->base_addr, dev->dev_addr, irq);
248 + platform_set_drvdata(pdev, dev);
252 + dma_free_coherent(&pdev->dev,
253 + sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
254 + sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
255 + tp->rx_ring, tp->rx_ring_dma);
259 +static int tulip_remove(struct platform_device *pdev)
261 + struct net_device *dev = platform_get_drvdata (pdev);
262 + struct tulip_private *tp;
267 + tp = netdev_priv(dev);
268 + unregister_netdev(dev);
269 + dma_free_coherent(&pdev->dev,
270 + sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
271 + sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
272 + tp->rx_ring, tp->rx_ring_dma);
273 + iounmap(tp->base_addr);
275 + platform_set_drvdata(pdev, NULL);
280 #ifdef CONFIG_NET_POLL_CONTROLLER
282 * Polling 'interrupt' - used by things like netconsole to send skbs
283 @@ -2016,6 +2177,17 @@ static struct pci_driver tulip_pci_drive
287 +#ifdef CONFIG_TULIP_PLATFORM
288 +static struct platform_driver tulip_platform_driver = {
289 + .probe = tulip_probe,
290 + .remove = tulip_remove,
292 + .owner = THIS_MODULE,
299 static int __init tulip_init (void)
301 @@ -2032,6 +2204,9 @@ static int __init tulip_init (void)
302 #ifdef CONFIG_TULIP_PCI
303 ret = pci_register_driver(&tulip_pci_driver);
305 +#ifdef CONFIG_TULIP_PLATFORM
306 + ret = platform_driver_register(&tulip_platform_driver);
311 @@ -2041,6 +2216,9 @@ static void __exit tulip_cleanup (void)
312 #ifdef CONFIG_TULIP_PCI
313 pci_unregister_driver (&tulip_pci_driver);
315 +#ifdef CONFIG_TULIP_PLATFORM
316 + platform_driver_unregister (&tulip_platform_driver);
321 --- a/drivers/net/ethernet/dec/tulip/tulip.h
322 +++ b/drivers/net/ethernet/dec/tulip/tulip.h
324 #include <linux/timer.h>
325 #include <linux/delay.h>
326 #include <linux/pci.h>
327 +#include <linux/platform_device.h>
328 +#include <linux/platform_data/tulip.h>
331 #include <asm/unaligned.h>
332 @@ -69,28 +71,6 @@ enum tbl_flag {
336 -/* chip types. careful! order is VERY IMPORTANT here, as these
337 - * are used throughout the driver as indices into arrays */
338 -/* Note 21142 == 21143. */
343 - DC21142 = 3, DC21143 = 3,
361 @@ -446,7 +426,12 @@ struct tulip_private {
362 struct mediatable *mtable;
363 int cur_index; /* Current media index. */
365 +#ifdef CONFIG_TULIP_PCI
366 struct pci_dev *pdev;
368 +#ifdef CONFIG_TULIP_PLATFORM
369 + struct platform_device *pldev;
374 --- a/drivers/net/ethernet/dec/tulip/interrupt.c
375 +++ b/drivers/net/ethernet/dec/tulip/interrupt.c
376 @@ -77,6 +77,10 @@ int tulip_refill_rx(struct net_device *d
377 mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
380 +#ifdef CONFIG_TULIP_PLATFORM
381 + mapping = dma_map_single(&tp->pldev->dev, skb->data, PKT_BUF_SZ,
384 if (dma_mapping_error(tp->kdev, mapping)) {
386 tp->rx_buffers[entry].skb = NULL;
387 @@ -204,8 +208,7 @@ int tulip_poll(struct napi_struct *napi,
388 dev->stats.rx_fifo_errors++;
391 - struct sk_buff *skb;
393 + struct sk_buff *skb;
394 /* Check if the packet is long enough to accept without copying
395 to a minimally-sized skbuff. */
396 if (pkt_len < tulip_rx_copybreak &&
397 @@ -248,6 +251,10 @@ int tulip_poll(struct napi_struct *napi,
398 pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
399 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
401 +#ifdef CONFIG_TULIP_PLATFORM
402 + dma_unmap_single(&tp->pldev->dev, tp->rx_buffers[entry].mapping,
403 + PKT_BUF_SZ, DMA_FROM_DEVICE);
406 tp->rx_buffers[entry].skb = NULL;
407 tp->rx_buffers[entry].mapping = 0;
408 @@ -641,6 +648,11 @@ irqreturn_t tulip_interrupt(int irq, voi
409 tp->tx_buffers[entry].skb->len,
412 +#ifdef CONFIG_TULIP_PLATFORM
413 + dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[entry].mapping,
414 + tp->tx_buffers[entry].skb->len,
418 /* Free the original skb. */
419 dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
421 +++ b/include/linux/platform_data/tulip.h
423 +#ifndef _LINUX_TULIP_PDATA_H
424 +#define _LINUX_TULIP_PDATA_H
426 +/* chip types. careful! order is VERY IMPORTANT here, as these
427 + * are used throughout the driver as indices into arrays */
428 +/* Note 21142 == 21143. */
433 + DC21142 = 3, DC21143 = 3,
448 +struct tulip_platform_data {
450 + enum chips chip_id;