summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-11-20 02:47:32 -0500
committerJens Axboe <axboe@kernel.dk>2018-12-04 19:15:25 -0500
commitcd56f35e52d9496cbf5c85d27af9bdb064bec8df (patch)
tree985a7967672952f22f971cc3f9f1d70a2a07773b
parent83a7faace12e1bca6f659e117cde85769385fe08 (diff)
ata: rb532_cf: Convert to use GPIO descriptors
Pass a GPIO descriptor for the device instead of a hardcoded GPIO number from the global GPIO numberspace. Use gpio descriptors throughout. Cut the now completely unused platform data for the CF slot. Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Waldemar Brodkorb <wbx@openadk.org> Cc: Matt Redfearn <matt.redfearn@mips.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--arch/mips/include/asm/mach-rc32434/rb.h6
-rw-r--r--arch/mips/rb532/devices.c12
-rw-r--r--drivers/ata/pata_rb532_cf.c45
3 files changed, 19 insertions, 44 deletions
diff --git a/arch/mips/include/asm/mach-rc32434/rb.h b/arch/mips/include/asm/mach-rc32434/rb.h
index aac8ce8902e7..5dfd4d66d6fc 100644
--- a/arch/mips/include/asm/mach-rc32434/rb.h
+++ b/arch/mips/include/asm/mach-rc32434/rb.h
@@ -71,12 +71,6 @@ struct korina_device {
71 struct net_device *dev; 71 struct net_device *dev;
72}; 72};
73 73
74struct cf_device {
75 int gpio_pin;
76 void *dev;
77 struct gendisk *gd;
78};
79
80struct mpmc_device { 74struct mpmc_device {
81 unsigned char state; 75 unsigned char state;
82 spinlock_t lock; 76 spinlock_t lock;
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 2b23ad640f39..828d8cc3a5df 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -23,6 +23,7 @@
23#include <linux/mtd/platnand.h> 23#include <linux/mtd/platnand.h>
24#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/gpio/machine.h>
26#include <linux/gpio_keys.h> 27#include <linux/gpio_keys.h>
27#include <linux/input.h> 28#include <linux/input.h>
28#include <linux/serial_8250.h> 29#include <linux/serial_8250.h>
@@ -127,14 +128,18 @@ static struct resource cf_slot0_res[] = {
127 } 128 }
128}; 129};
129 130
130static struct cf_device cf_slot0_data = { 131static struct gpiod_lookup_table cf_slot0_gpio_table = {
131 .gpio_pin = CF_GPIO_NUM 132 .dev_id = "pata-rb532-cf",
133 .table = {
134 GPIO_LOOKUP("gpio0", CF_GPIO_NUM,
135 NULL, GPIO_ACTIVE_HIGH),
136 { },
137 },
132}; 138};
133 139
134static struct platform_device cf_slot0 = { 140static struct platform_device cf_slot0 = {
135 .id = -1, 141 .id = -1,
136 .name = "pata-rb532-cf", 142 .name = "pata-rb532-cf",
137 .dev.platform_data = &cf_slot0_data,
138 .resource = cf_slot0_res, 143 .resource = cf_slot0_res,
139 .num_resources = ARRAY_SIZE(cf_slot0_res), 144 .num_resources = ARRAY_SIZE(cf_slot0_res),
140}; 145};
@@ -305,6 +310,7 @@ static int __init plat_setup_devices(void)
305 310
306 dev_set_drvdata(&korina_dev0.dev, &korina_dev0_data); 311 dev_set_drvdata(&korina_dev0.dev, &korina_dev0_data);
307 312
313 gpiod_add_lookup_table(&cf_slot0_gpio_table);
308 return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs)); 314 return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs));
309} 315}
310 316
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index 653b9a0bf727..66bb5bff126b 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -27,7 +27,7 @@
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/gpio.h> 30#include <linux/gpio/consumer.h>
31 31
32#include <linux/libata.h> 32#include <linux/libata.h>
33#include <scsi/scsi_host.h> 33#include <scsi/scsi_host.h>
@@ -49,7 +49,7 @@
49 49
50struct rb532_cf_info { 50struct rb532_cf_info {
51 void __iomem *iobase; 51 void __iomem *iobase;
52 unsigned int gpio_line; 52 struct gpio_desc *gpio_line;
53 unsigned int irq; 53 unsigned int irq;
54}; 54};
55 55
@@ -60,7 +60,7 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance)
60 struct ata_host *ah = dev_instance; 60 struct ata_host *ah = dev_instance;
61 struct rb532_cf_info *info = ah->private_data; 61 struct rb532_cf_info *info = ah->private_data;
62 62
63 if (gpio_get_value(info->gpio_line)) { 63 if (gpiod_get_value(info->gpio_line)) {
64 irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW); 64 irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW);
65 ata_sff_interrupt(info->irq, dev_instance); 65 ata_sff_interrupt(info->irq, dev_instance);
66 } else { 66 } else {
@@ -106,10 +106,9 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
106static int rb532_pata_driver_probe(struct platform_device *pdev) 106static int rb532_pata_driver_probe(struct platform_device *pdev)
107{ 107{
108 int irq; 108 int irq;
109 int gpio; 109 struct gpio_desc *gpiod;
110 struct resource *res; 110 struct resource *res;
111 struct ata_host *ah; 111 struct ata_host *ah;
112 struct cf_device *pdata;
113 struct rb532_cf_info *info; 112 struct rb532_cf_info *info;
114 int ret; 113 int ret;
115 114
@@ -125,23 +124,12 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
125 return -ENOENT; 124 return -ENOENT;
126 } 125 }
127 126
128 pdata = dev_get_platdata(&pdev->dev); 127 gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN);
129 if (!pdata) { 128 if (IS_ERR(gpiod)) {
130 dev_err(&pdev->dev, "no platform data specified\n");
131 return -EINVAL;
132 }
133
134 gpio = pdata->gpio_pin;
135 if (gpio < 0) {
136 dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq); 129 dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq);
137 return -ENOENT; 130 return PTR_ERR(gpiod);
138 }
139
140 ret = gpio_request(gpio, DRV_NAME);
141 if (ret) {
142 dev_err(&pdev->dev, "GPIO request failed\n");
143 return ret;
144 } 131 }
132 gpiod_set_consumer_name(gpiod, DRV_NAME);
145 133
146 /* allocate host */ 134 /* allocate host */
147 ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS); 135 ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS);
@@ -153,7 +141,7 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
153 return -ENOMEM; 141 return -ENOMEM;
154 142
155 ah->private_data = info; 143 ah->private_data = info;
156 info->gpio_line = gpio; 144 info->gpio_line = gpiod;
157 info->irq = irq; 145 info->irq = irq;
158 146
159 info->iobase = devm_ioremap_nocache(&pdev->dev, res->start, 147 info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
@@ -161,26 +149,14 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
161 if (!info->iobase) 149 if (!info->iobase)
162 return -ENOMEM; 150 return -ENOMEM;
163 151
164 ret = gpio_direction_input(gpio);
165 if (ret) {
166 dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n",
167 ret);
168 goto err_free_gpio;
169 }
170
171 rb532_pata_setup_ports(ah); 152 rb532_pata_setup_ports(ah);
172 153
173 ret = ata_host_activate(ah, irq, rb532_pata_irq_handler, 154 ret = ata_host_activate(ah, irq, rb532_pata_irq_handler,
174 IRQF_TRIGGER_LOW, &rb532_pata_sht); 155 IRQF_TRIGGER_LOW, &rb532_pata_sht);
175 if (ret) 156 if (ret)
176 goto err_free_gpio; 157 return ret;
177 158
178 return 0; 159 return 0;
179
180err_free_gpio:
181 gpio_free(gpio);
182
183 return ret;
184} 160}
185 161
186static int rb532_pata_driver_remove(struct platform_device *pdev) 162static int rb532_pata_driver_remove(struct platform_device *pdev)
@@ -189,7 +165,6 @@ static int rb532_pata_driver_remove(struct platform_device *pdev)
189 struct rb532_cf_info *info = ah->private_data; 165 struct rb532_cf_info *info = ah->private_data;
190 166
191 ata_host_detach(ah); 167 ata_host_detach(ah);
192 gpio_free(info->gpio_line);
193 168
194 return 0; 169 return 0;
195} 170}