Add copy_to_iter(), copy_from_iter() and iov_iter_zero()
[deliverable/linux.git] / drivers / spi / spi-pxa2xx-pci.c
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
11 enum {
12 PORT_CE4100,
13 PORT_BYT,
14 };
15
16 struct pxa_spi_info {
17 enum pxa_ssp_type type;
18 int port_id;
19 int num_chipselect;
20 int tx_slave_id;
21 int tx_chan_id;
22 int rx_slave_id;
23 int rx_chan_id;
24 };
25
26 static struct pxa_spi_info spi_info_configs[] = {
27 [PORT_CE4100] = {
28 .type = PXA25x_SSP,
29 .port_id = -1,
30 .num_chipselect = -1,
31 .tx_slave_id = -1,
32 .tx_chan_id = -1,
33 .rx_slave_id = -1,
34 .rx_chan_id = -1,
35 },
36 [PORT_BYT] = {
37 .type = LPSS_SSP,
38 .port_id = 0,
39 .num_chipselect = 1,
40 .tx_slave_id = 0,
41 .tx_chan_id = 0,
42 .rx_slave_id = 1,
43 .rx_chan_id = 1,
44 },
45 };
46
47 static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
48 const struct pci_device_id *ent)
49 {
50 struct platform_device_info pi;
51 int ret;
52 struct platform_device *pdev;
53 struct pxa2xx_spi_master spi_pdata;
54 struct ssp_device *ssp;
55 struct pxa_spi_info *c;
56
57 ret = pcim_enable_device(dev);
58 if (ret)
59 return ret;
60
61 ret = pcim_iomap_regions(dev, 1 << 0, "PXA2xx SPI");
62 if (ret)
63 return ret;
64
65 c = &spi_info_configs[ent->driver_data];
66
67 memset(&spi_pdata, 0, sizeof(spi_pdata));
68 spi_pdata.num_chipselect = (c->num_chipselect > 0) ?
69 c->num_chipselect : dev->devfn;
70 spi_pdata.tx_slave_id = c->tx_slave_id;
71 spi_pdata.tx_chan_id = c->tx_chan_id;
72 spi_pdata.rx_slave_id = c->rx_slave_id;
73 spi_pdata.rx_chan_id = c->rx_chan_id;
74 spi_pdata.enable_dma = c->rx_slave_id >= 0 && c->tx_slave_id >= 0;
75
76 ssp = &spi_pdata.ssp;
77 ssp->phys_base = pci_resource_start(dev, 0);
78 ssp->mmio_base = pcim_iomap_table(dev)[0];
79 if (!ssp->mmio_base) {
80 dev_err(&dev->dev, "failed to ioremap() registers\n");
81 return -EIO;
82 }
83 ssp->irq = dev->irq;
84 ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn;
85 ssp->type = c->type;
86
87 memset(&pi, 0, sizeof(pi));
88 pi.parent = &dev->dev;
89 pi.name = "pxa2xx-spi";
90 pi.id = ssp->port_id;
91 pi.data = &spi_pdata;
92 pi.size_data = sizeof(spi_pdata);
93
94 pdev = platform_device_register_full(&pi);
95 if (IS_ERR(pdev))
96 return PTR_ERR(pdev);
97
98 pci_set_drvdata(dev, pdev);
99
100 return 0;
101 }
102
103 static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
104 {
105 struct platform_device *pdev = pci_get_drvdata(dev);
106
107 platform_device_unregister(pdev);
108 }
109
110 static const struct pci_device_id pxa2xx_spi_pci_devices[] = {
111 { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 },
112 { PCI_VDEVICE(INTEL, 0x0f0e), PORT_BYT },
113 { },
114 };
115 MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices);
116
117 static struct pci_driver pxa2xx_spi_pci_driver = {
118 .name = "pxa2xx_spi_pci",
119 .id_table = pxa2xx_spi_pci_devices,
120 .probe = pxa2xx_spi_pci_probe,
121 .remove = pxa2xx_spi_pci_remove,
122 };
123
124 module_pci_driver(pxa2xx_spi_pci_driver);
125
126 MODULE_DESCRIPTION("CE4100/LPSS PCI-SPI glue code for PXA's driver");
127 MODULE_LICENSE("GPL v2");
128 MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");
This page took 0.033764 seconds and 5 git commands to generate.