Re: [PATCH v2 8/8] net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)

2018-04-17 Thread Michael Schmitz
Hi Andrew,

On Wed, Apr 18, 2018 at 1:26 AM, Andrew Lunn  wrote:
> On Tue, Apr 17, 2018 at 02:08:15PM +1200, Michael Schmitz wrote:
>> Add platform device driver to populate the ax88796 platform data from
>> information provided by the XSurf100 zorro device driver.
>> This driver will have to be loaded before loading the ax88796 module,
>> or compiled as built-in.
>>
>> Signed-off-by: Michael Karcher 
>> Signed-off-by: Michael Schmitz 
>> ---
>>  drivers/net/ethernet/8390/Kconfig|   14 +-
>>  drivers/net/ethernet/8390/Makefile   |1 +
>>  drivers/net/ethernet/8390/xsurf100.c |  411 
>> ++
>>  3 files changed, 425 insertions(+), 1 deletions(-)
>>  create mode 100644 drivers/net/ethernet/8390/xsurf100.c
>>
>> diff --git a/drivers/net/ethernet/8390/Kconfig 
>> b/drivers/net/ethernet/8390/Kconfig
>> index fdc6734..0cadd45 100644
>> --- a/drivers/net/ethernet/8390/Kconfig
>> +++ b/drivers/net/ethernet/8390/Kconfig
>> @@ -30,7 +30,7 @@ config PCMCIA_AXNET
>>
>>  config AX88796
>>   tristate "ASIX AX88796 NE2000 clone support"
>> - depends on (ARM || MIPS || SUPERH)
>> + depends on (ARM || MIPS || SUPERH || AMIGA)
>
> Hi Michael
>
> Will it compile on other platforms? If so, it is a good idea to add
> COMPILE_TEST as well.

I suppose it will - nothing in there that wouldn't be portable. Well,
let's find out, shall we?

Cheers,

  Michael

>
>  Andrew


Re: [PATCH v2 8/8] net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)

2018-04-17 Thread Andrew Lunn
On Tue, Apr 17, 2018 at 02:08:15PM +1200, Michael Schmitz wrote:
> Add platform device driver to populate the ax88796 platform data from
> information provided by the XSurf100 zorro device driver.
> This driver will have to be loaded before loading the ax88796 module,
> or compiled as built-in.
> 
> Signed-off-by: Michael Karcher 
> Signed-off-by: Michael Schmitz 
> ---
>  drivers/net/ethernet/8390/Kconfig|   14 +-
>  drivers/net/ethernet/8390/Makefile   |1 +
>  drivers/net/ethernet/8390/xsurf100.c |  411 
> ++
>  3 files changed, 425 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/net/ethernet/8390/xsurf100.c
> 
> diff --git a/drivers/net/ethernet/8390/Kconfig 
> b/drivers/net/ethernet/8390/Kconfig
> index fdc6734..0cadd45 100644
> --- a/drivers/net/ethernet/8390/Kconfig
> +++ b/drivers/net/ethernet/8390/Kconfig
> @@ -30,7 +30,7 @@ config PCMCIA_AXNET
>  
>  config AX88796
>   tristate "ASIX AX88796 NE2000 clone support"
> - depends on (ARM || MIPS || SUPERH)
> + depends on (ARM || MIPS || SUPERH || AMIGA)

Hi Michael

Will it compile on other platforms? If so, it is a good idea to add
COMPILE_TEST as well.

 Andrew


[PATCH v2 8/8] net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)

2018-04-16 Thread Michael Schmitz
Add platform device driver to populate the ax88796 platform data from
information provided by the XSurf100 zorro device driver.
This driver will have to be loaded before loading the ax88796 module,
or compiled as built-in.

Signed-off-by: Michael Karcher 
Signed-off-by: Michael Schmitz 
---
 drivers/net/ethernet/8390/Kconfig|   14 +-
 drivers/net/ethernet/8390/Makefile   |1 +
 drivers/net/ethernet/8390/xsurf100.c |  411 ++
 3 files changed, 425 insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/ethernet/8390/xsurf100.c

diff --git a/drivers/net/ethernet/8390/Kconfig 
b/drivers/net/ethernet/8390/Kconfig
index fdc6734..0cadd45 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -30,7 +30,7 @@ config PCMCIA_AXNET
 
 config AX88796
tristate "ASIX AX88796 NE2000 clone support"
-   depends on (ARM || MIPS || SUPERH)
+   depends on (ARM || MIPS || SUPERH || AMIGA)
select CRC32
select PHYLIB
select MDIO_BITBANG
@@ -45,6 +45,18 @@ config AX88796_93CX6
---help---
  Select this if your platform comes with an external 93CX6 eeprom.
 
+config XSURF100
+   tristate "Amiga XSurf 100 AX88796/NE2000 clone support"
+   depends on ZORRO
+   depends on AX88796
+   ---help---
+ This driver is for the Individual Computers X-Surf 100 Ethernet
+ card (based on the Asix AX88796 chip). If you have such a card,
+ say Y. Otherwise, say N.
+
+ To compile this driver as a module, choose M here: the module
+ will be called xsurf100.
+
 config HYDRA
tristate "Hydra support"
depends on ZORRO
diff --git a/drivers/net/ethernet/8390/Makefile 
b/drivers/net/ethernet/8390/Makefile
index f975c2f..3715f8d 100644
--- a/drivers/net/ethernet/8390/Makefile
+++ b/drivers/net/ethernet/8390/Makefile
@@ -16,4 +16,5 @@ obj-$(CONFIG_PCMCIA_PCNET) += pcnet_cs.o 8390.o
 obj-$(CONFIG_STNIC) += stnic.o 8390.o
 obj-$(CONFIG_ULTRA) += smc-ultra.o 8390.o
 obj-$(CONFIG_WD80x3) += wd.o 8390.o
+obj-$(CONFIG_XSURF100) += xsurf100.o
 obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o
diff --git a/drivers/net/ethernet/8390/xsurf100.c 
b/drivers/net/ethernet/8390/xsurf100.c
new file mode 100644
index 000..3caece0
--- /dev/null
+++ b/drivers/net/ethernet/8390/xsurf100.c
@@ -0,0 +1,411 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100 \
+   ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x64, 0)
+
+#define XS100_IRQSTATUS_BASE 0x40
+#define XS100_8390_BASE 0x800
+
+/* Longword-access area. Translated to 2 16-bit access cycles by the
+ * X-Surf 100 FPGA
+ */
+#define XS100_8390_DATA32_BASE 0x8000
+#define XS100_8390_DATA32_SIZE 0x2000
+/* Sub-Areas for fast data register access; addresses relative to area begin */
+#define XS100_8390_DATA_READ32_BASE 0x0880
+#define XS100_8390_DATA_WRITE32_BASE 0x0C80
+#define XS100_8390_DATA_AREA_SIZE 0x80
+
+#define __NS8390_init ax_NS8390_init
+
+/* force unsigned long back to 'void __iomem *' */
+#define ax_convert_addr(_a) ((void __force __iomem *)(_a))
+
+#define ei_inb(_a) z_readb(ax_convert_addr(_a))
+#define ei_outb(_v, _a) z_writeb(_v, ax_convert_addr(_a))
+
+#define ei_inw(_a) z_readw(ax_convert_addr(_a))
+#define ei_outw(_v, _a) z_writew(_v, ax_convert_addr(_a))
+
+#define ei_inb_p(_a) ei_inb(_a)
+#define ei_outb_p(_v, _a) ei_outb(_v, _a)
+
+/* define EI_SHIFT() to take into account our register offsets */
+#define EI_SHIFT(x) (ei_local->reg_offset[(x)])
+
+/* Ensure we have our RCR base value */
+#define AX88796_PLATFORM
+
+static unsigned char version[] =
+   "ax88796.c: Copyright 2005,2007 Simtec Electronics\n";
+
+#include "lib8390.c"
+
+/* from ne.c */
+#define NE_CMD EI_SHIFT(0x00)
+#define NE_RESET   EI_SHIFT(0x1f)
+#define NE_DATAPORTEI_SHIFT(0x10)
+
+/* Hard reset the card. This used to pause for the same period that a
+ * 8390 reset command required, but that shouldn't be necessary.
+ */
+static void ax_reset_8390(struct net_device *dev)
+{
+   struct ei_device *ei_local = netdev_priv(dev);
+   unsigned long reset_start_time = jiffies;
+   void __iomem *addr = (void __iomem *)dev->base_addr;
+
+   netif_dbg(ei_local, hw, dev, "resetting the 8390 t=%ld...\n", jiffies);
+
+   ei_outb(ei_inb(addr + NE_RESET), addr + NE_RESET);
+
+   ei_local->txing = 0;
+   ei_local->dmaing = 0;
+
+   /* This check _should_not_ be necessary, omit eventually. */
+   while ((ei_inb(addr + EN0_ISR) & ENISR_RESET) == 0) {
+   if (time_after(jiffies, reset_start_time + 2 * HZ / 100)) {
+   netdev_warn(dev, "%s: did not complete.\n", __func__);
+   break;
+   }
+   }
+
+   ei_outb(ENISR_RESET, addr + EN0_ISR);   /* Ack intr. */
+}
+
+struct xsurf100_ax_plat_data {
+