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.h>
31 #include <scsi/scsi_host.h>
32 #include <mach/palmld.h>
34 #define DRV_NAME "pata_palmld"
36 static struct scsi_host_template palmld_sht
= {
37 ATA_PIO_SHT(DRV_NAME
),
40 static struct ata_port_operations palmld_port_ops
= {
41 .inherits
= &ata_sff_port_ops
,
42 .sff_data_xfer
= ata_sff_data_xfer_noirq
,
43 .cable_detect
= ata_cable_40wire
,
46 static __devinit
int palmld_pata_probe(struct platform_device
*pdev
)
48 struct ata_host
*host
;
54 host
= ata_host_alloc(&pdev
->dev
, 1);
58 /* remap drive's physical memory address */
59 mem
= devm_ioremap(&pdev
->dev
, PALMLD_IDE_PHYS
, 0x1000);
63 /* request and activate power GPIO, IRQ GPIO */
64 ret
= gpio_request(GPIO_NR_PALMLD_IDE_PWEN
, "HDD PWR");
67 ret
= gpio_direction_output(GPIO_NR_PALMLD_IDE_PWEN
, 1);
71 ret
= gpio_request(GPIO_NR_PALMLD_IDE_RESET
, "HDD RST");
74 ret
= gpio_direction_output(GPIO_NR_PALMLD_IDE_RESET
, 0);
79 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET
, 0);
81 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET
, 1);
84 /* setup the ata port */
86 ap
->ops
= &palmld_port_ops
;
87 ap
->pio_mask
= ATA_PIO4
;
88 ap
->flags
|= ATA_FLAG_MMIO
| ATA_FLAG_NO_LEGACY
| ATA_FLAG_PIO_POLLING
;
90 /* memory mapping voodoo */
91 ap
->ioaddr
.cmd_addr
= mem
+ 0x10;
92 ap
->ioaddr
.altstatus_addr
= mem
+ 0xe;
93 ap
->ioaddr
.ctl_addr
= mem
+ 0xe;
96 ata_sff_std_ports(&ap
->ioaddr
);
99 return ata_host_activate(host
, 0, NULL
, IRQF_TRIGGER_RISING
,
103 gpio_free(GPIO_NR_PALMLD_IDE_RESET
);
105 gpio_free(GPIO_NR_PALMLD_IDE_PWEN
);
110 static __devexit
int palmld_pata_remove(struct platform_device
*dev
)
112 struct ata_host
*host
= platform_get_drvdata(dev
);
114 ata_host_detach(host
);
116 /* power down the HDD */
117 gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN
, 0);
119 gpio_free(GPIO_NR_PALMLD_IDE_RESET
);
120 gpio_free(GPIO_NR_PALMLD_IDE_PWEN
);
125 static struct platform_driver palmld_pata_platform_driver
= {
128 .owner
= THIS_MODULE
,
130 .probe
= palmld_pata_probe
,
131 .remove
= __devexit_p(palmld_pata_remove
),
134 static int __init
palmld_pata_init(void)
136 return platform_driver_register(&palmld_pata_platform_driver
);
139 static void __exit
palmld_pata_exit(void)
141 platform_driver_unregister(&palmld_pata_platform_driver
);
144 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
145 MODULE_DESCRIPTION("PalmLD PATA driver");
146 MODULE_LICENSE("GPL");
147 MODULE_ALIAS("platform:" DRV_NAME
);
149 module_init(palmld_pata_init
);
150 module_exit(palmld_pata_exit
);