Skip to content

Commit

Permalink
Merge tag 'for-4.21/libata-20181221' of git://git.kernel.dk/linux-block
Browse files Browse the repository at this point in the history
Pull libata updates from Jens Axboe:
 "Here are the libata changes for this merge window. Nothing major in
  here. This contains:

   - GPIO descriptor conversions (Linus Walleij)

   - rcar deferred probing fix (Sergei Shtylyov)"

* tag 'for-4.21/libata-20181221' of git://git.kernel.dk/linux-block:
  sata_rcar: fix deferred probing
  ata: palmld: Introduce state container
  ata: palmld: Convert to GPIO descriptors
  ata: rb532_cf: Convert to use GPIO descriptors
  ata: sata_highbank: Convert to use GPIO descriptors
  ata: pxa: Drop <linux/gpio.h> include
  • Loading branch information
torvalds committed Dec 28, 2018
2 parents 956eb6c + 9f83cfd commit fe2b0cd
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 105 deletions.
2 changes: 2 additions & 0 deletions arch/arm/mach-pxa/palm27x.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef __INCLUDE_MACH_PALM27X__
#define __INCLUDE_MACH_PALM27X__

#include <linux/gpio/machine.h>

#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
extern void __init palm27x_mmc_init(int detect, int ro, int power,
int power_inverted);
Expand Down
12 changes: 12 additions & 0 deletions arch/arm/mach-pxa/palmld.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,20 @@ static struct platform_device palmld_ide_device = {
.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)
{
gpiod_add_lookup_table(&palmld_ide_gpio_table);
platform_device_register(&palmld_ide_device);
}
#else
Expand Down
6 changes: 0 additions & 6 deletions arch/mips/include/asm/mach-rc32434/rb.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ struct korina_device {
struct net_device *dev;
};

struct cf_device {
int gpio_pin;
void *dev;
struct gendisk *gd;
};

struct mpmc_device {
unsigned char state;
spinlock_t lock;
Expand Down
12 changes: 9 additions & 3 deletions arch/mips/rb532/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/mtd/platnand.h>
#include <linux/mtd/mtd.h>
#include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/gpio_keys.h>
#include <linux/input.h>
#include <linux/serial_8250.h>
Expand Down Expand Up @@ -127,14 +128,18 @@ static struct resource cf_slot0_res[] = {
}
};

static struct cf_device cf_slot0_data = {
.gpio_pin = CF_GPIO_NUM
static struct gpiod_lookup_table cf_slot0_gpio_table = {
.dev_id = "pata-rb532-cf",
.table = {
GPIO_LOOKUP("gpio0", CF_GPIO_NUM,
NULL, GPIO_ACTIVE_HIGH),
{ },
},
};

static struct platform_device cf_slot0 = {
.id = -1,
.name = "pata-rb532-cf",
.dev.platform_data = &cf_slot0_data,
.resource = cf_slot0_res,
.num_resources = ARRAY_SIZE(cf_slot0_res),
};
Expand Down Expand Up @@ -305,6 +310,7 @@ static int __init plat_setup_devices(void)

dev_set_drvdata(&korina_dev0.dev, &korina_dev0_data);

gpiod_add_lookup_table(&cf_slot0_gpio_table);
return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs));
}

Expand Down
83 changes: 44 additions & 39 deletions drivers/ata/pata_palmld.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>

#include <scsi/scsi_host.h>
#include <mach/palmld.h>

#define DRV_NAME "pata_palmld"

static struct gpio palmld_hdd_gpios[] = {
{ GPIO_NR_PALMLD_IDE_PWEN, GPIOF_INIT_HIGH, "HDD Power" },
{ GPIO_NR_PALMLD_IDE_RESET, GPIOF_INIT_LOW, "HDD Reset" },
struct palmld_pata {
struct ata_host *host;
struct gpio_desc *power;
struct gpio_desc *reset;
};

static struct scsi_host_template palmld_sht = {
Expand All @@ -50,39 +51,44 @@ static struct ata_port_operations palmld_port_ops = {

static int palmld_pata_probe(struct platform_device *pdev)
{
struct ata_host *host;
struct palmld_pata *lda;
struct ata_port *ap;
void __iomem *mem;
struct device *dev = &pdev->dev;
int ret;

lda = devm_kzalloc(dev, sizeof(*lda), GFP_KERNEL);
if (!lda)
return -ENOMEM;

/* allocate host */
host = ata_host_alloc(&pdev->dev, 1);
if (!host) {
ret = -ENOMEM;
goto err1;
}
lda->host = ata_host_alloc(dev, 1);
if (!lda->host)
return -ENOMEM;

/* remap drive's physical memory address */
mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000);
if (!mem) {
ret = -ENOMEM;
goto err1;
mem = devm_ioremap(dev, PALMLD_IDE_PHYS, 0x1000);
if (!mem)
return -ENOMEM;

/* request and activate power and reset GPIOs */
lda->power = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH);
if (IS_ERR(lda->power))
return PTR_ERR(lda->power);
lda->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(lda->reset)) {
gpiod_set_value(lda->power, 0);
return PTR_ERR(lda->reset);
}

/* request and activate power GPIO, IRQ GPIO */
ret = gpio_request_array(palmld_hdd_gpios,
ARRAY_SIZE(palmld_hdd_gpios));
if (ret)
goto err1;

/* reset the drive */
gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0);
/* Assert reset to reset the drive */
gpiod_set_value(lda->reset, 1);
msleep(30);
gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 1);
gpiod_set_value(lda->reset, 0);
msleep(30);

/* setup the ata port */
ap = host->ports[0];
ap = lda->host->ports[0];
ap->ops = &palmld_port_ops;
ap->pio_mask = ATA_PIO4;
ap->flags |= ATA_FLAG_PIO_POLLING;
Expand All @@ -96,27 +102,26 @@ static int palmld_pata_probe(struct platform_device *pdev)
ata_sff_std_ports(&ap->ioaddr);

/* activate host */
ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING,
&palmld_sht);
if (ret)
goto err2;

return ret;
ret = ata_host_activate(lda->host, 0, NULL, IRQF_TRIGGER_RISING,
&palmld_sht);
/* power down on failure */
if (ret) {
gpiod_set_value(lda->power, 0);
return ret;
}

err2:
gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
err1:
return ret;
platform_set_drvdata(pdev, lda);
return 0;
}

static int palmld_pata_remove(struct platform_device *dev)
static int palmld_pata_remove(struct platform_device *pdev)
{
ata_platform_remove_one(dev);
struct palmld_pata *lda = platform_get_drvdata(pdev);

/* power down the HDD */
gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0);
ata_platform_remove_one(pdev);

gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
/* power down the HDD */
gpiod_set_value(lda->power, 0);

return 0;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/ata/pata_pxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <linux/libata.h>
#include <linux/platform_device.h>
#include <linux/dmaengine.h>
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/completion.h>

Expand Down
45 changes: 10 additions & 35 deletions drivers/ata/pata_rb532_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <linux/io.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>

#include <linux/libata.h>
#include <scsi/scsi_host.h>
Expand All @@ -49,7 +49,7 @@

struct rb532_cf_info {
void __iomem *iobase;
unsigned int gpio_line;
struct gpio_desc *gpio_line;
unsigned int irq;
};

Expand All @@ -60,7 +60,7 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
struct ata_host *ah = dev_instance;
struct rb532_cf_info *info = ah->private_data;

if (gpio_get_value(info->gpio_line)) {
if (gpiod_get_value(info->gpio_line)) {
irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW);
ata_sff_interrupt(info->irq, dev_instance);
} else {
Expand Down Expand Up @@ -106,10 +106,9 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
static int rb532_pata_driver_probe(struct platform_device *pdev)
{
int irq;
int gpio;
struct gpio_desc *gpiod;
struct resource *res;
struct ata_host *ah;
struct cf_device *pdata;
struct rb532_cf_info *info;
int ret;

Expand All @@ -125,23 +124,12 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
return -ENOENT;
}

pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
dev_err(&pdev->dev, "no platform data specified\n");
return -EINVAL;
}

gpio = pdata->gpio_pin;
if (gpio < 0) {
gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN);
if (IS_ERR(gpiod)) {
dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq);
return -ENOENT;
}

ret = gpio_request(gpio, DRV_NAME);
if (ret) {
dev_err(&pdev->dev, "GPIO request failed\n");
return ret;
return PTR_ERR(gpiod);
}
gpiod_set_consumer_name(gpiod, DRV_NAME);

/* allocate host */
ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS);
Expand All @@ -153,34 +141,22 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
return -ENOMEM;

ah->private_data = info;
info->gpio_line = gpio;
info->gpio_line = gpiod;
info->irq = irq;

info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
resource_size(res));
if (!info->iobase)
return -ENOMEM;

ret = gpio_direction_input(gpio);
if (ret) {
dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n",
ret);
goto err_free_gpio;
}

rb532_pata_setup_ports(ah);

ret = ata_host_activate(ah, irq, rb532_pata_irq_handler,
IRQF_TRIGGER_LOW, &rb532_pata_sht);
if (ret)
goto err_free_gpio;
return ret;

return 0;

err_free_gpio:
gpio_free(gpio);

return ret;
}

static int rb532_pata_driver_remove(struct platform_device *pdev)
Expand All @@ -189,7 +165,6 @@ static int rb532_pata_driver_remove(struct platform_device *pdev)
struct rb532_cf_info *info = ah->private_data;

ata_host_detach(ah);
gpio_free(info->gpio_line);

return 0;
}
Expand Down
Loading

0 comments on commit fe2b0cd

Please sign in to comment.