aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Röjfors <richard.rojfors@mocean-labs.com>2009-11-13 06:29:00 -0500
committerGrant Likely <grant.likely@secretlab.ca>2009-12-08 20:48:14 -0500
commit771669349e6cec0e29a18dc0b5a108e81b85d58c (patch)
tree85d37804913db521f8a2476c424cb9c552bec256
parentc9da2e125588677d74324df5088149063d578e8f (diff)
xilinx_spi: add a platform driver using the xilinx_spi common module.
This patch adds in a platform device driver using the xilinx_spi common module. Tested-by: John Linn <John.Linn@xilinx.com> Signed-off-by: Richard Röjfors <richard.rojfors@mocean-labs.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
-rw-r--r--drivers/spi/Kconfig7
-rw-r--r--drivers/spi/Makefile1
-rw-r--r--drivers/spi/xilinx_spi_pltfm.c102
3 files changed, 110 insertions, 0 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 4dda097c239e..c00f9e5b9df8 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -261,6 +261,13 @@ config SPI_XILINX_OF
261 help 261 help
262 This is the OF driver for the SPI controller IP from the Xilinx EDK. 262 This is the OF driver for the SPI controller IP from the Xilinx EDK.
263 263
264config SPI_XILINX_PLTFM
265 tristate "Xilinx SPI controller platform device"
266 depends on SPI_XILINX
267 help
268 This is the platform driver for the SPI controller IP
269 from the Xilinx EDK.
270
264# 271#
265# Add new SPI master controllers in alphabetical order above this line 272# Add new SPI master controllers in alphabetical order above this line
266# 273#
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 01c409548044..2f2bebc63b64 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o
33obj-$(CONFIG_SPI_TXX9) += spi_txx9.o 33obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
34obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o 34obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
35obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o 35obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o
36obj-$(CONFIG_SPI_XILINX_PLTFM) += xilinx_spi_pltfm.o
36obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o 37obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o
37obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o 38obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o
38# ... add above this line ... 39# ... add above this line ...
diff --git a/drivers/spi/xilinx_spi_pltfm.c b/drivers/spi/xilinx_spi_pltfm.c
new file mode 100644
index 000000000000..24debac646a9
--- /dev/null
+++ b/drivers/spi/xilinx_spi_pltfm.c
@@ -0,0 +1,102 @@
1/*
2 * Support for Xilinx SPI platform devices
3 * Copyright (c) 2009 Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19/* Supports:
20 * Xilinx SPI devices as platform devices
21 *
22 * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
23 */
24
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/io.h>
29#include <linux/platform_device.h>
30
31#include <linux/spi/spi.h>
32#include <linux/spi/spi_bitbang.h>
33#include <linux/spi/xilinx_spi.h>
34
35#include "xilinx_spi.h"
36
37static int __devinit xilinx_spi_probe(struct platform_device *dev)
38{
39 struct xspi_platform_data *pdata;
40 struct resource *r;
41 int irq;
42 struct spi_master *master;
43 u8 i;
44
45 pdata = dev->dev.platform_data;
46 if (!pdata)
47 return -ENODEV;
48
49 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
50 if (!r)
51 return -ENODEV;
52
53 irq = platform_get_irq(dev, 0);
54 if (irq < 0)
55 return -ENXIO;
56
57 master = xilinx_spi_init(&dev->dev, r, irq, dev->id);
58 if (!master)
59 return -ENODEV;
60
61 for (i = 0; i < pdata->num_devices; i++)
62 spi_new_device(master, pdata->devices + i);
63
64 platform_set_drvdata(dev, master);
65 return 0;
66}
67
68static int __devexit xilinx_spi_remove(struct platform_device *dev)
69{
70 xilinx_spi_deinit(platform_get_drvdata(dev));
71 platform_set_drvdata(dev, 0);
72
73 return 0;
74}
75
76/* work with hotplug and coldplug */
77MODULE_ALIAS("platform:" XILINX_SPI_NAME);
78
79static struct platform_driver xilinx_spi_driver = {
80 .probe = xilinx_spi_probe,
81 .remove = __devexit_p(xilinx_spi_remove),
82 .driver = {
83 .name = XILINX_SPI_NAME,
84 .owner = THIS_MODULE,
85 },
86};
87
88static int __init xilinx_spi_pltfm_init(void)
89{
90 return platform_driver_register(&xilinx_spi_driver);
91}
92module_init(xilinx_spi_pltfm_init);
93
94static void __exit xilinx_spi_pltfm_exit(void)
95{
96 platform_driver_unregister(&xilinx_spi_driver);
97}
98module_exit(xilinx_spi_pltfm_exit);
99
100MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
101MODULE_DESCRIPTION("Xilinx SPI platform driver");
102MODULE_LICENSE("GPL v2");