linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Jeff Garzik <jgarzik@pobox.com>
Cc: linux-arm-kernel@lists.arm.linux.org.uk,
	Eric Miao <eric.y.miao@gmail.com>,
	linux-ide@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCH 4/6] PalmLD IDE
Date: Tue, 21 Apr 2009 02:05:59 +0200	[thread overview]
Message-ID: <200904210205.59971.marek.vasut@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 44 bytes --]

Here it is, I hope it's not too rotten yet.

[-- Attachment #2: 0004-PalmLD-IDE-support.patch --]
[-- Type: text/x-diff, Size: 5500 bytes --]

From 8881f9cbf66a3050de328f6c020f864ca04c1e9b Mon Sep 17 00:00:00 2001
From: Marek <marek.vasut@gmail.com>
Date: Sat, 16 Aug 2008 16:25:34 +0200
Subject: [PATCH] PalmLD: IDE support
 Support for Palm LifeDrive's internal harddrive

---
 drivers/ata/Kconfig       |    9 +++
 drivers/ata/Makefile      |    1 +
 drivers/ata/pata_palmld.c |  145 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 155 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/pata_palmld.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ae84949..8e43d11 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -533,6 +533,15 @@ config PATA_OPTIDMA
 
 	  If unsure, say N.
 
+config PATA_PALMLD
+	tristate "Palm LifeDrive PATA support"
+	depends on MACH_PALMLD
+	help
+	  This option enables support for Palm LifeDrive's internal ATA
+	  port via the new ATA layer.
+
+	  If unsure, say N.
+
 config PATA_PCMCIA
 	tristate "PCMCIA PATA support"
 	depends on PCMCIA
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 674965f..2b393c9 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_PATA_MPC52xx)	+= pata_mpc52xx.o
 obj-$(CONFIG_PATA_MARVELL)	+= pata_marvell.o
 obj-$(CONFIG_PATA_MPIIX)	+= pata_mpiix.o
 obj-$(CONFIG_PATA_OLDPIIX)	+= pata_oldpiix.o
+obj-$(CONFIG_PATA_PALMLD)	+= pata_palmld.o
 obj-$(CONFIG_PATA_PCMCIA)	+= pata_pcmcia.o
 obj-$(CONFIG_PATA_PDC2027X)	+= pata_pdc2027x.o
 obj-$(CONFIG_PATA_PDC_OLD)	+= pata_pdc202xx_old.o
diff --git a/drivers/ata/pata_palmld.c b/drivers/ata/pata_palmld.c
new file mode 100644
index 0000000..f0693f8
--- /dev/null
+++ b/drivers/ata/pata_palmld.c
@@ -0,0 +1,145 @@
+/*
+ * drivers/ata/pata_palmld.c
+ *
+ * Driver for IDE channel in Palm LifeDrive
+ *
+ * Based on research of:
+ *		Alex Osborne <ato@meshy.org>
+ *
+ * Rewrite for mainline:
+ *		Marek Vasut <marek.vasut@gmail.com>
+ *
+ * Rewritten version based on pata_ixp4xx_cf.c:
+ * ixp4xx PATA/Compact Flash driver
+ * Copyright (C) 2006-07 Tower Technologies
+ * Author: Alessandro Zummo <a.zummo@towertech.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/libata.h>
+#include <linux/irq.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+
+#include <scsi/scsi_host.h>
+#include <mach/palmld.h>
+
+#define DRV_NAME "pata_palmld"
+
+static struct scsi_host_template palmld_sht = {
+	ATA_PIO_SHT(DRV_NAME),
+};
+
+static struct ata_port_operations palmld_port_ops = {
+	.inherits		= &ata_sff_port_ops,
+	.sff_data_xfer		= ata_sff_data_xfer_noirq,
+	.cable_detect		= ata_cable_40wire,
+};
+
+static __devinit int palmld_pata_probe(struct platform_device *pdev)
+{
+	struct ata_host *host;
+	struct ata_port *ap;
+	void __iomem *mem;
+	int ret;
+
+	/* allocate host */
+	host = ata_host_alloc(&pdev->dev, 1);
+	if (!host)
+		return -ENOMEM;
+
+	/* remap drive's physical memory address */
+	mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000);
+	if (!mem)
+		return -ENOMEM;
+
+	/* request and activate power GPIO, IRQ GPIO */
+	ret = gpio_request(GPIO_NR_PALMLD_IDE_PWEN, "HDD PWR");
+	if (ret)
+		goto err1;
+	ret = gpio_direction_output(GPIO_NR_PALMLD_IDE_PWEN, 1);
+	if (ret)
+		goto err2;
+
+	ret = gpio_request(GPIO_NR_PALMLD_IDE_IRQ, "HDD IRQ");
+	if (ret)
+		goto err2;
+	ret = gpio_direction_input(GPIO_NR_PALMLD_IDE_IRQ);
+	if (ret)
+		goto err3;
+
+	/* we'd better wait for drive's ready signal here
+	  (if we knew where it will come from) */
+	msleep(300);
+
+	/* setup the ata port */
+	ap = host->ports[0];
+	ap->ops	= &palmld_port_ops;
+	ap->pio_mask = ATA_PIO4;
+	ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_NO_ATAPI;
+
+	/* memory mapping voodoo */
+	ap->ioaddr.cmd_addr = mem + 0x10;
+	ap->ioaddr.altstatus_addr = mem + 0xe;
+	ap->ioaddr.ctl_addr = mem + 0xe;
+
+	/* start the port */
+	ata_sff_std_ports(&ap->ioaddr);
+
+	/* activate host */
+	return ata_host_activate(host, gpio_to_irq(GPIO_NR_PALMLD_IDE_IRQ),
+					ata_sff_interrupt, IRQF_TRIGGER_RISING,
+					&palmld_sht);
+err3:
+	gpio_free(GPIO_NR_PALMLD_IDE_IRQ);
+err2:
+	gpio_free(GPIO_NR_PALMLD_IDE_PWEN);
+err1:
+	return ret;
+}
+
+static __devexit int palmld_pata_remove(struct platform_device *dev)
+{
+	struct ata_host *host = platform_get_drvdata(dev);
+
+	ata_host_detach(host);
+
+	gpio_free(GPIO_NR_PALMLD_IDE_PWEN);
+	gpio_free(GPIO_NR_PALMLD_IDE_IRQ);
+
+	return 0;
+}
+
+static struct platform_driver palmld_pata_platform_driver = {
+	.driver	 = {
+		.name   = DRV_NAME,
+		.owner  = THIS_MODULE,
+	},
+	.probe		= palmld_pata_probe,
+	.remove		= __devexit_p(palmld_pata_remove),
+};
+
+static int __init palmld_pata_init(void)
+{
+	return platform_driver_register(&palmld_pata_platform_driver);
+}
+
+static void __exit palmld_pata_exit(void)
+{
+	platform_driver_unregister(&palmld_pata_platform_driver);
+}
+
+MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
+MODULE_DESCRIPTION("PalmLD PATA driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" DRV_NAME);
+
+module_init(palmld_pata_init);
+module_exit(palmld_pata_exit);
-- 
1.5.6


             reply	other threads:[~2009-04-21  0:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-21  0:05 Marek Vasut [this message]
2009-04-21 14:27 ` [PATCH 4/6] PalmLD IDE Alan Cox
2009-04-21 14:52   ` Marek Vasut
2009-04-21 15:19     ` Alan Cox
2009-04-21 17:44       ` Marek Vasut
2009-04-21 19:35         ` Alan Cox
2009-04-21 19:38           ` Jeff Garzik
  -- strict thread matches above, loose matches on Subject: below --
2009-03-22 21:23 Marek Vasut
2009-04-19 16:14 ` Marek Vasut
2009-04-20 20:38   ` Bartlomiej Zolnierkiewicz
2009-04-20 20:53     ` Marek Vasut
2009-04-20 21:01       ` Bartlomiej Zolnierkiewicz
2009-04-20 21:17       ` Alan Cox
2009-04-21  4:02 ` Eric Miao
2009-04-21 14:01   ` Marek Vasut
     [not found] <200808132252.23732.marek.vasut@gmail.com>
     [not found] ` <20080816090803.GI5946@flint.arm.linux.org.uk>
2008-08-16 14:30   ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200904210205.59971.marek.vasut@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=eric.y.miao@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).