net: support for NS8390 based ethernet on ColdFire CPU boards
Subsystems (4)
v2 cover net: support for NS8390 based ethernet on ColdFire CPU boards
This is version 2 of patches that add platform support for using the NS8390 based ethernet ports used on some ColdFire CPU boards. This version incorporates only minor changes from the first.
Patches to use these NS8390 devices on ColdFire boards have existed out-of-tree for years. Some of the base IO definitions (those in arch/m68k/include/asm/mcfne.h) have been in mainline, but unused for most of that time.
The first patch just neatens up mcfne.h (moving it to mcf8390.h). The second patch is the platform driver. The first patch would normaly just go through the m68knommu git tree, but I figured keeping these together made more sense.
--- arch/m68k/include/asm/mcf8390.h | 371 ++++++++++++++++++--------- arch/m68k/include/asm/mcfne.h | 242 ------------------ drivers/net/ethernet/8390/Kconfig | 14 + drivers/net/ethernet/8390/Makefile | 1 drivers/net/ethernet/8390/mcf8390.c | 480 ++++++++++++++++++++++++++++++++++++ 5 files changed, 746 insertions(+), 362 deletions(-)
PATCH v2 1/2 m68knommu: move the badly named mcfne.h to a better mcf8390.h
From: Greg Ungerer <[email protected]>
The mcfne.h include contains definitions to support NS8390 eth based hardware on ColdFire based CPU boards. So change its name to reflect that better.
--- arch/m68k/include/asm/mcf8390.h | 242 +++++++++++++++++++++++++++++++++++++++ arch/m68k/include/asm/mcfne.h | 242 --------------------------------------- 2 files changed, 242 insertions(+), 242 deletions(-) create mode 100644 arch/m68k/include/asm/mcf8390.h delete mode 100644 arch/m68k/include/asm/mcfne.h
arch/m68k/include/asm/mcf8390.h new file +242 -0
@@ -0,0 +1,242 @@ +/****************************************************************************/ + +/* +* mcf8390.h -- NS8390 support for ColdFire eval boards. +* +* (C) Copyright 1999-2000, Greg Ungerer ([email protected]) +* (C) Copyright 2000, Lineo (www.lineo.com) +* (C) Copyright 2001, SnapGear (www.snapgear.com) +* +* 19990409 David W. Miller Converted from m5206ne.h for 5307 eval board +* +* Hacked support for m5206e Cadre III evaluation board +* Fred Stevens ([email protected]) 13 April 1999 +*/ + +/****************************************************************************/ +#ifndef mcf8390_h +#define mcf8390_h +/****************************************************************************/ + + +/* +* Support for NE2000 clones devices in ColdFire based boards. +* Not all boards address these parts the same way, some use a +* direct addressing method, others use a side-band address space +* to access odd address registers, some require byte swapping +* others do not. +*/ +#define BSWAP (w) (((w) << 8) | ((w) >> 8)) +#define RSWAP (w) (w) + + +/* +* Define the basic hardware resources of NE2000 boards. +*/ + +#if defined(CONFIG_ARN5206 ) +#define NE2000_ADDR 0x40000300 +#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_IRQ_VECTOR 0xf0 +#define NE2000_IRQ_PRIORITY 2 +#define NE2000_IRQ_LEVEL 4 +#define NE2000_BYTE volatile unsigned short +#endif + +#if defined(CONFIG_M5206eC3) +#define NE2000_ADDR 0x40000300 +#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_IRQ_VECTOR 0x1c +#define NE2000_IRQ_PRIORITY 2 +#define NE2000_IRQ_LEVEL 4 +#define NE2000_BYTE volatile unsigned short +#endif + +#if defined(CONFIG_M5206e) && defined(CONFIG_NETtel) +#define NE2000_ADDR 0x30000300 +#define NE2000_IRQ_VECTOR 25 +#define NE2000_IRQ_PRIORITY 1 +#define NE2000_IRQ_LEVEL 3 +#define NE2000_BYTE volatile unsigned char +#endif + +#if defined(CONFIG_M5307C3 ) +#define NE2000_ADDR 0x40000300 +#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_IRQ_VECTOR 0x1b +#define NE2000_BYTE volatile unsigned short +#endif + +#if defined(CONFIG_M5272 ) && defined(CONFIG_NETtel) +#define NE2000_ADDR 0x30600300 +#define NE2000_ODDOFFSET 0x00008000 +#define NE2000_IRQ_VECTOR 67 +#undef BSWAP +#define BSWAP (w) (w) +#define NE2000_BYTE volatile unsigned short +#undef RSWAP +#define RSWAP (w) (((w) << 8) | ((w) >> 8)) +#endif + +#if defined(CONFIG_M5307 ) && defined(CONFIG_NETtel) +#define NE2000_ADDR0 0x30600300 +#define NE2000_ADDR1 0x30800300 +#define NE2000_ODDOFFSET 0x00008000 +#define NE2000_IRQ_VECTOR0 27 +#define NE2000_IRQ_VECTOR1 29 +#undef BSWAP +#define BSWAP (w) (w) +#define NE2000_BYTE volatile unsigned short +#undef RSWAP +#define RSWAP (w) (((w) << 8) | ((w) >> 8)) +#endif + +#if defined(CONFIG_M5307 ) && defined(CONFIG_SECUREEDGEMP3 ) +#define NE2000_ADDR 0x30600300 +#define NE2000_ODDOFFSET 0x00008000 +#define NE2000_IRQ_VECTOR 27 +#undef BSWAP +#define BSWAP (w) (w) +#define NE2000_BYTE volatile unsigned short +#undef RSWAP +#define RSWAP (w) (((w) << 8) | ((w) >> 8)) +#endif + +#if defined(CONFIG_ARN5307 ) +#define NE2000_ADDR 0xfe600300 +#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_IRQ_VECTOR 0x1b +#define NE2000_IRQ_PRIORITY 2 +#define NE2000_IRQ_LEVEL 3 +#define NE2000_BYTE volatile unsigned short +#endif + +#if defined(CONFIG_M5407C3 ) +#define NE2000_ADDR 0x40000300 +#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_IRQ_VECTOR 0x1b +#define NE2000_BYTE volatile unsigned short +#endif + +/****************************************************************************/ + +/* +* Side-band address space for odd address requires re-mapping +* many of the standard ISA access functions. +*/ +#ifdef NE2000_ODDOFFSET + +#undef outb +#undef outb_p +#undef inb +#undef inb_p +#undef outsb +#undef outsw +#undef insb +#undef insw + +#define outb ne2000_outb +#define inb ne2000_inb +#define outb_p ne2000_outb +#define inb_p ne2000_inb +#define outsb ne2000_outsb +#define outsw ne2000_outsw +#define insb ne2000_insb +#define insw ne2000_insw + + +#ifndef COLDFIRE_NE2000_FUNCS + +void ne2000_outb (unsigned int val,unsigned int addr); +int ne2000_inb (unsigned int addr); +void ne2000_insb (unsigned int addr,void *vbuf,int unsigned long len); +void ne2000_insw (unsigned int addr,void *vbuf,unsigned long len); +void ne2000_outsb (unsigned int addr,void *vbuf,unsigned long len); +void ne2000_outsw (unsigned int addr,void *vbuf,unsigned long len); + +#else + +/* +* This macro converts a conventional register address into the +* real memory pointer of the mapped NE2000 device. +* On most NE2000 implementations on ColdFire boards the chip is +* mapped in kinda funny, due to its ISA heritage. +*/ +#define NE2000_PTR (addr) ((addr&0x1)?(NE2000_ODDOFFSET+addr-1):(addr)) +#define NE2000_DATA_PTR (addr) (addr) + + +void ne2000_outb (unsigned int val,unsigned int addr) +{ +NE2000_BYTE *rp; + + rp = (NE2000_BYTE *)NE2000_PTR (addr); + *rp =RSWAP (val); +} + +int ne2000_inb (unsigned int addr) +{ +NE2000_BYTE *rp, val; + + rp = (NE2000_BYTE *)NE2000_PTR (addr); + val = *rp; +return ((int ) ((NE2000_BYTE )RSWAP (val))); +} + +void ne2000_insb (unsigned int addr,void *vbuf,int unsigned long len) +{ +NE2000_BYTE *rp, val; +unsigned char *buf; + + buf = (unsigned char *) vbuf; + rp = (NE2000_BYTE *)NE2000_DATA_PTR (addr); +for (; (len >0 ); len--) { + val = *rp; + *buf++ =RSWAP (val); + } +} + +void ne2000_insw (unsigned int addr,void *vbuf,unsigned long len) +{ +volatile unsigned short *rp; +unsigned short w, *buf; + + buf = (unsigned short *) vbuf; + rp = (volatile unsigned short *)NE2000_DATA_PTR (addr); +for (; (len >0 ); len--) { + w = *rp; + *buf++ =BSWAP (w); + } +} + +void ne2000_outsb (unsigned int addr,const void *vbuf,unsigned long len) +{ +NE2000_BYTE *rp, val; +unsigned char *buf; + + buf = (unsigned char *) vbuf; + rp = (NE2000_BYTE *)NE2000_DATA_PTR (addr); +for (; (len >0 ); len--) { + val = *buf++; + *rp =RSWAP (val); + } +} + +void ne2000_outsw (unsigned int addr,const void *vbuf,unsigned long len) +{ +volatile unsigned short *rp; +unsigned short w, *buf; + + buf = (unsigned short *) vbuf; + rp = (volatile unsigned short *)NE2000_DATA_PTR (addr); +for (; (len >0 ); len--) { + w = *buf++; + *rp =BSWAP (w); + } +} + +#endif /* COLDFIRE_NE2000_FUNCS */ +#endif /* NE2000_OFFOFFSET */ + +/****************************************************************************/ +#endif /* mcf8390_h */
arch/m68k/include/asm/mcfne.h deleted +0 -242
242 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v2 2/2 net: add support for NS8390 based eth controllers on some ColdFire CPU boards
In reply to [email protected]From: Greg Ungerer <[email protected]>
A number of older ColdFire CPU based boards use NS8390 based network controllers. Most use the Davicom 9008F or the UMC 9008F. This driver provides the support code to get these devices working on these platforms.
Generally the NS8390 based eth device is direct connected via the general purpose bus of the ColdFire CPU. So its addressing and interrupt setup is fixed on each of the different platforms (classic platform setup).
This driver is based on the other drivers/net/ethernet/8390 drivers, and includes the lib8390.c code. It uses the existing definitions of the board NS8390 device addresses, interrupts and access types from the arch/m68k/include/asm/mcf8390.h, but moves the IO access functions into the driver code and out of that header.
--- arch/m68k/include/asm/mcf8390.h | 129 +--------- drivers/net/ethernet/8390/Kconfig | 14 + drivers/net/ethernet/8390/Makefile | 1 + drivers/net/ethernet/8390/mcf8390.c | 480 +++++++++++++++++++++++++++++++++++ 4 files changed, 504 insertions(+), 120 deletions(-) create mode 100644 drivers/net/ethernet/8390/mcf8390.c
arch/m68k/include/asm/mcf8390.h +9 -120
@@ -37,6 +37,7 @@#if defined(CONFIG_ARN5206 )#define NE2000_ADDR 0x40000300#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_ADDRSIZE 0x00020000#define NE2000_IRQ_VECTOR 0xf0#define NE2000_IRQ_PRIORITY 2#define NE2000_IRQ_LEVEL 4
@@ -46,6 +47,7 @@#if defined(CONFIG_M5206eC3)#define NE2000_ADDR 0x40000300#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_ADDRSIZE 0x00020000#define NE2000_IRQ_VECTOR 0x1c#define NE2000_IRQ_PRIORITY 2#define NE2000_IRQ_LEVEL 4
@@ -54,6 +56,7 @@#if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)#define NE2000_ADDR 0x30000300 +#define NE2000_ADDRSIZE 0x00001000#define NE2000_IRQ_VECTOR 25#define NE2000_IRQ_PRIORITY 1#define NE2000_IRQ_LEVEL 3
@@ -63,6 +66,7 @@#if defined(CONFIG_M5307C3 )#define NE2000_ADDR 0x40000300#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_ADDRSIZE 0x00020000#define NE2000_IRQ_VECTOR 0x1b#define NE2000_BYTE volatile unsigned short#endif
@@ -70,6 +74,7 @@#if defined(CONFIG_M5272 ) && defined(CONFIG_NETtel)#define NE2000_ADDR 0x30600300#define NE2000_ODDOFFSET 0x00008000 +#define NE2000_ADDRSIZE 0x00010000#define NE2000_IRQ_VECTOR 67#undef BSWAP#define BSWAP (w) (w)
@@ -82,6 +87,7 @@#define NE2000_ADDR0 0x30600300#define NE2000_ADDR1 0x30800300#define NE2000_ODDOFFSET 0x00008000 +#define NE2000_ADDRSIZE 0x00010000#define NE2000_IRQ_VECTOR0 27#define NE2000_IRQ_VECTOR1 29#undef BSWAP
@@ -94,6 +100,7 @@#if defined(CONFIG_M5307 ) && defined(CONFIG_SECUREEDGEMP3 )#define NE2000_ADDR 0x30600300#define NE2000_ODDOFFSET 0x00008000 +#define NE2000_ADDRSIZE 0x00010000#define NE2000_IRQ_VECTOR 27#undef BSWAP#define BSWAP (w) (w)
@@ -105,6 +112,7 @@#if defined(CONFIG_ARN5307 )#define NE2000_ADDR 0xfe600300#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_ADDRSIZE 0x00020000#define NE2000_IRQ_VECTOR 0x1b#define NE2000_IRQ_PRIORITY 2#define NE2000_IRQ_LEVEL 3
@@ -114,129 +122,10 @@#if defined(CONFIG_M5407C3 )#define NE2000_ADDR 0x40000300#define NE2000_ODDOFFSET 0x00010000 +#define NE2000_ADDRSIZE 0x00020000#define NE2000_IRQ_VECTOR 0x1b#define NE2000_BYTE volatile unsigned short#endif /****************************************************************************/ - -/* -* Side-band address space for odd address requires re-mapping -* many of the standard ISA access functions. -*/ -#ifdef NE2000_ODDOFFSET - -#undef outb -#undef outb_p -#undef inb -#undef inb_p -#undef outsb -#undef outsw -#undef insb -#undef insw - -#define outb ne2000_outb -#define inb ne2000_inb -#define outb_p ne2000_outb -#define inb_p ne2000_inb -#define outsb ne2000_outsb -#define outsw ne2000_outsw -#define insb ne2000_insb -#define insw ne2000_insw - - -#ifndef COLDFIRE_NE2000_FUNCS - -void ne2000_outb (unsigned int val,unsigned int addr); -int ne2000_inb (unsigned int addr); -void ne2000_insb (unsigned int addr,void *vbuf,int unsigned long len); -void ne2000_insw (unsigned int addr,void *vbuf,unsigned long len); -void ne2000_outsb (unsigned int addr,void *vbuf,unsigned long len); -void ne2000_outsw (unsigned int addr,void *vbuf,unsigned long len); - -#else - -/* -* This macro converts a conventional register address into the -* real memory pointer of the mapped NE2000 device. -* On most NE2000 implementations on ColdFire boards the chip is -* mapped in kinda funny, due to its ISA heritage. -*/ -#define NE2000_PTR (addr) ((addr&0x1)?(NE2000_ODDOFFSET+addr-1):(addr)) -#define NE2000_DATA_PTR (addr) (addr) - - -void ne2000_outb (unsigned int val,unsigned int addr) -{ -NE2000_BYTE *rp; - - rp = (NE2000_BYTE *)NE2000_PTR (addr); - *rp =RSWAP (val); -} - -int ne2000_inb (unsigned int addr) -{ -NE2000_BYTE *rp, val; - - rp = (NE2000_BYTE *)NE2000_PTR (addr); - val = *rp; -return ((int ) ((NE2000_BYTE )RSWAP (val))); -} - -void ne2000_insb (unsigned int addr,void *vbuf,int unsigned long len) -{ -NE2000_BYTE *rp, val; -unsigned char *buf; - - buf = (unsigned char *) vbuf; - rp = (NE2000_BYTE *)NE2000_DATA_PTR (addr); -for (; (len >0 ); len--) { - val = *rp; - *buf++ =RSWAP (val); - } -} - -void ne2000_insw (unsigned int addr,void *vbuf,unsigned long len) -{ -volatile unsigned short *rp; -unsigned short w, *buf; - - buf = (unsigned short *) vbuf; - rp = (volatile unsigned short *)NE2000_DATA_PTR (addr); -for (; (len >0 ); len--) { - w = *rp; - *buf++ =BSWAP (w); - } -} - -void ne2000_outsb (unsigned int addr,const void *vbuf,unsigned long len) -{ -NE2000_BYTE *rp, val; -unsigned char *buf; - - buf = (unsigned char *) vbuf; - rp = (NE2000_BYTE *)NE2000_DATA_PTR (addr); -for (; (len >0 ); len--) { - val = *buf++; - *rp =RSWAP (val); - } -} - -void ne2000_outsw (unsigned int addr,const void *vbuf,unsigned long len) -{ -volatile unsigned short *rp; -unsigned short w, *buf; - - buf = (unsigned short *) vbuf; - rp = (volatile unsigned short *)NE2000_DATA_PTR (addr); -for (; (len >0 ); len--) { - w = *buf++; - *rp =BSWAP (w); - } -} - -#endif /* COLDFIRE_NE2000_FUNCS */ -#endif /* NE2000_OFFOFFSET */ - -/****************************************************************************/ #endif /* mcf8390_h */
drivers/net/ethernet/8390/Kconfig +14 -0
@@ -162,6 +162,20 @@ config MAC8390 and read the Ethernet-HOWTO, available from <http://www.tldp.org/docs.html#howto>. +config MCF8390 + tristate "ColdFire NS8390 based Ethernet support" + depends on COLDFIRE + select CRC32 + ---help--- + This driver is for Ethernet devices using an NS8390-compatible + chipset on many common ColdFire CPU based boards. Many of the older + Freescale dev boards use this, and some other common boards like + some SnapGear routers do as well. + + If you have one of these boards and want to use the network interface + on them then choose Y. To compile this driver as a module, choose M + here, the module will be called mcf8390. + config NE2000 tristate "NE2000/NE1000 support" depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX)
drivers/net/ethernet/8390/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_HPLAN_PLUS) += hp-plus.o 8390p.o obj-$(CONFIG_HPLAN) += hp.o 8390p.o obj-$(CONFIG_HYDRA) += hydra.o 8390.o obj-$(CONFIG_LNE390) += lne390.o 8390.o +obj-$(CONFIG_MCF8390) += mcf8390.o 8390.o obj-$(CONFIG_NE2000) += ne.o 8390p.o obj-$(CONFIG_NE2_MCA) += ne2.o 8390p.o obj-$(CONFIG_NE2K_PCI) += ne2k-pci.o 8390.o
drivers/net/ethernet/8390/mcf8390.c new file +480 -0
480 lines not on this page · raw message
Signature · 1 line
1.7.0.4
From: <[email protected]>
Date: Thu, 5 Jul 2012 09:49:58 +1000
Quoted 10 lines
This is version 2 of patches that add platform support for using the NS8390 based ethernet ports used on some ColdFire CPU boards. This version incorporates only minor changes from the first.
Patches to use these NS8390 devices on ColdFire boards have existed out-of-tree for years. Some of the base IO definitions (those in
arch/m68k/include/asm/mcfne.h) have been in mainline, but unused for most of that time.
Quoted 4 lines
The first patch just neatens up
mcfne.h(moving it tomcf8390.h). The second patch is the platform driver. The first patch would normaly just go through the m68knommu git tree, but I figured keeping these together made more sense.
Applied, thanks.
Can you explain why we've had this completely unused header file mcfne.h in the tree? Was it used by some external driver sources that were never merged?
Hi David,
Quoted 13 lines · David Miller
From: <[email protected]>
Date: Thu, 5 Jul 2012 09:49:58 +1000Quoted 10 lines
This is version 2 of patches that add platform support for using the NS8390 based ethernet ports used on some ColdFire CPU boards. This version incorporates only minor changes from the first.
Patches to use these NS8390 devices on ColdFire boards have existed out-of-tree for years. Some of the base IO definitions (those in
arch/m68k/include/asm/mcfne.h) have been in mainline, but unused for most of that time.
Quoted 6 lines
Quoted 4 lines
The first patch just neatens up
mcfne.h(moving it tomcf8390.h). The second patch is the platform driver. The first patch would normaly just go through the m68knommu git tree, but I figured keeping these together made more sense.Applied, thanks.
Great, thanks.
Quoted 3 lines
Can you explain why we've had this completely unused header file
mcfne.hin the tree? Was it used by some external driver sources that were never merged?
That mcfne.h came in with all the other non-mmu m68k headers back in the 2.5 kernel days. It was used by some external patches that modified the existing ne.c ethernet driver. But they were really hacks, and a bit ugly at that.
It was a recently pointed out by Paul Bolle on the m68k list that this file still was unused in mainline, and that prompted me to actually sort out the 8390 support on these boards and get it done right.
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com