All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support
@ 2021-06-19 23:24 Michael Schmitz
  2021-06-19 23:24 ` [PATCH v6 1/3] m68k: io_mm.h - add APNE 100 MBit support Michael Schmitz
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Michael Schmitz @ 2021-06-19 23:24 UTC (permalink / raw)
  To: linux-m68k, geert; +Cc: alex

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v6 1/3] m68k: io_mm.h - add APNE 100 MBit support
  2021-06-19 23:24 [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support Michael Schmitz
@ 2021-06-19 23:24 ` Michael Schmitz
  2021-06-19 23:24 ` [PATCH netdev v6 2/3] net/8390: apne.c - add 100 Mbit support to apne.c driver Michael Schmitz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Schmitz @ 2021-06-19 23:24 UTC (permalink / raw)
  To: linux-m68k, geert; +Cc: alex, 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 <alex@kazik.de>.

Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>

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

diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h
index 9c521b0..68922ef 100644
--- a/arch/m68k/include/asm/io_mm.h
+++ b/arch/m68k/include/asm/io_mm.h
@@ -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
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH netdev v6 2/3] net/8390: apne.c - add 100 Mbit support to apne.c driver
  2021-06-19 23:24 [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support Michael Schmitz
  2021-06-19 23:24 ` [PATCH v6 1/3] m68k: io_mm.h - add APNE 100 MBit support Michael Schmitz
@ 2021-06-19 23:24 ` Michael Schmitz
  2021-06-19 23:24 ` [PATCH netdev v6 3/3] net/8390: apne.c - autoprobe 100 Mbit mode in " Michael Schmitz
  2021-06-20  8:30 ` [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support ALeX Kazik
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Schmitz @ 2021-06-19 23:24 UTC (permalink / raw)
  To: linux-m68k, geert; +Cc: alex, Michael Schmitz, netdev

Add 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 <alex@kazik.de>.

CC: netdev@vger.kernel.org
Link: https://lore.kernel.org/r/1622958877-2026-1-git-send-email-schmitzmic@gmail.com
Tested-by: Alex Kazik <alex@kazik.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>

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

diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index 9f4b302..4c3f7b6 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -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
diff --git a/drivers/net/ethernet/8390/apne.c b/drivers/net/ethernet/8390/apne.c
index fe6c834..4dd721e 100644
--- a/drivers/net/ethernet/8390/apne.c
+++ b/drivers/net/ethernet/8390/apne.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH netdev v6 3/3] net/8390: apne.c - autoprobe 100 Mbit mode in apne.c driver
  2021-06-19 23:24 [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support Michael Schmitz
  2021-06-19 23:24 ` [PATCH v6 1/3] m68k: io_mm.h - add APNE 100 MBit support Michael Schmitz
  2021-06-19 23:24 ` [PATCH netdev v6 2/3] net/8390: apne.c - add 100 Mbit support to apne.c driver Michael Schmitz
@ 2021-06-19 23:24 ` Michael Schmitz
  2021-06-20  8:30 ` [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support ALeX Kazik
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Schmitz @ 2021-06-19 23:24 UTC (permalink / raw)
  To: linux-m68k, geert; +Cc: alex, Michael Schmitz, netdev

Add 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!

CC: netdev@vger.kernel.org
Link: https://lore.kernel.org/r/1622958877-2026-1-git-send-email-schmitzmic@gmail.com
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/apne.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/8390/apne.c b/drivers/net/ethernet/8390/apne.c
index 4dd721e..ec165f8 100644
--- a/drivers/net/ethernet/8390/apne.c
+++ b/drivers/net/ethernet/8390/apne.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support
  2021-06-19 23:24 [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support Michael Schmitz
                   ` (2 preceding siblings ...)
  2021-06-19 23:24 ` [PATCH netdev v6 3/3] net/8390: apne.c - autoprobe 100 Mbit mode in " Michael Schmitz
@ 2021-06-20  8:30 ` ALeX Kazik
  2021-06-20 19:27   ` Michael Schmitz
  3 siblings, 1 reply; 8+ messages in thread
From: ALeX Kazik @ 2021-06-20  8:30 UTC (permalink / raw)
  To: Michael Schmitz; +Cc: Linux/m68k, Geert Uytterhoeven

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support
  2021-06-20  8:30 ` [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support ALeX Kazik
@ 2021-06-20 19:27   ` Michael Schmitz
  2021-06-20 21:55     ` ALeX Kazik
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Schmitz @ 2021-06-20 19:27 UTC (permalink / raw)
  To: ALeX Kazik; +Cc: Linux/m68k, Geert Uytterhoeven

Hi Alex,

thanks for testing again - so autoprobe (no boot option) did_not_ work?

Cheers,

     Michael

On 20/06/21 8:30 pm, ALeX Kazik wrote:
> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support
  2021-06-20 19:27   ` Michael Schmitz
@ 2021-06-20 21:55     ` ALeX Kazik
  2021-06-20 23:47       ` Michael Schmitz
  0 siblings, 1 reply; 8+ messages in thread
From: ALeX Kazik @ 2021-06-20 21:55 UTC (permalink / raw)
  To: Michael Schmitz; +Cc: Linux/m68k, Geert Uytterhoeven

Hi Michael,

> thanks for testing again

I'm happy to help.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support
  2021-06-20 21:55     ` ALeX Kazik
@ 2021-06-20 23:47       ` Michael Schmitz
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Schmitz @ 2021-06-20 23:47 UTC (permalink / raw)
  To: ALeX Kazik; +Cc: Linux/m68k, Geert Uytterhoeven

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


On 21/06/21 9:55 am, ALeX Kazik wrote:

> Hi Michael,
>
>> thanks for testing again
> I'm happy to help.
>
>> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-20 23:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19 23:24 [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support Michael Schmitz
2021-06-19 23:24 ` [PATCH v6 1/3] m68k: io_mm.h - add APNE 100 MBit support Michael Schmitz
2021-06-19 23:24 ` [PATCH netdev v6 2/3] net/8390: apne.c - add 100 Mbit support to apne.c driver Michael Schmitz
2021-06-19 23:24 ` [PATCH netdev v6 3/3] net/8390: apne.c - autoprobe 100 Mbit mode in " Michael Schmitz
2021-06-20  8:30 ` [PATCH v6 0/3] Add APNE PCMCIA 100 Mbit support ALeX Kazik
2021-06-20 19:27   ` Michael Schmitz
2021-06-20 21:55     ` ALeX Kazik
2021-06-20 23:47       ` Michael Schmitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.