* [PATCH 01/14] m68k/atari EtherNEC: remove original EtherNEC driver
2013-03-25 1:16 (unknown), Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 02/14] m68k/atari EtherNAT: remove original EtherNAT driver Michael Schmitz
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
drivers/net/Space.c | 4 -
drivers/net/ethernet/8390/Kconfig | 8 -
drivers/net/ethernet/8390/Makefile | 1 -
drivers/net/ethernet/8390/atari_ethernec.c | 1008 ----------------------------
4 files changed, 0 insertions(+), 1021 deletions(-)
delete mode 100644 drivers/net/ethernet/8390/atari_ethernec.c
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index 9060424..3a8c753 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -47,7 +47,6 @@ extern struct net_device *ni65_probe(int unit);
extern struct net_device *sonic_probe(int unit);
extern struct net_device *smc_init(int unit);
extern struct net_device *atarilance_probe(int unit);
-extern struct net_device *atari_ethernec_probe(int unit);
extern struct net_device *sun3lance_probe(int unit);
extern struct net_device *sun3_82586_probe(int unit);
extern struct net_device *apne_probe(int unit);
@@ -131,9 +130,6 @@ static struct devprobe2 m68k_probes[] __initdata = {
#ifdef CONFIG_ATARILANCE /* Lance-based Atari ethernet boards */
{atarilance_probe, 0},
#endif
-#ifdef CONFIG_ATARI_ETHERNEC /* NE2000 based ROM port ethernet cards */
- {atari_ethernec_probe, 0},
-#endif
#ifdef CONFIG_SUN3LANCE /* sun3 onboard Lance chip */
{sun3lance_probe, 0},
#endif
diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index 1b41983..a5f91e1 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -135,14 +135,6 @@ config APNE
To compile this driver as a module, choose M here: the module
will be called apne.
-config ATARI_ETHERNEC
- tristate "Atari EtherNEC Ethernet support"
- depends on ATARI_ROM_ISA
- help
- Say Y to include support for the EtherNEC network adapter for the
- ROM port. The driver works by polling instead of interrupts, so it
- is quite slow.
-
config PCMCIA_PCNET
tristate "NE2000 compatible PCMCIA support"
depends on PCMCIA
diff --git a/drivers/net/ethernet/8390/Makefile b/drivers/net/ethernet/8390/Makefile
index 150728b..588954a 100644
--- a/drivers/net/ethernet/8390/Makefile
+++ b/drivers/net/ethernet/8390/Makefile
@@ -5,7 +5,6 @@
obj-$(CONFIG_MAC8390) += mac8390.o
obj-$(CONFIG_APNE) += apne.o 8390.o
obj-$(CONFIG_ARM_ETHERH) += etherh.o
-obj-$(CONFIG_ATARI_ETHERNEC) += atari_ethernec.o 8390.o
obj-$(CONFIG_AX88796) += ax88796.o
obj-$(CONFIG_HYDRA) += hydra.o 8390.o
obj-$(CONFIG_MCF8390) += mcf8390.o 8390.o
diff --git a/drivers/net/ethernet/8390/atari_ethernec.c b/drivers/net/ethernet/8390/atari_ethernec.c
deleted file mode 100644
index 4b1b953..0000000
--- a/drivers/net/ethernet/8390/atari_ethernec.c
+++ /dev/null
@@ -1,1008 +0,0 @@
-/*
- * atari_ethernec.c: Atari cartridge port ethernet adapter
- * (C) 2006 Michael Schmitz
- *
- * Modified after:
- */
-
-/* ne.c: A general non-shared-memory NS8390 ethernet driver for linux. */
-/*
- Written 1992-94 by Donald Becker.
-
- Copyright 1993 United States Government as represented by the
- Director, National Security Agency.
-
- This software may be used and distributed according to the terms
- of the GNU General Public License, incorporated herein by reference.
-
- The author may be reached as becker@scyld.com, or C/O
- Scyld Computing Corporation, 410 Severn Ave., Suite 210, Annapolis MD 21403
-
- This driver should work with many programmed-I/O 8390-based ethernet
- boards. Currently it supports the NE1000, NE2000, many clones,
- and some Cabletron products.
-
- Changelog:
-
- Paul Gortmaker : use ENISR_RDC to monitor Tx PIO uploads, made
- sanity checks and bad clone support optional.
- Paul Gortmaker : new reset code, reset card after probe at boot.
- Paul Gortmaker : multiple card support for module users.
- Paul Gortmaker : Support for PCI ne2k clones, similar to lance.c
- Paul Gortmaker : Allow users with bad cards to avoid full probe.
- Paul Gortmaker : PCI probe changes, more PCI cards supported.
- rjohnson@analogic.com : Changed init order so an interrupt will only
- occur after memory is allocated for dev->priv. Deallocated memory
- last in cleanup_modue()
- Richard Guenther : Added support for ISAPnP cards
- Paul Gortmaker : Discontinued PCI support - use ne2k-pci.c instead.
- Hayato Fujiwara : Add m32r support.
-
-*/
-
-/*
- * From the driver distribution kit by Thomas Redelberger:
- *
- * Hardware circuit description (see directory ETHERNEC for schematics)
- *
- * As there is no reset line on the CP, a resistor and a capacitor are
- * used to reset the NE card on power up.
- *
- * Reading from the NE card is done by a read cycle on the CP at address
- * /ROM4 + 512*ISA address as the ISA address lines A0-A4 are connected
- * to CP A9-A13. /ROM4 going low will start the ISA read cycle, enable
- * the ISA bus buffers of the NE card and start decoding of the ISA IO
- * address by the NE card. /ROM4 going high ends the cycle and the
- * processor latches the data.
- *
- * Because the CP is read only writing to the NE card must be done with
- * the trick to read from addresses that stand for the data. Dummy reads
- * at /ROM3 base address + data*2 + ISA address*512 effect this. You
- * might wonder why everything appears to be shifted up one bit. There is
- * no CP "A0" address line. There are the signals /UDS and /LDS instead
- * typical for the 68000 family. The original design which generated an
- * "A0" worked on an ST and an STE but did not on a Falcon.
- *
- * The falling edge of /ROM3 enables the CP address lines A1-A8 onto the
- * data bus and starts the ISA write cycle. The rising edge will end the
- * ISA write cycle and the NE latches the data. The processor will also
- * see and just read this same data but that is harmless.
- * Elmar Hilgart reported that the bus buffer IC shall be an TTL F-type
- * to keep up with the fast cycles on the Falcon.
- *
- * Base addresses:
- * rom4 EQU $00fa0000 ; ROM4 base address
- * rom3 EQU $00fb0000 ; ROM3 base address
- *
- */
-
-/* Routines for the NatSemi-based designs (NE[12]000). */
-
-static const char version1[] =
-"ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)\n";
-static const char version2[] =
-"atari_ethernec.c 11/10/06 Michael Schmitz (schmitz@debian.org)\n";
-
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/isapnp.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/jiffies.h>
-#include <linux/workqueue.h>
-
-#include <asm/atarihw.h>
-#include <asm/atariints.h>
-#include <asm/io.h>
-
-#include "8390.h"
-
-#define DRV_NAME "ethernec"
-
-/* Some defines that people can play with if so inclined. */
-
-/* Do we support clones that don't adhere to 14,15 of the SAprom ? */
-#define SUPPORT_NE_BAD_CLONES
-
-/* Do we perform extra sanity checks on stuff ? */
-/* #define NE_SANITY_CHECK */
-
-/* Do we implement the read before write bugfix ? */
-/* #define NE_RW_BUGFIX */
-
-/* Do we have a non std. amount of memory? (in units of 256 byte pages) */
-/* #define PACKETBUF_MEMSIZE 0x40 */
-
-/* A zero-terminated list of I/O addresses to be probed at boot. */
-#ifndef MODULE
-static unsigned int netcard_portlist[] __initdata = {
- 0x300, 0
-};
-#endif
-
-static struct isapnp_device_id isapnp_clone_list[] __initdata = {
- { ISAPNP_CARD_ID('A','X','E',0x2011),
- ISAPNP_VENDOR('A','X','E'), ISAPNP_FUNCTION(0x2011),
- (long) "NetGear EA201" },
- { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
- ISAPNP_VENDOR('E','D','I'), ISAPNP_FUNCTION(0x0216),
- (long) "NN NE2000" },
- { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
- ISAPNP_VENDOR('P','N','P'), ISAPNP_FUNCTION(0x80d6),
- (long) "Generic PNP" },
- { } /* terminate list */
-};
-
-MODULE_DEVICE_TABLE(isapnp, isapnp_clone_list);
-
-#ifdef SUPPORT_NE_BAD_CLONES
-/* A list of bad clones that we none-the-less recognize. */
-static struct { const char *name8, *name16; unsigned char SAprefix[4];}
-bad_clone_list[] __initdata = {
- {"DE100", "DE200", {0x00, 0xDE, 0x01,}},
- {"DE120", "DE220", {0x00, 0x80, 0xc8,}},
- {"DFI1000", "DFI2000", {'D', 'F', 'I',}}, /* Original, eh? */
- {"EtherNext UTP8", "EtherNext UTP16", {0x00, 0x00, 0x79}},
- {"NE1000","NE2000-invalid", {0x00, 0x00, 0xd8}}, /* Ancient real NE1000. */
- {"NN1000", "NN2000", {0x08, 0x03, 0x08}}, /* Outlaw no-name clone. */
- {"4-DIM8","4-DIM16", {0x00,0x00,0x4d,}}, /* Outlaw 4-Dimension cards. */
- {"Con-Intl_8", "Con-Intl_16", {0x00, 0x00, 0x24}}, /* Connect Int'nl */
- {"ET-100","ET-200", {0x00, 0x45, 0x54}}, /* YANG and YA clone */
- {"COMPEX","COMPEX16",{0x00,0x80,0x48}}, /* Broken ISA Compex cards */
- {"E-LAN100", "E-LAN200", {0x00, 0x00, 0x5d}}, /* Broken ne1000 clones */
- {"PCM-4823", "PCM-4823", {0x00, 0xc0, 0x6c}}, /* Broken Advantech MoBo */
- {"REALTEK", "RTL8019", {0x00, 0x00, 0xe8}}, /* no-name with Realtek chip */
-#if defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938)
- {"RBHMA4X00-RTL8019", "RBHMA4X00/RTL8019", {0x00, 0x60, 0x0a}}, /* Toshiba built-in */
-#endif
- {"LCS-8834", "LCS-8836", {0x04, 0x04, 0x37}}, /* ShinyNet (SET) */
- {NULL,}
-};
-#endif
-
-/* ---- No user-serviceable parts below ---- */
-
-#define NE_BASE (dev->base_addr)
-#define NE_CMD 0x00
-#define NE_DATAPORT 0x10 /* NatSemi-defined port window offset. */
-#define NE_RESET 0x1f /* Issue a read to reset, a write to clear. */
-#define NE_IO_EXTENT 0x20
-
-#define NE1SM_START_PG 0x20 /* First page of TX buffer */
-#define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */
-#define NESM_START_PG 0x40 /* First page of TX buffer */
-#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
-
-#if defined(CONFIG_PLAT_MAPPI)
-# define DCR_VAL 0x4b
-#elif defined(CONFIG_PLAT_OAKS32R) || \
- defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938) || \
- defined(CONFIG_ATARI_ETHERNEC) || defined(CONFIG_ATARI_ETHERNEC_MODULE)
-# define DCR_VAL 0x48 /* 8-bit mode */
-#else
-# define DCR_VAL 0x49
-#endif
-
-#if defined(CONFIG_ATARI_ETHERNEC) || defined(CONFIG_ATARI_ETHERNEC_MODULE)
-# define ETHERNEC_RTL_8019_BASE 0x300
-# define ETHERNEC_RTL_8019_IRQ IRQ_MFP_TIMD
-#endif
-
-static int ne_probe1(struct net_device *dev, int ioaddr);
-static int ne_probe_isapnp(struct net_device *dev);
-
-static void ne_reset_8390(struct net_device *dev);
-static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
- int ring_page);
-static void ne_block_input(struct net_device *dev, int count,
- struct sk_buff *skb, int ring_offset);
-static void ne_block_output(struct net_device *dev, const int count,
- const unsigned char *buf, const int start_page);
-
-
-/*
- * The Atari ROM port has no interrupt line, so we poll the card instead.
- */
-
-static int use_poll;
-
-/*
- * This is used by cleanup, to prevent the module from being unloaded while
- * intrpt_routine is still in the task queue
- */
-static wait_queue_head_t WaitQ;
-
-static struct delayed_work tqueue;
-
-static struct net_device *poll_dev = NULL;
-
-irqreturn_t atari_ei_interrupt(int irq, void *dev_id)
-{
- struct net_device *dev = dev_id;
- if (netif_running(dev))
- return ei_interrupt(dev->irq, dev);
- return IRQ_NONE;
-}
-
-static void atari_ethernec_int(struct work_struct *work)
-{
- struct net_device *dev = poll_dev;
-
- if (!dev) {
- /* If cleanup wants us to die */
- if (waitqueue_active(&WaitQ))
- wake_up(&WaitQ); /* Now cleanup_module can return */
- else
- /* Put ourselves back in the task queue */
- schedule_delayed_work(&tqueue, 1);
- return;
- }
-
- if (netif_running(dev))
- ei_interrupt(dev->irq, dev);
-
- /* If cleanup wants us to die */
- if (waitqueue_active(&WaitQ))
- wake_up(&WaitQ); /* Now cleanup_module can return */
- else
- /* Put ourselves back in the task queue */
- schedule_delayed_work(&tqueue, 0); /* reduced delay from 1 */
-}
-
-static void atari_ethernec_start_poll(struct net_device *dev)
-{
- poll_dev = dev;
-
- init_waitqueue_head(&WaitQ);
-
- INIT_DELAYED_WORK(&tqueue, atari_ethernec_int);
- schedule_delayed_work(&tqueue, 1);
-}
-
-static void atari_ethernec_stop_poll(struct net_device *dev)
-{
- poll_dev = NULL;
-
- if (dev)
- sleep_on(&WaitQ);
-}
-
-\f
-/* Probe for various non-shared-memory ethercards.
-
- NEx000-clone boards have a Station Address PROM (SAPROM) in the packet
- buffer memory space. NE2000 clones have 0x57,0x57 in bytes 0x0e,0x0f of
- the SAPROM, while other supposed NE2000 clones must be detected by their
- SA prefix.
-
- Reading the SAPROM from a word-wide card with the 8390 set in byte-wide
- mode results in doubled values, which can be detected and compensated for.
-
- The probe is also responsible for initializing the card and filling
- in the 'dev' and 'ei_status' structures.
-
- We use the minimum memory size for some ethercard product lines, iff we can't
- distinguish models. You can increase the packet buffer size by setting
- PACKETBUF_MEMSIZE. Reported Cabletron packet buffer locations are:
- E1010 starts at 0x100 and ends at 0x2000.
- E1010-x starts at 0x100 and ends at 0x8000. ("-x" means "more memory")
- E2010 starts at 0x100 and ends at 0x4000.
- E2010-x starts at 0x100 and ends at 0xffff.
-*/
-
-static int __init do_ne_probe(struct net_device *dev)
-{
- unsigned int base_addr = dev->base_addr;
- int rv;
-#ifndef MODULE
- int orig_irq = dev->irq;
-#endif
-
- /* First check any supplied i/o locations. User knows best. <cough> */
- if (base_addr > 0x1ff) { /* Check a single specified location. */
- rv = ne_probe1(dev, base_addr);
- if (!rv && use_poll) {
- /* Seems we have a valid device here; set up polling routine */
- poll_dev = dev;
- atari_ethernec_start_poll(dev);
- }
- return rv;
- } else if (base_addr != 0) /* Don't probe at all. */
- return -ENXIO;
-
- /* Then look for any installed ISAPnP clones */
- if (isapnp_present() && (ne_probe_isapnp(dev) == 0))
- return 0;
-
-#ifndef MODULE
- /* Last resort. The semi-risky ISA auto-probe. */
- for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) {
- int ioaddr = netcard_portlist[base_addr];
- dev->irq = orig_irq;
- rv = ne_probe1(dev, ioaddr);
- if (rv == 0) {
- if (use_poll) {
- poll_dev = dev;
- atari_ethernec_start_poll(dev);
- }
- return 0;
- }
- }
-#endif
-
- return -ENODEV;
-}
-
-#ifndef MODULE
-struct net_device * __init atari_ethernec_probe(int unit)
-{
- struct net_device *dev;
- int err;
-
- if (!MACH_IS_ATARI)
- return ERR_PTR(-ENODEV);
-
- dev = alloc_ei_netdev();
- if (!dev)
- return ERR_PTR(-ENOMEM);
-
- sprintf(dev->name, "eth%d", unit);
- netdev_boot_setup_check(dev);
-
-#if defined(CONFIG_ATARI_ETHERNEC)
- dev->base_addr = ETHERNEC_RTL_8019_BASE;
- dev->irq = ETHERNEC_RTL_8019_IRQ;
-#endif
- err = do_ne_probe(dev);
- if (err)
- goto out;
-
- /* Seems we have a valid device here; set up polling routine */
- return dev;
-out:
- free_netdev(dev);
- return ERR_PTR(err);
-}
-#endif
-
-static int __init ne_probe_isapnp(struct net_device *dev)
-{
- int i;
-
- for (i = 0; isapnp_clone_list[i].vendor != 0; i++) {
- struct pnp_dev *idev = NULL;
-
- while ((idev = pnp_find_dev(NULL,
- isapnp_clone_list[i].vendor,
- isapnp_clone_list[i].function,
- idev))) {
- /* Avoid already found cards from previous calls */
- if (pnp_device_attach(idev) < 0)
- continue;
- if (pnp_activate_dev(idev) < 0) {
- pnp_device_detach(idev);
- continue;
- }
- /* if no io and irq, search for next */
- if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0)) {
- pnp_device_detach(idev);
- continue;
- }
- /* found it */
- dev->base_addr = pnp_port_start(idev, 0);
- dev->irq = pnp_irq(idev, 0);
- printk(KERN_INFO "atari_ethernec.c: ISAPnP reports %s at i/o %#lx, irq %d.\n",
- (char *) isapnp_clone_list[i].driver_data,
- dev->base_addr, dev->irq);
- if (ne_probe1(dev, dev->base_addr) != 0) { /* Shouldn't happen. */
- printk(KERN_ERR "atari_ethernec.c: Probe of ISAPnP card at %#lx failed.\n",
- dev->base_addr);
- pnp_device_detach(idev);
- return -ENXIO;
- }
- ei_status.priv = (unsigned long)idev;
- break;
- }
- if (!idev)
- continue;
- return 0;
- }
-
- return -ENODEV;
-}
-
-static int __init ne_probe1(struct net_device *dev, int ioaddr)
-{
- int i;
- unsigned char SA_prom[32];
- int wordlength = 2;
- const char *name = NULL;
- int start_page, stop_page;
- int neX000, ctron, copam, bad_card;
- int reg0, ret;
- static unsigned version_printed;
-
- if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME))
- return -EBUSY;
-
- reg0 = inb_p(ioaddr);
- if (reg0 == 0xFF) {
- ret = -ENODEV;
- goto err_out;
- }
-
- /* Do a preliminary verification that we have a 8390. */
- {
- int regd;
- outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);
- regd = inb_p(ioaddr + 0x0d);
- outb_p(0xff, ioaddr + 0x0d);
- outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD);
- inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */
- if (inb_p(ioaddr + EN0_COUNTER0) != 0) {
- outb_p(reg0, ioaddr);
- outb_p(regd, ioaddr + 0x0d); /* Restore the old values. */
- ret = -ENODEV;
- goto err_out;
- }
- }
-
- if (ei_debug && version_printed++ == 0)
- printk(KERN_INFO "%s" KERN_INFO "%s", version1, version2);
-
- /* A user with a poor card that fails to ack the reset, or that
- does not have a valid 0x57,0x57 signature can still use this
- without having to recompile. Specifying an i/o address along
- with an otherwise unused dev->mem_end value of "0xBAD" will
- cause the driver to skip these parts of the probe. */
-
- bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad));
-
- /* Reset card. Who knows what dain-bramaged state it was left in. */
-
- {
- unsigned long reset_start_time = jiffies;
-
- /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
- outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
-
- while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0) {
- if (time_after(jiffies, reset_start_time + 2 * HZ / 100)) {
- if (bad_card) {
- printk(" (warning: no reset ack)");
- break;
- } else {
- // MSch: ARAnyM exits here
- printk(" not found (no reset ack).\n");
- ret = -ENODEV;
- goto err_out;
- }
- }
- }
-
- outb_p(0xff, ioaddr + EN0_ISR); /* Ack all intr. */
- }
-
- /* Read the 16 bytes of station address PROM.
- We must first initialize registers, similar to NS8390_init(eifdev, 0).
- We can't reliably read the SAPROM address without this.
- (I learned the hard way!). */
- {
- struct {unsigned char value, offset; } program_seq[] =
- {
- {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/
- {0x48, EN0_DCFG}, /* Set byte-wide (0x48) access. */
- {0x00, EN0_RCNTLO}, /* Clear the count regs. */
- {0x00, EN0_RCNTHI},
- {0x00, EN0_IMR}, /* Mask completion irq. */
- {0xFF, EN0_ISR},
- {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */
- {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */
- {32, EN0_RCNTLO},
- {0x00, EN0_RCNTHI},
- {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */
- {0x00, EN0_RSARHI},
- {E8390_RREAD+E8390_START, E8390_CMD},
- };
-
- for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
- outb_p(program_seq[i].value, ioaddr + program_seq[i].offset);
-
- }
- for (i = 0; i < 32 /*sizeof(SA_prom)*/; i += 2) {
- SA_prom[i] = inb(ioaddr + NE_DATAPORT);
- SA_prom[i+1] = inb(ioaddr + NE_DATAPORT);
- if (SA_prom[i] != SA_prom[i+1])
- wordlength = 1;
- }
-
- if (wordlength == 2) {
- for (i = 0; i < 16; i++)
- SA_prom[i] = SA_prom[i+i];
- /* We must set the 8390 for word mode. */
- outb_p(DCR_VAL, ioaddr + EN0_DCFG);
- start_page = NESM_START_PG;
-
- /*
- * Realtek RTL8019AS datasheet says that the PSTOP register
- * shouldn't exceed 0x60 in 8-bit mode.
- * This chip can be identified by reading the signature from
- * the remote byte count registers (otherwise write-only)...
- */
- if ((DCR_VAL & 0x01) == 0 && /* 8-bit mode */
- inb(ioaddr + EN0_RCNTLO) == 0x50 &&
- inb(ioaddr + EN0_RCNTHI) == 0x70)
- stop_page = 0x60;
- else
- stop_page = NESM_STOP_PG;
- } else {
- start_page = NE1SM_START_PG;
- stop_page = NE1SM_STOP_PG;
- }
-
-#if defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R)
- neX000 = ((SA_prom[14] == 0x57 && SA_prom[15] == 0x57)
- || (SA_prom[14] == 0x42 && SA_prom[15] == 0x42));
-#else
- neX000 = (SA_prom[14] == 0x57 && SA_prom[15] == 0x57);
-#endif
- ctron = (SA_prom[0] == 0x00 && SA_prom[1] == 0x00 && SA_prom[2] == 0x1d);
- copam = (SA_prom[14] == 0x49 && SA_prom[15] == 0x00);
-
- /* Set up the rest of the parameters. */
- if (neX000 || bad_card || copam) {
- name = (wordlength == 2) ? "NE2000" : "NE1000";
- } else if (ctron) {
- name = (wordlength == 2) ? "Ctron-8" : "Ctron-16";
- start_page = 0x01;
- stop_page = (wordlength == 2) ? 0x40 : 0x20;
- } else {
-#ifdef SUPPORT_NE_BAD_CLONES
- /* Ack! Well, there might be a *bad* NE*000 clone there.
- Check for total bogus addresses. */
- for (i = 0; bad_clone_list[i].name8; i++) {
- if (SA_prom[0] == bad_clone_list[i].SAprefix[0] &&
- SA_prom[1] == bad_clone_list[i].SAprefix[1] &&
- SA_prom[2] == bad_clone_list[i].SAprefix[2]) {
- if (wordlength == 2) {
- name = bad_clone_list[i].name16;
- } else {
- name = bad_clone_list[i].name8;
- }
- break;
- }
- }
- if (bad_clone_list[i].name8 == NULL) {
- printk(" not found (invalid signature %2.2x %2.2x).\n",
- SA_prom[14], SA_prom[15]);
- ret = -ENXIO;
- goto err_out;
- }
-#else
- printk(" not found.\n");
- ret = -ENXIO;
- goto err_out;
-#endif
- }
-
- if (dev->irq < 2) {
- unsigned long cookie = probe_irq_on();
- outb_p(0x50, ioaddr + EN0_IMR); /* Enable one interrupt. */
- outb_p(0x00, ioaddr + EN0_RCNTLO);
- outb_p(0x00, ioaddr + EN0_RCNTHI);
- outb_p(E8390_RREAD+E8390_START, ioaddr); /* Trigger it... */
- mdelay(10); /* wait 10ms for interrupt to propagate */
- outb_p(0x00, ioaddr + EN0_IMR); /* Mask it again. */
- dev->irq = probe_irq_off(cookie);
- if (ei_debug > 2)
- printk(" autoirq is %d\n", dev->irq);
- } else if (dev->irq == 2)
- /* Fixup for users that don't know that IRQ 2 is really IRQ 9,
- or don't know which one to set. */
- dev->irq = 9;
-
- /*
- * use timer based polling!
- */
- if (! dev->irq) {
- printk(" failed to detect IRQ line. Assuming irq %d\n",
- ETHERNEC_RTL_8019_IRQ);
- dev->irq = ETHERNEC_RTL_8019_IRQ;
- /* timer routine set up in atari_ethernec_probe() */
- if (dev->irq == IRQ_MFP_TIMD) {
- /* set Timer D data Register */
- st_mfp.tim_dt_d = 123; /* 200 Hz */
- /* start timer D, div = 1:100 */
- st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x6;
- }
- /* Must make this shared in case other timer ints are needed */
- ret = request_irq(dev->irq, atari_ei_interrupt, IRQF_SHARED, name, dev);
- if (ret) {
- printk(" unable to get IRQ %d (errno=%d), polling instead.\n",
- dev->irq, ret);
- use_poll = 1;
- }
- } else {
-
- /* Snarf the interrupt now. There's no point in waiting since we cannot
- share and the board will usually be enabled. */
- ret = request_irq(dev->irq, ei_interrupt, 0, name, dev);
- if (ret) {
- printk(" unable to get IRQ %d (errno=%d).\n", dev->irq, ret);
- goto err_out;
- }
- }
- dev->base_addr = ioaddr;
-
-#ifdef CONFIG_PLAT_MAPPI
- outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
- ioaddr + E8390_CMD); /* 0x61 */
- for (i = 0; i < ETH_ALEN; i++) {
- dev->dev_addr[i] = SA_prom[i] = inb_p(ioaddr + EN1_PHYS_SHIFT(i));
- printk(" %2.2x", SA_prom[i]);
- }
-#else
- for (i = 0; i < ETH_ALEN; i++) {
- printk(" %2.2x", SA_prom[i]);
- dev->dev_addr[i] = SA_prom[i];
- }
-#endif
-
- printk("\n%s: %s found at %#x, using IRQ %d.\n",
- dev->name, name, ioaddr, dev->irq);
-
- ei_status.name = name;
- ei_status.tx_start_page = start_page;
- ei_status.stop_page = stop_page;
-
- /* Use 16-bit mode only if this wasn't overridden by DCR_VAL */
- ei_status.word16 = (wordlength == 2 && (DCR_VAL & 0x01));
-
- ei_status.rx_start_page = start_page + TX_PAGES;
-#ifdef PACKETBUF_MEMSIZE
- /* Allow the packet buffer size to be overridden by know-it-alls. */
- ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
-#endif
-
- ei_status.reset_8390 = &ne_reset_8390;
- ei_status.block_input = &ne_block_input;
- ei_status.block_output = &ne_block_output;
- ei_status.get_8390_hdr = &ne_get_8390_hdr;
- ei_status.priv = 0;
- dev->netdev_ops = &ei_netdev_ops;
- NS8390_init(dev, 0);
-
- ret = register_netdev(dev);
- if (ret)
- goto out_irq;
- return 0;
-
-out_irq:
- free_irq(dev->irq, dev);
-err_out:
- release_region(ioaddr, NE_IO_EXTENT);
- return ret;
-}
-
-/* Hard reset the card. This used to pause for the same period that a
- 8390 reset command required, but that shouldn't be necessary. */
-
-static void ne_reset_8390(struct net_device *dev)
-{
- unsigned long reset_start_time = jiffies;
-
- if (ei_debug > 1)
- printk(KERN_DEBUG "resetting the 8390 t=%ld...", jiffies);
-
- /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
- outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
-
- ei_status.txing = 0;
- ei_status.dmaing = 0;
-
- /* This check _should_not_ be necessary, omit eventually. */
- while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) {
- if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
- printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n",
- dev->name);
- break;
- }
- }
- outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */
-}
-
-/* Grab the 8390 specific header. Similar to the block_input routine, but
- we don't need to be concerned with ring wrap as the header will be at
- the start of a page, so we optimize accordingly. */
-
-static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
-{
- int nic_base = dev->base_addr;
-
- /* This *shouldn't* happen. If it does, it's the last thing you'll see */
-
- if (ei_status.dmaing)
- {
- printk(KERN_EMERG "%s: DMAing conflict in ne_get_8390_hdr "
- "[DMAstat:%d][irqlock:%d].\n",
- dev->name, ei_status.dmaing, ei_status.irqlock);
- return;
- }
-
- ei_status.dmaing |= 0x01;
- outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
- outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
- outb_p(0, nic_base + EN0_RCNTHI);
- outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */
- outb_p(ring_page, nic_base + EN0_RSARHI);
- outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
-
- if (ei_status.word16)
- insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
- else
- insb(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr));
-
- outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
- ei_status.dmaing &= ~0x01;
-
- le16_to_cpus(&hdr->count);
-}
-
-/* Block input and output, similar to the Crynwr packet driver. If you
- are porting to a new ethercard, look at the packet driver source for hints.
- The NEx000 doesn't share the on-board packet memory -- you have to put
- the packet out through the "remote DMA" dataport using outb. */
-
-static void ne_block_input(struct net_device *dev, int count,
- struct sk_buff *skb, int ring_offset)
-{
-#ifdef NE_SANITY_CHECK
- int xfer_count = count;
-#endif
- int nic_base = dev->base_addr;
- char *buf = skb->data;
-
- /* This *shouldn't* happen. If it does, it's the last thing you'll see */
- if (ei_status.dmaing) {
- printk(KERN_EMERG "%s: DMAing conflict in ne_block_input "
- "[DMAstat:%d][irqlock:%d].\n",
- dev->name, ei_status.dmaing, ei_status.irqlock);
- return;
- }
- ei_status.dmaing |= 0x01;
- outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
- outb_p(count & 0xff, nic_base + EN0_RCNTLO);
- outb_p(count >> 8, nic_base + EN0_RCNTHI);
- outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO);
- outb_p(ring_offset >> 8, nic_base + EN0_RSARHI);
- outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
-
- if (ei_status.word16) {
- insw(NE_BASE + NE_DATAPORT,buf,count>>1);
- if (count & 0x01) {
- buf[count-1] = inb(NE_BASE + NE_DATAPORT);
-#ifdef NE_SANITY_CHECK
- xfer_count++;
-#endif
- }
- } else {
- insb(NE_BASE + NE_DATAPORT, buf, count);
- }
-
-#ifdef NE_SANITY_CHECK
- /* This was for the ALPHA version only, but enough people have
- been encountering problems so it is still here. If you see
- this message you either 1) have a slightly incompatible clone
- or 2) have noise/speed problems with your bus. */
-
- if (ei_debug > 1) {
- /* DMA termination address check... */
- int addr, tries = 20;
- do {
- /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
- -- it's broken for Rx on some cards! */
- int high = inb_p(nic_base + EN0_RSARHI);
- int low = inb_p(nic_base + EN0_RSARLO);
- addr = (high << 8) + low;
- if (((ring_offset + xfer_count) & 0xff) == low)
- break;
- } while (--tries > 0);
- if (tries <= 0)
- printk(KERN_WARNING "%s: RX transfer address mismatch,"
- "%#4.4x (expected) vs. %#4.4x (actual).\n",
- dev->name, ring_offset + xfer_count, addr);
- }
-#endif
- outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
- ei_status.dmaing &= ~0x01;
-}
-
-static void ne_block_output(struct net_device *dev, int count,
- const unsigned char *buf, const int start_page)
-{
- int nic_base = NE_BASE;
- unsigned long dma_start;
-#ifdef NE_SANITY_CHECK
- int retries = 0;
-#endif
-
- /* Round the count up for word writes. Do we need to do this?
- What effect will an odd byte count have on the 8390?
- I should check someday. */
-
- if (ei_status.word16 && (count & 0x01))
- count++;
-
- /* This *shouldn't* happen. If it does, it's the last thing you'll see */
- if (ei_status.dmaing) {
- printk(KERN_EMERG "%s: DMAing conflict in ne_block_output."
- "[DMAstat:%d][irqlock:%d]\n",
- dev->name, ei_status.dmaing, ei_status.irqlock);
- return;
- }
- ei_status.dmaing |= 0x01;
- /* We should already be in page 0, but to be safe... */
- outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD);
-
-#ifdef NE_SANITY_CHECK
-retry:
-#endif
-
-#ifdef NE8390_RW_BUGFIX
- /* Handle the read-before-write bug the same way as the
- Crynwr packet driver -- the NatSemi method doesn't work.
- Actually this doesn't always work either, but if you have
- problems with your NEx000 this is better than nothing! */
-
- outb_p(0x42, nic_base + EN0_RCNTLO);
- outb_p(0x00, nic_base + EN0_RCNTHI);
- outb_p(0x42, nic_base + EN0_RSARLO);
- outb_p(0x00, nic_base + EN0_RSARHI);
- outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
- /* Make certain that the dummy read has occurred. */
- udelay(6);
-#endif
-
- outb_p(ENISR_RDC, nic_base + EN0_ISR);
-
- /* Now the normal output. */
- outb_p(count & 0xff, nic_base + EN0_RCNTLO);
- outb_p(count >> 8, nic_base + EN0_RCNTHI);
- outb_p(0x00, nic_base + EN0_RSARLO);
- outb_p(start_page, nic_base + EN0_RSARHI);
-
- outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD);
- if (ei_status.word16)
- outsw(NE_BASE + NE_DATAPORT, buf, count>>1);
- else
- outsb(NE_BASE + NE_DATAPORT, buf, count);
-
- dma_start = jiffies;
-
-#ifdef NE_SANITY_CHECK
- /* This was for the ALPHA version only, but enough people have
- been encountering problems so it is still here. */
-
- if (ei_debug > 1) {
- /* DMA termination address check... */
- int addr, tries = 20;
- do {
- int high = inb_p(nic_base + EN0_RSARHI);
- int low = inb_p(nic_base + EN0_RSARLO);
- addr = (high << 8) + low;
- if ((start_page << 8) + count == addr)
- break;
- } while (--tries > 0);
-
- if (tries <= 0) {
- printk(KERN_WARNING "%s: Tx packet transfer address mismatch,"
- "%#4.4x (expected) vs. %#4.4x (actual).\n",
- dev->name, (start_page << 8) + count, addr);
- if (retries++ == 0)
- goto retry;
- }
- }
-#endif
-
- while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0) {
- if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
- printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
- ne_reset_8390(dev);
- NS8390_init(dev, 1);
- break;
- }
- }
-
- outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
- ei_status.dmaing &= ~0x01;
- return;
-}
-
-\f
-#ifdef MODULE
-#define MAX_NE_CARDS 1 /* Max number of NE cards per module */
-static struct net_device *dev_ne[MAX_NE_CARDS];
-static int io[MAX_NE_CARDS] = { 0x300 };
-static int irq[MAX_NE_CARDS];
-static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */
-
-module_param_array(io, int, NULL, 0);
-module_param_array(irq, int, NULL, 0);
-module_param_array(bad, int, NULL, 0);
-module_param(use_poll, int, 0);
-MODULE_PARM_DESC(io, "I/O base address(es),required");
-MODULE_PARM_DESC(irq, "IRQ number(s)");
-MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures");
-MODULE_PARM_DESC(use_poll, "Use timer interrupt to poll driver");
-MODULE_DESCRIPTION("NE1000/NE2000 ISA/PnP Ethernet driver");
-MODULE_LICENSE("GPL");
-
-/* This is set up so that no ISA autoprobe takes place. We can't guarantee
-that the ne2k probe is the last 8390 based probe to take place (as it
-is at boot) and so the probe will get confused by any other 8390 cards.
-ISA device autoprobes on a running machine are not recommended anyway. */
-
-int __init init_module(void)
-{
- int this_dev, found = 0;
-
- if (!MACH_IS_ATARI)
- return -ENODEV;
-
- for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
- struct net_device *dev = alloc_ei_netdev();
- if (!dev)
- break;
- dev->irq = irq[this_dev];
- dev->mem_end = bad[this_dev];
- dev->base_addr = io[this_dev];
- if (do_ne_probe(dev) == 0) {
- dev_ne[found++] = dev;
- continue;
- }
- free_netdev(dev);
- if (found)
- break;
- if (io[this_dev] != 0)
- printk(KERN_WARNING "atari_ethernec.c: No NE*000 card found at i/o = %#x\n", io[this_dev]);
- else
- printk(KERN_NOTICE "atari_ethernec.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n");
- return -ENXIO;
- }
- if (found)
- return 0;
- return -ENODEV;
-}
-
-static void cleanup_card(struct net_device *dev)
-{
- struct pnp_dev *idev = (struct pnp_dev *)ei_status.priv;
- if (idev)
- pnp_device_detach(idev);
- free_irq(dev->irq, dev);
- release_region(dev->base_addr, NE_IO_EXTENT);
-}
-
-void cleanup_module(void)
-{
- int this_dev;
-
- for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
- struct net_device *dev = dev_ne[this_dev];
- if (dev) {
- if (use_poll)
- atari_ethernec_stop_poll(dev);
- unregister_netdev(dev);
- cleanup_card(dev);
- free_netdev(dev);
- }
- }
-}
-#endif /* MODULE */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 02/14] m68k/atari EtherNAT: remove original EtherNAT driver
2013-03-25 1:16 (unknown), Michael Schmitz
2013-03-25 1:16 ` [PATCH 01/14] m68k/atari EtherNEC: remove original EtherNEC driver Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 03/14] m68k/atari: use CONFIG_ATARI in smc91x.h Michael Schmitz
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
drivers/net/ethernet/smsc/Kconfig | 10 -
drivers/net/ethernet/smsc/Makefile | 1 -
drivers/net/ethernet/smsc/atari_91C111.c | 2434 ------------------------------
3 files changed, 0 insertions(+), 2445 deletions(-)
delete mode 100644 drivers/net/ethernet/smsc/atari_91C111.c
diff --git a/drivers/net/ethernet/smsc/Kconfig b/drivers/net/ethernet/smsc/Kconfig
index 01893aa..bb1e8f3 100644
--- a/drivers/net/ethernet/smsc/Kconfig
+++ b/drivers/net/ethernet/smsc/Kconfig
@@ -19,16 +19,6 @@ config NET_VENDOR_SMSC
if NET_VENDOR_SMSC
-config ATARI_ETHERNAT
- tristate "Atari EtherNAT Ethernet support"
- select CRC32
- select MII
- depends on ATARI
- help
- Say Y to include support for the EtherNAT network adapter for the
- CT/60 extension port. The driver works by polling instead of
- interrupts, so it is quite slow.
-
config SMC9194
tristate "SMC 9194 support"
depends on (ISA || MAC && BROKEN)
diff --git a/drivers/net/ethernet/smsc/Makefile b/drivers/net/ethernet/smsc/Makefile
index ef228db..f3438de 100644
--- a/drivers/net/ethernet/smsc/Makefile
+++ b/drivers/net/ethernet/smsc/Makefile
@@ -2,7 +2,6 @@
# Makefile for the SMSC network device drivers.
#
-obj-$(CONFIG_ATARI_ETHERNAT) += atari_91C111.o
obj-$(CONFIG_SMC9194) += smc9194.o
obj-$(CONFIG_SMC91X) += smc91x.o
obj-$(CONFIG_PCMCIA_SMC91C92) += smc91c92_cs.o
diff --git a/drivers/net/ethernet/smsc/atari_91C111.c b/drivers/net/ethernet/smsc/atari_91C111.c
deleted file mode 100644
index 2708864..0000000
--- a/drivers/net/ethernet/smsc/atari_91C111.c
+++ /dev/null
@@ -1,2434 +0,0 @@
-/*
- * smc91x.c
- * This is a driver for SMSC's 91C9x/91C1xx single-chip Ethernet devices.
- *
- * Copyright (C) 1996 by Erik Stahlman
- * Copyright (C) 2001 Standard Microsystems Corporation
- * Developed by Simple Network Magic Corporation
- * Copyright (C) 2003 Monta Vista Software, Inc.
- * Unified SMC91x driver by Nicolas Pitre
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Arguments:
- * io = for the base address
- * irq = for the IRQ
- * nowait = 0 for normal wait states, 1 eliminates additional wait states
- *
- * original author:
- * Erik Stahlman <erik@vt.edu>
- *
- * hardware multicast code:
- * Peter Cammaert <pc@denkart.be>
- *
- * contributors:
- * Daris A Nevil <dnevil@snmc.com>
- * Nicolas Pitre <nico@fluxnic.net>
- * Russell King <rmk@arm.linux.org.uk>
- *
- * History:
- * 08/20/00 Arnaldo Melo fix kfree(skb) in smc_hardware_send_packet
- * 12/15/00 Christian Jullien fix "Warning: kfree_skb on hard IRQ"
- * 03/16/01 Daris A Nevil modified smc9194.c for use with LAN91C111
- * 08/22/01 Scott Anderson merge changes from smc9194 to smc91111
- * 08/21/01 Pramod B Bhardwaj added support for RevB of LAN91C111
- * 12/20/01 Jeff Sutherland initial port to Xscale PXA with DMA support
- * 04/07/03 Nicolas Pitre unified SMC91x driver, killed irq races,
- * more bus abstraction, big cleanup, etc.
- * 29/09/03 Russell King - add driver model support
- * - ethtool support
- * - convert to use generic MII interface
- * - add link up/down notification
- * - don't try to handle full negotiation in
- * smc_phy_configure
- * - clean up (and fix stack overrun) in PHY
- * MII read/write functions
- * 22/09/04 Nicolas Pitre big update (see commit log for details)
- */
-static const char version[] =
- "smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>\n";
-
-/* Debugging level */
-#ifndef SMC_DEBUG
-#define SMC_DEBUG 0
-#endif
-
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/crc32.h>
-#include <linux/platform_device.h>
-#include <linux/spinlock.h>
-#include <linux/ethtool.h>
-#include <linux/mii.h>
-#include <linux/workqueue.h>
-
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-
-#include <asm/hwtest.h>
-#include <asm/atariints.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#include "smc91x.h"
-
-#ifdef CONFIG_ISA
-/*
- * the LAN91C111 can be at any of the following port addresses. To change,
- * for a slightly different card, you can add it to the array. Keep in
- * mind that the array must end in zero.
- */
-static unsigned int smc_portlist[] __initdata = {
- 0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0,
- 0x300, 0x320, 0x340, 0x360, 0x380, 0x3A0, 0x3C0, 0x3E0, 0
-};
-
-/* MSch FIXME: endif CONFIG_ISA here? */
-
-#ifndef SMC_IOADDR
-# define SMC_IOADDR -1
-#endif
-static unsigned long io = SMC_IOADDR;
-module_param(io, ulong, 0400);
-MODULE_PARM_DESC(io, "I/O base address");
-
-#ifndef SMC_IRQ
-# define SMC_IRQ -1
-#endif
-static int irq = SMC_IRQ;
-module_param(irq, int, 0400);
-MODULE_PARM_DESC(irq, "IRQ number");
-
-#endif /* CONFIG_ISA */
-
-#ifndef SMC_NOWAIT
-# define SMC_NOWAIT 0
-#endif
-static int nowait = SMC_NOWAIT;
-module_param(nowait, int, 0400);
-MODULE_PARM_DESC(nowait, "set to 1 for no wait state");
-
-/*
- * Transmit timeout, default 5 seconds.
- */
-static int watchdog = 1000;
-module_param(watchdog, int, 0400);
-MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:smc91x");
-
-/*
- * The internal workings of the driver. If you are changing anything
- * here with the SMC stuff, you should have the datasheet and know
- * what you are doing.
- */
-#define CARDNAME "smc91x"
-
-/*
- * Use power-down feature of the chip
- */
-#define POWER_DOWN 1
-
-/*
- * Wait time for memory to be free. This probably shouldn't be
- * tuned that much, as waiting for this means nothing else happens
- * in the system
- */
-#define MEMORY_WAIT_TIME 16
-
-/*
- * The maximum number of processing loops allowed for each call to the
- * IRQ handler.
- */
-#define MAX_IRQ_LOOPS 8
-
-/*
- * This selects whether TX packets are sent one by one to the SMC91x internal
- * memory and throttled until transmission completes. This may prevent
- * RX overruns a litle by keeping much of the memory free for RX packets
- * but to the expense of reduced TX throughput and increased IRQ overhead.
- * Note this is not a cure for a too slow data bus or too high IRQ latency.
- */
-#define THROTTLE_TX_PKTS 0 /* MSch FIXME 1 */
-
-/*
- * The MII clock high/low times. 2x this number gives the MII clock period
- * in microseconds. (was 50, but this gives 6.4ms for each MII transaction!)
- */
-#define MII_DELAY 1
-
-#if SMC_DEBUG > 0
-#define DBG(n, args...) \
- do { \
- if (SMC_DEBUG >= (n)) \
- printk(args); \
- } while (0)
-
-#define PRINTK(args...) printk(args)
-#else
-#define DBG(n, args...) do { } while(0)
-#define PRINTK(args...) printk(KERN_DEBUG args)
-#endif
-
-#if SMC_DEBUG > 3
-static void PRINT_PKT(u_char *buf, int length)
-{
- int i;
- int remainder;
- int lines;
-
- lines = length / 16;
- remainder = length % 16;
-
- for (i = 0; i < lines ; i ++) {
- int cur;
- for (cur = 0; cur < 8; cur++) {
- u_char a, b;
- a = *buf++;
- b = *buf++;
- printk("%02x%02x ", a, b);
- }
- printk("\n");
- }
- for (i = 0; i < remainder/2 ; i++) {
- u_char a, b;
- a = *buf++;
- b = *buf++;
- printk("%02x%02x ", a, b);
- }
- printk("\n");
-}
-#else
-#define PRINT_PKT(x...) do { } while(0)
-#endif
-
-
-/* this enables an interrupt in the interrupt mask register */
-#define SMC_ENABLE_INT(lp, x) do { \
- unsigned char mask; \
- unsigned long smc_enable_flags; \
- spin_lock_irqsave(&lp->lock, smc_enable_flags); \
- mask = SMC_GET_INT_MASK(lp); \
- mask |= (x); \
- SMC_SET_INT_MASK(lp, mask); \
- spin_unlock_irqrestore(&lp->lock, smc_enable_flags); \
-} while (0)
-
-/* this disables an interrupt from the interrupt mask register */
-#define SMC_DISABLE_INT(lp, x) do { \
- unsigned char mask; \
- unsigned long smc_disable_flags; \
- spin_lock_irqsave(&lp->lock, smc_disable_flags); \
- mask = SMC_GET_INT_MASK(lp); \
- mask &= ~(x); \
- SMC_SET_INT_MASK(lp, mask); \
- spin_unlock_irqrestore(&lp->lock, smc_disable_flags); \
-} while (0)
-
-/*
- * Wait while MMU is busy. This is usually in the order of a few nanosecs
- * if at all, but let's avoid deadlocking the system if the hardware
- * decides to go south.
- */
-#define SMC_WAIT_MMU_BUSY(lp) do { \
- if (unlikely(SMC_GET_MMU_CMD(lp) & MC_BUSY)) { \
- unsigned long timeout = jiffies + 2; \
- while (SMC_GET_MMU_CMD(lp) & MC_BUSY) { \
- if (time_after(jiffies, timeout)) { \
- printk("%s: timeout %s line %d\n", \
- dev->name, __FILE__, __LINE__); \
- break; \
- } \
- cpu_relax(); \
- } \
- } \
-} while (0)
-
-/*
- * MSch: Interrupt wrapper to prevent calling the main interrupt handler
- * from MFP timer D routine before device has been opened.
- */
-
-static irqreturn_t smc_interrupt(int irq, void *dev_id);
-
-static irqreturn_t atari_ethernat_interrupt(int irq, void *dev_id)
-{
- struct net_device *dev = (struct net_device *) dev_id;
- if (netif_running(dev)) {
- return smc_interrupt(dev->irq, dev);
- }
- return IRQ_HANDLED;
-}
-
-static int period = 0;
-module_param(period, int, 0);
-MODULE_PARM_DESC(period, "Timer D period (123 for 200Hz)");
-
-/*
- * this does a soft reset on the device
- */
-static void smc_reset(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int ctl, cfg;
- struct sk_buff *pending_skb;
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- /* Disable all interrupts, block TX tasklet */
- spin_lock_irq(&lp->lock);
- SMC_SELECT_BANK(lp, 2);
- SMC_SET_INT_MASK(lp, 0);
- pending_skb = lp->pending_tx_skb;
- lp->pending_tx_skb = NULL;
- spin_unlock_irq(&lp->lock);
-
- /* free any pending tx skb */
- if (pending_skb) {
- dev_kfree_skb(pending_skb);
- dev->stats.tx_errors++;
- dev->stats.tx_aborted_errors++;
- }
-
- /*
- * This resets the registers mostly to defaults, but doesn't
- * affect EEPROM. That seems unnecessary
- */
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_RCR(lp, RCR_SOFTRST);
-
- /*
- * Setup the Configuration Register
- * This is necessary because the CONFIG_REG is not affected
- * by a soft reset
- */
- SMC_SELECT_BANK(lp, 1);
-
- cfg = CONFIG_DEFAULT;
-
- /*
- * Setup for fast accesses if requested. If the card/system
- * can't handle it then there will be no recovery except for
- * a hard reset or power cycle
- */
- if (lp->cfg.flags & SMC91X_NOWAIT)
- cfg |= CONFIG_NO_WAIT;
-
- /*
- * Release from possible power-down state
- * Configuration register is not affected by Soft Reset
- */
- cfg |= CONFIG_EPH_POWER_EN;
-
- SMC_SET_CONFIG(lp, cfg);
-
- /* this should pause enough for the chip to be happy */
- /*
- * elaborate? What does the chip _need_? --jgarzik
- *
- * This seems to be undocumented, but something the original
- * driver(s) have always done. Suspect undocumented timing
- * info/determined empirically. --rmk
- */
- udelay(1);
-
- /* Disable transmit and receive functionality */
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_RCR(lp, RCR_CLEAR);
- SMC_SET_TCR(lp, TCR_CLEAR);
-
- SMC_SELECT_BANK(lp, 1);
- ctl = SMC_GET_CTL(lp) | CTL_LE_ENABLE;
-
- /*
- * Set the control register to automatically release successfully
- * transmitted packets, to make the best use out of our limited
- * memory
- */
- if(!THROTTLE_TX_PKTS)
- ctl |= CTL_AUTO_RELEASE;
- else
- ctl &= ~CTL_AUTO_RELEASE;
- SMC_SET_CTL(lp, ctl);
-
- /* Reset the MMU */
- SMC_SELECT_BANK(lp, 2);
- SMC_SET_MMU_CMD(lp, MC_RESET);
- SMC_WAIT_MMU_BUSY(lp);
-}
-
-/*
- * Enable Interrupts, Receive, and Transmit
- */
-static void smc_enable(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- int mask;
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- /* see the header file for options in TCR/RCR DEFAULT */
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_TCR(lp, lp->tcr_cur_mode);
- SMC_SET_RCR(lp, lp->rcr_cur_mode);
-
- SMC_SELECT_BANK(lp, 1);
- SMC_SET_MAC_ADDR(lp, dev->dev_addr);
-
- /* now, enable interrupts */
- mask = IM_EPH_INT|IM_RX_OVRN_INT|IM_RCV_INT;
- if (lp->version >= (CHIP_91100 << 4))
- mask |= IM_MDINT;
- SMC_SELECT_BANK(lp, 2);
- SMC_SET_INT_MASK(lp, mask);
-
- /*
- * From this point the register bank must _NOT_ be switched away
- * to something else than bank 2 without proper locking against
- * races with any tasklet or interrupt handlers until smc_shutdown()
- * or smc_reset() is called.
- */
-}
-
-/*
- * this puts the device in an inactive state
- */
-static void smc_shutdown(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- struct sk_buff *pending_skb;
-
- DBG(2, "%s: %s\n", CARDNAME, __func__);
-
- /* no more interrupts for me */
- spin_lock_irq(&lp->lock);
- SMC_SELECT_BANK(lp, 2);
- SMC_SET_INT_MASK(lp, 0);
- pending_skb = lp->pending_tx_skb;
- lp->pending_tx_skb = NULL;
- spin_unlock_irq(&lp->lock);
- if (pending_skb)
- dev_kfree_skb(pending_skb);
-
- /* and tell the card to stay away from that nasty outside world */
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_RCR(lp, RCR_CLEAR);
- SMC_SET_TCR(lp, TCR_CLEAR);
-
-#ifdef POWER_DOWN
- /* finally, shut the chip down */
- SMC_SELECT_BANK(lp, 1);
- SMC_SET_CONFIG(lp, SMC_GET_CONFIG(lp) & ~CONFIG_EPH_POWER_EN);
-#endif
-}
-
-/*
- * This is the procedure to handle the receipt of a packet.
- */
-static inline void smc_rcv(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int packet_number, status, packet_len;
-
- DBG(3, "%s: %s\n", dev->name, __func__);
-
- packet_number = SMC_GET_RXFIFO(lp);
- if (unlikely(packet_number & RXFIFO_REMPTY)) {
- PRINTK("%s: smc_rcv with nothing on FIFO.\n", dev->name);
- return;
- }
-
- /* read from start of packet */
- SMC_SET_PTR(lp, PTR_READ | PTR_RCV | PTR_AUTOINC);
-
- /* First two words are status and packet length */
- SMC_GET_PKT_HDR(lp, status, packet_len);
- packet_len &= 0x07ff; /* mask off top bits */
- DBG(2, "%s: RX PNR 0x%x STATUS 0x%04x LENGTH 0x%04x (%d)\n",
- dev->name, packet_number, status,
- packet_len, packet_len);
-
- back:
- if (unlikely(packet_len < 6 || status & RS_ERRORS)) {
- if (status & RS_TOOLONG && packet_len <= (1514 + 4 + 6)) {
- /* accept VLAN packets */
- status &= ~RS_TOOLONG;
- goto back;
- }
- if (packet_len < 6) {
- /* bloody hardware */
- printk(KERN_ERR "%s: fubar (rxlen %u status %x\n",
- dev->name, packet_len, status);
- status |= RS_TOOSHORT;
- }
- SMC_WAIT_MMU_BUSY(lp);
- SMC_SET_MMU_CMD(lp, MC_RELEASE);
- dev->stats.rx_errors++;
- if (status & RS_ALGNERR)
- dev->stats.rx_frame_errors++;
- if (status & (RS_TOOSHORT | RS_TOOLONG))
- dev->stats.rx_length_errors++;
- if (status & RS_BADCRC)
- dev->stats.rx_crc_errors++;
- } else {
- struct sk_buff *skb;
- unsigned char *data;
- unsigned int data_len;
-
- /* set multicast stats */
- if (status & RS_MULTICAST)
- dev->stats.multicast++;
-
- /*
- * Actual payload is packet_len - 6 (or 5 if odd byte).
- * We want skb_reserve(2) and the final ctrl word
- * (2 bytes, possibly containing the payload odd byte).
- * Furthermore, we add 2 bytes to allow rounding up to
- * multiple of 4 bytes on 32 bit buses.
- * Hence packet_len - 6 + 2 + 2 + 2.
- */
- skb = dev_alloc_skb(packet_len);
- if (unlikely(skb == NULL)) {
- printk(KERN_NOTICE "%s: Low memory, packet dropped.\n",
- dev->name);
- SMC_WAIT_MMU_BUSY(lp);
- SMC_SET_MMU_CMD(lp, MC_RELEASE);
- dev->stats.rx_dropped++;
- return;
- }
-
- /* Align IP header to 32 bits */
- skb_reserve(skb, 2);
-
- /* BUG: the LAN91C111 rev A never sets this bit. Force it. */
- if (lp->version == 0x90)
- status |= RS_ODDFRAME;
-
- /*
- * If odd length: packet_len - 5,
- * otherwise packet_len - 6.
- * With the trailing ctrl byte it's packet_len - 4.
- */
- data_len = packet_len - ((status & RS_ODDFRAME) ? 5 : 6);
- data = skb_put(skb, data_len);
- SMC_PULL_DATA(lp, data, packet_len - 4);
-
- SMC_WAIT_MMU_BUSY(lp);
- SMC_SET_MMU_CMD(lp, MC_RELEASE);
-
- PRINT_PKT(data, packet_len - 4);
-
- dev->last_rx = jiffies;
- skb->protocol = eth_type_trans(skb, dev);
- netif_rx(skb);
- dev->stats.rx_packets++;
- dev->stats.rx_bytes += data_len;
- }
-}
-
-#ifdef CONFIG_SMP
-/*
- * On SMP we have the following problem:
- *
- * A = smc_hardware_send_pkt()
- * B = smc_hard_start_xmit()
- * C = smc_interrupt()
- *
- * A and B can never be executed simultaneously. However, at least on UP,
- * it is possible (and even desirable) for C to interrupt execution of
- * A or B in order to have better RX reliability and avoid overruns.
- * C, just like A and B, must have exclusive access to the chip and
- * each of them must lock against any other concurrent access.
- * Unfortunately this is not possible to have C suspend execution of A or
- * B taking place on another CPU. On UP this is no an issue since A and B
- * are run from softirq context and C from hard IRQ context, and there is
- * no other CPU where concurrent access can happen.
- * If ever there is a way to force at least B and C to always be executed
- * on the same CPU then we could use read/write locks to protect against
- * any other concurrent access and C would always interrupt B. But life
- * isn't that easy in a SMP world...
- */
-#define smc_special_trylock(lock, flags) \
-({ \
- int __ret; \
- local_irq_save(flags); \
- __ret = spin_trylock(lock); \
- if (!__ret) \
- local_irq_restore(flags); \
- __ret; \
-})
-#define smc_special_lock(lock, flags) spin_lock_irqsave(lock, flags)
-#define smc_special_unlock(lock, flags) spin_unlock_irqrestore(lock, flags)
-#else
-#define smc_special_trylock(lock, flags) (flags == flags)
-#define smc_special_lock(lock, flags) do { flags = 0; } while (0)
-#define smc_special_unlock(lock, flags) do { flags = 0; } while (0)
-#endif
-
-/*
- * MSch FIXME: add SMC_PUSH_DATA_BE(lp, p, l)
- */
-
-/*
- * This is called to actually send a packet to the chip.
- */
-static void smc_hardware_send_pkt(unsigned long data)
-{
- struct net_device *dev = (struct net_device *)data;
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- struct sk_buff *skb;
- unsigned int packet_no, len;
- unsigned char *buf;
- unsigned long flags;
-
- DBG(3, "%s: %s\n", dev->name, __func__);
-
- if (!smc_special_trylock(&lp->lock, flags)) {
- netif_stop_queue(dev);
- tasklet_schedule(&lp->tx_task);
- return;
- }
-
- skb = lp->pending_tx_skb;
- if (unlikely(!skb)) {
- smc_special_unlock(&lp->lock, flags);
- return;
- }
- lp->pending_tx_skb = NULL;
-
- packet_no = SMC_GET_AR(lp);
- if (unlikely(packet_no & AR_FAILED)) {
- printk("%s: Memory allocation failed.\n", dev->name);
- dev->stats.tx_errors++;
- dev->stats.tx_fifo_errors++;
- smc_special_unlock(&lp->lock, flags);
- goto done;
- }
-
- /* point to the beginning of the packet */
- SMC_SET_PN(lp, packet_no);
- SMC_SET_PTR(lp, PTR_AUTOINC);
-
- buf = skb->data;
- len = skb->len;
- DBG(2, "%s: TX PNR 0x%x LENGTH 0x%04x (%d) BUF 0x%p\n",
- dev->name, packet_no, len, len, buf);
- PRINT_PKT(buf, len);
-
- /*
- * Send the packet length (+6 for status words, length, and ctl.
- * The card will pad to 64 bytes with zeroes if packet is too small.
- */
- SMC_PUT_PKT_HDR(lp, 0, len + 6);
-
- /* send the actual data */
- SMC_PUSH_DATA(lp, buf, len & ~1);
-
- /* Send final ctl word with the last byte if there is one */
- SMC_outw(((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr, DATA_REG(lp));
-
- /*
- * If THROTTLE_TX_PKTS is set, we stop the queue here. This will
- * have the effect of having at most one packet queued for TX
- * in the chip's memory at all time.
- *
- * If THROTTLE_TX_PKTS is not set then the queue is stopped only
- * when memory allocation (MC_ALLOC) does not succeed right away.
- */
- if (THROTTLE_TX_PKTS)
- netif_stop_queue(dev);
-
- /* queue the packet for TX */
- SMC_SET_MMU_CMD(lp, MC_ENQUEUE);
- smc_special_unlock(&lp->lock, flags);
-
- dev->trans_start = jiffies;
- dev->stats.tx_packets++;
- dev->stats.tx_bytes += len;
-
- SMC_ENABLE_INT(lp, IM_TX_INT | IM_TX_EMPTY_INT);
-
-done: if (!THROTTLE_TX_PKTS)
- netif_wake_queue(dev);
-
- dev_kfree_skb(skb);
-}
-
-/*
- * Since I am not sure if I will have enough room in the chip's ram
- * to store the packet, I call this routine which either sends it
- * now, or set the card to generates an interrupt when ready
- * for the packet.
- */
-static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int numPages, poll_count, status;
- unsigned long flags;
-
- DBG(3, "%s: %s\n", dev->name, __func__);
-
- BUG_ON(lp->pending_tx_skb != NULL);
-
- /*
- * The MMU wants the number of pages to be the number of 256 bytes
- * 'pages', minus 1 (since a packet can't ever have 0 pages :))
- *
- * The 91C111 ignores the size bits, but earlier models don't.
- *
- * Pkt size for allocating is data length +6 (for additional status
- * words, length and ctl)
- *
- * If odd size then last byte is included in ctl word.
- */
- numPages = ((skb->len & ~1) + (6 - 1)) >> 8;
- if (unlikely(numPages > 7)) {
- printk("%s: Far too big packet error.\n", dev->name);
- dev->stats.tx_errors++;
- dev->stats.tx_dropped++;
- dev_kfree_skb(skb);
- return NETDEV_TX_OK;
- }
-
- smc_special_lock(&lp->lock, flags);
-
- /* now, try to allocate the memory */
- SMC_SET_MMU_CMD(lp, MC_ALLOC | numPages);
-
- /*
- * Poll the chip for a short amount of time in case the
- * allocation succeeds quickly.
- */
- poll_count = MEMORY_WAIT_TIME;
- do {
- status = SMC_GET_INT(lp);
- if (status & IM_ALLOC_INT) {
- SMC_ACK_INT(lp, IM_ALLOC_INT);
- break;
- }
- } while (--poll_count);
-
- smc_special_unlock(&lp->lock, flags);
-
- lp->pending_tx_skb = skb;
- if (!poll_count) {
- /* oh well, wait until the chip finds memory later */
- netif_stop_queue(dev);
- DBG(2, "%s: TX memory allocation deferred.\n", dev->name);
- SMC_ENABLE_INT(lp, IM_ALLOC_INT);
- } else {
- /*
- * Allocation succeeded: push packet to the chip's own memory
- * immediately.
- */
- smc_hardware_send_pkt((unsigned long)dev);
- }
-
- return NETDEV_TX_OK;
-}
-
-/*
- * This handles a TX interrupt, which is only called when:
- * - a TX error occurred, or
- * - CTL_AUTO_RELEASE is not set and TX of a packet completed.
- */
-static void smc_tx(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int saved_packet, packet_no, tx_status, pkt_len;
-
- DBG(3, "%s: %s\n", dev->name, __func__);
-
- /* If the TX FIFO is empty then nothing to do */
- packet_no = SMC_GET_TXFIFO(lp);
- if (unlikely(packet_no & TXFIFO_TEMPTY)) {
- PRINTK("%s: smc_tx with nothing on FIFO.\n", dev->name);
- return;
- }
-
- /* select packet to read from */
- saved_packet = SMC_GET_PN(lp);
- SMC_SET_PN(lp, packet_no);
-
- /* read the first word (status word) from this packet */
- SMC_SET_PTR(lp, PTR_AUTOINC | PTR_READ);
- SMC_GET_PKT_HDR(lp, tx_status, pkt_len);
- DBG(2, "%s: TX STATUS 0x%04x PNR 0x%02x\n",
- dev->name, tx_status, packet_no);
-
- if (!(tx_status & ES_TX_SUC))
- dev->stats.tx_errors++;
-
- if (tx_status & ES_LOSTCARR)
- dev->stats.tx_carrier_errors++;
-
- if (tx_status & (ES_LATCOL | ES_16COL)) {
- PRINTK("%s: %s occurred on last xmit\n", dev->name,
- (tx_status & ES_LATCOL) ?
- "late collision" : "too many collisions");
- dev->stats.tx_window_errors++;
- if (!(dev->stats.tx_window_errors & 63) && net_ratelimit()) {
- printk(KERN_INFO "%s: unexpectedly large number of "
- "bad collisions. Please check duplex "
- "setting.\n", dev->name);
- }
- }
-
- /* kill the packet */
- SMC_WAIT_MMU_BUSY(lp);
- SMC_SET_MMU_CMD(lp, MC_FREEPKT);
-
- /* Don't restore Packet Number Reg until busy bit is cleared */
- SMC_WAIT_MMU_BUSY(lp);
- SMC_SET_PN(lp, saved_packet);
-
- /* re-enable transmit */
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_TCR(lp, lp->tcr_cur_mode);
- SMC_SELECT_BANK(lp, 2);
-}
-
-
-/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/
-
-static void smc_mii_out(struct net_device *dev, unsigned int val, int bits)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int mii_reg, mask;
-
- mii_reg = SMC_GET_MII(lp) & ~(MII_MCLK | MII_MDOE | MII_MDO);
- mii_reg |= MII_MDOE;
-
- for (mask = 1 << (bits - 1); mask; mask >>= 1) {
- if (val & mask)
- mii_reg |= MII_MDO;
- else
- mii_reg &= ~MII_MDO;
-
- SMC_SET_MII(lp, mii_reg);
- udelay(MII_DELAY);
- SMC_SET_MII(lp, mii_reg | MII_MCLK);
- udelay(MII_DELAY);
- }
-}
-
-static unsigned int smc_mii_in(struct net_device *dev, int bits)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int mii_reg, mask, val;
-
- mii_reg = SMC_GET_MII(lp) & ~(MII_MCLK | MII_MDOE | MII_MDO);
- SMC_SET_MII(lp, mii_reg);
-
- for (mask = 1 << (bits - 1), val = 0; mask; mask >>= 1) {
- if (SMC_GET_MII(lp) & MII_MDI)
- val |= mask;
-
- SMC_SET_MII(lp, mii_reg);
- udelay(MII_DELAY);
- SMC_SET_MII(lp, mii_reg | MII_MCLK);
- udelay(MII_DELAY);
- }
-
- return val;
-}
-
-/*
- * Reads a register from the MII Management serial interface
- */
-static int smc_phy_read(struct net_device *dev, int phyaddr, int phyreg)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int phydata;
-
- SMC_SELECT_BANK(lp, 3);
-
- /* Idle - 32 ones */
- smc_mii_out(dev, 0xffffffff, 32);
-
- /* Start code (01) + read (10) + phyaddr + phyreg */
- smc_mii_out(dev, 6 << 10 | phyaddr << 5 | phyreg, 14);
-
- /* Turnaround (2bits) + phydata */
- phydata = smc_mii_in(dev, 18);
-
- /* Return to idle state */
- SMC_SET_MII(lp, SMC_GET_MII(lp) & ~(MII_MCLK|MII_MDOE|MII_MDO));
-
- DBG(3, "%s: phyaddr=0x%x, phyreg=0x%x, phydata=0x%x\n",
- __func__, phyaddr, phyreg, phydata);
-
- SMC_SELECT_BANK(lp, 2);
- return phydata;
-}
-
-/*
- * Writes a register to the MII Management serial interface
- */
-static void smc_phy_write(struct net_device *dev, int phyaddr, int phyreg,
- int phydata)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
-
- SMC_SELECT_BANK(lp, 3);
-
- /* Idle - 32 ones */
- smc_mii_out(dev, 0xffffffff, 32);
-
- /* Start code (01) + write (01) + phyaddr + phyreg + turnaround + phydata */
- smc_mii_out(dev, 5 << 28 | phyaddr << 23 | phyreg << 18 | 2 << 16 | phydata, 32);
-
- /* Return to idle state */
- SMC_SET_MII(lp, SMC_GET_MII(lp) & ~(MII_MCLK|MII_MDOE|MII_MDO));
-
- DBG(3, "%s: phyaddr=0x%x, phyreg=0x%x, phydata=0x%x\n",
- __func__, phyaddr, phyreg, phydata);
-
- SMC_SELECT_BANK(lp, 2);
-}
-
-/*
- * Finds and reports the PHY address
- */
-static void smc_phy_detect(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- int phyaddr;
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- lp->phy_type = 0;
-
- /*
- * Scan all 32 PHY addresses if necessary, starting at
- * PHY#1 to PHY#31, and then PHY#0 last.
- */
- for (phyaddr = 1; phyaddr < 33; ++phyaddr) {
- unsigned int id1, id2;
-
- /* Read the PHY identifiers */
- id1 = smc_phy_read(dev, phyaddr & 31, MII_PHYSID1);
- id2 = smc_phy_read(dev, phyaddr & 31, MII_PHYSID2);
-
- DBG(3, "%s: phy_id1=0x%x, phy_id2=0x%x\n",
- dev->name, id1, id2);
-
- /* Make sure it is a valid identifier */
- if (id1 != 0x0000 && id1 != 0xffff && id1 != 0x8000 &&
- id2 != 0x0000 && id2 != 0xffff && id2 != 0x8000) {
- /* Save the PHY's address */
- lp->mii.phy_id = phyaddr & 31;
- lp->phy_type = id1 << 16 | id2;
- break;
- }
- }
-}
-
-/*
- * Sets the PHY to a configuration as determined by the user
- */
-static int smc_phy_fixed(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- int phyaddr = lp->mii.phy_id;
- int bmcr, cfg1;
-
- DBG(3, "%s: %s\n", dev->name, __func__);
-
- /* Enter Link Disable state */
- cfg1 = smc_phy_read(dev, phyaddr, PHY_CFG1_REG);
- cfg1 |= PHY_CFG1_LNKDIS;
- smc_phy_write(dev, phyaddr, PHY_CFG1_REG, cfg1);
-
- /*
- * Set our fixed capabilities
- * Disable auto-negotiation
- */
- bmcr = 0;
-
- if (lp->ctl_rfduplx)
- bmcr |= BMCR_FULLDPLX;
-
- if (lp->ctl_rspeed == 100)
- bmcr |= BMCR_SPEED100;
-
- /* Write our capabilities to the phy control register */
- smc_phy_write(dev, phyaddr, MII_BMCR, bmcr);
-
- /* Re-Configure the Receive/Phy Control register */
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_RPC(lp, lp->rpc_cur_mode);
- SMC_SELECT_BANK(lp, 2);
-
- return 1;
-}
-
-/*
- * smc_phy_reset - reset the phy
- * @dev: net device
- * @phy: phy address
- *
- * Issue a software reset for the specified PHY and
- * wait up to 100ms for the reset to complete. We should
- * not access the PHY for 50ms after issuing the reset.
- *
- * The time to wait appears to be dependent on the PHY.
- *
- * Must be called with lp->lock locked.
- */
-static int smc_phy_reset(struct net_device *dev, int phy)
-{
- struct smc_local *lp = netdev_priv(dev);
- unsigned int bmcr;
- int timeout;
-
- smc_phy_write(dev, phy, MII_BMCR, BMCR_RESET);
-
- for (timeout = 2; timeout; timeout--) {
- spin_unlock_irq(&lp->lock);
- msleep(50);
- spin_lock_irq(&lp->lock);
-
- bmcr = smc_phy_read(dev, phy, MII_BMCR);
- if (!(bmcr & BMCR_RESET))
- break;
- }
-
- return bmcr & BMCR_RESET;
-}
-
-/*
- * smc_phy_powerdown - powerdown phy
- * @dev: net device
- *
- * Power down the specified PHY
- */
-static void smc_phy_powerdown(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- unsigned int bmcr;
- int phy = lp->mii.phy_id;
-
- if (lp->phy_type == 0)
- return;
-
- /* We need to ensure that no calls to smc_phy_configure are
- pending.
- */
- cancel_work_sync(&lp->phy_configure);
-
- bmcr = smc_phy_read(dev, phy, MII_BMCR);
- smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN);
-}
-
-/*
- * smc_phy_check_media - check the media status and adjust TCR
- * @dev: net device
- * @init: set true for initialisation
- *
- * Select duplex mode depending on negotiation state. This
- * also updates our carrier state.
- */
-static void smc_phy_check_media(struct net_device *dev, int init)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
-
- if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) {
- /* duplex state has changed */
- if (lp->mii.full_duplex) {
- lp->tcr_cur_mode |= TCR_SWFDUP;
- } else {
- lp->tcr_cur_mode &= ~TCR_SWFDUP;
- }
-
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_TCR(lp, lp->tcr_cur_mode);
- }
-}
-
-/*
- * Configures the specified PHY through the MII management interface
- * using Autonegotiation.
- * Calls smc_phy_fixed() if the user has requested a certain config.
- * If RPC ANEG bit is set, the media selection is dependent purely on
- * the selection by the MII (either in the MII BMCR reg or the result
- * of autonegotiation.) If the RPC ANEG bit is cleared, the selection
- * is controlled by the RPC SPEED and RPC DPLX bits.
- */
-static void smc_phy_configure(struct work_struct *work)
-{
- struct smc_local *lp =
- container_of(work, struct smc_local, phy_configure);
- struct net_device *dev = lp->dev;
- void __iomem *ioaddr = lp->base;
- int phyaddr = lp->mii.phy_id;
- int my_phy_caps; /* My PHY capabilities */
- int my_ad_caps; /* My Advertised capabilities */
- int status;
-
- DBG(3, "%s:smc_program_phy()\n", dev->name);
-
- spin_lock_irq(&lp->lock);
-
- /*
- * We should not be called if phy_type is zero.
- */
- if (lp->phy_type == 0)
- goto smc_phy_configure_exit;
-
- if (smc_phy_reset(dev, phyaddr)) {
- printk("%s: PHY reset timed out\n", dev->name);
- goto smc_phy_configure_exit;
- }
-
- /*
- * Enable PHY Interrupts (for register 18)
- * Interrupts listed here are disabled
- */
- smc_phy_write(dev, phyaddr, PHY_MASK_REG,
- PHY_INT_LOSSSYNC | PHY_INT_CWRD | PHY_INT_SSD |
- PHY_INT_ESD | PHY_INT_RPOL | PHY_INT_JAB |
- PHY_INT_SPDDET | PHY_INT_DPLXDET);
-
- /* Configure the Receive/Phy Control register */
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_RPC(lp, lp->rpc_cur_mode);
-
- /* If the user requested no auto neg, then go set his request */
- if (lp->mii.force_media) {
- smc_phy_fixed(dev);
- goto smc_phy_configure_exit;
- }
-
- /* Copy our capabilities from MII_BMSR to MII_ADVERTISE */
- my_phy_caps = smc_phy_read(dev, phyaddr, MII_BMSR);
-
- if (!(my_phy_caps & BMSR_ANEGCAPABLE)) {
- printk(KERN_INFO "Auto negotiation NOT supported\n");
- smc_phy_fixed(dev);
- goto smc_phy_configure_exit;
- }
-
- my_ad_caps = ADVERTISE_CSMA; /* I am CSMA capable */
-
- if (my_phy_caps & BMSR_100BASE4)
- my_ad_caps |= ADVERTISE_100BASE4;
- if (my_phy_caps & BMSR_100FULL)
- my_ad_caps |= ADVERTISE_100FULL;
- if (my_phy_caps & BMSR_100HALF)
- my_ad_caps |= ADVERTISE_100HALF;
- if (my_phy_caps & BMSR_10FULL)
- my_ad_caps |= ADVERTISE_10FULL;
- if (my_phy_caps & BMSR_10HALF)
- my_ad_caps |= ADVERTISE_10HALF;
-
- /* Disable capabilities not selected by our user */
- if (lp->ctl_rspeed != 100)
- my_ad_caps &= ~(ADVERTISE_100BASE4|ADVERTISE_100FULL|ADVERTISE_100HALF);
-
- if (!lp->ctl_rfduplx)
- my_ad_caps &= ~(ADVERTISE_100FULL|ADVERTISE_10FULL);
-
- /* Update our Auto-Neg Advertisement Register */
- smc_phy_write(dev, phyaddr, MII_ADVERTISE, my_ad_caps);
- lp->mii.advertising = my_ad_caps;
-
- /*
- * Read the register back. Without this, it appears that when
- * auto-negotiation is restarted, sometimes it isn't ready and
- * the link does not come up.
- */
- status = smc_phy_read(dev, phyaddr, MII_ADVERTISE);
-
- DBG(2, "%s: phy caps=%x\n", dev->name, my_phy_caps);
- DBG(2, "%s: phy advertised caps=%x\n", dev->name, my_ad_caps);
-
- /* Restart auto-negotiation process in order to advertise my caps */
- smc_phy_write(dev, phyaddr, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
-
- smc_phy_check_media(dev, 1);
-
-smc_phy_configure_exit:
- SMC_SELECT_BANK(lp, 2);
- spin_unlock_irq(&lp->lock);
-}
-
-/*
- * smc_phy_interrupt
- *
- * Purpose: Handle interrupts relating to PHY register 18. This is
- * called from the "hard" interrupt handler under our private spinlock.
- */
-static void smc_phy_interrupt(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- int phyaddr = lp->mii.phy_id;
- int phy18;
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- if (lp->phy_type == 0)
- return;
-
- for(;;) {
- smc_phy_check_media(dev, 0);
-
- /* Read PHY Register 18, Status Output */
- phy18 = smc_phy_read(dev, phyaddr, PHY_INT_REG);
- if ((phy18 & PHY_INT_INT) == 0)
- break;
- }
-}
-
-/*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/
-
-static void smc_10bt_check_media(struct net_device *dev, int init)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int old_carrier, new_carrier;
-
- old_carrier = netif_carrier_ok(dev) ? 1 : 0;
-
- SMC_SELECT_BANK(lp, 0);
- new_carrier = (SMC_GET_EPH_STATUS(lp) & ES_LINK_OK) ? 1 : 0;
- SMC_SELECT_BANK(lp, 2);
-
- if (init || (old_carrier != new_carrier)) {
- if (!new_carrier) {
- netif_carrier_off(dev);
- } else {
- netif_carrier_on(dev);
- }
- if (netif_msg_link(lp))
- printk(KERN_INFO "%s: link %s\n", dev->name,
- new_carrier ? "up" : "down");
- }
-}
-
-static void smc_eph_interrupt(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned int ctl;
-
- smc_10bt_check_media(dev, 0);
-
- SMC_SELECT_BANK(lp, 1);
- ctl = SMC_GET_CTL(lp);
- SMC_SET_CTL(lp, ctl & ~CTL_LE_ENABLE);
- SMC_SET_CTL(lp, ctl);
- SMC_SELECT_BANK(lp, 2);
-}
-
-/*
- * This is the main routine of the driver, to handle the device when
- * it needs some attention.
- */
-static irqreturn_t smc_interrupt(int irq, void *dev_id)
-{
- struct net_device *dev = dev_id;
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- int status, mask, timeout, card_stats;
- int saved_pointer;
-
- DBG(3, "%s: %s\n", dev->name, __func__);
-
- spin_lock(&lp->lock);
-
- /* A preamble may be used when there is a potential race
- * between the interruptible transmit functions and this
- * ISR. */
- SMC_INTERRUPT_PREAMBLE;
-
- saved_pointer = SMC_GET_PTR(lp);
- mask = SMC_GET_INT_MASK(lp);
- SMC_SET_INT_MASK(lp, 0);
-
- /* set a timeout value, so I don't stay here forever */
- timeout = MAX_IRQ_LOOPS;
-
- do {
- status = SMC_GET_INT(lp);
-
- DBG(2, "%s: INT 0x%02x MASK 0x%02x MEM 0x%04x FIFO 0x%04x\n",
- dev->name, status, mask,
- ({ int meminfo; SMC_SELECT_BANK(lp, 0);
- meminfo = SMC_GET_MIR(lp);
- SMC_SELECT_BANK(lp, 2); meminfo; }),
- SMC_GET_FIFO(lp));
-
- status &= mask;
- if (!status)
- break;
-
- if (status & IM_TX_INT) {
- /* do this before RX as it will free memory quickly */
- DBG(3, "%s: TX int\n", dev->name);
- smc_tx(dev);
- SMC_ACK_INT(lp, IM_TX_INT);
- if (THROTTLE_TX_PKTS)
- netif_wake_queue(dev);
- } else if (status & IM_RCV_INT) {
- DBG(3, "%s: RX irq\n", dev->name);
- smc_rcv(dev);
- } else if (status & IM_ALLOC_INT) {
- DBG(3, "%s: Allocation irq\n", dev->name);
- tasklet_hi_schedule(&lp->tx_task);
- mask &= ~IM_ALLOC_INT;
- } else if (status & IM_TX_EMPTY_INT) {
- DBG(3, "%s: TX empty\n", dev->name);
- mask &= ~IM_TX_EMPTY_INT;
-
- /* update stats */
- SMC_SELECT_BANK(lp, 0);
- card_stats = SMC_GET_COUNTER(lp);
- SMC_SELECT_BANK(lp, 2);
-
- /* single collisions */
- dev->stats.collisions += card_stats & 0xF;
- card_stats >>= 4;
-
- /* multiple collisions */
- dev->stats.collisions += card_stats & 0xF;
- } else if (status & IM_RX_OVRN_INT) {
- DBG(1, "%s: RX overrun (EPH_ST 0x%04x)\n", dev->name,
- ({ int eph_st; SMC_SELECT_BANK(lp, 0);
- eph_st = SMC_GET_EPH_STATUS(lp);
- SMC_SELECT_BANK(lp, 2); eph_st; }));
- SMC_ACK_INT(lp, IM_RX_OVRN_INT);
- dev->stats.rx_errors++;
- dev->stats.rx_fifo_errors++;
- } else if (status & IM_EPH_INT) {
- smc_eph_interrupt(dev);
- } else if (status & IM_MDINT) {
- SMC_ACK_INT(lp, IM_MDINT);
- smc_phy_interrupt(dev);
- } else if (status & IM_ERCV_INT) {
- SMC_ACK_INT(lp, IM_ERCV_INT);
- PRINTK("%s: UNSUPPORTED: ERCV INTERRUPT\n", dev->name);
- }
- } while (--timeout);
-
- /* restore register states */
- SMC_SET_PTR(lp, saved_pointer);
- SMC_SET_INT_MASK(lp, mask);
- spin_unlock(&lp->lock);
-
-#ifndef CONFIG_NET_POLL_CONTROLLER
- if (timeout == MAX_IRQ_LOOPS && dev->irq != IRQ_MFP_TIMD)
- PRINTK("%s: spurious interrupt (mask = 0x%02x)\n",
- dev->name, mask);
-#endif
- DBG(3, "%s: Interrupt done (%d loops)\n",
- dev->name, MAX_IRQ_LOOPS - timeout);
-
- /*
- * We return IRQ_HANDLED unconditionally here even if there was
- * nothing to do. There is a possibility that a packet might
- * get enqueued into the chip right after TX_EMPTY_INT is raised
- * but just before the CPU acknowledges the IRQ.
- * Better take an unneeded IRQ in some occasions than complexifying
- * the code for all cases.
- */
- return IRQ_HANDLED;
-}
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
-/*
- * Polling receive - used by netconsole and other diagnostic tools
- * to allow network i/o with interrupts disabled.
- */
-static void smc_poll_controller(struct net_device *dev)
-{
- disable_irq(dev->irq);
- smc_interrupt(dev->irq, dev);
- enable_irq(dev->irq);
-}
-#endif
-
-/* Our watchdog timed out. Called by the networking layer */
-static void smc_timeout(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- int status, mask, eph_st, meminfo, fifo;
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- spin_lock_irq(&lp->lock);
- status = SMC_GET_INT(lp);
- mask = SMC_GET_INT_MASK(lp);
- fifo = SMC_GET_FIFO(lp);
- SMC_SELECT_BANK(lp, 0);
- eph_st = SMC_GET_EPH_STATUS(lp);
- meminfo = SMC_GET_MIR(lp);
- SMC_SELECT_BANK(lp, 2);
- spin_unlock_irq(&lp->lock);
- PRINTK( "%s: TX timeout (INT 0x%02x INTMASK 0x%02x "
- "MEM 0x%04x FIFO 0x%04x EPH_ST 0x%04x)\n",
- dev->name, status, mask, meminfo, fifo, eph_st );
-
- smc_reset(dev);
- smc_enable(dev);
-
- /*
- * Reconfiguring the PHY doesn't seem like a bad idea here, but
- * smc_phy_configure() calls msleep() which calls schedule_timeout()
- * which calls schedule(). Hence we use a work queue.
- */
- if (lp->phy_type != 0)
- schedule_work(&lp->phy_configure);
-
- /* We can accept TX packets again */
- dev->trans_start = jiffies; /* prevent tx timeout */
- netif_wake_queue(dev);
-}
-
-/*
- * This routine will, depending on the values passed to it,
- * either make it accept multicast packets, go into
- * promiscuous mode (for TCPDUMP and cousins) or accept
- * a select set of multicast packets
- */
-static void smc_set_multicast_list(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- void __iomem *ioaddr = lp->base;
- unsigned char multicast_table[8];
- int update_multicast = 0;
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- if (dev->flags & IFF_PROMISC) {
- DBG(2, "%s: RCR_PRMS\n", dev->name);
- lp->rcr_cur_mode |= RCR_PRMS;
- }
-
-/* BUG? I never disable promiscuous mode if multicasting was turned on.
- Now, I turn off promiscuous mode, but I don't do anything to multicasting
- when promiscuous mode is turned on.
-*/
-
- /*
- * Here, I am setting this to accept all multicast packets.
- * I don't need to zero the multicast table, because the flag is
- * checked before the table is
- */
- else if (dev->flags & IFF_ALLMULTI || netdev_mc_count(dev) > 16) {
- DBG(2, "%s: RCR_ALMUL\n", dev->name);
- lp->rcr_cur_mode |= RCR_ALMUL;
- }
-
- /*
- * This sets the internal hardware table to filter out unwanted
- * multicast packets before they take up memory.
- *
- * The SMC chip uses a hash table where the high 6 bits of the CRC of
- * address are the offset into the table. If that bit is 1, then the
- * multicast packet is accepted. Otherwise, it's dropped silently.
- *
- * To use the 6 bits as an offset into the table, the high 3 bits are
- * the number of the 8 bit register, while the low 3 bits are the bit
- * within that register.
- */
- else if (!netdev_mc_empty(dev)) {
- struct netdev_hw_addr *ha;
-
- /* table for flipping the order of 3 bits */
- static const unsigned char invert3[] = {0, 4, 2, 6, 1, 5, 3, 7};
-
- /* start with a table of all zeros: reject all */
- memset(multicast_table, 0, sizeof(multicast_table));
-
- netdev_for_each_mc_addr(ha, dev) {
- int position;
-
- /* make sure this is a multicast address -
- shouldn't this be a given if we have it here ? */
- if (!(*ha->addr & 1))
- continue;
-
- /* only use the low order bits */
- position = crc32_le(~0, ha->addr, 6) & 0x3f;
-
- /* do some messy swapping to put the bit in the right spot */
- multicast_table[invert3[position&7]] |=
- (1<<invert3[(position>>3)&7]);
- }
-
- /* be sure I get rid of flags I might have set */
- lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL);
-
- /* now, the table can be loaded into the chipset */
- update_multicast = 1;
- } else {
- DBG(2, "%s: ~(RCR_PRMS|RCR_ALMUL)\n", dev->name);
- lp->rcr_cur_mode &= ~(RCR_PRMS | RCR_ALMUL);
-
- /*
- * since I'm disabling all multicast entirely, I need to
- * clear the multicast list
- */
- memset(multicast_table, 0, sizeof(multicast_table));
- update_multicast = 1;
- }
-
- spin_lock_irq(&lp->lock);
- SMC_SELECT_BANK(lp, 0);
- SMC_SET_RCR(lp, lp->rcr_cur_mode);
- if (update_multicast) {
- SMC_SELECT_BANK(lp, 3);
- SMC_SET_MCAST(lp, multicast_table);
- }
- SMC_SELECT_BANK(lp, 2);
- spin_unlock_irq(&lp->lock);
-}
-
-
-/*
- * Open and Initialize the board
- *
- * Set up everything, reset the card, etc..
- */
-static int
-smc_open(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- /*
- * Check that the address is valid. If its not, refuse
- * to bring the device up. The user must specify an
- * address using ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
- */
- if (!is_valid_ether_addr(dev->dev_addr)) {
- PRINTK("%s: no valid ethernet hw addr\n", __func__);
- return -EINVAL;
- }
-
- /* Setup the default Register Modes */
- lp->tcr_cur_mode = TCR_DEFAULT;
- lp->rcr_cur_mode = RCR_DEFAULT;
- lp->rpc_cur_mode = RPC_DEFAULT |
- lp->cfg.leda << RPC_LSXA_SHFT |
- lp->cfg.ledb << RPC_LSXB_SHFT;
-
- /*
- * If we are not using a MII interface, we need to
- * monitor our own carrier signal to detect faults.
- */
- if (lp->phy_type == 0)
- lp->tcr_cur_mode |= TCR_MON_CSN;
-
- /* reset the hardware */
- smc_reset(dev);
- smc_enable(dev);
-
- /* Configure the PHY, initialize the link state */
- if (lp->phy_type != 0)
- smc_phy_configure(&lp->phy_configure);
- else {
- spin_lock_irq(&lp->lock);
- smc_10bt_check_media(dev, 1);
- spin_unlock_irq(&lp->lock);
- }
-
- netif_start_queue(dev);
- return 0;
-}
-
-/*
- * smc_close
- *
- * this makes the board clean up everything that it can
- * and not talk to the outside world. Caused by
- * an 'ifconfig ethX down'
- */
-static int smc_close(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
-
- DBG(2, "%s: %s\n", dev->name, __func__);
-
- netif_stop_queue(dev);
- netif_carrier_off(dev);
-
- /* clear everything */
- smc_shutdown(dev);
- tasklet_kill(&lp->tx_task);
- smc_phy_powerdown(dev);
- return 0;
-}
-
-/*
- * Ethtool support
- */
-static int
-smc_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- struct smc_local *lp = netdev_priv(dev);
- int ret;
-
- cmd->maxtxpkt = 1;
- cmd->maxrxpkt = 1;
-
- if (lp->phy_type != 0) {
- spin_lock_irq(&lp->lock);
- ret = mii_ethtool_gset(&lp->mii, cmd);
- spin_unlock_irq(&lp->lock);
- } else {
- cmd->supported = SUPPORTED_10baseT_Half |
- SUPPORTED_10baseT_Full |
- SUPPORTED_TP | SUPPORTED_AUI;
-
- if (lp->ctl_rspeed == 10)
- cmd->speed = SPEED_10;
- else if (lp->ctl_rspeed == 100)
- cmd->speed = SPEED_100;
-
- cmd->autoneg = AUTONEG_DISABLE;
- cmd->transceiver = XCVR_INTERNAL;
- cmd->port = 0;
- cmd->duplex = lp->tcr_cur_mode & TCR_SWFDUP ? DUPLEX_FULL : DUPLEX_HALF;
-
- ret = 0;
- }
-
- return ret;
-}
-
-static int
-smc_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- struct smc_local *lp = netdev_priv(dev);
- int ret;
-
- if (lp->phy_type != 0) {
- spin_lock_irq(&lp->lock);
- ret = mii_ethtool_sset(&lp->mii, cmd);
- spin_unlock_irq(&lp->lock);
- } else {
- if (cmd->autoneg != AUTONEG_DISABLE ||
- cmd->speed != SPEED_10 ||
- (cmd->duplex != DUPLEX_HALF && cmd->duplex != DUPLEX_FULL) ||
- (cmd->port != PORT_TP && cmd->port != PORT_AUI))
- return -EINVAL;
-
-// lp->port = cmd->port;
- lp->ctl_rfduplx = cmd->duplex == DUPLEX_FULL;
-
-// if (netif_running(dev))
-// smc_set_port(dev);
-
- ret = 0;
- }
-
- return ret;
-}
-
-static void
-smc_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
-{
- strncpy(info->driver, CARDNAME, sizeof(info->driver));
- strncpy(info->version, version, sizeof(info->version));
- strncpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info));
-}
-
-static int smc_ethtool_nwayreset(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- int ret = -EINVAL;
-
- if (lp->phy_type != 0) {
- spin_lock_irq(&lp->lock);
- ret = mii_nway_restart(&lp->mii);
- spin_unlock_irq(&lp->lock);
- }
-
- return ret;
-}
-
-static u32 smc_ethtool_getmsglevel(struct net_device *dev)
-{
- struct smc_local *lp = netdev_priv(dev);
- return lp->msg_enable;
-}
-
-static void smc_ethtool_setmsglevel(struct net_device *dev, u32 level)
-{
- struct smc_local *lp = netdev_priv(dev);
- lp->msg_enable = level;
-}
-
-static const struct ethtool_ops smc_ethtool_ops = {
- .get_settings = smc_ethtool_getsettings,
- .set_settings = smc_ethtool_setsettings,
- .get_drvinfo = smc_ethtool_getdrvinfo,
-
- .get_msglevel = smc_ethtool_getmsglevel,
- .set_msglevel = smc_ethtool_setmsglevel,
- .nway_reset = smc_ethtool_nwayreset,
- .get_link = ethtool_op_get_link,
-// .get_eeprom = smc_ethtool_geteeprom,
-// .set_eeprom = smc_ethtool_seteeprom,
-};
-
-static const struct net_device_ops smc_netdev_ops = {
- .ndo_open = smc_open,
- .ndo_stop = smc_close,
- .ndo_start_xmit = smc_hard_start_xmit,
- .ndo_tx_timeout = smc_timeout,
- .ndo_set_rx_mode = smc_set_multicast_list,
- .ndo_change_mtu = eth_change_mtu,
- .ndo_validate_addr = eth_validate_addr,
- .ndo_set_mac_address = eth_mac_addr,
-#ifdef CONFIG_NET_POLL_CONTROLLER
- .ndo_poll_controller = smc_poll_controller,
-#endif
-};
-
-/*
- * smc_findirq
- *
- * This routine has a simple purpose -- make the SMC chip generate an
- * interrupt, so an auto-detect routine can detect it, and find the IRQ,
- */
-/*
- * does this still work?
- *
- * I just deleted auto_irq.c, since it was never built...
- * --jgarzik
- */
-static int smc_findirq(struct smc_local *lp)
-{
- void __iomem *ioaddr = lp->base;
- int timeout = 20;
- unsigned long cookie;
-
- DBG(2, "%s: %s\n", CARDNAME, __func__);
-
- cookie = probe_irq_on();
-
- /*
- * What I try to do here is trigger an ALLOC_INT. This is done
- * by allocating a small chunk of memory, which will give an interrupt
- * when done.
- */
- /* enable ALLOCation interrupts ONLY */
- SMC_SELECT_BANK(lp, 2);
- SMC_SET_INT_MASK(lp, IM_ALLOC_INT);
-
- /*
- * Allocate 512 bytes of memory. Note that the chip was just
- * reset so all the memory is available
- */
- SMC_SET_MMU_CMD(lp, MC_ALLOC | 1);
-
- /*
- * Wait until positive that the interrupt has been generated
- */
- do {
- int int_status;
- udelay(10);
- int_status = SMC_GET_INT(lp);
- if (int_status & IM_ALLOC_INT)
- break; /* got the interrupt */
- } while (--timeout);
-
- /*
- * there is really nothing that I can do here if timeout fails,
- * as autoirq_report will return a 0 anyway, which is what I
- * want in this case. Plus, the clean up is needed in both
- * cases.
- */
-
- /* and disable all interrupts again */
- SMC_SET_INT_MASK(lp, 0);
-
- /* and return what I found */
- return probe_irq_off(cookie);
-}
-
-/*
- * Function: smc_probe(unsigned long ioaddr)
- *
- * Purpose:
- * Tests to see if a given ioaddr points to an SMC91x chip.
- * Returns a 0 on success
- *
- * Algorithm:
- * (1) see if the high byte of BANK_SELECT is 0x33
- * (2) compare the ioaddr with the base register's address
- * (3) see if I recognize the chip ID in the appropriate register
- *
- * Here I do typical initialization tasks.
- *
- * o Initialize the structure if needed
- * o print out my vanity message if not done so already
- * o print out what type of hardware is detected
- * o print out the ethernet address
- * o find the IRQ
- * o set up my private data
- * o configure the dev structure with my subroutines
- * o actually GRAB the irq.
- * o GRAB the region
- */
-static int smc_probe(struct net_device *dev, void __iomem *ioaddr,
- unsigned long irq_flags)
-{
- struct smc_local *lp = netdev_priv(dev);
- static int version_printed = 0;
- int retval;
- unsigned int val, revision_register;
- const char *version_string;
-
- DBG(2, "%s: %s\n", CARDNAME, __func__);
-
- /* First, see if there is a card at the expected address! */
- if (!hwreg_present( ioaddr + BANK_SELECT )) {
- retval = -ENODEV;
- goto err_out;
- }
-
- /* First, see if the high byte is 0x33 */
- val = SMC_CURRENT_BANK(lp);
- DBG(2, "%s: bank signature probe returned 0x%04x\n", CARDNAME, val);
- if ((val & 0xFF00) != 0x3300) {
- if ((val & 0xFF) == 0x33) {
- printk(KERN_WARNING
- "%s: Detected possible byte-swapped interface"
- " at IOADDR %p\n", CARDNAME, ioaddr);
- }
- retval = -ENODEV;
- goto err_out;
- }
-
- /*
- * The above MIGHT indicate a device, but I need to write to
- * further test this.
- */
- SMC_SELECT_BANK(lp, 0);
- val = SMC_CURRENT_BANK(lp);
- if ((val & 0xFF00) != 0x3300) {
- retval = -ENODEV;
- goto err_out;
- }
-
- /*
- * well, we've already written once, so hopefully another
- * time won't hurt. This time, I need to switch the bank
- * register to bank 1, so I can access the base address
- * register
- */
- SMC_SELECT_BANK(lp, 1);
- val = SMC_GET_BASE(lp);
- val = ((val & 0x1F00) >> 3) << SMC_IO_SHIFT;
- if (((unsigned int)ioaddr & (0x3e0 << SMC_IO_SHIFT)) != val) {
- printk("%s: IOADDR %p doesn't match configuration (%x).\n",
- CARDNAME, ioaddr, val);
- }
-
- /*
- * check if the revision register is something that I
- * recognize. These might need to be added to later,
- * as future revisions could be added.
- */
- SMC_SELECT_BANK(lp, 3);
- revision_register = SMC_GET_REV(lp);
- DBG(2, "%s: revision = 0x%04x\n", CARDNAME, revision_register);
- version_string = chip_ids[ (revision_register >> 4) & 0xF];
- if (!version_string || (revision_register & 0xff00) != 0x3300) {
- /* I don't recognize this chip, so... */
- printk("%s: IO %p: Unrecognized revision register 0x%04x"
- ", Contact author.\n", CARDNAME,
- ioaddr, revision_register);
-
- retval = -ENODEV;
- goto err_out;
- }
-
- /* At this point I'll assume that the chip is an SMC91x. */
- if (version_printed++ == 0)
- printk("%s", version);
-
- /* fill in some of the fields */
- dev->base_addr = (unsigned long)ioaddr;
- lp->base = ioaddr;
- lp->version = revision_register & 0xff;
- spin_lock_init(&lp->lock);
-
- /* Get the MAC address */
- SMC_SELECT_BANK(lp, 1);
- SMC_GET_MAC_ADDR(lp, dev->dev_addr);
-
- /* now, reset the chip, and put it into a known state */
- smc_reset(dev);
-
- /*
- * If dev->irq is 0, then the device has to be banged on to see
- * what the IRQ is.
- *
- * This banging doesn't always detect the IRQ, for unknown reasons.
- * a workaround is to reset the chip and try again.
- *
- * Interestingly, the DOS packet driver *SETS* the IRQ on the card to
- * be what is requested on the command line. I don't do that, mostly
- * because the card that I have uses a non-standard method of accessing
- * the IRQs, and because this _should_ work in most configurations.
- *
- * Specifying an IRQ is done with the assumption that the user knows
- * what (s)he is doing. No checking is done!!!!
- */
- if (dev->irq < 1) {
- int trials;
-
- trials = 3;
- while (trials--) {
- dev->irq = smc_findirq(lp);
- if (dev->irq)
- break;
- /* kick the card and try again */
- smc_reset(dev);
- }
- }
- if (dev->irq == 0) {
- printk("%s: Couldn't autodetect your IRQ. Use irq=xx.\n",
- dev->name);
- retval = -ENODEV;
- goto err_out;
- }
- dev->irq = irq_canonicalize(dev->irq);
-
- /* Fill in the fields of the device structure with ethernet values. */
- ether_setup(dev);
-
- dev->watchdog_timeo = msecs_to_jiffies(watchdog);
- dev->netdev_ops = &smc_netdev_ops;
- dev->ethtool_ops = &smc_ethtool_ops;
-
- tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev);
- INIT_WORK(&lp->phy_configure, smc_phy_configure);
- lp->dev = dev;
- lp->mii.phy_id_mask = 0x1f;
- lp->mii.reg_num_mask = 0x1f;
- lp->mii.force_media = 0;
- lp->mii.full_duplex = 0;
- lp->mii.dev = dev;
- lp->mii.mdio_read = smc_phy_read;
- lp->mii.mdio_write = smc_phy_write;
-
- /*
- * Locate the phy, if any.
- */
- if (lp->version >= (CHIP_91100 << 4))
- smc_phy_detect(dev);
-
- /* then shut everything down to save power */
- smc_shutdown(dev);
- smc_phy_powerdown(dev);
-
- /* Set default parameters */
- lp->msg_enable = NETIF_MSG_LINK;
- lp->ctl_rfduplx = 0;
- lp->ctl_rspeed = 10;
-
- if (lp->version >= (CHIP_91100 << 4)) {
- lp->ctl_rfduplx = 1;
- lp->ctl_rspeed = 100;
- }
-
- /* Grab the IRQ */
- retval = request_irq(dev->irq, atari_ethernat_interrupt, irq_flags, dev->name, dev);
- if (retval)
- goto err_out;
-
-#ifdef CONFIG_ARCH_PXA
-# ifdef SMC_USE_PXA_DMA
- lp->cfg.flags |= SMC91X_USE_DMA;
-# endif
- if (lp->cfg.flags & SMC91X_USE_DMA) {
- int dma = pxa_request_dma(dev->name, DMA_PRIO_LOW,
- smc_pxa_dma_irq, NULL);
- if (dma >= 0)
- dev->dma = dma;
- }
-#endif
-
- retval = register_netdev(dev);
- if (retval == 0) {
- /* now, print out the card info, in a short format.. */
- printk("%s: %s (rev %d) at %p IRQ %d",
- dev->name, version_string, revision_register & 0x0f,
- lp->base, dev->irq);
-
- if (dev->dma != (unsigned char)-1)
- printk(" DMA %d", dev->dma);
-
- printk(KERN_INFO "%s%s\n",
- lp->cfg.flags & SMC91X_NOWAIT ? " [nowait]" : "",
- THROTTLE_TX_PKTS ? " [throttle_tx]" : "");
-
- if (!is_valid_ether_addr(dev->dev_addr)) {
- printk("%s: Invalid ethernet MAC address. Please "
- "set using ifconfig\n", dev->name);
- random_ether_addr(dev->dev_addr);
- printk(KERN_INFO "%s: Ethernet addr set (random): %pM\n",
- dev->name, dev->dev_addr);
- } else {
- /* Print the Ethernet address */
- printk("%s: Ethernet addr: %pM\n",
- dev->name, dev->dev_addr);
- }
-
- if (lp->phy_type == 0) {
- PRINTK("%s: No PHY found\n", dev->name);
- } else if ((lp->phy_type & 0xfffffff0) == 0x0016f840) {
- PRINTK("%s: PHY LAN83C183 (LAN91C111 Internal)\n", dev->name);
- } else if ((lp->phy_type & 0xfffffff0) == 0x02821c50) {
- PRINTK("%s: PHY LAN83C180\n", dev->name);
- }
- }
-
-err_out:
-#ifdef CONFIG_ARCH_PXA
- if (retval && dev->dma != (unsigned char)-1)
- pxa_free_dma(dev->dma);
-#endif
- return retval;
-}
-
-static int smc_enable_device(struct platform_device *pdev)
-{
- struct net_device *ndev = platform_get_drvdata(pdev);
- struct smc_local *lp = netdev_priv(ndev);
- unsigned long flags;
- unsigned char ecor, ecsr;
- void __iomem *addr;
- struct resource * res;
-
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib");
- if (!res)
- return 0;
-
- /*
- * Map the attribute space. This is overkill, but clean.
- */
- addr = ioremap(res->start, ATTRIB_SIZE);
- if (!addr)
- return -ENOMEM;
-
- /*
- * Reset the device. We must disable IRQs around this
- * since a reset causes the IRQ line become active.
- */
- local_irq_save(flags);
- ecor = readb(addr + (ECOR << SMC_IO_SHIFT)) & ~ECOR_RESET;
- writeb(ecor | ECOR_RESET, addr + (ECOR << SMC_IO_SHIFT));
- readb(addr + (ECOR << SMC_IO_SHIFT));
-
- /*
- * Wait 100us for the chip to reset.
- */
- udelay(100);
-
- /*
- * The device will ignore all writes to the enable bit while
- * reset is asserted, even if the reset bit is cleared in the
- * same write. Must clear reset first, then enable the device.
- */
- writeb(ecor, addr + (ECOR << SMC_IO_SHIFT));
- writeb(ecor | ECOR_ENABLE, addr + (ECOR << SMC_IO_SHIFT));
-
- /*
- * Set the appropriate byte/word mode.
- */
- ecsr = readb(addr + (ECSR << SMC_IO_SHIFT)) & ~ECSR_IOIS8;
- if (!SMC_16BIT(lp))
- ecsr |= ECSR_IOIS8;
- writeb(ecsr, addr + (ECSR << SMC_IO_SHIFT));
- local_irq_restore(flags);
-
- iounmap(addr);
-
- /*
- * Wait for the chip to wake up. We could poll the control
- * register in the main register space, but that isn't mapped
- * yet. We know this is going to take 750us.
- */
- msleep(1);
-
- return 0;
-}
-
-static int smc_request_attrib(struct platform_device *pdev,
- struct net_device *ndev)
-{
- struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib");
-
- if (!res)
- return 0;
-
- if (!request_mem_region(res->start, ATTRIB_SIZE, CARDNAME))
- return -EBUSY;
-
- return 0;
-}
-
-static void smc_release_attrib(struct platform_device *pdev,
- struct net_device *ndev)
-{
- struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib");
-
- if (res)
- release_mem_region(res->start, ATTRIB_SIZE);
-}
-
-static inline void smc_request_datacs(struct platform_device *pdev, struct net_device *ndev)
-{
- if (SMC_CAN_USE_DATACS) {
- struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32");
- struct smc_local *lp = netdev_priv(ndev);
-
- if (!res)
- return;
-
- if(!request_mem_region(res->start, SMC_DATA_EXTENT, CARDNAME)) {
- printk(KERN_INFO "%s: failed to request datacs memory region.\n", CARDNAME);
- return;
- }
-
- lp->datacs = ioremap(res->start, SMC_DATA_EXTENT);
- }
-}
-
-static void smc_release_datacs(struct platform_device *pdev, struct net_device *ndev)
-{
- if (SMC_CAN_USE_DATACS) {
- struct smc_local *lp = netdev_priv(ndev);
- struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-data32");
-
- if (lp->datacs)
- iounmap(lp->datacs);
-
- lp->datacs = NULL;
-
- if (res)
- release_mem_region(res->start, SMC_DATA_EXTENT);
- }
-}
-
-/*
- * smc_init(void)
- * Input parameters:
- * dev->base_addr == 0, try to find all possible locations
- * dev->base_addr > 0x1ff, this is the address to check
- * dev->base_addr == <anything else>, return failure code
- *
- * Output:
- * 0 --> there is a device
- * anything else, error
- */
-static int smc_drv_probe(struct platform_device *pdev)
-{
- struct smc91x_platdata *pd = pdev->dev.platform_data;
- struct smc_local *lp;
- struct net_device *ndev;
- struct resource *res, *ires;
- unsigned int __iomem *addr;
- unsigned long irq_flags = SMC_IRQ_FLAGS;
- int ret;
-
- ndev = alloc_etherdev(sizeof(struct smc_local));
- if (!ndev) {
- printk("%s: could not allocate device.\n", CARDNAME);
- ret = -ENOMEM;
- goto out;
- }
- SET_NETDEV_DEV(ndev, &pdev->dev);
-
- /* get configuration from platform data, only allow use of
- * bus width if both SMC_CAN_USE_xxx and SMC91X_USE_xxx are set.
- */
-
- lp = netdev_priv(ndev);
-
- if (pd) {
- memcpy(&lp->cfg, pd, sizeof(lp->cfg));
- lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags);
- } else {
- lp->cfg.flags |= (SMC_CAN_USE_8BIT) ? SMC91X_USE_8BIT : 0;
- lp->cfg.flags |= (SMC_CAN_USE_16BIT) ? SMC91X_USE_16BIT : 0;
- lp->cfg.flags |= (SMC_CAN_USE_32BIT) ? SMC91X_USE_32BIT : 0;
- lp->cfg.flags |= (nowait) ? SMC91X_NOWAIT : 0;
- }
-
- if (!lp->cfg.leda && !lp->cfg.ledb) {
- lp->cfg.leda = RPC_LSA_DEFAULT;
- lp->cfg.ledb = RPC_LSB_DEFAULT;
- }
-
- ndev->dma = (unsigned char)-1;
-
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs");
- if (!res)
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- ret = -ENODEV;
- goto out_free_netdev;
- }
-
-
- if (!request_mem_region(res->start, SMC_IO_EXTENT, CARDNAME)) {
- ret = -EBUSY;
- goto out_free_netdev;
- }
-
- ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!ires) {
- ret = -ENODEV;
- goto out_release_io;
- }
-
- ndev->irq = ires->start;
-
- if (ndev->irq != IRQ_MFP_TIMD) {
- printk("atari_91C111: IRQ resource specified irq=%d\n", ndev->irq);
-
- /*
- * 080720 MSch: testing timer based interrupts - need to set valid
- * interrupt here or request_irq bails out.
- * polling (use_poll == 1) not tested so far
- * Ultimately, this needs to be set in the platform device
- * data, or be overridden by module arguments
- * The actual level6 interrupt is hardwired to vector
- * 0xc4 according to the MiNT driver source. Interrupts
- * are enabled for the device by setting bit 1 at base+0x20
- * or base+0x23!
- */
- ndev->irq = IRQ_MFP_TIMD;
- ires->start = IRQ_MFP_TIMD;
- printk("atari_91C111: IRQ forced to irq=%d\n", ndev->irq);
- }
-
- if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK)
- irq_flags = ires->flags & IRQF_TRIGGER_MASK;
-
-
- if (ndev->irq == IRQ_MFP_TIMD) {
- printk(KERN_INFO "atari_91C111: Using timer D interrupt - do share!\n");
- irq_flags |= IRQF_SHARED;
- }
-
- ret = smc_request_attrib(pdev, ndev);
- if (ret)
- goto out_release_io;
-#if defined(CONFIG_SA1100_ASSABET)
- NCR_0 |= NCR_ENET_OSC_EN;
-#endif
- platform_set_drvdata(pdev, ndev);
- ret = smc_enable_device(pdev);
- if (ret)
- goto out_release_attrib;
-
- addr = ioremap(res->start, SMC_IO_EXTENT);
- if (!addr) {
- ret = -ENOMEM;
- goto out_release_attrib;
- }
-
-#ifdef CONFIG_ARCH_PXA
- {
- struct smc_local *lp = netdev_priv(ndev);
- lp->device = &pdev->dev;
- lp->physaddr = res->start;
- }
-#endif
-
- /*
- * about to probe for device; need to enable net IRQ here!
- * EtherNAT has interrupt enable register at 0x20 or 0x23
- * probe for base address + 0x23 or 0x20
- */
-
- ret = smc_probe(ndev, addr, irq_flags);
- if (ret != 0)
- goto out_iounmap;
-
- smc_request_datacs(pdev, ndev);
-
- if (ndev->irq == IRQ_MFP_TIMD) {
- /* maybe instead use MFP timer C ?? */
- /* init timer if not already running */
-
- int timd = period * 4;
- if (timd == 0)
- timd = 192; /* 200 Hz */
- else if (timd < 80)
- timd = 80;
- else if (timd > 255)
- timd = 255;
- printk(KERN_INFO "Timer D frequency: %u Hz\n", 38400/timd);
- /* set Timer D data Register */
- st_mfp.tim_dt_d = timd; /* 200 Hz */
- /* start timer D, div = 1:100 */
- st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x5;
- }
-
- return 0;
-
- out_iounmap:
- platform_set_drvdata(pdev, NULL);
- iounmap(addr);
- out_release_attrib:
- smc_release_attrib(pdev, ndev);
- out_release_io:
- release_mem_region(res->start, SMC_IO_EXTENT);
- out_free_netdev:
- free_netdev(ndev);
- out:
- printk("%s: not found (%d).\n", CARDNAME, ret);
-
- return ret;
-}
-
-static int smc_drv_remove(struct platform_device *pdev)
-{
- struct net_device *ndev = platform_get_drvdata(pdev);
- struct smc_local *lp = netdev_priv(ndev);
- struct resource *res;
-
- platform_set_drvdata(pdev, NULL);
-
- unregister_netdev(ndev);
-
- free_irq(ndev->irq, ndev);
-
-#ifdef CONFIG_ARCH_PXA
- if (ndev->dma != (unsigned char)-1)
- pxa_free_dma(ndev->dma);
-#endif
- iounmap(lp->base);
-
- smc_release_datacs(pdev,ndev);
- smc_release_attrib(pdev, ndev);
-
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs");
- if (!res)
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, SMC_IO_EXTENT);
-
- free_netdev(ndev);
-
- return 0;
-}
-
-static int smc_drv_suspend(struct device *dev)
-{
- struct platform_device *pdev = to_platform_device(dev);
- struct net_device *ndev = platform_get_drvdata(pdev);
-
- if (ndev) {
- if (netif_running(ndev)) {
- netif_device_detach(ndev);
- smc_shutdown(ndev);
- smc_phy_powerdown(ndev);
- }
- }
- return 0;
-}
-
-static int smc_drv_resume(struct device *dev)
-{
- struct platform_device *pdev = to_platform_device(dev);
- struct net_device *ndev = platform_get_drvdata(pdev);
-
- if (ndev) {
- struct smc_local *lp = netdev_priv(ndev);
- smc_enable_device(pdev);
- if (netif_running(ndev)) {
- smc_reset(ndev);
- smc_enable(ndev);
- if (lp->phy_type != 0)
- smc_phy_configure(&lp->phy_configure);
- netif_device_attach(ndev);
- }
- }
- return 0;
-}
-
-static struct dev_pm_ops smc_drv_pm_ops = {
- .suspend = smc_drv_suspend,
- .resume = smc_drv_resume,
-};
-
-static struct platform_driver smc_driver = {
- .probe = smc_drv_probe,
- .remove = smc_drv_remove,
- .driver = {
- .name = CARDNAME,
- .owner = THIS_MODULE,
- .pm = &smc_drv_pm_ops,
- },
-};
-
-static int __init smc_init(void)
-{
- if (!MACH_IS_ATARI)
- return -ENODEV;
-
-#ifdef MODULE
-#ifdef CONFIG_ISA
- if (io == -1)
- printk(KERN_WARNING
- "%s: You shouldn't use auto-probing with insmod!\n",
- CARDNAME);
-#endif
-#endif
-
- return platform_driver_register(&smc_driver);
-}
-
-static void __exit smc_cleanup(void)
-{
- platform_driver_unregister(&smc_driver);
-}
-
-module_init(smc_init);
-module_exit(smc_cleanup);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 03/14] m68k/atari: use CONFIG_ATARI in smc91x.h
2013-03-25 1:16 (unknown), Michael Schmitz
2013-03-25 1:16 ` [PATCH 01/14] m68k/atari EtherNEC: remove original EtherNEC driver Michael Schmitz
2013-03-25 1:16 ` [PATCH 02/14] m68k/atari EtherNAT: remove original EtherNAT driver Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 04/14] m68k/atari: EtherNAT - change number of Atari interrupt sources Michael Schmitz
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
drivers/net/ethernet/smsc/smc91x.h | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h
index f0f950c..528f7ba 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -231,7 +231,7 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
#include <unit/smc91111.h>
-#elif defined(CONFIG_ATARI_ETHERNAT) || defined(CONFIG_ATARI_ETHERNAT_MODULE)
+#elif defined(CONFIG_ATARI)
#define SMC_CAN_USE_8BIT 1
#define SMC_CAN_USE_16BIT 1
@@ -255,8 +255,6 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
#define RPC_LSA_DEFAULT RPC_LED_100_10
#define RPC_LSB_DEFAULT RPC_LED_TX_RX
-#define SMC_DYNAMIC_BUS_CONFIG
-
#elif defined(CONFIG_ARCH_MSM)
#define SMC_CAN_USE_8BIT 0
@@ -1142,7 +1140,7 @@ static const char * chip_ids[ 16 ] = {
} \
} while (0)
-#if defined(CONFIG_ATARI_ETHERNAT) || defined(CONFIG_ATARI_ETHERNAT_MODULE)
+#if defined(CONFIG_ATARI)
/*
* MSch: EtherNAT is 32 bit, so the misaligned data buffer hack applies.
* This appears to hurt quite a lot ... we actually need to byte swap the
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 04/14] m68k/atari: EtherNAT - change number of Atari interrupt sources
2013-03-25 1:16 (unknown), Michael Schmitz
` (2 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 03/14] m68k/atari: use CONFIG_ATARI in smc91x.h Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 05/14] m68k/irq: add handle_polled_irq() for timer based soft interrupts Michael Schmitz
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Increase the number of Atari interrupt sources to include EtherNAT
interrupts (interrupt nunbers 139/140, vectors 0xc3/0xc4).
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/atari/config.c | 20 +++++++++++++++++---
arch/m68k/include/asm/atariints.h | 2 +-
arch/m68k/include/asm/irq.h | 6 +++++-
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index ee9bb70..6c3e885 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -661,7 +661,7 @@ static void atari_get_hardware_list(struct seq_file *m)
* MSch: initial platform device support for Atari, required for EtherNAT
*/
-#define ATARI_ETHERNAT_IRQ 0xc3
+#define ATARI_ETHERNAT_IRQ 140
static struct resource smc91x_resources[] = {
[0] = {
@@ -685,16 +685,30 @@ static struct platform_device smc91x_device = {
.resource = smc91x_resources,
};
-static struct platform_device *atari_platform_devices[] __initdata = {
+static struct platform_device *atari_ethernat_devices[] __initdata = {
&smc91x_device
};
int __init atari_platform_init(void)
{
+ int rv = 0;
+
if (!MACH_IS_ATARI)
return -ENODEV;
- return platform_add_devices(atari_platform_devices, ARRAY_SIZE(atari_platform_devices));
+#ifdef CONFIG_ATARI_ETHERNAT
+ {
+ unsigned char *enatc_virt;
+ enatc_virt = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0xf);
+ if (hwreg_present(enatc_virt)) {
+ rv = platform_add_devices(atari_ethernat_devices,
+ ARRAY_SIZE(atari_ethernat_devices));
+ }
+ iounmap(enatc_virt);
+ }
+#endif
+
+ return rv;
}
arch_initcall(atari_platform_init);
diff --git a/arch/m68k/include/asm/atariints.h b/arch/m68k/include/asm/atariints.h
index 5fc13bd..12c759a 100644
--- a/arch/m68k/include/asm/atariints.h
+++ b/arch/m68k/include/asm/atariints.h
@@ -32,7 +32,7 @@
#define VME_SOURCE_BASE 56
#define VME_MAX_SOURCES 16
-#define NUM_ATARI_SOURCES (VME_SOURCE_BASE+VME_MAX_SOURCES-STMFP_SOURCE_BASE)
+#define NUM_ATARI_SOURCES 141
/* convert vector number to int source number */
#define IRQ_VECTOR_TO_SOURCE(v) ((v) - ((v) < 0x20 ? 0x18 : (0x40-8)))
diff --git a/arch/m68k/include/asm/irq.h b/arch/m68k/include/asm/irq.h
index c1155f0..81ca118 100644
--- a/arch/m68k/include/asm/irq.h
+++ b/arch/m68k/include/asm/irq.h
@@ -6,12 +6,16 @@
* different m68k hosts compiled into the kernel.
* Currently the Atari has 72 and the Amiga 24, but if both are
* supported in the kernel it is better to make room for 72.
+ * With EtherNAT add-on card on Atari, the highest interrupt
+ * number is 140 so NR_IRQS needs to be 141.
*/
#if defined(CONFIG_COLDFIRE)
#define NR_IRQS 256
#elif defined(CONFIG_VME) || defined(CONFIG_SUN3) || defined(CONFIG_SUN3X)
#define NR_IRQS 200
-#elif defined(CONFIG_ATARI) || defined(CONFIG_MAC)
+#elif defined(CONFIG_ATARI)
+#define NR_IRQS 141
+#elif defined(CONFIG_MAC)
#define NR_IRQS 72
#elif defined(CONFIG_Q40)
#define NR_IRQS 43
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 05/14] m68k/irq: add handle_polled_irq() for timer based soft interrupts
2013-03-25 1:16 (unknown), Michael Schmitz
` (3 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 04/14] m68k/atari: EtherNAT - change number of Atari interrupt sources Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 06/14] m68k/atari: use dedicated irq_chip for timer D interrupts Michael Schmitz
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
This patch adds a special 'polled interrupt' handler for timer based software interrupts.
handle_simple_irq() will respond to excessive unhandled interrupts (as are expected for a
polling timer interrupt) by disabling the apparently unhandled interrupt source.
handle_polled_irq() prevents this by setting the IRQS_POLL_INPROGRESS flag which will cause
the unhandled interrupt events to be ignored.
This is a temporary hack to allow timer based polling of the Atari ROM port network and USB
cards only. Suggestions on how to properly handle this in the normal interrupt framework are
most welcome.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
include/linux/irq.h | 1 +
kernel/irq/chip.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index bc4e066..5064385 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -407,6 +407,7 @@ extern void handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_edge_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
+extern void handle_polled_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_percpu_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index cbd97ce..667e4c1 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -353,6 +353,42 @@ out_unlock:
}
EXPORT_SYMBOL_GPL(handle_simple_irq);
+/**
+ * handle_polled_irq - Simple and software-decoded IRQs.
+ * @irq: the interrupt number
+ * @desc: the interrupt description structure for this irq
+ *
+ * Polled interrupts are sent from a demultiplexing software interrupt
+ * handler, where no interrupt hardware control is necessary.
+ */
+void
+handle_polled_irq(unsigned int irq, struct irq_desc *desc)
+{
+ raw_spin_lock(&desc->lock);
+
+ if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
+ if (!irq_check_poll(desc))
+ goto out_unlock;
+
+ desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
+ kstat_incr_irqs_this_cpu(irq, desc);
+
+ if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
+ desc->istate |= IRQS_PENDING;
+ goto out_unlock;
+ }
+
+ desc->istate |= IRQS_POLL_INPROGRESS;
+
+ handle_irq_event(desc);
+
+ desc->istate &= ~(IRQS_POLL_INPROGRESS);
+
+out_unlock:
+ raw_spin_unlock(&desc->lock);
+}
+EXPORT_SYMBOL_GPL(handle_polled_irq);
+
/*
* Called unconditionally from handle_level_irq() and only for oneshot
* interrupts from handle_fasteoi_irq()
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 06/14] m68k/atari: use dedicated irq_chip for timer D interrupts
2013-03-25 1:16 (unknown), Michael Schmitz
` (4 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 05/14] m68k/irq: add handle_polled_irq() for timer based soft interrupts Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 07/14] m68k/atari: EtherNEC - add platform device support Michael Schmitz
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
The MFP timer D is used as a polling timer for EtherNEC and NetUSBee
on Atari. Set up a dedicated IRQ chip for timer D to simplify interrupt
sharing, and use the new 'polling' IRQ handler for its interrupts.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/atari/ataints.c | 70 +++++++++++++++++++++++++++++++++++++
arch/m68k/include/asm/atariints.h | 9 +++++
2 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c
index 3f41092..2cf7349 100644
--- a/arch/m68k/atari/ataints.c
+++ b/arch/m68k/atari/ataints.c
@@ -122,6 +122,62 @@ static struct irq_chip atari_irq_chip = {
};
/*
+ * ST-MFP timer D chained interrupts - each driver gets its own timer
+ * interrupt instance.
+ */
+
+struct mfptimerbase {
+ volatile struct MFP *mfp;
+ unsigned char mfp_mask, mfp_data;
+ unsigned short int_mask;
+ int handler_irq, mfptimer_irq, server_irq;
+ char *name;
+} stmfp_base = {
+ .mfp = &st_mfp,
+ .int_mask = 0x0,
+ .handler_irq = IRQ_MFP_TIMD,
+ .mfptimer_irq = IRQ_MFP_TIMER1,
+ .name = "MFP Timer D"
+};
+
+static irqreturn_t mfptimer_handler(int irq, void *dev_id)
+{
+ struct mfptimerbase *base = dev_id;
+ int mach_irq;
+ unsigned char ints;
+
+ mach_irq = base->mfptimer_irq;
+ ints = base->int_mask;
+ for (; ints; mach_irq++, ints >>= 1) {
+ if (ints & 1)
+ generic_handle_irq(mach_irq);
+ }
+ return IRQ_HANDLED;
+}
+
+
+static void atari_mfptimer_enable(struct irq_data *data)
+{
+ int mfp_num = data->irq - IRQ_MFP_TIMER1;
+ stmfp_base.int_mask |= 1 << mfp_num;
+ atari_enable_irq(IRQ_MFP_TIMD);
+}
+
+static void atari_mfptimer_disable(struct irq_data *data)
+{
+ int mfp_num = data->irq - IRQ_MFP_TIMER1;
+ stmfp_base.int_mask &= ~(1 << mfp_num);
+ if (!stmfp_base.int_mask)
+ atari_disable_irq(IRQ_MFP_TIMD);
+}
+
+static struct irq_chip atari_mfptimer_chip = {
+ .name = "timer_d",
+ .irq_enable = atari_mfptimer_enable,
+ .irq_disable = atari_mfptimer_disable,
+};
+
+/*
* void atari_init_IRQ (void)
*
* Parameters: None
@@ -198,6 +254,20 @@ void __init atari_init_IRQ(void)
/* Initialize the PSG: all sounds off, both ports output */
sound_ym.rd_data_reg_sel = 7;
sound_ym.wd_data = 0xff;
+
+ m68k_setup_irq_controller(&atari_mfptimer_chip, handle_polled_irq,
+ IRQ_MFP_TIMER1, 8);
+
+ /* prepare timer D data for use as poll interrupt */
+ /* set Timer D data Register - needs to be > 0 */
+ st_mfp.tim_dt_d = 254; /* < 100 Hz */
+ /* start timer D, div = 1:100 */
+ st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x6;
+
+ /* request timer D dispatch handler */
+ if (request_irq(IRQ_MFP_TIMD, mfptimer_handler, IRQF_SHARED,
+ stmfp_base.name, &stmfp_base))
+ pr_err("Couldn't register %s interrupt\n", stmfp_base.name);
}
diff --git a/arch/m68k/include/asm/atariints.h b/arch/m68k/include/asm/atariints.h
index 12c759a..953e0ac 100644
--- a/arch/m68k/include/asm/atariints.h
+++ b/arch/m68k/include/asm/atariints.h
@@ -94,6 +94,15 @@
#define IRQ_SCCA_RX (52)
#define IRQ_SCCA_SPCOND (54)
+/* shared MFP timer D interrupts - hires timer for EtherNEC et al. */
+#define IRQ_MFP_TIMER1 (64)
+#define IRQ_MFP_TIMER2 (65)
+#define IRQ_MFP_TIMER3 (66)
+#define IRQ_MFP_TIMER4 (67)
+#define IRQ_MFP_TIMER5 (68)
+#define IRQ_MFP_TIMER6 (69)
+#define IRQ_MFP_TIMER7 (70)
+#define IRQ_MFP_TIMER8 (71)
#define INT_CLK 24576 /* CLK while int_clk =2.456MHz and divide = 100 */
#define INT_TICKS 246 /* to make sched_time = 99.902... HZ */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 07/14] m68k/atari: EtherNEC - add platform device support
2013-03-25 1:16 (unknown), Michael Schmitz
` (5 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 06/14] m68k/atari: use dedicated irq_chip for timer D interrupts Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 08/14] m68k/atari: EtherNAT - ethernet support - new driver (smc91x) Michael Schmitz
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Platform device support for EtherNEC, uset by ne.c driver.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/atari/config.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index 6c3e885..19114f5 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -689,6 +689,36 @@ static struct platform_device *atari_ethernat_devices[] __initdata = {
&smc91x_device
};
+#define ATARI_ETHERNEC_PHYS_ADDR 0xfffa0000
+#define ATARI_ETHERNEC_BASE 0x300
+#define ATARI_ETHERNEC_IRQ IRQ_MFP_TIMER1
+
+static struct resource rtl8019_resources[] = {
+ [0] = {
+ .name = "rtl8019-regs",
+ .start = ATARI_ETHERNEC_BASE,
+ .end = ATARI_ETHERNEC_BASE + 0x20 - 1,
+ .flags = IORESOURCE_IO,
+ },
+ [1] = {
+ .name = "rtl8019-irq",
+ .start = ATARI_ETHERNEC_IRQ,
+ .end = ATARI_ETHERNEC_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device rtl8019_device = {
+ .name = "ne",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(rtl8019_resources),
+ .resource = rtl8019_resources,
+};
+
+static struct platform_device *atari_ethernec_devices[] __initdata = {
+ &rtl8019_device
+};
+
int __init atari_platform_init(void)
{
int rv = 0;
@@ -708,6 +738,21 @@ int __init atari_platform_init(void)
}
#endif
+#ifdef CONFIG_ATARI_ETHERNEC
+ {
+ int error;
+ unsigned char *enec_virt;
+ enec_virt = (unsigned char *)ioremap((ATARI_ETHERNEC_PHYS_ADDR), 0xf);
+ if (hwreg_present(enec_virt)) {
+ error = platform_add_devices(atari_ethernec_devices,
+ ARRAY_SIZE(atari_ethernec_devices));
+ if (error && !rv)
+ rv = error;
+ }
+ iounmap(enec_virt);
+ }
+#endif
+
return rv;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 08/14] m68k/atari: EtherNAT - ethernet support - new driver (smc91x)
2013-03-25 1:16 (unknown), Michael Schmitz
` (6 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 07/14] m68k/atari: EtherNEC - add platform device support Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 09/14] m68k/atari: EtherNEC - ethernet support - new driver (ne.c) Michael Schmitz
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Use smc91x driver for Atari EtherNAT SMC91C111 ethernet chip.
Change to smc91x.h is necessary to avoid corruption of outgoing
ethernet packet headers (first two bytes end up swapped otherwise).
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/Kconfig.devices | 10 ++++++++++
drivers/net/ethernet/smsc/Kconfig | 2 +-
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/arch/m68k/Kconfig.devices b/arch/m68k/Kconfig.devices
index 4bc945d..d50ecbf 100644
--- a/arch/m68k/Kconfig.devices
+++ b/arch/m68k/Kconfig.devices
@@ -55,6 +55,16 @@ config NFETH
which will emulate a regular ethernet device while presenting an
ethertap device to the host system.
+config ATARI_ETHERNAT
+ bool "Atari EtherNAT Ethernet support"
+ depends on ATARI
+ ---help---
+ Say Y to include support for the EtherNAT network adapter for the
+ CT/60 extension port.
+
+ To compile the actual ethernet driver, choose Y or M for the SMC91X
+ option in the network device section; the module will be called smc91x.
+
endmenu
menu "Character devices"
diff --git a/drivers/net/ethernet/smsc/Kconfig b/drivers/net/ethernet/smsc/Kconfig
index bb1e8f3..d3485cf 100644
--- a/drivers/net/ethernet/smsc/Kconfig
+++ b/drivers/net/ethernet/smsc/Kconfig
@@ -40,7 +40,7 @@ config SMC91X
select NET_CORE
select MII
depends on (ARM || M32R || SUPERH || MIPS || BLACKFIN || \
- MN10300 || COLDFIRE)
+ MN10300 || COLDFIRE || ATARI_ETHERNAT)
---help---
This is a driver for SMC's 91x series of Ethernet chipsets,
including the SMC91C94 and the SMC91C111. Say Y if you want it
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 09/14] m68k/atari: EtherNEC - ethernet support - new driver (ne.c)
2013-03-25 1:16 (unknown), Michael Schmitz
` (7 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 08/14] m68k/atari: EtherNAT - ethernet support - new driver (smc91x) Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 10/14] m68k/atari: EtherNAT - add interrupt chip for Ethernet and USB interrupts Michael Schmitz
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Use ne.c driver for Atari EtherNEC and NetUSBee network adapters.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/Kconfig.devices | 11 +++++++++++
drivers/net/ethernet/8390/Kconfig | 3 ++-
drivers/net/ethernet/8390/ne.c | 2 ++
3 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/arch/m68k/Kconfig.devices b/arch/m68k/Kconfig.devices
index d50ecbf..1c38a91 100644
--- a/arch/m68k/Kconfig.devices
+++ b/arch/m68k/Kconfig.devices
@@ -65,6 +65,17 @@ config ATARI_ETHERNAT
To compile the actual ethernet driver, choose Y or M for the SMC91X
option in the network device section; the module will be called smc91x.
+config ATARI_ETHERNEC
+ bool "Atari EtherNEC Ethernet support"
+ depends on ATARI_ROM_ISA
+ ---help---
+ Say Y to include support for the EtherNEC and NetUSBee network adapters
+ for the ROM port. The driver works by polling instead of interrupts, so
+ it is quite slow.
+
+ To compile the actual ethernet driver, choose Y or M in for the NE2000
+ option in the network device section; the module will be called ne.
+
endmenu
menu "Character devices"
diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index a5f91e1..53abc78 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -91,7 +91,8 @@ config MCF8390
config NE2000
tristate "NE2000/NE1000 support"
- depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX)
+ depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX || \
+ ATARI_ETHERNEC)
select CRC32
---help---
If you have a network (Ethernet) card of this type, say Y and read
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index 47618e5..49948f6 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -166,6 +166,8 @@ bad_clone_list[] __initdata = {
#elif defined(CONFIG_PLAT_OAKS32R) || \
defined(CONFIG_MACH_TX49XX)
# define DCR_VAL 0x48 /* 8-bit mode */
+#elif defined(CONFIG_ATARI) /* 8-bit mode on Atari, normal on Q40 */
+# define DCR_VAL (MACH_IS_ATARI ? 0x48 : 0x49)
#else
# define DCR_VAL 0x49
#endif
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 10/14] m68k/atari: EtherNAT - add interrupt chip for Ethernet and USB interrupts
2013-03-25 1:16 (unknown), Michael Schmitz
` (8 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 09/14] m68k/atari: EtherNEC - ethernet support - new driver (ne.c) Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 11/14] m68k/atari: Implement 16 bit access macros for ROM port Michael Schmitz
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Add a dedicated interrupt chip definition for the EtherNAT CPLD interrupts.
SMC91C111 and ISP1160 chips have separate interrupts that can be enabled
and disabled in a CPLD register at offset 0x23 from the card base.
The smc91x and isp116x-hcd drivers will use this feature.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/atari/ataints.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c
index 2cf7349..525e641 100644
--- a/arch/m68k/atari/ataints.c
+++ b/arch/m68k/atari/ataints.c
@@ -49,6 +49,7 @@
#include <asm/atari_stdma.h>
#include <asm/irq.h>
#include <asm/entry.h>
+#include <asm/io.h>
/*
@@ -177,6 +178,66 @@ static struct irq_chip atari_mfptimer_chip = {
.irq_disable = atari_mfptimer_disable,
};
+
+/*
+ * EtherNAT CPLD interrupt handling
+ * CPLD interrupt register is at phys. 0x80000023
+ * Need this mapped in at interrupt startup time
+ */
+
+static unsigned char *enat_cpld;
+
+static unsigned int atari_ethernat_startup(struct irq_data *data)
+{
+ int enat_num = 140 - data->irq + 1;
+
+ m68k_irq_startup(data);
+ /*
+ * map CPLD interrupt register
+ */
+ if (!enat_cpld)
+ enat_cpld = (unsigned char *)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0x2);
+ /*
+ * do _not_ enable the USB chip interrupt here - causes interrupt storm
+ * and triggers dead interrupt watchdog
+ * Need to reset the USB chip to a sane state in early startup before removing this hack
+ */
+ if (enat_num == 1)
+ *enat_cpld |= 1 << enat_num;
+
+ return 0;
+}
+
+static void atari_ethernat_enable(struct irq_data *data)
+{
+ int enat_num = 140 - data->irq + 1;
+ *enat_cpld |= 1 << enat_num;
+}
+
+static void atari_ethernat_disable(struct irq_data *data)
+{
+ int enat_num = 140 - data->irq + 1;
+ *enat_cpld &= ~(1 << enat_num);
+}
+
+static void atari_ethernat_shutdown(struct irq_data *data)
+{
+ int enat_num = 140 - data->irq + 1;
+ if (enat_cpld) {
+ *enat_cpld &= ~(1 << enat_num);
+ iounmap(enat_cpld);
+ enat_cpld = NULL;
+ }
+}
+
+static struct irq_chip atari_ethernat_chip = {
+ .name = "ethernat",
+ .irq_startup = atari_ethernat_startup,
+ .irq_shutdown = atari_ethernat_shutdown,
+ .irq_enable = atari_ethernat_enable,
+ .irq_disable = atari_ethernat_disable,
+};
+
/*
* void atari_init_IRQ (void)
*
@@ -268,6 +329,13 @@ void __init atari_init_IRQ(void)
if (request_irq(IRQ_MFP_TIMD, mfptimer_handler, IRQF_SHARED,
stmfp_base.name, &stmfp_base))
pr_err("Couldn't register %s interrupt\n", stmfp_base.name);
+
+ /*
+ * EtherNAT ethernet / USB interrupt handlers
+ */
+
+ m68k_setup_irq_controller(&atari_ethernat_chip, handle_simple_irq,
+ 139, 2);
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 11/14] m68k/atari: Implement 16 bit access macros for ROM port
2013-03-25 1:16 (unknown), Michael Schmitz
` (9 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 10/14] m68k/atari: EtherNAT - add interrupt chip for Ethernet and USB interrupts Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 12/14] m68k: Implement ndelay() based on the existing udelay() logic Michael Schmitz
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Implement 16 bit access for ROM port adapter cards, following debugging
and clarification by David Galvez <dgalvez75@gmail.com>
Remove 32 bit ROM port access macros introduced in original ROM port
access patch. 32 bit writes are impossible to Atari ROM port adapters
without dropping the top bits - even 16 bit writes are done as two 8 bit
ones in order to keep room for the address and chip select bits.
32 bit read should work but there's no adapter hardware that would use these.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/include/asm/io_mm.h | 44 ++++++++++++------------------
arch/m68k/include/asm/raw_io.h | 57 +++++++++++++++++----------------------
2 files changed, 43 insertions(+), 58 deletions(-)
diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h
index 6eb2834..40884fe 100644
--- a/arch/m68k/include/asm/io_mm.h
+++ b/arch/m68k/include/asm/io_mm.h
@@ -68,10 +68,10 @@
#define enec_isa_read_base 0xfffa0000
#define enec_isa_write_base 0xfffb0000
-#define ENEC_ISA_IO_B(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x1F)<<9))
-#define ENEC_ISA_IO_W(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x1F)<<9))
-#define ENEC_ISA_MEM_B(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x1F)<<9))
-#define ENEC_ISA_MEM_W(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x1F)<<9))
+#define ENEC_ISA_IO_B(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x7F)<<9))
+#define ENEC_ISA_IO_W(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x7F)<<9))
+#define ENEC_ISA_MEM_B(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x7F)<<9))
+#define ENEC_ISA_MEM_W(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x7F)<<9))
#ifndef MULTI_ISA
#define MULTI_ISA 0
@@ -261,27 +261,29 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
#define isa_rom_inw(port) \
(ISA_SEX ? rom_in_be16(isa_itw(port)) \
: rom_in_le16(isa_itw(port)))
-#define isa_rom_inl(port) \
- (ISA_SEX ? rom_in_be32(isa_itw(port)) \
- : rom_in_le32(isa_itw(port)))
#define isa_rom_outb(val, port) rom_out_8(isa_itb(port), (val))
#define isa_rom_outw(val, port) \
(ISA_SEX ? rom_out_be16(isa_itw(port), (val)) \
: rom_out_le16(isa_itw(port), (val)))
-#define isa_rom_outl(val, port) \
- (ISA_SEX ? rom_out_be32(isa_itw(port), (val)) \
- : rom_out_le32(isa_itw(port), (val)))
#define isa_rom_readb(p) rom_in_8(isa_mtb((unsigned long)(p)))
#define isa_rom_readw(p) \
(ISA_SEX ? rom_in_be16(isa_mtw((unsigned long)(p))) \
: rom_in_le16(isa_mtw((unsigned long)(p))))
+#define isa_rom_readw_swap(p) \
+ (ISA_SEX ? rom_in_le16(isa_mtw((unsigned long)(p))) \
+ : rom_in_be16(isa_mtw((unsigned long)(p))))
+#define isa_rom_readw_raw(p) rom_in_be16(isa_mtw((unsigned long)(p)))
#define isa_rom_writeb(val, p) rom_out_8(isa_mtb((unsigned long)(p)), (val))
#define isa_rom_writew(val, p) \
(ISA_SEX ? rom_out_be16(isa_mtw((unsigned long)(p)), (val)) \
: rom_out_le16(isa_mtw((unsigned long)(p)), (val)))
+#define isa_rom_writew_swap(val, p) \
+ (ISA_SEX ? rom_out_le16(isa_mtw((unsigned long)(p)), (val)) \
+ : rom_out_be16(isa_mtw((unsigned long)(p)), (val)))
+#define isa_rom_writew_raw(val, p) rom_out_be16(isa_mtw((unsigned long)(p)), (val))
#endif /* CONFIG_ATARI_ROM_ISA */
static inline void isa_delay(void)
@@ -331,10 +333,8 @@ static inline void isa_delay(void)
#ifdef CONFIG_ATARI_ROM_ISA
#define isa_rom_inb_p(p) ({ u8 _v = isa_rom_inb(p); isa_delay(); _v; })
#define isa_rom_inw_p(p) ({ u16 _v = isa_rom_inw(p); isa_delay(); _v; })
-#define isa_rom_inl_p(p) ({ u32 _v = isa_rom_inl(p); isa_delay(); _v; })
#define isa_rom_outb_p(v, p) ({ isa_rom_outb((v), (p)); isa_delay(); })
#define isa_rom_outw_p(v, p) ({ isa_rom_outw((v), (p)); isa_delay(); })
-#define isa_rom_outl_p(v, p) ({ isa_rom_outl((v), (p)); isa_delay(); })
#define isa_rom_insb(port, buf, nr) raw_rom_insb(isa_itb(port), (u8 *)(buf), (nr))
@@ -342,19 +342,11 @@ static inline void isa_delay(void)
(ISA_SEX ? raw_rom_insw(isa_itw(port), (u16 *)(buf), (nr)) : \
raw_rom_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
-#define isa_rom_insl(port, buf, nr) \
- (ISA_SEX ? raw_rom_insl(isa_itw(port), (u32 *)(buf), (nr)) : \
- raw_rom_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
-
#define isa_rom_outsb(port, buf, nr) raw_rom_outsb(isa_itb(port), (u8 *)(buf), (nr))
#define isa_rom_outsw(port, buf, nr) \
(ISA_SEX ? raw_rom_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \
raw_rom_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
-
-#define isa_rom_outsl(port, buf, nr) \
- (ISA_SEX ? raw_rom_outsl(isa_itw(port), (u32 *)(buf), (nr)) : \
- raw_rom_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
#endif /* CONFIG_ATARI_ROM_ISA */
#endif /* CONFIG_ISA || CONFIG_ATARI_ROM_ISA */
@@ -396,22 +388,22 @@ static inline void isa_delay(void)
#define inb_p(port) ((port) < 1024 ? isa_rom_inb_p(port) : in_8(port))
#define inw(port) ((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
#define inw_p(port) ((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
-#define inl(port) ((port) < 1024 ? isa_rom_inl(port) : in_le32(port))
-#define inl_p(port) ((port) < 1024 ? isa_rom_inl_p(port) : in_le32(port))
+#define inl isa_inl
+#define inl_p isa_inl_p
#define outb(val, port) ((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
#define outw(val, port) ((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
-#define outl(val, port) ((port) < 1024 ? isa_rom_outl((val), (port)) : out_le32((port), (val)))
-#define outl_p(val, port) ((port) < 1024 ? isa_rom_outl_p((val), (port)) : out_le32((port), (val)))
+#define outl isa_outl
+#define outl_p isa_outl_p
#define insb(port, buf, nr) ((port) < 1024 ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
#define insw(port, buf, nr) ((port) < 1024 ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
-#define insl(port, buf, nr) ((port) < 1024 ? isa_rom_insl((port), (buf), (nr)) : isa_insl((port), (buf), (nr)))
+#define insl isa_insl
#define outsb(port, buf, nr) ((port) < 1024 ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
#define outsw(port, buf, nr) ((port) < 1024 ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
-#define outsl(port, buf, nr) ((port) < 1024 ? isa_rom_outsl((port), (buf), (nr)) : isa_outsl((port), (buf), (nr)))
+#define outsl isa_outsl
#define readb(addr) in_8(addr)
#define writeb(val,addr) out_8((addr),(val))
diff --git a/arch/m68k/include/asm/raw_io.h b/arch/m68k/include/asm/raw_io.h
index b1d9119..932faa3 100644
--- a/arch/m68k/include/asm/raw_io.h
+++ b/arch/m68k/include/asm/raw_io.h
@@ -70,34 +70,45 @@ extern void __iounmap(void *addr, unsigned long size);
* For writes, address lines A1-A8 are latched to ISA data lines D0-D7
* (meaning the bit pattern on A1-A8 can be read back as byte).
*
+ * Read and write operations are distinguished by the base address used:
+ * reads are from the ROM A side range, writes are through the B side range
+ * addresses (A side base + 0x10000).
+ *
* Reads and writes are byte only.
+ *
+ * 16 bit reads and writes are necessary for the NetUSBee adapter's USB
+ * chipset - 16 bit words are read straight off the ROM port while 16 bit
+ * reads are split into two byte writes. The low byte is latched to the
+ * NetUSBee buffer by a read from the _read_ window (with the data pattern
+ * asserted as A1-A8 address pattern). The high byte is then written to the
+ * write range as usual, completing the write cycle.
*/
#if defined(CONFIG_ATARI_ROM_ISA)
#define rom_in_8(addr) \
({ u16 __v = (*(__force volatile u16 *) (addr)); __v >>= 8; __v; })
#define rom_in_be16(addr) \
- ({ u16 __v = (*(__force volatile u16 *) (addr)); __v >>= 8; __v; })
-#define rom_in_be32(addr) \
- ({ u32 __v = (*(__force volatile u32 *) (addr)); __v >>= 8; __v; })
+ ({ u16 __v = (*(__force volatile u16 *) (addr)); __v; })
#define rom_in_le16(addr) \
- ({ u16 __v = le16_to_cpu(*(__force volatile u16 *) (addr)); __v >>= 8; __v; })
-#define rom_in_le32(addr) \
- ({ u32 __v = le32_to_cpu(*(__force volatile u32 *) (addr)); __v >>= 8; __v; })
-
-#define rom_out_8(addr, b) ({u8 __w, __v = (b); __w = ((*(__force volatile u8 *) ((addr) + 0x10000 + (__v<<1)))); })
-#define rom_out_be16(addr, w) ({u16 __w, __v = (w); __w = ((*(__force volatile u16 *) ((addr) + 0x10000 + (__v<<1)))); })
-#define rom_out_be32(addr, l) ({u32 __w, __v = (l); __w = ((*(__force volatile u32 *) ((addr) + 0x10000 + (__v<<1)))); })
-#define rom_out_le16(addr, w) ({u16 __w, __v = cpu_to_le16(w); __w = ((*(__force volatile u16 *) ((addr) + 0x10000 + (__v<<1)))); })
-#define rom_out_le32(addr, l) ({u32 __w, __v = cpu_to_le32(l); __w = ((*(__force volatile u32 *) ((addr) + 0x10000 + (__v<<1)))); })
+ ({ u16 __v = le16_to_cpu(*(__force volatile u16 *) (addr)); __v; })
+
+#define rom_out_8(addr, b) \
+ ({u8 __w, __v = (b); u32 _addr = ((u32) (addr)); \
+ __w = ((*(__force volatile u8 *) ((_addr | 0x10000) + (__v<<1)))); })
+#define rom_out_be16(addr, w) \
+ ({u16 __w, __v = (w); u32 _addr = ((u32) (addr)); \
+ __w = ((*(__force volatile u16 *) ((_addr & 0xFFFF0000UL) + ((__v & 0xFF)<<1)))); \
+ __w = ((*(__force volatile u16 *) ((_addr | 0x10000) + ((__v >> 8)<<1)))); })
+#define rom_out_le16(addr, w) \
+ ({u16 __w, __v = (w); u32 _addr = ((u32) (addr)); \
+ __w = ((*(__force volatile u16 *) ((_addr & 0xFFFF0000UL) + ((__v >> 8)<<1)))); \
+ __w = ((*(__force volatile u16 *) ((_addr | 0x10000) + ((__v & 0xFF)<<1)))); })
#define raw_rom_inb rom_in_8
#define raw_rom_inw rom_in_be16
-#define raw_rom_inl rom_in_be32
#define raw_rom_outb(val, port) rom_out_8((port), (val))
#define raw_rom_outw(val, port) rom_out_be16((port), (val))
-#define raw_rom_outl(val, port) rom_out_be32((port), (val))
#endif /* CONFIG_ATARI_ROM_ISA */
static inline void raw_insb(volatile u8 __iomem *port, u8 *buf, unsigned int len)
@@ -436,24 +447,6 @@ static inline void raw_rom_outsw_swapw(volatile u16 __iomem *port, const u16 *bu
for (i = 0; i < nr; i++)
rom_out_le16(port, *buf++);
}
-
-static inline void raw_rom_insl(volatile u16 __iomem *port, u32 *buf,
- unsigned int nr)
-{
- unsigned int i;
-
- for (i = 0; i < nr; i++)
- *buf++ = rom_in_be32(port);
-}
-
-static inline void raw_rom_outsl(volatile u16 __iomem *port, const u32 *buf,
- unsigned int nr)
-{
- unsigned int i;
-
- for (i = 0; i < nr; i++)
- rom_out_be32(port, *buf++);
-}
#endif /* CONFIG_ATARI_ROM_ISA */
#endif /* __KERNEL__ */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 12/14] m68k: Implement ndelay() based on the existing udelay() logic
2013-03-25 1:16 (unknown), Michael Schmitz
` (10 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 11/14] m68k/atari: Implement 16 bit access macros for ROM port Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 13/14] m68k/atari: USB - add platform device definitions for ISP1160 HCD Michael Schmitz
2013-03-25 1:16 ` [PATCH 14/14] m68k/atari: USB - Add ISP1160 USB host controller support Michael Schmitz
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Add ndelay macro, modeled after the CF udelay macro. The ISP1160
USB HCD chip on EtherNAT and NetUSBee needs a 150ns delay after
register access.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/include/asm/delay.h | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/arch/m68k/include/asm/delay.h b/arch/m68k/include/asm/delay.h
index 12d8fe4..8a9971d 100644
--- a/arch/m68k/include/asm/delay.h
+++ b/arch/m68k/include/asm/delay.h
@@ -92,5 +92,25 @@ static inline void __udelay(unsigned long usecs)
#define udelay(n) (__builtin_constant_p(n) ? \
((n) > 20000 ? __bad_udelay() : __const_udelay(n)) : __udelay(n))
+/*
+ * nanosecond delay:
+ *
+ * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6) is the number of loops per microsecond
+ *
+ * 1000 / ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6) is the number of nanoseconds per loop
+ *
+ * So n / ( 1000 / ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6) ) would be the number of loops for n nanoseconds
+ */
+
+/*
+ * The simpler m68k and ColdFire processors do not have a 32*32->64
+ * multiply instruction. So we need to handle them a little differently.
+ * We use a bit of shifting and a single 32*32->32 multiply to get close.
+ * This is a macro so that the const version can factor out the first
+ * multiply and shift.
+ */
+#define HZSCALE (268435456 / (1000000 / HZ))
+
+#define ndelay(n) __delay(DIV_ROUND_UP((n) * ((((HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6), 1000));
#endif /* defined(_M68K_DELAY_H) */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 13/14] m68k/atari: USB - add platform device definitions for ISP1160 HCD
2013-03-25 1:16 (unknown), Michael Schmitz
` (11 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 12/14] m68k: Implement ndelay() based on the existing udelay() logic Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
2013-03-25 1:16 ` [PATCH 14/14] m68k/atari: USB - Add ISP1160 USB host controller support Michael Schmitz
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Add platform devices for use by isp116x-hcd driver for EtherNAT and NetUSBee
USB functions.
Register definitions thanks to David Galvez <dgalvez75@gmail.com>
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/atari/config.c | 131 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 126 insertions(+), 5 deletions(-)
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index 19114f5..0137fa5 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -32,6 +32,7 @@
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/platform_device.h>
+#include <linux/usb/isp116x.h>
#include <linux/vt_kern.h>
#include <linux/module.h>
@@ -685,8 +686,70 @@ static struct platform_device smc91x_device = {
.resource = smc91x_resources,
};
+/*
+ * ISP 1160 - using the isp116x-hcd module
+ */
+
+#define ATARI_USB_PHYS_ADDR 0x80000012
+#define ATARI_USB_IRQ 139
+
+static struct resource isp1160_resources[] = {
+ [0] = {
+ .name = "isp1160-data",
+ .start = ATARI_USB_PHYS_ADDR,
+ .end = ATARI_USB_PHYS_ADDR + 0x1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .name = "isp1160-regs",
+ .start = ATARI_USB_PHYS_ADDR + 0x4,
+ .end = ATARI_USB_PHYS_ADDR + 0x5,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = {
+ .name = "isp1160-irq",
+ .start = ATARI_USB_IRQ,
+ .end = ATARI_USB_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static void isp1160_delay(struct device *dev, int delay)
+{
+ ndelay(delay);
+}
+
+/* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
+static struct isp116x_platform_data isp1160_platform_data = {
+ /* Enable internal resistors on downstream ports */
+ .sel15Kres = 1,
+ /* On-chip overcurrent protection */
+ .oc_enable = 1,
+ /* INT output polarity */
+ .int_act_high = 1,
+ /* INT edge or level triggered */
+ .int_edge_triggered = 0,
+
+ /* WAKEUP pin connected - NOT SUPPORTED */
+ /* .remote_wakeup_connected = 0, */
+ /* Wakeup by devices on usb bus enabled */
+ .remote_wakeup_enable = 0,
+ .delay = isp1160_delay,
+};
+
+static struct platform_device isp1160_device = {
+ .name = "isp116x-hcd",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(isp1160_resources),
+ .resource = isp1160_resources,
+ .dev = {
+ .platform_data = &isp1160_platform_data,
+ },
+};
+
static struct platform_device *atari_ethernat_devices[] __initdata = {
- &smc91x_device
+ &smc91x_device,
+ &isp1160_device
};
#define ATARI_ETHERNEC_PHYS_ADDR 0xfffa0000
@@ -715,8 +778,66 @@ static struct platform_device rtl8019_device = {
.resource = rtl8019_resources,
};
-static struct platform_device *atari_ethernec_devices[] __initdata = {
- &rtl8019_device
+/*
+ * NetUSBee: ISP1160 USB host adapter via ROM-port adapter
+ */
+
+#define ATARI_NETUSBEE_PHYS_ADDR 0xfffa8000
+#define ATARI_NETUSBEE_BASE 0x340
+#define ATARI_NETUSBEE_IRQ IRQ_MFP_TIMER2
+
+static struct resource netusbee_resources[] = {
+ [0] = {
+ .name = "isp1160-data",
+ .start = ATARI_NETUSBEE_BASE,
+ .end = ATARI_NETUSBEE_BASE + 0x1,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .name = "isp1160-regs",
+ .start = ATARI_NETUSBEE_BASE + 0x20,
+ .end = ATARI_NETUSBEE_BASE + 0x21,
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = {
+ .name = "isp1160-irq",
+ .start = ATARI_NETUSBEE_IRQ,
+ .end = ATARI_NETUSBEE_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+/* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
+static struct isp116x_platform_data netusbee_platform_data = {
+ /* Enable internal resistors on downstream ports */
+ .sel15Kres = 1,
+ /* On-chip overcurrent protection */
+ .oc_enable = 1,
+ /* INT output polarity */
+ .int_act_high = 1,
+ /* INT edge or level triggered */
+ .int_edge_triggered = 0,
+
+ /* WAKEUP pin connected - NOT SUPPORTED */
+ /* .remote_wakeup_connected = 0, */
+ /* Wakeup by devices on usb bus enabled */
+ .remote_wakeup_enable = 0,
+ .delay = isp1160_delay,
+};
+
+static struct platform_device netusbee_device = {
+ .name = "isp116x-hcd",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(netusbee_resources),
+ .resource = netusbee_resources,
+ .dev = {
+ .platform_data = &netusbee_platform_data,
+ },
+};
+
+static struct platform_device *atari_netusbee_devices[] __initdata = {
+ &rtl8019_device,
+ &netusbee_device
};
int __init atari_platform_init(void)
@@ -744,8 +865,8 @@ int __init atari_platform_init(void)
unsigned char *enec_virt;
enec_virt = (unsigned char *)ioremap((ATARI_ETHERNEC_PHYS_ADDR), 0xf);
if (hwreg_present(enec_virt)) {
- error = platform_add_devices(atari_ethernec_devices,
- ARRAY_SIZE(atari_ethernec_devices));
+ error = platform_add_devices(atari_netusbee_devices,
+ ARRAY_SIZE(atari_netusbee_devices));
if (error && !rv)
rv = error;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 14/14] m68k/atari: USB - Add ISP1160 USB host controller support
2013-03-25 1:16 (unknown), Michael Schmitz
` (12 preceding siblings ...)
2013-03-25 1:16 ` [PATCH 13/14] m68k/atari: USB - add platform device definitions for ISP1160 HCD Michael Schmitz
@ 2013-03-25 1:16 ` Michael Schmitz
13 siblings, 0 replies; 15+ messages in thread
From: Michael Schmitz @ 2013-03-25 1:16 UTC (permalink / raw)
To: geert; +Cc: linux-m68k, debian-68k, Michael Schmitz
Add Atari specific support code for isp116x-hcd driver used by EtherNAT
and NetUSBee adapters. Both use a 16-bit data bus wiring that is byte-swapped
in hardware. The EtherNAT adapter also has quirks relating to interrupts
and needs interrupts disabled until after the chip has been reset.
Debugging of FIFO register access code and NetUSBee support by David Galvez
<dgalvez75@gmail.com> (MiNT driver author).
Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
arch/m68k/Kconfig.bus | 11 ++++
drivers/usb/host/isp116x-hcd.c | 109 +++++++++++++++++++++++++++++++++++++++-
drivers/usb/host/isp116x.h | 41 ++++++++++++---
3 files changed, 150 insertions(+), 11 deletions(-)
diff --git a/arch/m68k/Kconfig.bus b/arch/m68k/Kconfig.bus
index 675b087..efb6aab 100644
--- a/arch/m68k/Kconfig.bus
+++ b/arch/m68k/Kconfig.bus
@@ -55,6 +55,17 @@ config ATARI_ROM_ISA
The only driver currently using this adapter is the EtherNEC
driver for RTL8019AS based NE2000 compatible network cards.
+config ATARI_USB
+ bool "Atari USB host controller support"
+ depends on ATARI
+ select USB_SUPPORT
+ select USB_ARCH_HAS_HCD
+ help
+ This option enables support for USB host controllers contained on
+ the EtherNAT and NetUSBee cards for Atari. You will have to select
+ an appropriate HCD driver in the USB section (the ISP1160 one is
+ the most commonly used one).
+
config GENERIC_ISA_DMA
def_bool ISA
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index b64e661..fce2766 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -82,8 +82,25 @@ MODULE_LICENSE("GPL");
static const char hcd_name[] = "isp116x-hcd";
+#ifdef CONFIG_ATARI
+static unsigned char *enat_cr; /* EtherNAT CPLD control register for USB interrupt enable */
+#endif
+
/*-----------------------------------------------------------------*/
+ /*
+ * 16 bit data bus byte swapped in hardware
+ *
+ * isp116x_write_addr uses raw_readw - hw byte swap takes care of different endianness
+ *
+ * isp116x_write_data16 uses raw_readw - byte swap done in hw so BE data ends up in proper LE format
+ * isp116x_raw_write_data16 uses readw - effectively same endiannes retained, use for LE format data
+ *
+ * reversed semantics of primitives allows to keep the register
+ * access functions unchanged for commands and control data - byte
+ * swap done transparently
+ */
+
/*
Write len bytes to fifo, pad till 32-bit boundary
*/
@@ -100,18 +117,27 @@ static void write_ptddata_to_fifo(struct isp116x *isp116x, void *buf, int len)
if ((unsigned long)dp2 & 1) {
/* not aligned */
+
for (; len > 1; len -= 2) {
w = *dp++;
w |= *dp++ << 8;
isp116x_raw_write_data16(isp116x, w);
}
if (len)
+#ifdef CONFIG_ATARI /* MSch: needs swap */
+ isp116x_raw_write_data16(isp116x, (u16) *dp);
+#else
isp116x_write_data16(isp116x, (u16) * dp);
+#endif
} else {
/* aligned */
for (; len > 1; len -= 2) {
/* Keep byte order ! */
+#ifdef CONFIG_ATARI /* MSch: needs swap */
+ isp116x_write_data16(isp116x, cpu_to_le16(*dp2++));
+#else
isp116x_raw_write_data16(isp116x, cpu_to_le16(*dp2++));
+#endif
}
if (len)
@@ -137,6 +163,7 @@ static void read_ptddata_from_fifo(struct isp116x *isp116x, void *buf, int len)
if ((unsigned long)dp2 & 1) {
/* not aligned */
+
for (; len > 1; len -= 2) {
w = isp116x_raw_read_data16(isp116x);
*dp++ = w & 0xff;
@@ -144,12 +171,20 @@ static void read_ptddata_from_fifo(struct isp116x *isp116x, void *buf, int len)
}
if (len)
+#ifdef CONFIG_ATARI /* MSch: needs swap */
+ *dp = 0xff & isp116x_raw_read_data16(isp116x);
+#else
*dp = 0xff & isp116x_read_data16(isp116x);
+#endif
} else {
/* aligned */
for (; len > 1; len -= 2) {
/* Keep byte order! */
+#ifdef CONFIG_ATARI /* MSch: needs swap */
+ *dp2++ = le16_to_cpu(isp116x_read_data16(isp116x));
+#else
*dp2++ = le16_to_cpu(isp116x_raw_read_data16(isp116x));
+#endif
}
if (len)
@@ -593,6 +628,11 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd)
u16 irqstat;
irqreturn_t ret = IRQ_NONE;
+#ifdef CONFIG_ATARI
+ if ((unsigned long) hcd->rsrc_start >= 0x80000000UL)
+ /* EtherNAT control register, disable interrupt for USB */
+ *enat_cr = (*enat_cr) & 0xFB;
+#endif
spin_lock(&isp116x->lock);
isp116x_write_reg16(isp116x, HCuPINTENB, 0);
irqstat = isp116x_read_reg16(isp116x, HCuPINT);
@@ -636,6 +676,10 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd)
isp116x_write_reg16(isp116x, HCuPINTENB, isp116x->irqenb);
done:
spin_unlock(&isp116x->lock);
+#ifdef CONFIG_ATARI
+ if ((unsigned long) hcd->rsrc_start >= 0x80000000UL)
+ *enat_cr = (*enat_cr) | 0x04; /* EtherNAT control register, enable interrupt for USB */
+#endif
return ret;
}
@@ -1259,8 +1303,11 @@ static int isp116x_reset(struct usb_hcd *hcd)
struct isp116x *isp116x = hcd_to_isp116x(hcd);
unsigned long t;
u16 clkrdy = 0;
+#ifdef CONFIG_ATARI
+ int ret, timeout = 200 /* ms */ ;
+#else
int ret, timeout = 15 /* ms */ ;
-
+#endif
ret = isp116x_sw_reset(isp116x);
if (ret)
return ret;
@@ -1291,6 +1338,12 @@ static void isp116x_stop(struct usb_hcd *hcd)
u32 val;
spin_lock_irqsave(&isp116x->lock, flags);
+
+#ifdef CONFIG_ATARI
+ if ((unsigned long) hcd->rsrc_start >= 0x80000000UL)
+ /* EtherNAT control register, disable interrupt for USB */
+ *enat_cr = (*enat_cr) & 0xFB;
+#endif
isp116x_write_reg16(isp116x, HCuPINTENB, 0);
/* Switch off ports' power, some devices don't come up
@@ -1356,6 +1409,12 @@ static int isp116x_start(struct usb_hcd *hcd)
val |= RH_A_PSM;
/* Report overcurrent per port */
val |= RH_A_OCPM;
+#ifdef CONFIG_ATARI
+ /* Galvez: For NetUSBee, Overcurrent protection disable,
+ to stop interrupt storm because OC events */
+ if ((unsigned long) hcd->rsrc_start < 0x80000000UL)
+ val |= (RH_A_NOCP | RH_A_NPS);
+#endif
isp116x_write_reg32(isp116x, HCRHDESCA, val);
isp116x->rhdesca = isp116x_read_reg32(isp116x, HCRHDESCA);
@@ -1394,6 +1453,10 @@ static int isp116x_start(struct usb_hcd *hcd)
isp116x_write_reg32(isp116x, HCRHPORT1, RH_PS_CCS);
isp116x_write_reg32(isp116x, HCRHPORT2, RH_PS_CCS);
+#ifdef CONFIG_ATARI
+ if ((unsigned long) hcd->rsrc_start >= 0x80000000UL)
+ *enat_cr = (*enat_cr) | 0x04; /* EtherNAT control register, enable interrupt for USB */
+#endif
isp116x_show_regs_log(isp116x);
spin_unlock_irqrestore(&isp116x->lock, flags);
return 0;
@@ -1539,6 +1602,9 @@ static int isp116x_remove(struct platform_device *pdev)
struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct isp116x *isp116x;
struct resource *res;
+#ifdef CONFIG_ATARI
+ unsigned long enat_cr_phys;
+#endif
if (!hcd)
return 0;
@@ -1552,7 +1618,14 @@ static int isp116x_remove(struct platform_device *pdev)
iounmap(isp116x->addr_reg);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, 2);
-
+#ifdef CONFIG_ATARI
+ if ((unsigned long) hcd->rsrc_start >= 0x80000000UL) {
+ iounmap(enat_cr);
+ /* unmap & release EtherNAT CPLD control register - at 0x23 off board base address */
+ enat_cr_phys = (res->start & 0xFFFFFF00) + 0x23;
+ release_mem_region(enat_cr_phys, 2);
+ }
+#endif
usb_put_hcd(hcd);
return 0;
}
@@ -1567,6 +1640,9 @@ static int isp116x_probe(struct platform_device *pdev)
int irq;
int ret = 0;
unsigned long irqflags;
+#ifdef CONFIG_ATARI
+ unsigned long enat_cr_phys;
+#endif
if (usb_disabled())
return -ENODEV;
@@ -1613,6 +1689,26 @@ static int isp116x_probe(struct platform_device *pdev)
goto err4;
}
+#ifdef CONFIG_ATARI
+ if ((unsigned long) data->start >= 0x80000000UL) {
+ /* map EtherNAT CPLD control register - at 0x23 off board base address */
+ enat_cr_phys = (data->start & 0xffffff00) + 0x23;
+ if (!request_mem_region(enat_cr_phys, 2, hcd_name)) {
+ ret = -EBUSY;
+ goto err41;
+ }
+ enat_cr = ioremap(enat_cr_phys, 2);
+ if (enat_cr == NULL) {
+ ret = -ENOMEM;
+ goto err42;
+ }
+ /* Disable USB interrupt in the EtherNat board */
+ *enat_cr = (*enat_cr) & 0xFB;
+ }
+ pr_info("ISP116X probe: data %p virt. %p, addr %p virt. %p\n",
+ (void *)data->start, data_reg, (void *)addr->start, addr_reg);
+#endif
+
/* allocate and initialize hcd */
hcd = usb_create_hcd(&isp116x_hc_driver, &pdev->dev, dev_name(&pdev->dev));
if (!hcd) {
@@ -1653,11 +1749,20 @@ static int isp116x_probe(struct platform_device *pdev)
return 0;
+
err7:
usb_remove_hcd(hcd);
err6:
usb_put_hcd(hcd);
err5:
+#ifdef CONFIG_ATARI
+ if ((unsigned long) data->start >= 0x80000000UL)
+ iounmap(enat_cr);
+ err42:
+ if ((unsigned long) data->start >= 0x80000000UL)
+ release_mem_region(enat_cr_phys, 2);
+ err41:
+#endif
iounmap(data_reg);
err4:
release_mem_region(data->start, 2);
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h
index 9a2c400..6359ccb 100644
--- a/drivers/usb/host/isp116x.h
+++ b/drivers/usb/host/isp116x.h
@@ -364,22 +364,45 @@ struct isp116x_ep {
#define IRQ_TEST() do{}while(0)
#endif
+
+#ifdef CONFIG_ATARI
+ /*
+ * 16 bit data bus byte swapped in hardware on both Atari variants.
+ * EtherNAT variant of ISP1160 integration is memory mapped at 0x800000XX,
+ * and uses regular readw/__raw_readw (but semantics swapped).
+ * NetUSBee variant is hooked up through ROM port and uses ROM port
+ * IO access, with fake IO address of 0x3XX.
+ * Selection of the appropriate accessors relies on ioremapped addresses still
+ * retaining the 0x3XX bit.
+ */
+#define isp_readw(p) ((((unsigned long)(__pa(p)) & 0x00000F00) == 0x00000300UL) ? isa_rom_readw_raw(__pa(p)) : __raw_readw((p)))
+#define isp_writew(v, p) ((((unsigned long)(__pa(p)) & 0x00000F00) == 0x00000300UL) ? isa_rom_writew_raw((v), __pa(p)) : __raw_writew((v), (p)))
+#define isp_raw_readw(p) ((((unsigned long)(__pa(p)) & 0x00000F00) == 0x00000300UL) ? isa_rom_readw(__pa(p)) : readw((p)))
+#define isp_raw_writew(v, p) ((((unsigned long)(__pa(p)) & 0x00000F00) == 0x00000300UL) ? isa_rom_writew((v), __pa(p)) : writew((v), (p)))
+#else
+ /* sane hardware */
+#define isp_readw readw
+#define isp_writew writew
+#define isp_raw_readw __raw_readw
+#define isp_raw_writew __raw_writew
+#endif
+
static inline void isp116x_write_addr(struct isp116x *isp116x, unsigned reg)
{
IRQ_TEST();
- writew(reg & 0xff, isp116x->addr_reg);
+ isp_writew(reg & 0xff, isp116x->addr_reg);
isp116x_delay(isp116x, 300);
}
static inline void isp116x_write_data16(struct isp116x *isp116x, u16 val)
{
- writew(val, isp116x->data_reg);
+ isp_writew(val, isp116x->data_reg);
isp116x_delay(isp116x, 150);
}
static inline void isp116x_raw_write_data16(struct isp116x *isp116x, u16 val)
{
- __raw_writew(val, isp116x->data_reg);
+ isp_raw_writew(val, isp116x->data_reg);
isp116x_delay(isp116x, 150);
}
@@ -387,7 +410,7 @@ static inline u16 isp116x_read_data16(struct isp116x *isp116x)
{
u16 val;
- val = readw(isp116x->data_reg);
+ val = isp_readw(isp116x->data_reg);
isp116x_delay(isp116x, 150);
return val;
}
@@ -396,16 +419,16 @@ static inline u16 isp116x_raw_read_data16(struct isp116x *isp116x)
{
u16 val;
- val = __raw_readw(isp116x->data_reg);
+ val = isp_raw_readw(isp116x->data_reg);
isp116x_delay(isp116x, 150);
return val;
}
static inline void isp116x_write_data32(struct isp116x *isp116x, u32 val)
{
- writew(val & 0xffff, isp116x->data_reg);
+ isp_writew(val & 0xffff, isp116x->data_reg);
isp116x_delay(isp116x, 150);
- writew(val >> 16, isp116x->data_reg);
+ isp_writew(val >> 16, isp116x->data_reg);
isp116x_delay(isp116x, 150);
}
@@ -413,9 +436,9 @@ static inline u32 isp116x_read_data32(struct isp116x *isp116x)
{
u32 val;
- val = (u32) readw(isp116x->data_reg);
+ val = (u32) isp_readw(isp116x->data_reg);
isp116x_delay(isp116x, 150);
- val |= ((u32) readw(isp116x->data_reg)) << 16;
+ val |= ((u32) isp_readw(isp116x->data_reg)) << 16;
isp116x_delay(isp116x, 150);
return val;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread