diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-13 22:15:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-13 22:15:11 -0500 |
commit | d3b43e12b2c8c69f79ab76dcdc5956f47c376378 (patch) | |
tree | 4fba9e425d7407e5abd5ab50d5ac09398ec5bff6 /drivers/spi | |
parent | 15de0599277f3477ddd11766282587f12d214252 (diff) | |
parent | 7cb943615aabbd72624f77f0a84b8c5d627cf846 (diff) |
Merge tag 'spi-for-linus' of git://git.secretlab.ca/git/linux-2.6
Pull SPI updates from Grant Likely:
"Primarily SPI device driver bug fixes, one removal of an old driver,
and some new tegra support. There is some core code change too, but
all in all pretty small stuff.
The new features to note are:
- Common code for describing GPIO CS lines in the device tree
- Remove the SPI_BUFSIZ limitation on spi_write_the_read()
- core spi ensures bits_per_word is set correctly
- SPARC can now use SPI"
* tag 'spi-for-linus' of git://git.secretlab.ca/git/linux-2.6: (36 commits)
spi/sparc: Allow of_register_spi_devices for sparc
spi: Remove HOTPLUG section attributes
spi: Add support for specifying 3-wire mode via device tree
spi: Fix comparison of different integer types
spi/orion: Add SPI_CHPA and SPI_CPOL support to kirkwood driver.
spi/sh: Add SH Mobile series as dependency to MSIOF controller
spi/sh-msiof: Remove unneeded clock name
spi: Remove SPI_BUFSIZ restriction on spi_write_then_read()
spi/stmp: remove obsolete driver
spi/clps711x: New SPI master driver
spi: omap2-mcspi: remove duplicate inclusion of linux/err.h
spi: omap2-mcspi: Fix the redifine warning
spi/sh-hspi: add CS manual control support
of_spi: add generic binding support to specify cs gpio
spi: omap2-mcspi: remove duplicated include from spi-omap2-mcspi.c
spi/bitbang: (cosmetic) simplify list manipulation
spi/bitbang: avoid needless loop flow manipulations
spi/omap: fix D0/D1 direction confusion
spi: tegra: add spi driver for sflash controller
spi: Dont call master->setup if not populated
...
Diffstat (limited to 'drivers/spi')
52 files changed, 2749 insertions, 938 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 1acae359cabe..2e188e1127eb 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -123,6 +123,13 @@ config SPI_BUTTERFLY | |||
123 | inexpensive battery powered microcontroller evaluation board. | 123 | inexpensive battery powered microcontroller evaluation board. |
124 | This same cable can be used to flash new firmware. | 124 | This same cable can be used to flash new firmware. |
125 | 125 | ||
126 | config SPI_CLPS711X | ||
127 | tristate "CLPS711X host SPI controller" | ||
128 | depends on ARCH_CLPS711X | ||
129 | help | ||
130 | This enables dedicated general purpose SPI/Microwire1-compatible | ||
131 | master mode interface (SSI1) for CLPS711X-based CPUs. | ||
132 | |||
126 | config SPI_COLDFIRE_QSPI | 133 | config SPI_COLDFIRE_QSPI |
127 | tristate "Freescale Coldfire QSPI controller" | 134 | tristate "Freescale Coldfire QSPI controller" |
128 | depends on (M520x || M523x || M5249 || M525x || M527x || M528x || M532x) | 135 | depends on (M520x || M523x || M5249 || M525x || M527x || M528x || M532x) |
@@ -341,10 +348,10 @@ config SPI_SC18IS602 | |||
341 | 348 | ||
342 | config SPI_SH_MSIOF | 349 | config SPI_SH_MSIOF |
343 | tristate "SuperH MSIOF SPI controller" | 350 | tristate "SuperH MSIOF SPI controller" |
344 | depends on SUPERH && HAVE_CLK | 351 | depends on (SUPERH || ARCH_SHMOBILE) && HAVE_CLK |
345 | select SPI_BITBANG | 352 | select SPI_BITBANG |
346 | help | 353 | help |
347 | SPI driver for SuperH MSIOF blocks. | 354 | SPI driver for SuperH and SH Mobile MSIOF blocks. |
348 | 355 | ||
349 | config SPI_SH | 356 | config SPI_SH |
350 | tristate "SuperH SPI controller" | 357 | tristate "SuperH SPI controller" |
@@ -372,12 +379,6 @@ config SPI_SIRF | |||
372 | help | 379 | help |
373 | SPI driver for CSR SiRFprimaII SoCs | 380 | SPI driver for CSR SiRFprimaII SoCs |
374 | 381 | ||
375 | config SPI_STMP3XXX | ||
376 | tristate "Freescale STMP37xx/378x SPI/SSP controller" | ||
377 | depends on ARCH_STMP3XXX | ||
378 | help | ||
379 | SPI driver for Freescale STMP37xx/378x SoC SSP interface | ||
380 | |||
381 | config SPI_MXS | 382 | config SPI_MXS |
382 | tristate "Freescale MXS SPI controller" | 383 | tristate "Freescale MXS SPI controller" |
383 | depends on ARCH_MXS | 384 | depends on ARCH_MXS |
@@ -385,6 +386,20 @@ config SPI_MXS | |||
385 | help | 386 | help |
386 | SPI driver for Freescale MXS devices. | 387 | SPI driver for Freescale MXS devices. |
387 | 388 | ||
389 | config SPI_TEGRA20_SFLASH | ||
390 | tristate "Nvidia Tegra20 Serial flash Controller" | ||
391 | depends on ARCH_TEGRA | ||
392 | help | ||
393 | SPI driver for Nvidia Tegra20 Serial flash Controller interface. | ||
394 | The main usecase of this controller is to use spi flash as boot | ||
395 | device. | ||
396 | |||
397 | config SPI_TEGRA20_SLINK | ||
398 | tristate "Nvidia Tegra20/Tegra30 SLINK Controller" | ||
399 | depends on ARCH_TEGRA && TEGRA20_APB_DMA | ||
400 | help | ||
401 | SPI driver for Nvidia Tegra20/Tegra30 SLINK Controller interface. | ||
402 | |||
388 | config SPI_TI_SSP | 403 | config SPI_TI_SSP |
389 | tristate "TI Sequencer Serial Port - SPI Support" | 404 | tristate "TI Sequencer Serial Port - SPI Support" |
390 | depends on MFD_TI_SSP | 405 | depends on MFD_TI_SSP |
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index c48df47e4b0f..64e970ba261c 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile | |||
@@ -19,6 +19,7 @@ obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o | |||
19 | obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o | 19 | obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o |
20 | obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o | 20 | obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o |
21 | obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o | 21 | obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o |
22 | obj-$(CONFIG_SPI_CLPS711X) += spi-clps711x.o | ||
22 | obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi-coldfire-qspi.o | 23 | obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi-coldfire-qspi.o |
23 | obj-$(CONFIG_SPI_DAVINCI) += spi-davinci.o | 24 | obj-$(CONFIG_SPI_DAVINCI) += spi-davinci.o |
24 | obj-$(CONFIG_SPI_DESIGNWARE) += spi-dw.o | 25 | obj-$(CONFIG_SPI_DESIGNWARE) += spi-dw.o |
@@ -59,11 +60,11 @@ obj-$(CONFIG_SPI_SH_HSPI) += spi-sh-hspi.o | |||
59 | obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o | 60 | obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o |
60 | obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o | 61 | obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o |
61 | obj-$(CONFIG_SPI_SIRF) += spi-sirf.o | 62 | obj-$(CONFIG_SPI_SIRF) += spi-sirf.o |
62 | obj-$(CONFIG_SPI_STMP3XXX) += spi-stmp.o | 63 | obj-$(CONFIG_SPI_TEGRA20_SFLASH) += spi-tegra20-sflash.o |
64 | obj-$(CONFIG_SPI_TEGRA20_SLINK) += spi-tegra20-slink.o | ||
63 | obj-$(CONFIG_SPI_TI_SSP) += spi-ti-ssp.o | 65 | obj-$(CONFIG_SPI_TI_SSP) += spi-ti-ssp.o |
64 | obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o | 66 | obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o |
65 | obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o | 67 | obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o |
66 | obj-$(CONFIG_SPI_TXX9) += spi-txx9.o | 68 | obj-$(CONFIG_SPI_TXX9) += spi-txx9.o |
67 | obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o | 69 | obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o |
68 | obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o | 70 | obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o |
69 | |||
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c index f1fec2a19d10..5e7314ac51e9 100644 --- a/drivers/spi/spi-altera.c +++ b/drivers/spi/spi-altera.c | |||
@@ -215,7 +215,7 @@ static irqreturn_t altera_spi_irq(int irq, void *dev) | |||
215 | return IRQ_HANDLED; | 215 | return IRQ_HANDLED; |
216 | } | 216 | } |
217 | 217 | ||
218 | static int __devinit altera_spi_probe(struct platform_device *pdev) | 218 | static int altera_spi_probe(struct platform_device *pdev) |
219 | { | 219 | { |
220 | struct altera_spi_platform_data *platp = pdev->dev.platform_data; | 220 | struct altera_spi_platform_data *platp = pdev->dev.platform_data; |
221 | struct altera_spi *hw; | 221 | struct altera_spi *hw; |
@@ -290,7 +290,7 @@ exit: | |||
290 | return err; | 290 | return err; |
291 | } | 291 | } |
292 | 292 | ||
293 | static int __devexit altera_spi_remove(struct platform_device *dev) | 293 | static int altera_spi_remove(struct platform_device *dev) |
294 | { | 294 | { |
295 | struct altera_spi *hw = platform_get_drvdata(dev); | 295 | struct altera_spi *hw = platform_get_drvdata(dev); |
296 | struct spi_master *master = hw->bitbang.master; | 296 | struct spi_master *master = hw->bitbang.master; |
@@ -311,7 +311,7 @@ MODULE_DEVICE_TABLE(of, altera_spi_match); | |||
311 | 311 | ||
312 | static struct platform_driver altera_spi_driver = { | 312 | static struct platform_driver altera_spi_driver = { |
313 | .probe = altera_spi_probe, | 313 | .probe = altera_spi_probe, |
314 | .remove = __devexit_p(altera_spi_remove), | 314 | .remove = altera_spi_remove, |
315 | .driver = { | 315 | .driver = { |
316 | .name = DRV_NAME, | 316 | .name = DRV_NAME, |
317 | .owner = THIS_MODULE, | 317 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index 249077e5cc48..9a5d7791c5fb 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c | |||
@@ -192,7 +192,7 @@ static u32 ath79_spi_txrx_mode0(struct spi_device *spi, unsigned nsecs, | |||
192 | return ath79_spi_rr(sp, AR71XX_SPI_REG_RDS); | 192 | return ath79_spi_rr(sp, AR71XX_SPI_REG_RDS); |
193 | } | 193 | } |
194 | 194 | ||
195 | static __devinit int ath79_spi_probe(struct platform_device *pdev) | 195 | static int ath79_spi_probe(struct platform_device *pdev) |
196 | { | 196 | { |
197 | struct spi_master *master; | 197 | struct spi_master *master; |
198 | struct ath79_spi *sp; | 198 | struct ath79_spi *sp; |
@@ -251,7 +251,7 @@ err_put_master: | |||
251 | return ret; | 251 | return ret; |
252 | } | 252 | } |
253 | 253 | ||
254 | static __devexit int ath79_spi_remove(struct platform_device *pdev) | 254 | static int ath79_spi_remove(struct platform_device *pdev) |
255 | { | 255 | { |
256 | struct ath79_spi *sp = platform_get_drvdata(pdev); | 256 | struct ath79_spi *sp = platform_get_drvdata(pdev); |
257 | 257 | ||
@@ -265,7 +265,7 @@ static __devexit int ath79_spi_remove(struct platform_device *pdev) | |||
265 | 265 | ||
266 | static struct platform_driver ath79_spi_driver = { | 266 | static struct platform_driver ath79_spi_driver = { |
267 | .probe = ath79_spi_probe, | 267 | .probe = ath79_spi_probe, |
268 | .remove = __devexit_p(ath79_spi_remove), | 268 | .remove = ath79_spi_remove, |
269 | .driver = { | 269 | .driver = { |
270 | .name = DRV_NAME, | 270 | .name = DRV_NAME, |
271 | .owner = THIS_MODULE, | 271 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 61fb0ec26f06..75c0c4f5fdf2 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c | |||
@@ -907,7 +907,7 @@ static void atmel_spi_cleanup(struct spi_device *spi) | |||
907 | 907 | ||
908 | /*-------------------------------------------------------------------------*/ | 908 | /*-------------------------------------------------------------------------*/ |
909 | 909 | ||
910 | static int __devinit atmel_spi_probe(struct platform_device *pdev) | 910 | static int atmel_spi_probe(struct platform_device *pdev) |
911 | { | 911 | { |
912 | struct resource *regs; | 912 | struct resource *regs; |
913 | int irq; | 913 | int irq; |
@@ -1003,7 +1003,7 @@ out_free: | |||
1003 | return ret; | 1003 | return ret; |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | static int __devexit atmel_spi_remove(struct platform_device *pdev) | 1006 | static int atmel_spi_remove(struct platform_device *pdev) |
1007 | { | 1007 | { |
1008 | struct spi_master *master = platform_get_drvdata(pdev); | 1008 | struct spi_master *master = platform_get_drvdata(pdev); |
1009 | struct atmel_spi *as = spi_master_get_devdata(master); | 1009 | struct atmel_spi *as = spi_master_get_devdata(master); |
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index a9f4049c6769..f44ab5508535 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <bcm63xx_dev_spi.h> | 36 | #include <bcm63xx_dev_spi.h> |
37 | 37 | ||
38 | #define PFX KBUILD_MODNAME | 38 | #define PFX KBUILD_MODNAME |
39 | #define DRV_VER "0.1.2" | ||
40 | 39 | ||
41 | struct bcm63xx_spi { | 40 | struct bcm63xx_spi { |
42 | struct completion done; | 41 | struct completion done; |
@@ -170,13 +169,6 @@ static int bcm63xx_spi_setup(struct spi_device *spi) | |||
170 | return -EINVAL; | 169 | return -EINVAL; |
171 | } | 170 | } |
172 | 171 | ||
173 | ret = bcm63xx_spi_check_transfer(spi, NULL); | ||
174 | if (ret < 0) { | ||
175 | dev_err(&spi->dev, "setup: unsupported mode bits %x\n", | ||
176 | spi->mode & ~MODEBITS); | ||
177 | return ret; | ||
178 | } | ||
179 | |||
180 | dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n", | 172 | dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n", |
181 | __func__, spi->mode & MODEBITS, spi->bits_per_word, 0); | 173 | __func__, spi->mode & MODEBITS, spi->bits_per_word, 0); |
182 | 174 | ||
@@ -337,7 +329,7 @@ static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id) | |||
337 | } | 329 | } |
338 | 330 | ||
339 | 331 | ||
340 | static int __devinit bcm63xx_spi_probe(struct platform_device *pdev) | 332 | static int bcm63xx_spi_probe(struct platform_device *pdev) |
341 | { | 333 | { |
342 | struct resource *r; | 334 | struct resource *r; |
343 | struct device *dev = &pdev->dev; | 335 | struct device *dev = &pdev->dev; |
@@ -441,8 +433,8 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev) | |||
441 | goto out_clk_disable; | 433 | goto out_clk_disable; |
442 | } | 434 | } |
443 | 435 | ||
444 | dev_info(dev, "at 0x%08x (irq %d, FIFOs size %d) v%s\n", | 436 | dev_info(dev, "at 0x%08x (irq %d, FIFOs size %d)\n", |
445 | r->start, irq, bs->fifo_size, DRV_VER); | 437 | r->start, irq, bs->fifo_size); |
446 | 438 | ||
447 | return 0; | 439 | return 0; |
448 | 440 | ||
@@ -457,7 +449,7 @@ out: | |||
457 | return ret; | 449 | return ret; |
458 | } | 450 | } |
459 | 451 | ||
460 | static int __devexit bcm63xx_spi_remove(struct platform_device *pdev) | 452 | static int bcm63xx_spi_remove(struct platform_device *pdev) |
461 | { | 453 | { |
462 | struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); | 454 | struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); |
463 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); | 455 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
@@ -485,6 +477,8 @@ static int bcm63xx_spi_suspend(struct device *dev) | |||
485 | platform_get_drvdata(to_platform_device(dev)); | 477 | platform_get_drvdata(to_platform_device(dev)); |
486 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); | 478 | struct bcm63xx_spi *bs = spi_master_get_devdata(master); |
487 | 479 | ||
480 | spi_master_suspend(master); | ||
481 | |||
488 | clk_disable(bs->clk); | 482 | clk_disable(bs->clk); |
489 | 483 | ||
490 | return 0; | 484 | return 0; |
@@ -498,6 +492,8 @@ static int bcm63xx_spi_resume(struct device *dev) | |||
498 | 492 | ||
499 | clk_enable(bs->clk); | 493 | clk_enable(bs->clk); |
500 | 494 | ||
495 | spi_master_resume(master); | ||
496 | |||
501 | return 0; | 497 | return 0; |
502 | } | 498 | } |
503 | 499 | ||
@@ -518,7 +514,7 @@ static struct platform_driver bcm63xx_spi_driver = { | |||
518 | .pm = BCM63XX_SPI_PM_OPS, | 514 | .pm = BCM63XX_SPI_PM_OPS, |
519 | }, | 515 | }, |
520 | .probe = bcm63xx_spi_probe, | 516 | .probe = bcm63xx_spi_probe, |
521 | .remove = __devexit_p(bcm63xx_spi_remove), | 517 | .remove = bcm63xx_spi_remove, |
522 | }; | 518 | }; |
523 | 519 | ||
524 | module_platform_driver(bcm63xx_spi_driver); | 520 | module_platform_driver(bcm63xx_spi_driver); |
diff --git a/drivers/spi/spi-bfin-sport.c b/drivers/spi/spi-bfin-sport.c index 6555ecd07302..ac7ffca7ba47 100644 --- a/drivers/spi/spi-bfin-sport.c +++ b/drivers/spi/spi-bfin-sport.c | |||
@@ -755,8 +755,7 @@ bfin_sport_spi_destroy_queue(struct bfin_sport_spi_master_data *drv_data) | |||
755 | return 0; | 755 | return 0; |
756 | } | 756 | } |
757 | 757 | ||
758 | static int __devinit | 758 | static int bfin_sport_spi_probe(struct platform_device *pdev) |
759 | bfin_sport_spi_probe(struct platform_device *pdev) | ||
760 | { | 759 | { |
761 | struct device *dev = &pdev->dev; | 760 | struct device *dev = &pdev->dev; |
762 | struct bfin5xx_spi_master *platform_info; | 761 | struct bfin5xx_spi_master *platform_info; |
@@ -863,8 +862,7 @@ bfin_sport_spi_probe(struct platform_device *pdev) | |||
863 | } | 862 | } |
864 | 863 | ||
865 | /* stop hardware and remove the driver */ | 864 | /* stop hardware and remove the driver */ |
866 | static int __devexit | 865 | static int bfin_sport_spi_remove(struct platform_device *pdev) |
867 | bfin_sport_spi_remove(struct platform_device *pdev) | ||
868 | { | 866 | { |
869 | struct bfin_sport_spi_master_data *drv_data = platform_get_drvdata(pdev); | 867 | struct bfin_sport_spi_master_data *drv_data = platform_get_drvdata(pdev); |
870 | int status = 0; | 868 | int status = 0; |
@@ -935,7 +933,7 @@ static struct platform_driver bfin_sport_spi_driver = { | |||
935 | .owner = THIS_MODULE, | 933 | .owner = THIS_MODULE, |
936 | }, | 934 | }, |
937 | .probe = bfin_sport_spi_probe, | 935 | .probe = bfin_sport_spi_probe, |
938 | .remove = __devexit_p(bfin_sport_spi_remove), | 936 | .remove = bfin_sport_spi_remove, |
939 | .suspend = bfin_sport_spi_suspend, | 937 | .suspend = bfin_sport_spi_suspend, |
940 | .resume = bfin_sport_spi_resume, | 938 | .resume = bfin_sport_spi_resume, |
941 | }; | 939 | }; |
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c index 9bb4d4af8547..0429d833f75b 100644 --- a/drivers/spi/spi-bfin5xx.c +++ b/drivers/spi/spi-bfin5xx.c | |||
@@ -1387,7 +1387,7 @@ out_error_get_res: | |||
1387 | } | 1387 | } |
1388 | 1388 | ||
1389 | /* stop hardware and remove the driver */ | 1389 | /* stop hardware and remove the driver */ |
1390 | static int __devexit bfin_spi_remove(struct platform_device *pdev) | 1390 | static int bfin_spi_remove(struct platform_device *pdev) |
1391 | { | 1391 | { |
1392 | struct bfin_spi_master_data *drv_data = platform_get_drvdata(pdev); | 1392 | struct bfin_spi_master_data *drv_data = platform_get_drvdata(pdev); |
1393 | int status = 0; | 1393 | int status = 0; |
@@ -1477,7 +1477,7 @@ static struct platform_driver bfin_spi_driver = { | |||
1477 | }, | 1477 | }, |
1478 | .suspend = bfin_spi_suspend, | 1478 | .suspend = bfin_spi_suspend, |
1479 | .resume = bfin_spi_resume, | 1479 | .resume = bfin_spi_resume, |
1480 | .remove = __devexit_p(bfin_spi_remove), | 1480 | .remove = bfin_spi_remove, |
1481 | }; | 1481 | }; |
1482 | 1482 | ||
1483 | static int __init bfin_spi_init(void) | 1483 | static int __init bfin_spi_init(void) |
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c index aef59b1a15f7..8b3d8efafd3c 100644 --- a/drivers/spi/spi-bitbang.c +++ b/drivers/spi/spi-bitbang.c | |||
@@ -260,11 +260,11 @@ static void bitbang_work(struct work_struct *work) | |||
260 | struct spi_bitbang *bitbang = | 260 | struct spi_bitbang *bitbang = |
261 | container_of(work, struct spi_bitbang, work); | 261 | container_of(work, struct spi_bitbang, work); |
262 | unsigned long flags; | 262 | unsigned long flags; |
263 | struct spi_message *m, *_m; | ||
263 | 264 | ||
264 | spin_lock_irqsave(&bitbang->lock, flags); | 265 | spin_lock_irqsave(&bitbang->lock, flags); |
265 | bitbang->busy = 1; | 266 | bitbang->busy = 1; |
266 | while (!list_empty(&bitbang->queue)) { | 267 | list_for_each_entry_safe(m, _m, &bitbang->queue, queue) { |
267 | struct spi_message *m; | ||
268 | struct spi_device *spi; | 268 | struct spi_device *spi; |
269 | unsigned nsecs; | 269 | unsigned nsecs; |
270 | struct spi_transfer *t = NULL; | 270 | struct spi_transfer *t = NULL; |
@@ -273,9 +273,7 @@ static void bitbang_work(struct work_struct *work) | |||
273 | int status; | 273 | int status; |
274 | int do_setup = -1; | 274 | int do_setup = -1; |
275 | 275 | ||
276 | m = container_of(bitbang->queue.next, struct spi_message, | 276 | list_del(&m->queue); |
277 | queue); | ||
278 | list_del_init(&m->queue); | ||
279 | spin_unlock_irqrestore(&bitbang->lock, flags); | 277 | spin_unlock_irqrestore(&bitbang->lock, flags); |
280 | 278 | ||
281 | /* FIXME this is made-up ... the correct value is known to | 279 | /* FIXME this is made-up ... the correct value is known to |
@@ -346,17 +344,14 @@ static void bitbang_work(struct work_struct *work) | |||
346 | if (t->delay_usecs) | 344 | if (t->delay_usecs) |
347 | udelay(t->delay_usecs); | 345 | udelay(t->delay_usecs); |
348 | 346 | ||
349 | if (!cs_change) | 347 | if (cs_change && !list_is_last(&t->transfer_list, &m->transfers)) { |
350 | continue; | 348 | /* sometimes a short mid-message deselect of the chip |
351 | if (t->transfer_list.next == &m->transfers) | 349 | * may be needed to terminate a mode or command |
352 | break; | 350 | */ |
353 | 351 | ndelay(nsecs); | |
354 | /* sometimes a short mid-message deselect of the chip | 352 | bitbang->chipselect(spi, BITBANG_CS_INACTIVE); |
355 | * may be needed to terminate a mode or command | 353 | ndelay(nsecs); |
356 | */ | 354 | } |
357 | ndelay(nsecs); | ||
358 | bitbang->chipselect(spi, BITBANG_CS_INACTIVE); | ||
359 | ndelay(nsecs); | ||
360 | } | 355 | } |
361 | 356 | ||
362 | m->status = status; | 357 | m->status = status; |
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c new file mode 100644 index 000000000000..1366c4620d5d --- /dev/null +++ b/drivers/spi/spi-clps711x.c | |||
@@ -0,0 +1,296 @@ | |||
1 | /* | ||
2 | * CLPS711X SPI bus driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/io.h> | ||
13 | #include <linux/clk.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/gpio.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/spi/spi.h> | ||
21 | #include <linux/platform_data/spi-clps711x.h> | ||
22 | |||
23 | #include <mach/hardware.h> | ||
24 | |||
25 | #define DRIVER_NAME "spi-clps711x" | ||
26 | |||
27 | struct spi_clps711x_data { | ||
28 | struct completion done; | ||
29 | |||
30 | struct clk *spi_clk; | ||
31 | u32 max_speed_hz; | ||
32 | |||
33 | u8 *tx_buf; | ||
34 | u8 *rx_buf; | ||
35 | int count; | ||
36 | int len; | ||
37 | |||
38 | int chipselect[0]; | ||
39 | }; | ||
40 | |||
41 | static int spi_clps711x_setup(struct spi_device *spi) | ||
42 | { | ||
43 | struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); | ||
44 | |||
45 | if (spi->bits_per_word != 8) { | ||
46 | dev_err(&spi->dev, "Unsupported master bus width %i\n", | ||
47 | spi->bits_per_word); | ||
48 | return -EINVAL; | ||
49 | } | ||
50 | |||
51 | /* We are expect that SPI-device is not selected */ | ||
52 | gpio_direction_output(hw->chipselect[spi->chip_select], | ||
53 | !(spi->mode & SPI_CS_HIGH)); | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | static void spi_clps711x_setup_mode(struct spi_device *spi) | ||
59 | { | ||
60 | /* Setup edge for transfer */ | ||
61 | if (spi->mode & SPI_CPHA) | ||
62 | clps_writew(clps_readw(SYSCON3) | SYSCON3_ADCCKNSEN, SYSCON3); | ||
63 | else | ||
64 | clps_writew(clps_readw(SYSCON3) & ~SYSCON3_ADCCKNSEN, SYSCON3); | ||
65 | } | ||
66 | |||
67 | static int spi_clps711x_setup_xfer(struct spi_device *spi, | ||
68 | struct spi_transfer *xfer) | ||
69 | { | ||
70 | u32 speed = xfer->speed_hz ? : spi->max_speed_hz; | ||
71 | u8 bpw = xfer->bits_per_word ? : spi->bits_per_word; | ||
72 | struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); | ||
73 | |||
74 | if (bpw != 8) { | ||
75 | dev_err(&spi->dev, "Unsupported master bus width %i\n", bpw); | ||
76 | return -EINVAL; | ||
77 | } | ||
78 | |||
79 | /* Setup SPI frequency divider */ | ||
80 | if (!speed || (speed >= hw->max_speed_hz)) | ||
81 | clps_writel((clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK) | | ||
82 | SYSCON1_ADCKSEL(3), SYSCON1); | ||
83 | else if (speed >= (hw->max_speed_hz / 2)) | ||
84 | clps_writel((clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK) | | ||
85 | SYSCON1_ADCKSEL(2), SYSCON1); | ||
86 | else if (speed >= (hw->max_speed_hz / 8)) | ||
87 | clps_writel((clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK) | | ||
88 | SYSCON1_ADCKSEL(1), SYSCON1); | ||
89 | else | ||
90 | clps_writel((clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK) | | ||
91 | SYSCON1_ADCKSEL(0), SYSCON1); | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static int spi_clps711x_transfer_one_message(struct spi_master *master, | ||
97 | struct spi_message *msg) | ||
98 | { | ||
99 | struct spi_clps711x_data *hw = spi_master_get_devdata(master); | ||
100 | struct spi_transfer *xfer; | ||
101 | int status = 0, cs = hw->chipselect[msg->spi->chip_select]; | ||
102 | u32 data; | ||
103 | |||
104 | spi_clps711x_setup_mode(msg->spi); | ||
105 | |||
106 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
107 | if (spi_clps711x_setup_xfer(msg->spi, xfer)) { | ||
108 | status = -EINVAL; | ||
109 | goto out_xfr; | ||
110 | } | ||
111 | |||
112 | gpio_set_value(cs, !!(msg->spi->mode & SPI_CS_HIGH)); | ||
113 | |||
114 | INIT_COMPLETION(hw->done); | ||
115 | |||
116 | hw->count = 0; | ||
117 | hw->len = xfer->len; | ||
118 | hw->tx_buf = (u8 *)xfer->tx_buf; | ||
119 | hw->rx_buf = (u8 *)xfer->rx_buf; | ||
120 | |||
121 | /* Initiate transfer */ | ||
122 | data = hw->tx_buf ? hw->tx_buf[hw->count] : 0; | ||
123 | clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); | ||
124 | |||
125 | wait_for_completion(&hw->done); | ||
126 | |||
127 | if (xfer->delay_usecs) | ||
128 | udelay(xfer->delay_usecs); | ||
129 | |||
130 | if (xfer->cs_change || | ||
131 | list_is_last(&xfer->transfer_list, &msg->transfers)) | ||
132 | gpio_set_value(cs, !(msg->spi->mode & SPI_CS_HIGH)); | ||
133 | |||
134 | msg->actual_length += xfer->len; | ||
135 | } | ||
136 | |||
137 | out_xfr: | ||
138 | msg->status = status; | ||
139 | spi_finalize_current_message(master); | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static irqreturn_t spi_clps711x_isr(int irq, void *dev_id) | ||
145 | { | ||
146 | struct spi_clps711x_data *hw = (struct spi_clps711x_data *)dev_id; | ||
147 | u32 data; | ||
148 | |||
149 | /* Handle RX */ | ||
150 | data = clps_readb(SYNCIO); | ||
151 | if (hw->rx_buf) | ||
152 | hw->rx_buf[hw->count] = (u8)data; | ||
153 | |||
154 | hw->count++; | ||
155 | |||
156 | /* Handle TX */ | ||
157 | if (hw->count < hw->len) { | ||
158 | data = hw->tx_buf ? hw->tx_buf[hw->count] : 0; | ||
159 | clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); | ||
160 | } else | ||
161 | complete(&hw->done); | ||
162 | |||
163 | return IRQ_HANDLED; | ||
164 | } | ||
165 | |||
166 | static int spi_clps711x_probe(struct platform_device *pdev) | ||
167 | { | ||
168 | int i, ret; | ||
169 | struct spi_master *master; | ||
170 | struct spi_clps711x_data *hw; | ||
171 | struct spi_clps711x_pdata *pdata = dev_get_platdata(&pdev->dev); | ||
172 | |||
173 | if (!pdata) { | ||
174 | dev_err(&pdev->dev, "No platform data supplied\n"); | ||
175 | return -EINVAL; | ||
176 | } | ||
177 | |||
178 | if (pdata->num_chipselect < 1) { | ||
179 | dev_err(&pdev->dev, "At least one CS must be defined\n"); | ||
180 | return -EINVAL; | ||
181 | } | ||
182 | |||
183 | master = spi_alloc_master(&pdev->dev, | ||
184 | sizeof(struct spi_clps711x_data) + | ||
185 | sizeof(int) * pdata->num_chipselect); | ||
186 | if (!master) { | ||
187 | dev_err(&pdev->dev, "SPI allocating memory error\n"); | ||
188 | return -ENOMEM; | ||
189 | } | ||
190 | |||
191 | master->bus_num = pdev->id; | ||
192 | master->mode_bits = SPI_CPHA | SPI_CS_HIGH; | ||
193 | master->num_chipselect = pdata->num_chipselect; | ||
194 | master->setup = spi_clps711x_setup; | ||
195 | master->transfer_one_message = spi_clps711x_transfer_one_message; | ||
196 | |||
197 | hw = spi_master_get_devdata(master); | ||
198 | |||
199 | for (i = 0; i < master->num_chipselect; i++) { | ||
200 | hw->chipselect[i] = pdata->chipselect[i]; | ||
201 | if (!gpio_is_valid(hw->chipselect[i])) { | ||
202 | dev_err(&pdev->dev, "Invalid CS GPIO %i\n", i); | ||
203 | ret = -EINVAL; | ||
204 | goto err_out; | ||
205 | } | ||
206 | if (gpio_request(hw->chipselect[i], DRIVER_NAME)) { | ||
207 | dev_err(&pdev->dev, "Can't get CS GPIO %i\n", i); | ||
208 | ret = -EINVAL; | ||
209 | goto err_out; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | hw->spi_clk = devm_clk_get(&pdev->dev, "spi"); | ||
214 | if (IS_ERR(hw->spi_clk)) { | ||
215 | dev_err(&pdev->dev, "Can't get clocks\n"); | ||
216 | ret = PTR_ERR(hw->spi_clk); | ||
217 | goto err_out; | ||
218 | } | ||
219 | hw->max_speed_hz = clk_get_rate(hw->spi_clk); | ||
220 | |||
221 | init_completion(&hw->done); | ||
222 | platform_set_drvdata(pdev, master); | ||
223 | |||
224 | /* Disable extended mode due hardware problems */ | ||
225 | clps_writew(clps_readw(SYSCON3) & ~SYSCON3_ADCCON, SYSCON3); | ||
226 | |||
227 | /* Clear possible pending interrupt */ | ||
228 | clps_readl(SYNCIO); | ||
229 | |||
230 | ret = devm_request_irq(&pdev->dev, IRQ_SSEOTI, spi_clps711x_isr, 0, | ||
231 | dev_name(&pdev->dev), hw); | ||
232 | if (ret) { | ||
233 | dev_err(&pdev->dev, "Can't request IRQ\n"); | ||
234 | clk_put(hw->spi_clk); | ||
235 | goto clk_out; | ||
236 | } | ||
237 | |||
238 | ret = spi_register_master(master); | ||
239 | if (!ret) { | ||
240 | dev_info(&pdev->dev, | ||
241 | "SPI bus driver initialized. Master clock %u Hz\n", | ||
242 | hw->max_speed_hz); | ||
243 | return 0; | ||
244 | } | ||
245 | |||
246 | dev_err(&pdev->dev, "Failed to register master\n"); | ||
247 | devm_free_irq(&pdev->dev, IRQ_SSEOTI, hw); | ||
248 | |||
249 | clk_out: | ||
250 | devm_clk_put(&pdev->dev, hw->spi_clk); | ||
251 | |||
252 | err_out: | ||
253 | while (--i >= 0) | ||
254 | if (gpio_is_valid(hw->chipselect[i])) | ||
255 | gpio_free(hw->chipselect[i]); | ||
256 | |||
257 | platform_set_drvdata(pdev, NULL); | ||
258 | spi_master_put(master); | ||
259 | kfree(master); | ||
260 | |||
261 | return ret; | ||
262 | } | ||
263 | |||
264 | static int spi_clps711x_remove(struct platform_device *pdev) | ||
265 | { | ||
266 | int i; | ||
267 | struct spi_master *master = platform_get_drvdata(pdev); | ||
268 | struct spi_clps711x_data *hw = spi_master_get_devdata(master); | ||
269 | |||
270 | devm_free_irq(&pdev->dev, IRQ_SSEOTI, hw); | ||
271 | |||
272 | for (i = 0; i < master->num_chipselect; i++) | ||
273 | if (gpio_is_valid(hw->chipselect[i])) | ||
274 | gpio_free(hw->chipselect[i]); | ||
275 | |||
276 | devm_clk_put(&pdev->dev, hw->spi_clk); | ||
277 | platform_set_drvdata(pdev, NULL); | ||
278 | spi_unregister_master(master); | ||
279 | kfree(master); | ||
280 | |||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | static struct platform_driver clps711x_spi_driver = { | ||
285 | .driver = { | ||
286 | .name = DRIVER_NAME, | ||
287 | .owner = THIS_MODULE, | ||
288 | }, | ||
289 | .probe = spi_clps711x_probe, | ||
290 | .remove = spi_clps711x_remove, | ||
291 | }; | ||
292 | module_platform_driver(clps711x_spi_driver); | ||
293 | |||
294 | MODULE_LICENSE("GPL"); | ||
295 | MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>"); | ||
296 | MODULE_DESCRIPTION("CLPS711X SPI bus driver"); | ||
diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c index 764bfee75920..58466b810da4 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c | |||
@@ -401,7 +401,7 @@ static int mcfqspi_setup(struct spi_device *spi) | |||
401 | return 0; | 401 | return 0; |
402 | } | 402 | } |
403 | 403 | ||
404 | static int __devinit mcfqspi_probe(struct platform_device *pdev) | 404 | static int mcfqspi_probe(struct platform_device *pdev) |
405 | { | 405 | { |
406 | struct spi_master *master; | 406 | struct spi_master *master; |
407 | struct mcfqspi *mcfqspi; | 407 | struct mcfqspi *mcfqspi; |
@@ -515,7 +515,7 @@ fail0: | |||
515 | return status; | 515 | return status; |
516 | } | 516 | } |
517 | 517 | ||
518 | static int __devexit mcfqspi_remove(struct platform_device *pdev) | 518 | static int mcfqspi_remove(struct platform_device *pdev) |
519 | { | 519 | { |
520 | struct spi_master *master = platform_get_drvdata(pdev); | 520 | struct spi_master *master = platform_get_drvdata(pdev); |
521 | struct mcfqspi *mcfqspi = spi_master_get_devdata(master); | 521 | struct mcfqspi *mcfqspi = spi_master_get_devdata(master); |
@@ -594,7 +594,7 @@ static struct platform_driver mcfqspi_driver = { | |||
594 | .driver.owner = THIS_MODULE, | 594 | .driver.owner = THIS_MODULE, |
595 | .driver.pm = &mcfqspi_pm, | 595 | .driver.pm = &mcfqspi_pm, |
596 | .probe = mcfqspi_probe, | 596 | .probe = mcfqspi_probe, |
597 | .remove = __devexit_p(mcfqspi_remove), | 597 | .remove = mcfqspi_remove, |
598 | }; | 598 | }; |
599 | module_platform_driver(mcfqspi_driver); | 599 | module_platform_driver(mcfqspi_driver); |
600 | 600 | ||
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 147dfa87a64b..13661e129d96 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c | |||
@@ -769,7 +769,7 @@ rx_dma_failed: | |||
769 | * It will invoke spi_bitbang_start to create work queue so that client driver | 769 | * It will invoke spi_bitbang_start to create work queue so that client driver |
770 | * can register transfer method to work queue. | 770 | * can register transfer method to work queue. |
771 | */ | 771 | */ |
772 | static int __devinit davinci_spi_probe(struct platform_device *pdev) | 772 | static int davinci_spi_probe(struct platform_device *pdev) |
773 | { | 773 | { |
774 | struct spi_master *master; | 774 | struct spi_master *master; |
775 | struct davinci_spi *dspi; | 775 | struct davinci_spi *dspi; |
@@ -952,7 +952,7 @@ err: | |||
952 | * It will also call spi_bitbang_stop to destroy the work queue which was | 952 | * It will also call spi_bitbang_stop to destroy the work queue which was |
953 | * created by spi_bitbang_start. | 953 | * created by spi_bitbang_start. |
954 | */ | 954 | */ |
955 | static int __devexit davinci_spi_remove(struct platform_device *pdev) | 955 | static int davinci_spi_remove(struct platform_device *pdev) |
956 | { | 956 | { |
957 | struct davinci_spi *dspi; | 957 | struct davinci_spi *dspi; |
958 | struct spi_master *master; | 958 | struct spi_master *master; |
@@ -980,7 +980,7 @@ static struct platform_driver davinci_spi_driver = { | |||
980 | .owner = THIS_MODULE, | 980 | .owner = THIS_MODULE, |
981 | }, | 981 | }, |
982 | .probe = davinci_spi_probe, | 982 | .probe = davinci_spi_probe, |
983 | .remove = __devexit_p(davinci_spi_remove), | 983 | .remove = davinci_spi_remove, |
984 | }; | 984 | }; |
985 | module_platform_driver(davinci_spi_driver); | 985 | module_platform_driver(davinci_spi_driver); |
986 | 986 | ||
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index db2f1ba06eab..4a6d5c9057a4 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c | |||
@@ -26,7 +26,7 @@ struct dw_spi_mmio { | |||
26 | struct clk *clk; | 26 | struct clk *clk; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | static int __devinit dw_spi_mmio_probe(struct platform_device *pdev) | 29 | static int dw_spi_mmio_probe(struct platform_device *pdev) |
30 | { | 30 | { |
31 | struct dw_spi_mmio *dwsmmio; | 31 | struct dw_spi_mmio *dwsmmio; |
32 | struct dw_spi *dws; | 32 | struct dw_spi *dws; |
@@ -106,7 +106,7 @@ err_end: | |||
106 | return ret; | 106 | return ret; |
107 | } | 107 | } |
108 | 108 | ||
109 | static int __devexit dw_spi_mmio_remove(struct platform_device *pdev) | 109 | static int dw_spi_mmio_remove(struct platform_device *pdev) |
110 | { | 110 | { |
111 | struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev); | 111 | struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev); |
112 | struct resource *mem; | 112 | struct resource *mem; |
@@ -129,7 +129,7 @@ static int __devexit dw_spi_mmio_remove(struct platform_device *pdev) | |||
129 | 129 | ||
130 | static struct platform_driver dw_spi_mmio_driver = { | 130 | static struct platform_driver dw_spi_mmio_driver = { |
131 | .probe = dw_spi_mmio_probe, | 131 | .probe = dw_spi_mmio_probe, |
132 | .remove = __devexit_p(dw_spi_mmio_remove), | 132 | .remove = dw_spi_mmio_remove, |
133 | .driver = { | 133 | .driver = { |
134 | .name = DRIVER_NAME, | 134 | .name = DRIVER_NAME, |
135 | .owner = THIS_MODULE, | 135 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c index ff81abbb3066..6055c8d9fdd7 100644 --- a/drivers/spi/spi-dw-pci.c +++ b/drivers/spi/spi-dw-pci.c | |||
@@ -32,7 +32,7 @@ struct dw_spi_pci { | |||
32 | struct dw_spi dws; | 32 | struct dw_spi dws; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | static int __devinit spi_pci_probe(struct pci_dev *pdev, | 35 | static int spi_pci_probe(struct pci_dev *pdev, |
36 | const struct pci_device_id *ent) | 36 | const struct pci_device_id *ent) |
37 | { | 37 | { |
38 | struct dw_spi_pci *dwpci; | 38 | struct dw_spi_pci *dwpci; |
@@ -105,7 +105,7 @@ err_disable: | |||
105 | return ret; | 105 | return ret; |
106 | } | 106 | } |
107 | 107 | ||
108 | static void __devexit spi_pci_remove(struct pci_dev *pdev) | 108 | static void spi_pci_remove(struct pci_dev *pdev) |
109 | { | 109 | { |
110 | struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); | 110 | struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); |
111 | 111 | ||
@@ -159,7 +159,7 @@ static struct pci_driver dw_spi_driver = { | |||
159 | .name = DRIVER_NAME, | 159 | .name = DRIVER_NAME, |
160 | .id_table = pci_ids, | 160 | .id_table = pci_ids, |
161 | .probe = spi_pci_probe, | 161 | .probe = spi_pci_probe, |
162 | .remove = __devexit_p(spi_pci_remove), | 162 | .remove = spi_pci_remove, |
163 | .suspend = spi_suspend, | 163 | .suspend = spi_suspend, |
164 | .resume = spi_resume, | 164 | .resume = spi_resume, |
165 | }; | 165 | }; |
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index d1a495f64e2d..c1abc06899e7 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c | |||
@@ -696,7 +696,7 @@ static void dw_spi_cleanup(struct spi_device *spi) | |||
696 | kfree(chip); | 696 | kfree(chip); |
697 | } | 697 | } |
698 | 698 | ||
699 | static int __devinit init_queue(struct dw_spi *dws) | 699 | static int init_queue(struct dw_spi *dws) |
700 | { | 700 | { |
701 | INIT_LIST_HEAD(&dws->queue); | 701 | INIT_LIST_HEAD(&dws->queue); |
702 | spin_lock_init(&dws->lock); | 702 | spin_lock_init(&dws->lock); |
@@ -795,7 +795,7 @@ static void spi_hw_init(struct dw_spi *dws) | |||
795 | } | 795 | } |
796 | } | 796 | } |
797 | 797 | ||
798 | int __devinit dw_spi_add_host(struct dw_spi *dws) | 798 | int dw_spi_add_host(struct dw_spi *dws) |
799 | { | 799 | { |
800 | struct spi_master *master; | 800 | struct spi_master *master; |
801 | int ret; | 801 | int ret; |
@@ -877,7 +877,7 @@ exit: | |||
877 | } | 877 | } |
878 | EXPORT_SYMBOL_GPL(dw_spi_add_host); | 878 | EXPORT_SYMBOL_GPL(dw_spi_add_host); |
879 | 879 | ||
880 | void __devexit dw_spi_remove_host(struct dw_spi *dws) | 880 | void dw_spi_remove_host(struct dw_spi *dws) |
881 | { | 881 | { |
882 | int status = 0; | 882 | int status = 0; |
883 | 883 | ||
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index 3a219599612a..acb1e1935c5a 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c | |||
@@ -1023,7 +1023,7 @@ static void ep93xx_spi_release_dma(struct ep93xx_spi *espi) | |||
1023 | free_page((unsigned long)espi->zeropage); | 1023 | free_page((unsigned long)espi->zeropage); |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | static int __devinit ep93xx_spi_probe(struct platform_device *pdev) | 1026 | static int ep93xx_spi_probe(struct platform_device *pdev) |
1027 | { | 1027 | { |
1028 | struct spi_master *master; | 1028 | struct spi_master *master; |
1029 | struct ep93xx_spi_info *info; | 1029 | struct ep93xx_spi_info *info; |
@@ -1138,7 +1138,7 @@ fail_release_master: | |||
1138 | return error; | 1138 | return error; |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | static int __devexit ep93xx_spi_remove(struct platform_device *pdev) | 1141 | static int ep93xx_spi_remove(struct platform_device *pdev) |
1142 | { | 1142 | { |
1143 | struct spi_master *master = platform_get_drvdata(pdev); | 1143 | struct spi_master *master = platform_get_drvdata(pdev); |
1144 | struct ep93xx_spi *espi = spi_master_get_devdata(master); | 1144 | struct ep93xx_spi *espi = spi_master_get_devdata(master); |
@@ -1180,7 +1180,7 @@ static struct platform_driver ep93xx_spi_driver = { | |||
1180 | .owner = THIS_MODULE, | 1180 | .owner = THIS_MODULE, |
1181 | }, | 1181 | }, |
1182 | .probe = ep93xx_spi_probe, | 1182 | .probe = ep93xx_spi_probe, |
1183 | .remove = __devexit_p(ep93xx_spi_remove), | 1183 | .remove = ep93xx_spi_remove, |
1184 | }; | 1184 | }; |
1185 | module_platform_driver(ep93xx_spi_driver); | 1185 | module_platform_driver(ep93xx_spi_driver); |
1186 | 1186 | ||
diff --git a/drivers/spi/spi-falcon.c b/drivers/spi/spi-falcon.c index 8f6aa735a24c..6a6f62ec2840 100644 --- a/drivers/spi/spi-falcon.c +++ b/drivers/spi/spi-falcon.c | |||
@@ -403,7 +403,7 @@ static int falcon_sflash_xfer_one(struct spi_master *master, | |||
403 | return 0; | 403 | return 0; |
404 | } | 404 | } |
405 | 405 | ||
406 | static int __devinit falcon_sflash_probe(struct platform_device *pdev) | 406 | static int falcon_sflash_probe(struct platform_device *pdev) |
407 | { | 407 | { |
408 | struct falcon_sflash *priv; | 408 | struct falcon_sflash *priv; |
409 | struct spi_master *master; | 409 | struct spi_master *master; |
@@ -438,7 +438,7 @@ static int __devinit falcon_sflash_probe(struct platform_device *pdev) | |||
438 | return ret; | 438 | return ret; |
439 | } | 439 | } |
440 | 440 | ||
441 | static int __devexit falcon_sflash_remove(struct platform_device *pdev) | 441 | static int falcon_sflash_remove(struct platform_device *pdev) |
442 | { | 442 | { |
443 | struct falcon_sflash *priv = platform_get_drvdata(pdev); | 443 | struct falcon_sflash *priv = platform_get_drvdata(pdev); |
444 | 444 | ||
@@ -455,7 +455,7 @@ MODULE_DEVICE_TABLE(of, falcon_sflash_match); | |||
455 | 455 | ||
456 | static struct platform_driver falcon_sflash_driver = { | 456 | static struct platform_driver falcon_sflash_driver = { |
457 | .probe = falcon_sflash_probe, | 457 | .probe = falcon_sflash_probe, |
458 | .remove = __devexit_p(falcon_sflash_remove), | 458 | .remove = falcon_sflash_remove, |
459 | .driver = { | 459 | .driver = { |
460 | .name = DRV_NAME, | 460 | .name = DRV_NAME, |
461 | .owner = THIS_MODULE, | 461 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 27bdc47b5250..24610ca8955d 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
@@ -587,7 +587,7 @@ static void fsl_espi_remove(struct mpc8xxx_spi *mspi) | |||
587 | iounmap(mspi->reg_base); | 587 | iounmap(mspi->reg_base); |
588 | } | 588 | } |
589 | 589 | ||
590 | static struct spi_master * __devinit fsl_espi_probe(struct device *dev, | 590 | static struct spi_master * fsl_espi_probe(struct device *dev, |
591 | struct resource *mem, unsigned int irq) | 591 | struct resource *mem, unsigned int irq) |
592 | { | 592 | { |
593 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 593 | struct fsl_spi_platform_data *pdata = dev->platform_data; |
@@ -686,7 +686,7 @@ static int of_fsl_espi_get_chipselects(struct device *dev) | |||
686 | return 0; | 686 | return 0; |
687 | } | 687 | } |
688 | 688 | ||
689 | static int __devinit of_fsl_espi_probe(struct platform_device *ofdev) | 689 | static int of_fsl_espi_probe(struct platform_device *ofdev) |
690 | { | 690 | { |
691 | struct device *dev = &ofdev->dev; | 691 | struct device *dev = &ofdev->dev; |
692 | struct device_node *np = ofdev->dev.of_node; | 692 | struct device_node *np = ofdev->dev.of_node; |
@@ -725,7 +725,7 @@ err: | |||
725 | return ret; | 725 | return ret; |
726 | } | 726 | } |
727 | 727 | ||
728 | static int __devexit of_fsl_espi_remove(struct platform_device *dev) | 728 | static int of_fsl_espi_remove(struct platform_device *dev) |
729 | { | 729 | { |
730 | return mpc8xxx_spi_remove(&dev->dev); | 730 | return mpc8xxx_spi_remove(&dev->dev); |
731 | } | 731 | } |
@@ -743,7 +743,7 @@ static struct platform_driver fsl_espi_driver = { | |||
743 | .of_match_table = of_fsl_espi_match, | 743 | .of_match_table = of_fsl_espi_match, |
744 | }, | 744 | }, |
745 | .probe = of_fsl_espi_probe, | 745 | .probe = of_fsl_espi_probe, |
746 | .remove = __devexit_p(of_fsl_espi_remove), | 746 | .remove = of_fsl_espi_remove, |
747 | }; | 747 | }; |
748 | module_platform_driver(fsl_espi_driver); | 748 | module_platform_driver(fsl_espi_driver); |
749 | 749 | ||
diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c index 1503574b215a..8ade675a04f1 100644 --- a/drivers/spi/spi-fsl-lib.c +++ b/drivers/spi/spi-fsl-lib.c | |||
@@ -169,7 +169,7 @@ err: | |||
169 | return ret; | 169 | return ret; |
170 | } | 170 | } |
171 | 171 | ||
172 | int __devexit mpc8xxx_spi_remove(struct device *dev) | 172 | int mpc8xxx_spi_remove(struct device *dev) |
173 | { | 173 | { |
174 | struct mpc8xxx_spi *mpc8xxx_spi; | 174 | struct mpc8xxx_spi *mpc8xxx_spi; |
175 | struct spi_master *master; | 175 | struct spi_master *master; |
@@ -189,7 +189,7 @@ int __devexit mpc8xxx_spi_remove(struct device *dev) | |||
189 | return 0; | 189 | return 0; |
190 | } | 190 | } |
191 | 191 | ||
192 | int __devinit of_mpc8xxx_spi_probe(struct platform_device *ofdev) | 192 | int of_mpc8xxx_spi_probe(struct platform_device *ofdev) |
193 | { | 193 | { |
194 | struct device *dev = &ofdev->dev; | 194 | struct device *dev = &ofdev->dev; |
195 | struct device_node *np = ofdev->dev.of_node; | 195 | struct device_node *np = ofdev->dev.of_node; |
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 6a62934ca74c..1a7f6359d998 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c | |||
@@ -843,7 +843,7 @@ static void fsl_spi_remove(struct mpc8xxx_spi *mspi) | |||
843 | fsl_spi_cpm_free(mspi); | 843 | fsl_spi_cpm_free(mspi); |
844 | } | 844 | } |
845 | 845 | ||
846 | static struct spi_master * __devinit fsl_spi_probe(struct device *dev, | 846 | static struct spi_master * fsl_spi_probe(struct device *dev, |
847 | struct resource *mem, unsigned int irq) | 847 | struct resource *mem, unsigned int irq) |
848 | { | 848 | { |
849 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 849 | struct fsl_spi_platform_data *pdata = dev->platform_data; |
@@ -1041,7 +1041,7 @@ static int of_fsl_spi_free_chipselects(struct device *dev) | |||
1041 | return 0; | 1041 | return 0; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | static int __devinit of_fsl_spi_probe(struct platform_device *ofdev) | 1044 | static int of_fsl_spi_probe(struct platform_device *ofdev) |
1045 | { | 1045 | { |
1046 | struct device *dev = &ofdev->dev; | 1046 | struct device *dev = &ofdev->dev; |
1047 | struct device_node *np = ofdev->dev.of_node; | 1047 | struct device_node *np = ofdev->dev.of_node; |
@@ -1081,7 +1081,7 @@ err: | |||
1081 | return ret; | 1081 | return ret; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | static int __devexit of_fsl_spi_remove(struct platform_device *ofdev) | 1084 | static int of_fsl_spi_remove(struct platform_device *ofdev) |
1085 | { | 1085 | { |
1086 | int ret; | 1086 | int ret; |
1087 | 1087 | ||
@@ -1105,7 +1105,7 @@ static struct platform_driver of_fsl_spi_driver = { | |||
1105 | .of_match_table = of_fsl_spi_match, | 1105 | .of_match_table = of_fsl_spi_match, |
1106 | }, | 1106 | }, |
1107 | .probe = of_fsl_spi_probe, | 1107 | .probe = of_fsl_spi_probe, |
1108 | .remove = __devexit_p(of_fsl_spi_remove), | 1108 | .remove = of_fsl_spi_remove, |
1109 | }; | 1109 | }; |
1110 | 1110 | ||
1111 | #ifdef CONFIG_MPC832x_RDB | 1111 | #ifdef CONFIG_MPC832x_RDB |
@@ -1116,7 +1116,7 @@ static struct platform_driver of_fsl_spi_driver = { | |||
1116 | * tree can work with OpenFirmware driver. But for now we support old trees | 1116 | * tree can work with OpenFirmware driver. But for now we support old trees |
1117 | * as well. | 1117 | * as well. |
1118 | */ | 1118 | */ |
1119 | static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev) | 1119 | static int plat_mpc8xxx_spi_probe(struct platform_device *pdev) |
1120 | { | 1120 | { |
1121 | struct resource *mem; | 1121 | struct resource *mem; |
1122 | int irq; | 1122 | int irq; |
@@ -1139,7 +1139,7 @@ static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev) | |||
1139 | return 0; | 1139 | return 0; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | static int __devexit plat_mpc8xxx_spi_remove(struct platform_device *pdev) | 1142 | static int plat_mpc8xxx_spi_remove(struct platform_device *pdev) |
1143 | { | 1143 | { |
1144 | return mpc8xxx_spi_remove(&pdev->dev); | 1144 | return mpc8xxx_spi_remove(&pdev->dev); |
1145 | } | 1145 | } |
@@ -1147,7 +1147,7 @@ static int __devexit plat_mpc8xxx_spi_remove(struct platform_device *pdev) | |||
1147 | MODULE_ALIAS("platform:mpc8xxx_spi"); | 1147 | MODULE_ALIAS("platform:mpc8xxx_spi"); |
1148 | static struct platform_driver mpc8xxx_spi_driver = { | 1148 | static struct platform_driver mpc8xxx_spi_driver = { |
1149 | .probe = plat_mpc8xxx_spi_probe, | 1149 | .probe = plat_mpc8xxx_spi_probe, |
1150 | .remove = __devexit_p(plat_mpc8xxx_spi_remove), | 1150 | .remove = plat_mpc8xxx_spi_remove, |
1151 | .driver = { | 1151 | .driver = { |
1152 | .name = "mpc8xxx_spi", | 1152 | .name = "mpc8xxx_spi", |
1153 | .owner = THIS_MODULE, | 1153 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index a2b50c516b31..c7cf0b7a069b 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c | |||
@@ -287,7 +287,7 @@ static void spi_gpio_cleanup(struct spi_device *spi) | |||
287 | spi_bitbang_cleanup(spi); | 287 | spi_bitbang_cleanup(spi); |
288 | } | 288 | } |
289 | 289 | ||
290 | static int __devinit spi_gpio_alloc(unsigned pin, const char *label, bool is_in) | 290 | static int spi_gpio_alloc(unsigned pin, const char *label, bool is_in) |
291 | { | 291 | { |
292 | int value; | 292 | int value; |
293 | 293 | ||
@@ -301,9 +301,8 @@ static int __devinit spi_gpio_alloc(unsigned pin, const char *label, bool is_in) | |||
301 | return value; | 301 | return value; |
302 | } | 302 | } |
303 | 303 | ||
304 | static int __devinit | 304 | static int spi_gpio_request(struct spi_gpio_platform_data *pdata, |
305 | spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label, | 305 | const char *label, u16 *res_flags) |
306 | u16 *res_flags) | ||
307 | { | 306 | { |
308 | int value; | 307 | int value; |
309 | 308 | ||
@@ -392,7 +391,7 @@ static inline int spi_gpio_probe_dt(struct platform_device *pdev) | |||
392 | } | 391 | } |
393 | #endif | 392 | #endif |
394 | 393 | ||
395 | static int __devinit spi_gpio_probe(struct platform_device *pdev) | 394 | static int spi_gpio_probe(struct platform_device *pdev) |
396 | { | 395 | { |
397 | int status; | 396 | int status; |
398 | struct spi_master *master; | 397 | struct spi_master *master; |
@@ -485,7 +484,7 @@ gpio_free: | |||
485 | return status; | 484 | return status; |
486 | } | 485 | } |
487 | 486 | ||
488 | static int __devexit spi_gpio_remove(struct platform_device *pdev) | 487 | static int spi_gpio_remove(struct platform_device *pdev) |
489 | { | 488 | { |
490 | struct spi_gpio *spi_gpio; | 489 | struct spi_gpio *spi_gpio; |
491 | struct spi_gpio_platform_data *pdata; | 490 | struct spi_gpio_platform_data *pdata; |
@@ -518,7 +517,7 @@ static struct platform_driver spi_gpio_driver = { | |||
518 | .of_match_table = of_match_ptr(spi_gpio_dt_ids), | 517 | .of_match_table = of_match_ptr(spi_gpio_dt_ids), |
519 | }, | 518 | }, |
520 | .probe = spi_gpio_probe, | 519 | .probe = spi_gpio_probe, |
521 | .remove = __devexit_p(spi_gpio_remove), | 520 | .remove = spi_gpio_remove, |
522 | }; | 521 | }; |
523 | module_platform_driver(spi_gpio_driver); | 522 | module_platform_driver(spi_gpio_driver); |
524 | 523 | ||
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index c9a0d8467de6..904913290aa5 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c | |||
@@ -750,7 +750,7 @@ static void spi_imx_cleanup(struct spi_device *spi) | |||
750 | { | 750 | { |
751 | } | 751 | } |
752 | 752 | ||
753 | static int __devinit spi_imx_probe(struct platform_device *pdev) | 753 | static int spi_imx_probe(struct platform_device *pdev) |
754 | { | 754 | { |
755 | struct device_node *np = pdev->dev.of_node; | 755 | struct device_node *np = pdev->dev.of_node; |
756 | const struct of_device_id *of_id = | 756 | const struct of_device_id *of_id = |
@@ -906,7 +906,7 @@ out_gpio_free: | |||
906 | return ret; | 906 | return ret; |
907 | } | 907 | } |
908 | 908 | ||
909 | static int __devexit spi_imx_remove(struct platform_device *pdev) | 909 | static int spi_imx_remove(struct platform_device *pdev) |
910 | { | 910 | { |
911 | struct spi_master *master = platform_get_drvdata(pdev); | 911 | struct spi_master *master = platform_get_drvdata(pdev); |
912 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 912 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -942,7 +942,7 @@ static struct platform_driver spi_imx_driver = { | |||
942 | }, | 942 | }, |
943 | .id_table = spi_imx_devtype, | 943 | .id_table = spi_imx_devtype, |
944 | .probe = spi_imx_probe, | 944 | .probe = spi_imx_probe, |
945 | .remove = __devexit_p(spi_imx_remove), | 945 | .remove = spi_imx_remove, |
946 | }; | 946 | }; |
947 | module_platform_driver(spi_imx_driver); | 947 | module_platform_driver(spi_imx_driver); |
948 | 948 | ||
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 0a1e39e94d06..cb3a3106bd4f 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c | |||
@@ -406,7 +406,7 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id) | |||
406 | } | 406 | } |
407 | 407 | ||
408 | /* bus_num is used only for the case dev->platform_data == NULL */ | 408 | /* bus_num is used only for the case dev->platform_data == NULL */ |
409 | static int __devinit mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, | 409 | static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, |
410 | u32 size, unsigned int irq, | 410 | u32 size, unsigned int irq, |
411 | s16 bus_num) | 411 | s16 bus_num) |
412 | { | 412 | { |
@@ -492,7 +492,7 @@ free_master: | |||
492 | return ret; | 492 | return ret; |
493 | } | 493 | } |
494 | 494 | ||
495 | static int __devexit mpc512x_psc_spi_do_remove(struct device *dev) | 495 | static int mpc512x_psc_spi_do_remove(struct device *dev) |
496 | { | 496 | { |
497 | struct spi_master *master = spi_master_get(dev_get_drvdata(dev)); | 497 | struct spi_master *master = spi_master_get(dev_get_drvdata(dev)); |
498 | struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); | 498 | struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); |
@@ -508,7 +508,7 @@ static int __devexit mpc512x_psc_spi_do_remove(struct device *dev) | |||
508 | return 0; | 508 | return 0; |
509 | } | 509 | } |
510 | 510 | ||
511 | static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op) | 511 | static int mpc512x_psc_spi_of_probe(struct platform_device *op) |
512 | { | 512 | { |
513 | const u32 *regaddr_p; | 513 | const u32 *regaddr_p; |
514 | u64 regaddr64, size64; | 514 | u64 regaddr64, size64; |
@@ -539,7 +539,7 @@ static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op) | |||
539 | irq_of_parse_and_map(op->dev.of_node, 0), id); | 539 | irq_of_parse_and_map(op->dev.of_node, 0), id); |
540 | } | 540 | } |
541 | 541 | ||
542 | static int __devexit mpc512x_psc_spi_of_remove(struct platform_device *op) | 542 | static int mpc512x_psc_spi_of_remove(struct platform_device *op) |
543 | { | 543 | { |
544 | return mpc512x_psc_spi_do_remove(&op->dev); | 544 | return mpc512x_psc_spi_do_remove(&op->dev); |
545 | } | 545 | } |
@@ -553,7 +553,7 @@ MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match); | |||
553 | 553 | ||
554 | static struct platform_driver mpc512x_psc_spi_of_driver = { | 554 | static struct platform_driver mpc512x_psc_spi_of_driver = { |
555 | .probe = mpc512x_psc_spi_of_probe, | 555 | .probe = mpc512x_psc_spi_of_probe, |
556 | .remove = __devexit_p(mpc512x_psc_spi_of_remove), | 556 | .remove = mpc512x_psc_spi_of_remove, |
557 | .driver = { | 557 | .driver = { |
558 | .name = "mpc512x-psc-spi", | 558 | .name = "mpc512x-psc-spi", |
559 | .owner = THIS_MODULE, | 559 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c index bd47d262d53f..291120b37dbb 100644 --- a/drivers/spi/spi-mpc52xx-psc.c +++ b/drivers/spi/spi-mpc52xx-psc.c | |||
@@ -363,7 +363,7 @@ static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) | |||
363 | } | 363 | } |
364 | 364 | ||
365 | /* bus_num is used only for the case dev->platform_data == NULL */ | 365 | /* bus_num is used only for the case dev->platform_data == NULL */ |
366 | static int __devinit mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | 366 | static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, |
367 | u32 size, unsigned int irq, s16 bus_num) | 367 | u32 size, unsigned int irq, s16 bus_num) |
368 | { | 368 | { |
369 | struct fsl_spi_platform_data *pdata = dev->platform_data; | 369 | struct fsl_spi_platform_data *pdata = dev->platform_data; |
@@ -450,7 +450,7 @@ free_master: | |||
450 | return ret; | 450 | return ret; |
451 | } | 451 | } |
452 | 452 | ||
453 | static int __devinit mpc52xx_psc_spi_of_probe(struct platform_device *op) | 453 | static int mpc52xx_psc_spi_of_probe(struct platform_device *op) |
454 | { | 454 | { |
455 | const u32 *regaddr_p; | 455 | const u32 *regaddr_p; |
456 | u64 regaddr64, size64; | 456 | u64 regaddr64, size64; |
@@ -479,7 +479,7 @@ static int __devinit mpc52xx_psc_spi_of_probe(struct platform_device *op) | |||
479 | irq_of_parse_and_map(op->dev.of_node, 0), id); | 479 | irq_of_parse_and_map(op->dev.of_node, 0), id); |
480 | } | 480 | } |
481 | 481 | ||
482 | static int __devexit mpc52xx_psc_spi_of_remove(struct platform_device *op) | 482 | static int mpc52xx_psc_spi_of_remove(struct platform_device *op) |
483 | { | 483 | { |
484 | struct spi_master *master = spi_master_get(dev_get_drvdata(&op->dev)); | 484 | struct spi_master *master = spi_master_get(dev_get_drvdata(&op->dev)); |
485 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master); | 485 | struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master); |
@@ -505,7 +505,7 @@ MODULE_DEVICE_TABLE(of, mpc52xx_psc_spi_of_match); | |||
505 | 505 | ||
506 | static struct platform_driver mpc52xx_psc_spi_of_driver = { | 506 | static struct platform_driver mpc52xx_psc_spi_of_driver = { |
507 | .probe = mpc52xx_psc_spi_of_probe, | 507 | .probe = mpc52xx_psc_spi_of_probe, |
508 | .remove = __devexit_p(mpc52xx_psc_spi_of_remove), | 508 | .remove = mpc52xx_psc_spi_of_remove, |
509 | .driver = { | 509 | .driver = { |
510 | .name = "mpc52xx-psc-spi", | 510 | .name = "mpc52xx-psc-spi", |
511 | .owner = THIS_MODULE, | 511 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c index 045410650212..29f77056eedc 100644 --- a/drivers/spi/spi-mpc52xx.c +++ b/drivers/spi/spi-mpc52xx.c | |||
@@ -390,7 +390,7 @@ static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m) | |||
390 | /* | 390 | /* |
391 | * OF Platform Bus Binding | 391 | * OF Platform Bus Binding |
392 | */ | 392 | */ |
393 | static int __devinit mpc52xx_spi_probe(struct platform_device *op) | 393 | static int mpc52xx_spi_probe(struct platform_device *op) |
394 | { | 394 | { |
395 | struct spi_master *master; | 395 | struct spi_master *master; |
396 | struct mpc52xx_spi *ms; | 396 | struct mpc52xx_spi *ms; |
@@ -527,7 +527,7 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op) | |||
527 | return rc; | 527 | return rc; |
528 | } | 528 | } |
529 | 529 | ||
530 | static int __devexit mpc52xx_spi_remove(struct platform_device *op) | 530 | static int mpc52xx_spi_remove(struct platform_device *op) |
531 | { | 531 | { |
532 | struct spi_master *master = spi_master_get(dev_get_drvdata(&op->dev)); | 532 | struct spi_master *master = spi_master_get(dev_get_drvdata(&op->dev)); |
533 | struct mpc52xx_spi *ms = spi_master_get_devdata(master); | 533 | struct mpc52xx_spi *ms = spi_master_get_devdata(master); |
@@ -547,7 +547,7 @@ static int __devexit mpc52xx_spi_remove(struct platform_device *op) | |||
547 | return 0; | 547 | return 0; |
548 | } | 548 | } |
549 | 549 | ||
550 | static const struct of_device_id mpc52xx_spi_match[] __devinitconst = { | 550 | static const struct of_device_id mpc52xx_spi_match[] = { |
551 | { .compatible = "fsl,mpc5200-spi", }, | 551 | { .compatible = "fsl,mpc5200-spi", }, |
552 | {} | 552 | {} |
553 | }; | 553 | }; |
@@ -560,6 +560,6 @@ static struct platform_driver mpc52xx_spi_of_driver = { | |||
560 | .of_match_table = mpc52xx_spi_match, | 560 | .of_match_table = mpc52xx_spi_match, |
561 | }, | 561 | }, |
562 | .probe = mpc52xx_spi_probe, | 562 | .probe = mpc52xx_spi_probe, |
563 | .remove = __devexit_p(mpc52xx_spi_remove), | 563 | .remove = mpc52xx_spi_remove, |
564 | }; | 564 | }; |
565 | module_platform_driver(mpc52xx_spi_of_driver); | 565 | module_platform_driver(mpc52xx_spi_of_driver); |
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c index 86dd04d6bc87..a3ede249d05d 100644 --- a/drivers/spi/spi-mxs.c +++ b/drivers/spi/spi-mxs.c | |||
@@ -509,7 +509,7 @@ static const struct of_device_id mxs_spi_dt_ids[] = { | |||
509 | }; | 509 | }; |
510 | MODULE_DEVICE_TABLE(of, mxs_spi_dt_ids); | 510 | MODULE_DEVICE_TABLE(of, mxs_spi_dt_ids); |
511 | 511 | ||
512 | static int __devinit mxs_spi_probe(struct platform_device *pdev) | 512 | static int mxs_spi_probe(struct platform_device *pdev) |
513 | { | 513 | { |
514 | const struct of_device_id *of_id = | 514 | const struct of_device_id *of_id = |
515 | of_match_device(mxs_spi_dt_ids, &pdev->dev); | 515 | of_match_device(mxs_spi_dt_ids, &pdev->dev); |
@@ -636,7 +636,7 @@ out_master_free: | |||
636 | return ret; | 636 | return ret; |
637 | } | 637 | } |
638 | 638 | ||
639 | static int __devexit mxs_spi_remove(struct platform_device *pdev) | 639 | static int mxs_spi_remove(struct platform_device *pdev) |
640 | { | 640 | { |
641 | struct spi_master *master; | 641 | struct spi_master *master; |
642 | struct mxs_spi *spi; | 642 | struct mxs_spi *spi; |
@@ -659,7 +659,7 @@ static int __devexit mxs_spi_remove(struct platform_device *pdev) | |||
659 | 659 | ||
660 | static struct platform_driver mxs_spi_driver = { | 660 | static struct platform_driver mxs_spi_driver = { |
661 | .probe = mxs_spi_probe, | 661 | .probe = mxs_spi_probe, |
662 | .remove = __devexit_p(mxs_spi_remove), | 662 | .remove = mxs_spi_remove, |
663 | .driver = { | 663 | .driver = { |
664 | .name = DRIVER_NAME, | 664 | .name = DRIVER_NAME, |
665 | .owner = THIS_MODULE, | 665 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c index a6eca6ffdabe..b3f9ec83ef73 100644 --- a/drivers/spi/spi-nuc900.c +++ b/drivers/spi/spi-nuc900.c | |||
@@ -346,7 +346,7 @@ static void nuc900_init_spi(struct nuc900_spi *hw) | |||
346 | nuc900_enable_int(hw); | 346 | nuc900_enable_int(hw); |
347 | } | 347 | } |
348 | 348 | ||
349 | static int __devinit nuc900_spi_probe(struct platform_device *pdev) | 349 | static int nuc900_spi_probe(struct platform_device *pdev) |
350 | { | 350 | { |
351 | struct nuc900_spi *hw; | 351 | struct nuc900_spi *hw; |
352 | struct spi_master *master; | 352 | struct spi_master *master; |
@@ -453,7 +453,7 @@ err_nomem: | |||
453 | return err; | 453 | return err; |
454 | } | 454 | } |
455 | 455 | ||
456 | static int __devexit nuc900_spi_remove(struct platform_device *dev) | 456 | static int nuc900_spi_remove(struct platform_device *dev) |
457 | { | 457 | { |
458 | struct nuc900_spi *hw = platform_get_drvdata(dev); | 458 | struct nuc900_spi *hw = platform_get_drvdata(dev); |
459 | 459 | ||
@@ -477,7 +477,7 @@ static int __devexit nuc900_spi_remove(struct platform_device *dev) | |||
477 | 477 | ||
478 | static struct platform_driver nuc900_spi_driver = { | 478 | static struct platform_driver nuc900_spi_driver = { |
479 | .probe = nuc900_spi_probe, | 479 | .probe = nuc900_spi_probe, |
480 | .remove = __devexit_p(nuc900_spi_remove), | 480 | .remove = nuc900_spi_remove, |
481 | .driver = { | 481 | .driver = { |
482 | .name = "nuc900-spi", | 482 | .name = "nuc900-spi", |
483 | .owner = THIS_MODULE, | 483 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c index 9d9071b730be..432e66ec3088 100644 --- a/drivers/spi/spi-oc-tiny.c +++ b/drivers/spi/spi-oc-tiny.c | |||
@@ -243,7 +243,7 @@ static irqreturn_t tiny_spi_irq(int irq, void *dev) | |||
243 | #ifdef CONFIG_OF | 243 | #ifdef CONFIG_OF |
244 | #include <linux/of_gpio.h> | 244 | #include <linux/of_gpio.h> |
245 | 245 | ||
246 | static int __devinit tiny_spi_of_probe(struct platform_device *pdev) | 246 | static int tiny_spi_of_probe(struct platform_device *pdev) |
247 | { | 247 | { |
248 | struct tiny_spi *hw = platform_get_drvdata(pdev); | 248 | struct tiny_spi *hw = platform_get_drvdata(pdev); |
249 | struct device_node *np = pdev->dev.of_node; | 249 | struct device_node *np = pdev->dev.of_node; |
@@ -277,13 +277,13 @@ static int __devinit tiny_spi_of_probe(struct platform_device *pdev) | |||
277 | return 0; | 277 | return 0; |
278 | } | 278 | } |
279 | #else /* !CONFIG_OF */ | 279 | #else /* !CONFIG_OF */ |
280 | static int __devinit tiny_spi_of_probe(struct platform_device *pdev) | 280 | static int tiny_spi_of_probe(struct platform_device *pdev) |
281 | { | 281 | { |
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | #endif /* CONFIG_OF */ | 284 | #endif /* CONFIG_OF */ |
285 | 285 | ||
286 | static int __devinit tiny_spi_probe(struct platform_device *pdev) | 286 | static int tiny_spi_probe(struct platform_device *pdev) |
287 | { | 287 | { |
288 | struct tiny_spi_platform_data *platp = pdev->dev.platform_data; | 288 | struct tiny_spi_platform_data *platp = pdev->dev.platform_data; |
289 | struct tiny_spi *hw; | 289 | struct tiny_spi *hw; |
@@ -373,7 +373,7 @@ exit: | |||
373 | return err; | 373 | return err; |
374 | } | 374 | } |
375 | 375 | ||
376 | static int __devexit tiny_spi_remove(struct platform_device *pdev) | 376 | static int tiny_spi_remove(struct platform_device *pdev) |
377 | { | 377 | { |
378 | struct tiny_spi *hw = platform_get_drvdata(pdev); | 378 | struct tiny_spi *hw = platform_get_drvdata(pdev); |
379 | struct spi_master *master = hw->bitbang.master; | 379 | struct spi_master *master = hw->bitbang.master; |
@@ -399,7 +399,7 @@ MODULE_DEVICE_TABLE(of, tiny_spi_match); | |||
399 | 399 | ||
400 | static struct platform_driver tiny_spi_driver = { | 400 | static struct platform_driver tiny_spi_driver = { |
401 | .probe = tiny_spi_probe, | 401 | .probe = tiny_spi_probe, |
402 | .remove = __devexit_p(tiny_spi_remove), | 402 | .remove = tiny_spi_remove, |
403 | .driver = { | 403 | .driver = { |
404 | .name = DRV_NAME, | 404 | .name = DRV_NAME, |
405 | .owner = THIS_MODULE, | 405 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index ea8fb2efb0f8..24daf964a409 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c | |||
@@ -266,7 +266,7 @@ static int octeon_spi_nop_transfer_hardware(struct spi_master *master) | |||
266 | return 0; | 266 | return 0; |
267 | } | 267 | } |
268 | 268 | ||
269 | static int __devinit octeon_spi_probe(struct platform_device *pdev) | 269 | static int octeon_spi_probe(struct platform_device *pdev) |
270 | { | 270 | { |
271 | 271 | ||
272 | struct resource *res_mem; | 272 | struct resource *res_mem; |
@@ -326,7 +326,7 @@ fail: | |||
326 | return err; | 326 | return err; |
327 | } | 327 | } |
328 | 328 | ||
329 | static int __devexit octeon_spi_remove(struct platform_device *pdev) | 329 | static int octeon_spi_remove(struct platform_device *pdev) |
330 | { | 330 | { |
331 | struct octeon_spi *p = platform_get_drvdata(pdev); | 331 | struct octeon_spi *p = platform_get_drvdata(pdev); |
332 | u64 register_base = p->register_base; | 332 | u64 register_base = p->register_base; |
@@ -352,7 +352,7 @@ static struct platform_driver octeon_spi_driver = { | |||
352 | .of_match_table = octeon_spi_match, | 352 | .of_match_table = octeon_spi_match, |
353 | }, | 353 | }, |
354 | .probe = octeon_spi_probe, | 354 | .probe = octeon_spi_probe, |
355 | .remove = __devexit_p(octeon_spi_remove), | 355 | .remove = octeon_spi_remove, |
356 | }; | 356 | }; |
357 | 357 | ||
358 | module_platform_driver(octeon_spi_driver); | 358 | module_platform_driver(octeon_spi_driver); |
diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c index dfb4b7f448c5..3aef7fa7d5b8 100644 --- a/drivers/spi/spi-omap-100k.c +++ b/drivers/spi/spi-omap-100k.c | |||
@@ -486,7 +486,7 @@ static int __init omap1_spi100k_reset(struct omap1_spi100k *spi100k) | |||
486 | return 0; | 486 | return 0; |
487 | } | 487 | } |
488 | 488 | ||
489 | static int __devinit omap1_spi100k_probe(struct platform_device *pdev) | 489 | static int omap1_spi100k_probe(struct platform_device *pdev) |
490 | { | 490 | { |
491 | struct spi_master *master; | 491 | struct spi_master *master; |
492 | struct omap1_spi100k *spi100k; | 492 | struct omap1_spi100k *spi100k; |
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 3542fdc664b1..b610f522ca44 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/of.h> | 39 | #include <linux/of.h> |
40 | #include <linux/of_device.h> | 40 | #include <linux/of_device.h> |
41 | #include <linux/pinctrl/consumer.h> | 41 | #include <linux/pinctrl/consumer.h> |
42 | #include <linux/err.h> | ||
43 | 42 | ||
44 | #include <linux/spi/spi.h> | 43 | #include <linux/spi/spi.h> |
45 | 44 | ||
@@ -130,6 +129,7 @@ struct omap2_mcspi { | |||
130 | struct omap2_mcspi_dma *dma_channels; | 129 | struct omap2_mcspi_dma *dma_channels; |
131 | struct device *dev; | 130 | struct device *dev; |
132 | struct omap2_mcspi_regs ctx; | 131 | struct omap2_mcspi_regs ctx; |
132 | unsigned int pin_dir:1; | ||
133 | }; | 133 | }; |
134 | 134 | ||
135 | struct omap2_mcspi_cs { | 135 | struct omap2_mcspi_cs { |
@@ -323,19 +323,11 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, | |||
323 | struct omap2_mcspi *mcspi; | 323 | struct omap2_mcspi *mcspi; |
324 | struct omap2_mcspi_dma *mcspi_dma; | 324 | struct omap2_mcspi_dma *mcspi_dma; |
325 | unsigned int count; | 325 | unsigned int count; |
326 | u8 * rx; | ||
327 | const u8 * tx; | ||
328 | void __iomem *chstat_reg; | ||
329 | struct omap2_mcspi_cs *cs = spi->controller_state; | ||
330 | 326 | ||
331 | mcspi = spi_master_get_devdata(spi->master); | 327 | mcspi = spi_master_get_devdata(spi->master); |
332 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; | 328 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; |
333 | count = xfer->len; | 329 | count = xfer->len; |
334 | 330 | ||
335 | rx = xfer->rx_buf; | ||
336 | tx = xfer->tx_buf; | ||
337 | chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; | ||
338 | |||
339 | if (mcspi_dma->dma_tx) { | 331 | if (mcspi_dma->dma_tx) { |
340 | struct dma_async_tx_descriptor *tx; | 332 | struct dma_async_tx_descriptor *tx; |
341 | struct scatterlist sg; | 333 | struct scatterlist sg; |
@@ -359,19 +351,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, | |||
359 | dma_async_issue_pending(mcspi_dma->dma_tx); | 351 | dma_async_issue_pending(mcspi_dma->dma_tx); |
360 | omap2_mcspi_set_dma_req(spi, 0, 1); | 352 | omap2_mcspi_set_dma_req(spi, 0, 1); |
361 | 353 | ||
362 | wait_for_completion(&mcspi_dma->dma_tx_completion); | ||
363 | dma_unmap_single(mcspi->dev, xfer->tx_dma, count, | ||
364 | DMA_TO_DEVICE); | ||
365 | |||
366 | /* for TX_ONLY mode, be sure all words have shifted out */ | ||
367 | if (rx == NULL) { | ||
368 | if (mcspi_wait_for_reg_bit(chstat_reg, | ||
369 | OMAP2_MCSPI_CHSTAT_TXS) < 0) | ||
370 | dev_err(&spi->dev, "TXS timed out\n"); | ||
371 | else if (mcspi_wait_for_reg_bit(chstat_reg, | ||
372 | OMAP2_MCSPI_CHSTAT_EOT) < 0) | ||
373 | dev_err(&spi->dev, "EOT timed out\n"); | ||
374 | } | ||
375 | } | 354 | } |
376 | 355 | ||
377 | static unsigned | 356 | static unsigned |
@@ -492,6 +471,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) | |||
492 | struct dma_slave_config cfg; | 471 | struct dma_slave_config cfg; |
493 | enum dma_slave_buswidth width; | 472 | enum dma_slave_buswidth width; |
494 | unsigned es; | 473 | unsigned es; |
474 | void __iomem *chstat_reg; | ||
495 | 475 | ||
496 | mcspi = spi_master_get_devdata(spi->master); | 476 | mcspi = spi_master_get_devdata(spi->master); |
497 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; | 477 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; |
@@ -526,8 +506,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) | |||
526 | omap2_mcspi_tx_dma(spi, xfer, cfg); | 506 | omap2_mcspi_tx_dma(spi, xfer, cfg); |
527 | 507 | ||
528 | if (rx != NULL) | 508 | if (rx != NULL) |
529 | return omap2_mcspi_rx_dma(spi, xfer, cfg, es); | 509 | count = omap2_mcspi_rx_dma(spi, xfer, cfg, es); |
530 | 510 | ||
511 | if (tx != NULL) { | ||
512 | chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; | ||
513 | wait_for_completion(&mcspi_dma->dma_tx_completion); | ||
514 | dma_unmap_single(mcspi->dev, xfer->tx_dma, xfer->len, | ||
515 | DMA_TO_DEVICE); | ||
516 | |||
517 | /* for TX_ONLY mode, be sure all words have shifted out */ | ||
518 | if (rx == NULL) { | ||
519 | if (mcspi_wait_for_reg_bit(chstat_reg, | ||
520 | OMAP2_MCSPI_CHSTAT_TXS) < 0) | ||
521 | dev_err(&spi->dev, "TXS timed out\n"); | ||
522 | else if (mcspi_wait_for_reg_bit(chstat_reg, | ||
523 | OMAP2_MCSPI_CHSTAT_EOT) < 0) | ||
524 | dev_err(&spi->dev, "EOT timed out\n"); | ||
525 | } | ||
526 | } | ||
531 | return count; | 527 | return count; |
532 | } | 528 | } |
533 | 529 | ||
@@ -765,8 +761,15 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi, | |||
765 | /* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS | 761 | /* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS |
766 | * REVISIT: this controller could support SPI_3WIRE mode. | 762 | * REVISIT: this controller could support SPI_3WIRE mode. |
767 | */ | 763 | */ |
768 | l &= ~(OMAP2_MCSPI_CHCONF_IS|OMAP2_MCSPI_CHCONF_DPE1); | 764 | if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) { |
769 | l |= OMAP2_MCSPI_CHCONF_DPE0; | 765 | l &= ~OMAP2_MCSPI_CHCONF_IS; |
766 | l &= ~OMAP2_MCSPI_CHCONF_DPE1; | ||
767 | l |= OMAP2_MCSPI_CHCONF_DPE0; | ||
768 | } else { | ||
769 | l |= OMAP2_MCSPI_CHCONF_IS; | ||
770 | l |= OMAP2_MCSPI_CHCONF_DPE1; | ||
771 | l &= ~OMAP2_MCSPI_CHCONF_DPE0; | ||
772 | } | ||
770 | 773 | ||
771 | /* wordlength */ | 774 | /* wordlength */ |
772 | l &= ~OMAP2_MCSPI_CHCONF_WL_MASK; | 775 | l &= ~OMAP2_MCSPI_CHCONF_WL_MASK; |
@@ -1085,7 +1088,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, | |||
1085 | return 0; | 1088 | return 0; |
1086 | } | 1089 | } |
1087 | 1090 | ||
1088 | static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) | 1091 | static int omap2_mcspi_master_setup(struct omap2_mcspi *mcspi) |
1089 | { | 1092 | { |
1090 | struct spi_master *master = mcspi->master; | 1093 | struct spi_master *master = mcspi->master; |
1091 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; | 1094 | struct omap2_mcspi_regs *ctx = &mcspi->ctx; |
@@ -1138,7 +1141,7 @@ static const struct of_device_id omap_mcspi_of_match[] = { | |||
1138 | }; | 1141 | }; |
1139 | MODULE_DEVICE_TABLE(of, omap_mcspi_of_match); | 1142 | MODULE_DEVICE_TABLE(of, omap_mcspi_of_match); |
1140 | 1143 | ||
1141 | static int __devinit omap2_mcspi_probe(struct platform_device *pdev) | 1144 | static int omap2_mcspi_probe(struct platform_device *pdev) |
1142 | { | 1145 | { |
1143 | struct spi_master *master; | 1146 | struct spi_master *master; |
1144 | const struct omap2_mcspi_platform_config *pdata; | 1147 | const struct omap2_mcspi_platform_config *pdata; |
@@ -1167,6 +1170,11 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) | |||
1167 | master->cleanup = omap2_mcspi_cleanup; | 1170 | master->cleanup = omap2_mcspi_cleanup; |
1168 | master->dev.of_node = node; | 1171 | master->dev.of_node = node; |
1169 | 1172 | ||
1173 | dev_set_drvdata(&pdev->dev, master); | ||
1174 | |||
1175 | mcspi = spi_master_get_devdata(master); | ||
1176 | mcspi->master = master; | ||
1177 | |||
1170 | match = of_match_device(omap_mcspi_of_match, &pdev->dev); | 1178 | match = of_match_device(omap_mcspi_of_match, &pdev->dev); |
1171 | if (match) { | 1179 | if (match) { |
1172 | u32 num_cs = 1; /* default number of chipselect */ | 1180 | u32 num_cs = 1; /* default number of chipselect */ |
@@ -1175,19 +1183,17 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) | |||
1175 | of_property_read_u32(node, "ti,spi-num-cs", &num_cs); | 1183 | of_property_read_u32(node, "ti,spi-num-cs", &num_cs); |
1176 | master->num_chipselect = num_cs; | 1184 | master->num_chipselect = num_cs; |
1177 | master->bus_num = bus_num++; | 1185 | master->bus_num = bus_num++; |
1186 | if (of_get_property(node, "ti,pindir-d0-out-d1-in", NULL)) | ||
1187 | mcspi->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; | ||
1178 | } else { | 1188 | } else { |
1179 | pdata = pdev->dev.platform_data; | 1189 | pdata = pdev->dev.platform_data; |
1180 | master->num_chipselect = pdata->num_cs; | 1190 | master->num_chipselect = pdata->num_cs; |
1181 | if (pdev->id != -1) | 1191 | if (pdev->id != -1) |
1182 | master->bus_num = pdev->id; | 1192 | master->bus_num = pdev->id; |
1193 | mcspi->pin_dir = pdata->pin_dir; | ||
1183 | } | 1194 | } |
1184 | regs_offset = pdata->regs_offset; | 1195 | regs_offset = pdata->regs_offset; |
1185 | 1196 | ||
1186 | dev_set_drvdata(&pdev->dev, master); | ||
1187 | |||
1188 | mcspi = spi_master_get_devdata(master); | ||
1189 | mcspi->master = master; | ||
1190 | |||
1191 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1197 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1192 | if (r == NULL) { | 1198 | if (r == NULL) { |
1193 | status = -ENODEV; | 1199 | status = -ENODEV; |
@@ -1272,7 +1278,7 @@ free_master: | |||
1272 | return status; | 1278 | return status; |
1273 | } | 1279 | } |
1274 | 1280 | ||
1275 | static int __devexit omap2_mcspi_remove(struct platform_device *pdev) | 1281 | static int omap2_mcspi_remove(struct platform_device *pdev) |
1276 | { | 1282 | { |
1277 | struct spi_master *master; | 1283 | struct spi_master *master; |
1278 | struct omap2_mcspi *mcspi; | 1284 | struct omap2_mcspi *mcspi; |
@@ -1341,7 +1347,7 @@ static struct platform_driver omap2_mcspi_driver = { | |||
1341 | .of_match_table = omap_mcspi_of_match, | 1347 | .of_match_table = omap_mcspi_of_match, |
1342 | }, | 1348 | }, |
1343 | .probe = omap2_mcspi_probe, | 1349 | .probe = omap2_mcspi_probe, |
1344 | .remove = __devexit_p(omap2_mcspi_remove), | 1350 | .remove = omap2_mcspi_remove, |
1345 | }; | 1351 | }; |
1346 | 1352 | ||
1347 | module_platform_driver(omap2_mcspi_driver); | 1353 | module_platform_driver(omap2_mcspi_driver); |
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index b17c09cf0a05..b7e718254b1d 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c | |||
@@ -32,8 +32,12 @@ | |||
32 | #define ORION_SPI_DATA_IN_REG 0x0c | 32 | #define ORION_SPI_DATA_IN_REG 0x0c |
33 | #define ORION_SPI_INT_CAUSE_REG 0x10 | 33 | #define ORION_SPI_INT_CAUSE_REG 0x10 |
34 | 34 | ||
35 | #define ORION_SPI_MODE_CPOL (1 << 11) | ||
36 | #define ORION_SPI_MODE_CPHA (1 << 12) | ||
35 | #define ORION_SPI_IF_8_16_BIT_MODE (1 << 5) | 37 | #define ORION_SPI_IF_8_16_BIT_MODE (1 << 5) |
36 | #define ORION_SPI_CLK_PRESCALE_MASK 0x1F | 38 | #define ORION_SPI_CLK_PRESCALE_MASK 0x1F |
39 | #define ORION_SPI_MODE_MASK (ORION_SPI_MODE_CPOL | \ | ||
40 | ORION_SPI_MODE_CPHA) | ||
37 | 41 | ||
38 | struct orion_spi { | 42 | struct orion_spi { |
39 | struct spi_master *master; | 43 | struct spi_master *master; |
@@ -123,6 +127,23 @@ static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed) | |||
123 | return 0; | 127 | return 0; |
124 | } | 128 | } |
125 | 129 | ||
130 | static void | ||
131 | orion_spi_mode_set(struct spi_device *spi) | ||
132 | { | ||
133 | u32 reg; | ||
134 | struct orion_spi *orion_spi; | ||
135 | |||
136 | orion_spi = spi_master_get_devdata(spi->master); | ||
137 | |||
138 | reg = readl(spi_reg(orion_spi, ORION_SPI_IF_CONFIG_REG)); | ||
139 | reg &= ~ORION_SPI_MODE_MASK; | ||
140 | if (spi->mode & SPI_CPOL) | ||
141 | reg |= ORION_SPI_MODE_CPOL; | ||
142 | if (spi->mode & SPI_CPHA) | ||
143 | reg |= ORION_SPI_MODE_CPHA; | ||
144 | writel(reg, spi_reg(orion_spi, ORION_SPI_IF_CONFIG_REG)); | ||
145 | } | ||
146 | |||
126 | /* | 147 | /* |
127 | * called only when no transfer is active on the bus | 148 | * called only when no transfer is active on the bus |
128 | */ | 149 | */ |
@@ -142,6 +163,8 @@ orion_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
142 | if ((t != NULL) && t->bits_per_word) | 163 | if ((t != NULL) && t->bits_per_word) |
143 | bits_per_word = t->bits_per_word; | 164 | bits_per_word = t->bits_per_word; |
144 | 165 | ||
166 | orion_spi_mode_set(spi); | ||
167 | |||
145 | rc = orion_spi_baudrate_set(spi, speed); | 168 | rc = orion_spi_baudrate_set(spi, speed); |
146 | if (rc) | 169 | if (rc) |
147 | return rc; | 170 | return rc; |
@@ -399,7 +422,7 @@ static int __init orion_spi_probe(struct platform_device *pdev) | |||
399 | } | 422 | } |
400 | 423 | ||
401 | /* we support only mode 0, and no options */ | 424 | /* we support only mode 0, and no options */ |
402 | master->mode_bits = 0; | 425 | master->mode_bits = SPI_CPHA | SPI_CPOL; |
403 | 426 | ||
404 | master->setup = orion_spi_setup; | 427 | master->setup = orion_spi_setup; |
405 | master->transfer_one_message = orion_spi_transfer_one_message; | 428 | master->transfer_one_message = orion_spi_transfer_one_message; |
@@ -478,7 +501,7 @@ static int __exit orion_spi_remove(struct platform_device *pdev) | |||
478 | 501 | ||
479 | MODULE_ALIAS("platform:" DRIVER_NAME); | 502 | MODULE_ALIAS("platform:" DRIVER_NAME); |
480 | 503 | ||
481 | static const struct of_device_id orion_spi_of_match_table[] __devinitdata = { | 504 | static const struct of_device_id orion_spi_of_match_table[] = { |
482 | { .compatible = "marvell,orion-spi", }, | 505 | { .compatible = "marvell,orion-spi", }, |
483 | {} | 506 | {} |
484 | }; | 507 | }; |
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index a1db91a99b89..b0fe393c882c 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
@@ -371,6 +371,7 @@ struct pl022 { | |||
371 | /* Two optional pin states - default & sleep */ | 371 | /* Two optional pin states - default & sleep */ |
372 | struct pinctrl *pinctrl; | 372 | struct pinctrl *pinctrl; |
373 | struct pinctrl_state *pins_default; | 373 | struct pinctrl_state *pins_default; |
374 | struct pinctrl_state *pins_idle; | ||
374 | struct pinctrl_state *pins_sleep; | 375 | struct pinctrl_state *pins_sleep; |
375 | struct spi_master *master; | 376 | struct spi_master *master; |
376 | struct pl022_ssp_controller *master_info; | 377 | struct pl022_ssp_controller *master_info; |
@@ -1088,7 +1089,7 @@ err_alloc_rx_sg: | |||
1088 | return -ENOMEM; | 1089 | return -ENOMEM; |
1089 | } | 1090 | } |
1090 | 1091 | ||
1091 | static int __devinit pl022_dma_probe(struct pl022 *pl022) | 1092 | static int pl022_dma_probe(struct pl022 *pl022) |
1092 | { | 1093 | { |
1093 | dma_cap_mask_t mask; | 1094 | dma_cap_mask_t mask; |
1094 | 1095 | ||
@@ -2057,8 +2058,7 @@ pl022_platform_data_dt_get(struct device *dev) | |||
2057 | return pd; | 2058 | return pd; |
2058 | } | 2059 | } |
2059 | 2060 | ||
2060 | static int __devinit | 2061 | static int pl022_probe(struct amba_device *adev, const struct amba_id *id) |
2061 | pl022_probe(struct amba_device *adev, const struct amba_id *id) | ||
2062 | { | 2062 | { |
2063 | struct device *dev = &adev->dev; | 2063 | struct device *dev = &adev->dev; |
2064 | struct pl022_ssp_controller *platform_info = adev->dev.platform_data; | 2064 | struct pl022_ssp_controller *platform_info = adev->dev.platform_data; |
@@ -2116,6 +2116,11 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2116 | } else | 2116 | } else |
2117 | dev_err(dev, "could not get default pinstate\n"); | 2117 | dev_err(dev, "could not get default pinstate\n"); |
2118 | 2118 | ||
2119 | pl022->pins_idle = pinctrl_lookup_state(pl022->pinctrl, | ||
2120 | PINCTRL_STATE_IDLE); | ||
2121 | if (IS_ERR(pl022->pins_idle)) | ||
2122 | dev_dbg(dev, "could not get idle pinstate\n"); | ||
2123 | |||
2119 | pl022->pins_sleep = pinctrl_lookup_state(pl022->pinctrl, | 2124 | pl022->pins_sleep = pinctrl_lookup_state(pl022->pinctrl, |
2120 | PINCTRL_STATE_SLEEP); | 2125 | PINCTRL_STATE_SLEEP); |
2121 | if (IS_ERR(pl022->pins_sleep)) | 2126 | if (IS_ERR(pl022->pins_sleep)) |
@@ -2246,10 +2251,9 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2246 | pm_runtime_set_autosuspend_delay(dev, | 2251 | pm_runtime_set_autosuspend_delay(dev, |
2247 | platform_info->autosuspend_delay); | 2252 | platform_info->autosuspend_delay); |
2248 | pm_runtime_use_autosuspend(dev); | 2253 | pm_runtime_use_autosuspend(dev); |
2249 | pm_runtime_put_autosuspend(dev); | ||
2250 | } else { | ||
2251 | pm_runtime_put(dev); | ||
2252 | } | 2254 | } |
2255 | pm_runtime_put(dev); | ||
2256 | |||
2253 | return 0; | 2257 | return 0; |
2254 | 2258 | ||
2255 | err_spi_register: | 2259 | err_spi_register: |
@@ -2270,7 +2274,7 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2270 | return status; | 2274 | return status; |
2271 | } | 2275 | } |
2272 | 2276 | ||
2273 | static int __devexit | 2277 | static int |
2274 | pl022_remove(struct amba_device *adev) | 2278 | pl022_remove(struct amba_device *adev) |
2275 | { | 2279 | { |
2276 | struct pl022 *pl022 = amba_get_drvdata(adev); | 2280 | struct pl022 *pl022 = amba_get_drvdata(adev); |
@@ -2303,35 +2307,47 @@ pl022_remove(struct amba_device *adev) | |||
2303 | * the runtime counterparts to handle external resources like | 2307 | * the runtime counterparts to handle external resources like |
2304 | * clocks, pins and regulators when going to sleep. | 2308 | * clocks, pins and regulators when going to sleep. |
2305 | */ | 2309 | */ |
2306 | static void pl022_suspend_resources(struct pl022 *pl022) | 2310 | static void pl022_suspend_resources(struct pl022 *pl022, bool runtime) |
2307 | { | 2311 | { |
2308 | int ret; | 2312 | int ret; |
2313 | struct pinctrl_state *pins_state; | ||
2309 | 2314 | ||
2310 | clk_disable(pl022->clk); | 2315 | clk_disable(pl022->clk); |
2311 | 2316 | ||
2317 | pins_state = runtime ? pl022->pins_idle : pl022->pins_sleep; | ||
2312 | /* Optionally let pins go into sleep states */ | 2318 | /* Optionally let pins go into sleep states */ |
2313 | if (!IS_ERR(pl022->pins_sleep)) { | 2319 | if (!IS_ERR(pins_state)) { |
2314 | ret = pinctrl_select_state(pl022->pinctrl, | 2320 | ret = pinctrl_select_state(pl022->pinctrl, pins_state); |
2315 | pl022->pins_sleep); | ||
2316 | if (ret) | 2321 | if (ret) |
2317 | dev_err(&pl022->adev->dev, | 2322 | dev_err(&pl022->adev->dev, "could not set %s pins\n", |
2318 | "could not set pins to sleep state\n"); | 2323 | runtime ? "idle" : "sleep"); |
2319 | } | 2324 | } |
2320 | } | 2325 | } |
2321 | 2326 | ||
2322 | static void pl022_resume_resources(struct pl022 *pl022) | 2327 | static void pl022_resume_resources(struct pl022 *pl022, bool runtime) |
2323 | { | 2328 | { |
2324 | int ret; | 2329 | int ret; |
2325 | 2330 | ||
2326 | /* Optionaly enable pins to be muxed in and configured */ | 2331 | /* Optionaly enable pins to be muxed in and configured */ |
2332 | /* First go to the default state */ | ||
2327 | if (!IS_ERR(pl022->pins_default)) { | 2333 | if (!IS_ERR(pl022->pins_default)) { |
2328 | ret = pinctrl_select_state(pl022->pinctrl, | 2334 | ret = pinctrl_select_state(pl022->pinctrl, pl022->pins_default); |
2329 | pl022->pins_default); | ||
2330 | if (ret) | 2335 | if (ret) |
2331 | dev_err(&pl022->adev->dev, | 2336 | dev_err(&pl022->adev->dev, |
2332 | "could not set default pins\n"); | 2337 | "could not set default pins\n"); |
2333 | } | 2338 | } |
2334 | 2339 | ||
2340 | if (!runtime) { | ||
2341 | /* Then let's idle the pins until the next transfer happens */ | ||
2342 | if (!IS_ERR(pl022->pins_idle)) { | ||
2343 | ret = pinctrl_select_state(pl022->pinctrl, | ||
2344 | pl022->pins_idle); | ||
2345 | if (ret) | ||
2346 | dev_err(&pl022->adev->dev, | ||
2347 | "could not set idle pins\n"); | ||
2348 | } | ||
2349 | } | ||
2350 | |||
2335 | clk_enable(pl022->clk); | 2351 | clk_enable(pl022->clk); |
2336 | } | 2352 | } |
2337 | #endif | 2353 | #endif |
@@ -2347,7 +2363,9 @@ static int pl022_suspend(struct device *dev) | |||
2347 | dev_warn(dev, "cannot suspend master\n"); | 2363 | dev_warn(dev, "cannot suspend master\n"); |
2348 | return ret; | 2364 | return ret; |
2349 | } | 2365 | } |
2350 | pl022_suspend_resources(pl022); | 2366 | |
2367 | pm_runtime_get_sync(dev); | ||
2368 | pl022_suspend_resources(pl022, false); | ||
2351 | 2369 | ||
2352 | dev_dbg(dev, "suspended\n"); | 2370 | dev_dbg(dev, "suspended\n"); |
2353 | return 0; | 2371 | return 0; |
@@ -2358,7 +2376,8 @@ static int pl022_resume(struct device *dev) | |||
2358 | struct pl022 *pl022 = dev_get_drvdata(dev); | 2376 | struct pl022 *pl022 = dev_get_drvdata(dev); |
2359 | int ret; | 2377 | int ret; |
2360 | 2378 | ||
2361 | pl022_resume_resources(pl022); | 2379 | pl022_resume_resources(pl022, false); |
2380 | pm_runtime_put(dev); | ||
2362 | 2381 | ||
2363 | /* Start the queue running */ | 2382 | /* Start the queue running */ |
2364 | ret = spi_master_resume(pl022->master); | 2383 | ret = spi_master_resume(pl022->master); |
@@ -2376,7 +2395,7 @@ static int pl022_runtime_suspend(struct device *dev) | |||
2376 | { | 2395 | { |
2377 | struct pl022 *pl022 = dev_get_drvdata(dev); | 2396 | struct pl022 *pl022 = dev_get_drvdata(dev); |
2378 | 2397 | ||
2379 | pl022_suspend_resources(pl022); | 2398 | pl022_suspend_resources(pl022, true); |
2380 | return 0; | 2399 | return 0; |
2381 | } | 2400 | } |
2382 | 2401 | ||
@@ -2384,7 +2403,7 @@ static int pl022_runtime_resume(struct device *dev) | |||
2384 | { | 2403 | { |
2385 | struct pl022 *pl022 = dev_get_drvdata(dev); | 2404 | struct pl022 *pl022 = dev_get_drvdata(dev); |
2386 | 2405 | ||
2387 | pl022_resume_resources(pl022); | 2406 | pl022_resume_resources(pl022, true); |
2388 | return 0; | 2407 | return 0; |
2389 | } | 2408 | } |
2390 | #endif | 2409 | #endif |
@@ -2464,7 +2483,7 @@ static struct amba_driver pl022_driver = { | |||
2464 | }, | 2483 | }, |
2465 | .id_table = pl022_ids, | 2484 | .id_table = pl022_ids, |
2466 | .probe = pl022_probe, | 2485 | .probe = pl022_probe, |
2467 | .remove = __devexit_p(pl022_remove), | 2486 | .remove = pl022_remove, |
2468 | }; | 2487 | }; |
2469 | 2488 | ||
2470 | static int __init pl022_init(void) | 2489 | static int __init pl022_init(void) |
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index 9f6ba34b172c..cf95587eefde 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c | |||
@@ -51,7 +51,7 @@ void pxa_ssp_free(struct ssp_device *ssp) | |||
51 | } | 51 | } |
52 | EXPORT_SYMBOL_GPL(pxa_ssp_free); | 52 | EXPORT_SYMBOL_GPL(pxa_ssp_free); |
53 | 53 | ||
54 | static int __devinit ce4100_spi_probe(struct pci_dev *dev, | 54 | static int ce4100_spi_probe(struct pci_dev *dev, |
55 | const struct pci_device_id *ent) | 55 | const struct pci_device_id *ent) |
56 | { | 56 | { |
57 | int ret; | 57 | int ret; |
@@ -129,7 +129,7 @@ err_nomem: | |||
129 | return ret; | 129 | return ret; |
130 | } | 130 | } |
131 | 131 | ||
132 | static void __devexit ce4100_spi_remove(struct pci_dev *dev) | 132 | static void ce4100_spi_remove(struct pci_dev *dev) |
133 | { | 133 | { |
134 | struct ce4100_info *spi_info; | 134 | struct ce4100_info *spi_info; |
135 | struct ssp_device *ssp; | 135 | struct ssp_device *ssp; |
@@ -161,7 +161,7 @@ static struct pci_driver ce4100_spi_driver = { | |||
161 | .name = "ce4100_spi", | 161 | .name = "ce4100_spi", |
162 | .id_table = ce4100_spi_devices, | 162 | .id_table = ce4100_spi_devices, |
163 | .probe = ce4100_spi_probe, | 163 | .probe = ce4100_spi_probe, |
164 | .remove = __devexit_p(ce4100_spi_remove), | 164 | .remove = ce4100_spi_remove, |
165 | }; | 165 | }; |
166 | 166 | ||
167 | module_pci_driver(ce4100_spi_driver); | 167 | module_pci_driver(ce4100_spi_driver); |
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index dc25bee8d33f..5c8c4f5883c4 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c | |||
@@ -1438,7 +1438,7 @@ static void cleanup(struct spi_device *spi) | |||
1438 | kfree(chip); | 1438 | kfree(chip); |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | static int __devinit init_queue(struct driver_data *drv_data) | 1441 | static int init_queue(struct driver_data *drv_data) |
1442 | { | 1442 | { |
1443 | INIT_LIST_HEAD(&drv_data->queue); | 1443 | INIT_LIST_HEAD(&drv_data->queue); |
1444 | spin_lock_init(&drv_data->lock); | 1444 | spin_lock_init(&drv_data->lock); |
@@ -1526,7 +1526,7 @@ static int destroy_queue(struct driver_data *drv_data) | |||
1526 | return 0; | 1526 | return 0; |
1527 | } | 1527 | } |
1528 | 1528 | ||
1529 | static int __devinit pxa2xx_spi_probe(struct platform_device *pdev) | 1529 | static int pxa2xx_spi_probe(struct platform_device *pdev) |
1530 | { | 1530 | { |
1531 | struct device *dev = &pdev->dev; | 1531 | struct device *dev = &pdev->dev; |
1532 | struct pxa2xx_spi_master *platform_info; | 1532 | struct pxa2xx_spi_master *platform_info; |
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 30faf6d4ab91..902f2fb902db 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c | |||
@@ -661,7 +661,7 @@ static irqreturn_t rspi_irq(int irq, void *_sr) | |||
661 | return ret; | 661 | return ret; |
662 | } | 662 | } |
663 | 663 | ||
664 | static int __devinit rspi_request_dma(struct rspi_data *rspi, | 664 | static int rspi_request_dma(struct rspi_data *rspi, |
665 | struct platform_device *pdev) | 665 | struct platform_device *pdev) |
666 | { | 666 | { |
667 | struct rspi_plat_data *rspi_pd = pdev->dev.platform_data; | 667 | struct rspi_plat_data *rspi_pd = pdev->dev.platform_data; |
@@ -709,7 +709,7 @@ static int __devinit rspi_request_dma(struct rspi_data *rspi, | |||
709 | return 0; | 709 | return 0; |
710 | } | 710 | } |
711 | 711 | ||
712 | static void __devexit rspi_release_dma(struct rspi_data *rspi) | 712 | static void rspi_release_dma(struct rspi_data *rspi) |
713 | { | 713 | { |
714 | if (rspi->chan_tx) | 714 | if (rspi->chan_tx) |
715 | dma_release_channel(rspi->chan_tx); | 715 | dma_release_channel(rspi->chan_tx); |
@@ -717,7 +717,7 @@ static void __devexit rspi_release_dma(struct rspi_data *rspi) | |||
717 | dma_release_channel(rspi->chan_rx); | 717 | dma_release_channel(rspi->chan_rx); |
718 | } | 718 | } |
719 | 719 | ||
720 | static int __devexit rspi_remove(struct platform_device *pdev) | 720 | static int rspi_remove(struct platform_device *pdev) |
721 | { | 721 | { |
722 | struct rspi_data *rspi = dev_get_drvdata(&pdev->dev); | 722 | struct rspi_data *rspi = dev_get_drvdata(&pdev->dev); |
723 | 723 | ||
@@ -731,7 +731,7 @@ static int __devexit rspi_remove(struct platform_device *pdev) | |||
731 | return 0; | 731 | return 0; |
732 | } | 732 | } |
733 | 733 | ||
734 | static int __devinit rspi_probe(struct platform_device *pdev) | 734 | static int rspi_probe(struct platform_device *pdev) |
735 | { | 735 | { |
736 | struct resource *res; | 736 | struct resource *res; |
737 | struct spi_master *master; | 737 | struct spi_master *master; |
@@ -827,7 +827,7 @@ error1: | |||
827 | 827 | ||
828 | static struct platform_driver rspi_driver = { | 828 | static struct platform_driver rspi_driver = { |
829 | .probe = rspi_probe, | 829 | .probe = rspi_probe, |
830 | .remove = __devexit_p(rspi_remove), | 830 | .remove = rspi_remove, |
831 | .driver = { | 831 | .driver = { |
832 | .name = "rspi", | 832 | .name = "rspi", |
833 | .owner = THIS_MODULE, | 833 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c index a2a080b7f42b..02d64603fcc5 100644 --- a/drivers/spi/spi-s3c24xx.c +++ b/drivers/spi/spi-s3c24xx.c | |||
@@ -506,7 +506,7 @@ static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw) | |||
506 | } | 506 | } |
507 | } | 507 | } |
508 | 508 | ||
509 | static int __devinit s3c24xx_spi_probe(struct platform_device *pdev) | 509 | static int s3c24xx_spi_probe(struct platform_device *pdev) |
510 | { | 510 | { |
511 | struct s3c2410_spi_info *pdata; | 511 | struct s3c2410_spi_info *pdata; |
512 | struct s3c24xx_spi *hw; | 512 | struct s3c24xx_spi *hw; |
@@ -663,7 +663,7 @@ static int __devinit s3c24xx_spi_probe(struct platform_device *pdev) | |||
663 | return err; | 663 | return err; |
664 | } | 664 | } |
665 | 665 | ||
666 | static int __devexit s3c24xx_spi_remove(struct platform_device *dev) | 666 | static int s3c24xx_spi_remove(struct platform_device *dev) |
667 | { | 667 | { |
668 | struct s3c24xx_spi *hw = platform_get_drvdata(dev); | 668 | struct s3c24xx_spi *hw = platform_get_drvdata(dev); |
669 | 669 | ||
@@ -722,7 +722,7 @@ static const struct dev_pm_ops s3c24xx_spi_pmops = { | |||
722 | MODULE_ALIAS("platform:s3c2410-spi"); | 722 | MODULE_ALIAS("platform:s3c2410-spi"); |
723 | static struct platform_driver s3c24xx_spi_driver = { | 723 | static struct platform_driver s3c24xx_spi_driver = { |
724 | .probe = s3c24xx_spi_probe, | 724 | .probe = s3c24xx_spi_probe, |
725 | .remove = __devexit_p(s3c24xx_spi_remove), | 725 | .remove = s3c24xx_spi_remove, |
726 | .driver = { | 726 | .driver = { |
727 | .name = "s3c2410-spi", | 727 | .name = "s3c2410-spi", |
728 | .owner = THIS_MODULE, | 728 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 6e7a805d324d..4dd7b7ce5c5a 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c | |||
@@ -516,7 +516,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) | |||
516 | 516 | ||
517 | /* Disable Clock */ | 517 | /* Disable Clock */ |
518 | if (sdd->port_conf->clk_from_cmu) { | 518 | if (sdd->port_conf->clk_from_cmu) { |
519 | clk_disable(sdd->src_clk); | 519 | clk_disable_unprepare(sdd->src_clk); |
520 | } else { | 520 | } else { |
521 | val = readl(regs + S3C64XX_SPI_CLK_CFG); | 521 | val = readl(regs + S3C64XX_SPI_CLK_CFG); |
522 | val &= ~S3C64XX_SPI_ENCLK_ENABLE; | 522 | val &= ~S3C64XX_SPI_ENCLK_ENABLE; |
@@ -564,7 +564,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) | |||
564 | /* There is half-multiplier before the SPI */ | 564 | /* There is half-multiplier before the SPI */ |
565 | clk_set_rate(sdd->src_clk, sdd->cur_speed * 2); | 565 | clk_set_rate(sdd->src_clk, sdd->cur_speed * 2); |
566 | /* Enable Clock */ | 566 | /* Enable Clock */ |
567 | clk_enable(sdd->src_clk); | 567 | clk_prepare_enable(sdd->src_clk); |
568 | } else { | 568 | } else { |
569 | /* Configure Clock */ | 569 | /* Configure Clock */ |
570 | val = readl(regs + S3C64XX_SPI_CLK_CFG); | 570 | val = readl(regs + S3C64XX_SPI_CLK_CFG); |
@@ -1056,7 +1056,7 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel) | |||
1056 | flush_fifo(sdd); | 1056 | flush_fifo(sdd); |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | static int __devinit s3c64xx_spi_get_dmares( | 1059 | static int s3c64xx_spi_get_dmares( |
1060 | struct s3c64xx_spi_driver_data *sdd, bool tx) | 1060 | struct s3c64xx_spi_driver_data *sdd, bool tx) |
1061 | { | 1061 | { |
1062 | struct platform_device *pdev = sdd->pdev; | 1062 | struct platform_device *pdev = sdd->pdev; |
@@ -1112,7 +1112,7 @@ static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd) | |||
1112 | dev_err(dev, "invalid gpio[%d]: %d\n", idx, gpio); | 1112 | dev_err(dev, "invalid gpio[%d]: %d\n", idx, gpio); |
1113 | goto free_gpio; | 1113 | goto free_gpio; |
1114 | } | 1114 | } |
1115 | 1115 | sdd->gpios[idx] = gpio; | |
1116 | ret = gpio_request(gpio, "spi-bus"); | 1116 | ret = gpio_request(gpio, "spi-bus"); |
1117 | if (ret) { | 1117 | if (ret) { |
1118 | dev_err(dev, "gpio [%d] request failed: %d\n", | 1118 | dev_err(dev, "gpio [%d] request failed: %d\n", |
@@ -1135,7 +1135,7 @@ static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd) | |||
1135 | gpio_free(sdd->gpios[idx]); | 1135 | gpio_free(sdd->gpios[idx]); |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | static struct __devinit s3c64xx_spi_info * s3c64xx_spi_parse_dt( | 1138 | static struct s3c64xx_spi_info * s3c64xx_spi_parse_dt( |
1139 | struct device *dev) | 1139 | struct device *dev) |
1140 | { | 1140 | { |
1141 | struct s3c64xx_spi_info *sci; | 1141 | struct s3c64xx_spi_info *sci; |
@@ -1302,7 +1302,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) | |||
1302 | goto err3; | 1302 | goto err3; |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | if (clk_enable(sdd->clk)) { | 1305 | if (clk_prepare_enable(sdd->clk)) { |
1306 | dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); | 1306 | dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); |
1307 | ret = -EBUSY; | 1307 | ret = -EBUSY; |
1308 | goto err4; | 1308 | goto err4; |
@@ -1317,7 +1317,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) | |||
1317 | goto err5; | 1317 | goto err5; |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | if (clk_enable(sdd->src_clk)) { | 1320 | if (clk_prepare_enable(sdd->src_clk)) { |
1321 | dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name); | 1321 | dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name); |
1322 | ret = -EBUSY; | 1322 | ret = -EBUSY; |
1323 | goto err6; | 1323 | goto err6; |
@@ -1361,11 +1361,11 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) | |||
1361 | err8: | 1361 | err8: |
1362 | free_irq(irq, sdd); | 1362 | free_irq(irq, sdd); |
1363 | err7: | 1363 | err7: |
1364 | clk_disable(sdd->src_clk); | 1364 | clk_disable_unprepare(sdd->src_clk); |
1365 | err6: | 1365 | err6: |
1366 | clk_put(sdd->src_clk); | 1366 | clk_put(sdd->src_clk); |
1367 | err5: | 1367 | err5: |
1368 | clk_disable(sdd->clk); | 1368 | clk_disable_unprepare(sdd->clk); |
1369 | err4: | 1369 | err4: |
1370 | clk_put(sdd->clk); | 1370 | clk_put(sdd->clk); |
1371 | err3: | 1371 | err3: |
@@ -1393,10 +1393,10 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) | |||
1393 | 1393 | ||
1394 | free_irq(platform_get_irq(pdev, 0), sdd); | 1394 | free_irq(platform_get_irq(pdev, 0), sdd); |
1395 | 1395 | ||
1396 | clk_disable(sdd->src_clk); | 1396 | clk_disable_unprepare(sdd->src_clk); |
1397 | clk_put(sdd->src_clk); | 1397 | clk_put(sdd->src_clk); |
1398 | 1398 | ||
1399 | clk_disable(sdd->clk); | 1399 | clk_disable_unprepare(sdd->clk); |
1400 | clk_put(sdd->clk); | 1400 | clk_put(sdd->clk); |
1401 | 1401 | ||
1402 | if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) | 1402 | if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) |
@@ -1417,8 +1417,8 @@ static int s3c64xx_spi_suspend(struct device *dev) | |||
1417 | spi_master_suspend(master); | 1417 | spi_master_suspend(master); |
1418 | 1418 | ||
1419 | /* Disable the clock */ | 1419 | /* Disable the clock */ |
1420 | clk_disable(sdd->src_clk); | 1420 | clk_disable_unprepare(sdd->src_clk); |
1421 | clk_disable(sdd->clk); | 1421 | clk_disable_unprepare(sdd->clk); |
1422 | 1422 | ||
1423 | if (!sdd->cntrlr_info->cfg_gpio && dev->of_node) | 1423 | if (!sdd->cntrlr_info->cfg_gpio && dev->of_node) |
1424 | s3c64xx_spi_dt_gpio_free(sdd); | 1424 | s3c64xx_spi_dt_gpio_free(sdd); |
@@ -1440,8 +1440,8 @@ static int s3c64xx_spi_resume(struct device *dev) | |||
1440 | sci->cfg_gpio(); | 1440 | sci->cfg_gpio(); |
1441 | 1441 | ||
1442 | /* Enable the clock */ | 1442 | /* Enable the clock */ |
1443 | clk_enable(sdd->src_clk); | 1443 | clk_prepare_enable(sdd->src_clk); |
1444 | clk_enable(sdd->clk); | 1444 | clk_prepare_enable(sdd->clk); |
1445 | 1445 | ||
1446 | s3c64xx_spi_hwinit(sdd, sdd->port_id); | 1446 | s3c64xx_spi_hwinit(sdd, sdd->port_id); |
1447 | 1447 | ||
@@ -1457,8 +1457,8 @@ static int s3c64xx_spi_runtime_suspend(struct device *dev) | |||
1457 | struct spi_master *master = dev_get_drvdata(dev); | 1457 | struct spi_master *master = dev_get_drvdata(dev); |
1458 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); | 1458 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); |
1459 | 1459 | ||
1460 | clk_disable(sdd->clk); | 1460 | clk_disable_unprepare(sdd->clk); |
1461 | clk_disable(sdd->src_clk); | 1461 | clk_disable_unprepare(sdd->src_clk); |
1462 | 1462 | ||
1463 | return 0; | 1463 | return 0; |
1464 | } | 1464 | } |
@@ -1468,8 +1468,8 @@ static int s3c64xx_spi_runtime_resume(struct device *dev) | |||
1468 | struct spi_master *master = dev_get_drvdata(dev); | 1468 | struct spi_master *master = dev_get_drvdata(dev); |
1469 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); | 1469 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); |
1470 | 1470 | ||
1471 | clk_enable(sdd->src_clk); | 1471 | clk_prepare_enable(sdd->src_clk); |
1472 | clk_enable(sdd->clk); | 1472 | clk_prepare_enable(sdd->clk); |
1473 | 1473 | ||
1474 | return 0; | 1474 | return 0; |
1475 | } | 1475 | } |
diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c index 796c077ef439..32f7b55fce09 100644 --- a/drivers/spi/spi-sh-hspi.c +++ b/drivers/spi/spi-sh-hspi.c | |||
@@ -68,6 +68,16 @@ static u32 hspi_read(struct hspi_priv *hspi, int reg) | |||
68 | return ioread32(hspi->addr + reg); | 68 | return ioread32(hspi->addr + reg); |
69 | } | 69 | } |
70 | 70 | ||
71 | static void hspi_bit_set(struct hspi_priv *hspi, int reg, u32 mask, u32 set) | ||
72 | { | ||
73 | u32 val = hspi_read(hspi, reg); | ||
74 | |||
75 | val &= ~mask; | ||
76 | val |= set & mask; | ||
77 | |||
78 | hspi_write(hspi, reg, val); | ||
79 | } | ||
80 | |||
71 | /* | 81 | /* |
72 | * transfer function | 82 | * transfer function |
73 | */ | 83 | */ |
@@ -105,6 +115,13 @@ static int hspi_unprepare_transfer(struct spi_master *master) | |||
105 | return 0; | 115 | return 0; |
106 | } | 116 | } |
107 | 117 | ||
118 | #define hspi_hw_cs_enable(hspi) hspi_hw_cs_ctrl(hspi, 0) | ||
119 | #define hspi_hw_cs_disable(hspi) hspi_hw_cs_ctrl(hspi, 1) | ||
120 | static void hspi_hw_cs_ctrl(struct hspi_priv *hspi, int hi) | ||
121 | { | ||
122 | hspi_bit_set(hspi, SPSCR, (1 << 6), (hi) << 6); | ||
123 | } | ||
124 | |||
108 | static void hspi_hw_setup(struct hspi_priv *hspi, | 125 | static void hspi_hw_setup(struct hspi_priv *hspi, |
109 | struct spi_message *msg, | 126 | struct spi_message *msg, |
110 | struct spi_transfer *t) | 127 | struct spi_transfer *t) |
@@ -155,7 +172,7 @@ static void hspi_hw_setup(struct hspi_priv *hspi, | |||
155 | 172 | ||
156 | hspi_write(hspi, SPCR, spcr); | 173 | hspi_write(hspi, SPCR, spcr); |
157 | hspi_write(hspi, SPSR, 0x0); | 174 | hspi_write(hspi, SPSR, 0x0); |
158 | hspi_write(hspi, SPSCR, 0x1); /* master mode */ | 175 | hspi_write(hspi, SPSCR, 0x21); /* master mode / CS control */ |
159 | } | 176 | } |
160 | 177 | ||
161 | static int hspi_transfer_one_message(struct spi_master *master, | 178 | static int hspi_transfer_one_message(struct spi_master *master, |
@@ -166,12 +183,21 @@ static int hspi_transfer_one_message(struct spi_master *master, | |||
166 | u32 tx; | 183 | u32 tx; |
167 | u32 rx; | 184 | u32 rx; |
168 | int ret, i; | 185 | int ret, i; |
186 | unsigned int cs_change; | ||
187 | const int nsecs = 50; | ||
169 | 188 | ||
170 | dev_dbg(hspi->dev, "%s\n", __func__); | 189 | dev_dbg(hspi->dev, "%s\n", __func__); |
171 | 190 | ||
191 | cs_change = 1; | ||
172 | ret = 0; | 192 | ret = 0; |
173 | list_for_each_entry(t, &msg->transfers, transfer_list) { | 193 | list_for_each_entry(t, &msg->transfers, transfer_list) { |
174 | hspi_hw_setup(hspi, msg, t); | 194 | |
195 | if (cs_change) { | ||
196 | hspi_hw_setup(hspi, msg, t); | ||
197 | hspi_hw_cs_enable(hspi); | ||
198 | ndelay(nsecs); | ||
199 | } | ||
200 | cs_change = t->cs_change; | ||
175 | 201 | ||
176 | for (i = 0; i < t->len; i++) { | 202 | for (i = 0; i < t->len; i++) { |
177 | 203 | ||
@@ -198,9 +224,22 @@ static int hspi_transfer_one_message(struct spi_master *master, | |||
198 | } | 224 | } |
199 | 225 | ||
200 | msg->actual_length += t->len; | 226 | msg->actual_length += t->len; |
227 | |||
228 | if (t->delay_usecs) | ||
229 | udelay(t->delay_usecs); | ||
230 | |||
231 | if (cs_change) { | ||
232 | ndelay(nsecs); | ||
233 | hspi_hw_cs_disable(hspi); | ||
234 | ndelay(nsecs); | ||
235 | } | ||
201 | } | 236 | } |
202 | 237 | ||
203 | msg->status = ret; | 238 | msg->status = ret; |
239 | if (!cs_change) { | ||
240 | ndelay(nsecs); | ||
241 | hspi_hw_cs_disable(hspi); | ||
242 | } | ||
204 | spi_finalize_current_message(master); | 243 | spi_finalize_current_message(master); |
205 | 244 | ||
206 | return ret; | 245 | return ret; |
@@ -229,7 +268,7 @@ static void hspi_cleanup(struct spi_device *spi) | |||
229 | dev_dbg(dev, "%s cleanup\n", spi->modalias); | 268 | dev_dbg(dev, "%s cleanup\n", spi->modalias); |
230 | } | 269 | } |
231 | 270 | ||
232 | static int __devinit hspi_probe(struct platform_device *pdev) | 271 | static int hspi_probe(struct platform_device *pdev) |
233 | { | 272 | { |
234 | struct resource *res; | 273 | struct resource *res; |
235 | struct spi_master *master; | 274 | struct spi_master *master; |
@@ -300,7 +339,7 @@ static int __devinit hspi_probe(struct platform_device *pdev) | |||
300 | return ret; | 339 | return ret; |
301 | } | 340 | } |
302 | 341 | ||
303 | static int __devexit hspi_remove(struct platform_device *pdev) | 342 | static int hspi_remove(struct platform_device *pdev) |
304 | { | 343 | { |
305 | struct hspi_priv *hspi = dev_get_drvdata(&pdev->dev); | 344 | struct hspi_priv *hspi = dev_get_drvdata(&pdev->dev); |
306 | 345 | ||
@@ -314,7 +353,7 @@ static int __devexit hspi_remove(struct platform_device *pdev) | |||
314 | 353 | ||
315 | static struct platform_driver hspi_driver = { | 354 | static struct platform_driver hspi_driver = { |
316 | .probe = hspi_probe, | 355 | .probe = hspi_probe, |
317 | .remove = __devexit_p(hspi_remove), | 356 | .remove = hspi_remove, |
318 | .driver = { | 357 | .driver = { |
319 | .name = "sh-hspi", | 358 | .name = "sh-hspi", |
320 | .owner = THIS_MODULE, | 359 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 1f466bc66d9d..96358d0eabb7 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c | |||
@@ -597,7 +597,6 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) | |||
597 | struct resource *r; | 597 | struct resource *r; |
598 | struct spi_master *master; | 598 | struct spi_master *master; |
599 | struct sh_msiof_spi_priv *p; | 599 | struct sh_msiof_spi_priv *p; |
600 | char clk_name[16]; | ||
601 | int i; | 600 | int i; |
602 | int ret; | 601 | int ret; |
603 | 602 | ||
@@ -614,10 +613,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) | |||
614 | p->info = pdev->dev.platform_data; | 613 | p->info = pdev->dev.platform_data; |
615 | init_completion(&p->done); | 614 | init_completion(&p->done); |
616 | 615 | ||
617 | snprintf(clk_name, sizeof(clk_name), "msiof%d", pdev->id); | 616 | p->clk = clk_get(&pdev->dev, NULL); |
618 | p->clk = clk_get(&pdev->dev, clk_name); | ||
619 | if (IS_ERR(p->clk)) { | 617 | if (IS_ERR(p->clk)) { |
620 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | 618 | dev_err(&pdev->dev, "cannot get clock\n"); |
621 | ret = PTR_ERR(p->clk); | 619 | ret = PTR_ERR(p->clk); |
622 | goto err1; | 620 | goto err1; |
623 | } | 621 | } |
diff --git a/drivers/spi/spi-sh.c b/drivers/spi/spi-sh.c index 79442c31bcd9..3c3600a994bd 100644 --- a/drivers/spi/spi-sh.c +++ b/drivers/spi/spi-sh.c | |||
@@ -432,7 +432,7 @@ static irqreturn_t spi_sh_irq(int irq, void *_ss) | |||
432 | return IRQ_HANDLED; | 432 | return IRQ_HANDLED; |
433 | } | 433 | } |
434 | 434 | ||
435 | static int __devexit spi_sh_remove(struct platform_device *pdev) | 435 | static int spi_sh_remove(struct platform_device *pdev) |
436 | { | 436 | { |
437 | struct spi_sh_data *ss = dev_get_drvdata(&pdev->dev); | 437 | struct spi_sh_data *ss = dev_get_drvdata(&pdev->dev); |
438 | 438 | ||
@@ -444,7 +444,7 @@ static int __devexit spi_sh_remove(struct platform_device *pdev) | |||
444 | return 0; | 444 | return 0; |
445 | } | 445 | } |
446 | 446 | ||
447 | static int __devinit spi_sh_probe(struct platform_device *pdev) | 447 | static int spi_sh_probe(struct platform_device *pdev) |
448 | { | 448 | { |
449 | struct resource *res; | 449 | struct resource *res; |
450 | struct spi_master *master; | 450 | struct spi_master *master; |
@@ -539,7 +539,7 @@ static int __devinit spi_sh_probe(struct platform_device *pdev) | |||
539 | 539 | ||
540 | static struct platform_driver spi_sh_driver = { | 540 | static struct platform_driver spi_sh_driver = { |
541 | .probe = spi_sh_probe, | 541 | .probe = spi_sh_probe, |
542 | .remove = __devexit_p(spi_sh_remove), | 542 | .remove = spi_sh_remove, |
543 | .driver = { | 543 | .driver = { |
544 | .name = "sh_spi", | 544 | .name = "sh_spi", |
545 | .owner = THIS_MODULE, | 545 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index ecc3d9763d10..e0f43a512e84 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c | |||
@@ -479,7 +479,7 @@ static int spi_sirfsoc_setup(struct spi_device *spi) | |||
479 | return spi_sirfsoc_setup_transfer(spi, NULL); | 479 | return spi_sirfsoc_setup_transfer(spi, NULL); |
480 | } | 480 | } |
481 | 481 | ||
482 | static int __devinit spi_sirfsoc_probe(struct platform_device *pdev) | 482 | static int spi_sirfsoc_probe(struct platform_device *pdev) |
483 | { | 483 | { |
484 | struct sirfsoc_spi *sspi; | 484 | struct sirfsoc_spi *sspi; |
485 | struct spi_master *master; | 485 | struct spi_master *master; |
@@ -604,7 +604,7 @@ err_cs: | |||
604 | return ret; | 604 | return ret; |
605 | } | 605 | } |
606 | 606 | ||
607 | static int __devexit spi_sirfsoc_remove(struct platform_device *pdev) | 607 | static int spi_sirfsoc_remove(struct platform_device *pdev) |
608 | { | 608 | { |
609 | struct spi_master *master; | 609 | struct spi_master *master; |
610 | struct sirfsoc_spi *sspi; | 610 | struct sirfsoc_spi *sspi; |
@@ -673,7 +673,7 @@ static struct platform_driver spi_sirfsoc_driver = { | |||
673 | .of_match_table = spi_sirfsoc_of_match, | 673 | .of_match_table = spi_sirfsoc_of_match, |
674 | }, | 674 | }, |
675 | .probe = spi_sirfsoc_probe, | 675 | .probe = spi_sirfsoc_probe, |
676 | .remove = __devexit_p(spi_sirfsoc_remove), | 676 | .remove = spi_sirfsoc_remove, |
677 | }; | 677 | }; |
678 | module_platform_driver(spi_sirfsoc_driver); | 678 | module_platform_driver(spi_sirfsoc_driver); |
679 | 679 | ||
diff --git a/drivers/spi/spi-stmp.c b/drivers/spi/spi-stmp.c deleted file mode 100644 index 911e904b3c84..000000000000 --- a/drivers/spi/spi-stmp.c +++ /dev/null | |||
@@ -1,664 +0,0 @@ | |||
1 | /* | ||
2 | * Freescale STMP378X SPI master driver | ||
3 | * | ||
4 | * Author: dmitry pervushin <dimka@embeddedalley.com> | ||
5 | * | ||
6 | * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. | ||
7 | * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * The code contained herein is licensed under the GNU General Public | ||
12 | * License. You may obtain a copy of the GNU General Public License | ||
13 | * Version 2 or later at the following locations: | ||
14 | * | ||
15 | * http://www.opensource.org/licenses/gpl-license.html | ||
16 | * http://www.gnu.org/copyleft/gpl.html | ||
17 | */ | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/spi/spi.h> | ||
23 | #include <linux/err.h> | ||
24 | #include <linux/clk.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/dma-mapping.h> | ||
27 | #include <linux/delay.h> | ||
28 | |||
29 | #include <mach/platform.h> | ||
30 | #include <mach/stmp3xxx.h> | ||
31 | #include <mach/dma.h> | ||
32 | #include <mach/regs-ssp.h> | ||
33 | #include <mach/regs-apbh.h> | ||
34 | |||
35 | |||
36 | /* 0 means DMA mode(recommended, default), !0 - PIO mode */ | ||
37 | static int pio; | ||
38 | static int clock; | ||
39 | |||
40 | /* default timeout for busy waits is 2 seconds */ | ||
41 | #define STMP_SPI_TIMEOUT (2 * HZ) | ||
42 | |||
43 | struct stmp_spi { | ||
44 | int id; | ||
45 | |||
46 | void * __iomem regs; /* vaddr of the control registers */ | ||
47 | |||
48 | int irq, err_irq; | ||
49 | u32 dma; | ||
50 | struct stmp3xxx_dma_descriptor d; | ||
51 | |||
52 | u32 speed_khz; | ||
53 | u32 saved_timings; | ||
54 | u32 divider; | ||
55 | |||
56 | struct clk *clk; | ||
57 | struct device *master_dev; | ||
58 | |||
59 | struct work_struct work; | ||
60 | struct workqueue_struct *workqueue; | ||
61 | |||
62 | /* lock protects queue access */ | ||
63 | spinlock_t lock; | ||
64 | struct list_head queue; | ||
65 | |||
66 | struct completion done; | ||
67 | }; | ||
68 | |||
69 | #define busy_wait(cond) \ | ||
70 | ({ \ | ||
71 | unsigned long end_jiffies = jiffies + STMP_SPI_TIMEOUT; \ | ||
72 | bool succeeded = false; \ | ||
73 | do { \ | ||
74 | if (cond) { \ | ||
75 | succeeded = true; \ | ||
76 | break; \ | ||
77 | } \ | ||
78 | cpu_relax(); \ | ||
79 | } while (time_before(jiffies, end_jiffies)); \ | ||
80 | succeeded; \ | ||
81 | }) | ||
82 | |||
83 | /** | ||
84 | * stmp_spi_init_hw | ||
85 | * Initialize the SSP port | ||
86 | */ | ||
87 | static int stmp_spi_init_hw(struct stmp_spi *ss) | ||
88 | { | ||
89 | int err = 0; | ||
90 | void *pins = ss->master_dev->platform_data; | ||
91 | |||
92 | err = stmp3xxx_request_pin_group(pins, dev_name(ss->master_dev)); | ||
93 | if (err) | ||
94 | goto out; | ||
95 | |||
96 | ss->clk = clk_get(NULL, "ssp"); | ||
97 | if (IS_ERR(ss->clk)) { | ||
98 | err = PTR_ERR(ss->clk); | ||
99 | goto out_free_pins; | ||
100 | } | ||
101 | clk_enable(ss->clk); | ||
102 | |||
103 | stmp3xxx_reset_block(ss->regs, false); | ||
104 | stmp3xxx_dma_reset_channel(ss->dma); | ||
105 | |||
106 | return 0; | ||
107 | |||
108 | out_free_pins: | ||
109 | stmp3xxx_release_pin_group(pins, dev_name(ss->master_dev)); | ||
110 | out: | ||
111 | return err; | ||
112 | } | ||
113 | |||
114 | static void stmp_spi_release_hw(struct stmp_spi *ss) | ||
115 | { | ||
116 | void *pins = ss->master_dev->platform_data; | ||
117 | |||
118 | if (ss->clk && !IS_ERR(ss->clk)) { | ||
119 | clk_disable(ss->clk); | ||
120 | clk_put(ss->clk); | ||
121 | } | ||
122 | stmp3xxx_release_pin_group(pins, dev_name(ss->master_dev)); | ||
123 | } | ||
124 | |||
125 | static int stmp_spi_setup_transfer(struct spi_device *spi, | ||
126 | struct spi_transfer *t) | ||
127 | { | ||
128 | u8 bits_per_word; | ||
129 | u32 hz; | ||
130 | struct stmp_spi *ss = spi_master_get_devdata(spi->master); | ||
131 | u16 rate; | ||
132 | |||
133 | bits_per_word = spi->bits_per_word; | ||
134 | if (t && t->bits_per_word) | ||
135 | bits_per_word = t->bits_per_word; | ||
136 | |||
137 | /* | ||
138 | * Calculate speed: | ||
139 | * - by default, use maximum speed from ssp clk | ||
140 | * - if device overrides it, use it | ||
141 | * - if transfer specifies other speed, use transfer's one | ||
142 | */ | ||
143 | hz = 1000 * ss->speed_khz / ss->divider; | ||
144 | if (spi->max_speed_hz) | ||
145 | hz = min(hz, spi->max_speed_hz); | ||
146 | if (t && t->speed_hz) | ||
147 | hz = min(hz, t->speed_hz); | ||
148 | |||
149 | if (hz == 0) { | ||
150 | dev_err(&spi->dev, "Cannot continue with zero clock\n"); | ||
151 | return -EINVAL; | ||
152 | } | ||
153 | |||
154 | if (bits_per_word != 8) { | ||
155 | dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", | ||
156 | __func__, bits_per_word); | ||
157 | return -EINVAL; | ||
158 | } | ||
159 | |||
160 | dev_dbg(&spi->dev, "Requested clk rate = %uHz, max = %uHz/%d = %uHz\n", | ||
161 | hz, ss->speed_khz, ss->divider, | ||
162 | ss->speed_khz * 1000 / ss->divider); | ||
163 | |||
164 | if (ss->speed_khz * 1000 / ss->divider < hz) { | ||
165 | dev_err(&spi->dev, "%s, unsupported clock rate %uHz\n", | ||
166 | __func__, hz); | ||
167 | return -EINVAL; | ||
168 | } | ||
169 | |||
170 | rate = 1000 * ss->speed_khz/ss->divider/hz; | ||
171 | |||
172 | writel(BF(ss->divider, SSP_TIMING_CLOCK_DIVIDE) | | ||
173 | BF(rate - 1, SSP_TIMING_CLOCK_RATE), | ||
174 | HW_SSP_TIMING + ss->regs); | ||
175 | |||
176 | writel(BF(1 /* mode SPI */, SSP_CTRL1_SSP_MODE) | | ||
177 | BF(4 /* 8 bits */, SSP_CTRL1_WORD_LENGTH) | | ||
178 | ((spi->mode & SPI_CPOL) ? BM_SSP_CTRL1_POLARITY : 0) | | ||
179 | ((spi->mode & SPI_CPHA) ? BM_SSP_CTRL1_PHASE : 0) | | ||
180 | (pio ? 0 : BM_SSP_CTRL1_DMA_ENABLE), | ||
181 | ss->regs + HW_SSP_CTRL1); | ||
182 | |||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | static int stmp_spi_setup(struct spi_device *spi) | ||
187 | { | ||
188 | /* spi_setup() does basic checks, | ||
189 | * stmp_spi_setup_transfer() does more later | ||
190 | */ | ||
191 | if (spi->bits_per_word != 8) { | ||
192 | dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", | ||
193 | __func__, spi->bits_per_word); | ||
194 | return -EINVAL; | ||
195 | } | ||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static inline u32 stmp_spi_cs(unsigned cs) | ||
200 | { | ||
201 | return ((cs & 1) ? BM_SSP_CTRL0_WAIT_FOR_CMD : 0) | | ||
202 | ((cs & 2) ? BM_SSP_CTRL0_WAIT_FOR_IRQ : 0); | ||
203 | } | ||
204 | |||
205 | static int stmp_spi_txrx_dma(struct stmp_spi *ss, int cs, | ||
206 | unsigned char *buf, dma_addr_t dma_buf, int len, | ||
207 | int first, int last, bool write) | ||
208 | { | ||
209 | u32 c0 = 0; | ||
210 | dma_addr_t spi_buf_dma = dma_buf; | ||
211 | int status = 0; | ||
212 | enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
213 | |||
214 | c0 |= (first ? BM_SSP_CTRL0_LOCK_CS : 0); | ||
215 | c0 |= (last ? BM_SSP_CTRL0_IGNORE_CRC : 0); | ||
216 | c0 |= (write ? 0 : BM_SSP_CTRL0_READ); | ||
217 | c0 |= BM_SSP_CTRL0_DATA_XFER; | ||
218 | |||
219 | c0 |= stmp_spi_cs(cs); | ||
220 | |||
221 | c0 |= BF(len, SSP_CTRL0_XFER_COUNT); | ||
222 | |||
223 | if (!dma_buf) | ||
224 | spi_buf_dma = dma_map_single(ss->master_dev, buf, len, dir); | ||
225 | |||
226 | ss->d.command->cmd = | ||
227 | BF(len, APBH_CHn_CMD_XFER_COUNT) | | ||
228 | BF(1, APBH_CHn_CMD_CMDWORDS) | | ||
229 | BM_APBH_CHn_CMD_WAIT4ENDCMD | | ||
230 | BM_APBH_CHn_CMD_IRQONCMPLT | | ||
231 | BF(write ? BV_APBH_CHn_CMD_COMMAND__DMA_READ : | ||
232 | BV_APBH_CHn_CMD_COMMAND__DMA_WRITE, | ||
233 | APBH_CHn_CMD_COMMAND); | ||
234 | ss->d.command->pio_words[0] = c0; | ||
235 | ss->d.command->buf_ptr = spi_buf_dma; | ||
236 | |||
237 | stmp3xxx_dma_reset_channel(ss->dma); | ||
238 | stmp3xxx_dma_clear_interrupt(ss->dma); | ||
239 | stmp3xxx_dma_enable_interrupt(ss->dma); | ||
240 | init_completion(&ss->done); | ||
241 | stmp3xxx_dma_go(ss->dma, &ss->d, 1); | ||
242 | wait_for_completion(&ss->done); | ||
243 | |||
244 | if (!busy_wait(readl(ss->regs + HW_SSP_CTRL0) & BM_SSP_CTRL0_RUN)) | ||
245 | status = -ETIMEDOUT; | ||
246 | |||
247 | if (!dma_buf) | ||
248 | dma_unmap_single(ss->master_dev, spi_buf_dma, len, dir); | ||
249 | |||
250 | return status; | ||
251 | } | ||
252 | |||
253 | static inline void stmp_spi_enable(struct stmp_spi *ss) | ||
254 | { | ||
255 | stmp3xxx_setl(BM_SSP_CTRL0_LOCK_CS, ss->regs + HW_SSP_CTRL0); | ||
256 | stmp3xxx_clearl(BM_SSP_CTRL0_IGNORE_CRC, ss->regs + HW_SSP_CTRL0); | ||
257 | } | ||
258 | |||
259 | static inline void stmp_spi_disable(struct stmp_spi *ss) | ||
260 | { | ||
261 | stmp3xxx_clearl(BM_SSP_CTRL0_LOCK_CS, ss->regs + HW_SSP_CTRL0); | ||
262 | stmp3xxx_setl(BM_SSP_CTRL0_IGNORE_CRC, ss->regs + HW_SSP_CTRL0); | ||
263 | } | ||
264 | |||
265 | static int stmp_spi_txrx_pio(struct stmp_spi *ss, int cs, | ||
266 | unsigned char *buf, int len, | ||
267 | bool first, bool last, bool write) | ||
268 | { | ||
269 | if (first) | ||
270 | stmp_spi_enable(ss); | ||
271 | |||
272 | stmp3xxx_setl(stmp_spi_cs(cs), ss->regs + HW_SSP_CTRL0); | ||
273 | |||
274 | while (len--) { | ||
275 | if (last && len <= 0) | ||
276 | stmp_spi_disable(ss); | ||
277 | |||
278 | stmp3xxx_clearl(BM_SSP_CTRL0_XFER_COUNT, | ||
279 | ss->regs + HW_SSP_CTRL0); | ||
280 | stmp3xxx_setl(1, ss->regs + HW_SSP_CTRL0); | ||
281 | |||
282 | if (write) | ||
283 | stmp3xxx_clearl(BM_SSP_CTRL0_READ, | ||
284 | ss->regs + HW_SSP_CTRL0); | ||
285 | else | ||
286 | stmp3xxx_setl(BM_SSP_CTRL0_READ, | ||
287 | ss->regs + HW_SSP_CTRL0); | ||
288 | |||
289 | /* Run! */ | ||
290 | stmp3xxx_setl(BM_SSP_CTRL0_RUN, ss->regs + HW_SSP_CTRL0); | ||
291 | |||
292 | if (!busy_wait(readl(ss->regs + HW_SSP_CTRL0) & | ||
293 | BM_SSP_CTRL0_RUN)) | ||
294 | break; | ||
295 | |||
296 | if (write) | ||
297 | writel(*buf, ss->regs + HW_SSP_DATA); | ||
298 | |||
299 | /* Set TRANSFER */ | ||
300 | stmp3xxx_setl(BM_SSP_CTRL0_DATA_XFER, ss->regs + HW_SSP_CTRL0); | ||
301 | |||
302 | if (!write) { | ||
303 | if (busy_wait((readl(ss->regs + HW_SSP_STATUS) & | ||
304 | BM_SSP_STATUS_FIFO_EMPTY))) | ||
305 | break; | ||
306 | *buf = readl(ss->regs + HW_SSP_DATA) & 0xFF; | ||
307 | } | ||
308 | |||
309 | if (!busy_wait(readl(ss->regs + HW_SSP_CTRL0) & | ||
310 | BM_SSP_CTRL0_RUN)) | ||
311 | break; | ||
312 | |||
313 | /* advance to the next byte */ | ||
314 | buf++; | ||
315 | } | ||
316 | |||
317 | return len < 0 ? 0 : -ETIMEDOUT; | ||
318 | } | ||
319 | |||
320 | static int stmp_spi_handle_message(struct stmp_spi *ss, struct spi_message *m) | ||
321 | { | ||
322 | bool first, last; | ||
323 | struct spi_transfer *t, *tmp_t; | ||
324 | int status = 0; | ||
325 | int cs; | ||
326 | |||
327 | cs = m->spi->chip_select; | ||
328 | |||
329 | list_for_each_entry_safe(t, tmp_t, &m->transfers, transfer_list) { | ||
330 | |||
331 | first = (&t->transfer_list == m->transfers.next); | ||
332 | last = (&t->transfer_list == m->transfers.prev); | ||
333 | |||
334 | if (first || t->speed_hz || t->bits_per_word) | ||
335 | stmp_spi_setup_transfer(m->spi, t); | ||
336 | |||
337 | /* reject "not last" transfers which request to change cs */ | ||
338 | if (t->cs_change && !last) { | ||
339 | dev_err(&m->spi->dev, | ||
340 | "Message with t->cs_change has been skipped\n"); | ||
341 | continue; | ||
342 | } | ||
343 | |||
344 | if (t->tx_buf) { | ||
345 | status = pio ? | ||
346 | stmp_spi_txrx_pio(ss, cs, (void *)t->tx_buf, | ||
347 | t->len, first, last, true) : | ||
348 | stmp_spi_txrx_dma(ss, cs, (void *)t->tx_buf, | ||
349 | t->tx_dma, t->len, first, last, true); | ||
350 | #ifdef DEBUG | ||
351 | if (t->len < 0x10) | ||
352 | print_hex_dump_bytes("Tx ", | ||
353 | DUMP_PREFIX_OFFSET, | ||
354 | t->tx_buf, t->len); | ||
355 | else | ||
356 | pr_debug("Tx: %d bytes\n", t->len); | ||
357 | #endif | ||
358 | } | ||
359 | if (t->rx_buf) { | ||
360 | status = pio ? | ||
361 | stmp_spi_txrx_pio(ss, cs, t->rx_buf, | ||
362 | t->len, first, last, false) : | ||
363 | stmp_spi_txrx_dma(ss, cs, t->rx_buf, | ||
364 | t->rx_dma, t->len, first, last, false); | ||
365 | #ifdef DEBUG | ||
366 | if (t->len < 0x10) | ||
367 | print_hex_dump_bytes("Rx ", | ||
368 | DUMP_PREFIX_OFFSET, | ||
369 | t->rx_buf, t->len); | ||
370 | else | ||
371 | pr_debug("Rx: %d bytes\n", t->len); | ||
372 | #endif | ||
373 | } | ||
374 | |||
375 | if (t->delay_usecs) | ||
376 | udelay(t->delay_usecs); | ||
377 | |||
378 | if (status) | ||
379 | break; | ||
380 | |||
381 | } | ||
382 | return status; | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * stmp_spi_handle - handle messages from the queue | ||
387 | */ | ||
388 | static void stmp_spi_handle(struct work_struct *w) | ||
389 | { | ||
390 | struct stmp_spi *ss = container_of(w, struct stmp_spi, work); | ||
391 | unsigned long flags; | ||
392 | struct spi_message *m; | ||
393 | |||
394 | spin_lock_irqsave(&ss->lock, flags); | ||
395 | while (!list_empty(&ss->queue)) { | ||
396 | m = list_entry(ss->queue.next, struct spi_message, queue); | ||
397 | list_del_init(&m->queue); | ||
398 | spin_unlock_irqrestore(&ss->lock, flags); | ||
399 | |||
400 | m->status = stmp_spi_handle_message(ss, m); | ||
401 | m->complete(m->context); | ||
402 | |||
403 | spin_lock_irqsave(&ss->lock, flags); | ||
404 | } | ||
405 | spin_unlock_irqrestore(&ss->lock, flags); | ||
406 | |||
407 | return; | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * stmp_spi_transfer - perform message transfer. | ||
412 | * Called indirectly from spi_async, queues all the messages to | ||
413 | * spi_handle_message. | ||
414 | * @spi: spi device | ||
415 | * @m: message to be queued | ||
416 | */ | ||
417 | static int stmp_spi_transfer(struct spi_device *spi, struct spi_message *m) | ||
418 | { | ||
419 | struct stmp_spi *ss = spi_master_get_devdata(spi->master); | ||
420 | unsigned long flags; | ||
421 | |||
422 | m->status = -EINPROGRESS; | ||
423 | spin_lock_irqsave(&ss->lock, flags); | ||
424 | list_add_tail(&m->queue, &ss->queue); | ||
425 | queue_work(ss->workqueue, &ss->work); | ||
426 | spin_unlock_irqrestore(&ss->lock, flags); | ||
427 | return 0; | ||
428 | } | ||
429 | |||
430 | static irqreturn_t stmp_spi_irq(int irq, void *dev_id) | ||
431 | { | ||
432 | struct stmp_spi *ss = dev_id; | ||
433 | |||
434 | stmp3xxx_dma_clear_interrupt(ss->dma); | ||
435 | complete(&ss->done); | ||
436 | return IRQ_HANDLED; | ||
437 | } | ||
438 | |||
439 | static irqreturn_t stmp_spi_irq_err(int irq, void *dev_id) | ||
440 | { | ||
441 | struct stmp_spi *ss = dev_id; | ||
442 | u32 c1, st; | ||
443 | |||
444 | c1 = readl(ss->regs + HW_SSP_CTRL1); | ||
445 | st = readl(ss->regs + HW_SSP_STATUS); | ||
446 | dev_err(ss->master_dev, "%s: status = 0x%08X, c1 = 0x%08X\n", | ||
447 | __func__, st, c1); | ||
448 | stmp3xxx_clearl(c1 & 0xCCCC0000, ss->regs + HW_SSP_CTRL1); | ||
449 | |||
450 | return IRQ_HANDLED; | ||
451 | } | ||
452 | |||
453 | static int __devinit stmp_spi_probe(struct platform_device *dev) | ||
454 | { | ||
455 | int err = 0; | ||
456 | struct spi_master *master; | ||
457 | struct stmp_spi *ss; | ||
458 | struct resource *r; | ||
459 | |||
460 | master = spi_alloc_master(&dev->dev, sizeof(struct stmp_spi)); | ||
461 | if (master == NULL) { | ||
462 | err = -ENOMEM; | ||
463 | goto out0; | ||
464 | } | ||
465 | master->flags = SPI_MASTER_HALF_DUPLEX; | ||
466 | |||
467 | ss = spi_master_get_devdata(master); | ||
468 | platform_set_drvdata(dev, master); | ||
469 | |||
470 | /* Get resources(memory, IRQ) associated with the device */ | ||
471 | r = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
472 | if (r == NULL) { | ||
473 | err = -ENODEV; | ||
474 | goto out_put_master; | ||
475 | } | ||
476 | ss->regs = ioremap(r->start, resource_size(r)); | ||
477 | if (!ss->regs) { | ||
478 | err = -EINVAL; | ||
479 | goto out_put_master; | ||
480 | } | ||
481 | |||
482 | ss->master_dev = &dev->dev; | ||
483 | ss->id = dev->id; | ||
484 | |||
485 | INIT_WORK(&ss->work, stmp_spi_handle); | ||
486 | INIT_LIST_HEAD(&ss->queue); | ||
487 | spin_lock_init(&ss->lock); | ||
488 | |||
489 | ss->workqueue = create_singlethread_workqueue(dev_name(&dev->dev)); | ||
490 | if (!ss->workqueue) { | ||
491 | err = -ENXIO; | ||
492 | goto out_put_master; | ||
493 | } | ||
494 | master->transfer = stmp_spi_transfer; | ||
495 | master->setup = stmp_spi_setup; | ||
496 | |||
497 | /* the spi->mode bits understood by this driver: */ | ||
498 | master->mode_bits = SPI_CPOL | SPI_CPHA; | ||
499 | |||
500 | ss->irq = platform_get_irq(dev, 0); | ||
501 | if (ss->irq < 0) { | ||
502 | err = ss->irq; | ||
503 | goto out_put_master; | ||
504 | } | ||
505 | ss->err_irq = platform_get_irq(dev, 1); | ||
506 | if (ss->err_irq < 0) { | ||
507 | err = ss->err_irq; | ||
508 | goto out_put_master; | ||
509 | } | ||
510 | |||
511 | r = platform_get_resource(dev, IORESOURCE_DMA, 0); | ||
512 | if (r == NULL) { | ||
513 | err = -ENODEV; | ||
514 | goto out_put_master; | ||
515 | } | ||
516 | |||
517 | ss->dma = r->start; | ||
518 | err = stmp3xxx_dma_request(ss->dma, &dev->dev, dev_name(&dev->dev)); | ||
519 | if (err) | ||
520 | goto out_put_master; | ||
521 | |||
522 | err = stmp3xxx_dma_allocate_command(ss->dma, &ss->d); | ||
523 | if (err) | ||
524 | goto out_free_dma; | ||
525 | |||
526 | master->bus_num = dev->id; | ||
527 | master->num_chipselect = 1; | ||
528 | |||
529 | /* SPI controller initializations */ | ||
530 | err = stmp_spi_init_hw(ss); | ||
531 | if (err) { | ||
532 | dev_dbg(&dev->dev, "cannot initialize hardware\n"); | ||
533 | goto out_free_dma_desc; | ||
534 | } | ||
535 | |||
536 | if (clock) { | ||
537 | dev_info(&dev->dev, "clock rate forced to %d\n", clock); | ||
538 | clk_set_rate(ss->clk, clock); | ||
539 | } | ||
540 | ss->speed_khz = clk_get_rate(ss->clk); | ||
541 | ss->divider = 2; | ||
542 | dev_info(&dev->dev, "max possible speed %d = %ld/%d kHz\n", | ||
543 | ss->speed_khz, clk_get_rate(ss->clk), ss->divider); | ||
544 | |||
545 | /* Register for SPI interrupt */ | ||
546 | err = request_irq(ss->irq, stmp_spi_irq, 0, | ||
547 | dev_name(&dev->dev), ss); | ||
548 | if (err) { | ||
549 | dev_dbg(&dev->dev, "request_irq failed, %d\n", err); | ||
550 | goto out_release_hw; | ||
551 | } | ||
552 | |||
553 | /* ..and shared interrupt for all SSP controllers */ | ||
554 | err = request_irq(ss->err_irq, stmp_spi_irq_err, IRQF_SHARED, | ||
555 | dev_name(&dev->dev), ss); | ||
556 | if (err) { | ||
557 | dev_dbg(&dev->dev, "request_irq(error) failed, %d\n", err); | ||
558 | goto out_free_irq; | ||
559 | } | ||
560 | |||
561 | err = spi_register_master(master); | ||
562 | if (err) { | ||
563 | dev_dbg(&dev->dev, "cannot register spi master, %d\n", err); | ||
564 | goto out_free_irq_2; | ||
565 | } | ||
566 | dev_info(&dev->dev, "at (mapped) 0x%08X, irq=%d, bus %d, %s mode\n", | ||
567 | (u32)ss->regs, ss->irq, master->bus_num, | ||
568 | pio ? "PIO" : "DMA"); | ||
569 | return 0; | ||
570 | |||
571 | out_free_irq_2: | ||
572 | free_irq(ss->err_irq, ss); | ||
573 | out_free_irq: | ||
574 | free_irq(ss->irq, ss); | ||
575 | out_free_dma_desc: | ||
576 | stmp3xxx_dma_free_command(ss->dma, &ss->d); | ||
577 | out_free_dma: | ||
578 | stmp3xxx_dma_release(ss->dma); | ||
579 | out_release_hw: | ||
580 | stmp_spi_release_hw(ss); | ||
581 | out_put_master: | ||
582 | if (ss->workqueue) | ||
583 | destroy_workqueue(ss->workqueue); | ||
584 | if (ss->regs) | ||
585 | iounmap(ss->regs); | ||
586 | platform_set_drvdata(dev, NULL); | ||
587 | spi_master_put(master); | ||
588 | out0: | ||
589 | return err; | ||
590 | } | ||
591 | |||
592 | static int __devexit stmp_spi_remove(struct platform_device *dev) | ||
593 | { | ||
594 | struct stmp_spi *ss; | ||
595 | struct spi_master *master; | ||
596 | |||
597 | master = spi_master_get(platform_get_drvdata(dev)); | ||
598 | ss = spi_master_get_devdata(master); | ||
599 | |||
600 | spi_unregister_master(master); | ||
601 | |||
602 | free_irq(ss->err_irq, ss); | ||
603 | free_irq(ss->irq, ss); | ||
604 | stmp3xxx_dma_free_command(ss->dma, &ss->d); | ||
605 | stmp3xxx_dma_release(ss->dma); | ||
606 | stmp_spi_release_hw(ss); | ||
607 | destroy_workqueue(ss->workqueue); | ||
608 | iounmap(ss->regs); | ||
609 | spi_master_put(master); | ||
610 | return 0; | ||
611 | } | ||
612 | |||
613 | #ifdef CONFIG_PM | ||
614 | static int stmp_spi_suspend(struct platform_device *pdev, pm_message_t pmsg) | ||
615 | { | ||
616 | struct stmp_spi *ss; | ||
617 | struct spi_master *master; | ||
618 | |||
619 | master = platform_get_drvdata(pdev); | ||
620 | ss = spi_master_get_devdata(master); | ||
621 | |||
622 | ss->saved_timings = readl(HW_SSP_TIMING + ss->regs); | ||
623 | clk_disable(ss->clk); | ||
624 | |||
625 | return 0; | ||
626 | } | ||
627 | |||
628 | static int stmp_spi_resume(struct platform_device *pdev) | ||
629 | { | ||
630 | struct stmp_spi *ss; | ||
631 | struct spi_master *master; | ||
632 | |||
633 | master = platform_get_drvdata(pdev); | ||
634 | ss = spi_master_get_devdata(master); | ||
635 | |||
636 | clk_enable(ss->clk); | ||
637 | stmp3xxx_reset_block(ss->regs, false); | ||
638 | writel(ss->saved_timings, ss->regs + HW_SSP_TIMING); | ||
639 | |||
640 | return 0; | ||
641 | } | ||
642 | |||
643 | #else | ||
644 | #define stmp_spi_suspend NULL | ||
645 | #define stmp_spi_resume NULL | ||
646 | #endif | ||
647 | |||
648 | static struct platform_driver stmp_spi_driver = { | ||
649 | .probe = stmp_spi_probe, | ||
650 | .remove = __devexit_p(stmp_spi_remove), | ||
651 | .driver = { | ||
652 | .name = "stmp3xxx_ssp", | ||
653 | .owner = THIS_MODULE, | ||
654 | }, | ||
655 | .suspend = stmp_spi_suspend, | ||
656 | .resume = stmp_spi_resume, | ||
657 | }; | ||
658 | module_platform_driver(stmp_spi_driver); | ||
659 | |||
660 | module_param(pio, int, S_IRUGO); | ||
661 | module_param(clock, int, S_IRUGO); | ||
662 | MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com>"); | ||
663 | MODULE_DESCRIPTION("STMP3xxx SPI/SSP driver"); | ||
664 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c new file mode 100644 index 000000000000..448a8cc71df3 --- /dev/null +++ b/drivers/spi/spi-tegra20-sflash.c | |||
@@ -0,0 +1,665 @@ | |||
1 | /* | ||
2 | * SPI driver for Nvidia's Tegra20 Serial Flash Controller. | ||
3 | * | ||
4 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * Author: Laxman Dewangan <ldewangan@nvidia.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms and conditions of the GNU General Public License, | ||
10 | * version 2, as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
15 | * more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #include <linux/clk.h> | ||
22 | #include <linux/completion.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/err.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/kthread.h> | ||
30 | #include <linux/module.h> | ||
31 | #include <linux/platform_device.h> | ||
32 | #include <linux/pm_runtime.h> | ||
33 | #include <linux/of.h> | ||
34 | #include <linux/of_device.h> | ||
35 | #include <linux/spi/spi.h> | ||
36 | #include <linux/spi/spi-tegra.h> | ||
37 | #include <mach/clk.h> | ||
38 | |||
39 | #define SPI_COMMAND 0x000 | ||
40 | #define SPI_GO BIT(30) | ||
41 | #define SPI_M_S BIT(28) | ||
42 | #define SPI_ACTIVE_SCLK_MASK (0x3 << 26) | ||
43 | #define SPI_ACTIVE_SCLK_DRIVE_LOW (0 << 26) | ||
44 | #define SPI_ACTIVE_SCLK_DRIVE_HIGH (1 << 26) | ||
45 | #define SPI_ACTIVE_SCLK_PULL_LOW (2 << 26) | ||
46 | #define SPI_ACTIVE_SCLK_PULL_HIGH (3 << 26) | ||
47 | |||
48 | #define SPI_CK_SDA_FALLING (1 << 21) | ||
49 | #define SPI_CK_SDA_RISING (0 << 21) | ||
50 | #define SPI_CK_SDA_MASK (1 << 21) | ||
51 | #define SPI_ACTIVE_SDA (0x3 << 18) | ||
52 | #define SPI_ACTIVE_SDA_DRIVE_LOW (0 << 18) | ||
53 | #define SPI_ACTIVE_SDA_DRIVE_HIGH (1 << 18) | ||
54 | #define SPI_ACTIVE_SDA_PULL_LOW (2 << 18) | ||
55 | #define SPI_ACTIVE_SDA_PULL_HIGH (3 << 18) | ||
56 | |||
57 | #define SPI_CS_POL_INVERT BIT(16) | ||
58 | #define SPI_TX_EN BIT(15) | ||
59 | #define SPI_RX_EN BIT(14) | ||
60 | #define SPI_CS_VAL_HIGH BIT(13) | ||
61 | #define SPI_CS_VAL_LOW 0x0 | ||
62 | #define SPI_CS_SW BIT(12) | ||
63 | #define SPI_CS_HW 0x0 | ||
64 | #define SPI_CS_DELAY_MASK (7 << 9) | ||
65 | #define SPI_CS3_EN BIT(8) | ||
66 | #define SPI_CS2_EN BIT(7) | ||
67 | #define SPI_CS1_EN BIT(6) | ||
68 | #define SPI_CS0_EN BIT(5) | ||
69 | |||
70 | #define SPI_CS_MASK (SPI_CS3_EN | SPI_CS2_EN | \ | ||
71 | SPI_CS1_EN | SPI_CS0_EN) | ||
72 | #define SPI_BIT_LENGTH(x) (((x) & 0x1f) << 0) | ||
73 | |||
74 | #define SPI_MODES (SPI_ACTIVE_SCLK_MASK | SPI_CK_SDA_MASK) | ||
75 | |||
76 | #define SPI_STATUS 0x004 | ||
77 | #define SPI_BSY BIT(31) | ||
78 | #define SPI_RDY BIT(30) | ||
79 | #define SPI_TXF_FLUSH BIT(29) | ||
80 | #define SPI_RXF_FLUSH BIT(28) | ||
81 | #define SPI_RX_UNF BIT(27) | ||
82 | #define SPI_TX_OVF BIT(26) | ||
83 | #define SPI_RXF_EMPTY BIT(25) | ||
84 | #define SPI_RXF_FULL BIT(24) | ||
85 | #define SPI_TXF_EMPTY BIT(23) | ||
86 | #define SPI_TXF_FULL BIT(22) | ||
87 | #define SPI_BLK_CNT(count) (((count) & 0xffff) + 1) | ||
88 | |||
89 | #define SPI_FIFO_ERROR (SPI_RX_UNF | SPI_TX_OVF) | ||
90 | #define SPI_FIFO_EMPTY (SPI_TX_EMPTY | SPI_RX_EMPTY) | ||
91 | |||
92 | #define SPI_RX_CMP 0x8 | ||
93 | #define SPI_DMA_CTL 0x0C | ||
94 | #define SPI_DMA_EN BIT(31) | ||
95 | #define SPI_IE_RXC BIT(27) | ||
96 | #define SPI_IE_TXC BIT(26) | ||
97 | #define SPI_PACKED BIT(20) | ||
98 | #define SPI_RX_TRIG_MASK (0x3 << 18) | ||
99 | #define SPI_RX_TRIG_1W (0x0 << 18) | ||
100 | #define SPI_RX_TRIG_4W (0x1 << 18) | ||
101 | #define SPI_TX_TRIG_MASK (0x3 << 16) | ||
102 | #define SPI_TX_TRIG_1W (0x0 << 16) | ||
103 | #define SPI_TX_TRIG_4W (0x1 << 16) | ||
104 | #define SPI_DMA_BLK_COUNT(count) (((count) - 1) & 0xFFFF); | ||
105 | |||
106 | #define SPI_TX_FIFO 0x10 | ||
107 | #define SPI_RX_FIFO 0x20 | ||
108 | |||
109 | #define DATA_DIR_TX (1 << 0) | ||
110 | #define DATA_DIR_RX (1 << 1) | ||
111 | |||
112 | #define MAX_CHIP_SELECT 4 | ||
113 | #define SPI_FIFO_DEPTH 4 | ||
114 | #define SPI_DMA_TIMEOUT (msecs_to_jiffies(1000)) | ||
115 | |||
116 | struct tegra_sflash_data { | ||
117 | struct device *dev; | ||
118 | struct spi_master *master; | ||
119 | spinlock_t lock; | ||
120 | |||
121 | struct clk *clk; | ||
122 | void __iomem *base; | ||
123 | unsigned irq; | ||
124 | u32 spi_max_frequency; | ||
125 | u32 cur_speed; | ||
126 | |||
127 | struct spi_device *cur_spi; | ||
128 | unsigned cur_pos; | ||
129 | unsigned cur_len; | ||
130 | unsigned bytes_per_word; | ||
131 | unsigned cur_direction; | ||
132 | unsigned curr_xfer_words; | ||
133 | |||
134 | unsigned cur_rx_pos; | ||
135 | unsigned cur_tx_pos; | ||
136 | |||
137 | u32 tx_status; | ||
138 | u32 rx_status; | ||
139 | u32 status_reg; | ||
140 | |||
141 | u32 def_command_reg; | ||
142 | u32 command_reg; | ||
143 | u32 dma_control_reg; | ||
144 | |||
145 | struct completion xfer_completion; | ||
146 | struct spi_transfer *curr_xfer; | ||
147 | }; | ||
148 | |||
149 | static int tegra_sflash_runtime_suspend(struct device *dev); | ||
150 | static int tegra_sflash_runtime_resume(struct device *dev); | ||
151 | |||
152 | static inline unsigned long tegra_sflash_readl(struct tegra_sflash_data *tsd, | ||
153 | unsigned long reg) | ||
154 | { | ||
155 | return readl(tsd->base + reg); | ||
156 | } | ||
157 | |||
158 | static inline void tegra_sflash_writel(struct tegra_sflash_data *tsd, | ||
159 | unsigned long val, unsigned long reg) | ||
160 | { | ||
161 | writel(val, tsd->base + reg); | ||
162 | } | ||
163 | |||
164 | static void tegra_sflash_clear_status(struct tegra_sflash_data *tsd) | ||
165 | { | ||
166 | /* Write 1 to clear status register */ | ||
167 | tegra_sflash_writel(tsd, SPI_RDY | SPI_FIFO_ERROR, SPI_STATUS); | ||
168 | } | ||
169 | |||
170 | static unsigned tegra_sflash_calculate_curr_xfer_param( | ||
171 | struct spi_device *spi, struct tegra_sflash_data *tsd, | ||
172 | struct spi_transfer *t) | ||
173 | { | ||
174 | unsigned remain_len = t->len - tsd->cur_pos; | ||
175 | unsigned max_word; | ||
176 | |||
177 | tsd->bytes_per_word = (t->bits_per_word - 1) / 8 + 1; | ||
178 | max_word = remain_len / tsd->bytes_per_word; | ||
179 | if (max_word > SPI_FIFO_DEPTH) | ||
180 | max_word = SPI_FIFO_DEPTH; | ||
181 | tsd->curr_xfer_words = max_word; | ||
182 | return max_word; | ||
183 | } | ||
184 | |||
185 | static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf( | ||
186 | struct tegra_sflash_data *tsd, struct spi_transfer *t) | ||
187 | { | ||
188 | unsigned nbytes; | ||
189 | unsigned long status; | ||
190 | unsigned max_n_32bit = tsd->curr_xfer_words; | ||
191 | u8 *tx_buf = (u8 *)t->tx_buf + tsd->cur_tx_pos; | ||
192 | |||
193 | if (max_n_32bit > SPI_FIFO_DEPTH) | ||
194 | max_n_32bit = SPI_FIFO_DEPTH; | ||
195 | nbytes = max_n_32bit * tsd->bytes_per_word; | ||
196 | |||
197 | status = tegra_sflash_readl(tsd, SPI_STATUS); | ||
198 | while (!(status & SPI_TXF_FULL)) { | ||
199 | int i; | ||
200 | unsigned int x = 0; | ||
201 | |||
202 | for (i = 0; nbytes && (i < tsd->bytes_per_word); | ||
203 | i++, nbytes--) | ||
204 | x |= ((*tx_buf++) << i*8); | ||
205 | tegra_sflash_writel(tsd, x, SPI_TX_FIFO); | ||
206 | if (!nbytes) | ||
207 | break; | ||
208 | |||
209 | status = tegra_sflash_readl(tsd, SPI_STATUS); | ||
210 | } | ||
211 | tsd->cur_tx_pos += max_n_32bit * tsd->bytes_per_word; | ||
212 | return max_n_32bit; | ||
213 | } | ||
214 | |||
215 | static int tegra_sflash_read_rx_fifo_to_client_rxbuf( | ||
216 | struct tegra_sflash_data *tsd, struct spi_transfer *t) | ||
217 | { | ||
218 | unsigned long status; | ||
219 | unsigned int read_words = 0; | ||
220 | u8 *rx_buf = (u8 *)t->rx_buf + tsd->cur_rx_pos; | ||
221 | |||
222 | status = tegra_sflash_readl(tsd, SPI_STATUS); | ||
223 | while (!(status & SPI_RXF_EMPTY)) { | ||
224 | int i; | ||
225 | unsigned long x; | ||
226 | |||
227 | x = tegra_sflash_readl(tsd, SPI_RX_FIFO); | ||
228 | for (i = 0; (i < tsd->bytes_per_word); i++) | ||
229 | *rx_buf++ = (x >> (i*8)) & 0xFF; | ||
230 | read_words++; | ||
231 | status = tegra_sflash_readl(tsd, SPI_STATUS); | ||
232 | } | ||
233 | tsd->cur_rx_pos += read_words * tsd->bytes_per_word; | ||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | static int tegra_sflash_start_cpu_based_transfer( | ||
238 | struct tegra_sflash_data *tsd, struct spi_transfer *t) | ||
239 | { | ||
240 | unsigned long val = 0; | ||
241 | unsigned cur_words; | ||
242 | |||
243 | if (tsd->cur_direction & DATA_DIR_TX) | ||
244 | val |= SPI_IE_TXC; | ||
245 | |||
246 | if (tsd->cur_direction & DATA_DIR_RX) | ||
247 | val |= SPI_IE_RXC; | ||
248 | |||
249 | tegra_sflash_writel(tsd, val, SPI_DMA_CTL); | ||
250 | tsd->dma_control_reg = val; | ||
251 | |||
252 | if (tsd->cur_direction & DATA_DIR_TX) | ||
253 | cur_words = tegra_sflash_fill_tx_fifo_from_client_txbuf(tsd, t); | ||
254 | else | ||
255 | cur_words = tsd->curr_xfer_words; | ||
256 | val |= SPI_DMA_BLK_COUNT(cur_words); | ||
257 | tegra_sflash_writel(tsd, val, SPI_DMA_CTL); | ||
258 | tsd->dma_control_reg = val; | ||
259 | val |= SPI_DMA_EN; | ||
260 | tegra_sflash_writel(tsd, val, SPI_DMA_CTL); | ||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | static int tegra_sflash_start_transfer_one(struct spi_device *spi, | ||
265 | struct spi_transfer *t, bool is_first_of_msg, | ||
266 | bool is_single_xfer) | ||
267 | { | ||
268 | struct tegra_sflash_data *tsd = spi_master_get_devdata(spi->master); | ||
269 | u32 speed; | ||
270 | unsigned long command; | ||
271 | |||
272 | speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; | ||
273 | if (!speed) | ||
274 | speed = tsd->spi_max_frequency; | ||
275 | if (speed != tsd->cur_speed) { | ||
276 | clk_set_rate(tsd->clk, speed); | ||
277 | tsd->cur_speed = speed; | ||
278 | } | ||
279 | |||
280 | tsd->cur_spi = spi; | ||
281 | tsd->cur_pos = 0; | ||
282 | tsd->cur_rx_pos = 0; | ||
283 | tsd->cur_tx_pos = 0; | ||
284 | tsd->curr_xfer = t; | ||
285 | tegra_sflash_calculate_curr_xfer_param(spi, tsd, t); | ||
286 | if (is_first_of_msg) { | ||
287 | command = tsd->def_command_reg; | ||
288 | command |= SPI_BIT_LENGTH(t->bits_per_word - 1); | ||
289 | command |= SPI_CS_VAL_HIGH; | ||
290 | |||
291 | command &= ~SPI_MODES; | ||
292 | if (spi->mode & SPI_CPHA) | ||
293 | command |= SPI_CK_SDA_FALLING; | ||
294 | |||
295 | if (spi->mode & SPI_CPOL) | ||
296 | command |= SPI_ACTIVE_SCLK_DRIVE_HIGH; | ||
297 | else | ||
298 | command |= SPI_ACTIVE_SCLK_DRIVE_LOW; | ||
299 | command |= SPI_CS0_EN << spi->chip_select; | ||
300 | } else { | ||
301 | command = tsd->command_reg; | ||
302 | command &= ~SPI_BIT_LENGTH(~0); | ||
303 | command |= SPI_BIT_LENGTH(t->bits_per_word - 1); | ||
304 | command &= ~(SPI_RX_EN | SPI_TX_EN); | ||
305 | } | ||
306 | |||
307 | tsd->cur_direction = 0; | ||
308 | if (t->rx_buf) { | ||
309 | command |= SPI_RX_EN; | ||
310 | tsd->cur_direction |= DATA_DIR_RX; | ||
311 | } | ||
312 | if (t->tx_buf) { | ||
313 | command |= SPI_TX_EN; | ||
314 | tsd->cur_direction |= DATA_DIR_TX; | ||
315 | } | ||
316 | tegra_sflash_writel(tsd, command, SPI_COMMAND); | ||
317 | tsd->command_reg = command; | ||
318 | |||
319 | return tegra_sflash_start_cpu_based_transfer(tsd, t); | ||
320 | } | ||
321 | |||
322 | static int tegra_sflash_transfer_one_message(struct spi_master *master, | ||
323 | struct spi_message *msg) | ||
324 | { | ||
325 | bool is_first_msg = true; | ||
326 | int single_xfer; | ||
327 | struct tegra_sflash_data *tsd = spi_master_get_devdata(master); | ||
328 | struct spi_transfer *xfer; | ||
329 | struct spi_device *spi = msg->spi; | ||
330 | int ret; | ||
331 | |||
332 | ret = pm_runtime_get_sync(tsd->dev); | ||
333 | if (ret < 0) { | ||
334 | dev_err(tsd->dev, "pm_runtime_get() failed, err = %d\n", ret); | ||
335 | return ret; | ||
336 | } | ||
337 | |||
338 | msg->status = 0; | ||
339 | msg->actual_length = 0; | ||
340 | single_xfer = list_is_singular(&msg->transfers); | ||
341 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
342 | INIT_COMPLETION(tsd->xfer_completion); | ||
343 | ret = tegra_sflash_start_transfer_one(spi, xfer, | ||
344 | is_first_msg, single_xfer); | ||
345 | if (ret < 0) { | ||
346 | dev_err(tsd->dev, | ||
347 | "spi can not start transfer, err %d\n", ret); | ||
348 | goto exit; | ||
349 | } | ||
350 | is_first_msg = false; | ||
351 | ret = wait_for_completion_timeout(&tsd->xfer_completion, | ||
352 | SPI_DMA_TIMEOUT); | ||
353 | if (WARN_ON(ret == 0)) { | ||
354 | dev_err(tsd->dev, | ||
355 | "spi trasfer timeout, err %d\n", ret); | ||
356 | ret = -EIO; | ||
357 | goto exit; | ||
358 | } | ||
359 | |||
360 | if (tsd->tx_status || tsd->rx_status) { | ||
361 | dev_err(tsd->dev, "Error in Transfer\n"); | ||
362 | ret = -EIO; | ||
363 | goto exit; | ||
364 | } | ||
365 | msg->actual_length += xfer->len; | ||
366 | if (xfer->cs_change && xfer->delay_usecs) { | ||
367 | tegra_sflash_writel(tsd, tsd->def_command_reg, | ||
368 | SPI_COMMAND); | ||
369 | udelay(xfer->delay_usecs); | ||
370 | } | ||
371 | } | ||
372 | ret = 0; | ||
373 | exit: | ||
374 | tegra_sflash_writel(tsd, tsd->def_command_reg, SPI_COMMAND); | ||
375 | msg->status = ret; | ||
376 | spi_finalize_current_message(master); | ||
377 | pm_runtime_put(tsd->dev); | ||
378 | return ret; | ||
379 | } | ||
380 | |||
381 | static irqreturn_t handle_cpu_based_xfer(struct tegra_sflash_data *tsd) | ||
382 | { | ||
383 | struct spi_transfer *t = tsd->curr_xfer; | ||
384 | unsigned long flags; | ||
385 | |||
386 | spin_lock_irqsave(&tsd->lock, flags); | ||
387 | if (tsd->tx_status || tsd->rx_status || (tsd->status_reg & SPI_BSY)) { | ||
388 | dev_err(tsd->dev, | ||
389 | "CpuXfer ERROR bit set 0x%x\n", tsd->status_reg); | ||
390 | dev_err(tsd->dev, | ||
391 | "CpuXfer 0x%08x:0x%08x\n", tsd->command_reg, | ||
392 | tsd->dma_control_reg); | ||
393 | tegra_periph_reset_assert(tsd->clk); | ||
394 | udelay(2); | ||
395 | tegra_periph_reset_deassert(tsd->clk); | ||
396 | complete(&tsd->xfer_completion); | ||
397 | goto exit; | ||
398 | } | ||
399 | |||
400 | if (tsd->cur_direction & DATA_DIR_RX) | ||
401 | tegra_sflash_read_rx_fifo_to_client_rxbuf(tsd, t); | ||
402 | |||
403 | if (tsd->cur_direction & DATA_DIR_TX) | ||
404 | tsd->cur_pos = tsd->cur_tx_pos; | ||
405 | else | ||
406 | tsd->cur_pos = tsd->cur_rx_pos; | ||
407 | |||
408 | if (tsd->cur_pos == t->len) { | ||
409 | complete(&tsd->xfer_completion); | ||
410 | goto exit; | ||
411 | } | ||
412 | |||
413 | tegra_sflash_calculate_curr_xfer_param(tsd->cur_spi, tsd, t); | ||
414 | tegra_sflash_start_cpu_based_transfer(tsd, t); | ||
415 | exit: | ||
416 | spin_unlock_irqrestore(&tsd->lock, flags); | ||
417 | return IRQ_HANDLED; | ||
418 | } | ||
419 | |||
420 | static irqreturn_t tegra_sflash_isr(int irq, void *context_data) | ||
421 | { | ||
422 | struct tegra_sflash_data *tsd = context_data; | ||
423 | |||
424 | tsd->status_reg = tegra_sflash_readl(tsd, SPI_STATUS); | ||
425 | if (tsd->cur_direction & DATA_DIR_TX) | ||
426 | tsd->tx_status = tsd->status_reg & SPI_TX_OVF; | ||
427 | |||
428 | if (tsd->cur_direction & DATA_DIR_RX) | ||
429 | tsd->rx_status = tsd->status_reg & SPI_RX_UNF; | ||
430 | tegra_sflash_clear_status(tsd); | ||
431 | |||
432 | return handle_cpu_based_xfer(tsd); | ||
433 | } | ||
434 | |||
435 | static struct tegra_spi_platform_data *tegra_sflash_parse_dt( | ||
436 | struct platform_device *pdev) | ||
437 | { | ||
438 | struct tegra_spi_platform_data *pdata; | ||
439 | struct device_node *np = pdev->dev.of_node; | ||
440 | u32 max_freq; | ||
441 | |||
442 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
443 | if (!pdata) { | ||
444 | dev_err(&pdev->dev, "Memory alloc for pdata failed\n"); | ||
445 | return NULL; | ||
446 | } | ||
447 | |||
448 | if (!of_property_read_u32(np, "spi-max-frequency", &max_freq)) | ||
449 | pdata->spi_max_frequency = max_freq; | ||
450 | |||
451 | return pdata; | ||
452 | } | ||
453 | |||
454 | static struct of_device_id tegra_sflash_of_match[] = { | ||
455 | { .compatible = "nvidia,tegra20-sflash", }, | ||
456 | {} | ||
457 | }; | ||
458 | MODULE_DEVICE_TABLE(of, tegra_sflash_of_match); | ||
459 | |||
460 | static int tegra_sflash_probe(struct platform_device *pdev) | ||
461 | { | ||
462 | struct spi_master *master; | ||
463 | struct tegra_sflash_data *tsd; | ||
464 | struct resource *r; | ||
465 | struct tegra_spi_platform_data *pdata = pdev->dev.platform_data; | ||
466 | int ret; | ||
467 | const struct of_device_id *match; | ||
468 | |||
469 | match = of_match_device(of_match_ptr(tegra_sflash_of_match), | ||
470 | &pdev->dev); | ||
471 | if (!match) { | ||
472 | dev_err(&pdev->dev, "Error: No device match found\n"); | ||
473 | return -ENODEV; | ||
474 | } | ||
475 | |||
476 | if (!pdata && pdev->dev.of_node) | ||
477 | pdata = tegra_sflash_parse_dt(pdev); | ||
478 | |||
479 | if (!pdata) { | ||
480 | dev_err(&pdev->dev, "No platform data, exiting\n"); | ||
481 | return -ENODEV; | ||
482 | } | ||
483 | |||
484 | if (!pdata->spi_max_frequency) | ||
485 | pdata->spi_max_frequency = 25000000; /* 25MHz */ | ||
486 | |||
487 | master = spi_alloc_master(&pdev->dev, sizeof(*tsd)); | ||
488 | if (!master) { | ||
489 | dev_err(&pdev->dev, "master allocation failed\n"); | ||
490 | return -ENOMEM; | ||
491 | } | ||
492 | |||
493 | /* the spi->mode bits understood by this driver: */ | ||
494 | master->mode_bits = SPI_CPOL | SPI_CPHA; | ||
495 | master->transfer_one_message = tegra_sflash_transfer_one_message; | ||
496 | master->num_chipselect = MAX_CHIP_SELECT; | ||
497 | master->bus_num = -1; | ||
498 | |||
499 | dev_set_drvdata(&pdev->dev, master); | ||
500 | tsd = spi_master_get_devdata(master); | ||
501 | tsd->master = master; | ||
502 | tsd->dev = &pdev->dev; | ||
503 | spin_lock_init(&tsd->lock); | ||
504 | |||
505 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
506 | if (!r) { | ||
507 | dev_err(&pdev->dev, "No IO memory resource\n"); | ||
508 | ret = -ENODEV; | ||
509 | goto exit_free_master; | ||
510 | } | ||
511 | tsd->base = devm_request_and_ioremap(&pdev->dev, r); | ||
512 | if (!tsd->base) { | ||
513 | dev_err(&pdev->dev, | ||
514 | "Cannot request memregion/iomap dma address\n"); | ||
515 | ret = -EADDRNOTAVAIL; | ||
516 | goto exit_free_master; | ||
517 | } | ||
518 | |||
519 | tsd->irq = platform_get_irq(pdev, 0); | ||
520 | ret = request_irq(tsd->irq, tegra_sflash_isr, 0, | ||
521 | dev_name(&pdev->dev), tsd); | ||
522 | if (ret < 0) { | ||
523 | dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n", | ||
524 | tsd->irq); | ||
525 | goto exit_free_master; | ||
526 | } | ||
527 | |||
528 | tsd->clk = devm_clk_get(&pdev->dev, "spi"); | ||
529 | if (IS_ERR(tsd->clk)) { | ||
530 | dev_err(&pdev->dev, "can not get clock\n"); | ||
531 | ret = PTR_ERR(tsd->clk); | ||
532 | goto exit_free_irq; | ||
533 | } | ||
534 | |||
535 | tsd->spi_max_frequency = pdata->spi_max_frequency; | ||
536 | init_completion(&tsd->xfer_completion); | ||
537 | pm_runtime_enable(&pdev->dev); | ||
538 | if (!pm_runtime_enabled(&pdev->dev)) { | ||
539 | ret = tegra_sflash_runtime_resume(&pdev->dev); | ||
540 | if (ret) | ||
541 | goto exit_pm_disable; | ||
542 | } | ||
543 | |||
544 | ret = pm_runtime_get_sync(&pdev->dev); | ||
545 | if (ret < 0) { | ||
546 | dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret); | ||
547 | goto exit_pm_disable; | ||
548 | } | ||
549 | |||
550 | /* Reset controller */ | ||
551 | tegra_periph_reset_assert(tsd->clk); | ||
552 | udelay(2); | ||
553 | tegra_periph_reset_deassert(tsd->clk); | ||
554 | |||
555 | tsd->def_command_reg = SPI_M_S | SPI_CS_SW; | ||
556 | tegra_sflash_writel(tsd, tsd->def_command_reg, SPI_COMMAND); | ||
557 | pm_runtime_put(&pdev->dev); | ||
558 | |||
559 | master->dev.of_node = pdev->dev.of_node; | ||
560 | ret = spi_register_master(master); | ||
561 | if (ret < 0) { | ||
562 | dev_err(&pdev->dev, "can not register to master err %d\n", ret); | ||
563 | goto exit_pm_disable; | ||
564 | } | ||
565 | return ret; | ||
566 | |||
567 | exit_pm_disable: | ||
568 | pm_runtime_disable(&pdev->dev); | ||
569 | if (!pm_runtime_status_suspended(&pdev->dev)) | ||
570 | tegra_sflash_runtime_suspend(&pdev->dev); | ||
571 | exit_free_irq: | ||
572 | free_irq(tsd->irq, tsd); | ||
573 | exit_free_master: | ||
574 | spi_master_put(master); | ||
575 | return ret; | ||
576 | } | ||
577 | |||
578 | static int tegra_sflash_remove(struct platform_device *pdev) | ||
579 | { | ||
580 | struct spi_master *master = dev_get_drvdata(&pdev->dev); | ||
581 | struct tegra_sflash_data *tsd = spi_master_get_devdata(master); | ||
582 | |||
583 | free_irq(tsd->irq, tsd); | ||
584 | spi_unregister_master(master); | ||
585 | |||
586 | pm_runtime_disable(&pdev->dev); | ||
587 | if (!pm_runtime_status_suspended(&pdev->dev)) | ||
588 | tegra_sflash_runtime_suspend(&pdev->dev); | ||
589 | |||
590 | return 0; | ||
591 | } | ||
592 | |||
593 | #ifdef CONFIG_PM_SLEEP | ||
594 | static int tegra_sflash_suspend(struct device *dev) | ||
595 | { | ||
596 | struct spi_master *master = dev_get_drvdata(dev); | ||
597 | |||
598 | return spi_master_suspend(master); | ||
599 | } | ||
600 | |||
601 | static int tegra_sflash_resume(struct device *dev) | ||
602 | { | ||
603 | struct spi_master *master = dev_get_drvdata(dev); | ||
604 | struct tegra_sflash_data *tsd = spi_master_get_devdata(master); | ||
605 | int ret; | ||
606 | |||
607 | ret = pm_runtime_get_sync(dev); | ||
608 | if (ret < 0) { | ||
609 | dev_err(dev, "pm runtime failed, e = %d\n", ret); | ||
610 | return ret; | ||
611 | } | ||
612 | tegra_sflash_writel(tsd, tsd->command_reg, SPI_COMMAND); | ||
613 | pm_runtime_put(dev); | ||
614 | |||
615 | return spi_master_resume(master); | ||
616 | } | ||
617 | #endif | ||
618 | |||
619 | static int tegra_sflash_runtime_suspend(struct device *dev) | ||
620 | { | ||
621 | struct spi_master *master = dev_get_drvdata(dev); | ||
622 | struct tegra_sflash_data *tsd = spi_master_get_devdata(master); | ||
623 | |||
624 | /* Flush all write which are in PPSB queue by reading back */ | ||
625 | tegra_sflash_readl(tsd, SPI_COMMAND); | ||
626 | |||
627 | clk_disable_unprepare(tsd->clk); | ||
628 | return 0; | ||
629 | } | ||
630 | |||
631 | static int tegra_sflash_runtime_resume(struct device *dev) | ||
632 | { | ||
633 | struct spi_master *master = dev_get_drvdata(dev); | ||
634 | struct tegra_sflash_data *tsd = spi_master_get_devdata(master); | ||
635 | int ret; | ||
636 | |||
637 | ret = clk_prepare_enable(tsd->clk); | ||
638 | if (ret < 0) { | ||
639 | dev_err(tsd->dev, "clk_prepare failed: %d\n", ret); | ||
640 | return ret; | ||
641 | } | ||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | static const struct dev_pm_ops slink_pm_ops = { | ||
646 | SET_RUNTIME_PM_OPS(tegra_sflash_runtime_suspend, | ||
647 | tegra_sflash_runtime_resume, NULL) | ||
648 | SET_SYSTEM_SLEEP_PM_OPS(tegra_sflash_suspend, tegra_sflash_resume) | ||
649 | }; | ||
650 | static struct platform_driver tegra_sflash_driver = { | ||
651 | .driver = { | ||
652 | .name = "spi-tegra-sflash", | ||
653 | .owner = THIS_MODULE, | ||
654 | .pm = &slink_pm_ops, | ||
655 | .of_match_table = of_match_ptr(tegra_sflash_of_match), | ||
656 | }, | ||
657 | .probe = tegra_sflash_probe, | ||
658 | .remove = tegra_sflash_remove, | ||
659 | }; | ||
660 | module_platform_driver(tegra_sflash_driver); | ||
661 | |||
662 | MODULE_ALIAS("platform:spi-tegra-sflash"); | ||
663 | MODULE_DESCRIPTION("NVIDIA Tegra20 Serial Flash Controller Driver"); | ||
664 | MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); | ||
665 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c new file mode 100644 index 000000000000..651167f2e0af --- /dev/null +++ b/drivers/spi/spi-tegra20-slink.c | |||
@@ -0,0 +1,1358 @@ | |||
1 | /* | ||
2 | * SPI driver for Nvidia's Tegra20/Tegra30 SLINK Controller. | ||
3 | * | ||
4 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
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, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <linux/clk.h> | ||
20 | #include <linux/completion.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/dmaengine.h> | ||
23 | #include <linux/dma-mapping.h> | ||
24 | #include <linux/dmapool.h> | ||
25 | #include <linux/err.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/io.h> | ||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/kthread.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/platform_device.h> | ||
33 | #include <linux/pm_runtime.h> | ||
34 | #include <linux/of.h> | ||
35 | #include <linux/of_device.h> | ||
36 | #include <linux/spi/spi.h> | ||
37 | #include <linux/spi/spi-tegra.h> | ||
38 | #include <mach/clk.h> | ||
39 | |||
40 | #define SLINK_COMMAND 0x000 | ||
41 | #define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0) | ||
42 | #define SLINK_WORD_SIZE(x) (((x) & 0x1f) << 5) | ||
43 | #define SLINK_BOTH_EN (1 << 10) | ||
44 | #define SLINK_CS_SW (1 << 11) | ||
45 | #define SLINK_CS_VALUE (1 << 12) | ||
46 | #define SLINK_CS_POLARITY (1 << 13) | ||
47 | #define SLINK_IDLE_SDA_DRIVE_LOW (0 << 16) | ||
48 | #define SLINK_IDLE_SDA_DRIVE_HIGH (1 << 16) | ||
49 | #define SLINK_IDLE_SDA_PULL_LOW (2 << 16) | ||
50 | #define SLINK_IDLE_SDA_PULL_HIGH (3 << 16) | ||
51 | #define SLINK_IDLE_SDA_MASK (3 << 16) | ||
52 | #define SLINK_CS_POLARITY1 (1 << 20) | ||
53 | #define SLINK_CK_SDA (1 << 21) | ||
54 | #define SLINK_CS_POLARITY2 (1 << 22) | ||
55 | #define SLINK_CS_POLARITY3 (1 << 23) | ||
56 | #define SLINK_IDLE_SCLK_DRIVE_LOW (0 << 24) | ||
57 | #define SLINK_IDLE_SCLK_DRIVE_HIGH (1 << 24) | ||
58 | #define SLINK_IDLE_SCLK_PULL_LOW (2 << 24) | ||
59 | #define SLINK_IDLE_SCLK_PULL_HIGH (3 << 24) | ||
60 | #define SLINK_IDLE_SCLK_MASK (3 << 24) | ||
61 | #define SLINK_M_S (1 << 28) | ||
62 | #define SLINK_WAIT (1 << 29) | ||
63 | #define SLINK_GO (1 << 30) | ||
64 | #define SLINK_ENB (1 << 31) | ||
65 | |||
66 | #define SLINK_MODES (SLINK_IDLE_SCLK_MASK | SLINK_CK_SDA) | ||
67 | |||
68 | #define SLINK_COMMAND2 0x004 | ||
69 | #define SLINK_LSBFE (1 << 0) | ||
70 | #define SLINK_SSOE (1 << 1) | ||
71 | #define SLINK_SPIE (1 << 4) | ||
72 | #define SLINK_BIDIROE (1 << 6) | ||
73 | #define SLINK_MODFEN (1 << 7) | ||
74 | #define SLINK_INT_SIZE(x) (((x) & 0x1f) << 8) | ||
75 | #define SLINK_CS_ACTIVE_BETWEEN (1 << 17) | ||
76 | #define SLINK_SS_EN_CS(x) (((x) & 0x3) << 18) | ||
77 | #define SLINK_SS_SETUP(x) (((x) & 0x3) << 20) | ||
78 | #define SLINK_FIFO_REFILLS_0 (0 << 22) | ||
79 | #define SLINK_FIFO_REFILLS_1 (1 << 22) | ||
80 | #define SLINK_FIFO_REFILLS_2 (2 << 22) | ||
81 | #define SLINK_FIFO_REFILLS_3 (3 << 22) | ||
82 | #define SLINK_FIFO_REFILLS_MASK (3 << 22) | ||
83 | #define SLINK_WAIT_PACK_INT(x) (((x) & 0x7) << 26) | ||
84 | #define SLINK_SPC0 (1 << 29) | ||
85 | #define SLINK_TXEN (1 << 30) | ||
86 | #define SLINK_RXEN (1 << 31) | ||
87 | |||
88 | #define SLINK_STATUS 0x008 | ||
89 | #define SLINK_COUNT(val) (((val) >> 0) & 0x1f) | ||
90 | #define SLINK_WORD(val) (((val) >> 5) & 0x1f) | ||
91 | #define SLINK_BLK_CNT(val) (((val) >> 0) & 0xffff) | ||
92 | #define SLINK_MODF (1 << 16) | ||
93 | #define SLINK_RX_UNF (1 << 18) | ||
94 | #define SLINK_TX_OVF (1 << 19) | ||
95 | #define SLINK_TX_FULL (1 << 20) | ||
96 | #define SLINK_TX_EMPTY (1 << 21) | ||
97 | #define SLINK_RX_FULL (1 << 22) | ||
98 | #define SLINK_RX_EMPTY (1 << 23) | ||
99 | #define SLINK_TX_UNF (1 << 24) | ||
100 | #define SLINK_RX_OVF (1 << 25) | ||
101 | #define SLINK_TX_FLUSH (1 << 26) | ||
102 | #define SLINK_RX_FLUSH (1 << 27) | ||
103 | #define SLINK_SCLK (1 << 28) | ||
104 | #define SLINK_ERR (1 << 29) | ||
105 | #define SLINK_RDY (1 << 30) | ||
106 | #define SLINK_BSY (1 << 31) | ||
107 | #define SLINK_FIFO_ERROR (SLINK_TX_OVF | SLINK_RX_UNF | \ | ||
108 | SLINK_TX_UNF | SLINK_RX_OVF) | ||
109 | |||
110 | #define SLINK_FIFO_EMPTY (SLINK_TX_EMPTY | SLINK_RX_EMPTY) | ||
111 | |||
112 | #define SLINK_MAS_DATA 0x010 | ||
113 | #define SLINK_SLAVE_DATA 0x014 | ||
114 | |||
115 | #define SLINK_DMA_CTL 0x018 | ||
116 | #define SLINK_DMA_BLOCK_SIZE(x) (((x) & 0xffff) << 0) | ||
117 | #define SLINK_TX_TRIG_1 (0 << 16) | ||
118 | #define SLINK_TX_TRIG_4 (1 << 16) | ||
119 | #define SLINK_TX_TRIG_8 (2 << 16) | ||
120 | #define SLINK_TX_TRIG_16 (3 << 16) | ||
121 | #define SLINK_TX_TRIG_MASK (3 << 16) | ||
122 | #define SLINK_RX_TRIG_1 (0 << 18) | ||
123 | #define SLINK_RX_TRIG_4 (1 << 18) | ||
124 | #define SLINK_RX_TRIG_8 (2 << 18) | ||
125 | #define SLINK_RX_TRIG_16 (3 << 18) | ||
126 | #define SLINK_RX_TRIG_MASK (3 << 18) | ||
127 | #define SLINK_PACKED (1 << 20) | ||
128 | #define SLINK_PACK_SIZE_4 (0 << 21) | ||
129 | #define SLINK_PACK_SIZE_8 (1 << 21) | ||
130 | #define SLINK_PACK_SIZE_16 (2 << 21) | ||
131 | #define SLINK_PACK_SIZE_32 (3 << 21) | ||
132 | #define SLINK_PACK_SIZE_MASK (3 << 21) | ||
133 | #define SLINK_IE_TXC (1 << 26) | ||
134 | #define SLINK_IE_RXC (1 << 27) | ||
135 | #define SLINK_DMA_EN (1 << 31) | ||
136 | |||
137 | #define SLINK_STATUS2 0x01c | ||
138 | #define SLINK_TX_FIFO_EMPTY_COUNT(val) (((val) & 0x3f) >> 0) | ||
139 | #define SLINK_RX_FIFO_FULL_COUNT(val) (((val) & 0x3f0000) >> 16) | ||
140 | #define SLINK_SS_HOLD_TIME(val) (((val) & 0xF) << 6) | ||
141 | |||
142 | #define SLINK_TX_FIFO 0x100 | ||
143 | #define SLINK_RX_FIFO 0x180 | ||
144 | |||
145 | #define DATA_DIR_TX (1 << 0) | ||
146 | #define DATA_DIR_RX (1 << 1) | ||
147 | |||
148 | #define SLINK_DMA_TIMEOUT (msecs_to_jiffies(1000)) | ||
149 | |||
150 | #define DEFAULT_SPI_DMA_BUF_LEN (16*1024) | ||
151 | #define TX_FIFO_EMPTY_COUNT_MAX SLINK_TX_FIFO_EMPTY_COUNT(0x20) | ||
152 | #define RX_FIFO_FULL_COUNT_ZERO SLINK_RX_FIFO_FULL_COUNT(0) | ||
153 | |||
154 | #define SLINK_STATUS2_RESET \ | ||
155 | (TX_FIFO_EMPTY_COUNT_MAX | RX_FIFO_FULL_COUNT_ZERO << 16) | ||
156 | |||
157 | #define MAX_CHIP_SELECT 4 | ||
158 | #define SLINK_FIFO_DEPTH 32 | ||
159 | |||
160 | struct tegra_slink_chip_data { | ||
161 | bool cs_hold_time; | ||
162 | }; | ||
163 | |||
164 | struct tegra_slink_data { | ||
165 | struct device *dev; | ||
166 | struct spi_master *master; | ||
167 | const struct tegra_slink_chip_data *chip_data; | ||
168 | spinlock_t lock; | ||
169 | |||
170 | struct clk *clk; | ||
171 | void __iomem *base; | ||
172 | phys_addr_t phys; | ||
173 | unsigned irq; | ||
174 | int dma_req_sel; | ||
175 | u32 spi_max_frequency; | ||
176 | u32 cur_speed; | ||
177 | |||
178 | struct spi_device *cur_spi; | ||
179 | unsigned cur_pos; | ||
180 | unsigned cur_len; | ||
181 | unsigned words_per_32bit; | ||
182 | unsigned bytes_per_word; | ||
183 | unsigned curr_dma_words; | ||
184 | unsigned cur_direction; | ||
185 | |||
186 | unsigned cur_rx_pos; | ||
187 | unsigned cur_tx_pos; | ||
188 | |||
189 | unsigned dma_buf_size; | ||
190 | unsigned max_buf_size; | ||
191 | bool is_curr_dma_xfer; | ||
192 | bool is_hw_based_cs; | ||
193 | |||
194 | struct completion rx_dma_complete; | ||
195 | struct completion tx_dma_complete; | ||
196 | |||
197 | u32 tx_status; | ||
198 | u32 rx_status; | ||
199 | u32 status_reg; | ||
200 | bool is_packed; | ||
201 | unsigned long packed_size; | ||
202 | |||
203 | u32 command_reg; | ||
204 | u32 command2_reg; | ||
205 | u32 dma_control_reg; | ||
206 | u32 def_command_reg; | ||
207 | u32 def_command2_reg; | ||
208 | |||
209 | struct completion xfer_completion; | ||
210 | struct spi_transfer *curr_xfer; | ||
211 | struct dma_chan *rx_dma_chan; | ||
212 | u32 *rx_dma_buf; | ||
213 | dma_addr_t rx_dma_phys; | ||
214 | struct dma_async_tx_descriptor *rx_dma_desc; | ||
215 | |||
216 | struct dma_chan *tx_dma_chan; | ||
217 | u32 *tx_dma_buf; | ||
218 | dma_addr_t tx_dma_phys; | ||
219 | struct dma_async_tx_descriptor *tx_dma_desc; | ||
220 | }; | ||
221 | |||
222 | static int tegra_slink_runtime_suspend(struct device *dev); | ||
223 | static int tegra_slink_runtime_resume(struct device *dev); | ||
224 | |||
225 | static inline unsigned long tegra_slink_readl(struct tegra_slink_data *tspi, | ||
226 | unsigned long reg) | ||
227 | { | ||
228 | return readl(tspi->base + reg); | ||
229 | } | ||
230 | |||
231 | static inline void tegra_slink_writel(struct tegra_slink_data *tspi, | ||
232 | unsigned long val, unsigned long reg) | ||
233 | { | ||
234 | writel(val, tspi->base + reg); | ||
235 | |||
236 | /* Read back register to make sure that register writes completed */ | ||
237 | if (reg != SLINK_TX_FIFO) | ||
238 | readl(tspi->base + SLINK_MAS_DATA); | ||
239 | } | ||
240 | |||
241 | static void tegra_slink_clear_status(struct tegra_slink_data *tspi) | ||
242 | { | ||
243 | unsigned long val; | ||
244 | unsigned long val_write = 0; | ||
245 | |||
246 | val = tegra_slink_readl(tspi, SLINK_STATUS); | ||
247 | |||
248 | /* Write 1 to clear status register */ | ||
249 | val_write = SLINK_RDY | SLINK_FIFO_ERROR; | ||
250 | tegra_slink_writel(tspi, val_write, SLINK_STATUS); | ||
251 | } | ||
252 | |||
253 | static unsigned long tegra_slink_get_packed_size(struct tegra_slink_data *tspi, | ||
254 | struct spi_transfer *t) | ||
255 | { | ||
256 | unsigned long val; | ||
257 | |||
258 | switch (tspi->bytes_per_word) { | ||
259 | case 0: | ||
260 | val = SLINK_PACK_SIZE_4; | ||
261 | break; | ||
262 | case 1: | ||
263 | val = SLINK_PACK_SIZE_8; | ||
264 | break; | ||
265 | case 2: | ||
266 | val = SLINK_PACK_SIZE_16; | ||
267 | break; | ||
268 | case 4: | ||
269 | val = SLINK_PACK_SIZE_32; | ||
270 | break; | ||
271 | default: | ||
272 | val = 0; | ||
273 | } | ||
274 | return val; | ||
275 | } | ||
276 | |||
277 | static unsigned tegra_slink_calculate_curr_xfer_param( | ||
278 | struct spi_device *spi, struct tegra_slink_data *tspi, | ||
279 | struct spi_transfer *t) | ||
280 | { | ||
281 | unsigned remain_len = t->len - tspi->cur_pos; | ||
282 | unsigned max_word; | ||
283 | unsigned bits_per_word ; | ||
284 | unsigned max_len; | ||
285 | unsigned total_fifo_words; | ||
286 | |||
287 | bits_per_word = t->bits_per_word ? t->bits_per_word : | ||
288 | spi->bits_per_word; | ||
289 | tspi->bytes_per_word = (bits_per_word - 1) / 8 + 1; | ||
290 | |||
291 | if (bits_per_word == 8 || bits_per_word == 16) { | ||
292 | tspi->is_packed = 1; | ||
293 | tspi->words_per_32bit = 32/bits_per_word; | ||
294 | } else { | ||
295 | tspi->is_packed = 0; | ||
296 | tspi->words_per_32bit = 1; | ||
297 | } | ||
298 | tspi->packed_size = tegra_slink_get_packed_size(tspi, t); | ||
299 | |||
300 | if (tspi->is_packed) { | ||
301 | max_len = min(remain_len, tspi->max_buf_size); | ||
302 | tspi->curr_dma_words = max_len/tspi->bytes_per_word; | ||
303 | total_fifo_words = max_len/4; | ||
304 | } else { | ||
305 | max_word = (remain_len - 1) / tspi->bytes_per_word + 1; | ||
306 | max_word = min(max_word, tspi->max_buf_size/4); | ||
307 | tspi->curr_dma_words = max_word; | ||
308 | total_fifo_words = max_word; | ||
309 | } | ||
310 | return total_fifo_words; | ||
311 | } | ||
312 | |||
313 | static unsigned tegra_slink_fill_tx_fifo_from_client_txbuf( | ||
314 | struct tegra_slink_data *tspi, struct spi_transfer *t) | ||
315 | { | ||
316 | unsigned nbytes; | ||
317 | unsigned tx_empty_count; | ||
318 | unsigned long fifo_status; | ||
319 | unsigned max_n_32bit; | ||
320 | unsigned i, count; | ||
321 | unsigned long x; | ||
322 | unsigned int written_words; | ||
323 | unsigned fifo_words_left; | ||
324 | u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; | ||
325 | |||
326 | fifo_status = tegra_slink_readl(tspi, SLINK_STATUS2); | ||
327 | tx_empty_count = SLINK_TX_FIFO_EMPTY_COUNT(fifo_status); | ||
328 | |||
329 | if (tspi->is_packed) { | ||
330 | fifo_words_left = tx_empty_count * tspi->words_per_32bit; | ||
331 | written_words = min(fifo_words_left, tspi->curr_dma_words); | ||
332 | nbytes = written_words * tspi->bytes_per_word; | ||
333 | max_n_32bit = DIV_ROUND_UP(nbytes, 4); | ||
334 | for (count = 0; count < max_n_32bit; count++) { | ||
335 | x = 0; | ||
336 | for (i = 0; (i < 4) && nbytes; i++, nbytes--) | ||
337 | x |= (*tx_buf++) << (i*8); | ||
338 | tegra_slink_writel(tspi, x, SLINK_TX_FIFO); | ||
339 | } | ||
340 | } else { | ||
341 | max_n_32bit = min(tspi->curr_dma_words, tx_empty_count); | ||
342 | written_words = max_n_32bit; | ||
343 | nbytes = written_words * tspi->bytes_per_word; | ||
344 | for (count = 0; count < max_n_32bit; count++) { | ||
345 | x = 0; | ||
346 | for (i = 0; nbytes && (i < tspi->bytes_per_word); | ||
347 | i++, nbytes--) | ||
348 | x |= ((*tx_buf++) << i*8); | ||
349 | tegra_slink_writel(tspi, x, SLINK_TX_FIFO); | ||
350 | } | ||
351 | } | ||
352 | tspi->cur_tx_pos += written_words * tspi->bytes_per_word; | ||
353 | return written_words; | ||
354 | } | ||
355 | |||
356 | static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf( | ||
357 | struct tegra_slink_data *tspi, struct spi_transfer *t) | ||
358 | { | ||
359 | unsigned rx_full_count; | ||
360 | unsigned long fifo_status; | ||
361 | unsigned i, count; | ||
362 | unsigned long x; | ||
363 | unsigned int read_words = 0; | ||
364 | unsigned len; | ||
365 | u8 *rx_buf = (u8 *)t->rx_buf + tspi->cur_rx_pos; | ||
366 | |||
367 | fifo_status = tegra_slink_readl(tspi, SLINK_STATUS2); | ||
368 | rx_full_count = SLINK_RX_FIFO_FULL_COUNT(fifo_status); | ||
369 | if (tspi->is_packed) { | ||
370 | len = tspi->curr_dma_words * tspi->bytes_per_word; | ||
371 | for (count = 0; count < rx_full_count; count++) { | ||
372 | x = tegra_slink_readl(tspi, SLINK_RX_FIFO); | ||
373 | for (i = 0; len && (i < 4); i++, len--) | ||
374 | *rx_buf++ = (x >> i*8) & 0xFF; | ||
375 | } | ||
376 | tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; | ||
377 | read_words += tspi->curr_dma_words; | ||
378 | } else { | ||
379 | unsigned int bits_per_word; | ||
380 | |||
381 | bits_per_word = t->bits_per_word ? t->bits_per_word : | ||
382 | tspi->cur_spi->bits_per_word; | ||
383 | for (count = 0; count < rx_full_count; count++) { | ||
384 | x = tegra_slink_readl(tspi, SLINK_RX_FIFO); | ||
385 | for (i = 0; (i < tspi->bytes_per_word); i++) | ||
386 | *rx_buf++ = (x >> (i*8)) & 0xFF; | ||
387 | } | ||
388 | tspi->cur_rx_pos += rx_full_count * tspi->bytes_per_word; | ||
389 | read_words += rx_full_count; | ||
390 | } | ||
391 | return read_words; | ||
392 | } | ||
393 | |||
394 | static void tegra_slink_copy_client_txbuf_to_spi_txbuf( | ||
395 | struct tegra_slink_data *tspi, struct spi_transfer *t) | ||
396 | { | ||
397 | unsigned len; | ||
398 | |||
399 | /* Make the dma buffer to read by cpu */ | ||
400 | dma_sync_single_for_cpu(tspi->dev, tspi->tx_dma_phys, | ||
401 | tspi->dma_buf_size, DMA_TO_DEVICE); | ||
402 | |||
403 | if (tspi->is_packed) { | ||
404 | len = tspi->curr_dma_words * tspi->bytes_per_word; | ||
405 | memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len); | ||
406 | } else { | ||
407 | unsigned int i; | ||
408 | unsigned int count; | ||
409 | u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; | ||
410 | unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word; | ||
411 | unsigned int x; | ||
412 | |||
413 | for (count = 0; count < tspi->curr_dma_words; count++) { | ||
414 | x = 0; | ||
415 | for (i = 0; consume && (i < tspi->bytes_per_word); | ||
416 | i++, consume--) | ||
417 | x |= ((*tx_buf++) << i * 8); | ||
418 | tspi->tx_dma_buf[count] = x; | ||
419 | } | ||
420 | } | ||
421 | tspi->cur_tx_pos += tspi->curr_dma_words * tspi->bytes_per_word; | ||
422 | |||
423 | /* Make the dma buffer to read by dma */ | ||
424 | dma_sync_single_for_device(tspi->dev, tspi->tx_dma_phys, | ||
425 | tspi->dma_buf_size, DMA_TO_DEVICE); | ||
426 | } | ||
427 | |||
428 | static void tegra_slink_copy_spi_rxbuf_to_client_rxbuf( | ||
429 | struct tegra_slink_data *tspi, struct spi_transfer *t) | ||
430 | { | ||
431 | unsigned len; | ||
432 | |||
433 | /* Make the dma buffer to read by cpu */ | ||
434 | dma_sync_single_for_cpu(tspi->dev, tspi->rx_dma_phys, | ||
435 | tspi->dma_buf_size, DMA_FROM_DEVICE); | ||
436 | |||
437 | if (tspi->is_packed) { | ||
438 | len = tspi->curr_dma_words * tspi->bytes_per_word; | ||
439 | memcpy(t->rx_buf + tspi->cur_rx_pos, tspi->rx_dma_buf, len); | ||
440 | } else { | ||
441 | unsigned int i; | ||
442 | unsigned int count; | ||
443 | unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos; | ||
444 | unsigned int x; | ||
445 | unsigned int rx_mask, bits_per_word; | ||
446 | |||
447 | bits_per_word = t->bits_per_word ? t->bits_per_word : | ||
448 | tspi->cur_spi->bits_per_word; | ||
449 | rx_mask = (1 << bits_per_word) - 1; | ||
450 | for (count = 0; count < tspi->curr_dma_words; count++) { | ||
451 | x = tspi->rx_dma_buf[count]; | ||
452 | x &= rx_mask; | ||
453 | for (i = 0; (i < tspi->bytes_per_word); i++) | ||
454 | *rx_buf++ = (x >> (i*8)) & 0xFF; | ||
455 | } | ||
456 | } | ||
457 | tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; | ||
458 | |||
459 | /* Make the dma buffer to read by dma */ | ||
460 | dma_sync_single_for_device(tspi->dev, tspi->rx_dma_phys, | ||
461 | tspi->dma_buf_size, DMA_FROM_DEVICE); | ||
462 | } | ||
463 | |||
464 | static void tegra_slink_dma_complete(void *args) | ||
465 | { | ||
466 | struct completion *dma_complete = args; | ||
467 | |||
468 | complete(dma_complete); | ||
469 | } | ||
470 | |||
471 | static int tegra_slink_start_tx_dma(struct tegra_slink_data *tspi, int len) | ||
472 | { | ||
473 | INIT_COMPLETION(tspi->tx_dma_complete); | ||
474 | tspi->tx_dma_desc = dmaengine_prep_slave_single(tspi->tx_dma_chan, | ||
475 | tspi->tx_dma_phys, len, DMA_MEM_TO_DEV, | ||
476 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
477 | if (!tspi->tx_dma_desc) { | ||
478 | dev_err(tspi->dev, "Not able to get desc for Tx\n"); | ||
479 | return -EIO; | ||
480 | } | ||
481 | |||
482 | tspi->tx_dma_desc->callback = tegra_slink_dma_complete; | ||
483 | tspi->tx_dma_desc->callback_param = &tspi->tx_dma_complete; | ||
484 | |||
485 | dmaengine_submit(tspi->tx_dma_desc); | ||
486 | dma_async_issue_pending(tspi->tx_dma_chan); | ||
487 | return 0; | ||
488 | } | ||
489 | |||
490 | static int tegra_slink_start_rx_dma(struct tegra_slink_data *tspi, int len) | ||
491 | { | ||
492 | INIT_COMPLETION(tspi->rx_dma_complete); | ||
493 | tspi->rx_dma_desc = dmaengine_prep_slave_single(tspi->rx_dma_chan, | ||
494 | tspi->rx_dma_phys, len, DMA_DEV_TO_MEM, | ||
495 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
496 | if (!tspi->rx_dma_desc) { | ||
497 | dev_err(tspi->dev, "Not able to get desc for Rx\n"); | ||
498 | return -EIO; | ||
499 | } | ||
500 | |||
501 | tspi->rx_dma_desc->callback = tegra_slink_dma_complete; | ||
502 | tspi->rx_dma_desc->callback_param = &tspi->rx_dma_complete; | ||
503 | |||
504 | dmaengine_submit(tspi->rx_dma_desc); | ||
505 | dma_async_issue_pending(tspi->rx_dma_chan); | ||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | static int tegra_slink_start_dma_based_transfer( | ||
510 | struct tegra_slink_data *tspi, struct spi_transfer *t) | ||
511 | { | ||
512 | unsigned long val; | ||
513 | unsigned long test_val; | ||
514 | unsigned int len; | ||
515 | int ret = 0; | ||
516 | unsigned long status; | ||
517 | |||
518 | /* Make sure that Rx and Tx fifo are empty */ | ||
519 | status = tegra_slink_readl(tspi, SLINK_STATUS); | ||
520 | if ((status & SLINK_FIFO_EMPTY) != SLINK_FIFO_EMPTY) { | ||
521 | dev_err(tspi->dev, | ||
522 | "Rx/Tx fifo are not empty status 0x%08lx\n", status); | ||
523 | return -EIO; | ||
524 | } | ||
525 | |||
526 | val = SLINK_DMA_BLOCK_SIZE(tspi->curr_dma_words - 1); | ||
527 | val |= tspi->packed_size; | ||
528 | if (tspi->is_packed) | ||
529 | len = DIV_ROUND_UP(tspi->curr_dma_words * tspi->bytes_per_word, | ||
530 | 4) * 4; | ||
531 | else | ||
532 | len = tspi->curr_dma_words * 4; | ||
533 | |||
534 | /* Set attention level based on length of transfer */ | ||
535 | if (len & 0xF) | ||
536 | val |= SLINK_TX_TRIG_1 | SLINK_RX_TRIG_1; | ||
537 | else if (((len) >> 4) & 0x1) | ||
538 | val |= SLINK_TX_TRIG_4 | SLINK_RX_TRIG_4; | ||
539 | else | ||
540 | val |= SLINK_TX_TRIG_8 | SLINK_RX_TRIG_8; | ||
541 | |||
542 | if (tspi->cur_direction & DATA_DIR_TX) | ||
543 | val |= SLINK_IE_TXC; | ||
544 | |||
545 | if (tspi->cur_direction & DATA_DIR_RX) | ||
546 | val |= SLINK_IE_RXC; | ||
547 | |||
548 | tegra_slink_writel(tspi, val, SLINK_DMA_CTL); | ||
549 | tspi->dma_control_reg = val; | ||
550 | |||
551 | if (tspi->cur_direction & DATA_DIR_TX) { | ||
552 | tegra_slink_copy_client_txbuf_to_spi_txbuf(tspi, t); | ||
553 | wmb(); | ||
554 | ret = tegra_slink_start_tx_dma(tspi, len); | ||
555 | if (ret < 0) { | ||
556 | dev_err(tspi->dev, | ||
557 | "Starting tx dma failed, err %d\n", ret); | ||
558 | return ret; | ||
559 | } | ||
560 | |||
561 | /* Wait for tx fifo to be fill before starting slink */ | ||
562 | test_val = tegra_slink_readl(tspi, SLINK_STATUS); | ||
563 | while (!(test_val & SLINK_TX_FULL)) | ||
564 | test_val = tegra_slink_readl(tspi, SLINK_STATUS); | ||
565 | } | ||
566 | |||
567 | if (tspi->cur_direction & DATA_DIR_RX) { | ||
568 | /* Make the dma buffer to read by dma */ | ||
569 | dma_sync_single_for_device(tspi->dev, tspi->rx_dma_phys, | ||
570 | tspi->dma_buf_size, DMA_FROM_DEVICE); | ||
571 | |||
572 | ret = tegra_slink_start_rx_dma(tspi, len); | ||
573 | if (ret < 0) { | ||
574 | dev_err(tspi->dev, | ||
575 | "Starting rx dma failed, err %d\n", ret); | ||
576 | if (tspi->cur_direction & DATA_DIR_TX) | ||
577 | dmaengine_terminate_all(tspi->tx_dma_chan); | ||
578 | return ret; | ||
579 | } | ||
580 | } | ||
581 | tspi->is_curr_dma_xfer = true; | ||
582 | if (tspi->is_packed) { | ||
583 | val |= SLINK_PACKED; | ||
584 | tegra_slink_writel(tspi, val, SLINK_DMA_CTL); | ||
585 | /* HW need small delay after settign Packed mode */ | ||
586 | udelay(1); | ||
587 | } | ||
588 | tspi->dma_control_reg = val; | ||
589 | |||
590 | val |= SLINK_DMA_EN; | ||
591 | tegra_slink_writel(tspi, val, SLINK_DMA_CTL); | ||
592 | return ret; | ||
593 | } | ||
594 | |||
595 | static int tegra_slink_start_cpu_based_transfer( | ||
596 | struct tegra_slink_data *tspi, struct spi_transfer *t) | ||
597 | { | ||
598 | unsigned long val; | ||
599 | unsigned cur_words; | ||
600 | |||
601 | val = tspi->packed_size; | ||
602 | if (tspi->cur_direction & DATA_DIR_TX) | ||
603 | val |= SLINK_IE_TXC; | ||
604 | |||
605 | if (tspi->cur_direction & DATA_DIR_RX) | ||
606 | val |= SLINK_IE_RXC; | ||
607 | |||
608 | tegra_slink_writel(tspi, val, SLINK_DMA_CTL); | ||
609 | tspi->dma_control_reg = val; | ||
610 | |||
611 | if (tspi->cur_direction & DATA_DIR_TX) | ||
612 | cur_words = tegra_slink_fill_tx_fifo_from_client_txbuf(tspi, t); | ||
613 | else | ||
614 | cur_words = tspi->curr_dma_words; | ||
615 | val |= SLINK_DMA_BLOCK_SIZE(cur_words - 1); | ||
616 | tegra_slink_writel(tspi, val, SLINK_DMA_CTL); | ||
617 | tspi->dma_control_reg = val; | ||
618 | |||
619 | tspi->is_curr_dma_xfer = false; | ||
620 | if (tspi->is_packed) { | ||
621 | val |= SLINK_PACKED; | ||
622 | tegra_slink_writel(tspi, val, SLINK_DMA_CTL); | ||
623 | udelay(1); | ||
624 | wmb(); | ||
625 | } | ||
626 | tspi->dma_control_reg = val; | ||
627 | val |= SLINK_DMA_EN; | ||
628 | tegra_slink_writel(tspi, val, SLINK_DMA_CTL); | ||
629 | return 0; | ||
630 | } | ||
631 | |||
632 | static int tegra_slink_init_dma_param(struct tegra_slink_data *tspi, | ||
633 | bool dma_to_memory) | ||
634 | { | ||
635 | struct dma_chan *dma_chan; | ||
636 | u32 *dma_buf; | ||
637 | dma_addr_t dma_phys; | ||
638 | int ret; | ||
639 | struct dma_slave_config dma_sconfig; | ||
640 | dma_cap_mask_t mask; | ||
641 | |||
642 | dma_cap_zero(mask); | ||
643 | dma_cap_set(DMA_SLAVE, mask); | ||
644 | dma_chan = dma_request_channel(mask, NULL, NULL); | ||
645 | if (!dma_chan) { | ||
646 | dev_err(tspi->dev, | ||
647 | "Dma channel is not available, will try later\n"); | ||
648 | return -EPROBE_DEFER; | ||
649 | } | ||
650 | |||
651 | dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size, | ||
652 | &dma_phys, GFP_KERNEL); | ||
653 | if (!dma_buf) { | ||
654 | dev_err(tspi->dev, " Not able to allocate the dma buffer\n"); | ||
655 | dma_release_channel(dma_chan); | ||
656 | return -ENOMEM; | ||
657 | } | ||
658 | |||
659 | dma_sconfig.slave_id = tspi->dma_req_sel; | ||
660 | if (dma_to_memory) { | ||
661 | dma_sconfig.src_addr = tspi->phys + SLINK_RX_FIFO; | ||
662 | dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
663 | dma_sconfig.src_maxburst = 0; | ||
664 | } else { | ||
665 | dma_sconfig.dst_addr = tspi->phys + SLINK_TX_FIFO; | ||
666 | dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
667 | dma_sconfig.dst_maxburst = 0; | ||
668 | } | ||
669 | |||
670 | ret = dmaengine_slave_config(dma_chan, &dma_sconfig); | ||
671 | if (ret) | ||
672 | goto scrub; | ||
673 | if (dma_to_memory) { | ||
674 | tspi->rx_dma_chan = dma_chan; | ||
675 | tspi->rx_dma_buf = dma_buf; | ||
676 | tspi->rx_dma_phys = dma_phys; | ||
677 | } else { | ||
678 | tspi->tx_dma_chan = dma_chan; | ||
679 | tspi->tx_dma_buf = dma_buf; | ||
680 | tspi->tx_dma_phys = dma_phys; | ||
681 | } | ||
682 | return 0; | ||
683 | |||
684 | scrub: | ||
685 | dma_free_coherent(tspi->dev, tspi->dma_buf_size, dma_buf, dma_phys); | ||
686 | dma_release_channel(dma_chan); | ||
687 | return ret; | ||
688 | } | ||
689 | |||
690 | static void tegra_slink_deinit_dma_param(struct tegra_slink_data *tspi, | ||
691 | bool dma_to_memory) | ||
692 | { | ||
693 | u32 *dma_buf; | ||
694 | dma_addr_t dma_phys; | ||
695 | struct dma_chan *dma_chan; | ||
696 | |||
697 | if (dma_to_memory) { | ||
698 | dma_buf = tspi->rx_dma_buf; | ||
699 | dma_chan = tspi->rx_dma_chan; | ||
700 | dma_phys = tspi->rx_dma_phys; | ||
701 | tspi->rx_dma_chan = NULL; | ||
702 | tspi->rx_dma_buf = NULL; | ||
703 | } else { | ||
704 | dma_buf = tspi->tx_dma_buf; | ||
705 | dma_chan = tspi->tx_dma_chan; | ||
706 | dma_phys = tspi->tx_dma_phys; | ||
707 | tspi->tx_dma_buf = NULL; | ||
708 | tspi->tx_dma_chan = NULL; | ||
709 | } | ||
710 | if (!dma_chan) | ||
711 | return; | ||
712 | |||
713 | dma_free_coherent(tspi->dev, tspi->dma_buf_size, dma_buf, dma_phys); | ||
714 | dma_release_channel(dma_chan); | ||
715 | } | ||
716 | |||
717 | static int tegra_slink_start_transfer_one(struct spi_device *spi, | ||
718 | struct spi_transfer *t, bool is_first_of_msg, | ||
719 | bool is_single_xfer) | ||
720 | { | ||
721 | struct tegra_slink_data *tspi = spi_master_get_devdata(spi->master); | ||
722 | u32 speed; | ||
723 | u8 bits_per_word; | ||
724 | unsigned total_fifo_words; | ||
725 | int ret; | ||
726 | struct tegra_spi_device_controller_data *cdata = spi->controller_data; | ||
727 | unsigned long command; | ||
728 | unsigned long command2; | ||
729 | |||
730 | bits_per_word = t->bits_per_word; | ||
731 | speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; | ||
732 | if (!speed) | ||
733 | speed = tspi->spi_max_frequency; | ||
734 | if (speed != tspi->cur_speed) { | ||
735 | clk_set_rate(tspi->clk, speed * 4); | ||
736 | tspi->cur_speed = speed; | ||
737 | } | ||
738 | |||
739 | tspi->cur_spi = spi; | ||
740 | tspi->cur_pos = 0; | ||
741 | tspi->cur_rx_pos = 0; | ||
742 | tspi->cur_tx_pos = 0; | ||
743 | tspi->curr_xfer = t; | ||
744 | total_fifo_words = tegra_slink_calculate_curr_xfer_param(spi, tspi, t); | ||
745 | |||
746 | if (is_first_of_msg) { | ||
747 | tegra_slink_clear_status(tspi); | ||
748 | |||
749 | command = tspi->def_command_reg; | ||
750 | command |= SLINK_BIT_LENGTH(bits_per_word - 1); | ||
751 | |||
752 | command2 = tspi->def_command2_reg; | ||
753 | command2 |= SLINK_SS_EN_CS(spi->chip_select); | ||
754 | |||
755 | /* possibly use the hw based chip select */ | ||
756 | tspi->is_hw_based_cs = false; | ||
757 | if (cdata && cdata->is_hw_based_cs && is_single_xfer && | ||
758 | ((tspi->curr_dma_words * tspi->bytes_per_word) == | ||
759 | (t->len - tspi->cur_pos))) { | ||
760 | int setup_count; | ||
761 | int sts2; | ||
762 | |||
763 | setup_count = cdata->cs_setup_clk_count >> 1; | ||
764 | setup_count = max(setup_count, 3); | ||
765 | command2 |= SLINK_SS_SETUP(setup_count); | ||
766 | if (tspi->chip_data->cs_hold_time) { | ||
767 | int hold_count; | ||
768 | |||
769 | hold_count = cdata->cs_hold_clk_count; | ||
770 | hold_count = max(hold_count, 0xF); | ||
771 | sts2 = tegra_slink_readl(tspi, SLINK_STATUS2); | ||
772 | sts2 &= ~SLINK_SS_HOLD_TIME(0xF); | ||
773 | sts2 |= SLINK_SS_HOLD_TIME(hold_count); | ||
774 | tegra_slink_writel(tspi, sts2, SLINK_STATUS2); | ||
775 | } | ||
776 | tspi->is_hw_based_cs = true; | ||
777 | } | ||
778 | |||
779 | if (tspi->is_hw_based_cs) | ||
780 | command &= ~SLINK_CS_SW; | ||
781 | else | ||
782 | command |= SLINK_CS_SW | SLINK_CS_VALUE; | ||
783 | |||
784 | command &= ~SLINK_MODES; | ||
785 | if (spi->mode & SPI_CPHA) | ||
786 | command |= SLINK_CK_SDA; | ||
787 | |||
788 | if (spi->mode & SPI_CPOL) | ||
789 | command |= SLINK_IDLE_SCLK_DRIVE_HIGH; | ||
790 | else | ||
791 | command |= SLINK_IDLE_SCLK_DRIVE_LOW; | ||
792 | } else { | ||
793 | command = tspi->command_reg; | ||
794 | command &= ~SLINK_BIT_LENGTH(~0); | ||
795 | command |= SLINK_BIT_LENGTH(bits_per_word - 1); | ||
796 | |||
797 | command2 = tspi->command2_reg; | ||
798 | command2 &= ~(SLINK_RXEN | SLINK_TXEN); | ||
799 | } | ||
800 | |||
801 | tegra_slink_writel(tspi, command, SLINK_COMMAND); | ||
802 | tspi->command_reg = command; | ||
803 | |||
804 | tspi->cur_direction = 0; | ||
805 | if (t->rx_buf) { | ||
806 | command2 |= SLINK_RXEN; | ||
807 | tspi->cur_direction |= DATA_DIR_RX; | ||
808 | } | ||
809 | if (t->tx_buf) { | ||
810 | command2 |= SLINK_TXEN; | ||
811 | tspi->cur_direction |= DATA_DIR_TX; | ||
812 | } | ||
813 | tegra_slink_writel(tspi, command2, SLINK_COMMAND2); | ||
814 | tspi->command2_reg = command2; | ||
815 | |||
816 | if (total_fifo_words > SLINK_FIFO_DEPTH) | ||
817 | ret = tegra_slink_start_dma_based_transfer(tspi, t); | ||
818 | else | ||
819 | ret = tegra_slink_start_cpu_based_transfer(tspi, t); | ||
820 | return ret; | ||
821 | } | ||
822 | |||
823 | static int tegra_slink_setup(struct spi_device *spi) | ||
824 | { | ||
825 | struct tegra_slink_data *tspi = spi_master_get_devdata(spi->master); | ||
826 | unsigned long val; | ||
827 | unsigned long flags; | ||
828 | int ret; | ||
829 | unsigned int cs_pol_bit[MAX_CHIP_SELECT] = { | ||
830 | SLINK_CS_POLARITY, | ||
831 | SLINK_CS_POLARITY1, | ||
832 | SLINK_CS_POLARITY2, | ||
833 | SLINK_CS_POLARITY3, | ||
834 | }; | ||
835 | |||
836 | dev_dbg(&spi->dev, "setup %d bpw, %scpol, %scpha, %dHz\n", | ||
837 | spi->bits_per_word, | ||
838 | spi->mode & SPI_CPOL ? "" : "~", | ||
839 | spi->mode & SPI_CPHA ? "" : "~", | ||
840 | spi->max_speed_hz); | ||
841 | |||
842 | BUG_ON(spi->chip_select >= MAX_CHIP_SELECT); | ||
843 | |||
844 | ret = pm_runtime_get_sync(tspi->dev); | ||
845 | if (ret < 0) { | ||
846 | dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret); | ||
847 | return ret; | ||
848 | } | ||
849 | |||
850 | spin_lock_irqsave(&tspi->lock, flags); | ||
851 | val = tspi->def_command_reg; | ||
852 | if (spi->mode & SPI_CS_HIGH) | ||
853 | val |= cs_pol_bit[spi->chip_select]; | ||
854 | else | ||
855 | val &= ~cs_pol_bit[spi->chip_select]; | ||
856 | tspi->def_command_reg = val; | ||
857 | tegra_slink_writel(tspi, tspi->def_command_reg, SLINK_COMMAND); | ||
858 | spin_unlock_irqrestore(&tspi->lock, flags); | ||
859 | |||
860 | pm_runtime_put(tspi->dev); | ||
861 | return 0; | ||
862 | } | ||
863 | |||
864 | static int tegra_slink_prepare_transfer(struct spi_master *master) | ||
865 | { | ||
866 | struct tegra_slink_data *tspi = spi_master_get_devdata(master); | ||
867 | |||
868 | return pm_runtime_get_sync(tspi->dev); | ||
869 | } | ||
870 | |||
871 | static int tegra_slink_unprepare_transfer(struct spi_master *master) | ||
872 | { | ||
873 | struct tegra_slink_data *tspi = spi_master_get_devdata(master); | ||
874 | |||
875 | pm_runtime_put(tspi->dev); | ||
876 | return 0; | ||
877 | } | ||
878 | |||
879 | static int tegra_slink_transfer_one_message(struct spi_master *master, | ||
880 | struct spi_message *msg) | ||
881 | { | ||
882 | bool is_first_msg = true; | ||
883 | int single_xfer; | ||
884 | struct tegra_slink_data *tspi = spi_master_get_devdata(master); | ||
885 | struct spi_transfer *xfer; | ||
886 | struct spi_device *spi = msg->spi; | ||
887 | int ret; | ||
888 | |||
889 | msg->status = 0; | ||
890 | msg->actual_length = 0; | ||
891 | single_xfer = list_is_singular(&msg->transfers); | ||
892 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
893 | INIT_COMPLETION(tspi->xfer_completion); | ||
894 | ret = tegra_slink_start_transfer_one(spi, xfer, | ||
895 | is_first_msg, single_xfer); | ||
896 | if (ret < 0) { | ||
897 | dev_err(tspi->dev, | ||
898 | "spi can not start transfer, err %d\n", ret); | ||
899 | goto exit; | ||
900 | } | ||
901 | is_first_msg = false; | ||
902 | ret = wait_for_completion_timeout(&tspi->xfer_completion, | ||
903 | SLINK_DMA_TIMEOUT); | ||
904 | if (WARN_ON(ret == 0)) { | ||
905 | dev_err(tspi->dev, | ||
906 | "spi trasfer timeout, err %d\n", ret); | ||
907 | ret = -EIO; | ||
908 | goto exit; | ||
909 | } | ||
910 | |||
911 | if (tspi->tx_status || tspi->rx_status) { | ||
912 | dev_err(tspi->dev, "Error in Transfer\n"); | ||
913 | ret = -EIO; | ||
914 | goto exit; | ||
915 | } | ||
916 | msg->actual_length += xfer->len; | ||
917 | if (xfer->cs_change && xfer->delay_usecs) { | ||
918 | tegra_slink_writel(tspi, tspi->def_command_reg, | ||
919 | SLINK_COMMAND); | ||
920 | udelay(xfer->delay_usecs); | ||
921 | } | ||
922 | } | ||
923 | ret = 0; | ||
924 | exit: | ||
925 | tegra_slink_writel(tspi, tspi->def_command_reg, SLINK_COMMAND); | ||
926 | tegra_slink_writel(tspi, tspi->def_command2_reg, SLINK_COMMAND2); | ||
927 | msg->status = ret; | ||
928 | spi_finalize_current_message(master); | ||
929 | return ret; | ||
930 | } | ||
931 | |||
932 | static irqreturn_t handle_cpu_based_xfer(struct tegra_slink_data *tspi) | ||
933 | { | ||
934 | struct spi_transfer *t = tspi->curr_xfer; | ||
935 | unsigned long flags; | ||
936 | |||
937 | spin_lock_irqsave(&tspi->lock, flags); | ||
938 | if (tspi->tx_status || tspi->rx_status || | ||
939 | (tspi->status_reg & SLINK_BSY)) { | ||
940 | dev_err(tspi->dev, | ||
941 | "CpuXfer ERROR bit set 0x%x\n", tspi->status_reg); | ||
942 | dev_err(tspi->dev, | ||
943 | "CpuXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg, | ||
944 | tspi->command2_reg, tspi->dma_control_reg); | ||
945 | tegra_periph_reset_assert(tspi->clk); | ||
946 | udelay(2); | ||
947 | tegra_periph_reset_deassert(tspi->clk); | ||
948 | complete(&tspi->xfer_completion); | ||
949 | goto exit; | ||
950 | } | ||
951 | |||
952 | if (tspi->cur_direction & DATA_DIR_RX) | ||
953 | tegra_slink_read_rx_fifo_to_client_rxbuf(tspi, t); | ||
954 | |||
955 | if (tspi->cur_direction & DATA_DIR_TX) | ||
956 | tspi->cur_pos = tspi->cur_tx_pos; | ||
957 | else | ||
958 | tspi->cur_pos = tspi->cur_rx_pos; | ||
959 | |||
960 | if (tspi->cur_pos == t->len) { | ||
961 | complete(&tspi->xfer_completion); | ||
962 | goto exit; | ||
963 | } | ||
964 | |||
965 | tegra_slink_calculate_curr_xfer_param(tspi->cur_spi, tspi, t); | ||
966 | tegra_slink_start_cpu_based_transfer(tspi, t); | ||
967 | exit: | ||
968 | spin_unlock_irqrestore(&tspi->lock, flags); | ||
969 | return IRQ_HANDLED; | ||
970 | } | ||
971 | |||
972 | static irqreturn_t handle_dma_based_xfer(struct tegra_slink_data *tspi) | ||
973 | { | ||
974 | struct spi_transfer *t = tspi->curr_xfer; | ||
975 | long wait_status; | ||
976 | int err = 0; | ||
977 | unsigned total_fifo_words; | ||
978 | unsigned long flags; | ||
979 | |||
980 | /* Abort dmas if any error */ | ||
981 | if (tspi->cur_direction & DATA_DIR_TX) { | ||
982 | if (tspi->tx_status) { | ||
983 | dmaengine_terminate_all(tspi->tx_dma_chan); | ||
984 | err += 1; | ||
985 | } else { | ||
986 | wait_status = wait_for_completion_interruptible_timeout( | ||
987 | &tspi->tx_dma_complete, SLINK_DMA_TIMEOUT); | ||
988 | if (wait_status <= 0) { | ||
989 | dmaengine_terminate_all(tspi->tx_dma_chan); | ||
990 | dev_err(tspi->dev, "TxDma Xfer failed\n"); | ||
991 | err += 1; | ||
992 | } | ||
993 | } | ||
994 | } | ||
995 | |||
996 | if (tspi->cur_direction & DATA_DIR_RX) { | ||
997 | if (tspi->rx_status) { | ||
998 | dmaengine_terminate_all(tspi->rx_dma_chan); | ||
999 | err += 2; | ||
1000 | } else { | ||
1001 | wait_status = wait_for_completion_interruptible_timeout( | ||
1002 | &tspi->rx_dma_complete, SLINK_DMA_TIMEOUT); | ||
1003 | if (wait_status <= 0) { | ||
1004 | dmaengine_terminate_all(tspi->rx_dma_chan); | ||
1005 | dev_err(tspi->dev, "RxDma Xfer failed\n"); | ||
1006 | err += 2; | ||
1007 | } | ||
1008 | } | ||
1009 | } | ||
1010 | |||
1011 | spin_lock_irqsave(&tspi->lock, flags); | ||
1012 | if (err) { | ||
1013 | dev_err(tspi->dev, | ||
1014 | "DmaXfer: ERROR bit set 0x%x\n", tspi->status_reg); | ||
1015 | dev_err(tspi->dev, | ||
1016 | "DmaXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg, | ||
1017 | tspi->command2_reg, tspi->dma_control_reg); | ||
1018 | tegra_periph_reset_assert(tspi->clk); | ||
1019 | udelay(2); | ||
1020 | tegra_periph_reset_deassert(tspi->clk); | ||
1021 | complete(&tspi->xfer_completion); | ||
1022 | spin_unlock_irqrestore(&tspi->lock, flags); | ||
1023 | return IRQ_HANDLED; | ||
1024 | } | ||
1025 | |||
1026 | if (tspi->cur_direction & DATA_DIR_RX) | ||
1027 | tegra_slink_copy_spi_rxbuf_to_client_rxbuf(tspi, t); | ||
1028 | |||
1029 | if (tspi->cur_direction & DATA_DIR_TX) | ||
1030 | tspi->cur_pos = tspi->cur_tx_pos; | ||
1031 | else | ||
1032 | tspi->cur_pos = tspi->cur_rx_pos; | ||
1033 | |||
1034 | if (tspi->cur_pos == t->len) { | ||
1035 | complete(&tspi->xfer_completion); | ||
1036 | goto exit; | ||
1037 | } | ||
1038 | |||
1039 | /* Continue transfer in current message */ | ||
1040 | total_fifo_words = tegra_slink_calculate_curr_xfer_param(tspi->cur_spi, | ||
1041 | tspi, t); | ||
1042 | if (total_fifo_words > SLINK_FIFO_DEPTH) | ||
1043 | err = tegra_slink_start_dma_based_transfer(tspi, t); | ||
1044 | else | ||
1045 | err = tegra_slink_start_cpu_based_transfer(tspi, t); | ||
1046 | |||
1047 | exit: | ||
1048 | spin_unlock_irqrestore(&tspi->lock, flags); | ||
1049 | return IRQ_HANDLED; | ||
1050 | } | ||
1051 | |||
1052 | static irqreturn_t tegra_slink_isr_thread(int irq, void *context_data) | ||
1053 | { | ||
1054 | struct tegra_slink_data *tspi = context_data; | ||
1055 | |||
1056 | if (!tspi->is_curr_dma_xfer) | ||
1057 | return handle_cpu_based_xfer(tspi); | ||
1058 | return handle_dma_based_xfer(tspi); | ||
1059 | } | ||
1060 | |||
1061 | static irqreturn_t tegra_slink_isr(int irq, void *context_data) | ||
1062 | { | ||
1063 | struct tegra_slink_data *tspi = context_data; | ||
1064 | |||
1065 | tspi->status_reg = tegra_slink_readl(tspi, SLINK_STATUS); | ||
1066 | if (tspi->cur_direction & DATA_DIR_TX) | ||
1067 | tspi->tx_status = tspi->status_reg & | ||
1068 | (SLINK_TX_OVF | SLINK_TX_UNF); | ||
1069 | |||
1070 | if (tspi->cur_direction & DATA_DIR_RX) | ||
1071 | tspi->rx_status = tspi->status_reg & | ||
1072 | (SLINK_RX_OVF | SLINK_RX_UNF); | ||
1073 | tegra_slink_clear_status(tspi); | ||
1074 | |||
1075 | return IRQ_WAKE_THREAD; | ||
1076 | } | ||
1077 | |||
1078 | static struct tegra_spi_platform_data *tegra_slink_parse_dt( | ||
1079 | struct platform_device *pdev) | ||
1080 | { | ||
1081 | struct tegra_spi_platform_data *pdata; | ||
1082 | const unsigned int *prop; | ||
1083 | struct device_node *np = pdev->dev.of_node; | ||
1084 | u32 of_dma[2]; | ||
1085 | |||
1086 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
1087 | if (!pdata) { | ||
1088 | dev_err(&pdev->dev, "Memory alloc for pdata failed\n"); | ||
1089 | return NULL; | ||
1090 | } | ||
1091 | |||
1092 | if (of_property_read_u32_array(np, "nvidia,dma-request-selector", | ||
1093 | of_dma, 2) >= 0) | ||
1094 | pdata->dma_req_sel = of_dma[1]; | ||
1095 | |||
1096 | prop = of_get_property(np, "spi-max-frequency", NULL); | ||
1097 | if (prop) | ||
1098 | pdata->spi_max_frequency = be32_to_cpup(prop); | ||
1099 | |||
1100 | return pdata; | ||
1101 | } | ||
1102 | |||
1103 | const struct tegra_slink_chip_data tegra30_spi_cdata = { | ||
1104 | .cs_hold_time = true, | ||
1105 | }; | ||
1106 | |||
1107 | const struct tegra_slink_chip_data tegra20_spi_cdata = { | ||
1108 | .cs_hold_time = false, | ||
1109 | }; | ||
1110 | |||
1111 | static struct of_device_id tegra_slink_of_match[] = { | ||
1112 | { .compatible = "nvidia,tegra30-slink", .data = &tegra30_spi_cdata, }, | ||
1113 | { .compatible = "nvidia,tegra20-slink", .data = &tegra20_spi_cdata, }, | ||
1114 | {} | ||
1115 | }; | ||
1116 | MODULE_DEVICE_TABLE(of, tegra_slink_of_match); | ||
1117 | |||
1118 | static int tegra_slink_probe(struct platform_device *pdev) | ||
1119 | { | ||
1120 | struct spi_master *master; | ||
1121 | struct tegra_slink_data *tspi; | ||
1122 | struct resource *r; | ||
1123 | struct tegra_spi_platform_data *pdata = pdev->dev.platform_data; | ||
1124 | int ret, spi_irq; | ||
1125 | const struct tegra_slink_chip_data *cdata = NULL; | ||
1126 | const struct of_device_id *match; | ||
1127 | |||
1128 | match = of_match_device(of_match_ptr(tegra_slink_of_match), &pdev->dev); | ||
1129 | if (!match) { | ||
1130 | dev_err(&pdev->dev, "Error: No device match found\n"); | ||
1131 | return -ENODEV; | ||
1132 | } | ||
1133 | cdata = match->data; | ||
1134 | if (!pdata && pdev->dev.of_node) | ||
1135 | pdata = tegra_slink_parse_dt(pdev); | ||
1136 | |||
1137 | if (!pdata) { | ||
1138 | dev_err(&pdev->dev, "No platform data, exiting\n"); | ||
1139 | return -ENODEV; | ||
1140 | } | ||
1141 | |||
1142 | if (!pdata->spi_max_frequency) | ||
1143 | pdata->spi_max_frequency = 25000000; /* 25MHz */ | ||
1144 | |||
1145 | master = spi_alloc_master(&pdev->dev, sizeof(*tspi)); | ||
1146 | if (!master) { | ||
1147 | dev_err(&pdev->dev, "master allocation failed\n"); | ||
1148 | return -ENOMEM; | ||
1149 | } | ||
1150 | |||
1151 | /* the spi->mode bits understood by this driver: */ | ||
1152 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
1153 | master->setup = tegra_slink_setup; | ||
1154 | master->prepare_transfer_hardware = tegra_slink_prepare_transfer; | ||
1155 | master->transfer_one_message = tegra_slink_transfer_one_message; | ||
1156 | master->unprepare_transfer_hardware = tegra_slink_unprepare_transfer; | ||
1157 | master->num_chipselect = MAX_CHIP_SELECT; | ||
1158 | master->bus_num = -1; | ||
1159 | |||
1160 | dev_set_drvdata(&pdev->dev, master); | ||
1161 | tspi = spi_master_get_devdata(master); | ||
1162 | tspi->master = master; | ||
1163 | tspi->dma_req_sel = pdata->dma_req_sel; | ||
1164 | tspi->dev = &pdev->dev; | ||
1165 | tspi->chip_data = cdata; | ||
1166 | spin_lock_init(&tspi->lock); | ||
1167 | |||
1168 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1169 | if (!r) { | ||
1170 | dev_err(&pdev->dev, "No IO memory resource\n"); | ||
1171 | ret = -ENODEV; | ||
1172 | goto exit_free_master; | ||
1173 | } | ||
1174 | tspi->phys = r->start; | ||
1175 | tspi->base = devm_request_and_ioremap(&pdev->dev, r); | ||
1176 | if (!tspi->base) { | ||
1177 | dev_err(&pdev->dev, | ||
1178 | "Cannot request memregion/iomap dma address\n"); | ||
1179 | ret = -EADDRNOTAVAIL; | ||
1180 | goto exit_free_master; | ||
1181 | } | ||
1182 | |||
1183 | spi_irq = platform_get_irq(pdev, 0); | ||
1184 | tspi->irq = spi_irq; | ||
1185 | ret = request_threaded_irq(tspi->irq, tegra_slink_isr, | ||
1186 | tegra_slink_isr_thread, IRQF_ONESHOT, | ||
1187 | dev_name(&pdev->dev), tspi); | ||
1188 | if (ret < 0) { | ||
1189 | dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n", | ||
1190 | tspi->irq); | ||
1191 | goto exit_free_master; | ||
1192 | } | ||
1193 | |||
1194 | tspi->clk = devm_clk_get(&pdev->dev, "slink"); | ||
1195 | if (IS_ERR(tspi->clk)) { | ||
1196 | dev_err(&pdev->dev, "can not get clock\n"); | ||
1197 | ret = PTR_ERR(tspi->clk); | ||
1198 | goto exit_free_irq; | ||
1199 | } | ||
1200 | |||
1201 | tspi->max_buf_size = SLINK_FIFO_DEPTH << 2; | ||
1202 | tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN; | ||
1203 | tspi->spi_max_frequency = pdata->spi_max_frequency; | ||
1204 | |||
1205 | if (pdata->dma_req_sel) { | ||
1206 | ret = tegra_slink_init_dma_param(tspi, true); | ||
1207 | if (ret < 0) { | ||
1208 | dev_err(&pdev->dev, "RxDma Init failed, err %d\n", ret); | ||
1209 | goto exit_free_irq; | ||
1210 | } | ||
1211 | |||
1212 | ret = tegra_slink_init_dma_param(tspi, false); | ||
1213 | if (ret < 0) { | ||
1214 | dev_err(&pdev->dev, "TxDma Init failed, err %d\n", ret); | ||
1215 | goto exit_rx_dma_free; | ||
1216 | } | ||
1217 | tspi->max_buf_size = tspi->dma_buf_size; | ||
1218 | init_completion(&tspi->tx_dma_complete); | ||
1219 | init_completion(&tspi->rx_dma_complete); | ||
1220 | } | ||
1221 | |||
1222 | init_completion(&tspi->xfer_completion); | ||
1223 | |||
1224 | pm_runtime_enable(&pdev->dev); | ||
1225 | if (!pm_runtime_enabled(&pdev->dev)) { | ||
1226 | ret = tegra_slink_runtime_resume(&pdev->dev); | ||
1227 | if (ret) | ||
1228 | goto exit_pm_disable; | ||
1229 | } | ||
1230 | |||
1231 | ret = pm_runtime_get_sync(&pdev->dev); | ||
1232 | if (ret < 0) { | ||
1233 | dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret); | ||
1234 | goto exit_pm_disable; | ||
1235 | } | ||
1236 | tspi->def_command_reg = SLINK_M_S; | ||
1237 | tspi->def_command2_reg = SLINK_CS_ACTIVE_BETWEEN; | ||
1238 | tegra_slink_writel(tspi, tspi->def_command_reg, SLINK_COMMAND); | ||
1239 | tegra_slink_writel(tspi, tspi->def_command2_reg, SLINK_COMMAND2); | ||
1240 | pm_runtime_put(&pdev->dev); | ||
1241 | |||
1242 | master->dev.of_node = pdev->dev.of_node; | ||
1243 | ret = spi_register_master(master); | ||
1244 | if (ret < 0) { | ||
1245 | dev_err(&pdev->dev, "can not register to master err %d\n", ret); | ||
1246 | goto exit_pm_disable; | ||
1247 | } | ||
1248 | return ret; | ||
1249 | |||
1250 | exit_pm_disable: | ||
1251 | pm_runtime_disable(&pdev->dev); | ||
1252 | if (!pm_runtime_status_suspended(&pdev->dev)) | ||
1253 | tegra_slink_runtime_suspend(&pdev->dev); | ||
1254 | tegra_slink_deinit_dma_param(tspi, false); | ||
1255 | exit_rx_dma_free: | ||
1256 | tegra_slink_deinit_dma_param(tspi, true); | ||
1257 | exit_free_irq: | ||
1258 | free_irq(spi_irq, tspi); | ||
1259 | exit_free_master: | ||
1260 | spi_master_put(master); | ||
1261 | return ret; | ||
1262 | } | ||
1263 | |||
1264 | static int tegra_slink_remove(struct platform_device *pdev) | ||
1265 | { | ||
1266 | struct spi_master *master = dev_get_drvdata(&pdev->dev); | ||
1267 | struct tegra_slink_data *tspi = spi_master_get_devdata(master); | ||
1268 | |||
1269 | free_irq(tspi->irq, tspi); | ||
1270 | spi_unregister_master(master); | ||
1271 | |||
1272 | if (tspi->tx_dma_chan) | ||
1273 | tegra_slink_deinit_dma_param(tspi, false); | ||
1274 | |||
1275 | if (tspi->rx_dma_chan) | ||
1276 | tegra_slink_deinit_dma_param(tspi, true); | ||
1277 | |||
1278 | pm_runtime_disable(&pdev->dev); | ||
1279 | if (!pm_runtime_status_suspended(&pdev->dev)) | ||
1280 | tegra_slink_runtime_suspend(&pdev->dev); | ||
1281 | |||
1282 | return 0; | ||
1283 | } | ||
1284 | |||
1285 | #ifdef CONFIG_PM_SLEEP | ||
1286 | static int tegra_slink_suspend(struct device *dev) | ||
1287 | { | ||
1288 | struct spi_master *master = dev_get_drvdata(dev); | ||
1289 | |||
1290 | return spi_master_suspend(master); | ||
1291 | } | ||
1292 | |||
1293 | static int tegra_slink_resume(struct device *dev) | ||
1294 | { | ||
1295 | struct spi_master *master = dev_get_drvdata(dev); | ||
1296 | struct tegra_slink_data *tspi = spi_master_get_devdata(master); | ||
1297 | int ret; | ||
1298 | |||
1299 | ret = pm_runtime_get_sync(dev); | ||
1300 | if (ret < 0) { | ||
1301 | dev_err(dev, "pm runtime failed, e = %d\n", ret); | ||
1302 | return ret; | ||
1303 | } | ||
1304 | tegra_slink_writel(tspi, tspi->command_reg, SLINK_COMMAND); | ||
1305 | tegra_slink_writel(tspi, tspi->command2_reg, SLINK_COMMAND2); | ||
1306 | pm_runtime_put(dev); | ||
1307 | |||
1308 | return spi_master_resume(master); | ||
1309 | } | ||
1310 | #endif | ||
1311 | |||
1312 | static int tegra_slink_runtime_suspend(struct device *dev) | ||
1313 | { | ||
1314 | struct spi_master *master = dev_get_drvdata(dev); | ||
1315 | struct tegra_slink_data *tspi = spi_master_get_devdata(master); | ||
1316 | |||
1317 | /* Flush all write which are in PPSB queue by reading back */ | ||
1318 | tegra_slink_readl(tspi, SLINK_MAS_DATA); | ||
1319 | |||
1320 | clk_disable_unprepare(tspi->clk); | ||
1321 | return 0; | ||
1322 | } | ||
1323 | |||
1324 | static int tegra_slink_runtime_resume(struct device *dev) | ||
1325 | { | ||
1326 | struct spi_master *master = dev_get_drvdata(dev); | ||
1327 | struct tegra_slink_data *tspi = spi_master_get_devdata(master); | ||
1328 | int ret; | ||
1329 | |||
1330 | ret = clk_prepare_enable(tspi->clk); | ||
1331 | if (ret < 0) { | ||
1332 | dev_err(tspi->dev, "clk_prepare failed: %d\n", ret); | ||
1333 | return ret; | ||
1334 | } | ||
1335 | return 0; | ||
1336 | } | ||
1337 | |||
1338 | static const struct dev_pm_ops slink_pm_ops = { | ||
1339 | SET_RUNTIME_PM_OPS(tegra_slink_runtime_suspend, | ||
1340 | tegra_slink_runtime_resume, NULL) | ||
1341 | SET_SYSTEM_SLEEP_PM_OPS(tegra_slink_suspend, tegra_slink_resume) | ||
1342 | }; | ||
1343 | static struct platform_driver tegra_slink_driver = { | ||
1344 | .driver = { | ||
1345 | .name = "spi-tegra-slink", | ||
1346 | .owner = THIS_MODULE, | ||
1347 | .pm = &slink_pm_ops, | ||
1348 | .of_match_table = of_match_ptr(tegra_slink_of_match), | ||
1349 | }, | ||
1350 | .probe = tegra_slink_probe, | ||
1351 | .remove = tegra_slink_remove, | ||
1352 | }; | ||
1353 | module_platform_driver(tegra_slink_driver); | ||
1354 | |||
1355 | MODULE_ALIAS("platform:spi-tegra-slink"); | ||
1356 | MODULE_DESCRIPTION("NVIDIA Tegra20/Tegra30 SLINK Controller Driver"); | ||
1357 | MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); | ||
1358 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/spi/spi-ti-ssp.c b/drivers/spi/spi-ti-ssp.c index 3f6f6e81c655..46992cab65f1 100644 --- a/drivers/spi/spi-ti-ssp.c +++ b/drivers/spi/spi-ti-ssp.c | |||
@@ -289,7 +289,7 @@ error_unlock: | |||
289 | return error; | 289 | return error; |
290 | } | 290 | } |
291 | 291 | ||
292 | static int __devinit ti_ssp_spi_probe(struct platform_device *pdev) | 292 | static int ti_ssp_spi_probe(struct platform_device *pdev) |
293 | { | 293 | { |
294 | const struct ti_ssp_spi_data *pdata; | 294 | const struct ti_ssp_spi_data *pdata; |
295 | struct ti_ssp_spi *hw; | 295 | struct ti_ssp_spi *hw; |
@@ -357,7 +357,7 @@ error_wq: | |||
357 | return error; | 357 | return error; |
358 | } | 358 | } |
359 | 359 | ||
360 | static int __devexit ti_ssp_spi_remove(struct platform_device *pdev) | 360 | static int ti_ssp_spi_remove(struct platform_device *pdev) |
361 | { | 361 | { |
362 | struct ti_ssp_spi *hw = platform_get_drvdata(pdev); | 362 | struct ti_ssp_spi *hw = platform_get_drvdata(pdev); |
363 | int error; | 363 | int error; |
@@ -378,7 +378,7 @@ static int __devexit ti_ssp_spi_remove(struct platform_device *pdev) | |||
378 | 378 | ||
379 | static struct platform_driver ti_ssp_spi_driver = { | 379 | static struct platform_driver ti_ssp_spi_driver = { |
380 | .probe = ti_ssp_spi_probe, | 380 | .probe = ti_ssp_spi_probe, |
381 | .remove = __devexit_p(ti_ssp_spi_remove), | 381 | .remove = ti_ssp_spi_remove, |
382 | .driver = { | 382 | .driver = { |
383 | .name = "ti-ssp-spi", | 383 | .name = "ti-ssp-spi", |
384 | .owner = THIS_MODULE, | 384 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi-tle62x0.c b/drivers/spi/spi-tle62x0.c index 24421024deaf..6b0874d782ed 100644 --- a/drivers/spi/spi-tle62x0.c +++ b/drivers/spi/spi-tle62x0.c | |||
@@ -240,7 +240,7 @@ static int to_gpio_num(struct device_attribute *attr) | |||
240 | return -1; | 240 | return -1; |
241 | } | 241 | } |
242 | 242 | ||
243 | static int __devinit tle62x0_probe(struct spi_device *spi) | 243 | static int tle62x0_probe(struct spi_device *spi) |
244 | { | 244 | { |
245 | struct tle62x0_state *st; | 245 | struct tle62x0_state *st; |
246 | struct tle62x0_pdata *pdata; | 246 | struct tle62x0_pdata *pdata; |
@@ -294,7 +294,7 @@ static int __devinit tle62x0_probe(struct spi_device *spi) | |||
294 | return ret; | 294 | return ret; |
295 | } | 295 | } |
296 | 296 | ||
297 | static int __devexit tle62x0_remove(struct spi_device *spi) | 297 | static int tle62x0_remove(struct spi_device *spi) |
298 | { | 298 | { |
299 | struct tle62x0_state *st = spi_get_drvdata(spi); | 299 | struct tle62x0_state *st = spi_get_drvdata(spi); |
300 | int ptr; | 300 | int ptr; |
@@ -313,7 +313,7 @@ static struct spi_driver tle62x0_driver = { | |||
313 | .owner = THIS_MODULE, | 313 | .owner = THIS_MODULE, |
314 | }, | 314 | }, |
315 | .probe = tle62x0_probe, | 315 | .probe = tle62x0_probe, |
316 | .remove = __devexit_p(tle62x0_remove), | 316 | .remove = tle62x0_remove, |
317 | }; | 317 | }; |
318 | 318 | ||
319 | module_spi_driver(tle62x0_driver); | 319 | module_spi_driver(tle62x0_driver); |
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 135f7406f4bf..f756481b0fea 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c | |||
@@ -1401,7 +1401,7 @@ static void pch_alloc_dma_buf(struct pch_spi_board_data *board_dat, | |||
1401 | PCH_BUF_SIZE, &dma->rx_buf_dma, GFP_KERNEL); | 1401 | PCH_BUF_SIZE, &dma->rx_buf_dma, GFP_KERNEL); |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | static int __devinit pch_spi_pd_probe(struct platform_device *plat_dev) | 1404 | static int pch_spi_pd_probe(struct platform_device *plat_dev) |
1405 | { | 1405 | { |
1406 | int ret; | 1406 | int ret; |
1407 | struct spi_master *master; | 1407 | struct spi_master *master; |
@@ -1498,7 +1498,7 @@ err_pci_iomap: | |||
1498 | return ret; | 1498 | return ret; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | static int __devexit pch_spi_pd_remove(struct platform_device *plat_dev) | 1501 | static int pch_spi_pd_remove(struct platform_device *plat_dev) |
1502 | { | 1502 | { |
1503 | struct pch_spi_board_data *board_dat = dev_get_platdata(&plat_dev->dev); | 1503 | struct pch_spi_board_data *board_dat = dev_get_platdata(&plat_dev->dev); |
1504 | struct pch_spi_data *data = platform_get_drvdata(plat_dev); | 1504 | struct pch_spi_data *data = platform_get_drvdata(plat_dev); |
@@ -1619,12 +1619,12 @@ static struct platform_driver pch_spi_pd_driver = { | |||
1619 | .owner = THIS_MODULE, | 1619 | .owner = THIS_MODULE, |
1620 | }, | 1620 | }, |
1621 | .probe = pch_spi_pd_probe, | 1621 | .probe = pch_spi_pd_probe, |
1622 | .remove = __devexit_p(pch_spi_pd_remove), | 1622 | .remove = pch_spi_pd_remove, |
1623 | .suspend = pch_spi_pd_suspend, | 1623 | .suspend = pch_spi_pd_suspend, |
1624 | .resume = pch_spi_pd_resume | 1624 | .resume = pch_spi_pd_resume |
1625 | }; | 1625 | }; |
1626 | 1626 | ||
1627 | static int __devinit pch_spi_probe(struct pci_dev *pdev, | 1627 | static int pch_spi_probe(struct pci_dev *pdev, |
1628 | const struct pci_device_id *id) | 1628 | const struct pci_device_id *id) |
1629 | { | 1629 | { |
1630 | struct pch_spi_board_data *board_dat; | 1630 | struct pch_spi_board_data *board_dat; |
@@ -1705,7 +1705,7 @@ err_no_mem: | |||
1705 | return retval; | 1705 | return retval; |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | static void __devexit pch_spi_remove(struct pci_dev *pdev) | 1708 | static void pch_spi_remove(struct pci_dev *pdev) |
1709 | { | 1709 | { |
1710 | int i; | 1710 | int i; |
1711 | struct pch_pd_dev_save *pd_dev_save = pci_get_drvdata(pdev); | 1711 | struct pch_pd_dev_save *pd_dev_save = pci_get_drvdata(pdev); |
@@ -1776,7 +1776,7 @@ static struct pci_driver pch_spi_pcidev_driver = { | |||
1776 | .name = "pch_spi", | 1776 | .name = "pch_spi", |
1777 | .id_table = pch_spi_pcidev_id, | 1777 | .id_table = pch_spi_pcidev_id, |
1778 | .probe = pch_spi_probe, | 1778 | .probe = pch_spi_probe, |
1779 | .remove = __devexit_p(pch_spi_remove), | 1779 | .remove = pch_spi_remove, |
1780 | .suspend = pch_spi_suspend, | 1780 | .suspend = pch_spi_suspend, |
1781 | .resume = pch_spi_resume, | 1781 | .resume = pch_spi_resume, |
1782 | }; | 1782 | }; |
diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 266a847e2992..4d3ec8b9f479 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c | |||
@@ -217,7 +217,7 @@ static int spi_xcomm_setup(struct spi_device *spi) | |||
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
219 | 219 | ||
220 | static int __devinit spi_xcomm_probe(struct i2c_client *i2c, | 220 | static int spi_xcomm_probe(struct i2c_client *i2c, |
221 | const struct i2c_device_id *id) | 221 | const struct i2c_device_id *id) |
222 | { | 222 | { |
223 | struct spi_xcomm *spi_xcomm; | 223 | struct spi_xcomm *spi_xcomm; |
@@ -246,7 +246,7 @@ static int __devinit spi_xcomm_probe(struct i2c_client *i2c, | |||
246 | return ret; | 246 | return ret; |
247 | } | 247 | } |
248 | 248 | ||
249 | static int __devexit spi_xcomm_remove(struct i2c_client *i2c) | 249 | static int spi_xcomm_remove(struct i2c_client *i2c) |
250 | { | 250 | { |
251 | struct spi_master *master = i2c_get_clientdata(i2c); | 251 | struct spi_master *master = i2c_get_clientdata(i2c); |
252 | 252 | ||
@@ -267,7 +267,7 @@ static struct i2c_driver spi_xcomm_driver = { | |||
267 | }, | 267 | }, |
268 | .id_table = spi_xcomm_ids, | 268 | .id_table = spi_xcomm_ids, |
269 | .probe = spi_xcomm_probe, | 269 | .probe = spi_xcomm_probe, |
270 | .remove = __devexit_p(spi_xcomm_remove), | 270 | .remove = spi_xcomm_remove, |
271 | }; | 271 | }; |
272 | module_i2c_driver(spi_xcomm_driver); | 272 | module_i2c_driver(spi_xcomm_driver); |
273 | 273 | ||
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 4c5a663b9fa8..e1d769607425 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c | |||
@@ -462,7 +462,7 @@ void xilinx_spi_deinit(struct spi_master *master) | |||
462 | } | 462 | } |
463 | EXPORT_SYMBOL(xilinx_spi_deinit); | 463 | EXPORT_SYMBOL(xilinx_spi_deinit); |
464 | 464 | ||
465 | static int __devinit xilinx_spi_probe(struct platform_device *dev) | 465 | static int xilinx_spi_probe(struct platform_device *dev) |
466 | { | 466 | { |
467 | struct xspi_platform_data *pdata; | 467 | struct xspi_platform_data *pdata; |
468 | struct resource *r; | 468 | struct resource *r; |
@@ -518,7 +518,7 @@ static int __devinit xilinx_spi_probe(struct platform_device *dev) | |||
518 | return 0; | 518 | return 0; |
519 | } | 519 | } |
520 | 520 | ||
521 | static int __devexit xilinx_spi_remove(struct platform_device *dev) | 521 | static int xilinx_spi_remove(struct platform_device *dev) |
522 | { | 522 | { |
523 | xilinx_spi_deinit(platform_get_drvdata(dev)); | 523 | xilinx_spi_deinit(platform_get_drvdata(dev)); |
524 | platform_set_drvdata(dev, 0); | 524 | platform_set_drvdata(dev, 0); |
@@ -531,7 +531,7 @@ MODULE_ALIAS("platform:" XILINX_SPI_NAME); | |||
531 | 531 | ||
532 | static struct platform_driver xilinx_spi_driver = { | 532 | static struct platform_driver xilinx_spi_driver = { |
533 | .probe = xilinx_spi_probe, | 533 | .probe = xilinx_spi_probe, |
534 | .remove = __devexit_p(xilinx_spi_remove), | 534 | .remove = xilinx_spi_remove, |
535 | .driver = { | 535 | .driver = { |
536 | .name = XILINX_SPI_NAME, | 536 | .name = XILINX_SPI_NAME, |
537 | .owner = THIS_MODULE, | 537 | .owner = THIS_MODULE, |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 718cc1f49230..ab095acdb2a8 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/mod_devicetable.h> | 31 | #include <linux/mod_devicetable.h> |
32 | #include <linux/spi/spi.h> | 32 | #include <linux/spi/spi.h> |
33 | #include <linux/of_gpio.h> | ||
33 | #include <linux/pm_runtime.h> | 34 | #include <linux/pm_runtime.h> |
34 | #include <linux/export.h> | 35 | #include <linux/export.h> |
35 | #include <linux/sched.h> | 36 | #include <linux/sched.h> |
@@ -333,6 +334,7 @@ struct spi_device *spi_alloc_device(struct spi_master *master) | |||
333 | spi->dev.parent = &master->dev; | 334 | spi->dev.parent = &master->dev; |
334 | spi->dev.bus = &spi_bus_type; | 335 | spi->dev.bus = &spi_bus_type; |
335 | spi->dev.release = spidev_release; | 336 | spi->dev.release = spidev_release; |
337 | spi->cs_gpio = -EINVAL; | ||
336 | device_initialize(&spi->dev); | 338 | device_initialize(&spi->dev); |
337 | return spi; | 339 | return spi; |
338 | } | 340 | } |
@@ -350,15 +352,16 @@ EXPORT_SYMBOL_GPL(spi_alloc_device); | |||
350 | int spi_add_device(struct spi_device *spi) | 352 | int spi_add_device(struct spi_device *spi) |
351 | { | 353 | { |
352 | static DEFINE_MUTEX(spi_add_lock); | 354 | static DEFINE_MUTEX(spi_add_lock); |
353 | struct device *dev = spi->master->dev.parent; | 355 | struct spi_master *master = spi->master; |
356 | struct device *dev = master->dev.parent; | ||
354 | struct device *d; | 357 | struct device *d; |
355 | int status; | 358 | int status; |
356 | 359 | ||
357 | /* Chipselects are numbered 0..max; validate. */ | 360 | /* Chipselects are numbered 0..max; validate. */ |
358 | if (spi->chip_select >= spi->master->num_chipselect) { | 361 | if (spi->chip_select >= master->num_chipselect) { |
359 | dev_err(dev, "cs%d >= max %d\n", | 362 | dev_err(dev, "cs%d >= max %d\n", |
360 | spi->chip_select, | 363 | spi->chip_select, |
361 | spi->master->num_chipselect); | 364 | master->num_chipselect); |
362 | return -EINVAL; | 365 | return -EINVAL; |
363 | } | 366 | } |
364 | 367 | ||
@@ -382,6 +385,9 @@ int spi_add_device(struct spi_device *spi) | |||
382 | goto done; | 385 | goto done; |
383 | } | 386 | } |
384 | 387 | ||
388 | if (master->cs_gpios) | ||
389 | spi->cs_gpio = master->cs_gpios[spi->chip_select]; | ||
390 | |||
385 | /* Drivers may modify this initial i/o setup, but will | 391 | /* Drivers may modify this initial i/o setup, but will |
386 | * normally rely on the device being setup. Devices | 392 | * normally rely on the device being setup. Devices |
387 | * using SPI_CS_HIGH can't coexist well otherwise... | 393 | * using SPI_CS_HIGH can't coexist well otherwise... |
@@ -492,8 +498,7 @@ static void spi_match_master_to_boardinfo(struct spi_master *master, | |||
492 | * The board info passed can safely be __initdata ... but be careful of | 498 | * The board info passed can safely be __initdata ... but be careful of |
493 | * any embedded pointers (platform_data, etc), they're copied as-is. | 499 | * any embedded pointers (platform_data, etc), they're copied as-is. |
494 | */ | 500 | */ |
495 | int __devinit | 501 | int spi_register_board_info(struct spi_board_info const *info, unsigned n) |
496 | spi_register_board_info(struct spi_board_info const *info, unsigned n) | ||
497 | { | 502 | { |
498 | struct boardinfo *bi; | 503 | struct boardinfo *bi; |
499 | int i; | 504 | int i; |
@@ -806,7 +811,7 @@ err_init_queue: | |||
806 | 811 | ||
807 | /*-------------------------------------------------------------------------*/ | 812 | /*-------------------------------------------------------------------------*/ |
808 | 813 | ||
809 | #if defined(CONFIG_OF) && !defined(CONFIG_SPARC) | 814 | #if defined(CONFIG_OF) |
810 | /** | 815 | /** |
811 | * of_register_spi_devices() - Register child devices onto the SPI bus | 816 | * of_register_spi_devices() - Register child devices onto the SPI bus |
812 | * @master: Pointer to spi_master device | 817 | * @master: Pointer to spi_master device |
@@ -861,6 +866,8 @@ static void of_register_spi_devices(struct spi_master *master) | |||
861 | spi->mode |= SPI_CPOL; | 866 | spi->mode |= SPI_CPOL; |
862 | if (of_find_property(nc, "spi-cs-high", NULL)) | 867 | if (of_find_property(nc, "spi-cs-high", NULL)) |
863 | spi->mode |= SPI_CS_HIGH; | 868 | spi->mode |= SPI_CS_HIGH; |
869 | if (of_find_property(nc, "spi-3wire", NULL)) | ||
870 | spi->mode |= SPI_3WIRE; | ||
864 | 871 | ||
865 | /* Device speed */ | 872 | /* Device speed */ |
866 | prop = of_get_property(nc, "spi-max-frequency", &len); | 873 | prop = of_get_property(nc, "spi-max-frequency", &len); |
@@ -1046,6 +1053,44 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size) | |||
1046 | } | 1053 | } |
1047 | EXPORT_SYMBOL_GPL(spi_alloc_master); | 1054 | EXPORT_SYMBOL_GPL(spi_alloc_master); |
1048 | 1055 | ||
1056 | #ifdef CONFIG_OF | ||
1057 | static int of_spi_register_master(struct spi_master *master) | ||
1058 | { | ||
1059 | u16 nb; | ||
1060 | int i, *cs; | ||
1061 | struct device_node *np = master->dev.of_node; | ||
1062 | |||
1063 | if (!np) | ||
1064 | return 0; | ||
1065 | |||
1066 | nb = of_gpio_named_count(np, "cs-gpios"); | ||
1067 | master->num_chipselect = max(nb, master->num_chipselect); | ||
1068 | |||
1069 | if (nb < 1) | ||
1070 | return 0; | ||
1071 | |||
1072 | cs = devm_kzalloc(&master->dev, | ||
1073 | sizeof(int) * master->num_chipselect, | ||
1074 | GFP_KERNEL); | ||
1075 | master->cs_gpios = cs; | ||
1076 | |||
1077 | if (!master->cs_gpios) | ||
1078 | return -ENOMEM; | ||
1079 | |||
1080 | memset(cs, -EINVAL, master->num_chipselect); | ||
1081 | |||
1082 | for (i = 0; i < nb; i++) | ||
1083 | cs[i] = of_get_named_gpio(np, "cs-gpios", i); | ||
1084 | |||
1085 | return 0; | ||
1086 | } | ||
1087 | #else | ||
1088 | static int of_spi_register_master(struct spi_master *master) | ||
1089 | { | ||
1090 | return 0; | ||
1091 | } | ||
1092 | #endif | ||
1093 | |||
1049 | /** | 1094 | /** |
1050 | * spi_register_master - register SPI master controller | 1095 | * spi_register_master - register SPI master controller |
1051 | * @master: initialized master, originally from spi_alloc_master() | 1096 | * @master: initialized master, originally from spi_alloc_master() |
@@ -1077,6 +1122,10 @@ int spi_register_master(struct spi_master *master) | |||
1077 | if (!dev) | 1122 | if (!dev) |
1078 | return -ENODEV; | 1123 | return -ENODEV; |
1079 | 1124 | ||
1125 | status = of_spi_register_master(master); | ||
1126 | if (status) | ||
1127 | return status; | ||
1128 | |||
1080 | /* even if it's just one always-selected device, there must | 1129 | /* even if it's just one always-selected device, there must |
1081 | * be at least one chipselect | 1130 | * be at least one chipselect |
1082 | */ | 1131 | */ |
@@ -1257,7 +1306,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master); | |||
1257 | int spi_setup(struct spi_device *spi) | 1306 | int spi_setup(struct spi_device *spi) |
1258 | { | 1307 | { |
1259 | unsigned bad_bits; | 1308 | unsigned bad_bits; |
1260 | int status; | 1309 | int status = 0; |
1261 | 1310 | ||
1262 | /* help drivers fail *cleanly* when they need options | 1311 | /* help drivers fail *cleanly* when they need options |
1263 | * that aren't supported with their current master | 1312 | * that aren't supported with their current master |
@@ -1272,7 +1321,8 @@ int spi_setup(struct spi_device *spi) | |||
1272 | if (!spi->bits_per_word) | 1321 | if (!spi->bits_per_word) |
1273 | spi->bits_per_word = 8; | 1322 | spi->bits_per_word = 8; |
1274 | 1323 | ||
1275 | status = spi->master->setup(spi); | 1324 | if (spi->master->setup) |
1325 | status = spi->master->setup(spi); | ||
1276 | 1326 | ||
1277 | dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s" | 1327 | dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s" |
1278 | "%u bits/w, %u Hz max --> %d\n", | 1328 | "%u bits/w, %u Hz max --> %d\n", |
@@ -1291,6 +1341,7 @@ EXPORT_SYMBOL_GPL(spi_setup); | |||
1291 | static int __spi_async(struct spi_device *spi, struct spi_message *message) | 1341 | static int __spi_async(struct spi_device *spi, struct spi_message *message) |
1292 | { | 1342 | { |
1293 | struct spi_master *master = spi->master; | 1343 | struct spi_master *master = spi->master; |
1344 | struct spi_transfer *xfer; | ||
1294 | 1345 | ||
1295 | /* Half-duplex links include original MicroWire, and ones with | 1346 | /* Half-duplex links include original MicroWire, and ones with |
1296 | * only one data pin like SPI_3WIRE (switches direction) or where | 1347 | * only one data pin like SPI_3WIRE (switches direction) or where |
@@ -1299,7 +1350,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) | |||
1299 | */ | 1350 | */ |
1300 | if ((master->flags & SPI_MASTER_HALF_DUPLEX) | 1351 | if ((master->flags & SPI_MASTER_HALF_DUPLEX) |
1301 | || (spi->mode & SPI_3WIRE)) { | 1352 | || (spi->mode & SPI_3WIRE)) { |
1302 | struct spi_transfer *xfer; | ||
1303 | unsigned flags = master->flags; | 1353 | unsigned flags = master->flags; |
1304 | 1354 | ||
1305 | list_for_each_entry(xfer, &message->transfers, transfer_list) { | 1355 | list_for_each_entry(xfer, &message->transfers, transfer_list) { |
@@ -1312,6 +1362,15 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) | |||
1312 | } | 1362 | } |
1313 | } | 1363 | } |
1314 | 1364 | ||
1365 | /** | ||
1366 | * Set transfer bits_per_word as spi device default if it is not | ||
1367 | * set for this transfer. | ||
1368 | */ | ||
1369 | list_for_each_entry(xfer, &message->transfers, transfer_list) { | ||
1370 | if (!xfer->bits_per_word) | ||
1371 | xfer->bits_per_word = spi->bits_per_word; | ||
1372 | } | ||
1373 | |||
1315 | message->spi = spi; | 1374 | message->spi = spi; |
1316 | message->status = -EINPROGRESS; | 1375 | message->status = -EINPROGRESS; |
1317 | return master->transfer(spi, message); | 1376 | return master->transfer(spi, message); |
@@ -1588,12 +1647,18 @@ int spi_write_then_read(struct spi_device *spi, | |||
1588 | struct spi_transfer x[2]; | 1647 | struct spi_transfer x[2]; |
1589 | u8 *local_buf; | 1648 | u8 *local_buf; |
1590 | 1649 | ||
1591 | /* Use preallocated DMA-safe buffer. We can't avoid copying here, | 1650 | /* Use preallocated DMA-safe buffer if we can. We can't avoid |
1592 | * (as a pure convenience thing), but we can keep heap costs | 1651 | * copying here, (as a pure convenience thing), but we can |
1593 | * out of the hot path ... | 1652 | * keep heap costs out of the hot path unless someone else is |
1653 | * using the pre-allocated buffer or the transfer is too large. | ||
1594 | */ | 1654 | */ |
1595 | if ((n_tx + n_rx) > SPI_BUFSIZ) | 1655 | if ((n_tx + n_rx) > SPI_BUFSIZ || !mutex_trylock(&lock)) { |
1596 | return -EINVAL; | 1656 | local_buf = kmalloc(max((unsigned)SPI_BUFSIZ, n_tx + n_rx), GFP_KERNEL); |
1657 | if (!local_buf) | ||
1658 | return -ENOMEM; | ||
1659 | } else { | ||
1660 | local_buf = buf; | ||
1661 | } | ||
1597 | 1662 | ||
1598 | spi_message_init(&message); | 1663 | spi_message_init(&message); |
1599 | memset(x, 0, sizeof x); | 1664 | memset(x, 0, sizeof x); |
@@ -1606,14 +1671,6 @@ int spi_write_then_read(struct spi_device *spi, | |||
1606 | spi_message_add_tail(&x[1], &message); | 1671 | spi_message_add_tail(&x[1], &message); |
1607 | } | 1672 | } |
1608 | 1673 | ||
1609 | /* ... unless someone else is using the pre-allocated buffer */ | ||
1610 | if (!mutex_trylock(&lock)) { | ||
1611 | local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL); | ||
1612 | if (!local_buf) | ||
1613 | return -ENOMEM; | ||
1614 | } else | ||
1615 | local_buf = buf; | ||
1616 | |||
1617 | memcpy(local_buf, txbuf, n_tx); | 1674 | memcpy(local_buf, txbuf, n_tx); |
1618 | x[0].tx_buf = local_buf; | 1675 | x[0].tx_buf = local_buf; |
1619 | x[1].rx_buf = local_buf + n_tx; | 1676 | x[1].rx_buf = local_buf + n_tx; |
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 830adbed1d7a..2e0655dbe070 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/compat.h> | 33 | #include <linux/compat.h> |
34 | #include <linux/of.h> | ||
35 | #include <linux/of_device.h> | ||
34 | 36 | ||
35 | #include <linux/spi/spi.h> | 37 | #include <linux/spi/spi.h> |
36 | #include <linux/spi/spidev.h> | 38 | #include <linux/spi/spidev.h> |
@@ -571,7 +573,7 @@ static struct class *spidev_class; | |||
571 | 573 | ||
572 | /*-------------------------------------------------------------------------*/ | 574 | /*-------------------------------------------------------------------------*/ |
573 | 575 | ||
574 | static int __devinit spidev_probe(struct spi_device *spi) | 576 | static int spidev_probe(struct spi_device *spi) |
575 | { | 577 | { |
576 | struct spidev_data *spidev; | 578 | struct spidev_data *spidev; |
577 | int status; | 579 | int status; |
@@ -620,7 +622,7 @@ static int __devinit spidev_probe(struct spi_device *spi) | |||
620 | return status; | 622 | return status; |
621 | } | 623 | } |
622 | 624 | ||
623 | static int __devexit spidev_remove(struct spi_device *spi) | 625 | static int spidev_remove(struct spi_device *spi) |
624 | { | 626 | { |
625 | struct spidev_data *spidev = spi_get_drvdata(spi); | 627 | struct spidev_data *spidev = spi_get_drvdata(spi); |
626 | 628 | ||
@@ -642,13 +644,21 @@ static int __devexit spidev_remove(struct spi_device *spi) | |||
642 | return 0; | 644 | return 0; |
643 | } | 645 | } |
644 | 646 | ||
647 | static const struct of_device_id spidev_dt_ids[] = { | ||
648 | { .compatible = "rohm,dh2228fv" }, | ||
649 | {}, | ||
650 | }; | ||
651 | |||
652 | MODULE_DEVICE_TABLE(of, spidev_dt_ids); | ||
653 | |||
645 | static struct spi_driver spidev_spi_driver = { | 654 | static struct spi_driver spidev_spi_driver = { |
646 | .driver = { | 655 | .driver = { |
647 | .name = "spidev", | 656 | .name = "spidev", |
648 | .owner = THIS_MODULE, | 657 | .owner = THIS_MODULE, |
658 | .of_match_table = of_match_ptr(spidev_dt_ids), | ||
649 | }, | 659 | }, |
650 | .probe = spidev_probe, | 660 | .probe = spidev_probe, |
651 | .remove = __devexit_p(spidev_remove), | 661 | .remove = spidev_remove, |
652 | 662 | ||
653 | /* NOTE: suspend/resume methods are not necessary here. | 663 | /* NOTE: suspend/resume methods are not necessary here. |
654 | * We don't do anything except pass the requests to/from | 664 | * We don't do anything except pass the requests to/from |