diff options
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-bcm63xx.c | 11 | ||||
-rw-r--r-- | drivers/spi/spi-butterfly.c | 30 | ||||
-rw-r--r-- | drivers/spi/spi-cadence.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi-davinci.c | 17 | ||||
-rw-r--r-- | drivers/spi/spi-dw-mid.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-dw.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-dw.h | 2 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-dspi.c | 12 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-espi.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi-mt65xx.c | 54 | ||||
-rw-r--r-- | drivers/spi/spi-pl022.c | 28 | ||||
-rw-r--r-- | drivers/spi/spi-sun4i.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi.c | 7 | ||||
-rw-r--r-- | drivers/spi/spidev.c | 2 |
14 files changed, 108 insertions, 77 deletions
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index 06858e04ec59..fee747030ee6 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c | |||
@@ -207,6 +207,9 @@ static void bcm63xx_spi_setup_transfer(struct spi_device *spi, | |||
207 | u8 clk_cfg, reg; | 207 | u8 clk_cfg, reg; |
208 | int i; | 208 | int i; |
209 | 209 | ||
210 | /* Default to lowest clock configuration */ | ||
211 | clk_cfg = SPI_CLK_0_391MHZ; | ||
212 | |||
210 | /* Find the closest clock configuration */ | 213 | /* Find the closest clock configuration */ |
211 | for (i = 0; i < SPI_CLK_MASK; i++) { | 214 | for (i = 0; i < SPI_CLK_MASK; i++) { |
212 | if (t->speed_hz >= bcm63xx_spi_freq_table[i][0]) { | 215 | if (t->speed_hz >= bcm63xx_spi_freq_table[i][0]) { |
@@ -215,10 +218,6 @@ static void bcm63xx_spi_setup_transfer(struct spi_device *spi, | |||
215 | } | 218 | } |
216 | } | 219 | } |
217 | 220 | ||
218 | /* No matching configuration found, default to lowest */ | ||
219 | if (i == SPI_CLK_MASK) | ||
220 | clk_cfg = SPI_CLK_0_391MHZ; | ||
221 | |||
222 | /* clear existing clock configuration bits of the register */ | 221 | /* clear existing clock configuration bits of the register */ |
223 | reg = bcm_spi_readb(bs, SPI_CLK_CFG); | 222 | reg = bcm_spi_readb(bs, SPI_CLK_CFG); |
224 | reg &= ~SPI_CLK_MASK; | 223 | reg &= ~SPI_CLK_MASK; |
@@ -562,8 +561,8 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) | |||
562 | goto out_clk_disable; | 561 | goto out_clk_disable; |
563 | } | 562 | } |
564 | 563 | ||
565 | dev_info(dev, "at 0x%08x (irq %d, FIFOs size %d)\n", | 564 | dev_info(dev, "at %pr (irq %d, FIFOs size %d)\n", |
566 | r->start, irq, bs->fifo_size); | 565 | r, irq, bs->fifo_size); |
567 | 566 | ||
568 | return 0; | 567 | return 0; |
569 | 568 | ||
diff --git a/drivers/spi/spi-butterfly.c b/drivers/spi/spi-butterfly.c index 9a95862986c8..22a31e4a1a11 100644 --- a/drivers/spi/spi-butterfly.c +++ b/drivers/spi/spi-butterfly.c | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | #include <linux/mtd/partitions.h> | 28 | #include <linux/mtd/partitions.h> |
29 | 29 | ||
30 | |||
31 | /* | 30 | /* |
32 | * This uses SPI to talk with an "AVR Butterfly", which is a $US20 card | 31 | * This uses SPI to talk with an "AVR Butterfly", which is a $US20 card |
33 | * with a battery powered AVR microcontroller and lots of goodies. You | 32 | * with a battery powered AVR microcontroller and lots of goodies. You |
@@ -37,7 +36,6 @@ | |||
37 | * and use this custom parallel port cable. | 36 | * and use this custom parallel port cable. |
38 | */ | 37 | */ |
39 | 38 | ||
40 | |||
41 | /* DATA output bits (pins 2..9 == D0..D7) */ | 39 | /* DATA output bits (pins 2..9 == D0..D7) */ |
42 | #define butterfly_nreset (1 << 1) /* pin 3 */ | 40 | #define butterfly_nreset (1 << 1) /* pin 3 */ |
43 | 41 | ||
@@ -52,14 +50,11 @@ | |||
52 | /* CONTROL output bits */ | 50 | /* CONTROL output bits */ |
53 | #define spi_cs_bit PARPORT_CONTROL_SELECT /* pin 17 */ | 51 | #define spi_cs_bit PARPORT_CONTROL_SELECT /* pin 17 */ |
54 | 52 | ||
55 | |||
56 | |||
57 | static inline struct butterfly *spidev_to_pp(struct spi_device *spi) | 53 | static inline struct butterfly *spidev_to_pp(struct spi_device *spi) |
58 | { | 54 | { |
59 | return spi->controller_data; | 55 | return spi->controller_data; |
60 | } | 56 | } |
61 | 57 | ||
62 | |||
63 | struct butterfly { | 58 | struct butterfly { |
64 | /* REVISIT ... for now, this must be first */ | 59 | /* REVISIT ... for now, this must be first */ |
65 | struct spi_bitbang bitbang; | 60 | struct spi_bitbang bitbang; |
@@ -140,7 +135,6 @@ static void butterfly_chipselect(struct spi_device *spi, int value) | |||
140 | parport_frob_control(pp->port, spi_cs_bit, value ? spi_cs_bit : 0); | 135 | parport_frob_control(pp->port, spi_cs_bit, value ? spi_cs_bit : 0); |
141 | } | 136 | } |
142 | 137 | ||
143 | |||
144 | /* we only needed to implement one mode here, and choose SPI_MODE_0 */ | 138 | /* we only needed to implement one mode here, and choose SPI_MODE_0 */ |
145 | 139 | ||
146 | #define spidelay(X) do { } while (0) | 140 | #define spidelay(X) do { } while (0) |
@@ -149,9 +143,8 @@ static void butterfly_chipselect(struct spi_device *spi, int value) | |||
149 | #include "spi-bitbang-txrx.h" | 143 | #include "spi-bitbang-txrx.h" |
150 | 144 | ||
151 | static u32 | 145 | static u32 |
152 | butterfly_txrx_word_mode0(struct spi_device *spi, | 146 | butterfly_txrx_word_mode0(struct spi_device *spi, unsigned nsecs, u32 word, |
153 | unsigned nsecs, | 147 | u8 bits) |
154 | u32 word, u8 bits) | ||
155 | { | 148 | { |
156 | return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits); | 149 | return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits); |
157 | } | 150 | } |
@@ -186,7 +179,6 @@ static struct flash_platform_data flash = { | |||
186 | .nr_parts = ARRAY_SIZE(partitions), | 179 | .nr_parts = ARRAY_SIZE(partitions), |
187 | }; | 180 | }; |
188 | 181 | ||
189 | |||
190 | /* REVISIT remove this ugly global and its "only one" limitation */ | 182 | /* REVISIT remove this ugly global and its "only one" limitation */ |
191 | static struct butterfly *butterfly; | 183 | static struct butterfly *butterfly; |
192 | 184 | ||
@@ -197,6 +189,7 @@ static void butterfly_attach(struct parport *p) | |||
197 | struct butterfly *pp; | 189 | struct butterfly *pp; |
198 | struct spi_master *master; | 190 | struct spi_master *master; |
199 | struct device *dev = p->physport->dev; | 191 | struct device *dev = p->physport->dev; |
192 | struct pardev_cb butterfly_cb; | ||
200 | 193 | ||
201 | if (butterfly || !dev) | 194 | if (butterfly || !dev) |
202 | return; | 195 | return; |
@@ -229,9 +222,9 @@ static void butterfly_attach(struct parport *p) | |||
229 | * parport hookup | 222 | * parport hookup |
230 | */ | 223 | */ |
231 | pp->port = p; | 224 | pp->port = p; |
232 | pd = parport_register_device(p, "spi_butterfly", | 225 | memset(&butterfly_cb, 0, sizeof(butterfly_cb)); |
233 | NULL, NULL, NULL, | 226 | butterfly_cb.private = pp; |
234 | 0 /* FLAGS */, pp); | 227 | pd = parport_register_dev_model(p, "spi_butterfly", &butterfly_cb, 0); |
235 | if (!pd) { | 228 | if (!pd) { |
236 | status = -ENOMEM; | 229 | status = -ENOMEM; |
237 | goto clean0; | 230 | goto clean0; |
@@ -262,7 +255,6 @@ static void butterfly_attach(struct parport *p) | |||
262 | parport_write_data(pp->port, pp->lastbyte); | 255 | parport_write_data(pp->port, pp->lastbyte); |
263 | msleep(100); | 256 | msleep(100); |
264 | 257 | ||
265 | |||
266 | /* | 258 | /* |
267 | * Start SPI ... for now, hide that we're two physical busses. | 259 | * Start SPI ... for now, hide that we're two physical busses. |
268 | */ | 260 | */ |
@@ -283,7 +275,7 @@ static void butterfly_attach(struct parport *p) | |||
283 | pp->dataflash = spi_new_device(pp->bitbang.master, &pp->info[0]); | 275 | pp->dataflash = spi_new_device(pp->bitbang.master, &pp->info[0]); |
284 | if (pp->dataflash) | 276 | if (pp->dataflash) |
285 | pr_debug("%s: dataflash at %s\n", p->name, | 277 | pr_debug("%s: dataflash at %s\n", p->name, |
286 | dev_name(&pp->dataflash->dev)); | 278 | dev_name(&pp->dataflash->dev)); |
287 | 279 | ||
288 | pr_info("%s: AVR Butterfly\n", p->name); | 280 | pr_info("%s: AVR Butterfly\n", p->name); |
289 | butterfly = pp; | 281 | butterfly = pp; |
@@ -297,7 +289,7 @@ clean2: | |||
297 | clean1: | 289 | clean1: |
298 | parport_unregister_device(pd); | 290 | parport_unregister_device(pd); |
299 | clean0: | 291 | clean0: |
300 | (void) spi_master_put(pp->bitbang.master); | 292 | spi_master_put(pp->bitbang.master); |
301 | done: | 293 | done: |
302 | pr_debug("%s: butterfly probe, fail %d\n", p->name, status); | 294 | pr_debug("%s: butterfly probe, fail %d\n", p->name, status); |
303 | } | 295 | } |
@@ -325,16 +317,16 @@ static void butterfly_detach(struct parport *p) | |||
325 | parport_release(pp->pd); | 317 | parport_release(pp->pd); |
326 | parport_unregister_device(pp->pd); | 318 | parport_unregister_device(pp->pd); |
327 | 319 | ||
328 | (void) spi_master_put(pp->bitbang.master); | 320 | spi_master_put(pp->bitbang.master); |
329 | } | 321 | } |
330 | 322 | ||
331 | static struct parport_driver butterfly_driver = { | 323 | static struct parport_driver butterfly_driver = { |
332 | .name = "spi_butterfly", | 324 | .name = "spi_butterfly", |
333 | .attach = butterfly_attach, | 325 | .match_port = butterfly_attach, |
334 | .detach = butterfly_detach, | 326 | .detach = butterfly_detach, |
327 | .devmodel = true, | ||
335 | }; | 328 | }; |
336 | 329 | ||
337 | |||
338 | static int __init butterfly_init(void) | 330 | static int __init butterfly_init(void) |
339 | { | 331 | { |
340 | return parport_register_driver(&butterfly_driver); | 332 | return parport_register_driver(&butterfly_driver); |
diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index 5a6749881ff9..121a4135b540 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c | |||
@@ -617,8 +617,7 @@ static int cdns_spi_remove(struct platform_device *pdev) | |||
617 | */ | 617 | */ |
618 | static int __maybe_unused cdns_spi_suspend(struct device *dev) | 618 | static int __maybe_unused cdns_spi_suspend(struct device *dev) |
619 | { | 619 | { |
620 | struct platform_device *pdev = container_of(dev, | 620 | struct platform_device *pdev = to_platform_device(dev); |
621 | struct platform_device, dev); | ||
622 | struct spi_master *master = platform_get_drvdata(pdev); | 621 | struct spi_master *master = platform_get_drvdata(pdev); |
623 | struct cdns_spi *xspi = spi_master_get_devdata(master); | 622 | struct cdns_spi *xspi = spi_master_get_devdata(master); |
624 | 623 | ||
@@ -641,8 +640,7 @@ static int __maybe_unused cdns_spi_suspend(struct device *dev) | |||
641 | */ | 640 | */ |
642 | static int __maybe_unused cdns_spi_resume(struct device *dev) | 641 | static int __maybe_unused cdns_spi_resume(struct device *dev) |
643 | { | 642 | { |
644 | struct platform_device *pdev = container_of(dev, | 643 | struct platform_device *pdev = to_platform_device(dev); |
645 | struct platform_device, dev); | ||
646 | struct spi_master *master = platform_get_drvdata(pdev); | 644 | struct spi_master *master = platform_get_drvdata(pdev); |
647 | struct cdns_spi *xspi = spi_master_get_devdata(master); | 645 | struct cdns_spi *xspi = spi_master_get_devdata(master); |
648 | int ret = 0; | 646 | int ret = 0; |
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 7d3af3eacf57..fddb7a3be322 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c | |||
@@ -477,33 +477,33 @@ static int davinci_spi_check_error(struct davinci_spi *dspi, int int_status) | |||
477 | struct device *sdev = dspi->bitbang.master->dev.parent; | 477 | struct device *sdev = dspi->bitbang.master->dev.parent; |
478 | 478 | ||
479 | if (int_status & SPIFLG_TIMEOUT_MASK) { | 479 | if (int_status & SPIFLG_TIMEOUT_MASK) { |
480 | dev_dbg(sdev, "SPI Time-out Error\n"); | 480 | dev_err(sdev, "SPI Time-out Error\n"); |
481 | return -ETIMEDOUT; | 481 | return -ETIMEDOUT; |
482 | } | 482 | } |
483 | if (int_status & SPIFLG_DESYNC_MASK) { | 483 | if (int_status & SPIFLG_DESYNC_MASK) { |
484 | dev_dbg(sdev, "SPI Desynchronization Error\n"); | 484 | dev_err(sdev, "SPI Desynchronization Error\n"); |
485 | return -EIO; | 485 | return -EIO; |
486 | } | 486 | } |
487 | if (int_status & SPIFLG_BITERR_MASK) { | 487 | if (int_status & SPIFLG_BITERR_MASK) { |
488 | dev_dbg(sdev, "SPI Bit error\n"); | 488 | dev_err(sdev, "SPI Bit error\n"); |
489 | return -EIO; | 489 | return -EIO; |
490 | } | 490 | } |
491 | 491 | ||
492 | if (dspi->version == SPI_VERSION_2) { | 492 | if (dspi->version == SPI_VERSION_2) { |
493 | if (int_status & SPIFLG_DLEN_ERR_MASK) { | 493 | if (int_status & SPIFLG_DLEN_ERR_MASK) { |
494 | dev_dbg(sdev, "SPI Data Length Error\n"); | 494 | dev_err(sdev, "SPI Data Length Error\n"); |
495 | return -EIO; | 495 | return -EIO; |
496 | } | 496 | } |
497 | if (int_status & SPIFLG_PARERR_MASK) { | 497 | if (int_status & SPIFLG_PARERR_MASK) { |
498 | dev_dbg(sdev, "SPI Parity Error\n"); | 498 | dev_err(sdev, "SPI Parity Error\n"); |
499 | return -EIO; | 499 | return -EIO; |
500 | } | 500 | } |
501 | if (int_status & SPIFLG_OVRRUN_MASK) { | 501 | if (int_status & SPIFLG_OVRRUN_MASK) { |
502 | dev_dbg(sdev, "SPI Data Overrun error\n"); | 502 | dev_err(sdev, "SPI Data Overrun error\n"); |
503 | return -EIO; | 503 | return -EIO; |
504 | } | 504 | } |
505 | if (int_status & SPIFLG_BUF_INIT_ACTIVE_MASK) { | 505 | if (int_status & SPIFLG_BUF_INIT_ACTIVE_MASK) { |
506 | dev_dbg(sdev, "SPI Buffer Init Active\n"); | 506 | dev_err(sdev, "SPI Buffer Init Active\n"); |
507 | return -EBUSY; | 507 | return -EBUSY; |
508 | } | 508 | } |
509 | } | 509 | } |
@@ -703,7 +703,8 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) | |||
703 | 703 | ||
704 | /* Wait for the transfer to complete */ | 704 | /* Wait for the transfer to complete */ |
705 | if (spicfg->io_type != SPI_IO_TYPE_POLL) { | 705 | if (spicfg->io_type != SPI_IO_TYPE_POLL) { |
706 | wait_for_completion_interruptible(&(dspi->done)); | 706 | if (wait_for_completion_timeout(&dspi->done, HZ) == 0) |
707 | errors = SPIFLG_TIMEOUT_MASK; | ||
707 | } else { | 708 | } else { |
708 | while (dspi->rcount > 0 || dspi->wcount > 0) { | 709 | while (dspi->rcount > 0 || dspi->wcount > 0) { |
709 | errors = davinci_spi_process_events(dspi); | 710 | errors = davinci_spi_process_events(dspi); |
diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c index bb1052e748f2..9185f6c08459 100644 --- a/drivers/spi/spi-dw-mid.c +++ b/drivers/spi/spi-dw-mid.c | |||
@@ -283,7 +283,7 @@ static void mid_spi_dma_stop(struct dw_spi *dws) | |||
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | static struct dw_spi_dma_ops mid_dma_ops = { | 286 | static const struct dw_spi_dma_ops mid_dma_ops = { |
287 | .dma_init = mid_spi_dma_init, | 287 | .dma_init = mid_spi_dma_init, |
288 | .dma_exit = mid_spi_dma_exit, | 288 | .dma_exit = mid_spi_dma_exit, |
289 | .dma_setup = mid_spi_dma_setup, | 289 | .dma_setup = mid_spi_dma_setup, |
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 882cd6618cd5..c09bb745693a 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c | |||
@@ -425,7 +425,7 @@ static int dw_spi_setup(struct spi_device *spi) | |||
425 | chip->type = chip_info->type; | 425 | chip->type = chip_info->type; |
426 | } | 426 | } |
427 | 427 | ||
428 | chip->tmode = 0; /* Tx & Rx */ | 428 | chip->tmode = SPI_TMOD_TR; |
429 | 429 | ||
430 | if (gpio_is_valid(spi->cs_gpio)) { | 430 | if (gpio_is_valid(spi->cs_gpio)) { |
431 | ret = gpio_direction_output(spi->cs_gpio, | 431 | ret = gpio_direction_output(spi->cs_gpio, |
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 35589a270468..61bc3cbab38d 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h | |||
@@ -130,7 +130,7 @@ struct dw_spi { | |||
130 | struct dma_chan *rxchan; | 130 | struct dma_chan *rxchan; |
131 | unsigned long dma_chan_busy; | 131 | unsigned long dma_chan_busy; |
132 | dma_addr_t dma_addr; /* phy address of the Data register */ | 132 | dma_addr_t dma_addr; /* phy address of the Data register */ |
133 | struct dw_spi_dma_ops *dma_ops; | 133 | const struct dw_spi_dma_ops *dma_ops; |
134 | void *dma_tx; | 134 | void *dma_tx; |
135 | void *dma_rx; | 135 | void *dma_rx; |
136 | 136 | ||
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 59a11437db70..39412c9097c6 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c | |||
@@ -167,7 +167,7 @@ static inline int is_double_byte_mode(struct fsl_dspi *dspi) | |||
167 | { | 167 | { |
168 | unsigned int val; | 168 | unsigned int val; |
169 | 169 | ||
170 | regmap_read(dspi->regmap, SPI_CTAR(dspi->cs), &val); | 170 | regmap_read(dspi->regmap, SPI_CTAR(0), &val); |
171 | 171 | ||
172 | return ((val & SPI_FRAME_BITS_MASK) == SPI_FRAME_BITS(8)) ? 0 : 1; | 172 | return ((val & SPI_FRAME_BITS_MASK) == SPI_FRAME_BITS(8)) ? 0 : 1; |
173 | } | 173 | } |
@@ -257,7 +257,7 @@ static u32 dspi_data_to_pushr(struct fsl_dspi *dspi, int tx_word) | |||
257 | 257 | ||
258 | return SPI_PUSHR_TXDATA(d16) | | 258 | return SPI_PUSHR_TXDATA(d16) | |
259 | SPI_PUSHR_PCS(dspi->cs) | | 259 | SPI_PUSHR_PCS(dspi->cs) | |
260 | SPI_PUSHR_CTAS(dspi->cs) | | 260 | SPI_PUSHR_CTAS(0) | |
261 | SPI_PUSHR_CONT; | 261 | SPI_PUSHR_CONT; |
262 | } | 262 | } |
263 | 263 | ||
@@ -290,7 +290,7 @@ static int dspi_eoq_write(struct fsl_dspi *dspi) | |||
290 | */ | 290 | */ |
291 | if (tx_word && (dspi->len == 1)) { | 291 | if (tx_word && (dspi->len == 1)) { |
292 | dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; | 292 | dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; |
293 | regmap_update_bits(dspi->regmap, SPI_CTAR(dspi->cs), | 293 | regmap_update_bits(dspi->regmap, SPI_CTAR(0), |
294 | SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); | 294 | SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); |
295 | tx_word = 0; | 295 | tx_word = 0; |
296 | } | 296 | } |
@@ -339,7 +339,7 @@ static int dspi_tcfq_write(struct fsl_dspi *dspi) | |||
339 | 339 | ||
340 | if (tx_word && (dspi->len == 1)) { | 340 | if (tx_word && (dspi->len == 1)) { |
341 | dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; | 341 | dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; |
342 | regmap_update_bits(dspi->regmap, SPI_CTAR(dspi->cs), | 342 | regmap_update_bits(dspi->regmap, SPI_CTAR(0), |
343 | SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); | 343 | SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); |
344 | tx_word = 0; | 344 | tx_word = 0; |
345 | } | 345 | } |
@@ -407,7 +407,7 @@ static int dspi_transfer_one_message(struct spi_master *master, | |||
407 | regmap_update_bits(dspi->regmap, SPI_MCR, | 407 | regmap_update_bits(dspi->regmap, SPI_MCR, |
408 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, | 408 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, |
409 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); | 409 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); |
410 | regmap_write(dspi->regmap, SPI_CTAR(dspi->cs), | 410 | regmap_write(dspi->regmap, SPI_CTAR(0), |
411 | dspi->cur_chip->ctar_val); | 411 | dspi->cur_chip->ctar_val); |
412 | 412 | ||
413 | trans_mode = dspi->devtype_data->trans_mode; | 413 | trans_mode = dspi->devtype_data->trans_mode; |
@@ -566,7 +566,7 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id) | |||
566 | if (!dspi->len) { | 566 | if (!dspi->len) { |
567 | if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM) { | 567 | if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM) { |
568 | regmap_update_bits(dspi->regmap, | 568 | regmap_update_bits(dspi->regmap, |
569 | SPI_CTAR(dspi->cs), | 569 | SPI_CTAR(0), |
570 | SPI_FRAME_BITS_MASK, | 570 | SPI_FRAME_BITS_MASK, |
571 | SPI_FRAME_BITS(16)); | 571 | SPI_FRAME_BITS(16)); |
572 | dspi->dataflags &= ~TRAN_STATE_WORD_ODD_NUM; | 572 | dspi->dataflags &= ~TRAN_STATE_WORD_ODD_NUM; |
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index c27124a5ec8e..7fd6a4c009d2 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
@@ -643,6 +643,11 @@ static int fsl_espi_runtime_resume(struct device *dev) | |||
643 | } | 643 | } |
644 | #endif | 644 | #endif |
645 | 645 | ||
646 | static size_t fsl_espi_max_transfer_size(struct spi_device *spi) | ||
647 | { | ||
648 | return SPCOM_TRANLEN_MAX; | ||
649 | } | ||
650 | |||
646 | static struct spi_master * fsl_espi_probe(struct device *dev, | 651 | static struct spi_master * fsl_espi_probe(struct device *dev, |
647 | struct resource *mem, unsigned int irq) | 652 | struct resource *mem, unsigned int irq) |
648 | { | 653 | { |
@@ -670,6 +675,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev, | |||
670 | master->cleanup = fsl_espi_cleanup; | 675 | master->cleanup = fsl_espi_cleanup; |
671 | master->transfer_one_message = fsl_espi_do_one_msg; | 676 | master->transfer_one_message = fsl_espi_do_one_msg; |
672 | master->auto_runtime_pm = true; | 677 | master->auto_runtime_pm = true; |
678 | master->max_transfer_size = fsl_espi_max_transfer_size; | ||
673 | 679 | ||
674 | mpc8xxx_spi = spi_master_get_devdata(master); | 680 | mpc8xxx_spi = spi_master_get_devdata(master); |
675 | 681 | ||
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 563954a61424..4895fe3944f1 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c | |||
@@ -323,7 +323,8 @@ static int mtk_spi_fifo_transfer(struct spi_master *master, | |||
323 | struct spi_device *spi, | 323 | struct spi_device *spi, |
324 | struct spi_transfer *xfer) | 324 | struct spi_transfer *xfer) |
325 | { | 325 | { |
326 | int cnt; | 326 | int cnt, remainder; |
327 | u32 reg_val; | ||
327 | struct mtk_spi *mdata = spi_master_get_devdata(master); | 328 | struct mtk_spi *mdata = spi_master_get_devdata(master); |
328 | 329 | ||
329 | mdata->cur_transfer = xfer; | 330 | mdata->cur_transfer = xfer; |
@@ -331,12 +332,16 @@ static int mtk_spi_fifo_transfer(struct spi_master *master, | |||
331 | mtk_spi_prepare_transfer(master, xfer); | 332 | mtk_spi_prepare_transfer(master, xfer); |
332 | mtk_spi_setup_packet(master); | 333 | mtk_spi_setup_packet(master); |
333 | 334 | ||
334 | if (xfer->len % 4) | 335 | cnt = xfer->len / 4; |
335 | cnt = xfer->len / 4 + 1; | ||
336 | else | ||
337 | cnt = xfer->len / 4; | ||
338 | iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt); | 336 | iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt); |
339 | 337 | ||
338 | remainder = xfer->len % 4; | ||
339 | if (remainder > 0) { | ||
340 | reg_val = 0; | ||
341 | memcpy(®_val, xfer->tx_buf + (cnt * 4), remainder); | ||
342 | writel(reg_val, mdata->base + SPI_TX_DATA_REG); | ||
343 | } | ||
344 | |||
340 | mtk_spi_enable_transfer(master); | 345 | mtk_spi_enable_transfer(master); |
341 | 346 | ||
342 | return 1; | 347 | return 1; |
@@ -410,7 +415,7 @@ static int mtk_spi_setup(struct spi_device *spi) | |||
410 | if (!spi->controller_data) | 415 | if (!spi->controller_data) |
411 | spi->controller_data = (void *)&mtk_default_chip_info; | 416 | spi->controller_data = (void *)&mtk_default_chip_info; |
412 | 417 | ||
413 | if (mdata->dev_comp->need_pad_sel) | 418 | if (mdata->dev_comp->need_pad_sel && gpio_is_valid(spi->cs_gpio)) |
414 | gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); | 419 | gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); |
415 | 420 | ||
416 | return 0; | 421 | return 0; |
@@ -418,7 +423,7 @@ static int mtk_spi_setup(struct spi_device *spi) | |||
418 | 423 | ||
419 | static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id) | 424 | static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id) |
420 | { | 425 | { |
421 | u32 cmd, reg_val, cnt; | 426 | u32 cmd, reg_val, cnt, remainder; |
422 | struct spi_master *master = dev_id; | 427 | struct spi_master *master = dev_id; |
423 | struct mtk_spi *mdata = spi_master_get_devdata(master); | 428 | struct mtk_spi *mdata = spi_master_get_devdata(master); |
424 | struct spi_transfer *trans = mdata->cur_transfer; | 429 | struct spi_transfer *trans = mdata->cur_transfer; |
@@ -431,12 +436,15 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id) | |||
431 | 436 | ||
432 | if (!master->can_dma(master, master->cur_msg->spi, trans)) { | 437 | if (!master->can_dma(master, master->cur_msg->spi, trans)) { |
433 | if (trans->rx_buf) { | 438 | if (trans->rx_buf) { |
434 | if (mdata->xfer_len % 4) | 439 | cnt = mdata->xfer_len / 4; |
435 | cnt = mdata->xfer_len / 4 + 1; | ||
436 | else | ||
437 | cnt = mdata->xfer_len / 4; | ||
438 | ioread32_rep(mdata->base + SPI_RX_DATA_REG, | 440 | ioread32_rep(mdata->base + SPI_RX_DATA_REG, |
439 | trans->rx_buf, cnt); | 441 | trans->rx_buf, cnt); |
442 | remainder = mdata->xfer_len % 4; | ||
443 | if (remainder > 0) { | ||
444 | reg_val = readl(mdata->base + SPI_RX_DATA_REG); | ||
445 | memcpy(trans->rx_buf + (cnt * 4), | ||
446 | ®_val, remainder); | ||
447 | } | ||
440 | } | 448 | } |
441 | spi_finalize_current_transfer(master); | 449 | spi_finalize_current_transfer(master); |
442 | return IRQ_HANDLED; | 450 | return IRQ_HANDLED; |
@@ -632,13 +640,23 @@ static int mtk_spi_probe(struct platform_device *pdev) | |||
632 | goto err_put_master; | 640 | goto err_put_master; |
633 | } | 641 | } |
634 | 642 | ||
635 | for (i = 0; i < master->num_chipselect; i++) { | 643 | if (!master->cs_gpios && master->num_chipselect > 1) { |
636 | ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i], | 644 | dev_err(&pdev->dev, |
637 | dev_name(&pdev->dev)); | 645 | "cs_gpios not specified and num_chipselect > 1\n"); |
638 | if (ret) { | 646 | ret = -EINVAL; |
639 | dev_err(&pdev->dev, | 647 | goto err_put_master; |
640 | "can't get CS GPIO %i\n", i); | 648 | } |
641 | goto err_put_master; | 649 | |
650 | if (master->cs_gpios) { | ||
651 | for (i = 0; i < master->num_chipselect; i++) { | ||
652 | ret = devm_gpio_request(&pdev->dev, | ||
653 | master->cs_gpios[i], | ||
654 | dev_name(&pdev->dev)); | ||
655 | if (ret) { | ||
656 | dev_err(&pdev->dev, | ||
657 | "can't get CS GPIO %i\n", i); | ||
658 | goto err_put_master; | ||
659 | } | ||
642 | } | 660 | } |
643 | } | 661 | } |
644 | } | 662 | } |
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 94af80676684..5e5fd77e2711 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
@@ -1171,19 +1171,31 @@ err_no_rxchan: | |||
1171 | static int pl022_dma_autoprobe(struct pl022 *pl022) | 1171 | static int pl022_dma_autoprobe(struct pl022 *pl022) |
1172 | { | 1172 | { |
1173 | struct device *dev = &pl022->adev->dev; | 1173 | struct device *dev = &pl022->adev->dev; |
1174 | struct dma_chan *chan; | ||
1175 | int err; | ||
1174 | 1176 | ||
1175 | /* automatically configure DMA channels from platform, normally using DT */ | 1177 | /* automatically configure DMA channels from platform, normally using DT */ |
1176 | pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx"); | 1178 | chan = dma_request_slave_channel_reason(dev, "rx"); |
1177 | if (!pl022->dma_rx_channel) | 1179 | if (IS_ERR(chan)) { |
1180 | err = PTR_ERR(chan); | ||
1178 | goto err_no_rxchan; | 1181 | goto err_no_rxchan; |
1182 | } | ||
1183 | |||
1184 | pl022->dma_rx_channel = chan; | ||
1179 | 1185 | ||
1180 | pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx"); | 1186 | chan = dma_request_slave_channel_reason(dev, "tx"); |
1181 | if (!pl022->dma_tx_channel) | 1187 | if (IS_ERR(chan)) { |
1188 | err = PTR_ERR(chan); | ||
1182 | goto err_no_txchan; | 1189 | goto err_no_txchan; |
1190 | } | ||
1191 | |||
1192 | pl022->dma_tx_channel = chan; | ||
1183 | 1193 | ||
1184 | pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); | 1194 | pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); |
1185 | if (!pl022->dummypage) | 1195 | if (!pl022->dummypage) { |
1196 | err = -ENOMEM; | ||
1186 | goto err_no_dummypage; | 1197 | goto err_no_dummypage; |
1198 | } | ||
1187 | 1199 | ||
1188 | return 0; | 1200 | return 0; |
1189 | 1201 | ||
@@ -1194,7 +1206,7 @@ err_no_txchan: | |||
1194 | dma_release_channel(pl022->dma_rx_channel); | 1206 | dma_release_channel(pl022->dma_rx_channel); |
1195 | pl022->dma_rx_channel = NULL; | 1207 | pl022->dma_rx_channel = NULL; |
1196 | err_no_rxchan: | 1208 | err_no_rxchan: |
1197 | return -ENODEV; | 1209 | return err; |
1198 | } | 1210 | } |
1199 | 1211 | ||
1200 | static void terminate_dma(struct pl022 *pl022) | 1212 | static void terminate_dma(struct pl022 *pl022) |
@@ -2236,6 +2248,10 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2236 | 2248 | ||
2237 | /* Get DMA channels, try autoconfiguration first */ | 2249 | /* Get DMA channels, try autoconfiguration first */ |
2238 | status = pl022_dma_autoprobe(pl022); | 2250 | status = pl022_dma_autoprobe(pl022); |
2251 | if (status == -EPROBE_DEFER) { | ||
2252 | dev_dbg(dev, "deferring probe to get DMA channel\n"); | ||
2253 | goto err_no_irq; | ||
2254 | } | ||
2239 | 2255 | ||
2240 | /* If that failed, use channels from platform_info */ | 2256 | /* If that failed, use channels from platform_info */ |
2241 | if (status == 0) | 2257 | if (status == 0) |
diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index fbb0a4d74e91..a6d936c68674 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c | |||
@@ -140,6 +140,9 @@ static void sun4i_spi_set_cs(struct spi_device *spi, bool enable) | |||
140 | reg &= ~SUN4I_CTL_CS_MASK; | 140 | reg &= ~SUN4I_CTL_CS_MASK; |
141 | reg |= SUN4I_CTL_CS(spi->chip_select); | 141 | reg |= SUN4I_CTL_CS(spi->chip_select); |
142 | 142 | ||
143 | /* We want to control the chip select manually */ | ||
144 | reg |= SUN4I_CTL_CS_MANUAL; | ||
145 | |||
143 | if (enable) | 146 | if (enable) |
144 | reg |= SUN4I_CTL_CS_LEVEL; | 147 | reg |= SUN4I_CTL_CS_LEVEL; |
145 | else | 148 | else |
@@ -222,9 +225,6 @@ static int sun4i_spi_transfer_one(struct spi_master *master, | |||
222 | else | 225 | else |
223 | reg |= SUN4I_CTL_DHB; | 226 | reg |= SUN4I_CTL_DHB; |
224 | 227 | ||
225 | /* We want to control the chip select manually */ | ||
226 | reg |= SUN4I_CTL_CS_MANUAL; | ||
227 | |||
228 | sun4i_spi_write(sspi, SUN4I_CTL_REG, reg); | 228 | sun4i_spi_write(sspi, SUN4I_CTL_REG, reg); |
229 | 229 | ||
230 | /* Ensure that we have a parent clock fast enough */ | 230 | /* Ensure that we have a parent clock fast enough */ |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index e2415be209d5..a678a7f1a65d 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -84,8 +84,7 @@ static ssize_t spi_device_##field##_show(struct device *dev, \ | |||
84 | struct device_attribute *attr, \ | 84 | struct device_attribute *attr, \ |
85 | char *buf) \ | 85 | char *buf) \ |
86 | { \ | 86 | { \ |
87 | struct spi_device *spi = container_of(dev, \ | 87 | struct spi_device *spi = to_spi_device(dev); \ |
88 | struct spi_device, dev); \ | ||
89 | return spi_statistics_##field##_show(&spi->statistics, buf); \ | 88 | return spi_statistics_##field##_show(&spi->statistics, buf); \ |
90 | } \ | 89 | } \ |
91 | static struct device_attribute dev_attr_spi_device_##field = { \ | 90 | static struct device_attribute dev_attr_spi_device_##field = { \ |
@@ -376,6 +375,7 @@ static void spi_drv_shutdown(struct device *dev) | |||
376 | 375 | ||
377 | /** | 376 | /** |
378 | * __spi_register_driver - register a SPI driver | 377 | * __spi_register_driver - register a SPI driver |
378 | * @owner: owner module of the driver to register | ||
379 | * @sdrv: the driver to register | 379 | * @sdrv: the driver to register |
380 | * Context: can sleep | 380 | * Context: can sleep |
381 | * | 381 | * |
@@ -1704,7 +1704,7 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size) | |||
1704 | master->bus_num = -1; | 1704 | master->bus_num = -1; |
1705 | master->num_chipselect = 1; | 1705 | master->num_chipselect = 1; |
1706 | master->dev.class = &spi_master_class; | 1706 | master->dev.class = &spi_master_class; |
1707 | master->dev.parent = get_device(dev); | 1707 | master->dev.parent = dev; |
1708 | spi_master_set_devdata(master, &master[1]); | 1708 | spi_master_set_devdata(master, &master[1]); |
1709 | 1709 | ||
1710 | return master; | 1710 | return master; |
@@ -2130,6 +2130,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) | |||
2130 | * Set transfer tx_nbits and rx_nbits as single transfer default | 2130 | * Set transfer tx_nbits and rx_nbits as single transfer default |
2131 | * (SPI_NBITS_SINGLE) if it is not set for this transfer. | 2131 | * (SPI_NBITS_SINGLE) if it is not set for this transfer. |
2132 | */ | 2132 | */ |
2133 | message->frame_length = 0; | ||
2133 | list_for_each_entry(xfer, &message->transfers, transfer_list) { | 2134 | list_for_each_entry(xfer, &message->transfers, transfer_list) { |
2134 | message->frame_length += xfer->len; | 2135 | message->frame_length += xfer->len; |
2135 | if (!xfer->bits_per_word) | 2136 | if (!xfer->bits_per_word) |
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 91a0fcd72423..d0e7dfc647cf 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -651,11 +651,11 @@ static int spidev_release(struct inode *inode, struct file *filp) | |||
651 | kfree(spidev->rx_buffer); | 651 | kfree(spidev->rx_buffer); |
652 | spidev->rx_buffer = NULL; | 652 | spidev->rx_buffer = NULL; |
653 | 653 | ||
654 | spin_lock_irq(&spidev->spi_lock); | ||
654 | if (spidev->spi) | 655 | if (spidev->spi) |
655 | spidev->speed_hz = spidev->spi->max_speed_hz; | 656 | spidev->speed_hz = spidev->spi->max_speed_hz; |
656 | 657 | ||
657 | /* ... after we unbound from the underlying device? */ | 658 | /* ... after we unbound from the underlying device? */ |
658 | spin_lock_irq(&spidev->spi_lock); | ||
659 | dofree = (spidev->spi == NULL); | 659 | dofree = (spidev->spi == NULL); |
660 | spin_unlock_irq(&spidev->spi_lock); | 660 | spin_unlock_irq(&spidev->spi_lock); |
661 | 661 | ||