aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/Kconfig1
-rw-r--r--drivers/spi/spi-altera.c1
-rw-r--r--drivers/spi/spi-ath79.c1
-rw-r--r--drivers/spi/spi-atmel.c1
-rw-r--r--drivers/spi/spi-bcm63xx.c1
-rw-r--r--drivers/spi/spi-bfin-sport.c1
-rw-r--r--drivers/spi/spi-bitbang.c1
-rw-r--r--drivers/spi/spi-clps711x.c1
-rw-r--r--drivers/spi/spi-gpio.c1
-rw-r--r--drivers/spi/spi-imx.c5
-rw-r--r--drivers/spi/spi-mpc512x-psc.c17
-rw-r--r--drivers/spi/spi-mpc52xx-psc.c1
-rw-r--r--drivers/spi/spi-mpc52xx.c14
-rw-r--r--drivers/spi/spi-mxs.c7
-rw-r--r--drivers/spi/spi-nuc900.c28
-rw-r--r--drivers/spi/spi-oc-tiny.c3
-rw-r--r--drivers/spi/spi-octeon.c78
-rw-r--r--drivers/spi/spi-omap2-mcspi.c1
-rw-r--r--drivers/spi/spi-orion.c1
-rw-r--r--drivers/spi/spi-ppc4xx.c1
-rw-r--r--drivers/spi/spi-pxa2xx-dma.c1
-rw-r--r--drivers/spi/spi-pxa2xx-pxadma.c1
-rw-r--r--drivers/spi/spi-s3c24xx.c1
-rw-r--r--drivers/spi/spi-sh-msiof.c1
-rw-r--r--drivers/spi/spi-sh-sci.c1
-rw-r--r--drivers/spi/spi-tegra114.c1
-rw-r--r--drivers/spi/spi-tegra20-sflash.c1
-rw-r--r--drivers/spi/spi-tegra20-slink.c1
-rw-r--r--drivers/spi/spi-xcomm.c1
-rw-r--r--drivers/spi/spi-xilinx.c1
30 files changed, 29 insertions, 146 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index eea4eb83f352..5bf7a4f100d2 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -212,7 +212,6 @@ config SPI_IMX
212 tristate "Freescale i.MX SPI controllers" 212 tristate "Freescale i.MX SPI controllers"
213 depends on ARCH_MXC || COMPILE_TEST 213 depends on ARCH_MXC || COMPILE_TEST
214 select SPI_BITBANG 214 select SPI_BITBANG
215 default m if IMX_HAVE_PLATFORM_SPI_IMX
216 help 215 help
217 This enables using the Freescale i.MX SPI controllers in master 216 This enables using the Freescale i.MX SPI controllers in master
218 mode. 217 mode.
diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c
index 09df64950234..5b5709a5c957 100644
--- a/drivers/spi/spi-altera.c
+++ b/drivers/spi/spi-altera.c
@@ -13,7 +13,6 @@
13 * published by the Free Software Foundation. 13 * published by the Free Software Foundation.
14 */ 14 */
15 15
16#include <linux/init.h>
17#include <linux/interrupt.h> 16#include <linux/interrupt.h>
18#include <linux/errno.h> 17#include <linux/errno.h>
19#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c
index c3b2fb9b6713..3898b0b9ee77 100644
--- a/drivers/spi/spi-ath79.c
+++ b/drivers/spi/spi-ath79.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/spinlock.h> 18#include <linux/spinlock.h>
20#include <linux/workqueue.h> 19#include <linux/workqueue.h>
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 9641237295cd..8005f9869481 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/clk.h> 12#include <linux/clk.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/platform_device.h> 14#include <linux/platform_device.h>
diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index c1cd2e0f54d1..0250fa721cea 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/clk.h> 23#include <linux/clk.h>
25#include <linux/io.h> 24#include <linux/io.h>
26#include <linux/module.h> 25#include <linux/module.h>
diff --git a/drivers/spi/spi-bfin-sport.c b/drivers/spi/spi-bfin-sport.c
index 38941e5920b5..f515c5e9db57 100644
--- a/drivers/spi/spi-bfin-sport.c
+++ b/drivers/spi/spi-bfin-sport.c
@@ -8,7 +8,6 @@
8 * Licensed under the GPL-2 or later. 8 * Licensed under the GPL-2 or later.
9 */ 9 */
10 10
11#include <linux/init.h>
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/delay.h> 12#include <linux/delay.h>
14#include <linux/device.h> 13#include <linux/device.h>
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index 67aead248753..dc7d2c2d643e 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -16,7 +16,6 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 17 */
18 18
19#include <linux/init.h>
20#include <linux/spinlock.h> 19#include <linux/spinlock.h>
21#include <linux/workqueue.h> 20#include <linux/workqueue.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c
index a2b8ef5d8c59..4cd62f636547 100644
--- a/drivers/spi/spi-clps711x.c
+++ b/drivers/spi/spi-clps711x.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/init.h>
15#include <linux/gpio.h> 14#include <linux/gpio.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/module.h> 16#include <linux/module.h>
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index e97baf2f475c..09823076df88 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -19,7 +19,6 @@
19 */ 19 */
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/platform_device.h> 22#include <linux/platform_device.h>
24#include <linux/gpio.h> 23#include <linux/gpio.h>
25#include <linux/of.h> 24#include <linux/of.h>
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index f52372c403ee..5daff2054ae4 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -23,7 +23,6 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/init.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/io.h> 27#include <linux/io.h>
29#include <linux/irq.h> 28#include <linux/irq.h>
@@ -880,12 +879,12 @@ static int spi_imx_probe(struct platform_device *pdev)
880 879
881 spi_imx->irq = platform_get_irq(pdev, 0); 880 spi_imx->irq = platform_get_irq(pdev, 0);
882 if (spi_imx->irq < 0) { 881 if (spi_imx->irq < 0) {
883 ret = -EINVAL; 882 ret = spi_imx->irq;
884 goto out_master_put; 883 goto out_master_put;
885 } 884 }
886 885
887 ret = devm_request_irq(&pdev->dev, spi_imx->irq, spi_imx_isr, 0, 886 ret = devm_request_irq(&pdev->dev, spi_imx->irq, spi_imx_isr, 0,
888 DRIVER_NAME, spi_imx); 887 dev_name(&pdev->dev), spi_imx);
889 if (ret) { 888 if (ret) {
890 dev_err(&pdev->dev, "can't get irq%d: %d\n", spi_imx->irq, ret); 889 dev_err(&pdev->dev, "can't get irq%d: %d\n", spi_imx->irq, ret);
891 goto out_master_put; 890 goto out_master_put;
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index 5032141eeeec..3822eef2ef9d 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -16,7 +16,6 @@
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/errno.h> 19#include <linux/errno.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/of_address.h> 21#include <linux/of_address.h>
@@ -466,10 +465,8 @@ static void mpc512x_spi_cs_control(struct spi_device *spi, bool onoff)
466 gpio_set_value(spi->cs_gpio, onoff); 465 gpio_set_value(spi->cs_gpio, onoff);
467} 466}
468 467
469/* bus_num is used only for the case dev->platform_data == NULL */
470static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, 468static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
471 u32 size, unsigned int irq, 469 u32 size, unsigned int irq)
472 s16 bus_num)
473{ 470{
474 struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); 471 struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
475 struct mpc512x_psc_spi *mps; 472 struct mpc512x_psc_spi *mps;
@@ -488,7 +485,6 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
488 485
489 if (pdata == NULL) { 486 if (pdata == NULL) {
490 mps->cs_control = mpc512x_spi_cs_control; 487 mps->cs_control = mpc512x_spi_cs_control;
491 master->bus_num = bus_num;
492 } else { 488 } else {
493 mps->cs_control = pdata->cs_control; 489 mps->cs_control = pdata->cs_control;
494 master->bus_num = pdata->bus_num; 490 master->bus_num = pdata->bus_num;
@@ -574,7 +570,6 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
574{ 570{
575 const u32 *regaddr_p; 571 const u32 *regaddr_p;
576 u64 regaddr64, size64; 572 u64 regaddr64, size64;
577 s16 id = -1;
578 573
579 regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); 574 regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL);
580 if (!regaddr_p) { 575 if (!regaddr_p) {
@@ -583,16 +578,8 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
583 } 578 }
584 regaddr64 = of_translate_address(op->dev.of_node, regaddr_p); 579 regaddr64 = of_translate_address(op->dev.of_node, regaddr_p);
585 580
586 /* get PSC id (0..11, used by port_config) */
587 id = of_alias_get_id(op->dev.of_node, "spi");
588 if (id < 0) {
589 dev_err(&op->dev, "no alias id for %s\n",
590 op->dev.of_node->full_name);
591 return id;
592 }
593
594 return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64, 581 return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
595 irq_of_parse_and_map(op->dev.of_node, 0), id); 582 irq_of_parse_and_map(op->dev.of_node, 0));
596} 583}
597 584
598static int mpc512x_psc_spi_of_remove(struct platform_device *op) 585static int mpc512x_psc_spi_of_remove(struct platform_device *op)
diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c
index 00ba910ab302..3d18d9351185 100644
--- a/drivers/spi/spi-mpc52xx-psc.c
+++ b/drivers/spi/spi-mpc52xx-psc.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/types.h> 15#include <linux/types.h>
17#include <linux/errno.h> 16#include <linux/errno.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index e3d29a56d70a..aac2a5ddd964 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/errno.h> 15#include <linux/errno.h>
17#include <linux/of_platform.h> 16#include <linux/of_platform.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
@@ -357,17 +356,6 @@ static void mpc52xx_spi_wq(struct work_struct *work)
357 * spi_master ops 356 * spi_master ops
358 */ 357 */
359 358
360static int mpc52xx_spi_setup(struct spi_device *spi)
361{
362 if (spi->bits_per_word % 8)
363 return -EINVAL;
364
365 if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST))
366 return -EINVAL;
367
368 return 0;
369}
370
371static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m) 359static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m)
372{ 360{
373 struct mpc52xx_spi *ms = spi_master_get_devdata(spi->master); 361 struct mpc52xx_spi *ms = spi_master_get_devdata(spi->master);
@@ -430,9 +418,9 @@ static int mpc52xx_spi_probe(struct platform_device *op)
430 goto err_alloc; 418 goto err_alloc;
431 } 419 }
432 420
433 master->setup = mpc52xx_spi_setup;
434 master->transfer = mpc52xx_spi_transfer; 421 master->transfer = mpc52xx_spi_transfer;
435 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; 422 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
423 master->bits_per_word_mask = SPI_BPW_MASK(8);
436 master->dev.of_node = op->dev.of_node; 424 master->dev.of_node = op->dev.of_node;
437 425
438 platform_set_drvdata(op, master); 426 platform_set_drvdata(op, master);
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 79e5aa2250c8..2884f0c2f5f0 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -29,7 +29,6 @@
29 */ 29 */
30 30
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/init.h>
33#include <linux/ioport.h> 32#include <linux/ioport.h>
34#include <linux/of.h> 33#include <linux/of.h>
35#include <linux/of_device.h> 34#include <linux/of_device.h>
@@ -371,7 +370,7 @@ static int mxs_spi_transfer_one(struct spi_master *master,
371{ 370{
372 struct mxs_spi *spi = spi_master_get_devdata(master); 371 struct mxs_spi *spi = spi_master_get_devdata(master);
373 struct mxs_ssp *ssp = &spi->ssp; 372 struct mxs_ssp *ssp = &spi->ssp;
374 struct spi_transfer *t, *tmp_t; 373 struct spi_transfer *t;
375 unsigned int flag; 374 unsigned int flag;
376 int status = 0; 375 int status = 0;
377 376
@@ -381,7 +380,7 @@ static int mxs_spi_transfer_one(struct spi_master *master,
381 writel(mxs_spi_cs_to_reg(m->spi->chip_select), 380 writel(mxs_spi_cs_to_reg(m->spi->chip_select),
382 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET); 381 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
383 382
384 list_for_each_entry_safe(t, tmp_t, &m->transfers, transfer_list) { 383 list_for_each_entry(t, &m->transfers, transfer_list) {
385 384
386 status = mxs_spi_setup_transfer(m->spi, t); 385 status = mxs_spi_setup_transfer(m->spi, t);
387 if (status) 386 if (status)
@@ -473,7 +472,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
473 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 472 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
474 irq_err = platform_get_irq(pdev, 0); 473 irq_err = platform_get_irq(pdev, 0);
475 if (irq_err < 0) 474 if (irq_err < 0)
476 return -EINVAL; 475 return irq_err;
477 476
478 base = devm_ioremap_resource(&pdev->dev, iores); 477 base = devm_ioremap_resource(&pdev->dev, iores);
479 if (IS_ERR(base)) 478 if (IS_ERR(base))
diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c
index bae97ffec4b9..16e30de650b0 100644
--- a/drivers/spi/spi-nuc900.c
+++ b/drivers/spi/spi-nuc900.c
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/spinlock.h> 12#include <linux/spinlock.h>
14#include <linux/workqueue.h> 13#include <linux/workqueue.h>
15#include <linux/interrupt.h> 14#include <linux/interrupt.h>
@@ -38,7 +37,9 @@
38/* usi register bit */ 37/* usi register bit */
39#define ENINT (0x01 << 17) 38#define ENINT (0x01 << 17)
40#define ENFLG (0x01 << 16) 39#define ENFLG (0x01 << 16)
40#define SLEEP (0x0f << 12)
41#define TXNUM (0x03 << 8) 41#define TXNUM (0x03 << 8)
42#define TXBITLEN (0x1f << 3)
42#define TXNEG (0x01 << 2) 43#define TXNEG (0x01 << 2)
43#define RXNEG (0x01 << 1) 44#define RXNEG (0x01 << 1)
44#define LSB (0x01 << 10) 45#define LSB (0x01 << 10)
@@ -58,11 +59,8 @@ struct nuc900_spi {
58 unsigned char *rx; 59 unsigned char *rx;
59 struct clk *clk; 60 struct clk *clk;
60 struct spi_master *master; 61 struct spi_master *master;
61 struct spi_device *curdev;
62 struct device *dev;
63 struct nuc900_spi_info *pdata; 62 struct nuc900_spi_info *pdata;
64 spinlock_t lock; 63 spinlock_t lock;
65 struct resource *res;
66}; 64};
67 65
68static inline struct nuc900_spi *to_hw(struct spi_device *sdev) 66static inline struct nuc900_spi *to_hw(struct spi_device *sdev)
@@ -119,19 +117,16 @@ static void nuc900_spi_chipsel(struct spi_device *spi, int value)
119 } 117 }
120} 118}
121 119
122static void nuc900_spi_setup_txnum(struct nuc900_spi *hw, 120static void nuc900_spi_setup_txnum(struct nuc900_spi *hw, unsigned int txnum)
123 unsigned int txnum)
124{ 121{
125 unsigned int val; 122 unsigned int val;
126 unsigned long flags; 123 unsigned long flags;
127 124
128 spin_lock_irqsave(&hw->lock, flags); 125 spin_lock_irqsave(&hw->lock, flags);
129 126
130 val = __raw_readl(hw->regs + USI_CNT); 127 val = __raw_readl(hw->regs + USI_CNT) & ~TXNUM;
131 128
132 if (!txnum) 129 if (txnum)
133 val &= ~TXNUM;
134 else
135 val |= txnum << 0x08; 130 val |= txnum << 0x08;
136 131
137 __raw_writel(val, hw->regs + USI_CNT); 132 __raw_writel(val, hw->regs + USI_CNT);
@@ -148,7 +143,7 @@ static void nuc900_spi_setup_txbitlen(struct nuc900_spi *hw,
148 143
149 spin_lock_irqsave(&hw->lock, flags); 144 spin_lock_irqsave(&hw->lock, flags);
150 145
151 val = __raw_readl(hw->regs + USI_CNT); 146 val = __raw_readl(hw->regs + USI_CNT) & ~TXBITLEN;
152 147
153 val |= (txbitlen << 0x03); 148 val |= (txbitlen << 0x03);
154 149
@@ -287,12 +282,11 @@ static void nuc900_set_sleep(struct nuc900_spi *hw, unsigned int sleep)
287 282
288 spin_lock_irqsave(&hw->lock, flags); 283 spin_lock_irqsave(&hw->lock, flags);
289 284
290 val = __raw_readl(hw->regs + USI_CNT); 285 val = __raw_readl(hw->regs + USI_CNT) & ~SLEEP;
291 286
292 if (sleep) 287 if (sleep)
293 val |= (sleep << 12); 288 val |= (sleep << 12);
294 else 289
295 val &= ~(0x0f << 12);
296 __raw_writel(val, hw->regs + USI_CNT); 290 __raw_writel(val, hw->regs + USI_CNT);
297 291
298 spin_unlock_irqrestore(&hw->lock, flags); 292 spin_unlock_irqrestore(&hw->lock, flags);
@@ -338,6 +332,7 @@ static int nuc900_spi_probe(struct platform_device *pdev)
338{ 332{
339 struct nuc900_spi *hw; 333 struct nuc900_spi *hw;
340 struct spi_master *master; 334 struct spi_master *master;
335 struct resource *res;
341 int err = 0; 336 int err = 0;
342 337
343 master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); 338 master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi));
@@ -349,7 +344,6 @@ static int nuc900_spi_probe(struct platform_device *pdev)
349 hw = spi_master_get_devdata(master); 344 hw = spi_master_get_devdata(master);
350 hw->master = master; 345 hw->master = master;
351 hw->pdata = dev_get_platdata(&pdev->dev); 346 hw->pdata = dev_get_platdata(&pdev->dev);
352 hw->dev = &pdev->dev;
353 347
354 if (hw->pdata == NULL) { 348 if (hw->pdata == NULL) {
355 dev_err(&pdev->dev, "No platform data supplied\n"); 349 dev_err(&pdev->dev, "No platform data supplied\n");
@@ -369,8 +363,8 @@ static int nuc900_spi_probe(struct platform_device *pdev)
369 hw->bitbang.chipselect = nuc900_spi_chipsel; 363 hw->bitbang.chipselect = nuc900_spi_chipsel;
370 hw->bitbang.txrx_bufs = nuc900_spi_txrx; 364 hw->bitbang.txrx_bufs = nuc900_spi_txrx;
371 365
372 hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 366 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
373 hw->regs = devm_ioremap_resource(&pdev->dev, hw->res); 367 hw->regs = devm_ioremap_resource(&pdev->dev, res);
374 if (IS_ERR(hw->regs)) { 368 if (IS_ERR(hw->regs)) {
375 err = PTR_ERR(hw->regs); 369 err = PTR_ERR(hw->regs);
376 goto err_pdata; 370 goto err_pdata;
diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c
index f7c896e2981e..8998d11c7238 100644
--- a/drivers/spi/spi-oc-tiny.c
+++ b/drivers/spi/spi-oc-tiny.c
@@ -15,7 +15,6 @@
15 * published by the Free Software Foundation. 15 * published by the Free Software Foundation.
16 */ 16 */
17 17
18#include <linux/init.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/errno.h> 19#include <linux/errno.h>
21#include <linux/module.h> 20#include <linux/module.h>
@@ -267,8 +266,6 @@ static int tiny_spi_probe(struct platform_device *pdev)
267 266
268 /* setup the state for the bitbang driver */ 267 /* setup the state for the bitbang driver */
269 hw->bitbang.master = master; 268 hw->bitbang.master = master;
270 if (!hw->bitbang.master)
271 return err;
272 hw->bitbang.setup_transfer = tiny_spi_setup_transfer; 269 hw->bitbang.setup_transfer = tiny_spi_setup_transfer;
273 hw->bitbang.chipselect = tiny_spi_chipselect; 270 hw->bitbang.chipselect = tiny_spi_chipselect;
274 hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs; 271 hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs;
diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c
index e31f6d833951..c5e2f718eebd 100644
--- a/drivers/spi/spi-octeon.c
+++ b/drivers/spi/spi-octeon.c
@@ -11,7 +11,6 @@
11#include <linux/spi/spi.h> 11#include <linux/spi/spi.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/init.h>
15#include <linux/io.h> 14#include <linux/io.h>
16#include <linux/of.h> 15#include <linux/of.h>
17 16
@@ -33,13 +32,6 @@ struct octeon_spi {
33 u64 cs_enax; 32 u64 cs_enax;
34}; 33};
35 34
36struct octeon_spi_setup {
37 u32 max_speed_hz;
38 u8 chip_select;
39 u8 mode;
40 u8 bits_per_word;
41};
42
43static void octeon_spi_wait_ready(struct octeon_spi *p) 35static void octeon_spi_wait_ready(struct octeon_spi *p)
44{ 36{
45 union cvmx_mpi_sts mpi_sts; 37 union cvmx_mpi_sts mpi_sts;
@@ -57,6 +49,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
57 struct spi_transfer *xfer, 49 struct spi_transfer *xfer,
58 bool last_xfer) 50 bool last_xfer)
59{ 51{
52 struct spi_device *spi = msg->spi;
60 union cvmx_mpi_cfg mpi_cfg; 53 union cvmx_mpi_cfg mpi_cfg;
61 union cvmx_mpi_tx mpi_tx; 54 union cvmx_mpi_tx mpi_tx;
62 unsigned int clkdiv; 55 unsigned int clkdiv;
@@ -68,18 +61,11 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
68 int len; 61 int len;
69 int i; 62 int i;
70 63
71 struct octeon_spi_setup *msg_setup = spi_get_ctldata(msg->spi); 64 mode = spi->mode;
72
73 speed_hz = msg_setup->max_speed_hz;
74 mode = msg_setup->mode;
75 cpha = mode & SPI_CPHA; 65 cpha = mode & SPI_CPHA;
76 cpol = mode & SPI_CPOL; 66 cpol = mode & SPI_CPOL;
77 67
78 if (xfer->speed_hz) 68 speed_hz = xfer->speed_hz ? : spi->max_speed_hz;
79 speed_hz = xfer->speed_hz;
80
81 if (speed_hz > OCTEON_SPI_MAX_CLOCK_HZ)
82 speed_hz = OCTEON_SPI_MAX_CLOCK_HZ;
83 69
84 clkdiv = octeon_get_io_clock_rate() / (2 * speed_hz); 70 clkdiv = octeon_get_io_clock_rate() / (2 * speed_hz);
85 71
@@ -93,8 +79,8 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
93 mpi_cfg.s.cslate = cpha ? 1 : 0; 79 mpi_cfg.s.cslate = cpha ? 1 : 0;
94 mpi_cfg.s.enable = 1; 80 mpi_cfg.s.enable = 1;
95 81
96 if (msg_setup->chip_select < 4) 82 if (spi->chip_select < 4)
97 p->cs_enax |= 1ull << (12 + msg_setup->chip_select); 83 p->cs_enax |= 1ull << (12 + spi->chip_select);
98 mpi_cfg.u64 |= p->cs_enax; 84 mpi_cfg.u64 |= p->cs_enax;
99 85
100 if (mpi_cfg.u64 != p->last_cfg) { 86 if (mpi_cfg.u64 != p->last_cfg) {
@@ -114,7 +100,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
114 cvmx_write_csr(p->register_base + OCTEON_SPI_DAT0 + (8 * i), d); 100 cvmx_write_csr(p->register_base + OCTEON_SPI_DAT0 + (8 * i), d);
115 } 101 }
116 mpi_tx.u64 = 0; 102 mpi_tx.u64 = 0;
117 mpi_tx.s.csid = msg_setup->chip_select; 103 mpi_tx.s.csid = spi->chip_select;
118 mpi_tx.s.leavecs = 1; 104 mpi_tx.s.leavecs = 1;
119 mpi_tx.s.txnum = tx_buf ? OCTEON_SPI_MAX_BYTES : 0; 105 mpi_tx.s.txnum = tx_buf ? OCTEON_SPI_MAX_BYTES : 0;
120 mpi_tx.s.totnum = OCTEON_SPI_MAX_BYTES; 106 mpi_tx.s.totnum = OCTEON_SPI_MAX_BYTES;
@@ -139,7 +125,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
139 } 125 }
140 126
141 mpi_tx.u64 = 0; 127 mpi_tx.u64 = 0;
142 mpi_tx.s.csid = msg_setup->chip_select; 128 mpi_tx.s.csid = spi->chip_select;
143 if (last_xfer) 129 if (last_xfer)
144 mpi_tx.s.leavecs = xfer->cs_change; 130 mpi_tx.s.leavecs = xfer->cs_change;
145 else 131 else
@@ -169,17 +155,9 @@ static int octeon_spi_transfer_one_message(struct spi_master *master,
169 int status = 0; 155 int status = 0;
170 struct spi_transfer *xfer; 156 struct spi_transfer *xfer;
171 157
172 /*
173 * We better have set the configuration via a call to .setup
174 * before we get here.
175 */
176 if (spi_get_ctldata(msg->spi) == NULL) {
177 status = -EINVAL;
178 goto err;
179 }
180
181 list_for_each_entry(xfer, &msg->transfers, transfer_list) { 158 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
182 bool last_xfer = &xfer->transfer_list == msg->transfers.prev; 159 bool last_xfer = list_is_last(&xfer->transfer_list,
160 &msg->transfers);
183 int r = octeon_spi_do_transfer(p, msg, xfer, last_xfer); 161 int r = octeon_spi_do_transfer(p, msg, xfer, last_xfer);
184 if (r < 0) { 162 if (r < 0) {
185 status = r; 163 status = r;
@@ -194,41 +172,6 @@ err:
194 return status; 172 return status;
195} 173}
196 174
197static struct octeon_spi_setup *octeon_spi_new_setup(struct spi_device *spi)
198{
199 struct octeon_spi_setup *setup = kzalloc(sizeof(*setup), GFP_KERNEL);
200 if (!setup)
201 return NULL;
202
203 setup->max_speed_hz = spi->max_speed_hz;
204 setup->chip_select = spi->chip_select;
205 setup->mode = spi->mode;
206 setup->bits_per_word = spi->bits_per_word;
207 return setup;
208}
209
210static int octeon_spi_setup(struct spi_device *spi)
211{
212 struct octeon_spi_setup *new_setup;
213 struct octeon_spi_setup *old_setup = spi_get_ctldata(spi);
214
215 new_setup = octeon_spi_new_setup(spi);
216 if (!new_setup)
217 return -ENOMEM;
218
219 spi_set_ctldata(spi, new_setup);
220 kfree(old_setup);
221
222 return 0;
223}
224
225static void octeon_spi_cleanup(struct spi_device *spi)
226{
227 struct octeon_spi_setup *old_setup = spi_get_ctldata(spi);
228 spi_set_ctldata(spi, NULL);
229 kfree(old_setup);
230}
231
232static int octeon_spi_probe(struct platform_device *pdev) 175static int octeon_spi_probe(struct platform_device *pdev)
233{ 176{
234 struct resource *res_mem; 177 struct resource *res_mem;
@@ -264,10 +207,9 @@ static int octeon_spi_probe(struct platform_device *pdev)
264 SPI_LSB_FIRST | 207 SPI_LSB_FIRST |
265 SPI_3WIRE; 208 SPI_3WIRE;
266 209
267 master->setup = octeon_spi_setup;
268 master->cleanup = octeon_spi_cleanup;
269 master->transfer_one_message = octeon_spi_transfer_one_message; 210 master->transfer_one_message = octeon_spi_transfer_one_message;
270 master->bits_per_word_mask = SPI_BPW_MASK(8); 211 master->bits_per_word_mask = SPI_BPW_MASK(8);
212 master->max_speed_hz = OCTEON_SPI_MAX_CLOCK_HZ;
271 213
272 master->dev.of_node = pdev->dev.of_node; 214 master->dev.of_node = pdev->dev.of_node;
273 err = devm_spi_register_master(&pdev->dev, master); 215 err = devm_spi_register_master(&pdev->dev, master);
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index a72127f08e39..94f133cb2770 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/init.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <linux/device.h> 27#include <linux/device.h>
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index 7f2121fe2622..a362425400ea 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -9,7 +9,6 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#include <linux/init.h>
13#include <linux/interrupt.h> 12#include <linux/interrupt.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include <linux/platform_device.h> 14#include <linux/platform_device.h>
diff --git a/drivers/spi/spi-ppc4xx.c b/drivers/spi/spi-ppc4xx.c
index 5ee56726f8d0..80b8408ac3e3 100644
--- a/drivers/spi/spi-ppc4xx.c
+++ b/drivers/spi/spi-ppc4xx.c
@@ -24,7 +24,6 @@
24 */ 24 */
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/init.h>
28#include <linux/sched.h> 27#include <linux/sched.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <linux/errno.h> 29#include <linux/errno.h>
diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c
index 3c0b55125f1e..713af4806f26 100644
--- a/drivers/spi/spi-pxa2xx-dma.c
+++ b/drivers/spi/spi-pxa2xx-dma.c
@@ -9,7 +9,6 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#include <linux/init.h>
13#include <linux/device.h> 12#include <linux/device.h>
14#include <linux/dma-mapping.h> 13#include <linux/dma-mapping.h>
15#include <linux/dmaengine.h> 14#include <linux/dmaengine.h>
diff --git a/drivers/spi/spi-pxa2xx-pxadma.c b/drivers/spi/spi-pxa2xx-pxadma.c
index 2916efc7cfe5..e8a26f25d5c0 100644
--- a/drivers/spi/spi-pxa2xx-pxadma.c
+++ b/drivers/spi/spi-pxa2xx-pxadma.c
@@ -18,7 +18,6 @@
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#include <linux/init.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/device.h> 22#include <linux/device.h>
24#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c
index 746424aa5353..c20df45204e2 100644
--- a/drivers/spi/spi-s3c24xx.c
+++ b/drivers/spi/spi-s3c24xx.c
@@ -9,7 +9,6 @@
9 * 9 *
10*/ 10*/
11 11
12#include <linux/init.h>
13#include <linux/spinlock.h> 12#include <linux/spinlock.h>
14#include <linux/workqueue.h> 13#include <linux/workqueue.h>
15#include <linux/interrupt.h> 14#include <linux/interrupt.h>
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 81cc02f5f9b0..33474061b742 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -15,7 +15,6 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/init.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/io.h> 19#include <linux/io.h>
21#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c
index 38eb24df796c..85c2efd57c80 100644
--- a/drivers/spi/spi-sh-sci.c
+++ b/drivers/spi/spi-sh-sci.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/spinlock.h> 18#include <linux/spinlock.h>
20#include <linux/workqueue.h> 19#include <linux/workqueue.h>
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index f176ad7b8f16..6be661e4c6e1 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -23,7 +23,6 @@
23#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
24#include <linux/dmapool.h> 24#include <linux/dmapool.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/init.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/io.h> 27#include <linux/io.h>
29#include <linux/kernel.h> 28#include <linux/kernel.h>
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index c45135e371b4..47869ea636e1 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -22,7 +22,6 @@
22#include <linux/completion.h> 22#include <linux/completion.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/init.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/io.h> 26#include <linux/io.h>
28#include <linux/kernel.h> 27#include <linux/kernel.h>
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index eb5b771e1575..e3c1b93e45d1 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -23,7 +23,6 @@
23#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
24#include <linux/dmapool.h> 24#include <linux/dmapool.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/init.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/io.h> 27#include <linux/io.h>
29#include <linux/kernel.h> 28#include <linux/kernel.h>
diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c
index 24c40b13dab1..350a76b7e8d4 100644
--- a/drivers/spi/spi-xcomm.c
+++ b/drivers/spi/spi-xcomm.c
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/init.h>
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/delay.h> 12#include <linux/delay.h>
14#include <linux/i2c.h> 13#include <linux/i2c.h>
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 6d4ce4615163..e6cd1112ae40 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
19#include <linux/of.h> 18#include <linux/of.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>