Skip to contentSkip to conversation

Add APNE PCMCIA 100 Mbit support

PATCH Superseded Michael Schmitz 3 participants 11 messages Jun 17, 2021 – Jun 18, 2021

Subsystems (4)

v3 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add APNE PCMCIA 100 Mbit support

Add another ISA type for these cards, and switch to that type from the APNE probe code in response to a module parameter.

I've addressed review comments received so far, to the best of my ability. Patch 1 not changed in v3, only fixes to patch 2 by Alex Kazik included.

v3 is the first version of this patch series sent to net-next (apne.c part only).

Tested by Alex on his Amiga 1200.

Cheers,

Michael

#1 lore raw

PATCH v3 1/2 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 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()

fixup - review comment Andreas Schwab (fallthrough)

---
 arch/m68k/include/asm/io_mm.h | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
arch/m68k/include/asm/io_mm.h +25 -1
index 9c521b0..3ab2f1d 100644
@@ -101,6 +101,11 @@
 #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_APNE100MBIT)
+#define MULTI_ISA 1
+#endif
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -136,6 +141,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -155,6 +163,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -171,6 +182,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
   switch(ISA_TYPE)
     {
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
     }
@@ -184,6 +198,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -203,6 +220,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -216,13 +236,14 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      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))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+#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_readb(p)       in_8(isa_mtb((unsigned long)(p)))
 #define isa_readw(p)       \
 	(ISA_SEX ? in_be16(isa_mtw((unsigned long)(p)))	\
@@ -270,6 +291,9 @@ static inline void isa_delay(void)
     case ISA_TYPE_Q40: isa_outb(0,0x80); break;
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: break;
+#endif
     case ISA_TYPE_AG: break;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
Signature · 1 line
2.7.4
#4 lore raw

PATCH v3 2/2 net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Add Kconfig option, 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. Additional code to reset the PCMCIA hardware is also added to the driver probe.

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 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 | 12 ++++++++++++
 drivers/net/ethernet/8390/apne.c  | 21 +++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/net/ethernet/8390/Kconfig +12 -0
index 9f4b302..6e4db63 100644
@@ -143,6 +143,18 @@ config APNE
 	  To compile this driver as a module, choose M here: the module
 	  will be called apne.
 
+config APNE100MBIT
+	bool "PCMCIA NE2000 100MBit support"
+	depends on APNE
+	default n
+	help
+	  This changes the driver to support 10/100Mbit cards (e.g. Netgear
+	  FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+	  supported by the same driver.
+
+	  To activate 100 Mbit support at runtime or from the kernel
+	  command line, use the apne.100mbit module parameter.
+
 config PCMCIA_PCNET
 	tristate "NE2000 compatible PCMCIA support"
 	depends on PCMCIA
drivers/net/ethernet/8390/apne.c +21 -0
index fe6c834..59e41ad 100644
@@ -120,6 +120,12 @@ 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)");
 
+#ifdef CONFIG_APNE100MBIT
+static bool apne_100_mbit;
+module_param_named(apne_100_mbit_msg, apne_100_mbit, bool, 0444);
+MODULE_PARM_DESC(apne_100_mbit_msg, "Enable 100 Mbit support");
+#endif
+
 struct net_device * __init apne_probe(int unit)
 {
 	struct net_device *dev;
@@ -139,6 +145,11 @@ struct net_device * __init apne_probe(int unit)
 	if ( !(AMIGAHW_PRESENT(PCMCIA)) )
 		return ERR_PTR(-ENODEV);
 
+#ifdef CONFIG_APNE100MBIT
+	if (apne_100_mbit)
+		isa_type = ISA_TYPE_AG16;
+#endif
+
 	pr_info("Looking for PCMCIA ethernet card : ");
 
 	/* check if a card is inserted */
@@ -590,6 +601,16 @@ static int init_pcmcia(void)
 #endif
 	u_long offset;
 
+#ifdef CONFIG_APNE100MBIT
+	/* reset card (idea taken from CardReset by Artur Pogoda) */
+	{
+		u_char  tmp = gayle.intreq;
+
+		gayle.intreq = 0xff;    mdelay(1);
+		gayle.intreq = tmp;     mdelay(300);
+	}
+#endif
+
 	pcmcia_reset();
 	pcmcia_program_voltage(PCMCIA_0V);
 	pcmcia_access_speed(PCMCIA_SPEED_250NS);
Signature · 1 line
2.7.4
#5 lore raw

Re: [PATCH net-next v3 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Quoted 79 lines · Michael Schmitz

Add Kconfig option, 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. Additional code to reset the PCMCIA hardware is also added to the driver probe.

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 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 | 12 ++++++++++++
 drivers/net/ethernet/8390/apne.c  | 21 +++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/net/ethernet/8390/Kconfig +12 -0
index 9f4b302..6e4db63 100644
@@ -143,6 +143,18 @@ config APNE
 	  To compile this driver as a module, choose M here: the module
 	  will be called apne.
 
+config APNE100MBIT
+	bool "PCMCIA NE2000 100MBit support"
+	depends on APNE
+	default n
+	help
+	  This changes the driver to support 10/100Mbit cards (e.g. Netgear
+	  FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+	  supported by the same driver.
+
+	  To activate 100 Mbit support at runtime or from the kernel
+	  command line, use the apne.100mbit module parameter.
+
 config PCMCIA_PCNET
 	tristate "NE2000 compatible PCMCIA support"
 	depends on PCMCIA
drivers/net/ethernet/8390/apne.c +6 -0
index fe6c834..59e41ad 100644
@@ -120,6 +120,12 @@ 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)");
 
+#ifdef CONFIG_APNE100MBIT
+static bool apne_100_mbit;
+module_param_named(apne_100_mbit_msg, apne_100_mbit, bool, 0444);
+MODULE_PARM_DESC(apne_100_mbit_msg, "Enable 100 Mbit support");
+#endif
+
 struct net_device * __init apne_probe(int unit)
 {
 	struct net_device *dev;

drivers/net/ethernet/8390/apne.c struct net_device * __init apne_probe(int unit) · line 152

Quoted 8 lines
drivers/net/ethernet/8390/apne.c +5 -0
@@ -139,6 +145,11 @@ struct net_device * __init apne_probe(int unit)
 	if ( !(AMIGAHW_PRESENT(PCMCIA)) )
 		return ERR_PTR(-ENODEV);
 
+#ifdef CONFIG_APNE100MBIT
+	if (apne_100_mbit)
+		isa_type = ISA_TYPE_AG16;
+#endif
+

I think isa_type has to be assigned unconditionally otherwise it can't be reset for 10 mbit cards. Therefore, the AMIGAHW_PRESENT(PCMCIA) logic in arch/m68k/kernel/setup_mm.c probably should move here.

Quoted 7 lines
drivers/net/ethernet/8390/apne.c +0 -0
 	pr_info("Looking for PCMCIA ethernet card : ");
 
 	/* check if a card is inserted */
@@ -590,6 +601,16 @@ static int init_pcmcia(void)
 #endif
 	u_long offset;
 

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 613

Quoted 10 lines
drivers/net/ethernet/8390/apne.c +10 -0
+#ifdef CONFIG_APNE100MBIT
+	/* reset card (idea taken from CardReset by Artur Pogoda) */
+	{
+		u_char  tmp = gayle.intreq;
+
+		gayle.intreq = 0xff;    mdelay(1);
+		gayle.intreq = tmp;     mdelay(300);
+	}
+#endif
+

The indentation/alignment here doesn't conform to the kernel coding style.

#2 lore raw

Re: [PATCH v3 1/2] m68k: io_mm.h - add APNE 100 MBit support

In reply to Michael Schmitz
Quoted 105 lines · Michael Schmitz

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 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()

fixup - review comment Andreas Schwab (fallthrough)

---
 arch/m68k/include/asm/io_mm.h | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
arch/m68k/include/asm/io_mm.h +20 -1
index 9c521b0..3ab2f1d 100644
@@ -101,6 +101,11 @@
 #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_APNE100MBIT)
+#define MULTI_ISA 1
+#endif
 
 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
 #define ISA_TYPE ISA_TYPE_Q40
@@ -136,6 +141,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -155,6 +163,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -171,6 +182,9 @@ static inline u32 __iomem *isa_itl(unsigned long addr)
   switch(ISA_TYPE)
     {
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
 #endif
     }
@@ -184,6 +198,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u8 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -203,6 +220,9 @@ 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
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16:
+#endif
     case ISA_TYPE_AG: return (u16 __iomem *)addr;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA
@@ -216,13 +236,14 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
 }
 
 
-#define isa_inb(port)      in_8(isa_itb(port))
 #define isa_inw(port)      (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 249

Quoted 10 lines
arch/m68k/include/asm/io_mm.h +2 -0
 #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))
 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
 
+#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_readb(p)       in_8(isa_mtb((unsigned long)(p)))
 #define isa_readw(p)       \
 	(ISA_SEX ? in_be16(isa_mtw((unsigned long)(p)))	\

Was the re-ordering of definitions deliberate?

arch/m68k/include/asm/io_mm.h static inline void isa_delay(void) · line 299

Quoted 11 lines
arch/m68k/include/asm/io_mm.h +3 -0
@@ -270,6 +291,9 @@ static inline void isa_delay(void)
     case ISA_TYPE_Q40: isa_outb(0,0x80); break;
 #endif
 #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: break;
+#endif
     case ISA_TYPE_AG: break;
 #endif
 #ifdef CONFIG_ATARI_ROM_ISA

I think most of these "#ifdef CONFIG_APNE100MBIT" conditionals are redundant. case ISA_TYPE_AG16 should be optimized away as dead code in the MULTI_ISA == 0 configuration. And in the MULTI_ISA == 1 configuration, the logic used to assign isa_type already depends on defined(CONFIG_APNE100MBIT).

#6 lore raw

Re: [PATCH net-next v3 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Finn Thain

Hi Finn,

thanks for your review!

Quoted 84 lines · Finn Thain
Quoted 82 lines · Michael Schmitz

Add Kconfig option, 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. Additional code to reset the PCMCIA hardware is also added to the driver probe.

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 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 | 12 ++++++++++++
  drivers/net/ethernet/8390/apne.c  | 21 +++++++++++++++++++++
  2 files changed, 33 insertions(+)
drivers/net/ethernet/8390/Kconfig +12 -0
index 9f4b302..6e4db63 100644
@@ -143,6 +143,18 @@ config APNE
  	  To compile this driver as a module, choose M here: the module
  	  will be called apne.
 
+config APNE100MBIT
+	bool "PCMCIA NE2000 100MBit support"
+	depends on APNE
+	default n
+	help
+	  This changes the driver to support 10/100Mbit cards (e.g. Netgear
+	  FA411, CNet Singlepoint). 10 MBit cards and 100 MBit cards are
+	  supported by the same driver.
+
+	  To activate 100 Mbit support at runtime or from the kernel
+	  command line, use the apne.100mbit module parameter.
+
  config PCMCIA_PCNET
  	tristate "NE2000 compatible PCMCIA support"
  	depends on PCMCIA
drivers/net/ethernet/8390/apne.c +6 -0
index fe6c834..59e41ad 100644
@@ -120,6 +120,12 @@ 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)");
 
+#ifdef CONFIG_APNE100MBIT
+static bool apne_100_mbit;
+module_param_named(apne_100_mbit_msg, apne_100_mbit, bool, 0444);
+MODULE_PARM_DESC(apne_100_mbit_msg, "Enable 100 Mbit support");
+#endif
+
  struct net_device * __init apne_probe(int unit)
  {
  	struct net_device *dev;
@@ -139,6 +145,11 @@ struct net_device * __init apne_probe(int unit)
  	if ( !(AMIGAHW_PRESENT(PCMCIA)) )
  		return ERR_PTR(-ENODEV);
 
Quoted 8 lines

drivers/net/ethernet/8390/apne.c struct net_device * __init apne_probe(int unit) · line 152

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +5 -0
+#ifdef CONFIG_APNE100MBIT
+	if (apne_100_mbit)
+		isa_type = ISA_TYPE_AG16;
+#endif
+

I think isa_type has to be assigned unconditionally otherwise it can't be reset for 10 mbit cards. Therefore, the AMIGAHW_PRESENT(PCMCIA) logic in arch/m68k/kernel/setup_mm.c probably should move here.

Good catch! I am uncertain though as to whether replacing a 100 Mbit card by a 10 Mbit one at run time is a common use case (or even possible, given constraints of the Amiga PCMCIA interface?), but it ought to work even if rarely used.

The comment there says isa_type must be set as early as possible, so I'd rather leave that alone, and add an 'else' clause here.

This of course raise the question whether we ought to move the entire isa_type handling into arch code instead - make it a generic amiga_pcmcia_16bit option settable via sysfs. There may be other 16 bit cards that require the same treatment, and duplicating PCMCIA mode switching all over the place could be avoided. Opinions?

Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/8390/apne.c +0 -0
  	pr_info("Looking for PCMCIA ethernet card : ");
 
  	/* check if a card is inserted */
@@ -590,6 +601,16 @@ static int init_pcmcia(void)
  #endif
  	u_long offset;
 
Quoted 11 lines

drivers/net/ethernet/8390/apne.c static int init_pcmcia(void) · line 613

Quoted 10 lines
drivers/net/ethernet/8390/apne.c +10 -0
+#ifdef CONFIG_APNE100MBIT
+	/* reset card (idea taken from CardReset by Artur Pogoda) */
+	{
+		u_char  tmp = gayle.intreq;
+
+		gayle.intreq = 0xff;    mdelay(1);
+		gayle.intreq = tmp;     mdelay(300);
+	}
+#endif
+

The indentation/alignment here doesn't conform to the kernel coding style.

Good one. Checkpatch missed that for some reason...

I'll respin ...

Cheers,

    Michael

#3 lore raw

Re: [PATCH v3 1/2] m68k: io_mm.h - add APNE 100 MBit support

In reply to Finn Thain

Hi Finn,

thanks for your comments!

Quoted 7 lines · Finn Thain
Quoted 7 lines

-#define isa_inb(port) 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))
#define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val))) #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))

Quoted 6 lines

arch/m68k/include/asm/io_mm.h static inline u16 __iomem *isa_mtw(unsigned long addr) · line 249

Quoted 5 lines
arch/m68k/include/asm/io_mm.h +2 -0
+#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_readb(p)       in_8(isa_mtb((unsigned long)(p)))
  #define isa_readw(p)       \
  	(ISA_SEX ? in_be16(isa_mtw((unsigned long)(p)))	\

Was the re-ordering of definitions deliberate?

Yes, it was. I remembered looking at a bug report for curl on the m68k kernel that was due to ordering of #defines.

On second thought, there is no prior definition of isa_inw in our case, so even this won't really be an issue.

Quoted 18 lines

arch/m68k/include/asm/io_mm.h static inline void isa_delay(void) · line 299

Quoted 13 lines
arch/m68k/include/asm/io_mm.h +3 -0
@@ -270,6 +291,9 @@ static inline void isa_delay(void)
      case ISA_TYPE_Q40: isa_outb(0,0x80); break;
  #endif
  #ifdef CONFIG_AMIGA_PCMCIA
+#ifdef CONFIG_APNE100MBIT
+    case ISA_TYPE_AG16: break;
+#endif
      case ISA_TYPE_AG: break;
  #endif
  #ifdef CONFIG_ATARI_ROM_ISA

I think most of these "#ifdef CONFIG_APNE100MBIT" conditionals are redundant. case ISA_TYPE_AG16 should be optimized away as dead code in the MULTI_ISA == 0 configuration. And in the MULTI_ISA == 1 configuration, the logic used to assign isa_type already depends on defined(CONFIG_APNE100MBIT).

You're right there, too. I'll drop those.

Cheers,

    Michael

#7 lore raw

Re: [PATCH net-next v3 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

In reply to Michael Schmitz

Hi Michael,

Quoted 45 lines · Michael Schmitz
Quoted 35 lines · Finn Thain
Quoted 34 lines · Michael Schmitz

Add Kconfig option, 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. Additional code to reset the PCMCIA hardware is also added to the driver probe.

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]>.

drivers/net/ethernet/8390/apne.c +6 -0
@@ -120,6 +120,12 @@ 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)");
 
+#ifdef CONFIG_APNE100MBIT
+static bool apne_100_mbit;
+module_param_named(apne_100_mbit_msg, apne_100_mbit, bool, 0444);
+MODULE_PARM_DESC(apne_100_mbit_msg, "Enable 100 Mbit support");
+#endif
+
  struct net_device * __init apne_probe(int unit)
  {
     struct net_device *dev;
@@ -139,6 +145,11 @@ struct net_device * __init apne_probe(int unit)
     if ( !(AMIGAHW_PRESENT(PCMCIA)) )
             return ERR_PTR(-ENODEV);
 
Quoted 8 lines

drivers/net/ethernet/8390/apne.c struct net_device * __init apne_probe(int unit) · line 152

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +5 -0
+#ifdef CONFIG_APNE100MBIT
+    if (apne_100_mbit)
+            isa_type = ISA_TYPE_AG16;
+#endif
+

I think isa_type has to be assigned unconditionally otherwise it can't be reset for 10 mbit cards. Therefore, the AMIGAHW_PRESENT(PCMCIA) logic in arch/m68k/kernel/setup_mm.c probably should move here.

Quoted 4 lines

Good catch! I am uncertain though as to whether replacing a 100 Mbit card by a 10 Mbit one at run time is a common use case (or even possible, given constraints of the Amiga PCMCIA interface?), but it ought to work even if rarely used.

Given it's PCMCIA, I guess that's a possibility. Furthermore, always setting isa_type means the user can recover from a mistake by unloading the module, and modprobe'ing again with the correct parameter.
For the builtin-case, that needs a s/0444/0644/ change, though.

Quoted 8 lines

The comment there says isa_type must be set as early as possible, so I'd rather leave that alone, and add an 'else' clause here.

This of course raise the question whether we ought to move the entire isa_type handling into arch code instead - make it a generic amiga_pcmcia_16bit option settable via sysfs. There may be other 16 bit cards that require the same treatment, and duplicating PCMCIA mode switching all over the place could be avoided. Opinions?

Indeed.

Still, can we autodetect in the driver?

I'm wondering how this is handled on PCs with PCMCIA, or if there really is something special about Amiga PCMCIA hardware...

And I'd really like to get rid of the CONFIG_APNE100MBIT option, i.e. always include the support, if possible.

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

#8 lore raw

Re: [PATCH net-next v3 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Geert,

Am 18.06.2021 um 19:16 schrieb Geert Uytterhoeven:

Quoted 14 lines
Quoted 9 lines
Quoted 8 lines

drivers/net/ethernet/8390/apne.c struct net_device * __init apne_probe(int unit) · line 152

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +5 -0
+#ifdef CONFIG_APNE100MBIT
+    if (apne_100_mbit)
+            isa_type = ISA_TYPE_AG16;
+#endif
+

I think isa_type has to be assigned unconditionally otherwise it can't be reset for 10 mbit cards. Therefore, the AMIGAHW_PRESENT(PCMCIA) logic in arch/m68k/kernel/setup_mm.c probably should move here.

Quoted 4 lines

Good catch! I am uncertain though as to whether replacing a 100 Mbit card by a 10 Mbit one at run time is a common use case (or even possible, given constraints of the Amiga PCMCIA interface?), but it ought to work even if rarely used.

Quoted 5 lines

Given it's PCMCIA, I guess that's a possibility. Furthermore, always setting isa_type means the user can recover from a mistake by unloading the module, and modprobe'ing again with the correct parameter.
For the builtin-case, that needs a s/0444/0644/ change, though.

How does re-probing after a card change for a builtin driver work? Changing the permission bits is a minor issue.

Quoted 11 lines
Quoted 9 lines

The comment there says isa_type must be set as early as possible, so I'd rather leave that alone, and add an 'else' clause here.

This of course raise the question whether we ought to move the entire isa_type handling into arch code instead - make it a generic amiga_pcmcia_16bit option settable via sysfs. There may be other 16 bit cards that require the same treatment, and duplicating PCMCIA mode switching all over the place could be avoided. Opinions?

Indeed.

The only downside I can see is that setting isa_type needs to be done ahead of modprobe, through sysfs. That might be a little error prone.

Quoted 1 line

Still, can we autodetect in the driver?

Guess we'll have to find out how the 16 bit cards behave if first poked in 8 bit mode, attempting to force a reset of the 8390 chip, and switching to 16 bit mode if this fails. That's normally done in apne_probe1() which runs after init_pcmcia(), so we can't rely on the result of a 8390 reset autoprobe to do the PCMCIA software reset there.

The 8390 reset part does not rely on anything else in apne_probe1(), so that code can be lifted out of apne_probe1() and run early in apne_probe() (after the check for an inserted PCMCIA card). I'll try and prepare a patch for Alex to test that method.

Quoted 3 lines

I'm wondering how this is handled on PCs with PCMCIA, or if there really is something special about Amiga PCMCIA hardware...

What's special about Amiga PCMCIA hardware is that the card reset isn't connected for those 16 bit cards, so pcmcia_reset() does not work.

Whether the software reset workaround hurts for 8 bit cards is something I don't know and cannot test. But

Quoted 2 lines

And I'd really like to get rid of the CONFIG_APNE100MBIT option, i.e. always include the support, if possible.

I can't see why that wouldn't be possible - the only downside is that we force MULTI_ISA=1 always for Amiga, and lose the optimizations done for MUTLI_ISA=0 in io_mm.h. Unless we autoprobe, we can use isa_type to guard against running a software reset on 8 bit cards ...

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

#9 lore raw

Re: [PATCH net-next v3 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Michael,

Quoted 15 lines · Michael Schmitz

Am 18.06.2021 um 19:16 schrieb Geert Uytterhoeven:

Quoted 14 lines
Quoted 13 lines
Quoted 8 lines

drivers/net/ethernet/8390/apne.c struct net_device * __init apne_probe(int unit) · line 152

Quoted 5 lines
drivers/net/ethernet/8390/apne.c +5 -0
+#ifdef CONFIG_APNE100MBIT
+    if (apne_100_mbit)
+            isa_type = ISA_TYPE_AG16;
+#endif
+

I think isa_type has to be assigned unconditionally otherwise it can't be reset for 10 mbit cards. Therefore, the AMIGAHW_PRESENT(PCMCIA) logic in arch/m68k/kernel/setup_mm.c probably should move here.

Good catch! I am uncertain though as to whether replacing a 100 Mbit card by a 10 Mbit one at run time is a common use case (or even possible, given constraints of the Amiga PCMCIA interface?), but it ought to work even if rarely used.

Quoted 8 lines
Quoted 5 lines

Given it's PCMCIA, I guess that's a possibility. Furthermore, always setting isa_type means the user can recover from a mistake by unloading the module, and modprobe'ing again with the correct parameter.
For the builtin-case, that needs a s/0444/0644/ change, though.

How does re-probing after a card change for a builtin driver work? Changing the permission bits is a minor issue.

Oh right, this driver predates the driver framework, and doesn't support PCMCIA hotplug. So auto-unregister on removal doesn't work. Even using unbind/bind in sysfs won't work.

So rmmod/modprobe is the only thing that has a chance to work...

Quoted 27 lines
Quoted 10 lines
Quoted 8 lines

The comment there says isa_type must be set as early as possible, so I'd rather leave that alone, and add an 'else' clause here.

This of course raise the question whether we ought to move the entire isa_type handling into arch code instead - make it a generic amiga_pcmcia_16bit option settable via sysfs. There may be other 16 bit cards that require the same treatment, and duplicating PCMCIA mode switching all over the place could be avoided. Opinions?

Indeed.

The only downside I can see is that setting isa_type needs to be done ahead of modprobe, through sysfs. That might be a little error prone.

Quoted 1 line

Still, can we autodetect in the driver?

Guess we'll have to find out how the 16 bit cards behave if first poked in 8 bit mode, attempting to force a reset of the 8390 chip, and switching to 16 bit mode if this fails. That's normally done in apne_probe1() which runs after init_pcmcia(), so we can't rely on the result of a 8390 reset autoprobe to do the PCMCIA software reset there.

The 8390 reset part does not rely on anything else in apne_probe1(), so that code can be lifted out of apne_probe1() and run early in apne_probe() (after the check for an inserted PCMCIA card). I'll try and prepare a patch for Alex to test that method.

Quoted 5 lines
Quoted 2 lines

I'm wondering how this is handled on PCs with PCMCIA, or if there really is something special about Amiga PCMCIA hardware...

What's special about Amiga PCMCIA hardware is that the card reset isn't connected for those 16 bit cards, so pcmcia_reset() does not work.

I was mostly thinking about the difference between 8-bit and 16-bit accesses.

Quoted 10 lines

Whether the software reset workaround hurts for 8 bit cards is something I don't know and cannot test. But

Quoted 2 lines

And I'd really like to get rid of the CONFIG_APNE100MBIT option, i.e. always include the support, if possible.

I can't see why that wouldn't be possible - the only downside is that we force MULTI_ISA=1 always for Amiga, and lose the optimizations done for MUTLI_ISA=0 in io_mm.h. Unless we autoprobe, we can use isa_type to guard against running a software reset on 8 bit cards ...

The latter sounds like a neat trick...

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
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
#10 lore raw

Re: [PATCH net-next v3 2/2] net/8390: apne.c - add 100 Mbit support to apne.c driver

Hi Geert,

Am 18.06.2021 um 20:13 schrieb Geert Uytterhoeven:

Quoted 36 lines
Quoted 3 lines

How does re-probing after a card change for a builtin driver work? Changing the permission bits is a minor issue.

Oh right, this driver predates the driver framework, and doesn't support PCMCIA hotplug. So auto-unregister on removal doesn't work. Even using unbind/bind in sysfs won't work.

So rmmod/modprobe is the only thing that has a chance to work...

Quoted 26 lines
Quoted 10 lines
Quoted 8 lines

The comment there says isa_type must be set as early as possible, so I'd rather leave that alone, and add an 'else' clause here.

This of course raise the question whether we ought to move the entire isa_type handling into arch code instead - make it a generic amiga_pcmcia_16bit option settable via sysfs. There may be other 16 bit cards that require the same treatment, and duplicating PCMCIA mode switching all over the place could be avoided. Opinions?

Indeed.

The only downside I can see is that setting isa_type needs to be done ahead of modprobe, through sysfs. That might be a little error prone.

Quoted 1 line

Still, can we autodetect in the driver?

Guess we'll have to find out how the 16 bit cards behave if first poked in 8 bit mode, attempting to force a reset of the 8390 chip, and switching to 16 bit mode if this fails. That's normally done in apne_probe1() which runs after init_pcmcia(), so we can't rely on the result of a 8390 reset autoprobe to do the PCMCIA software reset there.

The 8390 reset part does not rely on anything else in apne_probe1(), so that code can be lifted out of apne_probe1() and run early in apne_probe() (after the check for an inserted PCMCIA card). I'll try and prepare a patch for Alex to test that method.

I just realized that might not work - ínit_pcmcia() enables the PCMCIA interface for us, so the early 8390 reset may not go through at all... The module parameter may have to stay as a fallback option at least.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

I'm wondering how this is handled on PCs with PCMCIA, or if there really is something special about Amiga PCMCIA hardware...

What's special about Amiga PCMCIA hardware is that the card reset isn't connected for those 16 bit cards, so pcmcia_reset() does not work.

I was mostly thinking about the difference between 8-bit and 16-bit accesses.

No idea. I've never even seen an 8 bit PCMCIA card - I have a few old 16/32 bit ones around that were great for crashing my PowerBook, nothing else...

Quoted 9 lines
Quoted 7 lines
Quoted 2 lines

And I'd really like to get rid of the CONFIG_APNE100MBIT option, i.e. always include the support, if possible.

I can't see why that wouldn't be possible - the only downside is that we force MULTI_ISA=1 always for Amiga, and lose the optimizations done for MUTLI_ISA=0 in io_mm.h. Unless we autoprobe, we can use isa_type to guard against running a software reset on 8 bit cards ...

The latter sounds like a neat trick...

Yes, we can at least get rid of the APNE100MBIT option that way. I'll have to think about the autoprobe a bit more.

Cheers,

Michael

Quoted 4 lines

Gr{oetje,eeting}s,

Geert