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

spi/pxa2xx-pci: Add PCI mode support for BayTrail LPSS SPI

Similar to CE4100, BayTrail LPSS SPI can be PCI enumerated
as well. Thus, the functions are renamed from ce4100_xxx
to pxa2xx_spi_pci_xxx to clarify that this is a generic
PCI glue layer. Also, added required infrastructure to
support SPI hosts with different configurations.

This patch is based on Mika Westerberg's previous work.

Signed-off-by: Chew, Chiau Ee <chiau.ee.chew@intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Chew, Chiau Ee and committed by
Mark Brown
d6ba32d5 c9eaa447

+61 -15
+61 -15
drivers/spi/spi-pxa2xx-pci.c
··· 8 8 #include <linux/module.h> 9 9 #include <linux/spi/pxa2xx_spi.h> 10 10 11 - static int ce4100_spi_probe(struct pci_dev *dev, 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, 12 48 const struct pci_device_id *ent) 13 49 { 14 50 struct platform_device_info pi; ··· 52 16 struct platform_device *pdev; 53 17 struct pxa2xx_spi_master spi_pdata; 54 18 struct ssp_device *ssp; 19 + struct pxa_spi_info *c; 55 20 56 21 ret = pcim_enable_device(dev); 57 22 if (ret) ··· 62 25 if (ret) 63 26 return ret; 64 27 28 + c = &spi_info_configs[ent->driver_data]; 29 + 65 30 memset(&spi_pdata, 0, sizeof(spi_pdata)); 66 - spi_pdata.num_chipselect = dev->devfn; 31 + spi_pdata.num_chipselect = (c->num_chipselect > 0) ? 32 + c->num_chipselect : dev->devfn; 33 + spi_pdata.tx_slave_id = c->tx_slave_id; 34 + spi_pdata.tx_chan_id = c->tx_chan_id; 35 + spi_pdata.rx_slave_id = c->rx_slave_id; 36 + spi_pdata.rx_chan_id = c->rx_chan_id; 37 + spi_pdata.enable_dma = c->rx_slave_id >= 0 && c->tx_slave_id >= 0; 67 38 68 39 ssp = &spi_pdata.ssp; 69 40 ssp->phys_base = pci_resource_start(dev, 0); ··· 81 36 return -EIO; 82 37 } 83 38 ssp->irq = dev->irq; 84 - ssp->port_id = dev->devfn; 85 - ssp->type = PXA25x_SSP; 39 + ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn; 40 + ssp->type = c->type; 86 41 87 42 memset(&pi, 0, sizeof(pi)); 88 43 pi.parent = &dev->dev; ··· 100 55 return 0; 101 56 } 102 57 103 - static void ce4100_spi_remove(struct pci_dev *dev) 58 + static void pxa2xx_spi_pci_remove(struct pci_dev *dev) 104 59 { 105 60 struct platform_device *pdev = pci_get_drvdata(dev); 106 61 107 62 platform_device_unregister(pdev); 108 63 } 109 64 110 - static const struct pci_device_id ce4100_spi_devices[] = { 111 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) }, 65 + static const struct pci_device_id pxa2xx_spi_pci_devices[] = { 66 + { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 }, 67 + { PCI_VDEVICE(INTEL, 0x0f0e), PORT_BYT }, 112 68 { }, 113 69 }; 114 - MODULE_DEVICE_TABLE(pci, ce4100_spi_devices); 70 + MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices); 115 71 116 - static struct pci_driver ce4100_spi_driver = { 117 - .name = "ce4100_spi", 118 - .id_table = ce4100_spi_devices, 119 - .probe = ce4100_spi_probe, 120 - .remove = ce4100_spi_remove, 72 + static struct pci_driver pxa2xx_spi_pci_driver = { 73 + .name = "pxa2xx_spi_pci", 74 + .id_table = pxa2xx_spi_pci_devices, 75 + .probe = pxa2xx_spi_pci_probe, 76 + .remove = pxa2xx_spi_pci_remove, 121 77 }; 122 78 123 - module_pci_driver(ce4100_spi_driver); 79 + module_pci_driver(pxa2xx_spi_pci_driver); 124 80 125 - MODULE_DESCRIPTION("CE4100 PCI-SPI glue code for PXA's driver"); 81 + MODULE_DESCRIPTION("CE4100/LPSS PCI-SPI glue code for PXA's driver"); 126 82 MODULE_LICENSE("GPL v2"); 127 83 MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");