Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 4dfd459b738cf1f65b3eac4e0a9b19bc93cc91c6 102 lines 2.6 kB view raw
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");