memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP
[linux-2.6.git] / drivers / ata / pata_palmld.c
blob5ff31b68135c5c9a01c2b3166ff7f3cfb1a5cd71
1 /*
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 gpio palmld_hdd_gpios[] = {
37 { GPIO_NR_PALMLD_IDE_PWEN, GPIOF_INIT_HIGH, "HDD Power" },
38 { GPIO_NR_PALMLD_IDE_RESET, GPIOF_INIT_LOW, "HDD Reset" },
41 static struct scsi_host_template palmld_sht = {
42 ATA_PIO_SHT(DRV_NAME),
45 static struct ata_port_operations palmld_port_ops = {
46 .inherits = &ata_sff_port_ops,
47 .sff_data_xfer = ata_sff_data_xfer_noirq,
48 .cable_detect = ata_cable_40wire,
51 static __devinit int palmld_pata_probe(struct platform_device *pdev)
53 struct ata_host *host;
54 struct ata_port *ap;
55 void __iomem *mem;
56 int ret;
58 /* allocate host */
59 host = ata_host_alloc(&pdev->dev, 1);
60 if (!host) {
61 ret = -ENOMEM;
62 goto err1;
65 /* remap drive's physical memory address */
66 mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000);
67 if (!mem) {
68 ret = -ENOMEM;
69 goto err1;
72 /* request and activate power GPIO, IRQ GPIO */
73 ret = gpio_request_array(palmld_hdd_gpios,
74 ARRAY_SIZE(palmld_hdd_gpios));
75 if (ret)
76 goto err1;
78 /* reset the drive */
79 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0);
80 msleep(30);
81 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 1);
82 msleep(30);
84 /* setup the ata port */
85 ap = host->ports[0];
86 ap->ops = &palmld_port_ops;
87 ap->pio_mask = ATA_PIO4;
88 ap->flags |= 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;
95 /* start the port */
96 ata_sff_std_ports(&ap->ioaddr);
98 /* activate host */
99 ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING,
100 &palmld_sht);
101 if (ret)
102 goto err2;
104 return ret;
106 err2:
107 gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
108 err1:
109 return ret;
112 static __devexit int palmld_pata_remove(struct platform_device *dev)
114 struct ata_host *host = platform_get_drvdata(dev);
116 ata_host_detach(host);
118 /* power down the HDD */
119 gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0);
121 gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
123 return 0;
126 static struct platform_driver palmld_pata_platform_driver = {
127 .driver = {
128 .name = DRV_NAME,
129 .owner = THIS_MODULE,
131 .probe = palmld_pata_probe,
132 .remove = __devexit_p(palmld_pata_remove),
135 module_platform_driver(palmld_pata_platform_driver);
137 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
138 MODULE_DESCRIPTION("PalmLD PATA driver");
139 MODULE_LICENSE("GPL");
140 MODULE_ALIAS("platform:" DRV_NAME);