Commit 850a5b670af6293fcb1852af57567d19150ff638
Committed by
Grant Likely
1 parent
cb71941a68
spi/atmel: add DT support
Use the newly introduce cs-gpios dt support on atmel. We do not use the hardware cs as it's wired and has bugs and limitations. As the controller believes that only active-low devices/systems exists. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Showing 2 changed files with 42 additions and 1 deletions Side-by-side Diff
Documentation/devicetree/bindings/spi/spi_atmel.txt
1 | +Atmel SPI device | |
2 | + | |
3 | +Required properties: | |
4 | +- compatible : should be "atmel,at91rm9200-spi". | |
5 | +- reg: Address and length of the register set for the device | |
6 | +- interrupts: Should contain spi interrupt | |
7 | +- cs-gpios: chipselects | |
8 | + | |
9 | +Example: | |
10 | + | |
11 | +spi1: spi@fffcc000 { | |
12 | + compatible = "atmel,at91rm9200-spi"; | |
13 | + reg = <0xfffcc000 0x4000>; | |
14 | + interrupts = <13 4 5>; | |
15 | + #address-cells = <1>; | |
16 | + #size-cells = <0>; | |
17 | + cs-gpios = <&pioB 3 0>; | |
18 | + status = "okay"; | |
19 | + | |
20 | + mmc-slot@0 { | |
21 | + compatible = "mmc-spi-slot"; | |
22 | + reg = <0>; | |
23 | + gpios = <&pioC 4 0>; /* CD */ | |
24 | + spi-max-frequency = <25000000>; | |
25 | + }; | |
26 | +}; |
drivers/spi/spi-atmel.c
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | #include <linux/spi/spi.h> |
21 | 21 | #include <linux/slab.h> |
22 | 22 | #include <linux/platform_data/atmel.h> |
23 | +#include <linux/of.h> | |
23 | 24 | |
24 | 25 | #include <asm/io.h> |
25 | 26 | #include <asm/gpio.h> |
... | ... | @@ -768,6 +769,10 @@ |
768 | 769 | |
769 | 770 | /* chipselect must have been muxed as GPIO (e.g. in board setup) */ |
770 | 771 | npcs_pin = (unsigned int)spi->controller_data; |
772 | + | |
773 | + if (gpio_is_valid(spi->cs_gpio)) | |
774 | + npcs_pin = spi->cs_gpio; | |
775 | + | |
771 | 776 | asd = spi->controller_state; |
772 | 777 | if (!asd) { |
773 | 778 | asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); |
774 | 779 | |
... | ... | @@ -937,8 +942,9 @@ |
937 | 942 | /* the spi->mode bits understood by this driver: */ |
938 | 943 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; |
939 | 944 | |
945 | + master->dev.of_node = pdev->dev.of_node; | |
940 | 946 | master->bus_num = pdev->id; |
941 | - master->num_chipselect = 4; | |
947 | + master->num_chipselect = master->dev.of_node ? 0 : 4; | |
942 | 948 | master->setup = atmel_spi_setup; |
943 | 949 | master->transfer = atmel_spi_transfer; |
944 | 950 | master->cleanup = atmel_spi_cleanup; |
945 | 951 | |
946 | 952 | |
... | ... | @@ -1064,11 +1070,20 @@ |
1064 | 1070 | #define atmel_spi_resume NULL |
1065 | 1071 | #endif |
1066 | 1072 | |
1073 | +#if defined(CONFIG_OF) | |
1074 | +static const struct of_device_id atmel_spi_dt_ids[] = { | |
1075 | + { .compatible = "atmel,at91rm9200-spi" }, | |
1076 | + { /* sentinel */ } | |
1077 | +}; | |
1067 | 1078 | |
1079 | +MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids); | |
1080 | +#endif | |
1081 | + | |
1068 | 1082 | static struct platform_driver atmel_spi_driver = { |
1069 | 1083 | .driver = { |
1070 | 1084 | .name = "atmel_spi", |
1071 | 1085 | .owner = THIS_MODULE, |
1086 | + .of_match_table = of_match_ptr(atmel_spi_dt_ids), | |
1072 | 1087 | }, |
1073 | 1088 | .suspend = atmel_spi_suspend, |
1074 | 1089 | .resume = atmel_spi_resume, |