aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/spi/spi-davinci.txt30
-rw-r--r--Documentation/spi/spi-summary6
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/spi-davinci.c55
-rw-r--r--drivers/spi/spi-dw-mid.c65
-rw-r--r--drivers/spi/spi-dw-pci.c67
-rw-r--r--drivers/spi/spi-dw.c48
-rw-r--r--drivers/spi/spi-dw.h11
-rw-r--r--drivers/spi/spi-fsl-cpm.c14
-rw-r--r--drivers/spi/spi-fsl-dspi.c18
-rw-r--r--drivers/spi/spi-fsl-espi.c12
-rw-r--r--drivers/spi/spi-fsl-lib.c6
-rw-r--r--drivers/spi/spi-fsl-spi.c22
13 files changed, 211 insertions, 145 deletions
diff --git a/Documentation/devicetree/bindings/spi/spi-davinci.txt b/Documentation/devicetree/bindings/spi/spi-davinci.txt
index f80887bca0d6..12ecfe9e3599 100644
--- a/Documentation/devicetree/bindings/spi/spi-davinci.txt
+++ b/Documentation/devicetree/bindings/spi/spi-davinci.txt
@@ -1,5 +1,10 @@
1Davinci SPI controller device bindings 1Davinci SPI controller device bindings
2 2
3Links on DM:
4Keystone 2 - http://www.ti.com/lit/ug/sprugp2a/sprugp2a.pdf
5dm644x - http://www.ti.com/lit/ug/sprue32a/sprue32a.pdf
6OMAP-L138/da830 - http://www.ti.com/lit/ug/spruh77a/spruh77a.pdf
7
3Required properties: 8Required properties:
4- #address-cells: number of cells required to define a chip select 9- #address-cells: number of cells required to define a chip select
5 address on the SPI bus. Should be set to 1. 10 address on the SPI bus. Should be set to 1.
@@ -24,6 +29,30 @@ Optional:
24 cs-gpios = <0>, <0>, <0>, <&gpio1 30 0>, <&gpio1 31 0>; 29 cs-gpios = <0>, <0>, <0>, <&gpio1 30 0>, <&gpio1 31 0>;
25 where first three are internal CS and last two are GPIO CS. 30 where first three are internal CS and last two are GPIO CS.
26 31
32Optional properties for slave devices:
33SPI slave nodes can contain the following properties.
34Not all SPI Peripherals from Texas Instruments support this.
35Please check SPI peripheral documentation for a device before using these.
36
37- ti,spi-wdelay : delay between transmission of words
38 (SPIFMTn.WDELAY, SPIDAT1.WDEL) must be specified in number of SPI module
39 clock periods.
40
41 delay = WDELAY * SPI_module_clock_period + 2 * SPI_module_clock_period
42
43Below is timing diagram which shows functional meaning of
44"ti,spi-wdelay" parameter.
45
46 +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+
47SPI_CLK | | | | | | | | | | | | | | | |
48 +----------+ +-+ +-+ +-+ +-+ +---------------------------+ +-+ +-+ +-
49
50SPI_SOMI/SIMO+-----------------+ +-----------
51 +----------+ word1 +---------------------------+word2
52 +-----------------+ +-----------
53 WDELAY
54 <-------------------------->
55
27Example of a NOR flash slave device (n25q032) connected to DaVinci 56Example of a NOR flash slave device (n25q032) connected to DaVinci
28SPI controller device over the SPI bus. 57SPI controller device over the SPI bus.
29 58
@@ -43,6 +72,7 @@ spi0:spi@20BF0000 {
43 compatible = "st,m25p32"; 72 compatible = "st,m25p32";
44 spi-max-frequency = <25000000>; 73 spi-max-frequency = <25000000>;
45 reg = <0>; 74 reg = <0>;
75 ti,spi-wdelay = <8>;
46 76
47 partition@0 { 77 partition@0 {
48 label = "u-boot-spl"; 78 label = "u-boot-spl";
diff --git a/Documentation/spi/spi-summary b/Documentation/spi/spi-summary
index 7982bcc4d151..d29734bff28c 100644
--- a/Documentation/spi/spi-summary
+++ b/Documentation/spi/spi-summary
@@ -601,13 +601,13 @@ THANKS TO
601Contributors to Linux-SPI discussions include (in alphabetical order, 601Contributors to Linux-SPI discussions include (in alphabetical order,
602by last name): 602by last name):
603 603
604Mark Brown
604David Brownell 605David Brownell
605Russell King 606Russell King
607Grant Likely
606Dmitry Pervushin 608Dmitry Pervushin
607Stephen Street 609Stephen Street
608Mark Underwood 610Mark Underwood
609Andrew Victor 611Andrew Victor
610Vitaly Wool
611Grant Likely
612Mark Brown
613Linus Walleij 612Linus Walleij
613Vitaly Wool
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index a862a1c8eb29..c4f19887987b 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -602,7 +602,7 @@ config SPI_DW_PCI
602 depends on SPI_DESIGNWARE && PCI 602 depends on SPI_DESIGNWARE && PCI
603 603
604config SPI_DW_MID_DMA 604config SPI_DW_MID_DMA
605 bool "DMA support for DW SPI controller on Intel Moorestown platform" 605 bool "DMA support for DW SPI controller on Intel MID platform"
606 depends on SPI_DW_PCI && INTEL_MID_DMAC 606 depends on SPI_DW_PCI && INTEL_MID_DMAC
607 607
608config SPI_DW_MMIO 608config SPI_DW_MMIO
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 63c82a61c975..63700ab7bd9f 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -65,6 +65,7 @@
65 65
66/* SPIDAT1 (upper 16 bit defines) */ 66/* SPIDAT1 (upper 16 bit defines) */
67#define SPIDAT1_CSHOLD_MASK BIT(12) 67#define SPIDAT1_CSHOLD_MASK BIT(12)
68#define SPIDAT1_WDEL BIT(10)
68 69
69/* SPIGCR1 */ 70/* SPIGCR1 */
70#define SPIGCR1_CLKMOD_MASK BIT(1) 71#define SPIGCR1_CLKMOD_MASK BIT(1)
@@ -213,6 +214,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
213{ 214{
214 struct davinci_spi *dspi; 215 struct davinci_spi *dspi;
215 struct davinci_spi_platform_data *pdata; 216 struct davinci_spi_platform_data *pdata;
217 struct davinci_spi_config *spicfg = spi->controller_data;
216 u8 chip_sel = spi->chip_select; 218 u8 chip_sel = spi->chip_select;
217 u16 spidat1 = CS_DEFAULT; 219 u16 spidat1 = CS_DEFAULT;
218 bool gpio_chipsel = false; 220 bool gpio_chipsel = false;
@@ -227,6 +229,10 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
227 gpio = spi->cs_gpio; 229 gpio = spi->cs_gpio;
228 } 230 }
229 231
232 /* program delay transfers if tx_delay is non zero */
233 if (spicfg->wdelay)
234 spidat1 |= SPIDAT1_WDEL;
235
230 /* 236 /*
231 * Board specific chip select logic decides the polarity and cs 237 * Board specific chip select logic decides the polarity and cs
232 * line for the controller 238 * line for the controller
@@ -241,9 +247,9 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
241 spidat1 |= SPIDAT1_CSHOLD_MASK; 247 spidat1 |= SPIDAT1_CSHOLD_MASK;
242 spidat1 &= ~(0x1 << chip_sel); 248 spidat1 &= ~(0x1 << chip_sel);
243 } 249 }
244
245 iowrite16(spidat1, dspi->base + SPIDAT1 + 2);
246 } 250 }
251
252 iowrite16(spidat1, dspi->base + SPIDAT1 + 2);
247} 253}
248 254
249/** 255/**
@@ -289,7 +295,7 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
289 int prescale; 295 int prescale;
290 296
291 dspi = spi_master_get_devdata(spi->master); 297 dspi = spi_master_get_devdata(spi->master);
292 spicfg = (struct davinci_spi_config *)spi->controller_data; 298 spicfg = spi->controller_data;
293 if (!spicfg) 299 if (!spicfg)
294 spicfg = &davinci_spi_default_cfg; 300 spicfg = &davinci_spi_default_cfg;
295 301
@@ -337,6 +343,14 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
337 spifmt |= SPIFMT_PHASE_MASK; 343 spifmt |= SPIFMT_PHASE_MASK;
338 344
339 /* 345 /*
346 * Assume wdelay is used only on SPI peripherals that has this field
347 * in SPIFMTn register and when it's configured from board file or DT.
348 */
349 if (spicfg->wdelay)
350 spifmt |= ((spicfg->wdelay << SPIFMT_WDELAY_SHIFT)
351 & SPIFMT_WDELAY_MASK);
352
353 /*
340 * Version 1 hardware supports two basic SPI modes: 354 * Version 1 hardware supports two basic SPI modes:
341 * - Standard SPI mode uses 4 pins, with chipselect 355 * - Standard SPI mode uses 4 pins, with chipselect
342 * - 3 pin SPI is a 4 pin variant without CS (SPI_NO_CS) 356 * - 3 pin SPI is a 4 pin variant without CS (SPI_NO_CS)
@@ -353,9 +367,6 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
353 367
354 u32 delay = 0; 368 u32 delay = 0;
355 369
356 spifmt |= ((spicfg->wdelay << SPIFMT_WDELAY_SHIFT)
357 & SPIFMT_WDELAY_MASK);
358
359 if (spicfg->odd_parity) 370 if (spicfg->odd_parity)
360 spifmt |= SPIFMT_ODD_PARITY_MASK; 371 spifmt |= SPIFMT_ODD_PARITY_MASK;
361 372
@@ -387,6 +398,26 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
387 return 0; 398 return 0;
388} 399}
389 400
401static int davinci_spi_of_setup(struct spi_device *spi)
402{
403 struct davinci_spi_config *spicfg = spi->controller_data;
404 struct device_node *np = spi->dev.of_node;
405 u32 prop;
406
407 if (spicfg == NULL && np) {
408 spicfg = kzalloc(sizeof(*spicfg), GFP_KERNEL);
409 if (!spicfg)
410 return -ENOMEM;
411 *spicfg = davinci_spi_default_cfg;
412 /* override with dt configured values */
413 if (!of_property_read_u32(np, "ti,spi-wdelay", &prop))
414 spicfg->wdelay = (u8)prop;
415 spi->controller_data = spicfg;
416 }
417
418 return 0;
419}
420
390/** 421/**
391 * davinci_spi_setup - This functions will set default transfer method 422 * davinci_spi_setup - This functions will set default transfer method
392 * @spi: spi device on which data transfer to be done 423 * @spi: spi device on which data transfer to be done
@@ -437,7 +468,16 @@ static int davinci_spi_setup(struct spi_device *spi)
437 else 468 else
438 clear_io_bits(dspi->base + SPIGCR1, SPIGCR1_LOOPBACK_MASK); 469 clear_io_bits(dspi->base + SPIGCR1, SPIGCR1_LOOPBACK_MASK);
439 470
440 return retval; 471 return davinci_spi_of_setup(spi);
472}
473
474static void davinci_spi_cleanup(struct spi_device *spi)
475{
476 struct davinci_spi_config *spicfg = spi->controller_data;
477
478 spi->controller_data = NULL;
479 if (spi->dev.of_node)
480 kfree(spicfg);
441} 481}
442 482
443static int davinci_spi_check_error(struct davinci_spi *dspi, int int_status) 483static int davinci_spi_check_error(struct davinci_spi *dspi, int int_status)
@@ -951,6 +991,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
951 master->num_chipselect = pdata->num_chipselect; 991 master->num_chipselect = pdata->num_chipselect;
952 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16); 992 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16);
953 master->setup = davinci_spi_setup; 993 master->setup = davinci_spi_setup;
994 master->cleanup = davinci_spi_cleanup;
954 995
955 dspi->bitbang.chipselect = davinci_spi_chipselect; 996 dspi->bitbang.chipselect = davinci_spi_chipselect;
956 dspi->bitbang.setup_transfer = davinci_spi_setup_transfer; 997 dspi->bitbang.setup_transfer = davinci_spi_setup_transfer;
diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 6d207afec8cb..46c6d58e1fda 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Special handling for DW core on Intel MID platform 2 * Special handling for DW core on Intel MID platform
3 * 3 *
4 * Copyright (c) 2009, Intel Corporation. 4 * Copyright (c) 2009, 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -11,10 +11,6 @@
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details. 13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 */ 14 */
19 15
20#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
@@ -39,22 +35,25 @@ static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)
39{ 35{
40 struct dw_spi *dws = param; 36 struct dw_spi *dws = param;
41 37
42 return dws->dmac && (&dws->dmac->dev == chan->device->dev); 38 return dws->dma_dev == chan->device->dev;
43} 39}
44 40
45static int mid_spi_dma_init(struct dw_spi *dws) 41static int mid_spi_dma_init(struct dw_spi *dws)
46{ 42{
47 struct mid_dma *dw_dma = dws->dma_priv; 43 struct mid_dma *dw_dma = dws->dma_priv;
44 struct pci_dev *dma_dev;
48 struct intel_mid_dma_slave *rxs, *txs; 45 struct intel_mid_dma_slave *rxs, *txs;
49 dma_cap_mask_t mask; 46 dma_cap_mask_t mask;
50 47
51 /* 48 /*
52 * Get pci device for DMA controller, currently it could only 49 * Get pci device for DMA controller, currently it could only
53 * be the DMA controller of either Moorestown or Medfield 50 * be the DMA controller of Medfield
54 */ 51 */
55 dws->dmac = pci_get_device(PCI_VENDOR_ID_INTEL, 0x0813, NULL); 52 dma_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x0827, NULL);
56 if (!dws->dmac) 53 if (!dma_dev)
57 dws->dmac = pci_get_device(PCI_VENDOR_ID_INTEL, 0x0827, NULL); 54 return -ENODEV;
55
56 dws->dma_dev = &dma_dev->dev;
58 57
59 dma_cap_zero(mask); 58 dma_cap_zero(mask);
60 dma_cap_set(DMA_SLAVE, mask); 59 dma_cap_set(DMA_SLAVE, mask);
@@ -83,13 +82,18 @@ static int mid_spi_dma_init(struct dw_spi *dws)
83free_rxchan: 82free_rxchan:
84 dma_release_channel(dws->rxchan); 83 dma_release_channel(dws->rxchan);
85err_exit: 84err_exit:
86 return -1; 85 return -EBUSY;
87
88} 86}
89 87
90static void mid_spi_dma_exit(struct dw_spi *dws) 88static void mid_spi_dma_exit(struct dw_spi *dws)
91{ 89{
90 if (!dws->dma_inited)
91 return;
92
93 dmaengine_terminate_all(dws->txchan);
92 dma_release_channel(dws->txchan); 94 dma_release_channel(dws->txchan);
95
96 dmaengine_terminate_all(dws->rxchan);
93 dma_release_channel(dws->rxchan); 97 dma_release_channel(dws->rxchan);
94} 98}
95 99
@@ -109,8 +113,7 @@ static void dw_spi_dma_done(void *arg)
109 113
110static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change) 114static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
111{ 115{
112 struct dma_async_tx_descriptor *txdesc = NULL, *rxdesc = NULL; 116 struct dma_async_tx_descriptor *txdesc, *rxdesc;
113 struct dma_chan *txchan, *rxchan;
114 struct dma_slave_config txconf, rxconf; 117 struct dma_slave_config txconf, rxconf;
115 u16 dma_ctrl = 0; 118 u16 dma_ctrl = 0;
116 119
@@ -120,37 +123,34 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
120 dw_writew(dws, DW_SPI_DMARDLR, 0xf); 123 dw_writew(dws, DW_SPI_DMARDLR, 0xf);
121 dw_writew(dws, DW_SPI_DMATDLR, 0x10); 124 dw_writew(dws, DW_SPI_DMATDLR, 0x10);
122 if (dws->tx_dma) 125 if (dws->tx_dma)
123 dma_ctrl |= 0x2; 126 dma_ctrl |= SPI_DMA_TDMAE;
124 if (dws->rx_dma) 127 if (dws->rx_dma)
125 dma_ctrl |= 0x1; 128 dma_ctrl |= SPI_DMA_RDMAE;
126 dw_writew(dws, DW_SPI_DMACR, dma_ctrl); 129 dw_writew(dws, DW_SPI_DMACR, dma_ctrl);
127 spi_enable_chip(dws, 1); 130 spi_enable_chip(dws, 1);
128 } 131 }
129 132
130 dws->dma_chan_done = 0; 133 dws->dma_chan_done = 0;
131 txchan = dws->txchan;
132 rxchan = dws->rxchan;
133 134
134 /* 2. Prepare the TX dma transfer */ 135 /* 2. Prepare the TX dma transfer */
135 txconf.direction = DMA_MEM_TO_DEV; 136 txconf.direction = DMA_MEM_TO_DEV;
136 txconf.dst_addr = dws->dma_addr; 137 txconf.dst_addr = dws->dma_addr;
137 txconf.dst_maxburst = LNW_DMA_MSIZE_16; 138 txconf.dst_maxburst = LNW_DMA_MSIZE_16;
138 txconf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 139 txconf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
139 txconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 140 txconf.dst_addr_width = dws->dma_width;
140 txconf.device_fc = false; 141 txconf.device_fc = false;
141 142
142 txchan->device->device_control(txchan, DMA_SLAVE_CONFIG, 143 dmaengine_slave_config(dws->txchan, &txconf);
143 (unsigned long) &txconf);
144 144
145 memset(&dws->tx_sgl, 0, sizeof(dws->tx_sgl)); 145 memset(&dws->tx_sgl, 0, sizeof(dws->tx_sgl));
146 dws->tx_sgl.dma_address = dws->tx_dma; 146 dws->tx_sgl.dma_address = dws->tx_dma;
147 dws->tx_sgl.length = dws->len; 147 dws->tx_sgl.length = dws->len;
148 148
149 txdesc = dmaengine_prep_slave_sg(txchan, 149 txdesc = dmaengine_prep_slave_sg(dws->txchan,
150 &dws->tx_sgl, 150 &dws->tx_sgl,
151 1, 151 1,
152 DMA_MEM_TO_DEV, 152 DMA_MEM_TO_DEV,
153 DMA_PREP_INTERRUPT); 153 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
154 txdesc->callback = dw_spi_dma_done; 154 txdesc->callback = dw_spi_dma_done;
155 txdesc->callback_param = dws; 155 txdesc->callback_param = dws;
156 156
@@ -159,27 +159,30 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
159 rxconf.src_addr = dws->dma_addr; 159 rxconf.src_addr = dws->dma_addr;
160 rxconf.src_maxburst = LNW_DMA_MSIZE_16; 160 rxconf.src_maxburst = LNW_DMA_MSIZE_16;
161 rxconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 161 rxconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
162 rxconf.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 162 rxconf.src_addr_width = dws->dma_width;
163 rxconf.device_fc = false; 163 rxconf.device_fc = false;
164 164
165 rxchan->device->device_control(rxchan, DMA_SLAVE_CONFIG, 165 dmaengine_slave_config(dws->rxchan, &rxconf);
166 (unsigned long) &rxconf);
167 166
168 memset(&dws->rx_sgl, 0, sizeof(dws->rx_sgl)); 167 memset(&dws->rx_sgl, 0, sizeof(dws->rx_sgl));
169 dws->rx_sgl.dma_address = dws->rx_dma; 168 dws->rx_sgl.dma_address = dws->rx_dma;
170 dws->rx_sgl.length = dws->len; 169 dws->rx_sgl.length = dws->len;
171 170
172 rxdesc = dmaengine_prep_slave_sg(rxchan, 171 rxdesc = dmaengine_prep_slave_sg(dws->rxchan,
173 &dws->rx_sgl, 172 &dws->rx_sgl,
174 1, 173 1,
175 DMA_DEV_TO_MEM, 174 DMA_DEV_TO_MEM,
176 DMA_PREP_INTERRUPT); 175 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
177 rxdesc->callback = dw_spi_dma_done; 176 rxdesc->callback = dw_spi_dma_done;
178 rxdesc->callback_param = dws; 177 rxdesc->callback_param = dws;
179 178
180 /* rx must be started before tx due to spi instinct */ 179 /* rx must be started before tx due to spi instinct */
181 rxdesc->tx_submit(rxdesc); 180 dmaengine_submit(rxdesc);
182 txdesc->tx_submit(txdesc); 181 dma_async_issue_pending(dws->rxchan);
182
183 dmaengine_submit(txdesc);
184 dma_async_issue_pending(dws->txchan);
185
183 return 0; 186 return 0;
184} 187}
185 188
@@ -190,7 +193,7 @@ static struct dw_spi_dma_ops mid_dma_ops = {
190}; 193};
191#endif 194#endif
192 195
193/* Some specific info for SPI0 controller on Moorestown */ 196/* Some specific info for SPI0 controller on Intel MID */
194 197
195/* HW info for MRST CLk Control Unit, one 32b reg */ 198/* HW info for MRST CLk Control Unit, one 32b reg */
196#define MRST_SPI_CLK_BASE 100000000 /* 100m */ 199#define MRST_SPI_CLK_BASE 100000000 /* 100m */
diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index e14960470d8d..ba68da12cdf0 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * PCI interface driver for DW SPI Core 2 * PCI interface driver for DW SPI Core
3 * 3 *
4 * Copyright (c) 2009, Intel Corporation. 4 * Copyright (c) 2009, 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -11,10 +11,6 @@
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details. 13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 */ 14 */
19 15
20#include <linux/interrupt.h> 16#include <linux/interrupt.h>
@@ -32,17 +28,22 @@ struct dw_spi_pci {
32 struct dw_spi dws; 28 struct dw_spi dws;
33}; 29};
34 30
35static int spi_pci_probe(struct pci_dev *pdev, 31struct spi_pci_desc {
36 const struct pci_device_id *ent) 32 int (*setup)(struct dw_spi *);
33};
34
35static struct spi_pci_desc spi_pci_mid_desc = {
36 .setup = dw_spi_mid_init,
37};
38
39static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
37{ 40{
38 struct dw_spi_pci *dwpci; 41 struct dw_spi_pci *dwpci;
39 struct dw_spi *dws; 42 struct dw_spi *dws;
43 struct spi_pci_desc *desc = (struct spi_pci_desc *)ent->driver_data;
40 int pci_bar = 0; 44 int pci_bar = 0;
41 int ret; 45 int ret;
42 46
43 dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n",
44 pdev->vendor, pdev->device);
45
46 ret = pcim_enable_device(pdev); 47 ret = pcim_enable_device(pdev);
47 if (ret) 48 if (ret)
48 return ret; 49 return ret;
@@ -58,7 +59,7 @@ static int spi_pci_probe(struct pci_dev *pdev,
58 /* Get basic io resource and map it */ 59 /* Get basic io resource and map it */
59 dws->paddr = pci_resource_start(pdev, pci_bar); 60 dws->paddr = pci_resource_start(pdev, pci_bar);
60 61
61 ret = pcim_iomap_regions(pdev, 1, dev_name(&pdev->dev)); 62 ret = pcim_iomap_regions(pdev, 1 << pci_bar, pci_name(pdev));
62 if (ret) 63 if (ret)
63 return ret; 64 return ret;
64 65
@@ -69,11 +70,11 @@ static int spi_pci_probe(struct pci_dev *pdev,
69 dws->irq = pdev->irq; 70 dws->irq = pdev->irq;
70 71
71 /* 72 /*
72 * Specific handling for Intel MID paltforms, like dma setup, 73 * Specific handling for paltforms, like dma setup,
73 * clock rate, FIFO depth. 74 * clock rate, FIFO depth.
74 */ 75 */
75 if (pdev->device == 0x0800) { 76 if (desc && desc->setup) {
76 ret = dw_spi_mid_init(dws); 77 ret = desc->setup(dws);
77 if (ret) 78 if (ret)
78 return ret; 79 return ret;
79 } 80 }
@@ -85,6 +86,9 @@ static int spi_pci_probe(struct pci_dev *pdev,
85 /* PCI hook and SPI hook use the same drv data */ 86 /* PCI hook and SPI hook use the same drv data */
86 pci_set_drvdata(pdev, dwpci); 87 pci_set_drvdata(pdev, dwpci);
87 88
89 dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n",
90 pdev->vendor, pdev->device);
91
88 return 0; 92 return 0;
89} 93}
90 94
@@ -95,41 +99,29 @@ static void spi_pci_remove(struct pci_dev *pdev)
95 dw_spi_remove_host(&dwpci->dws); 99 dw_spi_remove_host(&dwpci->dws);
96} 100}
97 101
98#ifdef CONFIG_PM 102#ifdef CONFIG_PM_SLEEP
99static int spi_suspend(struct pci_dev *pdev, pm_message_t state) 103static int spi_suspend(struct device *dev)
100{ 104{
105 struct pci_dev *pdev = to_pci_dev(dev);
101 struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); 106 struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
102 int ret;
103 107
104 ret = dw_spi_suspend_host(&dwpci->dws); 108 return dw_spi_suspend_host(&dwpci->dws);
105 if (ret)
106 return ret;
107 pci_save_state(pdev);
108 pci_disable_device(pdev);
109 pci_set_power_state(pdev, pci_choose_state(pdev, state));
110 return ret;
111} 109}
112 110
113static int spi_resume(struct pci_dev *pdev) 111static int spi_resume(struct device *dev)
114{ 112{
113 struct pci_dev *pdev = to_pci_dev(dev);
115 struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); 114 struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
116 int ret;
117 115
118 pci_set_power_state(pdev, PCI_D0);
119 pci_restore_state(pdev);
120 ret = pci_enable_device(pdev);
121 if (ret)
122 return ret;
123 return dw_spi_resume_host(&dwpci->dws); 116 return dw_spi_resume_host(&dwpci->dws);
124} 117}
125#else
126#define spi_suspend NULL
127#define spi_resume NULL
128#endif 118#endif
129 119
120static SIMPLE_DEV_PM_OPS(dw_spi_pm_ops, spi_suspend, spi_resume);
121
130static const struct pci_device_id pci_ids[] = { 122static const struct pci_device_id pci_ids[] = {
131 /* Intel MID platform SPI controller 0 */ 123 /* Intel MID platform SPI controller 0 */
132 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) }, 124 { PCI_VDEVICE(INTEL, 0x0800), (kernel_ulong_t)&spi_pci_mid_desc},
133 {}, 125 {},
134}; 126};
135 127
@@ -138,8 +130,9 @@ static struct pci_driver dw_spi_driver = {
138 .id_table = pci_ids, 130 .id_table = pci_ids,
139 .probe = spi_pci_probe, 131 .probe = spi_pci_probe,
140 .remove = spi_pci_remove, 132 .remove = spi_pci_remove,
141 .suspend = spi_suspend, 133 .driver = {
142 .resume = spi_resume, 134 .pm = &dw_spi_pm_ops,
135 },
143}; 136};
144 137
145module_pci_driver(dw_spi_driver); 138module_pci_driver(dw_spi_driver);
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 33117fbbf689..729215885250 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -11,10 +11,6 @@
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details. 13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 */ 14 */
19 15
20#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
@@ -59,22 +55,20 @@ struct chip_data {
59 55
60#ifdef CONFIG_DEBUG_FS 56#ifdef CONFIG_DEBUG_FS
61#define SPI_REGS_BUFSIZE 1024 57#define SPI_REGS_BUFSIZE 1024
62static ssize_t spi_show_regs(struct file *file, char __user *user_buf, 58static ssize_t dw_spi_show_regs(struct file *file, char __user *user_buf,
63 size_t count, loff_t *ppos) 59 size_t count, loff_t *ppos)
64{ 60{
65 struct dw_spi *dws; 61 struct dw_spi *dws = file->private_data;
66 char *buf; 62 char *buf;
67 u32 len = 0; 63 u32 len = 0;
68 ssize_t ret; 64 ssize_t ret;
69 65
70 dws = file->private_data;
71
72 buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL); 66 buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL);
73 if (!buf) 67 if (!buf)
74 return 0; 68 return 0;
75 69
76 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, 70 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
77 "MRST SPI0 registers:\n"); 71 "%s registers:\n", dev_name(&dws->master->dev));
78 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, 72 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
79 "=================================\n"); 73 "=================================\n");
80 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, 74 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
@@ -110,41 +104,41 @@ static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
110 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, 104 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
111 "=================================\n"); 105 "=================================\n");
112 106
113 ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); 107 ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
114 kfree(buf); 108 kfree(buf);
115 return ret; 109 return ret;
116} 110}
117 111
118static const struct file_operations mrst_spi_regs_ops = { 112static const struct file_operations dw_spi_regs_ops = {
119 .owner = THIS_MODULE, 113 .owner = THIS_MODULE,
120 .open = simple_open, 114 .open = simple_open,
121 .read = spi_show_regs, 115 .read = dw_spi_show_regs,
122 .llseek = default_llseek, 116 .llseek = default_llseek,
123}; 117};
124 118
125static int mrst_spi_debugfs_init(struct dw_spi *dws) 119static int dw_spi_debugfs_init(struct dw_spi *dws)
126{ 120{
127 dws->debugfs = debugfs_create_dir("mrst_spi", NULL); 121 dws->debugfs = debugfs_create_dir("dw_spi", NULL);
128 if (!dws->debugfs) 122 if (!dws->debugfs)
129 return -ENOMEM; 123 return -ENOMEM;
130 124
131 debugfs_create_file("registers", S_IFREG | S_IRUGO, 125 debugfs_create_file("registers", S_IFREG | S_IRUGO,
132 dws->debugfs, (void *)dws, &mrst_spi_regs_ops); 126 dws->debugfs, (void *)dws, &dw_spi_regs_ops);
133 return 0; 127 return 0;
134} 128}
135 129
136static void mrst_spi_debugfs_remove(struct dw_spi *dws) 130static void dw_spi_debugfs_remove(struct dw_spi *dws)
137{ 131{
138 debugfs_remove_recursive(dws->debugfs); 132 debugfs_remove_recursive(dws->debugfs);
139} 133}
140 134
141#else 135#else
142static inline int mrst_spi_debugfs_init(struct dw_spi *dws) 136static inline int dw_spi_debugfs_init(struct dw_spi *dws)
143{ 137{
144 return 0; 138 return 0;
145} 139}
146 140
147static inline void mrst_spi_debugfs_remove(struct dw_spi *dws) 141static inline void dw_spi_debugfs_remove(struct dw_spi *dws)
148{ 142{
149} 143}
150#endif /* CONFIG_DEBUG_FS */ 144#endif /* CONFIG_DEBUG_FS */
@@ -396,7 +390,7 @@ static void pump_transfers(unsigned long data)
396 goto early_exit; 390 goto early_exit;
397 } 391 }
398 392
399 /* Delay if requested at end of transfer*/ 393 /* Delay if requested at end of transfer */
400 if (message->state == RUNNING_STATE) { 394 if (message->state == RUNNING_STATE) {
401 previous = list_entry(transfer->transfer_list.prev, 395 previous = list_entry(transfer->transfer_list.prev,
402 struct spi_transfer, 396 struct spi_transfer,
@@ -525,7 +519,7 @@ static int dw_spi_transfer_one_message(struct spi_master *master,
525 struct dw_spi *dws = spi_master_get_devdata(master); 519 struct dw_spi *dws = spi_master_get_devdata(master);
526 520
527 dws->cur_msg = msg; 521 dws->cur_msg = msg;
528 /* Initial message state*/ 522 /* Initial message state */
529 dws->cur_msg->state = START_STATE; 523 dws->cur_msg->state = START_STATE;
530 dws->cur_transfer = list_entry(dws->cur_msg->transfers.next, 524 dws->cur_transfer = list_entry(dws->cur_msg->transfers.next,
531 struct spi_transfer, 525 struct spi_transfer,
@@ -596,6 +590,9 @@ static int dw_spi_setup(struct spi_device *spi)
596 | (spi->mode << SPI_MODE_OFFSET) 590 | (spi->mode << SPI_MODE_OFFSET)
597 | (chip->tmode << SPI_TMOD_OFFSET); 591 | (chip->tmode << SPI_TMOD_OFFSET);
598 592
593 if (spi->mode & SPI_LOOP)
594 chip->cr0 |= 1 << SPI_SRL_OFFSET;
595
599 if (gpio_is_valid(spi->cs_gpio)) { 596 if (gpio_is_valid(spi->cs_gpio)) {
600 ret = gpio_direction_output(spi->cs_gpio, 597 ret = gpio_direction_output(spi->cs_gpio,
601 !(spi->mode & SPI_CS_HIGH)); 598 !(spi->mode & SPI_CS_HIGH));
@@ -655,8 +652,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
655 dws->prev_chip = NULL; 652 dws->prev_chip = NULL;
656 dws->dma_inited = 0; 653 dws->dma_inited = 0;
657 dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60); 654 dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60);
658 snprintf(dws->name, sizeof(dws->name), "dw_spi%d", 655 snprintf(dws->name, sizeof(dws->name), "dw_spi%d", dws->bus_num);
659 dws->bus_num);
660 656
661 ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED, 657 ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED,
662 dws->name, dws); 658 dws->name, dws);
@@ -665,7 +661,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
665 goto err_free_master; 661 goto err_free_master;
666 } 662 }
667 663
668 master->mode_bits = SPI_CPOL | SPI_CPHA; 664 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP;
669 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); 665 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
670 master->bus_num = dws->bus_num; 666 master->bus_num = dws->bus_num;
671 master->num_chipselect = dws->num_cs; 667 master->num_chipselect = dws->num_cs;
@@ -694,7 +690,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
694 goto err_dma_exit; 690 goto err_dma_exit;
695 } 691 }
696 692
697 mrst_spi_debugfs_init(dws); 693 dw_spi_debugfs_init(dws);
698 return 0; 694 return 0;
699 695
700err_dma_exit: 696err_dma_exit:
@@ -711,7 +707,7 @@ void dw_spi_remove_host(struct dw_spi *dws)
711{ 707{
712 if (!dws) 708 if (!dws)
713 return; 709 return;
714 mrst_spi_debugfs_remove(dws); 710 dw_spi_debugfs_remove(dws);
715 711
716 if (dws->dma_ops && dws->dma_ops->dma_exit) 712 if (dws->dma_ops && dws->dma_ops->dma_exit)
717 dws->dma_ops->dma_exit(dws); 713 dws->dma_ops->dma_exit(dws);
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 6d2acad34f64..83a103a76481 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -74,6 +74,10 @@
74#define SPI_INT_RXFI (1 << 4) 74#define SPI_INT_RXFI (1 << 4)
75#define SPI_INT_MSTI (1 << 5) 75#define SPI_INT_MSTI (1 << 5)
76 76
77/* Bit fields in DMACR */
78#define SPI_DMA_RDMAE (1 << 0)
79#define SPI_DMA_TDMAE (1 << 1)
80
77/* TX RX interrupt level threshold, max can be 256 */ 81/* TX RX interrupt level threshold, max can be 256 */
78#define SPI_INT_THRESHOLD 32 82#define SPI_INT_THRESHOLD 32
79 83
@@ -140,7 +144,6 @@ struct dw_spi {
140 dma_addr_t dma_addr; /* phy address of the Data register */ 144 dma_addr_t dma_addr; /* phy address of the Data register */
141 struct dw_spi_dma_ops *dma_ops; 145 struct dw_spi_dma_ops *dma_ops;
142 void *dma_priv; /* platform relate info */ 146 void *dma_priv; /* platform relate info */
143 struct pci_dev *dmac;
144 147
145 /* Bus interface info */ 148 /* Bus interface info */
146 void *priv; 149 void *priv;
@@ -217,11 +220,11 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
217 * Each SPI slave device to work with dw_api controller should 220 * Each SPI slave device to work with dw_api controller should
218 * has such a structure claiming its working mode (PIO/DMA etc), 221 * has such a structure claiming its working mode (PIO/DMA etc),
219 * which can be save in the "controller_data" member of the 222 * which can be save in the "controller_data" member of the
220 * struct spi_device 223 * struct spi_device.
221 */ 224 */
222struct dw_spi_chip { 225struct dw_spi_chip {
223 u8 poll_mode; /* 0 for contoller polling mode */ 226 u8 poll_mode; /* 1 for controller polling mode */
224 u8 type; /* SPI/SSP/Micrwire */ 227 u8 type; /* SPI/SSP/MicroWire */
225 u8 enable_dma; 228 u8 enable_dma;
226 void (*cs_control)(u32 command); 229 void (*cs_control)(u32 command);
227}; 230};
diff --git a/drivers/spi/spi-fsl-cpm.c b/drivers/spi/spi-fsl-cpm.c
index 54b06376f03c..c5dd20beee22 100644
--- a/drivers/spi/spi-fsl-cpm.c
+++ b/drivers/spi/spi-fsl-cpm.c
@@ -15,17 +15,17 @@
15 * Free Software Foundation; either version 2 of the License, or (at your 15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. 16 * option) any later version.
17 */ 17 */
18#include <linux/types.h>
19#include <linux/kernel.h>
20#include <linux/spi/spi.h>
21#include <linux/fsl_devices.h>
22#include <linux/dma-mapping.h>
23#include <linux/of_address.h>
24#include <asm/cpm.h> 18#include <asm/cpm.h>
25#include <asm/qe.h> 19#include <asm/qe.h>
20#include <linux/dma-mapping.h>
21#include <linux/fsl_devices.h>
22#include <linux/kernel.h>
23#include <linux/of_address.h>
24#include <linux/spi/spi.h>
25#include <linux/types.h>
26 26
27#include "spi-fsl-lib.h"
28#include "spi-fsl-cpm.h" 27#include "spi-fsl-cpm.h"
28#include "spi-fsl-lib.h"
29#include "spi-fsl-spi.h" 29#include "spi-fsl-spi.h"
30 30
31/* CPM1 and CPM2 are mutually exclusive. */ 31/* CPM1 and CPM2 are mutually exclusive. */
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 5021ddf03f60..63c3859d24cf 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -13,22 +13,22 @@
13 * 13 *
14 */ 14 */
15 15
16#include <linux/clk.h>
17#include <linux/delay.h>
18#include <linux/err.h>
19#include <linux/errno.h>
20#include <linux/interrupt.h>
21#include <linux/io.h>
16#include <linux/kernel.h> 22#include <linux/kernel.h>
17#include <linux/module.h> 23#include <linux/module.h>
18#include <linux/interrupt.h> 24#include <linux/of.h>
19#include <linux/errno.h> 25#include <linux/of_device.h>
20#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/pm_runtime.h>
21#include <linux/regmap.h> 28#include <linux/regmap.h>
22#include <linux/sched.h> 29#include <linux/sched.h>
23#include <linux/delay.h>
24#include <linux/io.h>
25#include <linux/clk.h>
26#include <linux/err.h>
27#include <linux/spi/spi.h> 30#include <linux/spi/spi.h>
28#include <linux/spi/spi_bitbang.h> 31#include <linux/spi/spi_bitbang.h>
29#include <linux/pm_runtime.h>
30#include <linux/of.h>
31#include <linux/of_device.h>
32 32
33#define DRIVER_NAME "fsl-dspi" 33#define DRIVER_NAME "fsl-dspi"
34 34
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 429e11190265..a7f94b6a9e70 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -8,19 +8,19 @@
8 * Free Software Foundation; either version 2 of the License, or (at your 8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
10 */ 10 */
11#include <linux/module.h>
12#include <linux/delay.h> 11#include <linux/delay.h>
13#include <linux/irq.h> 12#include <linux/err.h>
14#include <linux/spi/spi.h>
15#include <linux/platform_device.h>
16#include <linux/fsl_devices.h> 13#include <linux/fsl_devices.h>
14#include <linux/interrupt.h>
15#include <linux/irq.h>
16#include <linux/module.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/of.h> 18#include <linux/of.h>
19#include <linux/of_address.h> 19#include <linux/of_address.h>
20#include <linux/of_irq.h> 20#include <linux/of_irq.h>
21#include <linux/of_platform.h> 21#include <linux/of_platform.h>
22#include <linux/interrupt.h> 22#include <linux/platform_device.h>
23#include <linux/err.h> 23#include <linux/spi/spi.h>
24#include <sysdev/fsl_soc.h> 24#include <sysdev/fsl_soc.h>
25 25
26#include "spi-fsl-lib.h" 26#include "spi-fsl-lib.h"
diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c
index e0b773fc29cb..5ddb5b098e4e 100644
--- a/drivers/spi/spi-fsl-lib.c
+++ b/drivers/spi/spi-fsl-lib.c
@@ -16,10 +16,10 @@
16 * Free Software Foundation; either version 2 of the License, or (at your 16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version. 17 * option) any later version.
18 */ 18 */
19#include <linux/kernel.h>
20#include <linux/interrupt.h>
21#include <linux/fsl_devices.h>
22#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
20#include <linux/fsl_devices.h>
21#include <linux/interrupt.h>
22#include <linux/kernel.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/of_platform.h> 24#include <linux/of_platform.h>
25#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 590f31bc0aba..ed792880c9d6 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -19,25 +19,25 @@
19 * Free Software Foundation; either version 2 of the License, or (at your 19 * Free Software Foundation; either version 2 of the License, or (at your
20 * option) any later version. 20 * option) any later version.
21 */ 21 */
22#include <linux/module.h>
23#include <linux/types.h>
24#include <linux/kernel.h>
25#include <linux/interrupt.h>
26#include <linux/delay.h> 22#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/spi/spi.h>
29#include <linux/spi/spi_bitbang.h>
30#include <linux/platform_device.h>
31#include <linux/fsl_devices.h>
32#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
24#include <linux/fsl_devices.h>
25#include <linux/gpio.h>
26#include <linux/interrupt.h>
27#include <linux/irq.h>
28#include <linux/kernel.h>
33#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/module.h>
34#include <linux/mutex.h> 31#include <linux/mutex.h>
35#include <linux/of.h> 32#include <linux/of.h>
36#include <linux/of_platform.h>
37#include <linux/of_address.h> 33#include <linux/of_address.h>
38#include <linux/of_irq.h> 34#include <linux/of_irq.h>
39#include <linux/gpio.h>
40#include <linux/of_gpio.h> 35#include <linux/of_gpio.h>
36#include <linux/of_platform.h>
37#include <linux/platform_device.h>
38#include <linux/spi/spi.h>
39#include <linux/spi/spi_bitbang.h>
40#include <linux/types.h>
41 41
42#include "spi-fsl-lib.h" 42#include "spi-fsl-lib.h"
43#include "spi-fsl-cpm.h" 43#include "spi-fsl-cpm.h"