aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2016-07-04 05:44:24 -0400
committerMark Brown <broonie@kernel.org>2016-07-04 10:13:42 -0400
commit743485ea3bee852fa816a2ec6c64b3d500e39895 (patch)
tree1db6a0e3996f84db78ec43b6849ea6d144e19e8a
parent704d2b07946fcae68afd86c222fde129e11f6bbc (diff)
spi: pxa2xx-pci: Do a specific setup in a separate function
Move LPSS specific setup to a separate function. It makes ->probe() cleaner as well as allows extend the driver for different variation of hardware in the future, e.g. for Intel Merrifield. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-pxa2xx-pci.c77
1 files changed, 44 insertions, 33 deletions
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 {
29 unsigned long max_clk_rate; 29 unsigned long max_clk_rate;
30 30
31 /* DMA channel request parameters */ 31 /* DMA channel request parameters */
32 bool (*dma_filter)(struct dma_chan *chan, void *param);
32 void *tx_param; 33 void *tx_param;
33 void *rx_param; 34 void *rx_param;
35
36 int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c);
34}; 37};
35 38
36static struct dw_dma_slave byt_tx_param = { .dst_id = 0 }; 39static struct dw_dma_slave byt_tx_param = { .dst_id = 0 };
@@ -57,6 +60,35 @@ static bool lpss_dma_filter(struct dma_chan *chan, void *param)
57 return true; 60 return true;
58} 61}
59 62
63static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
64{
65 struct pci_dev *dma_dev;
66
67 c->num_chipselect = 1;
68 c->max_clk_rate = 50000000;
69
70 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
71
72 if (c->tx_param) {
73 struct dw_dma_slave *slave = c->tx_param;
74
75 slave->dma_dev = &dma_dev->dev;
76 slave->m_master = 0;
77 slave->p_master = 1;
78 }
79
80 if (c->rx_param) {
81 struct dw_dma_slave *slave = c->rx_param;
82
83 slave->dma_dev = &dma_dev->dev;
84 slave->m_master = 0;
85 slave->p_master = 1;
86 }
87
88 c->dma_filter = lpss_dma_filter;
89 return 0;
90}
91
60static struct pxa_spi_info spi_info_configs[] = { 92static struct pxa_spi_info spi_info_configs[] = {
61 [PORT_CE4100] = { 93 [PORT_CE4100] = {
62 .type = PXA25x_SSP, 94 .type = PXA25x_SSP,
@@ -67,32 +99,28 @@ static struct pxa_spi_info spi_info_configs[] = {
67 [PORT_BYT] = { 99 [PORT_BYT] = {
68 .type = LPSS_BYT_SSP, 100 .type = LPSS_BYT_SSP,
69 .port_id = 0, 101 .port_id = 0,
70 .num_chipselect = 1, 102 .setup = lpss_spi_setup,
71 .max_clk_rate = 50000000,
72 .tx_param = &byt_tx_param, 103 .tx_param = &byt_tx_param,
73 .rx_param = &byt_rx_param, 104 .rx_param = &byt_rx_param,
74 }, 105 },
75 [PORT_BSW0] = { 106 [PORT_BSW0] = {
76 .type = LPSS_BYT_SSP, 107 .type = LPSS_BYT_SSP,
77 .port_id = 0, 108 .port_id = 0,
78 .num_chipselect = 1, 109 .setup = lpss_spi_setup,
79 .max_clk_rate = 50000000,
80 .tx_param = &bsw0_tx_param, 110 .tx_param = &bsw0_tx_param,
81 .rx_param = &bsw0_rx_param, 111 .rx_param = &bsw0_rx_param,
82 }, 112 },
83 [PORT_BSW1] = { 113 [PORT_BSW1] = {
84 .type = LPSS_BYT_SSP, 114 .type = LPSS_BYT_SSP,
85 .port_id = 1, 115 .port_id = 1,
86 .num_chipselect = 1, 116 .setup = lpss_spi_setup,
87 .max_clk_rate = 50000000,
88 .tx_param = &bsw1_tx_param, 117 .tx_param = &bsw1_tx_param,
89 .rx_param = &bsw1_rx_param, 118 .rx_param = &bsw1_rx_param,
90 }, 119 },
91 [PORT_BSW2] = { 120 [PORT_BSW2] = {
92 .type = LPSS_BYT_SSP, 121 .type = LPSS_BYT_SSP,
93 .port_id = 2, 122 .port_id = 2,
94 .num_chipselect = 1, 123 .setup = lpss_spi_setup,
95 .max_clk_rate = 50000000,
96 .tx_param = &bsw2_tx_param, 124 .tx_param = &bsw2_tx_param,
97 .rx_param = &bsw2_rx_param, 125 .rx_param = &bsw2_rx_param,
98 }, 126 },
@@ -105,8 +133,7 @@ static struct pxa_spi_info spi_info_configs[] = {
105 [PORT_LPT] = { 133 [PORT_LPT] = {
106 .type = LPSS_LPT_SSP, 134 .type = LPSS_LPT_SSP,
107 .port_id = 0, 135 .port_id = 0,
108 .num_chipselect = 1, 136 .setup = lpss_spi_setup,
109 .max_clk_rate = 50000000,
110 .tx_param = &lpt_tx_param, 137 .tx_param = &lpt_tx_param,
111 .rx_param = &lpt_rx_param, 138 .rx_param = &lpt_rx_param,
112 }, 139 },
@@ -122,7 +149,6 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
122 struct ssp_device *ssp; 149 struct ssp_device *ssp;
123 struct pxa_spi_info *c; 150 struct pxa_spi_info *c;
124 char buf[40]; 151 char buf[40];
125 struct pci_dev *dma_dev;
126 152
127 ret = pcim_enable_device(dev); 153 ret = pcim_enable_device(dev);
128 if (ret) 154 if (ret)
@@ -133,30 +159,15 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
133 return ret; 159 return ret;
134 160
135 c = &spi_info_configs[ent->driver_data]; 161 c = &spi_info_configs[ent->driver_data];
136 162 if (c->setup) {
137 memset(&spi_pdata, 0, sizeof(spi_pdata)); 163 ret = c->setup(dev, c);
138 spi_pdata.num_chipselect = (c->num_chipselect > 0) ? 164 if (ret)
139 c->num_chipselect : dev->devfn; 165 return ret;
140
141 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
142
143 if (c->tx_param) {
144 struct dw_dma_slave *slave = c->tx_param;
145
146 slave->dma_dev = &dma_dev->dev;
147 slave->m_master = 0;
148 slave->p_master = 1;
149 }
150
151 if (c->rx_param) {
152 struct dw_dma_slave *slave = c->rx_param;
153
154 slave->dma_dev = &dma_dev->dev;
155 slave->m_master = 0;
156 slave->p_master = 1;
157 } 166 }
158 167
159 spi_pdata.dma_filter = lpss_dma_filter; 168 memset(&spi_pdata, 0, sizeof(spi_pdata));
169 spi_pdata.num_chipselect = (c->num_chipselect > 0) ? c->num_chipselect : dev->devfn;
170 spi_pdata.dma_filter = c->dma_filter;
160 spi_pdata.tx_param = c->tx_param; 171 spi_pdata.tx_param = c->tx_param;
161 spi_pdata.rx_param = c->rx_param; 172 spi_pdata.rx_param = c->rx_param;
162 spi_pdata.enable_dma = c->rx_param && c->tx_param; 173 spi_pdata.enable_dma = c->rx_param && c->tx_param;