aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/Kconfig16
-rw-r--r--drivers/spi/Makefile1
-rw-r--r--drivers/spi/amba-pl022.c2
-rw-r--r--drivers/spi/davinci_spi.c11
-rw-r--r--drivers/spi/mpc512x_psc_spi.c9
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c9
-rw-r--r--drivers/spi/mpc52xx_spi.c9
-rw-r--r--drivers/spi/pxa2xx_spi.c2
-rw-r--r--drivers/spi/pxa2xx_spi_pci.c2
-rw-r--r--drivers/spi/spi_fsl_espi.c11
-rw-r--r--drivers/spi/spi_fsl_lib.c3
-rw-r--r--drivers/spi/spi_fsl_lib.h3
-rw-r--r--drivers/spi/spi_fsl_spi.c11
-rw-r--r--drivers/spi/spi_ppc4xx.c9
-rw-r--r--drivers/spi/ti-ssp-spi.c402
-rw-r--r--drivers/spi/xilinx_spi.c6
16 files changed, 448 insertions, 58 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index bb233a9cbad2..7b90fc361b52 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -161,13 +161,13 @@ config SPI_IMX_VER_0_0
161 def_bool y if SOC_IMX21 || SOC_IMX27 161 def_bool y if SOC_IMX21 || SOC_IMX27
162 162
163config SPI_IMX_VER_0_4 163config SPI_IMX_VER_0_4
164 def_bool y if ARCH_MX31 164 def_bool y if SOC_IMX31
165 165
166config SPI_IMX_VER_0_7 166config SPI_IMX_VER_0_7
167 def_bool y if ARCH_MX25 || ARCH_MX35 || ARCH_MX51 || ARCH_MX53 167 def_bool y if ARCH_MX25 || SOC_IMX35 || SOC_IMX51 || SOC_IMX53
168 168
169config SPI_IMX_VER_2_3 169config SPI_IMX_VER_2_3
170 def_bool y if ARCH_MX51 || ARCH_MX53 170 def_bool y if SOC_IMX51 || SOC_IMX53
171 171
172config SPI_IMX 172config SPI_IMX
173 tristate "Freescale i.MX SPI controllers" 173 tristate "Freescale i.MX SPI controllers"
@@ -350,6 +350,16 @@ config SPI_TEGRA
350 help 350 help
351 SPI driver for NVidia Tegra SoCs 351 SPI driver for NVidia Tegra SoCs
352 352
353config SPI_TI_SSP
354 tristate "TI Sequencer Serial Port - SPI Support"
355 depends on MFD_TI_SSP
356 help
357 This selects an SPI master implementation using a TI sequencer
358 serial port.
359
360 To compile this driver as a module, choose M here: the
361 module will be called ti-ssp-spi.
362
353config SPI_TOPCLIFF_PCH 363config SPI_TOPCLIFF_PCH
354 tristate "Topcliff PCH SPI Controller" 364 tristate "Topcliff PCH SPI Controller"
355 depends on PCI 365 depends on PCI
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 86d1b5f9bbd9..f3f31d988358 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -43,6 +43,7 @@ obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
43obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx_hw.o 43obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx_hw.o
44obj-$(CONFIG_SPI_S3C64XX) += spi_s3c64xx.o 44obj-$(CONFIG_SPI_S3C64XX) += spi_s3c64xx.o
45obj-$(CONFIG_SPI_TEGRA) += spi_tegra.o 45obj-$(CONFIG_SPI_TEGRA) += spi_tegra.o
46obj-$(CONFIG_SPI_TI_SSP) += ti-ssp-spi.o
46obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi_topcliff_pch.o 47obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi_topcliff_pch.o
47obj-$(CONFIG_SPI_TXX9) += spi_txx9.o 48obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
48obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o 49obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index 71a1219a995d..95e58c70a2c9 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -2021,7 +2021,7 @@ static void pl022_cleanup(struct spi_device *spi)
2021 2021
2022 2022
2023static int __devinit 2023static int __devinit
2024pl022_probe(struct amba_device *adev, struct amba_id *id) 2024pl022_probe(struct amba_device *adev, const struct amba_id *id)
2025{ 2025{
2026 struct device *dev = &adev->dev; 2026 struct device *dev = &adev->dev;
2027 struct pl022_ssp_controller *platform_info = adev->dev.platform_data; 2027 struct pl022_ssp_controller *platform_info = adev->dev.platform_data;
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index 6beab99bf95b..166a879fd9e8 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -790,7 +790,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
790 struct resource *r, *mem; 790 struct resource *r, *mem;
791 resource_size_t dma_rx_chan = SPI_NO_RESOURCE; 791 resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
792 resource_size_t dma_tx_chan = SPI_NO_RESOURCE; 792 resource_size_t dma_tx_chan = SPI_NO_RESOURCE;
793 resource_size_t dma_eventq = SPI_NO_RESOURCE;
794 int i = 0, ret = 0; 793 int i = 0, ret = 0;
795 u32 spipc0; 794 u32 spipc0;
796 795
@@ -878,17 +877,13 @@ static int davinci_spi_probe(struct platform_device *pdev)
878 r = platform_get_resource(pdev, IORESOURCE_DMA, 1); 877 r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
879 if (r) 878 if (r)
880 dma_tx_chan = r->start; 879 dma_tx_chan = r->start;
881 r = platform_get_resource(pdev, IORESOURCE_DMA, 2);
882 if (r)
883 dma_eventq = r->start;
884 880
885 dspi->bitbang.txrx_bufs = davinci_spi_bufs; 881 dspi->bitbang.txrx_bufs = davinci_spi_bufs;
886 if (dma_rx_chan != SPI_NO_RESOURCE && 882 if (dma_rx_chan != SPI_NO_RESOURCE &&
887 dma_tx_chan != SPI_NO_RESOURCE && 883 dma_tx_chan != SPI_NO_RESOURCE) {
888 dma_eventq != SPI_NO_RESOURCE) {
889 dspi->dma.rx_channel = dma_rx_chan; 884 dspi->dma.rx_channel = dma_rx_chan;
890 dspi->dma.tx_channel = dma_tx_chan; 885 dspi->dma.tx_channel = dma_tx_chan;
891 dspi->dma.eventq = dma_eventq; 886 dspi->dma.eventq = pdata->dma_event_q;
892 887
893 ret = davinci_spi_request_dma(dspi); 888 ret = davinci_spi_request_dma(dspi);
894 if (ret) 889 if (ret)
@@ -897,7 +892,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
897 dev_info(&pdev->dev, "DMA: supported\n"); 892 dev_info(&pdev->dev, "DMA: supported\n");
898 dev_info(&pdev->dev, "DMA: RX channel: %d, TX channel: %d, " 893 dev_info(&pdev->dev, "DMA: RX channel: %d, TX channel: %d, "
899 "event queue: %d\n", dma_rx_chan, dma_tx_chan, 894 "event queue: %d\n", dma_rx_chan, dma_tx_chan,
900 dma_eventq); 895 pdata->dma_event_q);
901 } 896 }
902 897
903 dspi->get_rx = davinci_spi_rx_buf_u8; 898 dspi->get_rx = davinci_spi_rx_buf_u8;
diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/mpc512x_psc_spi.c
index 77d9e7ee8b27..6a5b4238fb6b 100644
--- a/drivers/spi/mpc512x_psc_spi.c
+++ b/drivers/spi/mpc512x_psc_spi.c
@@ -507,8 +507,7 @@ static int __devexit mpc512x_psc_spi_do_remove(struct device *dev)
507 return 0; 507 return 0;
508} 508}
509 509
510static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op, 510static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op)
511 const struct of_device_id *match)
512{ 511{
513 const u32 *regaddr_p; 512 const u32 *regaddr_p;
514 u64 regaddr64, size64; 513 u64 regaddr64, size64;
@@ -551,7 +550,7 @@ static struct of_device_id mpc512x_psc_spi_of_match[] = {
551 550
552MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match); 551MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match);
553 552
554static struct of_platform_driver mpc512x_psc_spi_of_driver = { 553static struct platform_driver mpc512x_psc_spi_of_driver = {
555 .probe = mpc512x_psc_spi_of_probe, 554 .probe = mpc512x_psc_spi_of_probe,
556 .remove = __devexit_p(mpc512x_psc_spi_of_remove), 555 .remove = __devexit_p(mpc512x_psc_spi_of_remove),
557 .driver = { 556 .driver = {
@@ -563,13 +562,13 @@ static struct of_platform_driver mpc512x_psc_spi_of_driver = {
563 562
564static int __init mpc512x_psc_spi_init(void) 563static int __init mpc512x_psc_spi_init(void)
565{ 564{
566 return of_register_platform_driver(&mpc512x_psc_spi_of_driver); 565 return platform_driver_register(&mpc512x_psc_spi_of_driver);
567} 566}
568module_init(mpc512x_psc_spi_init); 567module_init(mpc512x_psc_spi_init);
569 568
570static void __exit mpc512x_psc_spi_exit(void) 569static void __exit mpc512x_psc_spi_exit(void)
571{ 570{
572 of_unregister_platform_driver(&mpc512x_psc_spi_of_driver); 571 platform_driver_unregister(&mpc512x_psc_spi_of_driver);
573} 572}
574module_exit(mpc512x_psc_spi_exit); 573module_exit(mpc512x_psc_spi_exit);
575 574
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 8a904c1c8485..e30baf0852ac 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -450,8 +450,7 @@ free_master:
450 return ret; 450 return ret;
451} 451}
452 452
453static int __devinit mpc52xx_psc_spi_of_probe(struct platform_device *op, 453static int __devinit mpc52xx_psc_spi_of_probe(struct platform_device *op)
454 const struct of_device_id *match)
455{ 454{
456 const u32 *regaddr_p; 455 const u32 *regaddr_p;
457 u64 regaddr64, size64; 456 u64 regaddr64, size64;
@@ -503,7 +502,7 @@ static const struct of_device_id mpc52xx_psc_spi_of_match[] = {
503 502
504MODULE_DEVICE_TABLE(of, mpc52xx_psc_spi_of_match); 503MODULE_DEVICE_TABLE(of, mpc52xx_psc_spi_of_match);
505 504
506static struct of_platform_driver mpc52xx_psc_spi_of_driver = { 505static struct platform_driver mpc52xx_psc_spi_of_driver = {
507 .probe = mpc52xx_psc_spi_of_probe, 506 .probe = mpc52xx_psc_spi_of_probe,
508 .remove = __devexit_p(mpc52xx_psc_spi_of_remove), 507 .remove = __devexit_p(mpc52xx_psc_spi_of_remove),
509 .driver = { 508 .driver = {
@@ -515,13 +514,13 @@ static struct of_platform_driver mpc52xx_psc_spi_of_driver = {
515 514
516static int __init mpc52xx_psc_spi_init(void) 515static int __init mpc52xx_psc_spi_init(void)
517{ 516{
518 return of_register_platform_driver(&mpc52xx_psc_spi_of_driver); 517 return platform_driver_register(&mpc52xx_psc_spi_of_driver);
519} 518}
520module_init(mpc52xx_psc_spi_init); 519module_init(mpc52xx_psc_spi_init);
521 520
522static void __exit mpc52xx_psc_spi_exit(void) 521static void __exit mpc52xx_psc_spi_exit(void)
523{ 522{
524 of_unregister_platform_driver(&mpc52xx_psc_spi_of_driver); 523 platform_driver_unregister(&mpc52xx_psc_spi_of_driver);
525} 524}
526module_exit(mpc52xx_psc_spi_exit); 525module_exit(mpc52xx_psc_spi_exit);
527 526
diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
index 84439f655601..015a974bed72 100644
--- a/drivers/spi/mpc52xx_spi.c
+++ b/drivers/spi/mpc52xx_spi.c
@@ -390,8 +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 */
393static int __devinit mpc52xx_spi_probe(struct platform_device *op, 393static int __devinit mpc52xx_spi_probe(struct platform_device *op)
394 const struct of_device_id *match)
395{ 394{
396 struct spi_master *master; 395 struct spi_master *master;
397 struct mpc52xx_spi *ms; 396 struct mpc52xx_spi *ms;
@@ -556,7 +555,7 @@ static const struct of_device_id mpc52xx_spi_match[] __devinitconst = {
556}; 555};
557MODULE_DEVICE_TABLE(of, mpc52xx_spi_match); 556MODULE_DEVICE_TABLE(of, mpc52xx_spi_match);
558 557
559static struct of_platform_driver mpc52xx_spi_of_driver = { 558static struct platform_driver mpc52xx_spi_of_driver = {
560 .driver = { 559 .driver = {
561 .name = "mpc52xx-spi", 560 .name = "mpc52xx-spi",
562 .owner = THIS_MODULE, 561 .owner = THIS_MODULE,
@@ -568,13 +567,13 @@ static struct of_platform_driver mpc52xx_spi_of_driver = {
568 567
569static int __init mpc52xx_spi_init(void) 568static int __init mpc52xx_spi_init(void)
570{ 569{
571 return of_register_platform_driver(&mpc52xx_spi_of_driver); 570 return platform_driver_register(&mpc52xx_spi_of_driver);
572} 571}
573module_init(mpc52xx_spi_init); 572module_init(mpc52xx_spi_init);
574 573
575static void __exit mpc52xx_spi_exit(void) 574static void __exit mpc52xx_spi_exit(void)
576{ 575{
577 of_unregister_platform_driver(&mpc52xx_spi_of_driver); 576 platform_driver_unregister(&mpc52xx_spi_of_driver);
578} 577}
579module_exit(mpc52xx_spi_exit); 578module_exit(mpc52xx_spi_exit);
580 579
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 95928833855b..a429b01d0285 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1557,9 +1557,7 @@ static int __devinit pxa2xx_spi_probe(struct platform_device *pdev)
1557 drv_data->ssp = ssp; 1557 drv_data->ssp = ssp;
1558 1558
1559 master->dev.parent = &pdev->dev; 1559 master->dev.parent = &pdev->dev;
1560#ifdef CONFIG_OF
1561 master->dev.of_node = pdev->dev.of_node; 1560 master->dev.of_node = pdev->dev.of_node;
1562#endif
1563 /* the spi->mode bits understood by this driver: */ 1561 /* the spi->mode bits understood by this driver: */
1564 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1562 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1565 1563
diff --git a/drivers/spi/pxa2xx_spi_pci.c b/drivers/spi/pxa2xx_spi_pci.c
index 19752b09e155..378e504f89eb 100644
--- a/drivers/spi/pxa2xx_spi_pci.c
+++ b/drivers/spi/pxa2xx_spi_pci.c
@@ -89,9 +89,7 @@ static int __devinit ce4100_spi_probe(struct pci_dev *dev,
89 goto err_nomem; 89 goto err_nomem;
90 90
91 pdev->dev.parent = &dev->dev; 91 pdev->dev.parent = &dev->dev;
92#ifdef CONFIG_OF
93 pdev->dev.of_node = dev->dev.of_node; 92 pdev->dev.of_node = dev->dev.of_node;
94#endif
95 ssp = &spi_info->ssp; 93 ssp = &spi_info->ssp;
96 ssp->phys_base = pci_resource_start(dev, 0); 94 ssp->phys_base = pci_resource_start(dev, 0);
97 ssp->mmio_base = ioremap(phys_beg, phys_len); 95 ssp->mmio_base = ioremap(phys_beg, phys_len);
diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c
index a99e2333b949..900e921ab80e 100644
--- a/drivers/spi/spi_fsl_espi.c
+++ b/drivers/spi/spi_fsl_espi.c
@@ -685,8 +685,7 @@ static int of_fsl_espi_get_chipselects(struct device *dev)
685 return 0; 685 return 0;
686} 686}
687 687
688static int __devinit of_fsl_espi_probe(struct platform_device *ofdev, 688static int __devinit of_fsl_espi_probe(struct platform_device *ofdev)
689 const struct of_device_id *ofid)
690{ 689{
691 struct device *dev = &ofdev->dev; 690 struct device *dev = &ofdev->dev;
692 struct device_node *np = ofdev->dev.of_node; 691 struct device_node *np = ofdev->dev.of_node;
@@ -695,7 +694,7 @@ static int __devinit of_fsl_espi_probe(struct platform_device *ofdev,
695 struct resource irq; 694 struct resource irq;
696 int ret = -ENOMEM; 695 int ret = -ENOMEM;
697 696
698 ret = of_mpc8xxx_spi_probe(ofdev, ofid); 697 ret = of_mpc8xxx_spi_probe(ofdev);
699 if (ret) 698 if (ret)
700 return ret; 699 return ret;
701 700
@@ -736,7 +735,7 @@ static const struct of_device_id of_fsl_espi_match[] = {
736}; 735};
737MODULE_DEVICE_TABLE(of, of_fsl_espi_match); 736MODULE_DEVICE_TABLE(of, of_fsl_espi_match);
738 737
739static struct of_platform_driver fsl_espi_driver = { 738static struct platform_driver fsl_espi_driver = {
740 .driver = { 739 .driver = {
741 .name = "fsl_espi", 740 .name = "fsl_espi",
742 .owner = THIS_MODULE, 741 .owner = THIS_MODULE,
@@ -748,13 +747,13 @@ static struct of_platform_driver fsl_espi_driver = {
748 747
749static int __init fsl_espi_init(void) 748static int __init fsl_espi_init(void)
750{ 749{
751 return of_register_platform_driver(&fsl_espi_driver); 750 return platform_driver_register(&fsl_espi_driver);
752} 751}
753module_init(fsl_espi_init); 752module_init(fsl_espi_init);
754 753
755static void __exit fsl_espi_exit(void) 754static void __exit fsl_espi_exit(void)
756{ 755{
757 of_unregister_platform_driver(&fsl_espi_driver); 756 platform_driver_unregister(&fsl_espi_driver);
758} 757}
759module_exit(fsl_espi_exit); 758module_exit(fsl_espi_exit);
760 759
diff --git a/drivers/spi/spi_fsl_lib.c b/drivers/spi/spi_fsl_lib.c
index 5cd741fdb5c3..ff59f42ae990 100644
--- a/drivers/spi/spi_fsl_lib.c
+++ b/drivers/spi/spi_fsl_lib.c
@@ -189,8 +189,7 @@ int __devexit mpc8xxx_spi_remove(struct device *dev)
189 return 0; 189 return 0;
190} 190}
191 191
192int __devinit of_mpc8xxx_spi_probe(struct platform_device *ofdev, 192int __devinit of_mpc8xxx_spi_probe(struct platform_device *ofdev)
193 const struct of_device_id *ofid)
194{ 193{
195 struct device *dev = &ofdev->dev; 194 struct device *dev = &ofdev->dev;
196 struct device_node *np = ofdev->dev.of_node; 195 struct device_node *np = ofdev->dev.of_node;
diff --git a/drivers/spi/spi_fsl_lib.h b/drivers/spi/spi_fsl_lib.h
index 281e060977cd..cbe881b9ea76 100644
--- a/drivers/spi/spi_fsl_lib.h
+++ b/drivers/spi/spi_fsl_lib.h
@@ -118,7 +118,6 @@ extern const char *mpc8xxx_spi_strmode(unsigned int flags);
118extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, 118extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
119 unsigned int irq); 119 unsigned int irq);
120extern int mpc8xxx_spi_remove(struct device *dev); 120extern int mpc8xxx_spi_remove(struct device *dev);
121extern int of_mpc8xxx_spi_probe(struct platform_device *ofdev, 121extern int of_mpc8xxx_spi_probe(struct platform_device *ofdev);
122 const struct of_device_id *ofid);
123 122
124#endif /* __SPI_FSL_LIB_H__ */ 123#endif /* __SPI_FSL_LIB_H__ */
diff --git a/drivers/spi/spi_fsl_spi.c b/drivers/spi/spi_fsl_spi.c
index 7ca52d3ae8f8..7963c9b49566 100644
--- a/drivers/spi/spi_fsl_spi.c
+++ b/drivers/spi/spi_fsl_spi.c
@@ -1042,8 +1042,7 @@ static int of_fsl_spi_free_chipselects(struct device *dev)
1042 return 0; 1042 return 0;
1043} 1043}
1044 1044
1045static int __devinit of_fsl_spi_probe(struct platform_device *ofdev, 1045static int __devinit of_fsl_spi_probe(struct platform_device *ofdev)
1046 const struct of_device_id *ofid)
1047{ 1046{
1048 struct device *dev = &ofdev->dev; 1047 struct device *dev = &ofdev->dev;
1049 struct device_node *np = ofdev->dev.of_node; 1048 struct device_node *np = ofdev->dev.of_node;
@@ -1052,7 +1051,7 @@ static int __devinit of_fsl_spi_probe(struct platform_device *ofdev,
1052 struct resource irq; 1051 struct resource irq;
1053 int ret = -ENOMEM; 1052 int ret = -ENOMEM;
1054 1053
1055 ret = of_mpc8xxx_spi_probe(ofdev, ofid); 1054 ret = of_mpc8xxx_spi_probe(ofdev);
1056 if (ret) 1055 if (ret)
1057 return ret; 1056 return ret;
1058 1057
@@ -1100,7 +1099,7 @@ static const struct of_device_id of_fsl_spi_match[] = {
1100}; 1099};
1101MODULE_DEVICE_TABLE(of, of_fsl_spi_match); 1100MODULE_DEVICE_TABLE(of, of_fsl_spi_match);
1102 1101
1103static struct of_platform_driver of_fsl_spi_driver = { 1102static struct platform_driver of_fsl_spi_driver = {
1104 .driver = { 1103 .driver = {
1105 .name = "fsl_spi", 1104 .name = "fsl_spi",
1106 .owner = THIS_MODULE, 1105 .owner = THIS_MODULE,
@@ -1177,13 +1176,13 @@ static void __exit legacy_driver_unregister(void) {}
1177static int __init fsl_spi_init(void) 1176static int __init fsl_spi_init(void)
1178{ 1177{
1179 legacy_driver_register(); 1178 legacy_driver_register();
1180 return of_register_platform_driver(&of_fsl_spi_driver); 1179 return platform_driver_register(&of_fsl_spi_driver);
1181} 1180}
1182module_init(fsl_spi_init); 1181module_init(fsl_spi_init);
1183 1182
1184static void __exit fsl_spi_exit(void) 1183static void __exit fsl_spi_exit(void)
1185{ 1184{
1186 of_unregister_platform_driver(&of_fsl_spi_driver); 1185 platform_driver_unregister(&of_fsl_spi_driver);
1187 legacy_driver_unregister(); 1186 legacy_driver_unregister();
1188} 1187}
1189module_exit(fsl_spi_exit); 1188module_exit(fsl_spi_exit);
diff --git a/drivers/spi/spi_ppc4xx.c b/drivers/spi/spi_ppc4xx.c
index 80e172d3e72a..2a298c029194 100644
--- a/drivers/spi/spi_ppc4xx.c
+++ b/drivers/spi/spi_ppc4xx.c
@@ -390,8 +390,7 @@ static void free_gpios(struct ppc4xx_spi *hw)
390/* 390/*
391 * platform_device layer stuff... 391 * platform_device layer stuff...
392 */ 392 */
393static int __init spi_ppc4xx_of_probe(struct platform_device *op, 393static int __init spi_ppc4xx_of_probe(struct platform_device *op)
394 const struct of_device_id *match)
395{ 394{
396 struct ppc4xx_spi *hw; 395 struct ppc4xx_spi *hw;
397 struct spi_master *master; 396 struct spi_master *master;
@@ -586,7 +585,7 @@ static const struct of_device_id spi_ppc4xx_of_match[] = {
586 585
587MODULE_DEVICE_TABLE(of, spi_ppc4xx_of_match); 586MODULE_DEVICE_TABLE(of, spi_ppc4xx_of_match);
588 587
589static struct of_platform_driver spi_ppc4xx_of_driver = { 588static struct platform_driver spi_ppc4xx_of_driver = {
590 .probe = spi_ppc4xx_of_probe, 589 .probe = spi_ppc4xx_of_probe,
591 .remove = __exit_p(spi_ppc4xx_of_remove), 590 .remove = __exit_p(spi_ppc4xx_of_remove),
592 .driver = { 591 .driver = {
@@ -598,13 +597,13 @@ static struct of_platform_driver spi_ppc4xx_of_driver = {
598 597
599static int __init spi_ppc4xx_init(void) 598static int __init spi_ppc4xx_init(void)
600{ 599{
601 return of_register_platform_driver(&spi_ppc4xx_of_driver); 600 return platform_driver_register(&spi_ppc4xx_of_driver);
602} 601}
603module_init(spi_ppc4xx_init); 602module_init(spi_ppc4xx_init);
604 603
605static void __exit spi_ppc4xx_exit(void) 604static void __exit spi_ppc4xx_exit(void)
606{ 605{
607 of_unregister_platform_driver(&spi_ppc4xx_of_driver); 606 platform_driver_unregister(&spi_ppc4xx_of_driver);
608} 607}
609module_exit(spi_ppc4xx_exit); 608module_exit(spi_ppc4xx_exit);
610 609
diff --git a/drivers/spi/ti-ssp-spi.c b/drivers/spi/ti-ssp-spi.c
new file mode 100644
index 000000000000..ee22795c7973
--- /dev/null
+++ b/drivers/spi/ti-ssp-spi.c
@@ -0,0 +1,402 @@
1/*
2 * Sequencer Serial Port (SSP) based SPI master driver
3 *
4 * Copyright (C) 2010 Texas Instruments Inc
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 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/err.h>
23#include <linux/completion.h>
24#include <linux/delay.h>
25#include <linux/platform_device.h>
26#include <linux/spi/spi.h>
27#include <linux/mfd/ti_ssp.h>
28
29#define MODE_BITS (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH)
30
31struct ti_ssp_spi {
32 struct spi_master *master;
33 struct device *dev;
34 spinlock_t lock;
35 struct list_head msg_queue;
36 struct completion complete;
37 bool shutdown;
38 struct workqueue_struct *workqueue;
39 struct work_struct work;
40 u8 mode, bpw;
41 int cs_active;
42 u32 pc_en, pc_dis, pc_wr, pc_rd;
43 void (*select)(int cs);
44};
45
46static u32 ti_ssp_spi_rx(struct ti_ssp_spi *hw)
47{
48 u32 ret;
49
50 ti_ssp_run(hw->dev, hw->pc_rd, 0, &ret);
51 return ret;
52}
53
54static void ti_ssp_spi_tx(struct ti_ssp_spi *hw, u32 data)
55{
56 ti_ssp_run(hw->dev, hw->pc_wr, data << (32 - hw->bpw), NULL);
57}
58
59static int ti_ssp_spi_txrx(struct ti_ssp_spi *hw, struct spi_message *msg,
60 struct spi_transfer *t)
61{
62 int count;
63
64 if (hw->bpw <= 8) {
65 u8 *rx = t->rx_buf;
66 const u8 *tx = t->tx_buf;
67
68 for (count = 0; count < t->len; count += 1) {
69 if (t->tx_buf)
70 ti_ssp_spi_tx(hw, *tx++);
71 if (t->rx_buf)
72 *rx++ = ti_ssp_spi_rx(hw);
73 }
74 } else if (hw->bpw <= 16) {
75 u16 *rx = t->rx_buf;
76 const u16 *tx = t->tx_buf;
77
78 for (count = 0; count < t->len; count += 2) {
79 if (t->tx_buf)
80 ti_ssp_spi_tx(hw, *tx++);
81 if (t->rx_buf)
82 *rx++ = ti_ssp_spi_rx(hw);
83 }
84 } else {
85 u32 *rx = t->rx_buf;
86 const u32 *tx = t->tx_buf;
87
88 for (count = 0; count < t->len; count += 4) {
89 if (t->tx_buf)
90 ti_ssp_spi_tx(hw, *tx++);
91 if (t->rx_buf)
92 *rx++ = ti_ssp_spi_rx(hw);
93 }
94 }
95
96 msg->actual_length += count; /* bytes transferred */
97
98 dev_dbg(&msg->spi->dev, "xfer %s%s, %d bytes, %d bpw, count %d%s\n",
99 t->tx_buf ? "tx" : "", t->rx_buf ? "rx" : "", t->len,
100 hw->bpw, count, (count < t->len) ? " (under)" : "");
101
102 return (count < t->len) ? -EIO : 0; /* left over data */
103}
104
105static void ti_ssp_spi_chip_select(struct ti_ssp_spi *hw, int cs_active)
106{
107 cs_active = !!cs_active;
108 if (cs_active == hw->cs_active)
109 return;
110 ti_ssp_run(hw->dev, cs_active ? hw->pc_en : hw->pc_dis, 0, NULL);
111 hw->cs_active = cs_active;
112}
113
114#define __SHIFT_OUT(bits) (SSP_OPCODE_SHIFT | SSP_OUT_MODE | \
115 cs_en | clk | SSP_COUNT((bits) * 2 - 1))
116#define __SHIFT_IN(bits) (SSP_OPCODE_SHIFT | SSP_IN_MODE | \
117 cs_en | clk | SSP_COUNT((bits) * 2 - 1))
118
119static int ti_ssp_spi_setup_transfer(struct ti_ssp_spi *hw, u8 bpw, u8 mode)
120{
121 int error, idx = 0;
122 u32 seqram[16];
123 u32 cs_en, cs_dis, clk;
124 u32 topbits, botbits;
125
126 mode &= MODE_BITS;
127 if (mode == hw->mode && bpw == hw->bpw)
128 return 0;
129
130 cs_en = (mode & SPI_CS_HIGH) ? SSP_CS_HIGH : SSP_CS_LOW;
131 cs_dis = (mode & SPI_CS_HIGH) ? SSP_CS_LOW : SSP_CS_HIGH;
132 clk = (mode & SPI_CPOL) ? SSP_CLK_HIGH : SSP_CLK_LOW;
133
134 /* Construct instructions */
135
136 /* Disable Chip Select */
137 hw->pc_dis = idx;
138 seqram[idx++] = SSP_OPCODE_DIRECT | SSP_OUT_MODE | cs_dis | clk;
139 seqram[idx++] = SSP_OPCODE_STOP | SSP_OUT_MODE | cs_dis | clk;
140
141 /* Enable Chip Select */
142 hw->pc_en = idx;
143 seqram[idx++] = SSP_OPCODE_DIRECT | SSP_OUT_MODE | cs_en | clk;
144 seqram[idx++] = SSP_OPCODE_STOP | SSP_OUT_MODE | cs_en | clk;
145
146 /* Reads and writes need to be split for bpw > 16 */
147 topbits = (bpw > 16) ? 16 : bpw;
148 botbits = bpw - topbits;
149
150 /* Write */
151 hw->pc_wr = idx;
152 seqram[idx++] = __SHIFT_OUT(topbits) | SSP_ADDR_REG;
153 if (botbits)
154 seqram[idx++] = __SHIFT_OUT(botbits) | SSP_DATA_REG;
155 seqram[idx++] = SSP_OPCODE_STOP | SSP_OUT_MODE | cs_en | clk;
156
157 /* Read */
158 hw->pc_rd = idx;
159 if (botbits)
160 seqram[idx++] = __SHIFT_IN(botbits) | SSP_ADDR_REG;
161 seqram[idx++] = __SHIFT_IN(topbits) | SSP_DATA_REG;
162 seqram[idx++] = SSP_OPCODE_STOP | SSP_OUT_MODE | cs_en | clk;
163
164 error = ti_ssp_load(hw->dev, 0, seqram, idx);
165 if (error < 0)
166 return error;
167
168 error = ti_ssp_set_mode(hw->dev, ((mode & SPI_CPHA) ?
169 0 : SSP_EARLY_DIN));
170 if (error < 0)
171 return error;
172
173 hw->bpw = bpw;
174 hw->mode = mode;
175
176 return error;
177}
178
179static void ti_ssp_spi_work(struct work_struct *work)
180{
181 struct ti_ssp_spi *hw = container_of(work, struct ti_ssp_spi, work);
182
183 spin_lock(&hw->lock);
184
185 while (!list_empty(&hw->msg_queue)) {
186 struct spi_message *m;
187 struct spi_device *spi;
188 struct spi_transfer *t = NULL;
189 int status = 0;
190
191 m = container_of(hw->msg_queue.next, struct spi_message,
192 queue);
193
194 list_del_init(&m->queue);
195
196 spin_unlock(&hw->lock);
197
198 spi = m->spi;
199
200 if (hw->select)
201 hw->select(spi->chip_select);
202
203 list_for_each_entry(t, &m->transfers, transfer_list) {
204 int bpw = spi->bits_per_word;
205 int xfer_status;
206
207 if (t->bits_per_word)
208 bpw = t->bits_per_word;
209
210 if (ti_ssp_spi_setup_transfer(hw, bpw, spi->mode) < 0)
211 break;
212
213 ti_ssp_spi_chip_select(hw, 1);
214
215 xfer_status = ti_ssp_spi_txrx(hw, m, t);
216 if (xfer_status < 0)
217 status = xfer_status;
218
219 if (t->delay_usecs)
220 udelay(t->delay_usecs);
221
222 if (t->cs_change)
223 ti_ssp_spi_chip_select(hw, 0);
224 }
225
226 ti_ssp_spi_chip_select(hw, 0);
227 m->status = status;
228 m->complete(m->context);
229
230 spin_lock(&hw->lock);
231 }
232
233 if (hw->shutdown)
234 complete(&hw->complete);
235
236 spin_unlock(&hw->lock);
237}
238
239static int ti_ssp_spi_setup(struct spi_device *spi)
240{
241 if (spi->bits_per_word > 32)
242 return -EINVAL;
243
244 return 0;
245}
246
247static int ti_ssp_spi_transfer(struct spi_device *spi, struct spi_message *m)
248{
249 struct ti_ssp_spi *hw;
250 struct spi_transfer *t;
251 int error = 0;
252
253 m->actual_length = 0;
254 m->status = -EINPROGRESS;
255
256 hw = spi_master_get_devdata(spi->master);
257
258 if (list_empty(&m->transfers) || !m->complete)
259 return -EINVAL;
260
261 list_for_each_entry(t, &m->transfers, transfer_list) {
262 if (t->len && !(t->rx_buf || t->tx_buf)) {
263 dev_err(&spi->dev, "invalid xfer, no buffer\n");
264 return -EINVAL;
265 }
266
267 if (t->len && t->rx_buf && t->tx_buf) {
268 dev_err(&spi->dev, "invalid xfer, full duplex\n");
269 return -EINVAL;
270 }
271
272 if (t->bits_per_word > 32) {
273 dev_err(&spi->dev, "invalid xfer width %d\n",
274 t->bits_per_word);
275 return -EINVAL;
276 }
277 }
278
279 spin_lock(&hw->lock);
280 if (hw->shutdown) {
281 error = -ESHUTDOWN;
282 goto error_unlock;
283 }
284 list_add_tail(&m->queue, &hw->msg_queue);
285 queue_work(hw->workqueue, &hw->work);
286error_unlock:
287 spin_unlock(&hw->lock);
288 return error;
289}
290
291static int __devinit ti_ssp_spi_probe(struct platform_device *pdev)
292{
293 const struct ti_ssp_spi_data *pdata;
294 struct ti_ssp_spi *hw;
295 struct spi_master *master;
296 struct device *dev = &pdev->dev;
297 int error = 0;
298
299 pdata = dev->platform_data;
300 if (!pdata) {
301 dev_err(dev, "platform data not found\n");
302 return -EINVAL;
303 }
304
305 master = spi_alloc_master(dev, sizeof(struct ti_ssp_spi));
306 if (!master) {
307 dev_err(dev, "cannot allocate SPI master\n");
308 return -ENOMEM;
309 }
310
311 hw = spi_master_get_devdata(master);
312 platform_set_drvdata(pdev, hw);
313
314 hw->master = master;
315 hw->dev = dev;
316 hw->select = pdata->select;
317
318 spin_lock_init(&hw->lock);
319 init_completion(&hw->complete);
320 INIT_LIST_HEAD(&hw->msg_queue);
321 INIT_WORK(&hw->work, ti_ssp_spi_work);
322
323 hw->workqueue = create_singlethread_workqueue(dev_name(dev));
324 if (!hw->workqueue) {
325 error = -ENOMEM;
326 dev_err(dev, "work queue creation failed\n");
327 goto error_wq;
328 }
329
330 error = ti_ssp_set_iosel(hw->dev, pdata->iosel);
331 if (error < 0) {
332 dev_err(dev, "io setup failed\n");
333 goto error_iosel;
334 }
335
336 master->bus_num = pdev->id;
337 master->num_chipselect = pdata->num_cs;
338 master->mode_bits = MODE_BITS;
339 master->flags = SPI_MASTER_HALF_DUPLEX;
340 master->setup = ti_ssp_spi_setup;
341 master->transfer = ti_ssp_spi_transfer;
342
343 error = spi_register_master(master);
344 if (error) {
345 dev_err(dev, "master registration failed\n");
346 goto error_reg;
347 }
348
349 return 0;
350
351error_reg:
352error_iosel:
353 destroy_workqueue(hw->workqueue);
354error_wq:
355 spi_master_put(master);
356 return error;
357}
358
359static int __devexit ti_ssp_spi_remove(struct platform_device *pdev)
360{
361 struct ti_ssp_spi *hw = platform_get_drvdata(pdev);
362 int error;
363
364 hw->shutdown = 1;
365 while (!list_empty(&hw->msg_queue)) {
366 error = wait_for_completion_interruptible(&hw->complete);
367 if (error < 0) {
368 hw->shutdown = 0;
369 return error;
370 }
371 }
372 destroy_workqueue(hw->workqueue);
373 spi_unregister_master(hw->master);
374
375 return 0;
376}
377
378static struct platform_driver ti_ssp_spi_driver = {
379 .probe = ti_ssp_spi_probe,
380 .remove = __devexit_p(ti_ssp_spi_remove),
381 .driver = {
382 .name = "ti-ssp-spi",
383 .owner = THIS_MODULE,
384 },
385};
386
387static int __init ti_ssp_spi_init(void)
388{
389 return platform_driver_register(&ti_ssp_spi_driver);
390}
391module_init(ti_ssp_spi_init);
392
393static void __exit ti_ssp_spi_exit(void)
394{
395 platform_driver_unregister(&ti_ssp_spi_driver);
396}
397module_exit(ti_ssp_spi_exit);
398
399MODULE_DESCRIPTION("SSP SPI Master");
400MODULE_AUTHOR("Cyril Chemparathy");
401MODULE_LICENSE("GPL");
402MODULE_ALIAS("platform:ti-ssp-spi");
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 7adaef62a991..4d2c75df886c 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -351,14 +351,12 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
351 return IRQ_HANDLED; 351 return IRQ_HANDLED;
352} 352}
353 353
354#ifdef CONFIG_OF
355static const struct of_device_id xilinx_spi_of_match[] = { 354static const struct of_device_id xilinx_spi_of_match[] = {
356 { .compatible = "xlnx,xps-spi-2.00.a", }, 355 { .compatible = "xlnx,xps-spi-2.00.a", },
357 { .compatible = "xlnx,xps-spi-2.00.b", }, 356 { .compatible = "xlnx,xps-spi-2.00.b", },
358 {} 357 {}
359}; 358};
360MODULE_DEVICE_TABLE(of, xilinx_spi_of_match); 359MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
361#endif
362 360
363struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, 361struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
364 u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word) 362 u32 irq, s16 bus_num, int num_cs, int little_endian, int bits_per_word)
@@ -394,9 +392,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
394 392
395 master->bus_num = bus_num; 393 master->bus_num = bus_num;
396 master->num_chipselect = num_cs; 394 master->num_chipselect = num_cs;
397#ifdef CONFIG_OF
398 master->dev.of_node = dev->of_node; 395 master->dev.of_node = dev->of_node;
399#endif
400 396
401 xspi->mem = *mem; 397 xspi->mem = *mem;
402 xspi->irq = irq; 398 xspi->irq = irq;
@@ -539,9 +535,7 @@ static struct platform_driver xilinx_spi_driver = {
539 .driver = { 535 .driver = {
540 .name = XILINX_SPI_NAME, 536 .name = XILINX_SPI_NAME,
541 .owner = THIS_MODULE, 537 .owner = THIS_MODULE,
542#ifdef CONFIG_OF
543 .of_match_table = xilinx_spi_of_match, 538 .of_match_table = xilinx_spi_of_match,
544#endif
545 }, 539 },
546}; 540};
547 541