Staging: strip: delete the driver
[linux/fpc-iii.git] / drivers / spi / xilinx_spi_pltfm.c
blob24debac646a9f671ee39827f1e13fd9ffcaa4060
1 /*
2 * Support for Xilinx SPI platform devices
3 * Copyright (c) 2009 Intel Corporation
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.
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.
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.
19 /* Supports:
20 * Xilinx SPI devices as platform devices
22 * Inspired by xilinx_spi.c, 2002-2007 (c) MontaVista Software, Inc.
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>
31 #include <linux/spi/spi.h>
32 #include <linux/spi/spi_bitbang.h>
33 #include <linux/spi/xilinx_spi.h>
35 #include "xilinx_spi.h"
37 static int __devinit xilinx_spi_probe(struct platform_device *dev)
39 struct xspi_platform_data *pdata;
40 struct resource *r;
41 int irq;
42 struct spi_master *master;
43 u8 i;
45 pdata = dev->dev.platform_data;
46 if (!pdata)
47 return -ENODEV;
49 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
50 if (!r)
51 return -ENODEV;
53 irq = platform_get_irq(dev, 0);
54 if (irq < 0)
55 return -ENXIO;
57 master = xilinx_spi_init(&dev->dev, r, irq, dev->id);
58 if (!master)
59 return -ENODEV;
61 for (i = 0; i < pdata->num_devices; i++)
62 spi_new_device(master, pdata->devices + i);
64 platform_set_drvdata(dev, master);
65 return 0;
68 static int __devexit xilinx_spi_remove(struct platform_device *dev)
70 xilinx_spi_deinit(platform_get_drvdata(dev));
71 platform_set_drvdata(dev, 0);
73 return 0;
76 /* work with hotplug and coldplug */
77 MODULE_ALIAS("platform:" XILINX_SPI_NAME);
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,
88 static int __init xilinx_spi_pltfm_init(void)
90 return platform_driver_register(&xilinx_spi_driver);
92 module_init(xilinx_spi_pltfm_init);
94 static void __exit xilinx_spi_pltfm_exit(void)
96 platform_driver_unregister(&xilinx_spi_driver);
98 module_exit(xilinx_spi_pltfm_exit);
100 MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
101 MODULE_DESCRIPTION("Xilinx SPI platform driver");
102 MODULE_LICENSE("GPL v2");