public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net
@ 2015-11-16 23:33 Michael Schmitz
  2015-11-16 23:33 ` [PATCH 1/8] aX88796: Fix MAC address reading Michael Schmitz
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel

Geert,

just as a heads-up, I've been working on getting this series ready for
submission to -net. The first six patches will need to be taken through
-net, the last two are m68k specific and might be equally well placed in
arch/m68k/amiga for preference.

Patch 6 and 8 are optional - the interrupts are handled just fine inside
ei_interrupt if generated by other users of IRQ_AMIGA_PORTS.

If you know of some other hardware currently using IRQ_AMIGA_PORTS that
cannot handle shared interupts, give me a shout and I'll look into handling
this through a new interrupt controller for IRQ_AMIGA_PORTS.

There's a typo in #7 that gets fixed in #8, will be cleaned up before
submission.

Any other badness, just let me know what you'd like to see handled differently.

Cheers,

        Michael

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

* [PATCH 1/8] aX88796: Fix MAC address reading
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-16 23:33 ` [PATCH 2/8] ax88796: Attach MII bus only when open Michael Schmitz
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, Michael Karcher, Michael Schmitz

From: Michael Karcher <debian@mkarcher.dialup.fu-berlin.de>

To read the MAC address from the (virtual) SAprom. the remote DMA
unit needs to be set up like for every other process access to card-local
memory.

Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/ax88796.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 0443654..7963e1d 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -709,10 +709,16 @@ static int ax_init_dev(struct net_device *dev)
 	if (ax->plat->flags & AXFLG_HAS_EEPROM) {
 		unsigned char SA_prom[32];
 
+		ei_outb(6, ioaddr + EN0_RCNTLO);
+		ei_outb(0, ioaddr + EN0_RCNTHI);
+		ei_outb(0, ioaddr + EN0_RSARLO);
+		ei_outb(0, ioaddr + EN0_RSARHI);
+		ei_outb(E8390_RREAD+E8390_START, ioaddr + NE_CMD);
 		for (i = 0; i < sizeof(SA_prom); i += 2) {
 			SA_prom[i] = ei_inb(ioaddr + NE_DATAPORT);
 			SA_prom[i + 1] = ei_inb(ioaddr + NE_DATAPORT);
 		}
+		ei_outb(ENISR_RDC, ioaddr + EN0_ISR);	/* Ack intr. */
 
 		if (ax->plat->wordlength == 2)
 			for (i = 0; i < 16; i++)
-- 
1.7.0.4

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

* [PATCH 2/8] ax88796: Attach MII bus only when open
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
  2015-11-16 23:33 ` [PATCH 1/8] aX88796: Fix MAC address reading Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-16 23:33 ` [PATCH 3/8] ax88796: Move mii support functions upwards to prevent need of forward declaration Michael Schmitz
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, Michael Karcher, Michael Schmitz

From: Michael Karcher <debian@mkarcher.dialup.fu-berlin.de>

This is needed to be able to unload the module, as the module is busy
while the MII bus is attached.

Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/ax88796.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 7963e1d..f76753b 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -79,6 +79,8 @@ static unsigned char version[] = "ax88796.c: Copyright 2005,2007 Simtec Electron
 
 static u32 ax_msg_enable;
 
+static int ax_mii_init(struct net_device *dev);
+
 /* device private data */
 
 struct ax_device {
@@ -399,6 +401,10 @@ static int ax_open(struct net_device *dev)
 
 	netdev_dbg(dev, "open\n");
 
+	ret = ax_mii_init(dev);
+	if (ret)
+		goto failed_request_irq;
+
 	ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
 			  dev->name, dev);
 	if (ret)
@@ -445,6 +451,10 @@ static int ax_close(struct net_device *dev)
 	phy_disconnect(ax->phy_dev);
 
 	free_irq(dev->irq, dev);
+
+	mdiobus_unregister(ax->mii_bus);
+	kfree(ax->mii_bus->irq);
+	free_mdio_bitbang(ax->mii_bus);
 	return 0;
 }
 
@@ -790,10 +800,6 @@ static int ax_init_dev(struct net_device *dev)
 	dev->netdev_ops = &ax_netdev_ops;
 	dev->ethtool_ops = &ax_ethtool_ops;
 
-	ret = ax_mii_init(dev);
-	if (ret)
-		goto out_irq;
-
 	ax_NS8390_init(dev, 0);
 
 	ret = register_netdev(dev);
-- 
1.7.0.4

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

* [PATCH 3/8] ax88796: Move mii support functions upwards to prevent need of forward declaration
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
  2015-11-16 23:33 ` [PATCH 1/8] aX88796: Fix MAC address reading Michael Schmitz
  2015-11-16 23:33 ` [PATCH 2/8] ax88796: Attach MII bus only when open Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-16 23:33 ` [PATCH 4/8] ax88796: Do not free IRQ that did not get requested Michael Schmitz
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, Michael Schmitz

From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>

This commit contains nothing but moving of code lines inside ax88796.c

Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/ax88796.c |  192 +++++++++++++++++------------------
 1 files changed, 95 insertions(+), 97 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index f76753b..544f3ba 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -79,8 +79,6 @@ static unsigned char version[] = "ax88796.c: Copyright 2005,2007 Simtec Electron
 
 static u32 ax_msg_enable;
 
-static int ax_mii_init(struct net_device *dev);
-
 /* device private data */
 
 struct ax_device {
@@ -319,6 +317,101 @@ static void ax_block_output(struct net_device *dev, int count,
 #define AX_MEMR_EEO		BIT(6)
 #define AX_MEMR_EECLK		BIT(7)
 
+static void ax_bb_mdc(struct mdiobb_ctrl *ctrl, int level)
+{
+	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+	if (level)
+		ax->reg_memr |= AX_MEMR_MDC;
+	else
+		ax->reg_memr &= ~AX_MEMR_MDC;
+
+	ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static void ax_bb_dir(struct mdiobb_ctrl *ctrl, int output)
+{
+	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+	if (output)
+		ax->reg_memr &= ~AX_MEMR_MDIR;
+	else
+		ax->reg_memr |= AX_MEMR_MDIR;
+
+	ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static void ax_bb_set_data(struct mdiobb_ctrl *ctrl, int value)
+{
+	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+	if (value)
+		ax->reg_memr |= AX_MEMR_MDO;
+	else
+		ax->reg_memr &= ~AX_MEMR_MDO;
+
+	ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static int ax_bb_get_data(struct mdiobb_ctrl *ctrl)
+{
+	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+	int reg_memr = ei_inb(ax->addr_memr);
+
+	return reg_memr & AX_MEMR_MDI ? 1 : 0;
+}
+
+static struct mdiobb_ops bb_ops = {
+	.owner = THIS_MODULE,
+	.set_mdc = ax_bb_mdc,
+	.set_mdio_dir = ax_bb_dir,
+	.set_mdio_data = ax_bb_set_data,
+	.get_mdio_data = ax_bb_get_data,
+};
+
+static int ax_mii_init(struct net_device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev->dev.parent);
+	struct ei_device *ei_local = netdev_priv(dev);
+	struct ax_device *ax = to_ax_dev(dev);
+	int err, i;
+
+	ax->bb_ctrl.ops = &bb_ops;
+	ax->addr_memr = ei_local->mem + AX_MEMR;
+	ax->mii_bus = alloc_mdio_bitbang(&ax->bb_ctrl);
+	if (!ax->mii_bus) {
+		err = -ENOMEM;
+		goto out;
+	}
+
+	ax->mii_bus->name = "ax88796_mii_bus";
+	ax->mii_bus->parent = dev->dev.parent;
+	snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+		pdev->name, pdev->id);
+
+	ax->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
+	if (!ax->mii_bus->irq) {
+		err = -ENOMEM;
+		goto out_free_mdio_bitbang;
+	}
+
+	for (i = 0; i < PHY_MAX_ADDR; i++)
+		ax->mii_bus->irq[i] = PHY_POLL;
+
+	err = mdiobus_register(ax->mii_bus);
+	if (err)
+		goto out_free_irq;
+
+	return 0;
+
+ out_free_irq:
+	kfree(ax->mii_bus->irq);
+ out_free_mdio_bitbang:
+	free_mdio_bitbang(ax->mii_bus);
+ out:
+	return err;
+}
+
 static void ax_handle_link_change(struct net_device *dev)
 {
 	struct ax_device  *ax = to_ax_dev(dev);
@@ -578,103 +671,8 @@ static const struct net_device_ops ax_netdev_ops = {
 #endif
 };
 
-static void ax_bb_mdc(struct mdiobb_ctrl *ctrl, int level)
-{
-	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
-	if (level)
-		ax->reg_memr |= AX_MEMR_MDC;
-	else
-		ax->reg_memr &= ~AX_MEMR_MDC;
-
-	ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static void ax_bb_dir(struct mdiobb_ctrl *ctrl, int output)
-{
-	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
-	if (output)
-		ax->reg_memr &= ~AX_MEMR_MDIR;
-	else
-		ax->reg_memr |= AX_MEMR_MDIR;
-
-	ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static void ax_bb_set_data(struct mdiobb_ctrl *ctrl, int value)
-{
-	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
-	if (value)
-		ax->reg_memr |= AX_MEMR_MDO;
-	else
-		ax->reg_memr &= ~AX_MEMR_MDO;
-
-	ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static int ax_bb_get_data(struct mdiobb_ctrl *ctrl)
-{
-	struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-	int reg_memr = ei_inb(ax->addr_memr);
-
-	return reg_memr & AX_MEMR_MDI ? 1 : 0;
-}
-
-static struct mdiobb_ops bb_ops = {
-	.owner = THIS_MODULE,
-	.set_mdc = ax_bb_mdc,
-	.set_mdio_dir = ax_bb_dir,
-	.set_mdio_data = ax_bb_set_data,
-	.get_mdio_data = ax_bb_get_data,
-};
-
 /* setup code */
 
-static int ax_mii_init(struct net_device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev->dev.parent);
-	struct ei_device *ei_local = netdev_priv(dev);
-	struct ax_device *ax = to_ax_dev(dev);
-	int err, i;
-
-	ax->bb_ctrl.ops = &bb_ops;
-	ax->addr_memr = ei_local->mem + AX_MEMR;
-	ax->mii_bus = alloc_mdio_bitbang(&ax->bb_ctrl);
-	if (!ax->mii_bus) {
-		err = -ENOMEM;
-		goto out;
-	}
-
-	ax->mii_bus->name = "ax88796_mii_bus";
-	ax->mii_bus->parent = dev->dev.parent;
-	snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		pdev->name, pdev->id);
-
-	ax->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
-	if (!ax->mii_bus->irq) {
-		err = -ENOMEM;
-		goto out_free_mdio_bitbang;
-	}
-
-	for (i = 0; i < PHY_MAX_ADDR; i++)
-		ax->mii_bus->irq[i] = PHY_POLL;
-
-	err = mdiobus_register(ax->mii_bus);
-	if (err)
-		goto out_free_irq;
-
-	return 0;
-
- out_free_irq:
-	kfree(ax->mii_bus->irq);
- out_free_mdio_bitbang:
-	free_mdio_bitbang(ax->mii_bus);
- out:
-	return err;
-}
-
 static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local)
 {
 	void __iomem *ioaddr = ei_local->mem;
-- 
1.7.0.4

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

* [PATCH 4/8] ax88796: Do not free IRQ that did not get requested
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
                   ` (2 preceding siblings ...)
  2015-11-16 23:33 ` [PATCH 3/8] ax88796: Move mii support functions upwards to prevent need of forward declaration Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-16 23:33 ` [PATCH 5/8] ax88796: Add block_input/output hooks to ax_plat_data Michael Schmitz
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, Michael Karcher, Michael Schmitz

From: Michael Karcher <debian@mkarcher.dialup.fu-berlin.de>

The irq is request on netdev open time, so do not free it in probe
if something fails.
Also do not free the irq in remove, as it got already freed in close

Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/ax88796.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 544f3ba..6472473 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -802,7 +802,7 @@ static int ax_init_dev(struct net_device *dev)
 
 	ret = register_netdev(dev);
 	if (ret)
-		goto out_irq;
+		goto err_out;
 
 	netdev_info(dev, "%dbit, irq %d, %lx, MAC: %pM\n",
 		    ei_local->word16 ? 16 : 8, dev->irq, dev->base_addr,
@@ -810,9 +810,6 @@ static int ax_init_dev(struct net_device *dev)
 
 	return 0;
 
- out_irq:
-	/* cleanup irq */
-	free_irq(dev->irq, dev);
  err_out:
 	return ret;
 }
@@ -825,7 +822,6 @@ static int ax_remove(struct platform_device *pdev)
 	struct resource *mem;
 
 	unregister_netdev(dev);
-	free_irq(dev->irq, dev);
 
 	iounmap(ei_local->mem);
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
1.7.0.4

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

* [PATCH 5/8] ax88796: Add block_input/output hooks to ax_plat_data
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
                   ` (3 preceding siblings ...)
  2015-11-16 23:33 ` [PATCH 4/8] ax88796: Do not free IRQ that did not get requested Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-16 23:33 ` [PATCH 6/8] ax88796: add interrupt status callback to platform data Michael Schmitz
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, Michael Schmitz

Add platform specific hooks for block transfer reads/writes of packet
buffer data, superseding the default provided ax_block_input/output.
Currently used for m68k Amiga XSurf100.

Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/ax88796.c |   10 ++++++++--
 include/net/ax88796.h               |    7 ++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 6472473..d45c032 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -789,8 +789,14 @@ static int ax_init_dev(struct net_device *dev)
 #endif
 
 	ei_local->reset_8390 = &ax_reset_8390;
-	ei_local->block_input = &ax_block_input;
-	ei_local->block_output = &ax_block_output;
+	if (ax->plat->block_input)
+		ei_local->block_input = ax->plat->block_input;
+	else
+		ei_local->block_input = &ax_block_input;
+	if (ax->plat->block_output)
+		ei_local->block_output = ax->plat->block_output;
+	else
+		ei_local->block_output = &ax_block_output;
 	ei_local->get_8390_hdr = &ax_get_8390_hdr;
 	ei_local->priv = 0;
 	ei_local->msg_enable = ax_msg_enable;
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index b9a3bec..28d6a93 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -8,10 +8,11 @@
  * published by the Free Software Foundation.
  *
 */
-
 #ifndef __NET_AX88796_PLAT_H
 #define __NET_AX88796_PLAT_H
 
+struct net_device;
+
 #define AXFLG_HAS_EEPROM		(1<<0)
 #define AXFLG_MAC_FROMDEV		(1<<1)	/* device already has MAC */
 #define AXFLG_HAS_93CX6			(1<<2)	/* use eeprom_93cx6 driver */
@@ -26,6 +27,10 @@ struct ax_plat_data {
 	u32		*reg_offsets;	/* register offsets */
 	u8		*mac_addr;	/* MAC addr (only used when
 					   AXFLG_MAC_FROMPLATFORM is used */
+
+        /* uses default ax88796 buffer if set to NULL */
+	void (*block_output)(struct net_device *, int, const unsigned char *, int);
+	void (*block_input)(struct net_device *, int, struct sk_buff *, int);
 };
 
 #endif /* __NET_AX88796_PLAT_H */
-- 
1.7.0.4

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

* [PATCH 6/8] ax88796: add interrupt status callback to platform data
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
                   ` (4 preceding siblings ...)
  2015-11-16 23:33 ` [PATCH 5/8] ax88796: Add block_input/output hooks to ax_plat_data Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-16 23:33 ` [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device Michael Schmitz
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, Michael Schmitz

To be able to tell the ax88796 driver whether it is sensible to enter
the 8390 interrupt handler, an "is this interrupt caused by the 88796"
callback has been added to the ax_plat_data structure (with NULL being
compatible to the previous behaviour).

Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/ax88796.c |   23 +++++++++++++++++++++--
 include/net/ax88796.h               |    4 ++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index d45c032..020bcf7 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -166,6 +166,21 @@ static void ax_reset_8390(struct net_device *dev)
 	ei_outb(ENISR_RESET, addr + EN0_ISR);	/* Ack intr. */
 }
 
+/*
+ * Wrapper for __ei_interrupt for platforms that have a platform-specific
+ * way to find out whether the interrupt request might be caused by
+ * the ax88796 chip.
+ */
+static irqreturn_t ax_ei_interrupt_filtered(int irq, void *dev_id)
+{
+	struct net_device *dev = dev_id;
+	struct ax_device *ax = to_ax_dev(dev);
+	struct platform_device *pdev = to_platform_device(dev->dev.parent);
+	if (!ax->plat->check_irq(pdev))
+		return IRQ_NONE;
+
+	return ax_ei_interrupt(irq, dev_id);
+}
 
 static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
 			    int ring_page)
@@ -498,8 +513,12 @@ static int ax_open(struct net_device *dev)
 	if (ret)
 		goto failed_request_irq;
 
-	ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
-			  dev->name, dev);
+	if (ax->plat->check_irq)
+		ret = request_irq(dev->irq, ax_ei_interrupt_filtered,
+		                  ax->irqflags, dev->name, dev);
+	else
+		ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
+				  dev->name, dev);
 	if (ret)
 		goto failed_request_irq;
 
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index 28d6a93..d5b24be 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -12,6 +12,7 @@
 #define __NET_AX88796_PLAT_H
 
 struct net_device;
+struct platform_device;
 
 #define AXFLG_HAS_EEPROM		(1<<0)
 #define AXFLG_MAC_FROMDEV		(1<<1)	/* device already has MAC */
@@ -31,6 +32,9 @@ struct ax_plat_data {
         /* uses default ax88796 buffer if set to NULL */
 	void (*block_output)(struct net_device *, int, const unsigned char *, int);
 	void (*block_input)(struct net_device *, int, struct sk_buff *, int);
+	/* returns nonzero if a pending interrupt request might by caused by
+	   the ax88786. Handles all interrupts if set to NULL */
+	int (*check_irq)(struct platform_device *);
 };
 
 #endif /* __NET_AX88796_PLAT_H */
-- 
1.7.0.4

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

* [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
                   ` (5 preceding siblings ...)
  2015-11-16 23:33 ` [PATCH 6/8] ax88796: add interrupt status callback to platform data Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-17  8:16   ` Geert Uytterhoeven
  2015-11-16 23:33 ` [PATCH 8/8] ax88796: use interrupt status callback for XSurf100 driver Michael Schmitz
  2015-11-17  8:18 ` [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Geert Uytterhoeven
  8 siblings, 1 reply; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, 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 <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/Kconfig    |   10 ++++-
 drivers/net/ethernet/8390/Makefile   |    1 +
 drivers/net/ethernet/8390/xsurf100.c |   71 ++++++++++++++++++++++++++++++++++
 3 files changed, 81 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 edf7225..2cb6a32 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,14 @@ config AX88796_93CX6
 	---help---
 	  Select this if your platform comes with an external 93CX6 eeprom.
 
+config XSURF100
+	tristate "XSurf 100 support"
+	depends on ZORRO
+	depends on AX88796
+	---help---
+	  This driver is for the Individual Computers X-Surf 100 Ethernet
+          card. If you have such a card, say Y. Otherwise, say N.
+
 config HYDRA
 	tristate "Hydra support"
 	depends on ZORRO
diff --git a/drivers/net/ethernet/8390/Makefile b/drivers/net/ethernet/8390/Makefile
index ff3b318..c2dab5c 100644
--- a/drivers/net/ethernet/8390/Makefile
+++ b/drivers/net/ethernet/8390/Makefile
@@ -15,4 +15,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 0000000..3c34b04
--- /dev/null
+++ b/drivers/net/ethernet/8390/xsurf100.c
@@ -0,0 +1,71 @@
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/platform_device.h>
+#include <linux/zorro.h>
+#include <net/ax88796.h>
+#include <asm/amigaints.h>
+
+#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100 ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x64, 0)
+
+#define XS1000_8390_BASE 0x800
+
+static int xsurf100_probe(struct zorro_dev *zdev, const struct zorro_device_id *ent)
+{
+	struct platform_device *pdev;
+	struct ax_plat_data ax88796_data;
+	struct resource res[2] = {
+		DEFINE_RES_IRQ(IRQ_AMIGA_PORTS),
+		DEFINE_RES_IO(zdev->resource.start + XS1000_8390_BASE, 4 * 0x20)
+	};
+	int reg;
+	u32 reg_offsets[32];
+
+	for (reg = 0; reg < 0x20; reg++)
+		reg_offsets[reg] = 4;
+
+	ax88796_data.flags = AXFLG_HAS_EEPROM;
+	ax88796_data.wordlength = 2;
+	ax88796_data.dcr_val = 0x48;
+	ax88796_data.rcr_val = 0x40;
+	ax88796_data.reg_offsets = reg_offsets;
+
+	// TODO: xsurf100 specific accelerated data exchange
+
+	pdev = platform_device_register_resndata(
+		&zdev->dev, "ax88796", zdev->slotaddr,
+		res, 2,
+		&ax88796_data, sizeof ax88796_data);
+
+	// TODO: NULL check
+	zorro_set_drvdata(zdev, pdev);
+	return 0;
+}
+
+static void xsurf100_remove(struct zorro_dev *zdev)
+{
+	struct platform_device *pdev;
+
+	pdev = zorro_get_drvdata(zdev);
+
+	platform_device_unregister(pdev);
+}
+
+static struct zorro_device_id xsurf100_zorro_tbl[] = {
+       { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100, },
+       { 0 }
+};
+
+MODULE_DEVICE_TABLE(zorro, xsurf100_zorro_tbl);
+
+static struct zorro_driver xsurf100_driver = {
+       .name           = "xsurf100",
+       .id_table       = xsurf100_zorro_tbl,
+       .probe          = xsurf100_probe,
+       .remove         = xsurf100_remove,
+};
+
+module_driver(xsurf100_driver, zorro_register_driver, zorro_unregister_driver);
+
+MODULE_DESCRIPTION("X-Surf 100 driver");
+MODULE_AUTHOR("Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>");
+MODULE_LICENSE("GPL v2");
-- 
1.7.0.4

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

* [PATCH 8/8] ax88796: use interrupt status callback for XSurf100 driver
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
                   ` (6 preceding siblings ...)
  2015-11-16 23:33 ` [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device Michael Schmitz
@ 2015-11-16 23:33 ` Michael Schmitz
  2015-11-17  8:18 ` [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Geert Uytterhoeven
  8 siblings, 0 replies; 17+ messages in thread
From: Michael Schmitz @ 2015-11-16 23:33 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, debian-68k, kernel, Michael Schmitz

Make use of the ax88796 platform data interupt status hook in the
m68k Amiga XSurf100 driver. The XSurf100 interrupt is shared with
other Amiga hardware interrupts so ei_interrupt would otherwise
get called a lot without need.

Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
 drivers/net/ethernet/8390/xsurf100.c |   42 +++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/8390/xsurf100.c b/drivers/net/ethernet/8390/xsurf100.c
index 3c34b04..f1b1f62 100644
--- a/drivers/net/ethernet/8390/xsurf100.c
+++ b/drivers/net/ethernet/8390/xsurf100.c
@@ -7,27 +7,49 @@
 
 #define ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100 ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x64, 0)
 
-#define XS1000_8390_BASE 0x800
+#define XS100_IRQSTATUS_BASE 0x40
+#define XS100_8390_BASE 0x800
+
+struct xsurf100_ax_plat_data {
+	struct ax_plat_data ax;
+	void *base_regs;
+};
+
+static int is_xsurf100_network_irq(struct platform_device *pdev)
+{
+	struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+	return (readw(xs100->base_regs + XS100_IRQSTATUS_BASE) & 0xaaaa) != 0;
+}
 
 static int xsurf100_probe(struct zorro_dev *zdev, const struct zorro_device_id *ent)
 {
 	struct platform_device *pdev;
-	struct ax_plat_data ax88796_data;
+	struct xsurf100_ax_plat_data ax88796_data;
 	struct resource res[2] = {
 		DEFINE_RES_IRQ(IRQ_AMIGA_PORTS),
-		DEFINE_RES_IO(zdev->resource.start + XS1000_8390_BASE, 4 * 0x20)
+		DEFINE_RES_IO(zdev->resource.start + XS100_8390_BASE, 4 * 0x20)
 	};
 	int reg;
 	u32 reg_offsets[32];
 
+	if (!request_mem_region(zdev->resource.start, 0x100, zdev->name))
+	{
+		dev_err(&zdev->dev, "cannot reserve X-Surf 100 control registers\n");
+		return -ENXIO;
+	}
+
 	for (reg = 0; reg < 0x20; reg++)
 		reg_offsets[reg] = 4;
 
-	ax88796_data.flags = AXFLG_HAS_EEPROM;
-	ax88796_data.wordlength = 2;
-	ax88796_data.dcr_val = 0x48;
-	ax88796_data.rcr_val = 0x40;
-	ax88796_data.reg_offsets = reg_offsets;
+	memset(&ax88796_data, 0, sizeof ax88796_data);
+	ax88796_data.ax.flags = AXFLG_HAS_EEPROM;
+	ax88796_data.ax.wordlength = 2;
+	ax88796_data.ax.dcr_val = 0x48;
+	ax88796_data.ax.rcr_val = 0x40;
+	ax88796_data.ax.reg_offsets = reg_offsets;
+	ax88796_data.ax.check_irq = is_xsurf100_network_irq;
+	ax88796_data.base_regs = ioremap(zdev->resource.start, 0x100);
+
 
 	// TODO: xsurf100 specific accelerated data exchange
 
@@ -44,8 +66,12 @@ static int xsurf100_probe(struct zorro_dev *zdev, const struct zorro_device_id *
 static void xsurf100_remove(struct zorro_dev *zdev)
 {
 	struct platform_device *pdev;
+	struct xsurf100_ax_plat_data *xs100;
 
 	pdev = zorro_get_drvdata(zdev);
+	xs100 = dev_get_platdata(&pdev->dev);
+	iounmap(xs100->base_regs);
+	release_mem_region(zdev->resource.start, 0x100);
 
 	platform_device_unregister(pdev);
 }
-- 
1.7.0.4

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

* Re: [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device
  2015-11-16 23:33 ` [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device Michael Schmitz
@ 2015-11-17  8:16   ` Geert Uytterhoeven
  2015-11-17 17:59     ` Michael Karcher
  0 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2015-11-17  8:16 UTC (permalink / raw)
  To: Michael Schmitz; +Cc: Linux/m68k, Debian m68k, Michael Karcher

Hi Michael,

On Tue, Nov 17, 2015 at 12:33 AM, Michael Schmitz <schmitzmic@gmail.com> wrote:
> --- /dev/null
> +++ b/drivers/net/ethernet/8390/xsurf100.c
> @@ -0,0 +1,71 @@

> +static int xsurf100_probe(struct zorro_dev *zdev, const struct zorro_device_id *ent)
> +{
> +       struct platform_device *pdev;
> +       struct ax_plat_data ax88796_data;
> +       struct resource res[2] = {
> +               DEFINE_RES_IRQ(IRQ_AMIGA_PORTS),
> +               DEFINE_RES_IO(zdev->resource.start + XS1000_8390_BASE, 4 * 0x20)
> +       };
> +       int reg;
> +       u32 reg_offsets[32];
> +
> +       for (reg = 0; reg < 0x20; reg++)
> +               reg_offsets[reg] = 4;
> +
> +       ax88796_data.flags = AXFLG_HAS_EEPROM;
> +       ax88796_data.wordlength = 2;
> +       ax88796_data.dcr_val = 0x48;
> +       ax88796_data.rcr_val = 0x40;
> +       ax88796_data.reg_offsets = reg_offsets;
> +
> +       // TODO: xsurf100 specific accelerated data exchange
> +
> +       pdev = platform_device_register_resndata(
> +               &zdev->dev, "ax88796", zdev->slotaddr,
> +               res, 2,
> +               &ax88796_data, sizeof ax88796_data);
> +
> +       // TODO: NULL check
> +       zorro_set_drvdata(zdev, pdev);

This looks a bit strange to me: storing another platform device in the
driver-specific data. But I guess it's valid ;-)

BTW, as most Zorro boards are made of one or more "discrete" devices
(e.g. an IDE and Ethernet combo), but only one zorro_driver can bind to it,
I started converting Zorro drivers to MFD drivers a few years ago.
Unfortunately I still haven't finished that.
It would also make it simpler to embed a normal ax88796 platform device.

> +       return 0;
> +}

> +static struct zorro_device_id xsurf100_zorro_tbl[] = {

const

> +       { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100, },
> +       { 0 }
> +};

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net
  2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
                   ` (7 preceding siblings ...)
  2015-11-16 23:33 ` [PATCH 8/8] ax88796: use interrupt status callback for XSurf100 driver Michael Schmitz
@ 2015-11-17  8:18 ` Geert Uytterhoeven
  2015-11-17 18:16   ` Michael Karcher
  2015-11-18  1:52   ` Michael Schmitz
  8 siblings, 2 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2015-11-17  8:18 UTC (permalink / raw)
  To: Michael Schmitz; +Cc: Linux/m68k, Debian m68k, Michael Karcher

Hi Michael,

On Tue, Nov 17, 2015 at 12:33 AM, Michael Schmitz <schmitzmic@gmail.com> wrote:
> just as a heads-up, I've been working on getting this series ready for
> submission to -net. The first six patches will need to be taken through
> -net, the last two are m68k specific and might be equally well placed in
> arch/m68k/amiga for preference.

Please don't put drivers in arch/m68k/. drivers/net is fine for a pure-net
driver.

> Patch 6 and 8 are optional - the interrupts are handled just fine inside
> ei_interrupt if generated by other users of IRQ_AMIGA_PORTS.
>
> If you know of some other hardware currently using IRQ_AMIGA_PORTS that
> cannot handle shared interupts, give me a shout and I'll look into handling
> this through a new interrupt controller for IRQ_AMIGA_PORTS.

All Amiga devices should handle shared interrupts.

Thanks a lot for your work!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device
  2015-11-17  8:16   ` Geert Uytterhoeven
@ 2015-11-17 17:59     ` Michael Karcher
  2015-11-17 20:01       ` Geert Uytterhoeven
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Karcher @ 2015-11-17 17:59 UTC (permalink / raw)
  To: Geert Uytterhoeven, Michael Schmitz; +Cc: Linux/m68k, Debian m68k

Hello Geert,

thanks for your comments!

On 17.11.2015 09:16, Geert Uytterhoeven wrote:
>> +static int xsurf100_probe(struct zorro_dev *zdev, const struct zorro_device_id *ent)
>> +{
>> +       struct platform_device *pdev;
>> +       struct ax_plat_data ax88796_data;
>> +       struct resource res[2] = {
>> +               DEFINE_RES_IRQ(IRQ_AMIGA_PORTS),
>> +               DEFINE_RES_IO(zdev->resource.start + XS1000_8390_BASE, 4 * 0x20)
>> +       };
>> +       int reg;
>> +       u32 reg_offsets[32];
>> +
>> +       for (reg = 0; reg < 0x20; reg++)
>> +               reg_offsets[reg] = 4;
>> +
>> +       ax88796_data.flags = AXFLG_HAS_EEPROM;
>> +       ax88796_data.wordlength = 2;
>> +       ax88796_data.dcr_val = 0x48;
>> +       ax88796_data.rcr_val = 0x40;
>> +       ax88796_data.reg_offsets = reg_offsets;
>> +
>> +       // TODO: xsurf100 specific accelerated data exchange
>> +
>> +       pdev = platform_device_register_resndata(
>> +               &zdev->dev, "ax88796", zdev->slotaddr,
>> +               res, 2,
>> +               &ax88796_data, sizeof ax88796_data);
>> +
>> +       // TODO: NULL check
>> +       zorro_set_drvdata(zdev, pdev);
> This looks a bit strange to me: storing another platform device in the
> driver-specific data. But I guess it's valid ;-)
We get a zorro device from the amiga subsystem for each XSurf 100 board
installed in the machine. I want to bind the platform driver ax88796 to
a subrange of the address space of the XSurf 100. To get the platform
driver bound, I think I need to create a platform device (for each XSurf
100 Zorro device, so I can't have a static platform device allocated in
the Zorro driver). If I dynamically create a platform device, I have to
save the pointer somewhere, so I can remove the platform device when the
module gets unloaded. For me, the obvious place to store the pointer is
the driver-specific data of the Zorro device.
If you have a different suggestion on how to connect the ax88796
platform driver to a Zorro device that looks less strange to you, I am
happy to learn a different way.

> BTW, as most Zorro boards are made of one or more "discrete" devices
> (e.g. an IDE and Ethernet combo), but only one zorro_driver can bind to it,
> I started converting Zorro drivers to MFD drivers a few years ago.
The mfd framework might in fact be the different way I should learn
about. It feels a bit like the approach I used in xsurf100.c is
reinventing the mfd stuff, but I still have to find good documentation
on how to use the mfd framework. I didn't find anything in
linux/Documentation, and the comments in linux/include/linux/mfd/core.h
have a quite steep learning curve.

> Unfortunately I still haven't finished that.
> It would also make it simpler to embed a normal ax88796 platform device.
I don't see yet how your conversion of present Zorro drivers would help
for this new xsurf100 driver. On the other hand, if you just meant to
point out using a mfd driver instead of the "create platform devices by
hand" approach, *like* you are using for other drivers, I got your point
and you are likely right.
>> +static struct zorro_device_id xsurf100_zorro_tbl[] = {
> const
Of course. Thanks for pointing it out.

BTW: for me, the patch-set was trivially forward-ported by git rebasing
to 4.4-rc1

Kind regards,
  Michael Karcher

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

* Re: [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net
  2015-11-17  8:18 ` [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Geert Uytterhoeven
@ 2015-11-17 18:16   ` Michael Karcher
  2015-11-17 20:02     ` Geert Uytterhoeven
  2015-11-18  1:52   ` Michael Schmitz
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Karcher @ 2015-11-17 18:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Michael Schmitz; +Cc: Linux/m68k, Debian m68k

On 17.11.2015 09:18, Geert Uytterhoeven wrote:
> Please don't put drivers in arch/m68k/. drivers/net is fine for a
> pure-net driver. 
There is a USB daughterboard on the XSurf 100 card, so it will no longer
be pure-net if that daughterboard is installed.

See http://wiki.icomp.de/wiki/X-Surf-100 and
http://wiki.icomp.de/wiki/RapidRoad.

Regards,
  Michael Karcher

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

* Re: [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device
  2015-11-17 17:59     ` Michael Karcher
@ 2015-11-17 20:01       ` Geert Uytterhoeven
  0 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2015-11-17 20:01 UTC (permalink / raw)
  To: Michael Karcher; +Cc: Michael Schmitz, Linux/m68k, Debian m68k

Hi Michael,

On Tue, Nov 17, 2015 at 6:59 PM, Michael Karcher
<kernel@mkarcher.dialup.fu-berlin.de> wrote:
> On 17.11.2015 09:16, Geert Uytterhoeven wrote:
>>> +static int xsurf100_probe(struct zorro_dev *zdev, const struct zorro_device_id *ent)
>>> +{
>>> +       struct platform_device *pdev;
>>> +       struct ax_plat_data ax88796_data;
>>> +       struct resource res[2] = {
>>> +               DEFINE_RES_IRQ(IRQ_AMIGA_PORTS),
>>> +               DEFINE_RES_IO(zdev->resource.start + XS1000_8390_BASE, 4 * 0x20)
>>> +       };
>>> +       int reg;
>>> +       u32 reg_offsets[32];
>>> +
>>> +       for (reg = 0; reg < 0x20; reg++)
>>> +               reg_offsets[reg] = 4;
>>> +
>>> +       ax88796_data.flags = AXFLG_HAS_EEPROM;
>>> +       ax88796_data.wordlength = 2;
>>> +       ax88796_data.dcr_val = 0x48;
>>> +       ax88796_data.rcr_val = 0x40;
>>> +       ax88796_data.reg_offsets = reg_offsets;
>>> +
>>> +       // TODO: xsurf100 specific accelerated data exchange
>>> +
>>> +       pdev = platform_device_register_resndata(
>>> +               &zdev->dev, "ax88796", zdev->slotaddr,
>>> +               res, 2,
>>> +               &ax88796_data, sizeof ax88796_data);
>>> +
>>> +       // TODO: NULL check
>>> +       zorro_set_drvdata(zdev, pdev);
>> This looks a bit strange to me: storing another platform device in the
>> driver-specific data. But I guess it's valid ;-)
> We get a zorro device from the amiga subsystem for each XSurf 100 board
> installed in the machine. I want to bind the platform driver ax88796 to
> a subrange of the address space of the XSurf 100. To get the platform
> driver bound, I think I need to create a platform device (for each XSurf
> 100 Zorro device, so I can't have a static platform device allocated in
> the Zorro driver). If I dynamically create a platform device, I have to
> save the pointer somewhere, so I can remove the platform device when the
> module gets unloaded. For me, the obvious place to store the pointer is
> the driver-specific data of the Zorro device.
> If you have a different suggestion on how to connect the ax88796
> platform driver to a Zorro device that looks less strange to you, I am
> happy to learn a different way.

Sure, I understand why you're doing it.

>> BTW, as most Zorro boards are made of one or more "discrete" devices
>> (e.g. an IDE and Ethernet combo), but only one zorro_driver can bind to it,
>> I started converting Zorro drivers to MFD drivers a few years ago.
> The mfd framework might in fact be the different way I should learn
> about. It feels a bit like the approach I used in xsurf100.c is
> reinventing the mfd stuff, but I still have to find good documentation
> on how to use the mfd framework. I didn't find anything in
> linux/Documentation, and the comments in linux/include/linux/mfd/core.h
> have a quite steep learning curve.

Yeah, it looks quite complex ;-)

But in the end it's just about calling mfd_add_devices(), which will
create the needed platform_device(s) for you from a list of mfd "cells".

>> Unfortunately I still haven't finished that.
>> It would also make it simpler to embed a normal ax88796 platform device.
> I don't see yet how your conversion of present Zorro drivers would help
> for this new xsurf100 driver. On the other hand, if you just meant to
> point out using a mfd driver instead of the "create platform devices by
> hand" approach, *like* you are using for other drivers, I got your point
> and you are likely right.

Yes, that's what the MFD subsystem is about.

I've pushed my work-in-progress to
https://git.kernel.org/cgit/linux/kernel/git/geert/linux-m68k.git/log/?h=zorro-mfd

Please have a look at the various drivers/zorro/*-mfd.c files for inspiration.
drivers/zorro/8390-cell.c is a dummy cell driver, which is basically a
platform device driver. For X-Surf 100 that would be the existing ax88796
driver.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net
  2015-11-17 18:16   ` Michael Karcher
@ 2015-11-17 20:02     ` Geert Uytterhoeven
  0 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2015-11-17 20:02 UTC (permalink / raw)
  To: Michael Karcher; +Cc: Michael Schmitz, Linux/m68k, Debian m68k

Hi Michael,

On Tue, Nov 17, 2015 at 7:16 PM, Michael Karcher
<kernel@mkarcher.dialup.fu-berlin.de> wrote:
> On 17.11.2015 09:18, Geert Uytterhoeven wrote:
>> Please don't put drivers in arch/m68k/. drivers/net is fine for a
>> pure-net driver.
> There is a USB daughterboard on the XSurf 100 card, so it will no longer
> be pure-net if that daughterboard is installed.

Then it will definitely benefit from the MFD subsystem!

MFD drivers are typically under drivers/mfd/, but if we go that way for
generic Zorro drivers, I would store them under drivers/zorro/, if the MFD
maintainer won't object.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net
  2015-11-17  8:18 ` [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Geert Uytterhoeven
  2015-11-17 18:16   ` Michael Karcher
@ 2015-11-18  1:52   ` Michael Schmitz
  2015-11-18  8:09     ` Geert Uytterhoeven
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Schmitz @ 2015-11-18  1:52 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Linux/m68k, Debian m68k, Michael Karcher

Hi Geert,


On Tue, Nov 17, 2015 at 9:18 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Hi Michael,
>
> On Tue, Nov 17, 2015 at 12:33 AM, Michael Schmitz <schmitzmic@gmail.com> wrote:
>> just as a heads-up, I've been working on getting this series ready for
>> submission to -net. The first six patches will need to be taken through
>> -net, the last two are m68k specific and might be equally well placed in
>> arch/m68k/amiga for preference.
>
> Please don't put drivers in arch/m68k/. drivers/net is fine for a pure-net
> driver.

OK, fine. arch/m68k/atai is where I had put the platform devices for
the Atari network and USB drivers, but these don't require much more
than a few register definitions.

>
>> Patch 6 and 8 are optional - the interrupts are handled just fine inside
>> ei_interrupt if generated by other users of IRQ_AMIGA_PORTS.
>>
>> If you know of some other hardware currently using IRQ_AMIGA_PORTS that
>> cannot handle shared interupts, give me a shout and I'll look into handling
>> this through a new interrupt controller for IRQ_AMIGA_PORTS.
>
> All Amiga devices should handle shared interrupts.

Good - do you see any merit in using a platform defined interrrupt
wrapper to 'protect' a driver interrupt from spurious calls?

> Thanks a lot for your work!

My pleasure, as always.

Cheers,

  Michael


>
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> 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

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

* Re: [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net
  2015-11-18  1:52   ` Michael Schmitz
@ 2015-11-18  8:09     ` Geert Uytterhoeven
  0 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2015-11-18  8:09 UTC (permalink / raw)
  To: Michael Schmitz; +Cc: Linux/m68k, Debian m68k, Michael Karcher

Hi Michael,

On Wed, Nov 18, 2015 at 2:52 AM, Michael Schmitz <schmitzmic@gmail.com> wrote:
>>> Patch 6 and 8 are optional - the interrupts are handled just fine inside
>>> ei_interrupt if generated by other users of IRQ_AMIGA_PORTS.
>>>
>>> If you know of some other hardware currently using IRQ_AMIGA_PORTS that
>>> cannot handle shared interupts, give me a shout and I'll look into handling
>>> this through a new interrupt controller for IRQ_AMIGA_PORTS.
>>
>> All Amiga devices should handle shared interrupts.
>
> Good - do you see any merit in using a platform defined interrrupt
> wrapper to 'protect' a driver interrupt from spurious calls?

I can see its merit. I don't know if the ax88796 maintainer will like it.

All other 8390 drivers just use ei_interrupt(), even zorro8390.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

end of thread, other threads:[~2015-11-18  8:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-16 23:33 [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Michael Schmitz
2015-11-16 23:33 ` [PATCH 1/8] aX88796: Fix MAC address reading Michael Schmitz
2015-11-16 23:33 ` [PATCH 2/8] ax88796: Attach MII bus only when open Michael Schmitz
2015-11-16 23:33 ` [PATCH 3/8] ax88796: Move mii support functions upwards to prevent need of forward declaration Michael Schmitz
2015-11-16 23:33 ` [PATCH 4/8] ax88796: Do not free IRQ that did not get requested Michael Schmitz
2015-11-16 23:33 ` [PATCH 5/8] ax88796: Add block_input/output hooks to ax_plat_data Michael Schmitz
2015-11-16 23:33 ` [PATCH 6/8] ax88796: add interrupt status callback to platform data Michael Schmitz
2015-11-16 23:33 ` [PATCH 7/8] ax88796: Add X-Surf 100 zorro driver providing an ax88796 platform device Michael Schmitz
2015-11-17  8:16   ` Geert Uytterhoeven
2015-11-17 17:59     ` Michael Karcher
2015-11-17 20:01       ` Geert Uytterhoeven
2015-11-16 23:33 ` [PATCH 8/8] ax88796: use interrupt status callback for XSurf100 driver Michael Schmitz
2015-11-17  8:18 ` [PATCH 0/8] Amiga XSurf100 patch series, to be submitted to linux-net Geert Uytterhoeven
2015-11-17 18:16   ` Michael Karcher
2015-11-17 20:02     ` Geert Uytterhoeven
2015-11-18  1:52   ` Michael Schmitz
2015-11-18  8:09     ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox