public inbox for linux-ide@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] m68k: pata_cswarp: Add Amiga cslab ata support
@ 2025-03-24  9:24 Paolo Pisati
  2025-03-24  9:24 ` [PATCH v2 1/2] m68k: amiga_defconfig: enable PATA_CSWARP Paolo Pisati
  2025-03-24  9:24 ` [PATCH v2 2/2] ata: pata_cswarp: Add Amiga cslab ata support Paolo Pisati
  0 siblings, 2 replies; 7+ messages in thread
From: Paolo Pisati @ 2025-03-24  9:24 UTC (permalink / raw)
  To: Damien Le Moal, Niklas Cassel, Geert Uytterhoeven; +Cc: linux-ide, linux-m68k

Here is a driver (and the subsequent defconfig change) for the pata/CF socket in
the CS-Lab Warp series of Amiga boards.

Change in v2:
 - fix style, remove duplicate swap macro, driver version, etc
 - rework the zorro attach mechanism
 - remove the unnecessary zorro ids refactor

Paolo Pisati (2):
  m68k: amiga_defconfig: enable PATA_CSWARP
  ata: pata_cswarp: Add Amiga cslab ata support

 arch/m68k/configs/amiga_defconfig |   1 +
 drivers/ata/Kconfig               |  11 ++
 drivers/ata/Makefile              |   1 +
 drivers/ata/pata_cswarp.c         | 189 ++++++++++++++++++++++++++++++
 4 files changed, 202 insertions(+)
 create mode 100644 drivers/ata/pata_cswarp.c

-- 
2.34.1


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

* [PATCH v2 1/2] m68k: amiga_defconfig: enable PATA_CSWARP
  2025-03-24  9:24 [PATCH v2 0/2] m68k: pata_cswarp: Add Amiga cslab ata support Paolo Pisati
@ 2025-03-24  9:24 ` Paolo Pisati
  2025-03-24 10:53   ` Damien Le Moal
  2025-03-24  9:24 ` [PATCH v2 2/2] ata: pata_cswarp: Add Amiga cslab ata support Paolo Pisati
  1 sibling, 1 reply; 7+ messages in thread
From: Paolo Pisati @ 2025-03-24  9:24 UTC (permalink / raw)
  To: Damien Le Moal, Niklas Cassel, Geert Uytterhoeven; +Cc: linux-ide, linux-m68k

Signed-off-by: Paolo Pisati <p.pisati@gmail.com>
---
 arch/m68k/configs/amiga_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/m68k/configs/amiga_defconfig b/arch/m68k/configs/amiga_defconfig
index c705247e7b5b..feed92c95394 100644
--- a/arch/m68k/configs/amiga_defconfig
+++ b/arch/m68k/configs/amiga_defconfig
@@ -334,6 +334,7 @@ CONFIG_ATA=y
 # CONFIG_ATA_VERBOSE_ERROR is not set
 # CONFIG_ATA_BMDMA is not set
 CONFIG_PATA_GAYLE=y
+CONFIG_PATA_CSWARP=y
 CONFIG_PATA_BUDDHA=y
 CONFIG_MD=y
 CONFIG_BLK_DEV_DM=m
-- 
2.34.1


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

* [PATCH v2 2/2] ata: pata_cswarp: Add Amiga cslab ata support
  2025-03-24  9:24 [PATCH v2 0/2] m68k: pata_cswarp: Add Amiga cslab ata support Paolo Pisati
  2025-03-24  9:24 ` [PATCH v2 1/2] m68k: amiga_defconfig: enable PATA_CSWARP Paolo Pisati
@ 2025-03-24  9:24 ` Paolo Pisati
  2025-03-24 11:00   ` Damien Le Moal
  1 sibling, 1 reply; 7+ messages in thread
From: Paolo Pisati @ 2025-03-24  9:24 UTC (permalink / raw)
  To: Damien Le Moal, Niklas Cassel, Geert Uytterhoeven; +Cc: linux-ide, linux-m68k

Driver for the on-board IDE interface on CS-Lab Warp Expansion Card
(NOTE that idemode=native has to be set in Warp Configuration)

Signed-off-by: Paolo Pisati <p.pisati@gmail.com>
---
 drivers/ata/Kconfig       |  11 +++
 drivers/ata/Makefile      |   1 +
 drivers/ata/pata_cswarp.c | 189 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+)
 create mode 100644 drivers/ata/pata_cswarp.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index e00536b49552..a278386f0fa2 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -1025,6 +1025,17 @@ config PATA_GAYLE
 
 	  If unsure, say N.
 
+config PATA_CSWARP
+	tristate "Amiga CS Warp PATA support"
+	depends on M68K && AMIGA
+	help
+	  This option enables support for the on-board IDE interface on
+	  CS-Lab Warp Expansion Card (NOTE that idemode=native has to be
+	  set in Warp Configuration)
+
+	  If unsure, say N.
+
+
 config PATA_BUDDHA
 	tristate "Buddha/Catweasel/X-Surf PATA support"
 	depends on ZORRO
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 20e6645ab737..7b9b87ebacea 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -98,6 +98,7 @@ obj-$(CONFIG_PATA_WINBOND)	+= pata_sl82c105.o
 obj-$(CONFIG_PATA_CMD640_PCI)	+= pata_cmd640.o
 obj-$(CONFIG_PATA_FALCON)	+= pata_falcon.o
 obj-$(CONFIG_PATA_GAYLE)	+= pata_gayle.o
+obj-$(CONFIG_PATA_CSWARP)	+= pata_cswarp.o
 obj-$(CONFIG_PATA_BUDDHA)	+= pata_buddha.o
 obj-$(CONFIG_PATA_ISAPNP)	+= pata_isapnp.o
 obj-$(CONFIG_PATA_IXP4XX_CF)	+= pata_ixp4xx_cf.o
diff --git a/drivers/ata/pata_cswarp.c b/drivers/ata/pata_cswarp.c
new file mode 100644
index 000000000000..4e2877ed93c9
--- /dev/null
+++ b/drivers/ata/pata_cswarp.c
@@ -0,0 +1,189 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Amiga CS Warp PATA controller driver
+ *
+ * Copyright (c) 2024 CS-Lab s.c.
+ *		http://www.cs-lab.eu
+ *
+ * Based on pata_gayle.c, pata_buddha.c and warpATA.device:
+ *
+ *     Created 2 Jun 2024 by Andrzej Rogozynski
+ */
+
+#include <linux/ata.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/libata.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/zorro.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+
+#include <asm/amigahw.h>
+#include <asm/amigaints.h>
+#include <asm/amigayle.h>
+#include <asm/setup.h>
+
+#define DRV_NAME "pata_cswarp"
+
+#define WARP_OFFSET_ATA         0x6000
+
+static const struct scsi_host_template pata_cswarp_sht = {
+	ATA_PIO_SHT(DRV_NAME),
+};
+
+static unsigned int pata_cswarp_data_xfer(struct ata_queued_cmd *qc,
+					 unsigned char *buf,
+					 unsigned int buflen, int rw)
+{
+	struct ata_device *dev = qc->dev;
+	struct ata_port *ap = dev->link->ap;
+	void __iomem *data_addr = ap->ioaddr.data_addr;
+	unsigned int words = buflen >> 1;
+
+	/* Transfer multiple of 2 bytes */
+	if (rw == READ)
+		raw_insw((u16 *)data_addr, (u16 *)buf, words);
+	else
+		raw_outsw((u16 *)data_addr, (u16 *)buf, words);
+
+	/* Transfer trailing byte, if any. */
+	if (unlikely(buflen & 0x01)) {
+		unsigned char pad[2] = { };
+
+		/* Point buf to the tail of buffer */
+		buf += buflen - 1;
+
+		if (rw == READ) {
+			raw_insw((u16 *)data_addr, (u16 *)pad, 1);
+			*buf = pad[0];
+		} else {
+			pad[0] = *buf;
+			raw_outsw((u16 *)data_addr, (u16 *)pad, 1);
+		}
+		words++;
+	}
+
+	return words << 1;
+}
+
+/*
+ * Provide our own set_mode() as we don't want to change anything that has
+ * already been configured..
+ */
+static int pata_cswarp_set_mode(struct ata_link *link,
+			       struct ata_device **unused)
+{
+	struct ata_device *dev;
+
+	ata_for_each_dev(dev, link, ENABLED) {
+		/* We don't really care */
+		dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
+		dev->xfer_shift = ATA_SHIFT_PIO;
+		dev->flags |= ATA_DFLAG_PIO;
+		ata_dev_info(dev, "configured for PIO\n");
+	}
+	return 0;
+}
+
+static struct ata_port_operations pata_cswarp_ops = {
+	.inherits	= &ata_sff_port_ops,
+	.sff_data_xfer	= pata_cswarp_data_xfer,
+	.cable_detect	= ata_cable_unknown,
+	.set_mode	= pata_cswarp_set_mode,
+};
+
+static int pata_cswarp_probe(struct zorro_dev *z,
+			     const struct zorro_device_id *ent)
+{
+	static const char board_name[] = "csWarp";
+	struct ata_host *host;
+	struct ata_port *ap;
+	void __iomem *cswarp_ctrl_board, *base;
+	unsigned long board = z->resource.start;
+
+	dev_info(&z->dev, "%s IDE controller (board: 0x%lx)\n", board_name,
+		 board);
+
+	if (!devm_request_mem_region(&z->dev, board + WARP_OFFSET_ATA, 0x1800,
+				     DRV_NAME))
+		return -ENXIO;
+
+	/* allocate host */
+	host = ata_host_alloc(&z->dev, 1);
+	if (!host)
+		return -ENXIO;
+
+	cswarp_ctrl_board = (void *)board;
+
+	ap = host->ports[0];
+	base = cswarp_ctrl_board + WARP_OFFSET_ATA;
+
+	ap->ops = &pata_cswarp_ops;
+
+	ap->pio_mask = ATA_PIO4;
+	ap->flags |= ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY |
+		ATA_FLAG_PIO_POLLING;
+
+	ap->ioaddr.data_addr		= base;
+	ap->ioaddr.error_addr		= base + 1 * 4;
+	ap->ioaddr.feature_addr		= base + 1 * 4;
+	ap->ioaddr.nsect_addr		= base + 2 * 4;
+	ap->ioaddr.lbal_addr		= base + 3 * 4;
+	ap->ioaddr.lbam_addr		= base + 4 * 4;
+	ap->ioaddr.lbah_addr		= base + 5 * 4;
+	ap->ioaddr.device_addr		= base + 6 * 4;
+	ap->ioaddr.status_addr		= base + 7 * 4;
+	ap->ioaddr.command_addr		= base + 7 * 4;
+
+	ap->ioaddr.altstatus_addr	= base + (0x1000 | (6UL << 2));
+	ap->ioaddr.ctl_addr		= base + (0x1000 | (6UL << 2));
+
+	ata_port_desc(ap, "  cmd 0x%lx ctl 0x%lx", (unsigned long)base,
+		      (unsigned long)ap->ioaddr.ctl_addr);
+
+	ata_host_activate(host, 0, NULL,
+			  IRQF_SHARED, &pata_cswarp_sht);
+
+	return 0;
+}
+
+static void pata_cswarp_remove(struct zorro_dev *z)
+{
+	struct ata_host *host = dev_get_drvdata(&z->dev);
+
+	ata_host_detach(host);
+}
+
+static const struct zorro_device_id pata_cswarp_zorro_tbl[] = {
+	{ ZORRO_PROD_CSLAB_WARP_1260, 0},
+	{ 0 }
+};
+MODULE_DEVICE_TABLE(zorro, pata_cswarp_zorro_tbl);
+
+static struct zorro_driver pata_cswarp_driver = {
+	.name           = "pata_cswarp",
+	.id_table       = pata_cswarp_zorro_tbl,
+	.probe          = pata_cswarp_probe,
+	.remove         = pata_cswarp_remove,
+};
+
+static int __init pata_cswarp_init(void) {
+	return zorro_register_driver(&pata_cswarp_driver);
+}
+
+static void __exit pata_cswarp_unregister(void) {
+	zorro_unregister_driver(&pata_cswarp_driver);
+}
+
+module_init(pata_cswarp_init);
+module_exit(pata_cswarp_unregister);
+
+MODULE_AUTHOR("Andrzej Rogozynski");
+MODULE_DESCRIPTION("low-level driver for CSWarp PATA");
+MODULE_LICENSE("GPL");
-- 
2.34.1


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

* Re: [PATCH v2 1/2] m68k: amiga_defconfig: enable PATA_CSWARP
  2025-03-24  9:24 ` [PATCH v2 1/2] m68k: amiga_defconfig: enable PATA_CSWARP Paolo Pisati
@ 2025-03-24 10:53   ` Damien Le Moal
  2025-03-24 12:58     ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2025-03-24 10:53 UTC (permalink / raw)
  To: Paolo Pisati, Niklas Cassel, Geert Uytterhoeven; +Cc: linux-ide, linux-m68k

On 2025/03/24 5:24, Paolo Pisati wrote:
> Signed-off-by: Paolo Pisati <p.pisati@gmail.com>
> ---
>  arch/m68k/configs/amiga_defconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/m68k/configs/amiga_defconfig b/arch/m68k/configs/amiga_defconfig
> index c705247e7b5b..feed92c95394 100644
> --- a/arch/m68k/configs/amiga_defconfig
> +++ b/arch/m68k/configs/amiga_defconfig
> @@ -334,6 +334,7 @@ CONFIG_ATA=y
>  # CONFIG_ATA_VERBOSE_ERROR is not set
>  # CONFIG_ATA_BMDMA is not set
>  CONFIG_PATA_GAYLE=y
> +CONFIG_PATA_CSWARP=y

This needs to be patch 2, otherwise there will be some bisectability issues.
Unless Geert wants to take this patch and we queue patch 1 (the driver) through
libata tree.

Geert,

How do yu want to proceed ? We can take everything through libata, or you can
take both patches through your tree. I do not have a strong preference either way.

>  CONFIG_PATA_BUDDHA=y
>  CONFIG_MD=y
>  CONFIG_BLK_DEV_DM=m


-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH v2 2/2] ata: pata_cswarp: Add Amiga cslab ata support
  2025-03-24  9:24 ` [PATCH v2 2/2] ata: pata_cswarp: Add Amiga cslab ata support Paolo Pisati
@ 2025-03-24 11:00   ` Damien Le Moal
  2025-03-24 12:02     ` Paolo Pisati
  0 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2025-03-24 11:00 UTC (permalink / raw)
  To: Paolo Pisati, Niklas Cassel, Geert Uytterhoeven; +Cc: linux-ide, linux-m68k

On 2025/03/24 5:24, Paolo Pisati wrote:
> Driver for the on-board IDE interface on CS-Lab Warp Expansion Card
> (NOTE that idemode=native has to be set in Warp Configuration)
> 
> Signed-off-by: Paolo Pisati <p.pisati@gmail.com>

2 nits below.

[...]

> +static int pata_cswarp_probe(struct zorro_dev *z,
> +			     const struct zorro_device_id *ent)
> +{
> +	static const char board_name[] = "csWarp";
> +	struct ata_host *host;
> +	struct ata_port *ap;
> +	void __iomem *cswarp_ctrl_board, *base;
> +	unsigned long board = z->resource.start;
> +
> +	dev_info(&z->dev, "%s IDE controller (board: 0x%lx)\n", board_name,
> +		 board);
> +
> +	if (!devm_request_mem_region(&z->dev, board + WARP_OFFSET_ATA, 0x1800,
> +				     DRV_NAME))
> +		return -ENXIO;
> +
> +	/* allocate host */

Not a very useful comment :)
You can drop this as the function name is obvious.

> +	host = ata_host_alloc(&z->dev, 1);
> +	if (!host)
> +		return -ENXIO;
> +
> +	cswarp_ctrl_board = (void *)board;
> +
> +	ap = host->ports[0];
> +	base = cswarp_ctrl_board + WARP_OFFSET_ATA;
> +
> +	ap->ops = &pata_cswarp_ops;
> +
> +	ap->pio_mask = ATA_PIO4;
> +	ap->flags |= ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY |
> +		ATA_FLAG_PIO_POLLING;
> +
> +	ap->ioaddr.data_addr		= base;
> +	ap->ioaddr.error_addr		= base + 1 * 4;
> +	ap->ioaddr.feature_addr		= base + 1 * 4;
> +	ap->ioaddr.nsect_addr		= base + 2 * 4;
> +	ap->ioaddr.lbal_addr		= base + 3 * 4;
> +	ap->ioaddr.lbam_addr		= base + 4 * 4;
> +	ap->ioaddr.lbah_addr		= base + 5 * 4;
> +	ap->ioaddr.device_addr		= base + 6 * 4;
> +	ap->ioaddr.status_addr		= base + 7 * 4;
> +	ap->ioaddr.command_addr		= base + 7 * 4;
> +
> +	ap->ioaddr.altstatus_addr	= base + (0x1000 | (6UL << 2));
> +	ap->ioaddr.ctl_addr		= base + (0x1000 | (6UL << 2));
> +
> +	ata_port_desc(ap, "  cmd 0x%lx ctl 0x%lx", (unsigned long)base,
> +		      (unsigned long)ap->ioaddr.ctl_addr);
> +
> +	ata_host_activate(host, 0, NULL,
> +			  IRQF_SHARED, &pata_cswarp_sht);

	return ata_host_activate(host, 0, NULL,
				 IRQF_SHARED, &pata_cswarp_sht);

so that errors are properly reported.

> +
> +	return 0;
> +}
> +


-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH v2 2/2] ata: pata_cswarp: Add Amiga cslab ata support
  2025-03-24 11:00   ` Damien Le Moal
@ 2025-03-24 12:02     ` Paolo Pisati
  0 siblings, 0 replies; 7+ messages in thread
From: Paolo Pisati @ 2025-03-24 12:02 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: Paolo Pisati, Niklas Cassel, Geert Uytterhoeven, linux-ide,
	linux-m68k

On Mon, Mar 24, 2025 at 07:00:47AM -0400, Damien Le Moal wrote:
> > +	ata_port_desc(ap, "  cmd 0x%lx ctl 0x%lx", (unsigned long)base,
> > +		      (unsigned long)ap->ioaddr.ctl_addr);
> > +
> > +	ata_host_activate(host, 0, NULL,
> > +			  IRQF_SHARED, &pata_cswarp_sht);
> 
> 	return ata_host_activate(host, 0, NULL,
> 				 IRQF_SHARED, &pata_cswarp_sht);
> 
> so that errors are properly reported.

Ack, will send a v3 and reorder the patches.
-- 
bye,
p.

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

* Re: [PATCH v2 1/2] m68k: amiga_defconfig: enable PATA_CSWARP
  2025-03-24 10:53   ` Damien Le Moal
@ 2025-03-24 12:58     ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2025-03-24 12:58 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: Paolo Pisati, Niklas Cassel, linux-ide, linux-m68k

Hi Damien,

On Mon, 24 Mar 2025 at 11:53, Damien Le Moal <dlemoal@kernel.org> wrote:
> On 2025/03/24 5:24, Paolo Pisati wrote:
> > Signed-off-by: Paolo Pisati <p.pisati@gmail.com>
> > ---
> >  arch/m68k/configs/amiga_defconfig | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/m68k/configs/amiga_defconfig b/arch/m68k/configs/amiga_defconfig
> > index c705247e7b5b..feed92c95394 100644
> > --- a/arch/m68k/configs/amiga_defconfig
> > +++ b/arch/m68k/configs/amiga_defconfig
> > @@ -334,6 +334,7 @@ CONFIG_ATA=y
> >  # CONFIG_ATA_VERBOSE_ERROR is not set
> >  # CONFIG_ATA_BMDMA is not set
> >  CONFIG_PATA_GAYLE=y
> > +CONFIG_PATA_CSWARP=y
>
> This needs to be patch 2, otherwise there will be some bisectability issues.
> Unless Geert wants to take this patch and we queue patch 1 (the driver) through
> libata tree.
>
> Geert,
>
> How do yu want to proceed ? We can take everything through libata, or you can
> take both patches through your tree. I do not have a strong preference either way.

Me neither. We don't get to see new hardware support a lot ;-)

Paolo:
Please enable the driver in arch/m68k/configs/multi_defconfig, too.

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] 7+ messages in thread

end of thread, other threads:[~2025-03-24 12:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-24  9:24 [PATCH v2 0/2] m68k: pata_cswarp: Add Amiga cslab ata support Paolo Pisati
2025-03-24  9:24 ` [PATCH v2 1/2] m68k: amiga_defconfig: enable PATA_CSWARP Paolo Pisati
2025-03-24 10:53   ` Damien Le Moal
2025-03-24 12:58     ` Geert Uytterhoeven
2025-03-24  9:24 ` [PATCH v2 2/2] ata: pata_cswarp: Add Amiga cslab ata support Paolo Pisati
2025-03-24 11:00   ` Damien Le Moal
2025-03-24 12:02     ` Paolo Pisati

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