Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joachim Eastwood and committed by
Greg Kroah-Hartman
ed9084ec a843168d

+64 -2
+19
Documentation/devicetree/bindings/ata/atmel-at91_cf.txt
··· 1 + Atmel AT91RM9200 CompactFlash 2 + 3 + Required properties: 4 + - compatible : "atmel,at91rm9200-cf". 5 + - reg : should specify localbus address and size used. 6 + - gpios : specifies the gpio pins to control the CF device. Detect 7 + and reset gpio's are mandatory while irq and vcc gpio's are 8 + optional and may be set to 0 if not present. 9 + 10 + Example: 11 + compact-flash@50000000 { 12 + compatible = "atmel,at91rm9200-cf"; 13 + reg = <0x50000000 0x30000000>; 14 + gpios = <&pioC 13 0 /* irq */ 15 + &pioC 15 0 /* detect */ 16 + 0 /* vcc */ 17 + &pioC 5 0 /* reset */ 18 + >; 19 + };
+1 -1
drivers/pcmcia/Kconfig
··· 288 288 289 289 config AT91_CF 290 290 tristate "AT91 CompactFlash Controller" 291 - depends on PCMCIA && ARCH_AT91RM9200 291 + depends on PCMCIA && ARCH_AT91 292 292 help 293 293 Say Y here to support the CompactFlash controller on AT91 chips. 294 294 Or choose M to compile the driver as a module named "at91_cf".
+44 -1
drivers/pcmcia/at91_cf.c
··· 20 20 #include <linux/platform_data/atmel.h> 21 21 #include <linux/io.h> 22 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 27 #include <pcmcia/ss.h> 25 28 ··· 214 211 215 212 /*--------------------------------------------------------------------------*/ 216 213 214 + #if defined(CONFIG_OF) 215 + static const struct of_device_id at91_cf_dt_ids[] = { 216 + { .compatible = "atmel,at91rm9200-cf" }, 217 + { /* sentinel */ } 218 + }; 219 + MODULE_DEVICE_TABLE(of, at91_cf_dt_ids); 220 + 221 + static int at91_cf_dt_init(struct platform_device *pdev) 222 + { 223 + struct at91_cf_data *board; 224 + 225 + board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL); 226 + if (!board) 227 + return -ENOMEM; 228 + 229 + board->irq_pin = of_get_gpio(pdev->dev.of_node, 0); 230 + board->det_pin = of_get_gpio(pdev->dev.of_node, 1); 231 + board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2); 232 + board->rst_pin = of_get_gpio(pdev->dev.of_node, 3); 233 + 234 + pdev->dev.platform_data = board; 235 + 236 + return 0; 237 + } 238 + #else 239 + static int at91_cf_dt_init(struct platform_device *pdev) 240 + { 241 + return -ENODEV; 242 + } 243 + #endif 244 + 217 245 static int __init at91_cf_probe(struct platform_device *pdev) 218 246 { 219 247 struct at91_cf_socket *cf; ··· 252 218 struct resource *io; 253 219 int status; 254 220 255 - if (!board || !gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin)) 221 + if (!board) { 222 + status = at91_cf_dt_init(pdev); 223 + if (status) 224 + return status; 225 + 226 + board = pdev->dev.platform_data; 227 + } 228 + 229 + if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin)) 256 230 return -ENODEV; 257 231 258 232 io = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 402 360 .driver = { 403 361 .name = "at91_cf", 404 362 .owner = THIS_MODULE, 363 + .of_match_table = of_match_ptr(at91_cf_dt_ids), 405 364 }, 406 365 .remove = __exit_p(at91_cf_remove), 407 366 .suspend = at91_cf_suspend,