diff options
author | Andrew Lunn <andrew@lunn.ch> | 2012-07-23 06:08:09 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-07-23 06:43:39 -0400 |
commit | f814f9ac5a819542fdf6db97305db9da603c1eeb (patch) | |
tree | 02a558a9497634f1b001157cf46bc2e831d7521f /drivers | |
parent | 24ab32751183d4063d195c943af3cd6f1cad6794 (diff) |
spi/orion: add device tree binding
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@googlemail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/spi-orion.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index dfd04e91fa6d..74312a862ba8 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/of.h> | ||
20 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
21 | #include <asm/unaligned.h> | 22 | #include <asm/unaligned.h> |
22 | 23 | ||
@@ -453,6 +454,8 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
453 | struct orion_spi_info *spi_info; | 454 | struct orion_spi_info *spi_info; |
454 | unsigned long tclk_hz; | 455 | unsigned long tclk_hz; |
455 | int status = 0; | 456 | int status = 0; |
457 | const u32 *iprop; | ||
458 | int size; | ||
456 | 459 | ||
457 | spi_info = pdev->dev.platform_data; | 460 | spi_info = pdev->dev.platform_data; |
458 | 461 | ||
@@ -464,6 +467,12 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
464 | 467 | ||
465 | if (pdev->id != -1) | 468 | if (pdev->id != -1) |
466 | master->bus_num = pdev->id; | 469 | master->bus_num = pdev->id; |
470 | if (pdev->dev.of_node) { | ||
471 | iprop = of_get_property(pdev->dev.of_node, "cell-index", | ||
472 | &size); | ||
473 | if (iprop && size == sizeof(*iprop)) | ||
474 | master->bus_num = *iprop; | ||
475 | } | ||
467 | 476 | ||
468 | /* we support only mode 0, and no options */ | 477 | /* we support only mode 0, and no options */ |
469 | master->mode_bits = 0; | 478 | master->mode_bits = 0; |
@@ -511,6 +520,7 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
511 | if (orion_spi_reset(spi) < 0) | 520 | if (orion_spi_reset(spi) < 0) |
512 | goto out_rel_mem; | 521 | goto out_rel_mem; |
513 | 522 | ||
523 | master->dev.of_node = pdev->dev.of_node; | ||
514 | status = spi_register_master(master); | 524 | status = spi_register_master(master); |
515 | if (status < 0) | 525 | if (status < 0) |
516 | goto out_rel_mem; | 526 | goto out_rel_mem; |
@@ -552,10 +562,17 @@ static int __exit orion_spi_remove(struct platform_device *pdev) | |||
552 | 562 | ||
553 | MODULE_ALIAS("platform:" DRIVER_NAME); | 563 | MODULE_ALIAS("platform:" DRIVER_NAME); |
554 | 564 | ||
565 | static const struct of_device_id orion_spi_of_match_table[] __devinitdata = { | ||
566 | { .compatible = "marvell,orion-spi", }, | ||
567 | {} | ||
568 | }; | ||
569 | MODULE_DEVICE_TABLE(of, orion_spi_of_match_table); | ||
570 | |||
555 | static struct platform_driver orion_spi_driver = { | 571 | static struct platform_driver orion_spi_driver = { |
556 | .driver = { | 572 | .driver = { |
557 | .name = DRIVER_NAME, | 573 | .name = DRIVER_NAME, |
558 | .owner = THIS_MODULE, | 574 | .owner = THIS_MODULE, |
575 | .of_match_table = of_match_ptr(orion_spi_of_match_table), | ||
559 | }, | 576 | }, |
560 | .remove = __exit_p(orion_spi_remove), | 577 | .remove = __exit_p(orion_spi_remove), |
561 | }; | 578 | }; |