aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-11-23 07:44:39 -0500
committerGrant Likely <grant.likely@secretlab.ca>2012-12-17 12:11:32 -0500
commit850a5b670af6293fcb1852af57567d19150ff638 (patch)
tree929a247a47c6c4e58dcf77e5ca4b5490e46e0646 /drivers/spi
parentcb71941a682270dd5164d1332900694d19caa5e1 (diff)
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>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-atmel.c17
1 files changed, 16 insertions, 1 deletions
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)
1074static const struct of_device_id atmel_spi_dt_ids[] = {
1075 { .compatible = "atmel,at91rm9200-spi" },
1076 { /* sentinel */ }
1077};
1078
1079MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids);
1080#endif
1067 1081
1068static struct platform_driver atmel_spi_driver = { 1082static 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,