mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
pcmcia: at91_cf: add support for DT
Signed-off-by: Joachim Eastwood <[email protected]> Signed-off-by: Nicolas Ferre <[email protected]> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
a843168dc9
commit
ed9084ecfc
3 changed files with 64 additions and 2 deletions
|
|
@ -288,7 +288,7 @@ config BFIN_CFPCMCIA
|
|||
|
||||
config AT91_CF
|
||||
tristate "AT91 CompactFlash Controller"
|
||||
depends on PCMCIA && ARCH_AT91RM9200
|
||||
depends on PCMCIA && ARCH_AT91
|
||||
help
|
||||
Say Y here to support the CompactFlash controller on AT91 chips.
|
||||
Or choose M to compile the driver as a module named "at91_cf".
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@
|
|||
#include <linux/platform_data/atmel.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of_gpio.h>
|
||||
|
||||
#include <pcmcia/ss.h>
|
||||
|
||||
|
|
@ -211,6 +214,37 @@ static struct pccard_operations at91_cf_ops = {
|
|||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
static const struct of_device_id at91_cf_dt_ids[] = {
|
||||
{ .compatible = "atmel,at91rm9200-cf" },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, at91_cf_dt_ids);
|
||||
|
||||
static int at91_cf_dt_init(struct platform_device *pdev)
|
||||
{
|
||||
struct at91_cf_data *board;
|
||||
|
||||
board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
|
||||
if (!board)
|
||||
return -ENOMEM;
|
||||
|
||||
board->irq_pin = of_get_gpio(pdev->dev.of_node, 0);
|
||||
board->det_pin = of_get_gpio(pdev->dev.of_node, 1);
|
||||
board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2);
|
||||
board->rst_pin = of_get_gpio(pdev->dev.of_node, 3);
|
||||
|
||||
pdev->dev.platform_data = board;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int at91_cf_dt_init(struct platform_device *pdev)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int __init at91_cf_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct at91_cf_socket *cf;
|
||||
|
|
@ -218,7 +252,15 @@ static int __init at91_cf_probe(struct platform_device *pdev)
|
|||
struct resource *io;
|
||||
int status;
|
||||
|
||||
if (!board || !gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
|
||||
if (!board) {
|
||||
status = at91_cf_dt_init(pdev);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
board = pdev->dev.platform_data;
|
||||
}
|
||||
|
||||
if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
|
||||
return -ENODEV;
|
||||
|
||||
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
|
|
@ -360,6 +402,7 @@ static struct platform_driver at91_cf_driver = {
|
|||
.driver = {
|
||||
.name = "at91_cf",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(at91_cf_dt_ids),
|
||||
},
|
||||
.remove = __exit_p(at91_cf_remove),
|
||||
.suspend = at91_cf_suspend,
|
||||
|
|
|
|||
Loading…
Reference in a new issue