diff options
-rw-r--r-- | drivers/spi/Kconfig | 7 | ||||
-rw-r--r-- | drivers/spi/Makefile | 1 | ||||
-rw-r--r-- | drivers/spi/xilinx_spi_pltfm.c | 102 |
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 | ||
264 | config 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 | |||
33 | obj-$(CONFIG_SPI_TXX9) += spi_txx9.o | 33 | obj-$(CONFIG_SPI_TXX9) += spi_txx9.o |
34 | obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o | 34 | obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o |
35 | obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o | 35 | obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o |
36 | obj-$(CONFIG_SPI_XILINX_PLTFM) += xilinx_spi_pltfm.o | ||
36 | obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o | 37 | obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o |
37 | obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o | 38 | obj-$(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 | |||
37 | static 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 | |||
68 | static 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 */ | ||
77 | MODULE_ALIAS("platform:" XILINX_SPI_NAME); | ||
78 | |||
79 | static 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 | |||
88 | static int __init xilinx_spi_pltfm_init(void) | ||
89 | { | ||
90 | return platform_driver_register(&xilinx_spi_driver); | ||
91 | } | ||
92 | module_init(xilinx_spi_pltfm_init); | ||
93 | |||
94 | static void __exit xilinx_spi_pltfm_exit(void) | ||
95 | { | ||
96 | platform_driver_unregister(&xilinx_spi_driver); | ||
97 | } | ||
98 | module_exit(xilinx_spi_pltfm_exit); | ||
99 | |||
100 | MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>"); | ||
101 | MODULE_DESCRIPTION("Xilinx SPI platform driver"); | ||
102 | MODULE_LICENSE("GPL v2"); | ||