aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-altera.c2
-rw-r--r--drivers/spi/spi-bfin-sport.c3
-rw-r--r--drivers/spi/spi-bfin5xx.c3
-rw-r--r--drivers/spi/spi-bitbang.c6
-rw-r--r--drivers/spi/spi-clps711x.c2
-rw-r--r--drivers/spi/spi-coldfire-qspi.c3
-rw-r--r--drivers/spi/spi-davinci.c102
-rw-r--r--drivers/spi/spi-ep93xx.c2
-rw-r--r--drivers/spi/spi-omap2-mcspi.c8
-rw-r--r--drivers/spi/spi-s3c64xx.c2
-rw-r--r--drivers/spi/spi-sh-msiof.c56
-rw-r--r--drivers/spi/spi-sirf.c3
-rw-r--r--drivers/spi/spi-tegra20-slink.c9
-rw-r--r--drivers/spi/spi-txx9.c6
-rw-r--r--drivers/spi/spi.c3
15 files changed, 166 insertions, 44 deletions
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c
index 5e7314ac51e9..a537f8dffc09 100644
--- a/drivers/spi/spi-altera.c
+++ b/drivers/spi/spi-altera.c
@@ -134,7 +134,7 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
134 hw->tx = t->tx_buf; 134 hw->tx = t->tx_buf;
135 hw->rx = t->rx_buf; 135 hw->rx = t->rx_buf;
136 hw->count = 0; 136 hw->count = 0;
137 hw->bytes_per_word = (t->bits_per_word ? : spi->bits_per_word) / 8; 137 hw->bytes_per_word = t->bits_per_word / 8;
138 hw->len = t->len / hw->bytes_per_word; 138 hw->len = t->len / hw->bytes_per_word;
139 139
140 if (hw->irq >= 0) { 140 if (hw->irq >= 0) {
diff --git a/drivers/spi/spi-bfin-sport.c b/drivers/spi/spi-bfin-sport.c
index ac7ffca7ba47..39b0d1711b4e 100644
--- a/drivers/spi/spi-bfin-sport.c
+++ b/drivers/spi/spi-bfin-sport.c
@@ -416,8 +416,7 @@ bfin_sport_spi_pump_transfers(unsigned long data)
416 drv_data->cs_change = transfer->cs_change; 416 drv_data->cs_change = transfer->cs_change;
417 417
418 /* Bits per word setup */ 418 /* Bits per word setup */
419 bits_per_word = transfer->bits_per_word ? : 419 bits_per_word = transfer->bits_per_word;
420 message->spi->bits_per_word ? : 8;
421 if (bits_per_word % 16 == 0) 420 if (bits_per_word % 16 == 0)
422 drv_data->ops = &bfin_sport_transfer_ops_u16; 421 drv_data->ops = &bfin_sport_transfer_ops_u16;
423 else 422 else
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c
index 0429d833f75b..7d7c9918fffe 100644
--- a/drivers/spi/spi-bfin5xx.c
+++ b/drivers/spi/spi-bfin5xx.c
@@ -642,8 +642,7 @@ static void bfin_spi_pump_transfers(unsigned long data)
642 drv_data->cs_change = transfer->cs_change; 642 drv_data->cs_change = transfer->cs_change;
643 643
644 /* Bits per word setup */ 644 /* Bits per word setup */
645 bits_per_word = transfer->bits_per_word ? : 645 bits_per_word = transfer->bits_per_word;
646 message->spi->bits_per_word ? : 8;
647 if (bits_per_word % 16 == 0) { 646 if (bits_per_word % 16 == 0) {
648 drv_data->n_bytes = bits_per_word/8; 647 drv_data->n_bytes = bits_per_word/8;
649 drv_data->len = (transfer->len) >> 1; 648 drv_data->len = (transfer->len) >> 1;
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index 328c4dcd3d52..a63d7da3bfe2 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -69,7 +69,7 @@ static unsigned bitbang_txrx_8(
69 unsigned ns, 69 unsigned ns,
70 struct spi_transfer *t 70 struct spi_transfer *t
71) { 71) {
72 unsigned bits = t->bits_per_word ? : spi->bits_per_word; 72 unsigned bits = t->bits_per_word;
73 unsigned count = t->len; 73 unsigned count = t->len;
74 const u8 *tx = t->tx_buf; 74 const u8 *tx = t->tx_buf;
75 u8 *rx = t->rx_buf; 75 u8 *rx = t->rx_buf;
@@ -95,7 +95,7 @@ static unsigned bitbang_txrx_16(
95 unsigned ns, 95 unsigned ns,
96 struct spi_transfer *t 96 struct spi_transfer *t
97) { 97) {
98 unsigned bits = t->bits_per_word ? : spi->bits_per_word; 98 unsigned bits = t->bits_per_word;
99 unsigned count = t->len; 99 unsigned count = t->len;
100 const u16 *tx = t->tx_buf; 100 const u16 *tx = t->tx_buf;
101 u16 *rx = t->rx_buf; 101 u16 *rx = t->rx_buf;
@@ -121,7 +121,7 @@ static unsigned bitbang_txrx_32(
121 unsigned ns, 121 unsigned ns,
122 struct spi_transfer *t 122 struct spi_transfer *t
123) { 123) {
124 unsigned bits = t->bits_per_word ? : spi->bits_per_word; 124 unsigned bits = t->bits_per_word;
125 unsigned count = t->len; 125 unsigned count = t->len;
126 const u32 *tx = t->tx_buf; 126 const u32 *tx = t->tx_buf;
127 u32 *rx = t->rx_buf; 127 u32 *rx = t->rx_buf;
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c
index 1366c4620d5d..a11cbf02691a 100644
--- a/drivers/spi/spi-clps711x.c
+++ b/drivers/spi/spi-clps711x.c
@@ -68,7 +68,7 @@ static int spi_clps711x_setup_xfer(struct spi_device *spi,
68 struct spi_transfer *xfer) 68 struct spi_transfer *xfer)
69{ 69{
70 u32 speed = xfer->speed_hz ? : spi->max_speed_hz; 70 u32 speed = xfer->speed_hz ? : spi->max_speed_hz;
71 u8 bpw = xfer->bits_per_word ? : spi->bits_per_word; 71 u8 bpw = xfer->bits_per_word;
72 struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); 72 struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master);
73 73
74 if (bpw != 8) { 74 if (bpw != 8) {
diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c
index 58466b810da4..7b5cc9e4e94d 100644
--- a/drivers/spi/spi-coldfire-qspi.c
+++ b/drivers/spi/spi-coldfire-qspi.c
@@ -329,8 +329,7 @@ static int mcfqspi_transfer_one_message(struct spi_master *master,
329 mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high); 329 mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high);
330 330
331 mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE); 331 mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE);
332 if ((t->bits_per_word ? t->bits_per_word : 332 if (t->bits_per_word == 8)
333 spi->bits_per_word) == 8)
334 mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf, 333 mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf,
335 t->rx_buf); 334 t->rx_buf);
336 else 335 else
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 13661e129d96..50bd2cdc52de 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -28,6 +28,8 @@
28#include <linux/dmaengine.h> 28#include <linux/dmaengine.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/edma.h> 30#include <linux/edma.h>
31#include <linux/of.h>
32#include <linux/of_device.h>
31#include <linux/spi/spi.h> 33#include <linux/spi/spi.h>
32#include <linux/spi/spi_bitbang.h> 34#include <linux/spi/spi_bitbang.h>
33#include <linux/slab.h> 35#include <linux/slab.h>
@@ -135,7 +137,7 @@ struct davinci_spi {
135 int dma_rx_chnum; 137 int dma_rx_chnum;
136 int dma_tx_chnum; 138 int dma_tx_chnum;
137 139
138 struct davinci_spi_platform_data *pdata; 140 struct davinci_spi_platform_data pdata;
139 141
140 void (*get_rx)(u32 rx_data, struct davinci_spi *); 142 void (*get_rx)(u32 rx_data, struct davinci_spi *);
141 u32 (*get_tx)(struct davinci_spi *); 143 u32 (*get_tx)(struct davinci_spi *);
@@ -213,7 +215,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
213 bool gpio_chipsel = false; 215 bool gpio_chipsel = false;
214 216
215 dspi = spi_master_get_devdata(spi->master); 217 dspi = spi_master_get_devdata(spi->master);
216 pdata = dspi->pdata; 218 pdata = &dspi->pdata;
217 219
218 if (pdata->chip_sel && chip_sel < pdata->num_chipselect && 220 if (pdata->chip_sel && chip_sel < pdata->num_chipselect &&
219 pdata->chip_sel[chip_sel] != SPI_INTERN_CS) 221 pdata->chip_sel[chip_sel] != SPI_INTERN_CS)
@@ -392,7 +394,7 @@ static int davinci_spi_setup(struct spi_device *spi)
392 struct davinci_spi_platform_data *pdata; 394 struct davinci_spi_platform_data *pdata;
393 395
394 dspi = spi_master_get_devdata(spi->master); 396 dspi = spi_master_get_devdata(spi->master);
395 pdata = dspi->pdata; 397 pdata = &dspi->pdata;
396 398
397 /* if bits per word length is zero then set it default 8 */ 399 /* if bits per word length is zero then set it default 8 */
398 if (!spi->bits_per_word) 400 if (!spi->bits_per_word)
@@ -534,7 +536,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
534 struct scatterlist sg_rx, sg_tx; 536 struct scatterlist sg_rx, sg_tx;
535 537
536 dspi = spi_master_get_devdata(spi->master); 538 dspi = spi_master_get_devdata(spi->master);
537 pdata = dspi->pdata; 539 pdata = &dspi->pdata;
538 spicfg = (struct davinci_spi_config *)spi->controller_data; 540 spicfg = (struct davinci_spi_config *)spi->controller_data;
539 if (!spicfg) 541 if (!spicfg)
540 spicfg = &davinci_spi_default_cfg; 542 spicfg = &davinci_spi_default_cfg;
@@ -758,6 +760,70 @@ rx_dma_failed:
758 return r; 760 return r;
759} 761}
760 762
763#if defined(CONFIG_OF)
764static const struct of_device_id davinci_spi_of_match[] = {
765 {
766 .compatible = "ti,dm644x-spi",
767 },
768 {
769 .compatible = "ti,da8xx-spi",
770 .data = (void *)SPI_VERSION_2,
771 },
772 { },
773};
774MODULE_DEVICE_TABLE(of, davini_spi_of_match);
775
776/**
777 * spi_davinci_get_pdata - Get platform data from DTS binding
778 * @pdev: ptr to platform data
779 * @dspi: ptr to driver data
780 *
781 * Parses and populates pdata in dspi from device tree bindings.
782 *
783 * NOTE: Not all platform data params are supported currently.
784 */
785static int spi_davinci_get_pdata(struct platform_device *pdev,
786 struct davinci_spi *dspi)
787{
788 struct device_node *node = pdev->dev.of_node;
789 struct davinci_spi_platform_data *pdata;
790 unsigned int num_cs, intr_line = 0;
791 const struct of_device_id *match;
792
793 pdata = &dspi->pdata;
794
795 pdata->version = SPI_VERSION_1;
796 match = of_match_device(of_match_ptr(davinci_spi_of_match),
797 &pdev->dev);
798 if (!match)
799 return -ENODEV;
800
801 /* match data has the SPI version number for SPI_VERSION_2 */
802 if (match->data == (void *)SPI_VERSION_2)
803 pdata->version = SPI_VERSION_2;
804
805 /*
806 * default num_cs is 1 and all chipsel are internal to the chip
807 * indicated by chip_sel being NULL. GPIO based CS is not
808 * supported yet in DT bindings.
809 */
810 num_cs = 1;
811 of_property_read_u32(node, "num-cs", &num_cs);
812 pdata->num_chipselect = num_cs;
813 of_property_read_u32(node, "ti,davinci-spi-intr-line", &intr_line);
814 pdata->intr_line = intr_line;
815 return 0;
816}
817#else
818#define davinci_spi_of_match NULL
819static struct davinci_spi_platform_data
820 *spi_davinci_get_pdata(struct platform_device *pdev,
821 struct davinci_spi *dspi)
822{
823 return -ENODEV;
824}
825#endif
826
761/** 827/**
762 * davinci_spi_probe - probe function for SPI Master Controller 828 * davinci_spi_probe - probe function for SPI Master Controller
763 * @pdev: platform_device structure which contains plateform specific data 829 * @pdev: platform_device structure which contains plateform specific data
@@ -780,12 +846,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
780 int i = 0, ret = 0; 846 int i = 0, ret = 0;
781 u32 spipc0; 847 u32 spipc0;
782 848
783 pdata = pdev->dev.platform_data;
784 if (pdata == NULL) {
785 ret = -ENODEV;
786 goto err;
787 }
788
789 master = spi_alloc_master(&pdev->dev, sizeof(struct davinci_spi)); 849 master = spi_alloc_master(&pdev->dev, sizeof(struct davinci_spi));
790 if (master == NULL) { 850 if (master == NULL) {
791 ret = -ENOMEM; 851 ret = -ENOMEM;
@@ -800,6 +860,19 @@ static int davinci_spi_probe(struct platform_device *pdev)
800 goto free_master; 860 goto free_master;
801 } 861 }
802 862
863 if (pdev->dev.platform_data) {
864 pdata = pdev->dev.platform_data;
865 dspi->pdata = *pdata;
866 } else {
867 /* update dspi pdata with that from the DT */
868 ret = spi_davinci_get_pdata(pdev, dspi);
869 if (ret < 0)
870 goto free_master;
871 }
872
873 /* pdata in dspi is now updated and point pdata to that */
874 pdata = &dspi->pdata;
875
803 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 876 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
804 if (r == NULL) { 877 if (r == NULL) {
805 ret = -ENOENT; 878 ret = -ENOENT;
@@ -807,7 +880,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
807 } 880 }
808 881
809 dspi->pbase = r->start; 882 dspi->pbase = r->start;
810 dspi->pdata = pdata;
811 883
812 mem = request_mem_region(r->start, resource_size(r), pdev->name); 884 mem = request_mem_region(r->start, resource_size(r), pdev->name);
813 if (mem == NULL) { 885 if (mem == NULL) {
@@ -843,8 +915,9 @@ static int davinci_spi_probe(struct platform_device *pdev)
843 ret = -ENODEV; 915 ret = -ENODEV;
844 goto put_master; 916 goto put_master;
845 } 917 }
846 clk_enable(dspi->clk); 918 clk_prepare_enable(dspi->clk);
847 919
920 master->dev.of_node = pdev->dev.of_node;
848 master->bus_num = pdev->id; 921 master->bus_num = pdev->id;
849 master->num_chipselect = pdata->num_chipselect; 922 master->num_chipselect = pdata->num_chipselect;
850 master->setup = davinci_spi_setup; 923 master->setup = davinci_spi_setup;
@@ -927,7 +1000,7 @@ free_dma:
927 dma_release_channel(dspi->dma_rx); 1000 dma_release_channel(dspi->dma_rx);
928 dma_release_channel(dspi->dma_tx); 1001 dma_release_channel(dspi->dma_tx);
929free_clk: 1002free_clk:
930 clk_disable(dspi->clk); 1003 clk_disable_unprepare(dspi->clk);
931 clk_put(dspi->clk); 1004 clk_put(dspi->clk);
932put_master: 1005put_master:
933 spi_master_put(master); 1006 spi_master_put(master);
@@ -963,7 +1036,7 @@ static int davinci_spi_remove(struct platform_device *pdev)
963 1036
964 spi_bitbang_stop(&dspi->bitbang); 1037 spi_bitbang_stop(&dspi->bitbang);
965 1038
966 clk_disable(dspi->clk); 1039 clk_disable_unprepare(dspi->clk);
967 clk_put(dspi->clk); 1040 clk_put(dspi->clk);
968 spi_master_put(master); 1041 spi_master_put(master);
969 free_irq(dspi->irq, dspi); 1042 free_irq(dspi->irq, dspi);
@@ -978,6 +1051,7 @@ static struct platform_driver davinci_spi_driver = {
978 .driver = { 1051 .driver = {
979 .name = "spi_davinci", 1052 .name = "spi_davinci",
980 .owner = THIS_MODULE, 1053 .owner = THIS_MODULE,
1054 .of_match_table = davinci_spi_of_match,
981 }, 1055 },
982 .probe = davinci_spi_probe, 1056 .probe = davinci_spi_probe,
983 .remove = davinci_spi_remove, 1057 .remove = davinci_spi_remove,
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index acb1e1935c5a..aecbff16ad60 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -446,7 +446,7 @@ static inline int bits_per_word(const struct ep93xx_spi *espi)
446 struct spi_message *msg = espi->current_msg; 446 struct spi_message *msg = espi->current_msg;
447 struct spi_transfer *t = msg->state; 447 struct spi_transfer *t = msg->state;
448 448
449 return t->bits_per_word ? t->bits_per_word : msg->spi->bits_per_word; 449 return t->bits_per_word;
450} 450}
451 451
452static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t) 452static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 12789fcfa980..69945b014c96 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -298,10 +298,10 @@ static void omap2_mcspi_rx_callback(void *data)
298 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); 298 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
299 struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select]; 299 struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
300 300
301 complete(&mcspi_dma->dma_rx_completion);
302
303 /* We must disable the DMA RX request */ 301 /* We must disable the DMA RX request */
304 omap2_mcspi_set_dma_req(spi, 1, 0); 302 omap2_mcspi_set_dma_req(spi, 1, 0);
303
304 complete(&mcspi_dma->dma_rx_completion);
305} 305}
306 306
307static void omap2_mcspi_tx_callback(void *data) 307static void omap2_mcspi_tx_callback(void *data)
@@ -310,10 +310,10 @@ static void omap2_mcspi_tx_callback(void *data)
310 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); 310 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
311 struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select]; 311 struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
312 312
313 complete(&mcspi_dma->dma_tx_completion);
314
315 /* We must disable the DMA TX request */ 313 /* We must disable the DMA TX request */
316 omap2_mcspi_set_dma_req(spi, 0, 0); 314 omap2_mcspi_set_dma_req(spi, 0, 0);
315
316 complete(&mcspi_dma->dma_tx_completion);
317} 317}
318 318
319static void omap2_mcspi_tx_dma(struct spi_device *spi, 319static void omap2_mcspi_tx_dma(struct spi_device *spi,
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 6495352bcc19..a82bfa4af601 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -697,7 +697,7 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
697 INIT_COMPLETION(sdd->xfer_completion); 697 INIT_COMPLETION(sdd->xfer_completion);
698 698
699 /* Only BPW and Speed may change across transfers */ 699 /* Only BPW and Speed may change across transfers */
700 bpw = xfer->bits_per_word ? : spi->bits_per_word; 700 bpw = xfer->bits_per_word;
701 speed = xfer->speed_hz ? : spi->max_speed_hz; 701 speed = xfer->speed_hz ? : spi->max_speed_hz;
702 702
703 if (xfer->len % (bpw / 8)) { 703 if (xfer->len % (bpw / 8)) {
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 96358d0eabb7..8b40d0884f8b 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -20,6 +20,7 @@
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/of.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/pm_runtime.h> 25#include <linux/pm_runtime.h>
25 26
@@ -592,6 +593,37 @@ static u32 sh_msiof_spi_txrx_word(struct spi_device *spi, unsigned nsecs,
592 return 0; 593 return 0;
593} 594}
594 595
596#ifdef CONFIG_OF
597static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev)
598{
599 struct sh_msiof_spi_info *info;
600 struct device_node *np = dev->of_node;
601 u32 num_cs = 0;
602
603 info = devm_kzalloc(dev, sizeof(struct sh_msiof_spi_info), GFP_KERNEL);
604 if (!info) {
605 dev_err(dev, "failed to allocate setup data\n");
606 return NULL;
607 }
608
609 /* Parse the MSIOF properties */
610 of_property_read_u32(np, "num-cs", &num_cs);
611 of_property_read_u32(np, "renesas,tx-fifo-size",
612 &info->tx_fifo_override);
613 of_property_read_u32(np, "renesas,rx-fifo-size",
614 &info->rx_fifo_override);
615
616 info->num_chipselect = num_cs;
617
618 return info;
619}
620#else
621static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev)
622{
623 return NULL;
624}
625#endif
626
595static int sh_msiof_spi_probe(struct platform_device *pdev) 627static int sh_msiof_spi_probe(struct platform_device *pdev)
596{ 628{
597 struct resource *r; 629 struct resource *r;
@@ -610,7 +642,17 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
610 p = spi_master_get_devdata(master); 642 p = spi_master_get_devdata(master);
611 643
612 platform_set_drvdata(pdev, p); 644 platform_set_drvdata(pdev, p);
613 p->info = pdev->dev.platform_data; 645 if (pdev->dev.of_node)
646 p->info = sh_msiof_spi_parse_dt(&pdev->dev);
647 else
648 p->info = pdev->dev.platform_data;
649
650 if (!p->info) {
651 dev_err(&pdev->dev, "failed to obtain device info\n");
652 ret = -ENXIO;
653 goto err1;
654 }
655
614 init_completion(&p->done); 656 init_completion(&p->done);
615 657
616 p->clk = clk_get(&pdev->dev, NULL); 658 p->clk = clk_get(&pdev->dev, NULL);
@@ -715,6 +757,17 @@ static int sh_msiof_spi_runtime_nop(struct device *dev)
715 return 0; 757 return 0;
716} 758}
717 759
760#ifdef CONFIG_OF
761static const struct of_device_id sh_msiof_match[] = {
762 { .compatible = "renesas,sh-msiof", },
763 { .compatible = "renesas,sh-mobile-msiof", },
764 {},
765};
766MODULE_DEVICE_TABLE(of, sh_msiof_match);
767#else
768#define sh_msiof_match NULL
769#endif
770
718static struct dev_pm_ops sh_msiof_spi_dev_pm_ops = { 771static struct dev_pm_ops sh_msiof_spi_dev_pm_ops = {
719 .runtime_suspend = sh_msiof_spi_runtime_nop, 772 .runtime_suspend = sh_msiof_spi_runtime_nop,
720 .runtime_resume = sh_msiof_spi_runtime_nop, 773 .runtime_resume = sh_msiof_spi_runtime_nop,
@@ -727,6 +780,7 @@ static struct platform_driver sh_msiof_spi_drv = {
727 .name = "spi_sh_msiof", 780 .name = "spi_sh_msiof",
728 .owner = THIS_MODULE, 781 .owner = THIS_MODULE,
729 .pm = &sh_msiof_spi_dev_pm_ops, 782 .pm = &sh_msiof_spi_dev_pm_ops,
783 .of_match_table = sh_msiof_match,
730 }, 784 },
731}; 785};
732module_platform_driver(sh_msiof_spi_drv); 786module_platform_driver(sh_msiof_spi_drv);
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index e0f43a512e84..750666751efd 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -382,8 +382,7 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
382 382
383 sspi = spi_master_get_devdata(spi->master); 383 sspi = spi_master_get_devdata(spi->master);
384 384
385 bits_per_word = t && t->bits_per_word ? t->bits_per_word : 385 bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
386 spi->bits_per_word;
387 hz = t && t->speed_hz ? t->speed_hz : spi->max_speed_hz; 386 hz = t && t->speed_hz ? t->speed_hz : spi->max_speed_hz;
388 387
389 /* Enable IO mode for RX, TX */ 388 /* Enable IO mode for RX, TX */
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 651167f2e0af..7a95bddfb604 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -284,8 +284,7 @@ static unsigned tegra_slink_calculate_curr_xfer_param(
284 unsigned max_len; 284 unsigned max_len;
285 unsigned total_fifo_words; 285 unsigned total_fifo_words;
286 286
287 bits_per_word = t->bits_per_word ? t->bits_per_word : 287 bits_per_word = t->bits_per_word;
288 spi->bits_per_word;
289 tspi->bytes_per_word = (bits_per_word - 1) / 8 + 1; 288 tspi->bytes_per_word = (bits_per_word - 1) / 8 + 1;
290 289
291 if (bits_per_word == 8 || bits_per_word == 16) { 290 if (bits_per_word == 8 || bits_per_word == 16) {
@@ -378,8 +377,7 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf(
378 } else { 377 } else {
379 unsigned int bits_per_word; 378 unsigned int bits_per_word;
380 379
381 bits_per_word = t->bits_per_word ? t->bits_per_word : 380 bits_per_word = t->bits_per_word;
382 tspi->cur_spi->bits_per_word;
383 for (count = 0; count < rx_full_count; count++) { 381 for (count = 0; count < rx_full_count; count++) {
384 x = tegra_slink_readl(tspi, SLINK_RX_FIFO); 382 x = tegra_slink_readl(tspi, SLINK_RX_FIFO);
385 for (i = 0; (i < tspi->bytes_per_word); i++) 383 for (i = 0; (i < tspi->bytes_per_word); i++)
@@ -444,8 +442,7 @@ static void tegra_slink_copy_spi_rxbuf_to_client_rxbuf(
444 unsigned int x; 442 unsigned int x;
445 unsigned int rx_mask, bits_per_word; 443 unsigned int rx_mask, bits_per_word;
446 444
447 bits_per_word = t->bits_per_word ? t->bits_per_word : 445 bits_per_word = t->bits_per_word;
448 tspi->cur_spi->bits_per_word;
449 rx_mask = (1 << bits_per_word) - 1; 446 rx_mask = (1 << bits_per_word) - 1;
450 for (count = 0; count < tspi->curr_dma_words; count++) { 447 for (count = 0; count < tspi->curr_dma_words; count++) {
451 x = tspi->rx_dma_buf[count]; 448 x = tspi->rx_dma_buf[count];
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c
index d5a3cbb646cb..550b5f48fd8f 100644
--- a/drivers/spi/spi-txx9.c
+++ b/drivers/spi/spi-txx9.c
@@ -189,9 +189,8 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m)
189 unsigned int len = t->len; 189 unsigned int len = t->len;
190 unsigned int wsize; 190 unsigned int wsize;
191 u32 speed_hz = t->speed_hz ? : spi->max_speed_hz; 191 u32 speed_hz = t->speed_hz ? : spi->max_speed_hz;
192 u8 bits_per_word = t->bits_per_word ? : spi->bits_per_word; 192 u8 bits_per_word = t->bits_per_word;
193 193
194 bits_per_word = bits_per_word ? : 8;
195 wsize = bits_per_word >> 3; /* in bytes */ 194 wsize = bits_per_word >> 3; /* in bytes */
196 195
197 if (prev_speed_hz != speed_hz 196 if (prev_speed_hz != speed_hz
@@ -316,9 +315,8 @@ static int txx9spi_transfer(struct spi_device *spi, struct spi_message *m)
316 /* check each transfer's parameters */ 315 /* check each transfer's parameters */
317 list_for_each_entry (t, &m->transfers, transfer_list) { 316 list_for_each_entry (t, &m->transfers, transfer_list) {
318 u32 speed_hz = t->speed_hz ? : spi->max_speed_hz; 317 u32 speed_hz = t->speed_hz ? : spi->max_speed_hz;
319 u8 bits_per_word = t->bits_per_word ? : spi->bits_per_word; 318 u8 bits_per_word = t->bits_per_word;
320 319
321 bits_per_word = bits_per_word ? : 8;
322 if (!t->tx_buf && !t->rx_buf && t->len) 320 if (!t->tx_buf && !t->rx_buf && t->len)
323 return -EINVAL; 321 return -EINVAL;
324 if (bits_per_word != 8 && bits_per_word != 16) 322 if (bits_per_word != 8 && bits_per_word != 16)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 19ee901577da..08ff4acd5225 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1135,6 +1135,9 @@ int spi_register_master(struct spi_master *master)
1135 if (master->num_chipselect == 0) 1135 if (master->num_chipselect == 0)
1136 return -EINVAL; 1136 return -EINVAL;
1137 1137
1138 if ((master->bus_num < 0) && master->dev.of_node)
1139 master->bus_num = of_alias_get_id(master->dev.of_node, "spi");
1140
1138 /* convention: dynamically assigned bus IDs count down from the max */ 1141 /* convention: dynamically assigned bus IDs count down from the max */
1139 if (master->bus_num < 0) { 1142 if (master->bus_num < 0) {
1140 /* FIXME switch to an IDR based scheme, something like 1143 /* FIXME switch to an IDR based scheme, something like