diff options
| -rw-r--r-- | Documentation/devicetree/bindings/spi/spi-orion.txt | 19 | ||||
| -rw-r--r-- | drivers/spi/spi-orion.c | 17 |
2 files changed, 36 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/spi/spi-orion.txt b/Documentation/devicetree/bindings/spi/spi-orion.txt new file mode 100644 index 000000000000..a3ff50fc76fb --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi-orion.txt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | Marvell Orion SPI device | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible : should be "marvell,orion-spi". | ||
| 5 | - reg : offset and length of the register set for the device | ||
| 6 | - cell-index : Which of multiple SPI controllers is this. | ||
| 7 | Optional properties: | ||
| 8 | - interrupts : Is currently not used. | ||
| 9 | |||
| 10 | Example: | ||
| 11 | spi@10600 { | ||
| 12 | compatible = "marvell,orion-spi"; | ||
| 13 | #address-cells = <1>; | ||
| 14 | #size-cells = <0>; | ||
| 15 | cell-index = <0>; | ||
| 16 | reg = <0x10600 0x28>; | ||
| 17 | interrupts = <23>; | ||
| 18 | status = "disabled"; | ||
| 19 | }; | ||
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 | }; |
