Add APNE PCMCIA 100 Mbit support
Subsystems (4)
v6 cover Add APNE PCMCIA 100 Mbit support
Now that we've sanitzed m68k io_mm.h, revisit support for the 100 Mbit APNE PCMCIA card variants that didn't find favour with the netdev folks three years ago.
Add another ISA type for these cards, and switch to that type from the APNE probe code in response to a module parameter or kernel option. Support for the 16 bit 10/100 Mbit cards is now included by default.
Try to autoprobe for 16 bit mode (patch 3; experimental!).
Note that only patch 2 and 3 have been sent to netdev. These patches depend on patch 1, and must not be applied to the netdev tree before Geert has applied patch 1! A note to that effect has been added to the commit logs.
Cheers,
Michael
PATCH v6 1/3 m68k: io_mm.h - add APNE 100 MBit support
Add code to support 10 Mbit and 100 Mbit mode for APNE driver.
A new ISA type ISA_TYPE_AG16 dynamically switches the Amiga ISA inb accessor to word access as required by the 100 Mbit cards.
Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.
--
Changes from v4:
Geert Uytterhoeven:
- drop CONFIG_APNE100MBIT ifdefs
Changes from v3:
Finn Thain:
- revert isa_inb() define reordering
- omit redundant #ifdef around ISA_TYPE_AG16 case labels
Changes from v1:
Andreas Schwab:
- remove redundant fallthrough annotations
Changes from RFC:
Geert Uytterhoeven:
- rename ISA_TYPE_AG100 to ISA_TYPE_AG16 (16 bit cards)
- move ISA_TYPE_AG16 case inside #ifdef CONFIG_AMIGA_PCMCIA
- change #if defined(CONFIG_APNE_100MBIT) to #ifdef
- fix parentheses in isa_inb() define
- omit comment about compiler optimization
- add ISA_TYPE_AG16 case to isa_delay()
--- arch/m68k/include/asm/io_mm.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
arch/m68k/include/asm/io_mm.h +11 -5
@@ -65,12 +65,10 @@#define AG_ISA_IO_B (ioaddr) ( GAYLE_IO+(ioaddr)+(((ioaddr)&1)*GAYLE_ODD) )#define AG_ISA_IO_W (ioaddr) ( GAYLE_IO+(ioaddr) ) -#ifndef MULTI_ISA -#define MULTI_ISA 0 -#else +#ifdef MULTI_ISA #undef MULTI_ISA -#define MULTI_ISA 1#endif +#define MULTI_ISA 1/* Need MULTI_ISA for 16 bit PCMCIA card support ! */ #endif /* AMIGA_PCMCIA */ #ifdef CONFIG_ATARI_ROM_ISA
@@ -101,6 +99,8 @@#define ISA_TYPE_Q40 (1)#define ISA_TYPE_AG (2)#define ISA_TYPE_ENEC (3) +#define ISA_TYPE_AG16 (4)/* for 100 MBit APNE card */ +#if defined(CONFIG_Q40 ) && !defined(MULTI_ISA )#define ISA_TYPE ISA_TYPE_Q40
@@ -136,6 +136,7 @@ static inline u8 __iomem *isa_itb(unsigned long addr)case ISA_TYPE_Q40 :return (u8 __iomem *)Q40_ISA_IO_B (addr);#endif #ifdef CONFIG_AMIGA_PCMCIA +case ISA_TYPE_AG16 :case ISA_TYPE_AG :return (u8 __iomem *)AG_ISA_IO_B (addr);#endif #ifdef CONFIG_ATARI_ROM_ISA
@@ -155,6 +156,7 @@ static inline u16 __iomem *isa_itw(unsigned long addr)case ISA_TYPE_Q40 :return (u16 __iomem *)Q40_ISA_IO_W (addr);#endif #ifdef CONFIG_AMIGA_PCMCIA +case ISA_TYPE_AG16 :case ISA_TYPE_AG :return (u16 __iomem *)AG_ISA_IO_W (addr);#endif #ifdef CONFIG_ATARI_ROM_ISA
@@ -171,6 +173,7 @@ static inline u32 __iomem *isa_itl(unsigned long addr)switch (ISA_TYPE ) {#ifdef CONFIG_AMIGA_PCMCIA +case ISA_TYPE_AG16 :case ISA_TYPE_AG :return (u32 __iomem *)AG_ISA_IO_W (addr);#endif }
@@ -184,6 +187,7 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)case ISA_TYPE_Q40 :return (u8 __iomem *)Q40_ISA_MEM_B (addr);#endif #ifdef CONFIG_AMIGA_PCMCIA +case ISA_TYPE_AG16 :case ISA_TYPE_AG :return (u8 __iomem *)addr;#endif #ifdef CONFIG_ATARI_ROM_ISA
@@ -203,6 +207,7 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)case ISA_TYPE_Q40 :return (u16 __iomem *)Q40_ISA_MEM_W (addr);#endif #ifdef CONFIG_AMIGA_PCMCIA +case ISA_TYPE_AG16 :case ISA_TYPE_AG :return (u16 __iomem *)addr;#endif #ifdef CONFIG_ATARI_ROM_ISA
@@ -216,7 +221,7 @@ static inline u16 __iomem *isa_mtw(unsigned long addr) } -#define isa_inb (port) in_8(isa_itb(port)) +#define isa_inb (port) ((ISA_TYPE == ISA_TYPE_AG16) ? ((port) & 1 ? isa_inw((port) - 1) & 0xff : isa_inw(port) >> 8) : in_8(isa_itb(port)))#define isa_inw (port) (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))#define isa_inl (port) (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))#define isa_outb (val,port) out_8(isa_itb(port),(val))
@@ -270,6 +275,7 @@ static inline void isa_delay(void)case ISA_TYPE_Q40 :isa_outb (0 ,0x80 );break ;#endif #ifdef CONFIG_AMIGA_PCMCIA +case ISA_TYPE_AG16 :break ;case ISA_TYPE_AG :break ;#endif #ifdef CONFIG_ATARI_ROM_ISA
Signature · 1 line
2.7.4
PATCH v6 2/3 net/8390: apne.c - add 100 Mbit support to apne.c driver
In reply to Michael SchmitzAdd module parameter and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.
10 Mbit and 100 Mbit mode are supported by the same module. A module parameter switches Amiga ISA IO accessors to word access by changing isa_type at runtime. Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.
This patch depends on patch "m68k: io_mm.h - add APNE 100 MBit support" sent to linux-m68k, and must not be applied before that one!
Patch modified after patch "[PATCH RFC net-next] Amiga PCMCIA 100 MBit card support" submitted to netdev 2018/09/16 by Alex Kazik <[email protected]>.
--
Changes from v5:
- move autoprobe code to new patch in this series
Geert Uytterhoeven:
- reword Kconfig help text
Finn Thain:
- style fixes, use msec_to_jiffies in timeout calc
Alex Kazik:
- revert module parameter permission change
Changes from v4:
Geert Uytterhoeven:
- remove APNE100MBIT config option, always include 16 bit support
- change module parameter permissions
- try autoprobing for 16 bit mode early on in device probe
Changes from v3:
- change module parameter name to match Kconfig help
Finn Thain:
- fix coding style in new card reset code block
- allow reset of isa_type by module parameter
Changes from v1:
- fix module parameter name in Kconfig help text
Alex Kazik:
- change module parameter type to bool, fix module parameter permission
Changes from RFC:
Geert Uytterhoeven:
- change APNE_100MBIT to depend on APNE
- change '---help---' to 'help' (former no longer supported)
- fix whitespace errors
- fix module_param_named() arg count
- protect all added code by #ifdef CONFIG_APNE_100MBIT
--- drivers/net/ethernet/8390/Kconfig | 5 +++++ drivers/net/ethernet/8390/apne.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+)
drivers/net/ethernet/8390/Kconfig +5 -0
@@ -143,6 +143,11 @@ config APNE To compile this driver as a module, choose M here: the module will be called apne. + The driver also supports 10/100Mbit cards (e.g. Netgear FA411, + CNet Singlepoint). To activate 100 Mbit support, use the kernel + option apne.100mbit=1 (builtin) at boot time, or the apne.100mbit + module parameter. + config PCMCIA_PCNET tristate "NE2000 compatible PCMCIA support" depends on PCMCIA
drivers/net/ethernet/8390/apne.c +18 -0
@@ -120,6 +120,10 @@ static u32 apne_msg_enable;module_param_named (msg_enable, apne_msg_enable, uint,0444 );MODULE_PARM_DESC (msg_enable,"Debug message level (see linux/netdevice.h for bitmap)" ); +static bool apne_100_mbit; +module_param_named(100_mbit, apne_100_mbit, bool, 0444); +MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support"); +struct net_device *__init apne_probe (int unit) {struct net_device *dev;
@@ -139,6 +143,11 @@ struct net_device * __init apne_probe(int unit)if ( !(AMIGAHW_PRESENT (PCMCIA )) )return ERR_PTR (-ENODEV ); +if (apne_100_mbit) + isa_type =ISA_TYPE_AG16 ; +else + isa_type =ISA_TYPE_AG ; +pr_info ("Looking for PCMCIA ethernet card : " );/* check if a card is inserted */
@@ -590,6 +599,15 @@ static int init_pcmcia(void)#endif u_long offset; +/* reset card (idea taken from CardReset by Artur Pogoda) */ +if (isa_type ==ISA_TYPE_AG16 ) { +u_char tmp = gayle.intreq; + gayle.intreq =0xff ; +mdelay (1 ); + gayle.intreq = tmp; +mdelay (300 ); + } +pcmcia_reset ();pcmcia_program_voltage (PCMCIA_0V );pcmcia_access_speed (PCMCIA_SPEED_250NS );
Signature · 1 line
2.7.4
PATCH v6 3/3 net/8390: apne.c - autoprobe 100 Mbit mode in apne.c driver
In reply to Michael SchmitzAdd experimental autoprobe code to detect 16 bit/100 MBit cards to the APNE driver. Autoprobe uses the same code utilized in apne_probe1 to identify the 8390 chip - failure to identify the chip in 8 bit mode will switch the PCMCIA interface to 16 bit mode. This code is still untested!
This patch depends on patch "m68k: io_mm.h - add APNE 100 MBit support" sent to linux-m68k, and must not be applied before that one!
--- drivers/net/ethernet/8390/apne.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/net/ethernet/8390/apne.c +16 -0
@@ -156,6 +156,22 @@ struct net_device * __init apne_probe(int unit)return ERR_PTR (-ENODEV ); } +/* Reset card. Who knows what dain-bramaged state it was left in. */ + { +unsigned long reset_end_time = jiffies +msecs_to_jiffies (20 ); + +outb (inb (IOBASE +NE_RESET ),IOBASE +NE_RESET ); + +while ((inb (IOBASE +NE_EN0_ISR ) &ENISR_RESET ) ==0 ) +if (time_after (jiffies, reset_end_time)) { +pr_info ("Card not found (no reset ack).\n" ); + isa_type =ISA_TYPE_AG16 ; +break ; + } + +outb (0xff ,IOBASE +NE_EN0_ISR );/* Ack all intr. */ + } + dev =alloc_ei_netdev ();if (!dev)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.7.4
Hi,
I've tested the v6 patch on my A1200 and it works great. It's activated via the kernel boot option "apne.100_mbit=1".
Alex.
Hi Alex,
thanks for testing again - so autoprobe (no boot option) did_not_ work?
Cheers,
Michael
Quoted 6 lines · ALeX Kazik
Hi,
I've tested the v6 patch on my A1200 and it works great. It's activated via the kernel boot option "apne.100_mbit=1".
Alex.
Hi Michael,
Quoted 1 line
thanks for testing again
I'm happy to help.
Quoted 1 line
so autoprobe (no boot option)
did_not_work?
Yes, it did not work - sorry.
If anyone is curious: I'm testing with linux 5.12.9 (was the latest stable when the v1 appeared) and an about 5 year old installation on my A1200 with 68030+FPU@50Mhz and 64MB ram.
Alex.
Hi Alex,
thanks for clarifying.
There's a number of reasons why this might fail:
- card really needs the reset before even accepting the probe I/O,
- PCMCIA interface needs to be enabled before the probe (pcmcia_init() normally does that, but the card reset happens right at the start there),
- a probe read on a 16 bit card in 8 bit mode does appear to give the correct result.
I'll have to come up with something better - the CISTPL_CFTABLE_ENTRY config tuple ought to contain information about the IO path width somewhere. Just a matter of parsing it out without duplicating all of drivers/pcmcia/cistpl.c ... Any takers?
Cheers,
Michael
Quoted 13 lines · ALeX Kazik
Hi Michael,
Quoted 1 line
thanks for testing again
I'm happy to help.
Quoted 1 line
so autoprobe (no boot option)
did_not_work?Yes, it did not work - sorry.
If anyone is curious: I'm testing with linux 5.12.9 (was the latest stable when the v1 appeared) and an about 5 year old installation on my A1200 with 68030+FPU@50Mhz and 64MB ram.
Alex.