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 (EXPERIMENTAL)"
17 depends on TULIP_PCI && EXPERIMENTAL
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 @@ -657,6 +667,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 skb->dev = dev; /* Mark as being used by this device. */
68 tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
69 @@ -694,6 +708,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 @@ -757,6 +776,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 @@ -834,6 +858,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 @@ -846,6 +874,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 @@ -900,6 +932,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 @@ -915,6 +950,9 @@ static int tulip_ethtool_set_wol(struct
126 #ifdef CONFIG_TULIP_PCI
127 device_set_wakeup_enable(&tp->pdev->dev, tp->wolinfo.wolopts);
129 +#ifdef CONFIG_TULIP_PLATFORM
130 + device_set_wakeup_enable(&tp->pldev->dev, tp->wolinfo.wolopts);
135 @@ -1193,9 +1231,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 @@ -1219,6 +1257,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 @@ -1991,6 +2032,124 @@ static void __devexit tulip_remove_one (
158 #endif /* CONFIG_TULIP_PCI */
160 +#ifdef CONFIG_TULIP_PLATFORM
161 +static int __devinit 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->rx_ring = dma_alloc_coherent(&pdev->dev,
200 + sizeof(struct tulip_rx_desc) * RX_RING_SIZE +
201 + sizeof(struct tulip_tx_desc) * TX_RING_SIZE,
202 + &tp->rx_ring_dma, GFP_KERNEL);
205 + tp->tx_ring = (struct tulip_tx_desc *)(tp->rx_ring + RX_RING_SIZE);
206 + tp->tx_ring_dma = tp->rx_ring_dma + sizeof(struct tulip_rx_desc) * RX_RING_SIZE;
208 + tp->chip_id = pdata->chip_id;
209 + tp->flags = tulip_tbl[tp->chip_id].flags;
211 + spin_lock_init(&tp->lock);
212 + spin_lock_init(&tp->mii_lock);
214 + init_timer(&tp->timer);
215 + tp->timer.data = (unsigned long)dev;
216 + tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
218 + INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
220 + /* Stop the chip's Tx and Rx processes. */
221 + tulip_stop_rxtx(tp);
223 + /* Clear the missed-packet counter. */
224 + ioread32(ioaddr + CSR8);
226 + if (!is_valid_ether_addr(pdata->mac)) {
227 + dev_info(&pdev->dev, "generating random ethernet MAC\n");
228 + random_ether_addr(dev->dev_addr);
230 + memcpy(dev->dev_addr, pdata->mac, ETH_ALEN);
232 + /* The Tulip-specific entries in the device structure. */
233 + dev->netdev_ops = &tulip_netdev_ops;
234 + dev->watchdog_timeo = TX_TIMEOUT;
235 + netif_napi_add(dev, &tp->napi, tulip_poll, 16);
236 + SET_ETHTOOL_OPS(dev, &ops);
238 + if (register_netdev(dev))
239 + goto err_out_free_ring;
241 + dev_info(&dev->dev,
242 + "tulip_platform (%s) at MMIO %#lx %pM, IRQ %d\n",
243 + tulip_tbl[tp->chip_id].chip_name,
244 + (unsigned long)dev->base_addr, dev->dev_addr, irq);
246 + platform_set_drvdata(pdev, dev);
250 + dma_free_coherent(&pdev->dev,
251 + sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
252 + sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
253 + tp->rx_ring, tp->rx_ring_dma);
257 +static int __devexit tulip_remove(struct platform_device *pdev)
259 + struct net_device *dev = platform_get_drvdata (pdev);
260 + struct tulip_private *tp;
265 + tp = netdev_priv(dev);
266 + unregister_netdev(dev);
267 + dma_free_coherent(&pdev->dev,
268 + sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
269 + sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
270 + tp->rx_ring, tp->rx_ring_dma);
271 + iounmap(tp->base_addr);
273 + platform_set_drvdata(pdev, NULL);
278 #ifdef CONFIG_NET_POLL_CONTROLLER
280 * Polling 'interrupt' - used by things like netconsole to send skbs
281 @@ -2021,6 +2180,17 @@ static struct pci_driver tulip_pci_drive
285 +#ifdef CONFIG_TULIP_PLATFORM
286 +static struct platform_driver tulip_platform_driver = {
287 + .probe = tulip_probe,
288 + .remove = __devexit_p(tulip_remove),
290 + .owner = THIS_MODULE,
297 static int __init tulip_init (void)
299 @@ -2037,6 +2207,9 @@ static int __init tulip_init (void)
300 #ifdef CONFIG_TULIP_PCI
301 ret = pci_register_driver(&tulip_pci_driver);
303 +#ifdef CONFIG_TULIP_PLATFORM
304 + ret = platform_driver_register(&tulip_platform_driver);
309 @@ -2046,6 +2219,9 @@ static void __exit tulip_cleanup (void)
310 #ifdef CONFIG_TULIP_PCI
311 pci_unregister_driver (&tulip_pci_driver);
313 +#ifdef CONFIG_TULIP_PLATFORM
314 + platform_driver_unregister (&tulip_platform_driver);
319 --- a/drivers/net/ethernet/dec/tulip/tulip.h
320 +++ b/drivers/net/ethernet/dec/tulip/tulip.h
322 #include <linux/timer.h>
323 #include <linux/delay.h>
324 #include <linux/pci.h>
325 +#include <linux/platform_device.h>
326 +#include <linux/platform_data/tulip.h>
329 #include <asm/unaligned.h>
330 @@ -69,28 +71,6 @@ enum tbl_flag {
334 -/* chip types. careful! order is VERY IMPORTANT here, as these
335 - * are used throughout the driver as indices into arrays */
336 -/* Note 21142 == 21143. */
341 - DC21142 = 3, DC21143 = 3,
359 @@ -446,7 +426,12 @@ struct tulip_private {
360 struct mediatable *mtable;
361 int cur_index; /* Current media index. */
363 +#ifdef CONFIG_TULIP_PCI
364 struct pci_dev *pdev;
366 +#ifdef CONFIG_TULIP_PLATFORM
367 + struct platform_device *pldev;
372 --- a/drivers/net/ethernet/dec/tulip/interrupt.c
373 +++ b/drivers/net/ethernet/dec/tulip/interrupt.c
374 @@ -76,6 +76,10 @@ int tulip_refill_rx(struct net_device *d
375 mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
378 +#ifdef CONFIG_TULIP_PLATFORM
379 + mapping = dma_map_single(&tp->pldev->dev, skb->data, PKT_BUF_SZ,
382 tp->rx_buffers[entry].mapping = mapping;
384 skb->dev = dev; /* Mark as being used by this device. */
385 @@ -198,8 +202,7 @@ int tulip_poll(struct napi_struct *napi,
386 dev->stats.rx_fifo_errors++;
389 - struct sk_buff *skb;
391 + struct sk_buff *skb;
392 /* Check if the packet is long enough to accept without copying
393 to a minimally-sized skbuff. */
394 if (pkt_len < tulip_rx_copybreak &&
395 @@ -242,6 +245,10 @@ int tulip_poll(struct napi_struct *napi,
396 pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
397 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
399 +#ifdef CONFIG_TULIP_PLATFORM
400 + dma_unmap_single(&tp->pldev->dev, tp->rx_buffers[entry].mapping,
401 + PKT_BUF_SZ, DMA_FROM_DEVICE);
404 tp->rx_buffers[entry].skb = NULL;
405 tp->rx_buffers[entry].mapping = 0;
406 @@ -635,6 +642,11 @@ irqreturn_t tulip_interrupt(int irq, voi
407 tp->tx_buffers[entry].skb->len,
410 +#ifdef CONFIG_TULIP_PLATFORM
411 + dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[entry].mapping,
412 + tp->tx_buffers[entry].skb->len,
416 /* Free the original skb. */
417 dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
419 +++ b/include/linux/platform_data/tulip.h
421 +#ifndef _LINUX_TULIP_PDATA_H
422 +#define _LINUX_TULIP_PDATA_H
424 +/* chip types. careful! order is VERY IMPORTANT here, as these
425 + * are used throughout the driver as indices into arrays */
426 +/* Note 21142 == 21143. */
431 + DC21142 = 3, DC21143 = 3,
446 +struct tulip_platform_data {
448 + enum chips chip_id;