linux/drivers/spi/spi-pxa2xx-pci.c
<<
>>
Prefs
   1/*
   2 * CE4100's SPI device is more or less the same one as found on PXA
   3 *
   4 */
   5#include <linux/pci.h>
   6#include <linux/platform_device.h>
   7#include <linux/of_device.h>
   8#include <linux/module.h>
   9#include <linux/spi/pxa2xx_spi.h>
  10
  11static int ce4100_spi_probe(struct pci_dev *dev,
  12                const struct pci_device_id *ent)
  13{
  14        struct platform_device_info pi;
  15        int ret;
  16        struct platform_device *pdev;
  17        struct pxa2xx_spi_master spi_pdata;
  18        struct ssp_device *ssp;
  19
  20        ret = pcim_enable_device(dev);
  21        if (ret)
  22                return ret;
  23
  24        ret = pcim_iomap_regions(dev, 1 << 0, "PXA2xx SPI");
  25        if (!ret)
  26                return ret;
  27
  28        memset(&spi_pdata, 0, sizeof(spi_pdata));
  29        spi_pdata.num_chipselect = dev->devfn;
  30
  31        ssp = &spi_pdata.ssp;
  32        ssp->phys_base = pci_resource_start(dev, 0);
  33        ssp->mmio_base = pcim_iomap_table(dev)[0];
  34        if (!ssp->mmio_base) {
  35                dev_err(&dev->dev, "failed to ioremap() registers\n");
  36                return -EIO;
  37        }
  38        ssp->irq = dev->irq;
  39        ssp->port_id = dev->devfn;
  40        ssp->type = PXA25x_SSP;
  41
  42        memset(&pi, 0, sizeof(pi));
  43        pi.parent = &dev->dev;
  44        pi.name = "pxa2xx-spi";
  45        pi.id = ssp->port_id;
  46        pi.data = &spi_pdata;
  47        pi.size_data = sizeof(spi_pdata);
  48
  49        pdev = platform_device_register_full(&pi);
  50        if (!pdev)
  51                return -ENOMEM;
  52
  53        pci_set_drvdata(dev, pdev);
  54
  55        return 0;
  56}
  57
  58static void ce4100_spi_remove(struct pci_dev *dev)
  59{
  60        struct platform_device *pdev = pci_get_drvdata(dev);
  61
  62        platform_device_unregister(pdev);
  63}
  64
  65static DEFINE_PCI_DEVICE_TABLE(ce4100_spi_devices) = {
  66        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) },
  67        { },
  68};
  69MODULE_DEVICE_TABLE(pci, ce4100_spi_devices);
  70
  71static struct pci_driver ce4100_spi_driver = {
  72        .name           = "ce4100_spi",
  73        .id_table       = ce4100_spi_devices,
  74        .probe          = ce4100_spi_probe,
  75        .remove         = ce4100_spi_remove,
  76};
  77
  78module_pci_driver(ce4100_spi_driver);
  79
  80MODULE_DESCRIPTION("CE4100 PCI-SPI glue code for PXA's driver");
  81MODULE_LICENSE("GPL v2");
  82MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");
  83
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.