Skip to content

Commit

Permalink
spi/xilinx: fold platform_driver support into main body
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Grant Likely committed Nov 10, 2010
1 parent 91565c4 commit 8fd8821
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 118 deletions.
7 changes: 0 additions & 7 deletions drivers/spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,6 @@ config SPI_XILINX_OF
help
This is the OF driver for the SPI controller IP from the Xilinx EDK.

config SPI_XILINX_PLTFM
tristate "Xilinx SPI controller platform device"
depends on SPI_XILINX
help
This is the platform driver for the SPI controller IP
from the Xilinx EDK.

config SPI_NUC900
tristate "Nuvoton NUC900 series SPI"
depends on ARCH_W90X900 && EXPERIMENTAL
Expand Down
1 change: 0 additions & 1 deletion drivers/spi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi_topcliff_pch.o
obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o
obj-$(CONFIG_SPI_XILINX_PLTFM) += xilinx_spi_pltfm.o
obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o
obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o
obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o
Expand Down
79 changes: 73 additions & 6 deletions drivers/spi/xilinx_spi.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/*
* xilinx_spi.c
*
* Xilinx SPI controller driver (master mode only)
*
* Author: MontaVista Software, Inc.
* source@mvista.com
*
* 2002-2007 (c) MontaVista Software, Inc. This file is licensed under the
* terms of the GNU General Public License version 2. This program is licensed
* "as is" without any warranty of any kind, whether express or implied.
* Copyright (c) 2010 Secret Lab Technologies, Ltd.
* Copyright (c) 2009 Intel Corporation
* 2002-2007 (c) MontaVista Software, Inc.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>

#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h>
#include <linux/io.h>
Expand Down Expand Up @@ -456,6 +458,71 @@ void xilinx_spi_deinit(struct spi_master *master)
}
EXPORT_SYMBOL(xilinx_spi_deinit);

static int __devinit xilinx_spi_probe(struct platform_device *dev)
{
struct xspi_platform_data *pdata;
struct resource *r;
int irq;
struct spi_master *master;
u8 i;

pdata = dev->dev.platform_data;
if (!pdata)
return -ENODEV;

r = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!r)
return -ENODEV;

irq = platform_get_irq(dev, 0);
if (irq < 0)
return -ENXIO;

master = xilinx_spi_init(&dev->dev, r, irq, dev->id,
pdata->num_chipselect, pdata->little_endian,
pdata->bits_per_word);
if (!master)
return -ENODEV;

for (i = 0; i < pdata->num_devices; i++)
spi_new_device(master, pdata->devices + i);

platform_set_drvdata(dev, master);
return 0;
}

static int __devexit xilinx_spi_remove(struct platform_device *dev)
{
xilinx_spi_deinit(platform_get_drvdata(dev));
platform_set_drvdata(dev, 0);

return 0;
}

/* work with hotplug and coldplug */
MODULE_ALIAS("platform:" XILINX_SPI_NAME);

static struct platform_driver xilinx_spi_driver = {
.probe = xilinx_spi_probe,
.remove = __devexit_p(xilinx_spi_remove),
.driver = {
.name = XILINX_SPI_NAME,
.owner = THIS_MODULE,
},
};

static int __init xilinx_spi_pltfm_init(void)
{
return platform_driver_register(&xilinx_spi_driver);
}
module_init(xilinx_spi_pltfm_init);

static void __exit xilinx_spi_pltfm_exit(void)
{
platform_driver_unregister(&xilinx_spi_driver);
}
module_exit(xilinx_spi_pltfm_exit);

MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
MODULE_DESCRIPTION("Xilinx SPI driver");
MODULE_LICENSE("GPL");
104 changes: 0 additions & 104 deletions drivers/spi/xilinx_spi_pltfm.c

This file was deleted.

0 comments on commit 8fd8821

Please sign in to comment.