2 * drivers/ata/pata_palmld.c
4 * Driver for IDE channel in Palm LifeDrive
6 * Based on research of:
7 * Alex Osborne <ato@meshy.org>
9 * Rewrite for mainline:
10 * Marek Vasut <marek.vasut@gmail.com>
12 * Rewritten version based on pata_ixp4xx_cf.c:
13 * ixp4xx PATA/Compact Flash driver
14 * Copyright (C) 2006-07 Tower Technologies
15 * Author: Alessandro Zummo <a.zummo@towertech.it>
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License version 2 as
19 * published by the Free Software Foundation.
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/libata.h>
26 #include <linux/irq.h>
27 #include <linux/platform_device.h>
28 #include <linux/delay.h>
29 #include <linux/gpio/consumer.h>
31 #include <scsi/scsi_host.h>
32 #include <mach/palmld.h>
34 #define DRV_NAME "pata_palmld"
36 static struct gpio_desc *palmld_pata_power;
38 static struct scsi_host_template palmld_sht = {
39 ATA_PIO_SHT(DRV_NAME),
42 static struct ata_port_operations palmld_port_ops = {
43 .inherits = &ata_sff_port_ops,
44 .sff_data_xfer = ata_sff_data_xfer32,
45 .cable_detect = ata_cable_40wire,
48 static int palmld_pata_probe(struct platform_device *pdev)
50 struct ata_host *host;
53 struct device *dev = &pdev->dev;
54 struct gpio_desc *reset;
58 host = ata_host_alloc(dev, 1);
62 /* remap drive's physical memory address */
63 mem = devm_ioremap(dev, PALMLD_IDE_PHYS, 0x1000);
67 /* request and activate power and reset GPIOs */
68 palmld_pata_power = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH);
69 if (IS_ERR(palmld_pata_power))
70 return PTR_ERR(palmld_pata_power);
71 reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
73 gpiod_set_value(palmld_pata_power, 0);
74 return PTR_ERR(reset);
77 /* Assert reset to reset the drive */
78 gpiod_set_value(reset, 1);
80 gpiod_set_value(reset, 0);
83 /* setup the ata port */
85 ap->ops = &palmld_port_ops;
86 ap->pio_mask = ATA_PIO4;
87 ap->flags |= ATA_FLAG_PIO_POLLING;
89 /* memory mapping voodoo */
90 ap->ioaddr.cmd_addr = mem + 0x10;
91 ap->ioaddr.altstatus_addr = mem + 0xe;
92 ap->ioaddr.ctl_addr = mem + 0xe;
95 ata_sff_std_ports(&ap->ioaddr);
98 ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING,
100 /* power down on failure */
102 gpiod_set_value(palmld_pata_power, 0);
106 static int palmld_pata_remove(struct platform_device *dev)
108 ata_platform_remove_one(dev);
110 /* power down the HDD */
111 gpiod_set_value(palmld_pata_power, 0);
116 static struct platform_driver palmld_pata_platform_driver = {
120 .probe = palmld_pata_probe,
121 .remove = palmld_pata_remove,
124 module_platform_driver(palmld_pata_platform_driver);
126 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
127 MODULE_DESCRIPTION("PalmLD PATA driver");
128 MODULE_LICENSE("GPL");
129 MODULE_ALIAS("platform:" DRV_NAME);