Commit f43e4b00 authored by Linus Walleij's avatar Linus Walleij Committed by Jens Axboe

ata: palmld: Convert to GPIO descriptors

Instead of passing GPIO numbers directly to the PalmLD
ATA driver, pass GPIO descriptors from the board file and
handle these in the driver.

Cc: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent cd56f35e
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#ifndef __INCLUDE_MACH_PALM27X__ #ifndef __INCLUDE_MACH_PALM27X__
#define __INCLUDE_MACH_PALM27X__ #define __INCLUDE_MACH_PALM27X__
#include <linux/gpio/machine.h>
#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
extern void __init palm27x_mmc_init(int detect, int ro, int power, extern void __init palm27x_mmc_init(int detect, int ro, int power,
int power_inverted); int power_inverted);
......
...@@ -288,8 +288,20 @@ static struct platform_device palmld_ide_device = { ...@@ -288,8 +288,20 @@ static struct platform_device palmld_ide_device = {
.id = -1, .id = -1,
}; };
static struct gpiod_lookup_table palmld_ide_gpio_table = {
.dev_id = "pata_palmld",
.table = {
GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_PWEN,
"power", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_RESET,
"reset", GPIO_ACTIVE_LOW),
{ },
},
};
static void __init palmld_ide_init(void) static void __init palmld_ide_init(void)
{ {
gpiod_add_lookup_table(&palmld_ide_gpio_table);
platform_device_register(&palmld_ide_device); platform_device_register(&palmld_ide_device);
} }
#else #else
......
...@@ -26,17 +26,14 @@ ...@@ -26,17 +26,14 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <mach/palmld.h> #include <mach/palmld.h>
#define DRV_NAME "pata_palmld" #define DRV_NAME "pata_palmld"
static struct gpio palmld_hdd_gpios[] = { static struct gpio_desc *palmld_pata_power;
{ GPIO_NR_PALMLD_IDE_PWEN, GPIOF_INIT_HIGH, "HDD Power" },
{ GPIO_NR_PALMLD_IDE_RESET, GPIOF_INIT_LOW, "HDD Reset" },
};
static struct scsi_host_template palmld_sht = { static struct scsi_host_template palmld_sht = {
ATA_PIO_SHT(DRV_NAME), ATA_PIO_SHT(DRV_NAME),
...@@ -53,32 +50,34 @@ static int palmld_pata_probe(struct platform_device *pdev) ...@@ -53,32 +50,34 @@ static int palmld_pata_probe(struct platform_device *pdev)
struct ata_host *host; struct ata_host *host;
struct ata_port *ap; struct ata_port *ap;
void __iomem *mem; void __iomem *mem;
struct device *dev = &pdev->dev;
struct gpio_desc *reset;
int ret; int ret;
/* allocate host */ /* allocate host */
host = ata_host_alloc(&pdev->dev, 1); host = ata_host_alloc(dev, 1);
if (!host) { if (!host)
ret = -ENOMEM; return -ENOMEM;
goto err1;
}
/* remap drive's physical memory address */ /* remap drive's physical memory address */
mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000); mem = devm_ioremap(dev, PALMLD_IDE_PHYS, 0x1000);
if (!mem) { if (!mem)
ret = -ENOMEM; return -ENOMEM;
goto err1;
/* request and activate power and reset GPIOs */
palmld_pata_power = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH);
if (IS_ERR(palmld_pata_power))
return PTR_ERR(palmld_pata_power);
reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(reset)) {
gpiod_set_value(palmld_pata_power, 0);
return PTR_ERR(reset);
} }
/* request and activate power GPIO, IRQ GPIO */ /* Assert reset to reset the drive */
ret = gpio_request_array(palmld_hdd_gpios, gpiod_set_value(reset, 1);
ARRAY_SIZE(palmld_hdd_gpios));
if (ret)
goto err1;
/* reset the drive */
gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0);
msleep(30); msleep(30);
gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 1); gpiod_set_value(reset, 0);
msleep(30); msleep(30);
/* setup the ata port */ /* setup the ata port */
...@@ -98,14 +97,9 @@ static int palmld_pata_probe(struct platform_device *pdev) ...@@ -98,14 +97,9 @@ static int palmld_pata_probe(struct platform_device *pdev)
/* activate host */ /* activate host */
ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING, ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING,
&palmld_sht); &palmld_sht);
/* power down on failure */
if (ret) if (ret)
goto err2; gpiod_set_value(palmld_pata_power, 0);
return ret;
err2:
gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
err1:
return ret; return ret;
} }
...@@ -114,9 +108,7 @@ static int palmld_pata_remove(struct platform_device *dev) ...@@ -114,9 +108,7 @@ static int palmld_pata_remove(struct platform_device *dev)
ata_platform_remove_one(dev); ata_platform_remove_one(dev);
/* power down the HDD */ /* power down the HDD */
gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0); gpiod_set_value(palmld_pata_power, 0);
gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment