aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/at91_cf.c
diff options
context:
space:
mode:
authorJoachim Eastwood <manabian@gmail.com>2013-06-06 04:24:18 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-06 15:57:42 -0400
commited9084ecfccae55ea45c7f068d1f513b979a0132 (patch)
tree8dcab0793f6f2c9874e9e8edace75beefb6b0d64 /drivers/pcmcia/at91_cf.c
parenta843168dc9f222c4c46751d96c2b701b6539f261 (diff)
pcmcia: at91_cf: add support for DT
Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/pcmcia/at91_cf.c')
-rw-r--r--drivers/pcmcia/at91_cf.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index bce8a64cd7c0..149b95c957da 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -20,6 +20,9 @@
20#include <linux/platform_data/atmel.h> 20#include <linux/platform_data/atmel.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/sizes.h> 22#include <linux/sizes.h>
23#include <linux/of.h>
24#include <linux/of_device.h>
25#include <linux/of_gpio.h>
23 26
24#include <pcmcia/ss.h> 27#include <pcmcia/ss.h>
25 28
@@ -211,6 +214,37 @@ static struct pccard_operations at91_cf_ops = {
211 214
212/*--------------------------------------------------------------------------*/ 215/*--------------------------------------------------------------------------*/
213 216
217#if defined(CONFIG_OF)
218static const struct of_device_id at91_cf_dt_ids[] = {
219 { .compatible = "atmel,at91rm9200-cf" },
220 { /* sentinel */ }
221};
222MODULE_DEVICE_TABLE(of, at91_cf_dt_ids);
223
224static int at91_cf_dt_init(struct platform_device *pdev)
225{
226 struct at91_cf_data *board;
227
228 board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
229 if (!board)
230 return -ENOMEM;
231
232 board->irq_pin = of_get_gpio(pdev->dev.of_node, 0);
233 board->det_pin = of_get_gpio(pdev->dev.of_node, 1);
234 board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2);
235 board->rst_pin = of_get_gpio(pdev->dev.of_node, 3);
236
237 pdev->dev.platform_data = board;
238
239 return 0;
240}
241#else
242static int at91_cf_dt_init(struct platform_device *pdev)
243{
244 return -ENODEV;
245}
246#endif
247
214static int __init at91_cf_probe(struct platform_device *pdev) 248static int __init at91_cf_probe(struct platform_device *pdev)
215{ 249{
216 struct at91_cf_socket *cf; 250 struct at91_cf_socket *cf;
@@ -218,7 +252,15 @@ static int __init at91_cf_probe(struct platform_device *pdev)
218 struct resource *io; 252 struct resource *io;
219 int status; 253 int status;
220 254
221 if (!board || !gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin)) 255 if (!board) {
256 status = at91_cf_dt_init(pdev);
257 if (status)
258 return status;
259
260 board = pdev->dev.platform_data;
261 }
262
263 if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
222 return -ENODEV; 264 return -ENODEV;
223 265
224 io = platform_get_resource(pdev, IORESOURCE_MEM, 0); 266 io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -360,6 +402,7 @@ static struct platform_driver at91_cf_driver = {
360 .driver = { 402 .driver = {
361 .name = "at91_cf", 403 .name = "at91_cf",
362 .owner = THIS_MODULE, 404 .owner = THIS_MODULE,
405 .of_match_table = of_match_ptr(at91_cf_dt_ids),
363 }, 406 },
364 .remove = __exit_p(at91_cf_remove), 407 .remove = __exit_p(at91_cf_remove),
365 .suspend = at91_cf_suspend, 408 .suspend = at91_cf_suspend,