Add APNE PCMCIA 100 Mbit support
Subsystems (4)
v8 cover Add APNE PCMCIA 100 Mbit support
The first patch enables the use of core PCMCIA code to parse config table entries in Amiga drivers. The remaining two patches add 16 bit IO support to the m68k low-level IO access code, and add code to the APNE driver to autoprobe for 16 bit IO on cards that support it (the 100 Mbit cards). The core PCMCIA config table parser is utilized for this (may be built as a module).
Tested by Alex on a 100 Mbit card. Not yet tested on 10 Mbit cards - if any of those also have the 16 bit IO feature set in their config table, this patch series would break on those cards.
Note that only patch 3 has been sent to netdev. Please CC linux-m68k when providing comments.
Cheers,
Michael
PATCH v8 1/3 m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h
Add the interface definitions for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to amipcmcia.h for use by apne.c.
--
Changes from v7:
- add interface definitions only, move actual code to apne.c
--- arch/m68k/include/asm/amipcmcia.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/m68k/include/asm/amipcmcia.h +4 -0
@@ -64,6 +64,7 @@ static inline void pcmcia_disable_irq(void)#define PCMCIA_SPEED_250NS 250#define PCMCIA_SPEED_720NS 720 +#ifndef _LINUX_CISTPL_H/* PCMCIA Tuple codes */ #define CISTPL_NULL 0x00
@@ -106,5 +107,8 @@ static inline void pcmcia_disable_irq(void)#define CISTPL_FUNCID_NETWORK 0x06#define CISTPL_FUNCID_AIMS 0x07#define CISTPL_FUNCID_SCSI 0x08 +#else /* defined _LINUX_CISTPL_H */ +extern int pcmcia_parse_tuple (tuple_t *cftuple,cisparse_t *cfparse); +#endif #endif
Signature · 1 line
2.17.1
PATCH v8 2/3 m68k: io_mm.h - add APNE 100 MBit support
In reply to Michael SchmitzAdd 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
@@ -61,12 +61,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
@@ -97,6 +95,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
@@ -132,6 +132,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
@@ -148,6 +149,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
@@ -161,6 +163,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 default :return 0 ;/* avoid warnings, just in case */
@@ -174,6 +177,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
@@ -190,6 +194,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
@@ -200,7 +205,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))
@@ -254,6 +259,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.17.1
PATCH v8 3/3 net/8390: apne.c - add 100 Mbit support to apne.c driver
In reply to Michael SchmitzAdd module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.
Select core PCMCIA support modules for use by APNE driver.
10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing isa_type at runtime. Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.
An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.
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 v7:
- move 'select' for PCCARD and PCMCIA to 8390 Kconfig, so Amiga pcmcia.c may remain built-in while core PCMCIA code can be built as modules if APNE driver is a module.
- move 16 bit mode autoprobe code from amiga/pcmcia.c to this driver, to allow the core PCMCIA code we depend on to be built as modules.
- change module parameter type from bool to int to allow for tri-state semantics (autoprobe, 8 bit, 16 bit).
Changes from v6:
- use 16 bit mode autoprobe based on PCMCIA config table data
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
change module parameter - 0 for 8 bit, 1 for 16 bit, else autoprobe
--- drivers/net/ethernet/8390/Kconfig | 9 ++++ drivers/net/ethernet/8390/apne.c | 69 +++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)
drivers/net/ethernet/8390/Kconfig +9 -0
@@ -136,6 +136,8 @@ config NE2K_PCI config APNE tristate "PCMCIA NE2000 support" depends on AMIGA_PCMCIA + select PCCARD + select PCMCIA select CRC32 help If you have a PCMCIA NE2000 compatible adapter, say Y. Otherwise,
@@ -144,6 +146,13 @@ 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. The driver will attempt to autoprobe 100 Mbit + mode, so this option may not be necessary. Use apne.100mbit=0 + should autoprobe mis-detect a 100 Mbit card. + config PCMCIA_PCNET tristate "NE2000 compatible PCMCIA support" depends on PCMCIA
drivers/net/ethernet/8390/apne.c +69 -0
109 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v8 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver
11/4/21 9:10 AM, Michael Schmitz пишет:
Quoted 140 lines
Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.
Select core PCMCIA support modules for use by APNE driver.
10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing
isa_typeat runtime. Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.
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]>.
Tested-by Alex Kazik <[email protected]>Signed-off-by Michael Schmitz <[email protected]>--
Changes from v7:
- move 'select' for PCCARD and PCMCIA to 8390
Kconfig, so Amigapcmcia.cmay remain built-in while core PCMCIA code can be built as modules if APNE driver is a module.
- move 16 bit mode autoprobe code fromamiga/pcmcia.cto this driver, to allow the core PCMCIA code we depend on to be built as modules.
- change module parameter type from bool to int to allow for tri-state semantics (autoprobe, 8 bit, 16 bit).Changes from v6:
- use 16 bit mode autoprobe based on PCMCIA config table data
Changes from v5:
- move autoprobe code to new patch in this series
Geert Uytterhoeven:
- rewordKconfighelp textFinn Thain:
- style fixes, usemsec_to_jiffiesin timeout calcAlex Kazik:
- revert module parameter permission changeChanges 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 probeChanges from v3:
- change module parameter name to match
KconfighelpFinn Thain:
- fix coding style in new card reset code block
- allow reset ofisa_typeby module parameterChanges from v1:
- fix module parameter name in
Kconfighelp textAlex Kazik:
- change module parameter type to bool, fix module parameter permissionChanges from RFC:
Geert Uytterhoeven:
- changeAPNE_100MBITto depend on APNE
- change '---help---' to 'help' (former no longer supported)
- fix whitespace errors
- fixmodule_param_named()arg count
- protect all added code by #ifdefCONFIG_APNE_100MBITchange module parameter - 0 for 8 bit, 1 for 16 bit, else autoprobe
--- drivers/net/ethernet/8390/Kconfig | 9 ++++ drivers/net/ethernet/8390/apne.c | 69 +++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)drivers/net/ethernet/8390/Kconfig +9
-0@@ -136,6 +136,8 @@ config NE2K_PCI config APNE tristate "PCMCIA NE2000 support" depends on AMIGA_PCMCIA + select PCCARD + select PCMCIA select CRC32 help If you have a PCMCIA NE2000 compatible adapter, say Y. Otherwise,@@ -144,6 +146,13 @@ 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. The driver will attempt to autoprobe 100 Mbit + mode, so this option may not be necessary. Use apne.100mbit=0 + should autoprobe mis-detect a 100 Mbit card. + config PCMCIA_PCNET tristate "NE2000 compatible PCMCIA support" depends on PCMCIAdrivers/net/ethernet/8390/apne.c +2
-0@@ -38,6 +38,7 @@#include <linux/etherdevice.h> #include <linux/interrupt.h> #include <linux/jiffies.h> +#include <pcmcia/cistpl.h> #include <asm/io.h> #include <asm/setup.h> @@ -87,6 +88,7 @@ static void apne_block_output(struct net_device *dev, const int count,static irqreturn_t apne_interrupt (int irq,void *dev_id);static int init_pcmcia (void ); +static int pcmcia_is_16bit (void );/* IO base address used for nic */
drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 126
Quoted 6 lines
drivers/net/ethernet/8390/apne.c +3
-0@@ -119,6 +121,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 u32 apne_100_mbit =-1 ; +module_param_named(100_mbit, apne_100_mbit, uint, 0444); +MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");
Can we try to detect 100mbit support by default on load and make a configuration option in sysfs?
Quoted 94 lines
drivers/net/ethernet/8390/apne.c +64
-0+static struct net_device *__init apne_probe (void ) {struct net_device *dev;@@ -140,6 +146,13 @@ static struct net_device * __init apne_probe(void)pr_info ("Looking for PCMCIA ethernet card : " ); +if (apne_100_mbit ==1 ) + isa_type =ISA_TYPE_AG16 ; +else if (apne_100_mbit ==0 ) + isa_type =ISA_TYPE_AG ; +else +pr_cont (" (autoprobing 16 bit mode) " ); +/* check if a card is inserted */ if (!(PCMCIA_INSERTED )) {pr_cont ("NO PCMCIA card inserted\n" );@@ -167,6 +180,14 @@ static struct net_device * __init apne_probe(void)pr_cont ("ethernet PCMCIA card inserted\n" ); +#if IS_ENABLED (CONFIG_PCMCIA ) +if (apne_100_mbit <0 &&pcmcia_is_16bit ()) { +pr_info ("16-bit PCMCIA card detected!\n" ); + isa_type =ISA_TYPE_AG16 ; + apne_100_mbit =1 ; + } +#endif +if (!init_pcmcia ()) {/* XXX: shouldn't we re-enable irq here? */ free_netdev (dev);@@ -583,6 +604,16 @@ 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 );@@ -616,4 +647,42 @@ static int init_pcmcia(void)return 1 ; } +#if IS_ENABLED (CONFIG_PCMCIA ) +static int pcmcia_is_16bit (void ) +{ +u_char cftuple[258 ]; +int cftuple_len; +tuple_t cftable_tuple; +cistpl_cftable_entry_t cftable_entry; + + cftuple_len =pcmcia_copy_tuple (CISTPL_CFTABLE_ENTRY , cftuple,256 ); +if (cftuple_len <3 ) +return 0 ; +#ifdef DEBUG + else + print_hex_dump(KERN_WARNING, "cftable: ", DUMP_PREFIX_NONE, 8, + sizeof(char), cftuple, cftuple_len, false); +#endif + +/* build tuple_t struct and call pcmcia_parse_tuple */ + cftable_tuple.DesiredTuple =CISTPL_CFTABLE_ENTRY ; + cftable_tuple.TupleCode =CISTPL_CFTABLE_ENTRY ; + cftable_tuple.TupleData = &cftuple[2 ]; + cftable_tuple.TupleDataLen = cftuple_len -2 ; + cftable_tuple.TupleDataMax = cftuple_len -2 ; + +if (pcmcia_parse_tuple (&cftable_tuple, (cisparse_t *)&cftable_entry)) +return 0 ; + +#ifdef DEBUG +pr_info ("IO flags: %x\n" , cftable_entry.io.flags); +#endif + +if (cftable_entry.io.flags &CISTPL_IO_16BIT ) +return 1 ; + +return 0 ; +} +#endif +MODULE_LICENSE ("GPL" );
Re: [PATCH v8 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver
Denis,
Quoted 145 lines · Denis Kirjanov
11/4/21 9:10 AM, Michael Schmitz пишет:
Quoted 142 lines
Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.
Select core PCMCIA support modules for use by APNE driver.
10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing
isa_typeat runtime. Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.
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]>.
CC: [email protected]
Link:
https://lore.kernel.org/r/[email protected]Tested-by Alex Kazik <[email protected]>Signed-off-by Michael Schmitz <[email protected]>--
Changes from v7:
- move 'select' for PCCARD and PCMCIA to 8390
Kconfig, so Amigapcmcia.cmay remain built-in while core PCMCIA code can be built as modules if APNE driver is a module.
- move 16 bit mode autoprobe code fromamiga/pcmcia.cto this driver, to allow the core PCMCIA code we depend on to be built as modules.
- change module parameter type from bool to int to allow for tri-state semantics (autoprobe, 8 bit, 16 bit).Changes from v6:
- use 16 bit mode autoprobe based on PCMCIA config table data
Changes from v5:
- move autoprobe code to new patch in this series
Geert Uytterhoeven:
- rewordKconfighelp textFinn Thain:
- style fixes, usemsec_to_jiffiesin timeout calcAlex Kazik:
- revert module parameter permission changeChanges 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 probeChanges from v3:
- change module parameter name to match
KconfighelpFinn Thain:
- fix coding style in new card reset code block
- allow reset ofisa_typeby module parameterChanges from v1:
- fix module parameter name in
Kconfighelp textAlex Kazik:
- change module parameter type to bool, fix module parameter permissionChanges from RFC:
Geert Uytterhoeven:
- changeAPNE_100MBITto depend on APNE
- change '---help---' to 'help' (former no longer supported)
- fix whitespace errors
- fixmodule_param_named()arg count
- protect all added code by #ifdefCONFIG_APNE_100MBITchange module parameter - 0 for 8 bit, 1 for 16 bit, else autoprobe
--- drivers/net/ethernet/8390/Kconfig | 9 ++++ drivers/net/ethernet/8390/apne.c | 69 +++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)drivers/net/ethernet/8390/Kconfig +2
-0@@ -136,6 +136,8 @@ config NE2K_PCI config APNE tristate "PCMCIA NE2000 support" depends on AMIGA_PCMCIA + select PCCARD + select PCMCIA select CRC32 help If you have a PCMCIA NE2000 compatible adapter, say Y.Otherwise,
drivers/net/ethernet/8390/Kconfig +6
-0@@ -144,6 +146,13 @@ 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. The driver will attempt to autoprobe 100 Mbit + mode, so this option may not be necessary. Use apne.100mbit=0 + should autoprobe mis-detect a 100 Mbit card. + config PCMCIA_PCNET tristate "NE2000 compatible PCMCIA support" depends on PCMCIAdrivers/net/ethernet/8390/apne.c +2
-0@@ -38,6 +38,7 @@#include <linux/etherdevice.h> #include <linux/interrupt.h> #include <linux/jiffies.h> +#include <pcmcia/cistpl.h> #include <asm/io.h> #include <asm/setup.h> @@ -87,6 +88,7 @@ static void apne_block_output(struct net_device *dev, const int count, static irqreturn_t apne_interrupt(int irq, void *dev_id);static int init_pcmcia (void ); +static int pcmcia_is_16bit (void );/* IO base address used for nic */ @@ -119,6 +121,10 @@ static u32 apne_msg_enable;module_param_named (msg_enable, apne_msg_enable, uint,0444 );
Quoted 8 lines
drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 126
Quoted 5 lines
MODULE_PARM_DESC(msg_enable, "Debug message level (see
linux/netdevice.hfor bitmap)");
+static u32apne_100_mbit= -1;drivers/net/ethernet/8390/apne.c +2
-0+module_param_named(100_mbit, apne_100_mbit, uint, 0444); +MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support");Can we try to detect 100mbit support by default on load and make a configuration option in sysfs?
100mbit support _is_ detected by default on load (see code below). The module option is only there as an override.
PCMCIA 100mbit support is equivalent to 16 bit IO supported by the card. You might argue a sysfs option belongs in the built-in Amiga PCMCIA support code, instead of the card driver even though this is about a card feature. We had discussed this earlier and gone for the module parameter. I'll discuss this with Geert again.
Cheers,
Michael
Quoted 90 lines
Quoted 90 lines
drivers/net/ethernet/8390/apne.c +60
-0+static struct net_device *__init apne_probe (void ) {struct net_device *dev;@@ -140,6 +146,13 @@ static struct net_device * __init apne_probe(void)pr_info ("Looking for PCMCIA ethernet card : " ); + if (apne_100_mbit == 1) + isa_type = ISA_TYPE_AG16; + else if (apne_100_mbit == 0) + isa_type =ISA_TYPE_AG ; + else + pr_cont(" (autoprobing 16 bit mode) "); +/* check if a card is inserted */ if (!(PCMCIA_INSERTED )) {pr_cont ("NO PCMCIA card inserted\n" );@@ -167,6 +180,14 @@ static struct net_device * __init apne_probe(void)pr_cont ("ethernet PCMCIA card inserted\n" ); +#if IS_ENABLED(CONFIG_PCMCIA) +if (apne_100_mbit <0 &&pcmcia_is_16bit ()) { +pr_info ("16-bit PCMCIA card detected!\n" ); + isa_type =ISA_TYPE_AG16 ; + apne_100_mbit =1 ; + } +#endif +if (!init_pcmcia ()) {/* XXX: shouldn't we re-enable irq here? */ free_netdev (dev);@@ -583,6 +604,16 @@ 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 );@@ -616,4 +647,42 @@ static int init_pcmcia(void)return 1 ; } +#if IS_ENABLED(CONFIG_PCMCIA) +static int pcmcia_is_16bit (void ) +{ +u_char cftuple[258 ]; +int cftuple_len; +tuple_t cftable_tuple; +cistpl_cftable_entry_t cftable_entry; + + cftuple_len =pcmcia_copy_tuple (CISTPL_CFTABLE_ENTRY , cftuple,256 ); +if (cftuple_len <3 ) +return 0 ; +#ifdef DEBUG + else + print_hex_dump(KERN_WARNING, "cftable: ", DUMP_PREFIX_NONE, 8, + sizeof(char), cftuple, cftuple_len, false); +#endif + +/* build tuple_t struct and call pcmcia_parse_tuple */ + cftable_tuple.DesiredTuple =CISTPL_CFTABLE_ENTRY ; + cftable_tuple.TupleCode =CISTPL_CFTABLE_ENTRY ; + cftable_tuple.TupleData = &cftuple[2 ]; + cftable_tuple.TupleDataLen = cftuple_len -2 ; + cftable_tuple.TupleDataMax = cftuple_len -2 ; + +if (pcmcia_parse_tuple (&cftable_tuple, (cisparse_t *)&cftable_entry)) +return 0 ; + +#ifdef DEBUG +pr_info ("IO flags: %x\n" , cftable_entry.io.flags); +#endif + +if (cftable_entry.io.flags &CISTPL_IO_16BIT ) +return 1 ; + +return 0 ; +} +#endif +MODULE_LICENSE ("GPL" );
Geert Uytterhoeven
maintainerRe: [PATCH v8 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h
In reply to Michael SchmitzHi Michael,
Quoted 5 lines · Michael Schmitz
Add the interface definitions for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to
amipcmcia.hfor use byapne.c.Signed-off-by Michael Schmitz <[email protected]>
Thanks for your patch!
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 67
Quoted 7 lines
arch/m68k/include/asm/amipcmcia.h +1
-0@@ -64,6 +64,7 @@ static inline void pcmcia_disable_irq(void)#define PCMCIA_SPEED_250NS 250#define PCMCIA_SPEED_720NS 720 +#ifndef _LINUX_CISTPL_H
This #ifndef is here to prevent conflicts with <pcmcia/cistpl.h>? Why can't the definitions below be removed, and <pcmcia/cistpl.h> always included instead?
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 111
Quoted 9 lines
arch/m68k/include/asm/amipcmcia.h +2
-0/* PCMCIA Tuple codes */ #define CISTPL_NULL 0x00@@ -106,5 +107,8 @@ static inline void pcmcia_disable_irq(void)#define CISTPL_FUNCID_NETWORK 0x06#define CISTPL_FUNCID_AIMS 0x07#define CISTPL_FUNCID_SCSI 0x08 +#else /* defined _LINUX_CISTPL_H */ +extern int pcmcia_parse_tuple (tuple_t *cftuple,cisparse_t *cfparse);
This can be unconditional?
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 112
Quoted 1 line
arch/m68k/include/asm/amipcmcia.h +1
-0+#endif
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v8 2/3] m68k: io_mm.h - add APNE 100 MBit support
In reply to Michael SchmitzQuoted 10 lines · Michael Schmitz
Add code to support 10 Mbit and 100 Mbit mode for APNE driver.
A new ISA type
ISA_TYPE_AG16dynamically 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]>.
Signed-off-by Michael Schmitz <[email protected]>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Geert Uytterhoeven
maintainerRe: [PATCH v8 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver
In reply to Michael SchmitzHi Michael,
Quoted 26 lines · Michael Schmitz
Add module parameter, IO mode autoprobe and PCMCIA reset code required to support 100 Mbit PCMCIA ethernet cards on Amiga.
Select core PCMCIA support modules for use by APNE driver.
10 Mbit and 100 Mbit mode are supported by the same module. Use the core PCMCIA cftable parser to detect 16 bit cards, and automatically enable 16 bit ISA IO access for those cards by changing
isa_typeat runtime. Code to reset the PCMCIA hardware required for 16 bit cards is also added to the driver probe.An optional module parameter switches Amiga ISA IO accessors to 8 or 16 bit access in case autoprobe fails.
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]>.
Tested-by Alex Kazik <[email protected]>Signed-off-by Michael Schmitz <[email protected]>Changes from v7:
Quoted 8 lines
- move 'select' for PCCARD and PCMCIA to 8390
Kconfig, so Amigapcmcia.cmay remain built-in while core PCMCIA code can be built as modules if APNE driver is a module.
- move 16 bit mode autoprobe code fromamiga/pcmcia.cto this driver, to allow the core PCMCIA code we depend on to be built as modules.
- change module parameter type from bool to int to allow for tri-state semantics (autoprobe, 8 bit, 16 bit).
Thanks for the update!
drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 124
Quoted 8 lines
drivers/net/ethernet/8390/apne.c +1
-0@@ -119,6 +121,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 u32 apne_100_mbit =-1 ;
The changelog said you changed this to int, not u32...
Quoted 21 lines
drivers/net/ethernet/8390/apne.c +10
-0+module_param_named(100_mbit, apne_100_mbit, uint, 0444); +MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support"); +static struct net_device *__init apne_probe (void ) {struct net_device *dev;@@ -140,6 +146,13 @@ static struct net_device * __init apne_probe(void)pr_info ("Looking for PCMCIA ethernet card : " ); +if (apne_100_mbit ==1 ) + isa_type =ISA_TYPE_AG16 ; +else if (apne_100_mbit ==0 ) + isa_type =ISA_TYPE_AG ; +else +pr_cont (" (autoprobing 16 bit mode) " ); +/* check if a card is inserted */ if (!(PCMCIA_INSERTED )) {pr_cont ("NO PCMCIA card inserted\n" );
drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 184
Quoted 5 lines
drivers/net/ethernet/8390/apne.c +2
-0@@ -167,6 +180,14 @@ static struct net_device * __init apne_probe(void)pr_cont ("ethernet PCMCIA card inserted\n" ); +#if IS_ENABLED (CONFIG_PCMCIA ) +if (apne_100_mbit <0 &&pcmcia_is_16bit ()) {
apne_100_mbit is u32, hence can never be negative.
drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 193
Quoted 9 lines
drivers/net/ethernet/8390/apne.c +6
-0+pr_info ("16-bit PCMCIA card detected!\n" ); + isa_type =ISA_TYPE_AG16 ; + apne_100_mbit = 1; + } +#endif +if (!init_pcmcia ()) {/* XXX: shouldn't we re-enable irq here? */ free_netdev (dev);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v8 3/3] net/8390: apne.c - add 100 Mbit support to apne.c driver
Hi Geert,
Quoted 10 lines · Geert Uytterhoeven
drivers/net/ethernet/8390/apne.c static u32 apne_msg_enable; · line 124
Quoted 8 lines
drivers/net/ethernet/8390/apne.c +1
-0@@ -119,6 +121,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 u32 apne_100_mbit =-1 ;The changelog said you changed this to int, not u32...
Yes, and I had certainly done that, for the express purpose of allowing the negative ...
No idea how that one snuck back in, I'll fix that.
Denis suggested this be changed to a sysfs parameter, but neither this driver nor the Amiga PCMCIA support have been converted to the driver framework. I couldn't see a way to add a sysfs parameter, so I'd rather keep this as kernel command line or module parameter.
Cheers,
Michael
Quoted 50 lines
Quoted 21 lines
drivers/net/ethernet/8390/apne.c +10
-0+module_param_named(100_mbit, apne_100_mbit, uint, 0444); +MODULE_PARM_DESC(100_mbit, "Enable 100 Mbit support"); +static struct net_device *__init apne_probe (void ) {struct net_device *dev;@@ -140,6 +146,13 @@ static struct net_device * __init apne_probe(void)pr_info ("Looking for PCMCIA ethernet card : " ); +if (apne_100_mbit ==1 ) + isa_type =ISA_TYPE_AG16 ; +else if (apne_100_mbit ==0 ) + isa_type =ISA_TYPE_AG ; +else +pr_cont (" (autoprobing 16 bit mode) " ); +/* check if a card is inserted */ if (!(PCMCIA_INSERTED )) {pr_cont ("NO PCMCIA card inserted\n" );drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 184
Quoted 5 lines
drivers/net/ethernet/8390/apne.c +2
-0@@ -167,6 +180,14 @@ static struct net_device * __init apne_probe(void)pr_cont ("ethernet PCMCIA card inserted\n" ); +#if IS_ENABLED (CONFIG_PCMCIA ) +if (apne_100_mbit <0 &&pcmcia_is_16bit ()) {
apne_100_mbitis u32, hence can never be negative.drivers/net/ethernet/8390/apne.c static struct net_device * __init apne_probe(void) · line 193
Quoted 9 lines
drivers/net/ethernet/8390/apne.c +6
-0+pr_info ("16-bit PCMCIA card detected!\n" ); + isa_type =ISA_TYPE_AG16 ; + apne_100_mbit = 1; + } +#endif +if (!init_pcmcia ()) {/* XXX: shouldn't we re-enable irq here? */ free_netdev (dev);Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v8 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h
In reply to Geert UytterhoevenHi Geert,
Quoted 17 lines · Geert Uytterhoeven
Hi Michael,
Quoted 5 lines · Michael Schmitz
Add the interface definitions for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to
amipcmcia.hfor use byapne.c.Signed-off-by Michael Schmitz <[email protected]>Thanks for your patch!
Quoted 6 lines
arch/m68k/include/asm/amipcmcia.h +0
-0@@ -64,6 +64,7 @@ static inline void pcmcia_disable_irq(void)#define PCMCIA_SPEED_250NS 250#define PCMCIA_SPEED_720NS 720
Quoted 5 lines
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 67
Quoted 1 line
arch/m68k/include/asm/amipcmcia.h +1
-0+#ifndef _LINUX_CISTPL_HThis #ifndef is here to prevent conflicts with <
pcmcia/cistpl.h>? Why can't the definitions below be removed, and <pcmcia/cistpl.h> always included instead?
We'd have to include it everywhere amipcmcia.h is included (because of the pcmcia_parse_tuple() external declaration below). Didn't want to do that unless absolutely necessary, but if you don't mind that, I'll change this part.
Quoted 12 lines
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 111
Quoted 10 lines
arch/m68k/include/asm/amipcmcia.h +2
-0/* PCMCIA Tuple codes */ #define CISTPL_NULL 0x00@@ -106,5 +107,8 @@ static inline void pcmcia_disable_irq(void)#define CISTPL_FUNCID_NETWORK 0x06#define CISTPL_FUNCID_AIMS 0x07#define CISTPL_FUNCID_SCSI 0x08 +#else /* defined _LINUX_CISTPL_H */ +extern int pcmcia_parse_tuple (tuple_t *cftuple,cisparse_t *cfparse);This can be unconditional?
Brain fade on my part - this of course needs to be conditional on CONFIG_PCMCIA. not on _LINUX_CISTPL_H.
Cheers,
Michael
Quoted 14 lines
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 112
Quoted 2 lines
arch/m68k/include/asm/amipcmcia.h +1
-0+#endif Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Geert Uytterhoeven
maintainerRe: [PATCH v8 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h
Hi Michael,
Quoted 22 lines · Michael Schmitz
Quoted 15 lines · Geert Uytterhoeven
Quoted 5 lines · Michael Schmitz
Add the interface definitions for 16 bit card autoprobing (using the generic PCMCIA cftable entry parser) to
amipcmcia.hfor use byapne.c.Signed-off-by Michael Schmitz <[email protected]>Thanks for your patch!
Quoted 6 lines
arch/m68k/include/asm/amipcmcia.h +0
-0@@ -64,6 +64,7 @@ static inline void pcmcia_disable_irq(void)#define PCMCIA_SPEED_250NS 250#define PCMCIA_SPEED_720NS 720Quoted 5 lines
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 67
Quoted 1 line
arch/m68k/include/asm/amipcmcia.h +1
-0+#ifndef _LINUX_CISTPL_HThis #ifndef is here to prevent conflicts with <
pcmcia/cistpl.h>? Why can't the definitions below be removed, and <pcmcia/cistpl.h> always included instead?
Quoted 4 lines
We'd have to include it everywhere
amipcmcia.his included (because of thepcmcia_parse_tuple()external declaration below). Didn't want to do that unless absolutely necessary, but if you don't mind that, I'll change this part.
That include can be avoided by providing forward declarations for struct tuple_t and struct cisparse_t, and using the struct types instead of the typedefs for the pcmcia_parse_tuple() parameters, right?
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
arch/m68k/include/asm/amipcmcia.h +0
-0/* PCMCIA Tuple codes */ Quoted 9 lines
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 111
Quoted 7 lines
arch/m68k/include/asm/amipcmcia.h +2
-0#define CISTPL_NULL 0x00@@ -106,5 +107,8 @@ static inline void pcmcia_disable_irq(void)#define CISTPL_FUNCID_NETWORK 0x06#define CISTPL_FUNCID_AIMS 0x07#define CISTPL_FUNCID_SCSI 0x08 +#else /* defined _LINUX_CISTPL_H */ +extern int pcmcia_parse_tuple (tuple_t *cftuple,cisparse_t *cfparse);This can be unconditional?
Quoted 2 lines
Brain fade on my part - this of course needs to be conditional on
CONFIG_PCMCIA. not on_LINUX_CISTPL_H.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH v8 1/3] m68k: amiga/pcmcia - add 16 bit detection interface to amipcmcia.h
Hi Geert,
Quoted 12 lines · Geert Uytterhoeven
Quoted 12 lines
Quoted 11 lines
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 67
Quoted 7 lines
arch/m68k/include/asm/amipcmcia.h +1
-0@@ -64,6 +64,7 @@ static inline void pcmcia_disable_irq(void)#define PCMCIA_SPEED_250NS 250#define PCMCIA_SPEED_720NS 720 +#ifndef _LINUX_CISTPL_HThis #ifndef is here to prevent conflicts with <
pcmcia/cistpl.h>? Why can't the definitions below be removed, and <pcmcia/cistpl.h> always included instead?
Quoted 8 lines
Quoted 4 lines
We'd have to include it everywhere
amipcmcia.his included (because of thepcmcia_parse_tuple()external declaration below). Didn't want to do that unless absolutely necessary, but if you don't mind that, I'll change this part.That include can be avoided by providing forward declarations for struct
tuple_tand structcisparse_t, and using the struct types instead of the typedefs for thepcmcia_parse_tuple()parameters, right?
Probably, but we'd still have the conflicts from including both pcmcia/cistpl.h and asm/amipcmcia.h in apne.c.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
arch/m68k/include/asm/amipcmcia.h static inline void pcmcia_disable_irq(void) · line 111
Quoted 12 lines
arch/m68k/include/asm/amipcmcia.h +2
-0/* PCMCIA Tuple codes */ #define CISTPL_NULL 0x00@@ -106,5 +107,8 @@ static inline void pcmcia_disable_irq(void)#define CISTPL_FUNCID_NETWORK 0x06#define CISTPL_FUNCID_AIMS 0x07#define CISTPL_FUNCID_SCSI 0x08 +#else /* defined _LINUX_CISTPL_H */ +extern int pcmcia_parse_tuple (tuple_t *cftuple,cisparse_t *cfparse);This can be unconditional?
Quoted 3 lines
Quoted 2 lines
Brain fade on my part - this of course needs to be conditional on
CONFIG_PCMCIA. not on_LINUX_CISTPL_H.
Got your meaning now - this can be unconditional now.
Cheers,
Michael
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds