diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index 5202de94f792..8d58598c325d 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c @@ -29,8 +29,11 @@ struct pxa_spi_info { unsigned long max_clk_rate; /* DMA channel request parameters */ + bool (*dma_filter)(struct dma_chan *chan, void *param); void *tx_param; void *rx_param; + + int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c); }; static struct dw_dma_slave byt_tx_param = { .dst_id = 0 }; @@ -57,86 +60,12 @@ static bool lpss_dma_filter(struct dma_chan *chan, void *param) return true; } -static struct pxa_spi_info spi_info_configs[] = { - [PORT_CE4100] = { - .type = PXA25x_SSP, - .port_id = -1, - .num_chipselect = -1, - .max_clk_rate = 3686400, - }, - [PORT_BYT] = { - .type = LPSS_BYT_SSP, - .port_id = 0, - .num_chipselect = 1, - .max_clk_rate = 50000000, - .tx_param = &byt_tx_param, - .rx_param = &byt_rx_param, - }, - [PORT_BSW0] = { - .type = LPSS_BYT_SSP, - .port_id = 0, - .num_chipselect = 1, - .max_clk_rate = 50000000, - .tx_param = &bsw0_tx_param, - .rx_param = &bsw0_rx_param, - }, - [PORT_BSW1] = { - .type = LPSS_BYT_SSP, - .port_id = 1, - .num_chipselect = 1, - .max_clk_rate = 50000000, - .tx_param = &bsw1_tx_param, - .rx_param = &bsw1_rx_param, - }, - [PORT_BSW2] = { - .type = LPSS_BYT_SSP, - .port_id = 2, - .num_chipselect = 1, - .max_clk_rate = 50000000, - .tx_param = &bsw2_tx_param, - .rx_param = &bsw2_rx_param, - }, - [PORT_QUARK_X1000] = { - .type = QUARK_X1000_SSP, - .port_id = -1, - .num_chipselect = 1, - .max_clk_rate = 50000000, - }, - [PORT_LPT] = { - .type = LPSS_LPT_SSP, - .port_id = 0, - .num_chipselect = 1, - .max_clk_rate = 50000000, - .tx_param = &lpt_tx_param, - .rx_param = &lpt_rx_param, - }, -}; - -static int pxa2xx_spi_pci_probe(struct pci_dev *dev, - const struct pci_device_id *ent) +static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) { - struct platform_device_info pi; - int ret; - struct platform_device *pdev; - struct pxa2xx_spi_master spi_pdata; - struct ssp_device *ssp; - struct pxa_spi_info *c; - char buf[40]; struct pci_dev *dma_dev; - ret = pcim_enable_device(dev); - if (ret) - return ret; - - ret = pcim_iomap_regions(dev, 1 << 0, "PXA2xx SPI"); - if (ret) - return ret; - - c = &spi_info_configs[ent->driver_data]; - - memset(&spi_pdata, 0, sizeof(spi_pdata)); - spi_pdata.num_chipselect = (c->num_chipselect > 0) ? - c->num_chipselect : dev->devfn; + c->num_chipselect = 1; + c->max_clk_rate = 50000000; dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); @@ -156,7 +85,89 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, slave->p_master = 1; } - spi_pdata.dma_filter = lpss_dma_filter; + c->dma_filter = lpss_dma_filter; + return 0; +} + +static struct pxa_spi_info spi_info_configs[] = { + [PORT_CE4100] = { + .type = PXA25x_SSP, + .port_id = -1, + .num_chipselect = -1, + .max_clk_rate = 3686400, + }, + [PORT_BYT] = { + .type = LPSS_BYT_SSP, + .port_id = 0, + .setup = lpss_spi_setup, + .tx_param = &byt_tx_param, + .rx_param = &byt_rx_param, + }, + [PORT_BSW0] = { + .type = LPSS_BYT_SSP, + .port_id = 0, + .setup = lpss_spi_setup, + .tx_param = &bsw0_tx_param, + .rx_param = &bsw0_rx_param, + }, + [PORT_BSW1] = { + .type = LPSS_BYT_SSP, + .port_id = 1, + .setup = lpss_spi_setup, + .tx_param = &bsw1_tx_param, + .rx_param = &bsw1_rx_param, + }, + [PORT_BSW2] = { + .type = LPSS_BYT_SSP, + .port_id = 2, + .setup = lpss_spi_setup, + .tx_param = &bsw2_tx_param, + .rx_param = &bsw2_rx_param, + }, + [PORT_QUARK_X1000] = { + .type = QUARK_X1000_SSP, + .port_id = -1, + .num_chipselect = 1, + .max_clk_rate = 50000000, + }, + [PORT_LPT] = { + .type = LPSS_LPT_SSP, + .port_id = 0, + .setup = lpss_spi_setup, + .tx_param = &lpt_tx_param, + .rx_param = &lpt_rx_param, + }, +}; + +static int pxa2xx_spi_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + struct platform_device_info pi; + int ret; + struct platform_device *pdev; + struct pxa2xx_spi_master spi_pdata; + struct ssp_device *ssp; + struct pxa_spi_info *c; + char buf[40]; + + ret = pcim_enable_device(dev); + if (ret) + return ret; + + ret = pcim_iomap_regions(dev, 1 << 0, "PXA2xx SPI"); + if (ret) + return ret; + + c = &spi_info_configs[ent->driver_data]; + if (c->setup) { + ret = c->setup(dev, c); + if (ret) + return ret; + } + + memset(&spi_pdata, 0, sizeof(spi_pdata)); + spi_pdata.num_chipselect = (c->num_chipselect > 0) ? c->num_chipselect : dev->devfn; + spi_pdata.dma_filter = c->dma_filter; spi_pdata.tx_param = c->tx_param; spi_pdata.rx_param = c->rx_param; spi_pdata.enable_dma = c->rx_param && c->tx_param;