aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/xilinx_spi.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-10-14 11:04:29 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-11-09 23:41:27 -0500
commit8fd8821b62397f8ddb7bfb23c3246a22770ab2ee (patch)
tree1c12c696f8b6ad74f9eb3825b41f9b4702a8f077 /drivers/spi/xilinx_spi.c
parent91565c4068042b3d8e37e64e393ca105476419bd (diff)
spi/xilinx: fold platform_driver support into main body
This patch merges the platform driver support into the main body of xilinx_spi.c in preparation for merging the OF and non-OF support code. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Tested-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'drivers/spi/xilinx_spi.c')
-rw-r--r--drivers/spi/xilinx_spi.c79
1 files changed, 73 insertions, 6 deletions
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index efb28ba4a4ec..bb3b520df9dd 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -1,20 +1,22 @@
1/* 1/*
2 * xilinx_spi.c
3 *
4 * Xilinx SPI controller driver (master mode only) 2 * Xilinx SPI controller driver (master mode only)
5 * 3 *
6 * Author: MontaVista Software, Inc. 4 * Author: MontaVista Software, Inc.
7 * source@mvista.com 5 * source@mvista.com
8 * 6 *
9 * 2002-2007 (c) MontaVista Software, Inc. This file is licensed under the 7 * Copyright (c) 2010 Secret Lab Technologies, Ltd.
10 * terms of the GNU General Public License version 2. This program is licensed 8 * Copyright (c) 2009 Intel Corporation
11 * "as is" without any warranty of any kind, whether express or implied. 9 * 2002-2007 (c) MontaVista Software, Inc.
10
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
12 */ 14 */
13 15
14#include <linux/module.h> 16#include <linux/module.h>
15#include <linux/init.h> 17#include <linux/init.h>
16#include <linux/interrupt.h> 18#include <linux/interrupt.h>
17 19#include <linux/platform_device.h>
18#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
19#include <linux/spi/spi_bitbang.h> 21#include <linux/spi/spi_bitbang.h>
20#include <linux/io.h> 22#include <linux/io.h>
@@ -456,6 +458,71 @@ void xilinx_spi_deinit(struct spi_master *master)
456} 458}
457EXPORT_SYMBOL(xilinx_spi_deinit); 459EXPORT_SYMBOL(xilinx_spi_deinit);
458 460
461static int __devinit xilinx_spi_probe(struct platform_device *dev)
462{
463 struct xspi_platform_data *pdata;
464 struct resource *r;
465 int irq;
466 struct spi_master *master;
467 u8 i;
468
469 pdata = dev->dev.platform_data;
470 if (!pdata)
471 return -ENODEV;
472
473 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
474 if (!r)
475 return -ENODEV;
476
477 irq = platform_get_irq(dev, 0);
478 if (irq < 0)
479 return -ENXIO;
480
481 master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
482 pdata->num_chipselect, pdata->little_endian,
483 pdata->bits_per_word);
484 if (!master)
485 return -ENODEV;
486
487 for (i = 0; i < pdata->num_devices; i++)
488 spi_new_device(master, pdata->devices + i);
489
490 platform_set_drvdata(dev, master);
491 return 0;
492}
493
494static int __devexit xilinx_spi_remove(struct platform_device *dev)
495{
496 xilinx_spi_deinit(platform_get_drvdata(dev));
497 platform_set_drvdata(dev, 0);
498
499 return 0;
500}
501
502/* work with hotplug and coldplug */
503MODULE_ALIAS("platform:" XILINX_SPI_NAME);
504
505static struct platform_driver xilinx_spi_driver = {
506 .probe = xilinx_spi_probe,
507 .remove = __devexit_p(xilinx_spi_remove),
508 .driver = {
509 .name = XILINX_SPI_NAME,
510 .owner = THIS_MODULE,
511 },
512};
513
514static int __init xilinx_spi_pltfm_init(void)
515{
516 return platform_driver_register(&xilinx_spi_driver);
517}
518module_init(xilinx_spi_pltfm_init);
519
520static void __exit xilinx_spi_pltfm_exit(void)
521{
522 platform_driver_unregister(&xilinx_spi_driver);
523}
524module_exit(xilinx_spi_pltfm_exit);
525
459MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); 526MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
460MODULE_DESCRIPTION("Xilinx SPI driver"); 527MODULE_DESCRIPTION("Xilinx SPI driver");
461MODULE_LICENSE("GPL"); 528MODULE_LICENSE("GPL");