Skip to content

Commit a34fc82

Browse files
committed
Merge branch 'spi-next' from git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git
Pull in the changes Mark has queued up for SPI
2 parents 161b96c + 227c4ce commit a34fc82

15 files changed

Lines changed: 2257 additions & 78 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
NVIDIA Tegra20 SFLASH controller.
2+
3+
Required properties:
4+
- compatible : should be "nvidia,tegra20-sflash".
5+
- reg: Should contain SFLASH registers location and length.
6+
- interrupts: Should contain SFLASH interrupts.
7+
- nvidia,dma-request-selector : The Tegra DMA controller's phandle and
8+
request selector for this SFLASH controller.
9+
10+
Recommended properties:
11+
- spi-max-frequency: Definition as per
12+
Documentation/devicetree/bindings/spi/spi-bus.txt
13+
14+
Example:
15+
16+
spi@7000d600 {
17+
compatible = "nvidia,tegra20-sflash";
18+
reg = <0x7000c380 0x80>;
19+
interrupts = <0 39 0x04>;
20+
nvidia,dma-request-selector = <&apbdma 16>;
21+
spi-max-frequency = <25000000>;
22+
#address-cells = <1>;
23+
#size-cells = <0>;
24+
status = "disabled";
25+
};
26+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
NVIDIA Tegra20/Tegra30 SLINK controller.
2+
3+
Required properties:
4+
- compatible : should be "nvidia,tegra20-slink", "nvidia,tegra30-slink".
5+
- reg: Should contain SLINK registers location and length.
6+
- interrupts: Should contain SLINK interrupts.
7+
- nvidia,dma-request-selector : The Tegra DMA controller's phandle and
8+
request selector for this SLINK controller.
9+
10+
Recommended properties:
11+
- spi-max-frequency: Definition as per
12+
Documentation/devicetree/bindings/spi/spi-bus.txt
13+
14+
Example:
15+
16+
slink@7000d600 {
17+
compatible = "nvidia,tegra20-slink";
18+
reg = <0x7000d600 0x200>;
19+
interrupts = <0 82 0x04>;
20+
nvidia,dma-request-selector = <&apbdma 16>;
21+
spi-max-frequency = <25000000>;
22+
#address-cells = <1>;
23+
#size-cells = <0>;
24+
status = "disabled";
25+
};
26+

‎Documentation/devicetree/bindings/spi/omap-spi.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Required properties:
66
- "ti,omap4-spi" for OMAP4+.
77
- ti,spi-num-cs : Number of chipselect supported by the instance.
88
- ti,hwmods: Name of the hwmod associated to the McSPI
9-
9+
- ti,pindir-d0-out-d1-in: Select the D0 pin as output and D1 as
10+
input. The default is D0 as input and
11+
D1 as output.
1012

1113
Example:
1214

‎drivers/spi/Kconfig‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,20 @@ config SPI_MXS
392392
help
393393
SPI driver for Freescale MXS devices.
394394

395+
config SPI_TEGRA20_SFLASH
396+
tristate "Nvidia Tegra20 Serial flash Controller"
397+
depends on ARCH_TEGRA
398+
help
399+
SPI driver for Nvidia Tegra20 Serial flash Controller interface.
400+
The main usecase of this controller is to use spi flash as boot
401+
device.
402+
403+
config SPI_TEGRA20_SLINK
404+
tristate "Nvidia Tegra20/Tegra30 SLINK Controller"
405+
depends on ARCH_TEGRA && TEGRA20_APB_DMA
406+
help
407+
SPI driver for Nvidia Tegra20/Tegra30 SLINK Controller interface.
408+
395409
config SPI_TI_SSP
396410
tristate "TI Sequencer Serial Port - SPI Support"
397411
depends on MFD_TI_SSP

‎drivers/spi/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o
6161
obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o
6262
obj-$(CONFIG_SPI_SIRF) += spi-sirf.o
6363
obj-$(CONFIG_SPI_STMP3XXX) += spi-stmp.o
64+
obj-$(CONFIG_SPI_TEGRA20_SFLASH) += spi-tegra20-sflash.o
65+
obj-$(CONFIG_SPI_TEGRA20_SLINK) += spi-tegra20-slink.o
6466
obj-$(CONFIG_SPI_TI_SSP) += spi-ti-ssp.o
6567
obj-$(CONFIG_SPI_TLE62X0) += spi-tle62x0.o
6668
obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi-topcliff-pch.o
6769
obj-$(CONFIG_SPI_TXX9) += spi-txx9.o
6870
obj-$(CONFIG_SPI_XCOMM) += spi-xcomm.o
6971
obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o
70-

‎drivers/spi/spi-bcm63xx.c‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <bcm63xx_dev_spi.h>
3737

3838
#define PFX KBUILD_MODNAME
39-
#define DRV_VER "0.1.2"
4039

4140
struct bcm63xx_spi {
4241
struct completion done;
@@ -170,13 +169,6 @@ static int bcm63xx_spi_setup(struct spi_device *spi)
170169
return -EINVAL;
171170
}
172171

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-
180172
dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n",
181173
__func__, spi->mode & MODEBITS, spi->bits_per_word, 0);
182174

@@ -441,8 +433,8 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev)
441433
goto out_clk_disable;
442434
}
443435

444-
dev_info(dev, "at 0x%08x (irq %d, FIFOs size %d) v%s\n",
445-
r->start, irq, bs->fifo_size, DRV_VER);
436+
dev_info(dev, "at 0x%08x (irq %d, FIFOs size %d)\n",
437+
r->start, irq, bs->fifo_size);
446438

447439
return 0;
448440

@@ -485,6 +477,8 @@ static int bcm63xx_spi_suspend(struct device *dev)
485477
platform_get_drvdata(to_platform_device(dev));
486478
struct bcm63xx_spi *bs = spi_master_get_devdata(master);
487479

480+
spi_master_suspend(master);
481+
488482
clk_disable(bs->clk);
489483

490484
return 0;
@@ -498,6 +492,8 @@ static int bcm63xx_spi_resume(struct device *dev)
498492

499493
clk_enable(bs->clk);
500494

495+
spi_master_resume(master);
496+
501497
return 0;
502498
}
503499

‎drivers/spi/spi-omap2-mcspi.c‎

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct omap2_mcspi {
129129
struct omap2_mcspi_dma *dma_channels;
130130
struct device *dev;
131131
struct omap2_mcspi_regs ctx;
132+
unsigned int pin_dir:1;
132133
};
133134

134135
struct omap2_mcspi_cs {
@@ -322,19 +323,11 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
322323
struct omap2_mcspi *mcspi;
323324
struct omap2_mcspi_dma *mcspi_dma;
324325
unsigned int count;
325-
u8 * rx;
326-
const u8 * tx;
327-
void __iomem *chstat_reg;
328-
struct omap2_mcspi_cs *cs = spi->controller_state;
329326

330327
mcspi = spi_master_get_devdata(spi->master);
331328
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
332329
count = xfer->len;
333330

334-
rx = xfer->rx_buf;
335-
tx = xfer->tx_buf;
336-
chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
337-
338331
if (mcspi_dma->dma_tx) {
339332
struct dma_async_tx_descriptor *tx;
340333
struct scatterlist sg;
@@ -358,19 +351,6 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
358351
dma_async_issue_pending(mcspi_dma->dma_tx);
359352
omap2_mcspi_set_dma_req(spi, 0, 1);
360353

361-
wait_for_completion(&mcspi_dma->dma_tx_completion);
362-
dma_unmap_single(mcspi->dev, xfer->tx_dma, count,
363-
DMA_TO_DEVICE);
364-
365-
/* for TX_ONLY mode, be sure all words have shifted out */
366-
if (rx == NULL) {
367-
if (mcspi_wait_for_reg_bit(chstat_reg,
368-
OMAP2_MCSPI_CHSTAT_TXS) < 0)
369-
dev_err(&spi->dev, "TXS timed out\n");
370-
else if (mcspi_wait_for_reg_bit(chstat_reg,
371-
OMAP2_MCSPI_CHSTAT_EOT) < 0)
372-
dev_err(&spi->dev, "EOT timed out\n");
373-
}
374354
}
375355

376356
static unsigned
@@ -491,6 +471,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
491471
struct dma_slave_config cfg;
492472
enum dma_slave_buswidth width;
493473
unsigned es;
474+
void __iomem *chstat_reg;
494475

495476
mcspi = spi_master_get_devdata(spi->master);
496477
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
@@ -525,8 +506,24 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
525506
omap2_mcspi_tx_dma(spi, xfer, cfg);
526507

527508
if (rx != NULL)
528-
return omap2_mcspi_rx_dma(spi, xfer, cfg, es);
529-
509+
count = omap2_mcspi_rx_dma(spi, xfer, cfg, es);
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+
}
530527
return count;
531528
}
532529

@@ -764,8 +761,15 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
764761
/* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS
765762
* REVISIT: this controller could support SPI_3WIRE mode.
766763
*/
767-
l &= ~(OMAP2_MCSPI_CHCONF_IS|OMAP2_MCSPI_CHCONF_DPE1);
768-
l |= OMAP2_MCSPI_CHCONF_DPE0;
764+
if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {
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+
}
769773

770774
/* wordlength */
771775
l &= ~OMAP2_MCSPI_CHCONF_WL_MASK;
@@ -1166,6 +1170,11 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
11661170
master->cleanup = omap2_mcspi_cleanup;
11671171
master->dev.of_node = node;
11681172

1173+
dev_set_drvdata(&pdev->dev, master);
1174+
1175+
mcspi = spi_master_get_devdata(master);
1176+
mcspi->master = master;
1177+
11691178
match = of_match_device(omap_mcspi_of_match, &pdev->dev);
11701179
if (match) {
11711180
u32 num_cs = 1; /* default number of chipselect */
@@ -1174,19 +1183,17 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
11741183
of_property_read_u32(node, "ti,spi-num-cs", &num_cs);
11751184
master->num_chipselect = num_cs;
11761185
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;
11771188
} else {
11781189
pdata = pdev->dev.platform_data;
11791190
master->num_chipselect = pdata->num_cs;
11801191
if (pdev->id != -1)
11811192
master->bus_num = pdev->id;
1193+
mcspi->pin_dir = pdata->pin_dir;
11821194
}
11831195
regs_offset = pdata->regs_offset;
11841196

1185-
dev_set_drvdata(&pdev->dev, master);
1186-
1187-
mcspi = spi_master_get_devdata(master);
1188-
mcspi->master = master;
1189-
11901197
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
11911198
if (r == NULL) {
11921199
status = -ENODEV;

0 commit comments

Comments
 (0)