diff options
-rw-r--r-- | Documentation/devicetree/bindings/spi/spi_atmel.txt | 26 | ||||
-rw-r--r-- | drivers/spi/spi-atmel.c | 17 |
2 files changed, 42 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/spi/spi_atmel.txt b/Documentation/devicetree/bindings/spi/spi_atmel.txt new file mode 100644 index 000000000000..07e04cdc0c9e --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi_atmel.txt | |||
@@ -0,0 +1,26 @@ | |||
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 | }; | ||
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 75c0c4f5fdf2..ab34497bcfee 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/platform_data/atmel.h> | 22 | #include <linux/platform_data/atmel.h> |
23 | #include <linux/of.h> | ||
23 | 24 | ||
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
25 | #include <asm/gpio.h> | 26 | #include <asm/gpio.h> |
@@ -768,6 +769,10 @@ static int atmel_spi_setup(struct spi_device *spi) | |||
768 | 769 | ||
769 | /* chipselect must have been muxed as GPIO (e.g. in board setup) */ | 770 | /* chipselect must have been muxed as GPIO (e.g. in board setup) */ |
770 | npcs_pin = (unsigned int)spi->controller_data; | 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 | asd = spi->controller_state; | 776 | asd = spi->controller_state; |
772 | if (!asd) { | 777 | if (!asd) { |
773 | asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); | 778 | asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); |
@@ -937,8 +942,9 @@ static int atmel_spi_probe(struct platform_device *pdev) | |||
937 | /* the spi->mode bits understood by this driver: */ | 942 | /* the spi->mode bits understood by this driver: */ |
938 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | 943 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; |
939 | 944 | ||
945 | master->dev.of_node = pdev->dev.of_node; | ||
940 | master->bus_num = pdev->id; | 946 | master->bus_num = pdev->id; |
941 | master->num_chipselect = 4; | 947 | master->num_chipselect = master->dev.of_node ? 0 : 4; |
942 | master->setup = atmel_spi_setup; | 948 | master->setup = atmel_spi_setup; |
943 | master->transfer = atmel_spi_transfer; | 949 | master->transfer = atmel_spi_transfer; |
944 | master->cleanup = atmel_spi_cleanup; | 950 | master->cleanup = atmel_spi_cleanup; |
@@ -1064,11 +1070,20 @@ static int atmel_spi_resume(struct platform_device *pdev) | |||
1064 | #define atmel_spi_resume NULL | 1070 | #define atmel_spi_resume NULL |
1065 | #endif | 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 | }; | ||
1078 | |||
1079 | MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids); | ||
1080 | #endif | ||
1067 | 1081 | ||
1068 | static struct platform_driver atmel_spi_driver = { | 1082 | static struct platform_driver atmel_spi_driver = { |
1069 | .driver = { | 1083 | .driver = { |
1070 | .name = "atmel_spi", | 1084 | .name = "atmel_spi", |
1071 | .owner = THIS_MODULE, | 1085 | .owner = THIS_MODULE, |
1086 | .of_match_table = of_match_ptr(atmel_spi_dt_ids), | ||
1072 | }, | 1087 | }, |
1073 | .suspend = atmel_spi_suspend, | 1088 | .suspend = atmel_spi_suspend, |
1074 | .resume = atmel_spi_resume, | 1089 | .resume = atmel_spi_resume, |