aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2012-12-06 22:40:31 +0000
committerFlorian Fainelli <florian@openwrt.org>2012-12-06 22:40:31 +0000
commit445e77fdb52e04aefd492ab9c16d9ca43374309a (patch)
tree06b720e346b46270dd760ffb3ffdaf4cc9ad7800 /target
parentb1f1381c27bdc7566db17a763093d594f95042f7 (diff)
downloadupstream-445e77fdb52e04aefd492ab9c16d9ca43374309a.tar.gz
upstream-445e77fdb52e04aefd492ab9c16d9ca43374309a.tar.bz2
upstream-445e77fdb52e04aefd492ab9c16d9ca43374309a.zip
patch the tulip driver to accept a platform variant
Isolate the PCI specific parts and group them under CONFIG_TULIP_PCI CONFIG_TULIP_PLATFORM can be enabled for a platform style Tulip driver. Signed-off-by: Florian Fainelli <florian@openwrt.org> SVN-Revision: 34557
Diffstat (limited to 'target')
-rw-r--r--target/linux/adm8668/config-3.311
-rw-r--r--target/linux/adm8668/files/arch/mips/adm8668/Makefile1
-rw-r--r--target/linux/adm8668/patches-3.3/004-tulip_pci_split.patch407
-rw-r--r--target/linux/adm8668/patches-3.3/005-tulip_platform.patch451
4 files changed, 869 insertions, 1 deletions
diff --git a/target/linux/adm8668/config-3.3 b/target/linux/adm8668/config-3.3
index a354495cba..b365db19ad 100644
--- a/target/linux/adm8668/config-3.3
+++ b/target/linux/adm8668/config-3.3
@@ -20,7 +20,10 @@ CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
CONFIG_CPU_SUPPORTS_HIGHMEM=y
CONFIG_CSRC_R4K=y
CONFIG_CSRC_R4K_LIB=y
+# CONFIG_DE2104X is not set
+# CONFIG_DE4X5 is not set
CONFIG_DECOMPRESS_LZMA=y
+# CONFIG_DM9102 is not set
CONFIG_DMA_NONCOHERENT=y
CONFIG_EARLY_PRINTK=y
CONFIG_EEPROM_93CX6=m
@@ -64,6 +67,7 @@ CONFIG_MTD_ADM8668_PARTS=y
CONFIG_MTD_PHYSMAP=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_PER_CPU_KM=y
+CONFIG_NET_TULIP=y
CONFIG_NO_EXCEPT_FILL=y
CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y
CONFIG_PAGEFLAGS_EXTENDED=y
@@ -84,4 +88,11 @@ CONFIG_SYS_HAS_EARLY_PRINTK=y
CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_TULIP=y
+CONFIG_TULIP_NAPI=y
+# CONFIG_TULIP_NAPI_HW_MITIGATION is not set
+# CONFIG_TULIP_PCI is not set
+CONFIG_TULIP_PLATFORM=y
+# CONFIG_ULI526X is not set
+# CONFIG_WINBOND_840 is not set
CONFIG_ZONE_DMA_FLAG=0
diff --git a/target/linux/adm8668/files/arch/mips/adm8668/Makefile b/target/linux/adm8668/files/arch/mips/adm8668/Makefile
index e443f68663..e8f6d6bf22 100644
--- a/target/linux/adm8668/files/arch/mips/adm8668/Makefile
+++ b/target/linux/adm8668/files/arch/mips/adm8668/Makefile
@@ -4,4 +4,3 @@
obj-y := irq.o prom.o platform.o proc.o \
setup.o clock.o time.o early_printk.o \
- net_core.o net_intr.o
diff --git a/target/linux/adm8668/patches-3.3/004-tulip_pci_split.patch b/target/linux/adm8668/patches-3.3/004-tulip_pci_split.patch
new file mode 100644
index 0000000000..be2e70635a
--- /dev/null
+++ b/target/linux/adm8668/patches-3.3/004-tulip_pci_split.patch
@@ -0,0 +1,407 @@
+--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
++++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
+@@ -206,7 +206,7 @@ struct tulip_chip_table tulip_tbl[] = {
+
+ };
+
+-
++#ifdef CONFIG_TULIP_PCI
+ static DEFINE_PCI_DEVICE_TABLE(tulip_pci_tbl) = {
+ { 0x1011, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
+ { 0x1011, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21143 },
+@@ -250,7 +250,7 @@ static DEFINE_PCI_DEVICE_TABLE(tulip_pci
+ { } /* terminate list */
+ };
+ MODULE_DEVICE_TABLE(pci, tulip_pci_tbl);
+-
++#endif
+
+ /* A full-duplex map for media types. */
+ const char tulip_media_cap[32] =
+@@ -268,11 +268,14 @@ static void tulip_down(struct net_device
+ static struct net_device_stats *tulip_get_stats(struct net_device *dev);
+ static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+ static void set_rx_mode(struct net_device *dev);
++#ifdef CONFIG_TULIP_PCI
+ static void tulip_set_wolopts(struct pci_dev *pdev, u32 wolopts);
++#endif
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+ static void poll_tulip(struct net_device *dev);
+ #endif
+
++#ifdef CONFIG_TULIP_PCI
+ static void tulip_set_power_state (struct tulip_private *tp,
+ int sleep, int snooze)
+ {
+@@ -289,7 +292,7 @@ static void tulip_set_power_state (struc
+ }
+
+ }
+-
++#endif
+
+ static void tulip_up(struct net_device *dev)
+ {
+@@ -303,6 +306,7 @@ static void tulip_up(struct net_device *
+ napi_enable(&tp->napi);
+ #endif
+
++#ifdef CONFIG_TULIP_PCI
+ /* Wake the chip from sleep/snooze mode. */
+ tulip_set_power_state (tp, 0, 0);
+
+@@ -310,6 +314,7 @@ static void tulip_up(struct net_device *
+ pci_enable_wake(tp->pdev, PCI_D3hot, 0);
+ pci_enable_wake(tp->pdev, PCI_D3cold, 0);
+ tulip_set_wolopts(tp->pdev, 0);
++#endif
+
+ /* On some chip revs we must set the MII/SYM port before the reset!? */
+ if (tp->mii_cnt || (tp->mtable && tp->mtable->has_mii))
+@@ -317,14 +322,18 @@ static void tulip_up(struct net_device *
+
+ /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
+ iowrite32(0x00000001, ioaddr + CSR0);
++#ifdef CONFIG_TULIP_PCI
+ pci_read_config_dword(tp->pdev, PCI_COMMAND, &reg); /* flush write */
++#endif
+ udelay(100);
+
+ /* Deassert reset.
+ Wait the specified 50 PCI cycles after a reset by initializing
+ Tx and Rx queues and the address filter list. */
+ iowrite32(tp->csr0, ioaddr + CSR0);
++#ifdef CONFIG_TULIP_PCI
+ pci_read_config_dword(tp->pdev, PCI_COMMAND, &reg); /* flush write */
++#endif
+ udelay(100);
+
+ if (tulip_debug > 1)
+@@ -362,9 +371,11 @@ static void tulip_up(struct net_device *
+ *setup_frm++ = eaddrs[1]; *setup_frm++ = eaddrs[1];
+ *setup_frm++ = eaddrs[2]; *setup_frm++ = eaddrs[2];
+
++#ifdef CONFIG_TULIP_PCI
+ mapping = pci_map_single(tp->pdev, tp->setup_frame,
+ sizeof(tp->setup_frame),
+ PCI_DMA_TODEVICE);
++#endif
+ tp->tx_buffers[tp->cur_tx].skb = NULL;
+ tp->tx_buffers[tp->cur_tx].mapping = mapping;
+
+@@ -642,8 +653,10 @@ static void tulip_init_ring(struct net_d
+ tp->rx_buffers[i].skb = skb;
+ if (skb == NULL)
+ break;
++#ifdef CONFIG_TULIP_PCI
+ mapping = pci_map_single(tp->pdev, skb->data,
+ PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
++#endif
+ tp->rx_buffers[i].mapping = mapping;
+ skb->dev = dev; /* Mark as being used by this device. */
+ tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
+@@ -677,8 +690,10 @@ tulip_start_xmit(struct sk_buff *skb, st
+ entry = tp->cur_tx % TX_RING_SIZE;
+
+ tp->tx_buffers[entry].skb = skb;
++#ifdef CONFIG_TULIP_PCI
+ mapping = pci_map_single(tp->pdev, skb->data,
+ skb->len, PCI_DMA_TODEVICE);
++#endif
+ tp->tx_buffers[entry].mapping = mapping;
+ tp->tx_ring[entry].buffer1 = cpu_to_le32(mapping);
+
+@@ -729,16 +744,19 @@ static void tulip_clean_tx_ring(struct t
+ if (tp->tx_buffers[entry].skb == NULL) {
+ /* test because dummy frames not mapped */
+ if (tp->tx_buffers[entry].mapping)
++#ifdef CONFIG_TULIP_PCI
+ pci_unmap_single(tp->pdev,
+ tp->tx_buffers[entry].mapping,
+ sizeof(tp->setup_frame),
+ PCI_DMA_TODEVICE);
++#endif
+ continue;
+ }
+-
++#ifdef CONFIG_TULIP_PCI
+ pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
+ tp->tx_buffers[entry].skb->len,
+ PCI_DMA_TODEVICE);
++#endif
+
+ /* Free the original skb. */
+ dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
+@@ -789,7 +807,9 @@ static void tulip_down (struct net_devic
+ dev->if_port = tp->saved_if_port;
+
+ /* Leave the driver in snooze, not sleep, mode. */
++#ifdef CONFIG_TULIP_PCI
+ tulip_set_power_state (tp, 0, 1);
++#endif
+ }
+
+ static void tulip_free_ring (struct net_device *dev)
+@@ -810,8 +830,10 @@ static void tulip_free_ring (struct net_
+ /* An invalid address. */
+ tp->rx_ring[i].buffer1 = cpu_to_le32(0xBADF00D0);
+ if (skb) {
++#ifdef CONFIG_TULIP_PCI
+ pci_unmap_single(tp->pdev, mapping, PKT_BUF_SZ,
+ PCI_DMA_FROMDEVICE);
++#endif
+ dev_kfree_skb (skb);
+ }
+ }
+@@ -820,8 +842,10 @@ static void tulip_free_ring (struct net_
+ struct sk_buff *skb = tp->tx_buffers[i].skb;
+
+ if (skb != NULL) {
++#ifdef CONFIG_TULIP_PCI
+ pci_unmap_single(tp->pdev, tp->tx_buffers[i].mapping,
+ skb->len, PCI_DMA_TODEVICE);
++#endif
+ dev_kfree_skb (skb);
+ }
+ tp->tx_buffers[i].skb = NULL;
+@@ -873,7 +897,9 @@ static void tulip_get_drvinfo(struct net
+ struct tulip_private *np = netdev_priv(dev);
+ strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
+ strlcpy(info->version, DRV_VERSION, sizeof(info->version));
++#ifdef CONFIG_TULIP_PCI
+ strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
++#endif
+ }
+
+
+@@ -886,7 +912,9 @@ static int tulip_ethtool_set_wol(struct
+ return -EOPNOTSUPP;
+
+ tp->wolinfo.wolopts = wolinfo->wolopts;
++#ifdef CONFIG_TULIP_PCI
+ device_set_wakeup_enable(&tp->pdev->dev, tp->wolinfo.wolopts);
++#endif
+ return 0;
+ }
+
+@@ -1167,9 +1195,11 @@ static void set_rx_mode(struct net_devic
+
+ tp->tx_buffers[entry].skb = NULL;
+ tp->tx_buffers[entry].mapping =
++#ifdef CONFIG_TULIP_PCI
+ pci_map_single(tp->pdev, tp->setup_frame,
+ sizeof(tp->setup_frame),
+ PCI_DMA_TODEVICE);
++#endif
+ /* Put the setup frame on the Tx list. */
+ if (entry == TX_RING_SIZE-1)
+ tx_flags |= DESC_RING_WRAP; /* Wrap ring. */
+@@ -1267,19 +1297,22 @@ out:
+ netdev_dbg(dev, "MWI config cacheline=%d, csr0=%08x\n",
+ cache, csr0);
+ }
+-#endif
+
+ /*
+ * Chips that have the MRM/reserved bit quirk and the burst quirk. That
+ * is the DM910X and the on chip ULi devices
+ */
++#endif
+
++#ifdef CONFIG_TULIP_PCI
+ static int tulip_uli_dm_quirk(struct pci_dev *pdev)
+ {
+ if (pdev->vendor == 0x1282 && pdev->device == 0x9102)
+ return 1;
+ return 0;
+ }
++#endif
++
+
+ static const struct net_device_ops tulip_netdev_ops = {
+ .ndo_open = tulip_open,
+@@ -1297,6 +1330,7 @@ static const struct net_device_ops tulip
+ #endif
+ };
+
++#ifdef CONFIG_TULIP_PCI
+ DEFINE_PCI_DEVICE_TABLE(early_486_chipsets) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82424) },
+ { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496) },
+@@ -1814,6 +1848,7 @@ err_out_free_netdev:
+ }
+
+
++#ifdef CONFIG_TULIP_PCI
+ /* set the registers according to the given wolopts */
+ static void tulip_set_wolopts (struct pci_dev *pdev, u32 wolopts)
+ {
+@@ -1842,6 +1877,7 @@ static void tulip_set_wolopts (struct pc
+ iowrite32(tmp, ioaddr + CSR13);
+ }
+ }
++#endif
+
+ #ifdef CONFIG_PM
+
+@@ -1953,6 +1989,7 @@ static void __devexit tulip_remove_one (
+
+ /* pci_power_off (pdev, -1); */
+ }
++#endif /* CONFIG_TULIP_PCI */
+
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+ /*
+@@ -1971,7 +2008,8 @@ static void poll_tulip (struct net_devic
+ }
+ #endif
+
+-static struct pci_driver tulip_driver = {
++#ifdef CONFIG_TULIP_PCI
++static struct pci_driver tulip_pci_driver = {
+ .name = DRV_NAME,
+ .id_table = tulip_pci_tbl,
+ .probe = tulip_init_one,
+@@ -1981,10 +2019,12 @@ static struct pci_driver tulip_driver =
+ .resume = tulip_resume,
+ #endif /* CONFIG_PM */
+ };
++#endif
+
+
+ static int __init tulip_init (void)
+ {
++ int ret = 0;
+ #ifdef MODULE
+ pr_info("%s", version);
+ #endif
+@@ -1994,13 +2034,18 @@ static int __init tulip_init (void)
+ tulip_max_interrupt_work = max_interrupt_work;
+
+ /* probe for and init boards */
+- return pci_register_driver(&tulip_driver);
++#ifdef CONFIG_TULIP_PCI
++ ret = pci_register_driver(&tulip_pci_driver);
++#endif
++ return ret;
+ }
+
+
+ static void __exit tulip_cleanup (void)
+ {
+- pci_unregister_driver (&tulip_driver);
++#ifdef CONFIG_TULIP_PCI
++ pci_unregister_driver (&tulip_pci_driver);
++#endif
+ }
+
+
+--- a/drivers/net/ethernet/dec/tulip/interrupt.c
++++ b/drivers/net/ethernet/dec/tulip/interrupt.c
+@@ -72,9 +72,10 @@ int tulip_refill_rx(struct net_device *d
+ skb = tp->rx_buffers[entry].skb = dev_alloc_skb(PKT_BUF_SZ);
+ if (skb == NULL)
+ break;
+-
++#ifdef CONFIG_TULIP_PCI
+ mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
+ PCI_DMA_FROMDEVICE);
++#endif
+ tp->rx_buffers[entry].mapping = mapping;
+
+ skb->dev = dev; /* Mark as being used by this device. */
+@@ -204,9 +205,11 @@ int tulip_poll(struct napi_struct *napi,
+ if (pkt_len < tulip_rx_copybreak &&
+ (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
+ skb_reserve(skb, 2); /* 16 byte align the IP header */
++#ifdef CONFIG_TULIP_PCI
+ pci_dma_sync_single_for_cpu(tp->pdev,
+ tp->rx_buffers[entry].mapping,
+ pkt_len, PCI_DMA_FROMDEVICE);
++#endif
+ #if ! defined(__alpha__)
+ skb_copy_to_linear_data(skb, tp->rx_buffers[entry].skb->data,
+ pkt_len);
+@@ -216,9 +219,11 @@ int tulip_poll(struct napi_struct *napi,
+ tp->rx_buffers[entry].skb->data,
+ pkt_len);
+ #endif
++#ifdef CONFIG_TULIP_PCI
+ pci_dma_sync_single_for_device(tp->pdev,
+ tp->rx_buffers[entry].mapping,
+ pkt_len, PCI_DMA_FROMDEVICE);
++#endif
+ } else { /* Pass up the skb already on the Rx ring. */
+ char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
+ pkt_len);
+@@ -233,9 +238,10 @@ int tulip_poll(struct napi_struct *napi,
+ skb->head, temp);
+ }
+ #endif
+-
++#ifdef CONFIG_TULIP_PCI
+ pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
+ PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
++#endif
+
+ tp->rx_buffers[entry].skb = NULL;
+ tp->rx_buffers[entry].mapping = 0;
+@@ -591,10 +597,12 @@ irqreturn_t tulip_interrupt(int irq, voi
+ if (tp->tx_buffers[entry].skb == NULL) {
+ /* test because dummy frames not mapped */
+ if (tp->tx_buffers[entry].mapping)
++#ifdef CONFIG_TULIP_PCI
+ pci_unmap_single(tp->pdev,
+ tp->tx_buffers[entry].mapping,
+ sizeof(tp->setup_frame),
+ PCI_DMA_TODEVICE);
++#endif
+ continue;
+ }
+
+@@ -622,10 +630,11 @@ irqreturn_t tulip_interrupt(int irq, voi
+ dev->stats.collisions += (status >> 3) & 15;
+ dev->stats.tx_packets++;
+ }
+-
++#ifdef CONFIG_TULIP_PCI
+ pci_unmap_single(tp->pdev, tp->tx_buffers[entry].mapping,
+ tp->tx_buffers[entry].skb->len,
+ PCI_DMA_TODEVICE);
++#endif
+
+ /* Free the original skb. */
+ dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
+--- a/drivers/net/ethernet/dec/tulip/Kconfig
++++ b/drivers/net/ethernet/dec/tulip/Kconfig
+@@ -40,8 +40,12 @@ config DE2104X_DSL
+ Default is 0, and range is 0 to 31.
+
+ config TULIP
++ tristate
++
++config TULIP_PCI
+ tristate "DECchip Tulip (dc2114x) PCI support"
+ depends on PCI
++ select TULIP
+ select CRC32
+ ---help---
+ This driver is developed for the SMC EtherPower series Ethernet
+@@ -58,7 +62,7 @@ config TULIP
+
+ config TULIP_MWI
+ bool "New bus configuration (EXPERIMENTAL)"
+- depends on TULIP && EXPERIMENTAL
++ depends on TULIP_PCI && EXPERIMENTAL
+ ---help---
+ This configures your Tulip card specifically for the card and
+ system cache line size type you are using.
+@@ -69,7 +73,7 @@ config TULIP_MWI
+
+ config TULIP_MMIO
+ bool "Use PCI shared mem for NIC registers"
+- depends on TULIP
++ depends on TULIP_PCI
+ ---help---
+ Use PCI shared memory for the NIC registers, rather than going through
+ the Tulip's PIO (programmed I/O ports). Faster, but could produce
diff --git a/target/linux/adm8668/patches-3.3/005-tulip_platform.patch b/target/linux/adm8668/patches-3.3/005-tulip_platform.patch
new file mode 100644
index 0000000000..c9aa5e5813
--- /dev/null
+++ b/target/linux/adm8668/patches-3.3/005-tulip_platform.patch
@@ -0,0 +1,451 @@
+--- a/drivers/net/ethernet/dec/tulip/Kconfig
++++ b/drivers/net/ethernet/dec/tulip/Kconfig
+@@ -60,6 +60,14 @@ config TULIP_PCI
+ To compile this driver as a module, choose M here. The module will
+ be called tulip.
+
++config TULIP_PLATFORM
++ tristate "DECchip Tulip (dc2114x) Platform support"
++ depends on HAS_IOMEM
++ select TULIP
++ select CRC32
++ ---help---
++ This driver is for the platform variant.
++
+ config TULIP_MWI
+ bool "New bus configuration (EXPERIMENTAL)"
+ depends on TULIP_PCI && EXPERIMENTAL
+--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
++++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
+@@ -27,6 +27,8 @@
+ #include <linux/init.h>
+ #include <linux/interrupt.h>
+ #include <linux/etherdevice.h>
++#include <linux/platform_device.h>
++#include <linux/platform_data/tulip.h>
+ #include <linux/delay.h>
+ #include <linux/mii.h>
+ #include <linux/crc32.h>
+@@ -204,6 +206,9 @@ struct tulip_chip_table tulip_tbl[] = {
+ { "Conexant LANfinity", 256, 0x0001ebef,
+ HAS_MII | HAS_ACPI, tulip_timer, tulip_media_task },
+
++ { "Infineon ADM8668", 256, 0x0001a451,
++ MC_HASH_ONLY | COMET_MAC_ADDR, tulip_timer, tulip_media_task, },
++
+ };
+
+ #ifdef CONFIG_TULIP_PCI
+@@ -395,6 +400,7 @@ static void tulip_up(struct net_device *
+ i = 0;
+ if (tp->mtable == NULL)
+ goto media_picked;
++
+ if (dev->if_port) {
+ int looking_for = tulip_media_cap[dev->if_port] & MediaIsMII ? 11 :
+ (dev->if_port == 12 ? 0 : dev->if_port);
+@@ -488,6 +494,10 @@ media_picked:
+ iowrite32(ioread32(ioaddr + 0x88) | 1, ioaddr + 0x88);
+ dev->if_port = tp->mii_cnt ? 11 : 0;
+ tp->csr6 = 0x00040000;
++ } else if (tp->chip_id == ADM8668) {
++ /* Enable automatic Tx underrun recovery. */
++ iowrite32(ioread32(ioaddr + 0x88) | 1, ioaddr + 0x88);
++ tp->csr6 = 0x00040000;
+ } else if (tp->chip_id == AX88140) {
+ tp->csr6 = tp->mii_cnt ? 0x00040100 : 0x00000100;
+ } else
+@@ -657,6 +667,10 @@ static void tulip_init_ring(struct net_d
+ mapping = pci_map_single(tp->pdev, skb->data,
+ PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ mapping = dma_map_single(&tp->pldev->dev, skb->data,
++ PKT_BUF_SZ, DMA_FROM_DEVICE);
++#endif
+ tp->rx_buffers[i].mapping = mapping;
+ skb->dev = dev; /* Mark as being used by this device. */
+ tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
+@@ -694,6 +708,11 @@ tulip_start_xmit(struct sk_buff *skb, st
+ mapping = pci_map_single(tp->pdev, skb->data,
+ skb->len, PCI_DMA_TODEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ mapping = dma_map_single(&tp->pldev->dev, skb->data,
++ skb->len,
++ DMA_TO_DEVICE);
++#endif
+ tp->tx_buffers[entry].mapping = mapping;
+ tp->tx_ring[entry].buffer1 = cpu_to_le32(mapping);
+
+@@ -757,6 +776,11 @@ static void tulip_clean_tx_ring(struct t
+ tp->tx_buffers[entry].skb->len,
+ PCI_DMA_TODEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[entry].mapping,
++ tp->tx_buffers[entry].skb->len,
++ DMA_TO_DEVICE);
++#endif
+
+ /* Free the original skb. */
+ dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
+@@ -834,6 +858,10 @@ static void tulip_free_ring (struct net_
+ pci_unmap_single(tp->pdev, mapping, PKT_BUF_SZ,
+ PCI_DMA_FROMDEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ dma_unmap_single(&tp->pldev->dev, mapping, PKT_BUF_SZ,
++ DMA_FROM_DEVICE);
++#endif
+ dev_kfree_skb (skb);
+ }
+ }
+@@ -846,6 +874,10 @@ static void tulip_free_ring (struct net_
+ pci_unmap_single(tp->pdev, tp->tx_buffers[i].mapping,
+ skb->len, PCI_DMA_TODEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[i].mapping,
++ skb->len, DMA_TO_DEVICE);
++#endif
+ dev_kfree_skb (skb);
+ }
+ tp->tx_buffers[i].skb = NULL;
+@@ -900,6 +932,9 @@ static void tulip_get_drvinfo(struct net
+ #ifdef CONFIG_TULIP_PCI
+ strlcpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info));
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ strlcpy(info->bus_info, "platform", sizeof(info->bus_info));
++#endif
+ }
+
+
+@@ -915,6 +950,9 @@ static int tulip_ethtool_set_wol(struct
+ #ifdef CONFIG_TULIP_PCI
+ device_set_wakeup_enable(&tp->pdev->dev, tp->wolinfo.wolopts);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ device_set_wakeup_enable(&tp->pldev->dev, tp->wolinfo.wolopts);
++#endif
+ return 0;
+ }
+
+@@ -1193,9 +1231,9 @@ static void set_rx_mode(struct net_devic
+
+ }
+
++#ifdef CONFIG_TULIP_PCI
+ tp->tx_buffers[entry].skb = NULL;
+ tp->tx_buffers[entry].mapping =
+-#ifdef CONFIG_TULIP_PCI
+ pci_map_single(tp->pdev, tp->setup_frame,
+ sizeof(tp->setup_frame),
+ PCI_DMA_TODEVICE);
+@@ -1219,6 +1257,9 @@ static void set_rx_mode(struct net_devic
+ spin_unlock_irqrestore(&tp->lock, flags);
+ }
+
++ if (tp->chip_id == ADM8668)
++ csr6 |= (1 << 9); /* force 100Mbps full duplex */
++
+ iowrite32(csr6, ioaddr + CSR6);
+ }
+
+@@ -1991,6 +2032,124 @@ static void __devexit tulip_remove_one (
+ }
+ #endif /* CONFIG_TULIP_PCI */
+
++#ifdef CONFIG_TULIP_PLATFORM
++static int __devinit tulip_probe(struct platform_device *pdev)
++{
++ struct tulip_private *tp;
++ struct tulip_platform_data *pdata;
++ struct net_device *dev;
++ struct resource *res;
++ void __iomem *ioaddr;
++ int irq;
++
++ if (pdev->id < 0 || pdev->id >= MAX_UNITS)
++ return -EINVAL;
++
++ if (!(res = platform_get_resource(pdev, IORESOURCE_IRQ, 0)))
++ return -ENODEV;
++ irq = res->start;
++ if (!(res = platform_get_resource(pdev, IORESOURCE_MEM, 0)))
++ return -ENODEV;
++ if (!(ioaddr = ioremap(res->start, res->end - res->start)))
++ return -ENODEV;
++
++ pdata = pdev->dev.platform_data;
++ if (!pdata)
++ return -ENODEV;
++
++ if (!(dev = alloc_etherdev(sizeof (*tp))))
++ return -ENOMEM;
++
++ /* setup net dev */
++ dev->base_addr = (unsigned long)res->start;
++ dev->irq = irq;
++ SET_NETDEV_DEV(dev, &pdev->dev);
++
++ /* tulip private struct */
++ tp = netdev_priv(dev);
++ tp->dev = dev;
++ tp->base_addr = ioaddr;
++ tp->csr0 = 0;
++ tp->pldev = pdev;
++ tp->rx_ring = dma_alloc_coherent(&pdev->dev,
++ sizeof(struct tulip_rx_desc) * RX_RING_SIZE +
++ sizeof(struct tulip_tx_desc) * TX_RING_SIZE,
++ &tp->rx_ring_dma, GFP_KERNEL);
++ if (!tp->rx_ring)
++ return -ENODEV;
++ tp->tx_ring = (struct tulip_tx_desc *)(tp->rx_ring + RX_RING_SIZE);
++ tp->tx_ring_dma = tp->rx_ring_dma + sizeof(struct tulip_rx_desc) * RX_RING_SIZE;
++
++ tp->chip_id = pdata->chip_id;
++ tp->flags = tulip_tbl[tp->chip_id].flags;
++
++ spin_lock_init(&tp->lock);
++ spin_lock_init(&tp->mii_lock);
++
++ init_timer(&tp->timer);
++ tp->timer.data = (unsigned long)dev;
++ tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
++
++ INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
++
++ /* Stop the chip's Tx and Rx processes. */
++ tulip_stop_rxtx(tp);
++
++ /* Clear the missed-packet counter. */
++ ioread32(ioaddr + CSR8);
++
++ if (!is_valid_ether_addr(pdata->mac)) {
++ dev_info(&pdev->dev, "generating random ethernet MAC\n");
++ random_ether_addr(dev->dev_addr);
++ } else
++ memcpy(dev->dev_addr, pdata->mac, ETH_ALEN);
++
++ /* The Tulip-specific entries in the device structure. */
++ dev->netdev_ops = &tulip_netdev_ops;
++ dev->watchdog_timeo = TX_TIMEOUT;
++ netif_napi_add(dev, &tp->napi, tulip_poll, 16);
++ SET_ETHTOOL_OPS(dev, &ops);
++
++ if (register_netdev(dev))
++ goto err_out_free_ring;
++
++ dev_info(&dev->dev,
++ "tulip_platform (%s) at MMIO %#lx %pM, IRQ %d\n",
++ tulip_tbl[tp->chip_id].chip_name,
++ (unsigned long)dev->base_addr, dev->dev_addr, irq);
++
++ platform_set_drvdata(pdev, dev);
++ return 0;
++
++err_out_free_ring:
++ dma_free_coherent(&pdev->dev,
++ sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
++ sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
++ tp->rx_ring, tp->rx_ring_dma);
++ return -ENODEV;
++}
++
++static int __devexit tulip_remove(struct platform_device *pdev)
++{
++ struct net_device *dev = platform_get_drvdata (pdev);
++ struct tulip_private *tp;
++
++ if (!dev)
++ return -ENODEV;
++
++ tp = netdev_priv(dev);
++ unregister_netdev(dev);
++ dma_free_coherent(&pdev->dev,
++ sizeof (struct tulip_rx_desc) * RX_RING_SIZE +
++ sizeof (struct tulip_tx_desc) * TX_RING_SIZE,
++ tp->rx_ring, tp->rx_ring_dma);
++ iounmap(tp->base_addr);
++ free_netdev(dev);
++ platform_set_drvdata(pdev, NULL);
++ return 0;
++}
++#endif
++
+ #ifdef CONFIG_NET_POLL_CONTROLLER
+ /*
+ * Polling 'interrupt' - used by things like netconsole to send skbs
+@@ -2021,6 +2180,17 @@ static struct pci_driver tulip_pci_drive
+ };
+ #endif
+
++#ifdef CONFIG_TULIP_PLATFORM
++static struct platform_driver tulip_platform_driver = {
++ .probe = tulip_probe,
++ .remove = __devexit_p(tulip_remove),
++ .driver = {
++ .owner = THIS_MODULE,
++ .name = DRV_NAME,
++ },
++};
++#endif
++
+
+ static int __init tulip_init (void)
+ {
+@@ -2037,6 +2207,9 @@ static int __init tulip_init (void)
+ #ifdef CONFIG_TULIP_PCI
+ ret = pci_register_driver(&tulip_pci_driver);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ ret = platform_driver_register(&tulip_platform_driver);
++#endif
+ return ret;
+ }
+
+@@ -2046,6 +2219,9 @@ static void __exit tulip_cleanup (void)
+ #ifdef CONFIG_TULIP_PCI
+ pci_unregister_driver (&tulip_pci_driver);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ platform_driver_unregister (&tulip_platform_driver);
++#endif
+ }
+
+
+--- a/drivers/net/ethernet/dec/tulip/tulip.h
++++ b/drivers/net/ethernet/dec/tulip/tulip.h
+@@ -21,6 +21,8 @@
+ #include <linux/timer.h>
+ #include <linux/delay.h>
+ #include <linux/pci.h>
++#include <linux/platform_device.h>
++#include <linux/platform_data/tulip.h>
+ #include <asm/io.h>
+ #include <asm/irq.h>
+ #include <asm/unaligned.h>
+@@ -69,28 +71,6 @@ enum tbl_flag {
+ };
+
+
+-/* chip types. careful! order is VERY IMPORTANT here, as these
+- * are used throughout the driver as indices into arrays */
+-/* Note 21142 == 21143. */
+-enum chips {
+- DC21040 = 0,
+- DC21041 = 1,
+- DC21140 = 2,
+- DC21142 = 3, DC21143 = 3,
+- LC82C168,
+- MX98713,
+- MX98715,
+- MX98725,
+- AX88140,
+- PNIC2,
+- COMET,
+- COMPEX9881,
+- I21145,
+- DM910X,
+- CONEXANT,
+-};
+-
+-
+ enum MediaIs {
+ MediaIsFD = 1,
+ MediaAlwaysFD = 2,
+@@ -446,7 +426,12 @@ struct tulip_private {
+ struct mediatable *mtable;
+ int cur_index; /* Current media index. */
+ int saved_if_port;
++#ifdef CONFIG_TULIP_PCI
+ struct pci_dev *pdev;
++#endif
++#ifdef CONFIG_TULIP_PLATFORM
++ struct platform_device *pldev;
++#endif
+ int ttimer;
+ int susp_rx;
+ unsigned long nir;
+--- a/drivers/net/ethernet/dec/tulip/interrupt.c
++++ b/drivers/net/ethernet/dec/tulip/interrupt.c
+@@ -76,6 +76,10 @@ int tulip_refill_rx(struct net_device *d
+ mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
+ PCI_DMA_FROMDEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ mapping = dma_map_single(&tp->pldev->dev, skb->data, PKT_BUF_SZ,
++ DMA_FROM_DEVICE);
++#endif
+ tp->rx_buffers[entry].mapping = mapping;
+
+ skb->dev = dev; /* Mark as being used by this device. */
+@@ -198,8 +202,7 @@ int tulip_poll(struct napi_struct *napi,
+ dev->stats.rx_fifo_errors++;
+ }
+ } else {
+- struct sk_buff *skb;
+-
++ struct sk_buff *skb;
+ /* Check if the packet is long enough to accept without copying
+ to a minimally-sized skbuff. */
+ if (pkt_len < tulip_rx_copybreak &&
+@@ -242,6 +245,10 @@ int tulip_poll(struct napi_struct *napi,
+ pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
+ PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ dma_unmap_single(&tp->pldev->dev, tp->rx_buffers[entry].mapping,
++ PKT_BUF_SZ, DMA_FROM_DEVICE);
++#endif
+
+ tp->rx_buffers[entry].skb = NULL;
+ tp->rx_buffers[entry].mapping = 0;
+@@ -635,6 +642,11 @@ irqreturn_t tulip_interrupt(int irq, voi
+ tp->tx_buffers[entry].skb->len,
+ PCI_DMA_TODEVICE);
+ #endif
++#ifdef CONFIG_TULIP_PLATFORM
++ dma_unmap_single(&tp->pldev->dev, tp->tx_buffers[entry].mapping,
++ tp->tx_buffers[entry].skb->len,
++ DMA_TO_DEVICE);
++#endif
+
+ /* Free the original skb. */
+ dev_kfree_skb_irq(tp->tx_buffers[entry].skb);
+--- /dev/null
++++ b/include/linux/platform_data/tulip.h
+@@ -0,0 +1,31 @@
++#ifndef _LINUX_TULIP_PDATA_H
++#define _LINUX_TULIP_PDATA_H
++
++/* chip types. careful! order is VERY IMPORTANT here, as these
++ * are used throughout the driver as indices into arrays */
++/* Note 21142 == 21143. */
++enum chips {
++ DC21040 = 0,
++ DC21041 = 1,
++ DC21140 = 2,
++ DC21142 = 3, DC21143 = 3,
++ LC82C168,
++ MX98713,
++ MX98715,
++ MX98725,
++ AX88140,
++ PNIC2,
++ COMET,
++ COMPEX9881,
++ I21145,
++ DM910X,
++ CONEXANT,
++ ADM8668,
++};
++
++struct tulip_platform_data {
++ u8 mac[6];
++ enum chips chip_id;
++};
++
++#endif