aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-atmel.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/spi/spi-atmel.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/spi/spi-atmel.c')
-rw-r--r--drivers/spi/spi-atmel.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index ab34497bcfe..82dee9a6c0d 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -19,11 +19,10 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
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>
23#include <linux/of.h>
24 22
25#include <asm/io.h> 23#include <asm/io.h>
26#include <asm/gpio.h> 24#include <mach/board.h>
25#include <mach/gpio.h>
27#include <mach/cpu.h> 26#include <mach/cpu.h>
28 27
29/* SPI register offsets */ 28/* SPI register offsets */
@@ -769,10 +768,6 @@ static int atmel_spi_setup(struct spi_device *spi)
769 768
770 /* chipselect must have been muxed as GPIO (e.g. in board setup) */ 769 /* chipselect must have been muxed as GPIO (e.g. in board setup) */
771 npcs_pin = (unsigned int)spi->controller_data; 770 npcs_pin = (unsigned int)spi->controller_data;
772
773 if (gpio_is_valid(spi->cs_gpio))
774 npcs_pin = spi->cs_gpio;
775
776 asd = spi->controller_state; 771 asd = spi->controller_state;
777 if (!asd) { 772 if (!asd) {
778 asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); 773 asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL);
@@ -912,7 +907,7 @@ static void atmel_spi_cleanup(struct spi_device *spi)
912 907
913/*-------------------------------------------------------------------------*/ 908/*-------------------------------------------------------------------------*/
914 909
915static int atmel_spi_probe(struct platform_device *pdev) 910static int __init atmel_spi_probe(struct platform_device *pdev)
916{ 911{
917 struct resource *regs; 912 struct resource *regs;
918 int irq; 913 int irq;
@@ -942,9 +937,8 @@ static int atmel_spi_probe(struct platform_device *pdev)
942 /* the spi->mode bits understood by this driver: */ 937 /* the spi->mode bits understood by this driver: */
943 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 938 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
944 939
945 master->dev.of_node = pdev->dev.of_node;
946 master->bus_num = pdev->id; 940 master->bus_num = pdev->id;
947 master->num_chipselect = master->dev.of_node ? 0 : 4; 941 master->num_chipselect = 4;
948 master->setup = atmel_spi_setup; 942 master->setup = atmel_spi_setup;
949 master->transfer = atmel_spi_transfer; 943 master->transfer = atmel_spi_transfer;
950 master->cleanup = atmel_spi_cleanup; 944 master->cleanup = atmel_spi_cleanup;
@@ -1009,7 +1003,7 @@ out_free:
1009 return ret; 1003 return ret;
1010} 1004}
1011 1005
1012static int atmel_spi_remove(struct platform_device *pdev) 1006static int __exit atmel_spi_remove(struct platform_device *pdev)
1013{ 1007{
1014 struct spi_master *master = platform_get_drvdata(pdev); 1008 struct spi_master *master = platform_get_drvdata(pdev);
1015 struct atmel_spi *as = spi_master_get_devdata(master); 1009 struct atmel_spi *as = spi_master_get_devdata(master);
@@ -1070,27 +1064,28 @@ static int atmel_spi_resume(struct platform_device *pdev)
1070#define atmel_spi_resume NULL 1064#define atmel_spi_resume NULL
1071#endif 1065#endif
1072 1066
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
1081 1067
1082static struct platform_driver atmel_spi_driver = { 1068static struct platform_driver atmel_spi_driver = {
1083 .driver = { 1069 .driver = {
1084 .name = "atmel_spi", 1070 .name = "atmel_spi",
1085 .owner = THIS_MODULE, 1071 .owner = THIS_MODULE,
1086 .of_match_table = of_match_ptr(atmel_spi_dt_ids),
1087 }, 1072 },
1088 .suspend = atmel_spi_suspend, 1073 .suspend = atmel_spi_suspend,
1089 .resume = atmel_spi_resume, 1074 .resume = atmel_spi_resume,
1090 .probe = atmel_spi_probe,
1091 .remove = __exit_p(atmel_spi_remove), 1075 .remove = __exit_p(atmel_spi_remove),
1092}; 1076};
1093module_platform_driver(atmel_spi_driver); 1077
1078static int __init atmel_spi_init(void)
1079{
1080 return platform_driver_probe(&atmel_spi_driver, atmel_spi_probe);
1081}
1082module_init(atmel_spi_init);
1083
1084static void __exit atmel_spi_exit(void)
1085{
1086 platform_driver_unregister(&atmel_spi_driver);
1087}
1088module_exit(atmel_spi_exit);
1094 1089
1095MODULE_DESCRIPTION("Atmel AT32/AT91 SPI Controller driver"); 1090MODULE_DESCRIPTION("Atmel AT32/AT91 SPI Controller driver");
1096MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); 1091MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");