aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-pxa/palm27x.h2
-rw-r--r--arch/arm/mach-pxa/palmld.c12
-rw-r--r--drivers/ata/pata_palmld.c58
3 files changed, 39 insertions, 33 deletions
diff --git a/arch/arm/mach-pxa/palm27x.h b/arch/arm/mach-pxa/palm27x.h
index d4eac3d6ffb5..3316ed2016f3 100644
--- a/arch/arm/mach-pxa/palm27x.h
+++ b/arch/arm/mach-pxa/palm27x.h
@@ -12,6 +12,8 @@
12#ifndef __INCLUDE_MACH_PALM27X__ 12#ifndef __INCLUDE_MACH_PALM27X__
13#define __INCLUDE_MACH_PALM27X__ 13#define __INCLUDE_MACH_PALM27X__
14 14
15#include <linux/gpio/machine.h>
16
15#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 17#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
16extern void __init palm27x_mmc_init(int detect, int ro, int power, 18extern void __init palm27x_mmc_init(int detect, int ro, int power,
17 int power_inverted); 19 int power_inverted);
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 980f2847f5b5..a37ceec22903 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -288,8 +288,20 @@ static struct platform_device palmld_ide_device = {
288 .id = -1, 288 .id = -1,
289}; 289};
290 290
291static struct gpiod_lookup_table palmld_ide_gpio_table = {
292 .dev_id = "pata_palmld",
293 .table = {
294 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_PWEN,
295 "power", GPIO_ACTIVE_HIGH),
296 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_RESET,
297 "reset", GPIO_ACTIVE_LOW),
298 { },
299 },
300};
301
291static void __init palmld_ide_init(void) 302static void __init palmld_ide_init(void)
292{ 303{
304 gpiod_add_lookup_table(&palmld_ide_gpio_table);
293 platform_device_register(&palmld_ide_device); 305 platform_device_register(&palmld_ide_device);
294} 306}
295#else 307#else
diff --git a/drivers/ata/pata_palmld.c b/drivers/ata/pata_palmld.c
index d071ab6864a8..e2933c324d41 100644
--- a/drivers/ata/pata_palmld.c
+++ b/drivers/ata/pata_palmld.c
@@ -26,17 +26,14 @@
26#include <linux/irq.h> 26#include <linux/irq.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/gpio.h> 29#include <linux/gpio/consumer.h>
30 30
31#include <scsi/scsi_host.h> 31#include <scsi/scsi_host.h>
32#include <mach/palmld.h> 32#include <mach/palmld.h>
33 33
34#define DRV_NAME "pata_palmld" 34#define DRV_NAME "pata_palmld"
35 35
36static struct gpio palmld_hdd_gpios[] = { 36static struct gpio_desc *palmld_pata_power;
37 { GPIO_NR_PALMLD_IDE_PWEN, GPIOF_INIT_HIGH, "HDD Power" },
38 { GPIO_NR_PALMLD_IDE_RESET, GPIOF_INIT_LOW, "HDD Reset" },
39};
40 37
41static struct scsi_host_template palmld_sht = { 38static struct scsi_host_template palmld_sht = {
42 ATA_PIO_SHT(DRV_NAME), 39 ATA_PIO_SHT(DRV_NAME),
@@ -53,32 +50,34 @@ static int palmld_pata_probe(struct platform_device *pdev)
53 struct ata_host *host; 50 struct ata_host *host;
54 struct ata_port *ap; 51 struct ata_port *ap;
55 void __iomem *mem; 52 void __iomem *mem;
53 struct device *dev = &pdev->dev;
54 struct gpio_desc *reset;
56 int ret; 55 int ret;
57 56
58 /* allocate host */ 57 /* allocate host */
59 host = ata_host_alloc(&pdev->dev, 1); 58 host = ata_host_alloc(dev, 1);
60 if (!host) { 59 if (!host)
61 ret = -ENOMEM; 60 return -ENOMEM;
62 goto err1;
63 }
64 61
65 /* remap drive's physical memory address */ 62 /* remap drive's physical memory address */
66 mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000); 63 mem = devm_ioremap(dev, PALMLD_IDE_PHYS, 0x1000);
67 if (!mem) { 64 if (!mem)
68 ret = -ENOMEM; 65 return -ENOMEM;
69 goto err1; 66
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);
72 if (IS_ERR(reset)) {
73 gpiod_set_value(palmld_pata_power, 0);
74 return PTR_ERR(reset);
70 } 75 }
71 76
72 /* request and activate power GPIO, IRQ GPIO */ 77 /* Assert reset to reset the drive */
73 ret = gpio_request_array(palmld_hdd_gpios, 78 gpiod_set_value(reset, 1);
74 ARRAY_SIZE(palmld_hdd_gpios));
75 if (ret)
76 goto err1;
77
78 /* reset the drive */
79 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0);
80 msleep(30); 79 msleep(30);
81 gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 1); 80 gpiod_set_value(reset, 0);
82 msleep(30); 81 msleep(30);
83 82
84 /* setup the ata port */ 83 /* setup the ata port */
@@ -98,14 +97,9 @@ static int palmld_pata_probe(struct platform_device *pdev)
98 /* activate host */ 97 /* activate host */
99 ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING, 98 ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING,
100 &palmld_sht); 99 &palmld_sht);
100 /* power down on failure */
101 if (ret) 101 if (ret)
102 goto err2; 102 gpiod_set_value(palmld_pata_power, 0);
103
104 return ret;
105
106err2:
107 gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
108err1:
109 return ret; 103 return ret;
110} 104}
111 105
@@ -114,9 +108,7 @@ static int palmld_pata_remove(struct platform_device *dev)
114 ata_platform_remove_one(dev); 108 ata_platform_remove_one(dev);
115 109
116 /* power down the HDD */ 110 /* power down the HDD */
117 gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0); 111 gpiod_set_value(palmld_pata_power, 0);
118
119 gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
120 112
121 return 0; 113 return 0;
122} 114}