Skip to contentSkip to conversation

ata: add Amiga Gayle PATA controller driver

PATCH Superseded Bartlomiej Zolnierkiewicz 3 participants 3 messages Mar 1, 2018 1 message not in the archive libata

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20180301110252epcas2p3ea455cfb08b2f7edb4af6fbc95addc88@epcas2p3.samsung.com

#1 lore raw

PATCH v2 1/1 ata: add Amiga Gayle PATA controller driver

Add Amiga Gayle PATA controller driver. It enables libata support for the on-board IDE interfaces on some Amiga models (A600, A1200, A4000 and A4000T) and also for IDE interfaces on the Zorro expansion bus (M-Tech E-Matrix 530 expansion card).

Thanks to John Paul Adrian Glaubitz and Michael Schmitz for help with testing the driver.

---
v2:
- clarify license version (it should be GPL 2.0)
- use SPDX header

 drivers/ata/Kconfig      |   12 ++
 drivers/ata/Makefile     |    1 
 drivers/ata/pata_gayle.c |  222 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 235 insertions(+)
drivers/ata/Kconfig +12 -0
Index: b/drivers/ata/Kconfig
===================================================================
@@ -963,6 +963,18 @@ config PATA_FALCON
 
 	  If unsure, say N.
 
+config PATA_GAYLE
+	tristate "Amiga Gayle PATA support"
+	depends on M68K && AMIGA
+	help
+	  This option enables support for the on-board IDE
+	  interfaces on some Amiga models (A600, A1200,
+	  A4000 and A4000T) and also for IDE interfaces on
+	  the Zorro expansion bus (M-Tech E-Matrix 530
+	  expansion card).
+
+	  If unsure, say N.
+
 config PATA_ISAPNP
 	tristate "ISA Plug and Play PATA support"
 	depends on ISAPNP
drivers/ata/Makefile +1 -0
Index: b/drivers/ata/Makefile
===================================================================
@@ -98,6 +98,7 @@ obj-$(CONFIG_PATA_WINBOND)	+= pata_sl82c
 # SFF PIO only
 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_ISAPNP)	+= pata_isapnp.o
 obj-$(CONFIG_PATA_IXP4XX_CF)	+= pata_ixp4xx_cf.o
 obj-$(CONFIG_PATA_MPIIX)	+= pata_mpiix.o
drivers/ata/pata_gayle.c new file +222 -0

222 lines not on this page · raw message

#2 lore raw
Quoted 11 lines · Bartlomiej Zolnierkiewicz

Add Amiga Gayle PATA controller driver. It enables libata support for the on-board IDE interfaces on some Amiga models (A600, A1200, A4000 and A4000T) and also for IDE interfaces on the Zorro expansion bus (M-Tech E-Matrix 530 expansion card).

Thanks to John Paul Adrian Glaubitz and Michael Schmitz for help with testing the driver.

drivers/ata/pata_gayle.c line 16

Quoted 4 lines
drivers/ata/pata_gayle.c new file +3 -0
+#include <linux/kernel.h>
 
+#include <linux/module.h>
+#include <linux/init.h>

Choose one of those two.

drivers/ata/pata_gayle.c line 26

Quoted 10 lines
drivers/ata/pata_gayle.c new file +10 -0
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_cmnd.h>
+#include <linux/ata.h>
+#include <linux/libata.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/zorro.h>
+#include <linux/platform_device.h>

Better to keep in order.

drivers/ata/pata_gayle.c line 32

Quoted 5 lines
drivers/ata/pata_gayle.c new file +5 -0
+#include <asm/setup.h>
+#include <asm/amigahw.h>
+#include <asm/amigaints.h>
+#include <asm/amigayle.h>
+#include <asm/ide.h>

Ditto.

drivers/ata/pata_gayle.c line 105

Quoted 9 lines
drivers/ata/pata_gayle.c new file +8 -0
+static bool pata_gayle_irq_check(struct ata_port *ap)
+{
+       u8 ch;
+
+       ch = z_readb((unsigned long)ap->private_data);
 
+       if (!(ch & GAYLE_IRQ_IDE))
+               return false;
+       return true;

return !!(ch & GAYLE_IRQ_IDE);

?

drivers/ata/pata_gayle.c line 142

Quoted 7 lines
drivers/ata/pata_gayle.c new file +5 -0
+}
 
+static int __init pata_gayle_init_one(struct platform_device *pdev)
+{
 
+       pr_info(DRV_NAME ": Amiga Gayle IDE controller (A%u style)\n",
+               pdata->explicit_ack ? 1200 : 4000);

What's wrong with dev_info() ?

Quoted 4 lines
drivers/ata/pata_gayle.c new file +3 -0
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
+       if (!res)
+               return -ENODEV;

drivers/ata/pata_gayle.c line 169

Quoted 10 lines
drivers/ata/pata_gayle.c new file +8 -0
 
+
+       if (!devm_request_mem_region(&pdev->dev, res->start,
+                                    resource_size(res), DRV_NAME)) {
+               pr_err(DRV_NAME ": resources busy\n");
+               return -EBUSY;
+       }
+
 
+       base = ZTWO_VADDR(pdata->base);

Hmm... Can't you use devm_ioremap_resources() to get the virtual address for I/O ?

drivers/ata/pata_gayle.c line 187

Quoted 4 lines
drivers/ata/pata_gayle.c new file +4 -0
+       ap->private_data = (void *)ZTWO_VADDR(pdata->irqport);
+
+       ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", (unsigned long)base,
+                     (unsigned long)base + GAYLE_CONTROL);

When you use explicit casting in printf() you are doing in 99.9% cases something wrong.

Quoted 1 line

+ /* activate */

Noise.

Quoted 6 lines
drivers/ata/pata_gayle.c new file +5 -0
+       ret = ata_host_activate(host, IRQ_AMIGA_PORTS, ata_sff_interrupt,
+                               IRQF_SHARED, &pata_gayle_sht);
+       if (ret)
+               return ret;
 
+}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Hi Andy,

Quoted 6 lines · Andy Shevchenko
Quoted 1 line · Bartlomiej Zolnierkiewicz

+ base = ZTWO_VADDR(pdata->base);

Hmm... Can't you use devm_ioremap_resources() to get the virtual address for I/O ?

Zorro II address space is always mapped, and address conversion done through ZTWO_VADDR()/ZTWO_PADDR().

Quoted 7 lines

drivers/ata/pata_gayle.c line 187

Quoted 4 lines
drivers/ata/pata_gayle.c new file +4 -0
+       ap->private_data = (void *)ZTWO_VADDR(pdata->irqport);
+
+       ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", (unsigned long)base,
+                     (unsigned long)base + GAYLE_CONTROL);

When you use explicit casting in printf() you are doing in 99.9% cases something wrong.

Indeed. This should print the physical addresses, using pdata->base instead of base.

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