Skip to content

Commit a56f489

Browse files
committed
Merge tag 'spi-v4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi updates from Mark Brown: "Another quiet release for SPI, almost entirely driver specific changes with the diffstat dominated by two new drivers which are about two thirds of it in terms of lines of code: - new drivers for PIC32 standard and SQI controllers - the Cadence driver has had runtime PM support added and quite a few fixes and cleanups - flash-specific accelerated path support now has a feature query interface - the pxa2xx driver has been moved to use the core DMA mapping support" * tag 'spi-v4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (48 commits) spi: pic32-sqi: Fix linker error, undefined reference to `bad_dma_ops' spi: dw-pci: Spelling s/paltforms/platforms/g spi: pic32-sqi: Remove pic32_sqi_setup and pic32_sqi_cleanup spi: Fix simple typo s/impelment/implement spi: rockchip: potential NULL dereference on error spi: zynqmp: disable clocks in error paths spi: Drop unnecessary dependencies on relaxed I/O accessors spi: qup: Add spi_master_put in remove function spi: qup: Handle clocks in pm_runtime suspend and resume spi: st-ssc4: Fix missing spi_master_put in spi_st_probe error paths spi: st-ssc4: Allow compile test build spi: omap2-mcspi: Use dma_request_chan() for requesting DMA channel spi: davinci: Use dma_request_chan() for requesting DMA channel spi: pic32: Fix checking return value of devm_ioremap_resource spi: spi-fsl-dspi: Update DT binding documentation spi: Drop duplicate code to set master->dev.parent spi: pic32: Set proper bits_per_word_mask spi: return error if kmap'd buffers passed to spi_map_buf() spi: core: add hook flash_read_supported to spi_master spi: pic32-sqi: silence array overflow warning ...
2 parents 8bc4d5f + c4e85b7 commit a56f489

27 files changed

+2033
-288
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Microchip PIC32 SPI Master controller
2+
3+
Required properties:
4+
- compatible: Should be "microchip,pic32mzda-spi".
5+
- reg: Address and length of register space for the device.
6+
- interrupts: Should contain all three spi interrupts in sequence
7+
of <fault-irq>, <receive-irq>, <transmit-irq>.
8+
- interrupt-names: Should be "fault", "rx", "tx" in order.
9+
- clocks: Phandle of the clock generating SPI clock on the bus.
10+
- clock-names: Should be "mck0".
11+
- cs-gpios: Specifies the gpio pins to be used for chipselects.
12+
See: Documentation/devicetree/bindings/spi/spi-bus.txt
13+
14+
Optional properties:
15+
- dmas: Two or more DMA channel specifiers following the convention outlined
16+
in Documentation/devicetree/bindings/dma/dma.txt
17+
- dma-names: Names for the dma channels. There must be at least one channel
18+
named "spi-tx" for transmit and named "spi-rx" for receive.
19+
20+
Example:
21+
22+
spi1: spi@1f821000 {
23+
compatible = "microchip,pic32mzda-spi";
24+
reg = <0x1f821000 0x200>;
25+
interrupts = <109 IRQ_TYPE_LEVEL_HIGH>,
26+
<110 IRQ_TYPE_LEVEL_HIGH>,
27+
<111 IRQ_TYPE_LEVEL_HIGH>;
28+
interrupt-names = "fault", "rx", "tx";
29+
clocks = <&PBCLK2>;
30+
clock-names = "mck0";
31+
cs-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>;
32+
dmas = <&dma 134>, <&dma 135>;
33+
dma-names = "spi-rx", "spi-tx";
34+
};

Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Required properties:
1616

1717
Optional property:
1818
- big-endian: If present the dspi device's registers are implemented
19-
in big endian mode, otherwise in native mode(same with CPU), for more
20-
detail please see: Documentation/devicetree/bindings/regmap/regmap.txt.
19+
in big endian mode.
2120

2221
Optional SPI slave node properties:
2322
- fsl,spi-cs-sck-delay: a delay in nanoseconds between activating chip
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Microchip PIC32 Quad SPI controller
2+
-----------------------------------
3+
Required properties:
4+
- compatible: Should be "microchip,pic32mzda-sqi".
5+
- reg: Address and length of SQI controller register space.
6+
- interrupts: Should contain SQI interrupt.
7+
- clocks: Should contain phandle of two clocks in sequence, one that drives
8+
clock on SPI bus and other that drives SQI controller.
9+
- clock-names: Should be "spi_ck" and "reg_ck" in order.
10+
11+
Example:
12+
sqi1: spi@1f8e2000 {
13+
compatible = "microchip,pic32mzda-sqi";
14+
reg = <0x1f8e2000 0x200>;
15+
clocks = <&rootclk REF2CLK>, <&rootclk PB5CLK>;
16+
clock-names = "spi_ck", "reg_ck";
17+
interrupts = <169 IRQ_TYPE_LEVEL_HIGH>;
18+
};

drivers/spi/Kconfig

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ config SPI_OMAP_UWIRE
410410
config SPI_OMAP24XX
411411
tristate "McSPI driver for OMAP"
412412
depends on HAS_DMA
413-
depends on ARM || ARM64 || AVR32 || HEXAGON || MIPS || SUPERH
414413
depends on ARCH_OMAP2PLUS || COMPILE_TEST
415414
help
416415
SPI master controller for OMAP24XX and later Multichannel SPI
@@ -432,10 +431,23 @@ config SPI_OMAP_100K
432431

433432
config SPI_ORION
434433
tristate "Orion SPI master"
435-
depends on PLAT_ORION || COMPILE_TEST
434+
depends on PLAT_ORION || ARCH_MVEBU || COMPILE_TEST
436435
help
437436
This enables using the SPI master controller on the Orion chips.
438437

438+
config SPI_PIC32
439+
tristate "Microchip PIC32 series SPI"
440+
depends on MACH_PIC32 || COMPILE_TEST
441+
help
442+
SPI driver for Microchip PIC32 SPI master controller.
443+
444+
config SPI_PIC32_SQI
445+
tristate "Microchip PIC32 Quad SPI driver"
446+
depends on MACH_PIC32 || COMPILE_TEST
447+
depends on HAS_DMA
448+
help
449+
SPI driver for PIC32 Quad SPI controller.
450+
439451
config SPI_PL022
440452
tristate "ARM AMBA PL022 SSP controller"
441453
depends on ARM_AMBA
@@ -469,7 +481,6 @@ config SPI_PXA2XX_PCI
469481

470482
config SPI_ROCKCHIP
471483
tristate "Rockchip SPI controller driver"
472-
depends on ARM || ARM64 || AVR32 || HEXAGON || MIPS || SUPERH
473484
help
474485
This selects a driver for Rockchip SPI controller.
475486

@@ -569,7 +580,7 @@ config SPI_SIRF
569580

570581
config SPI_ST_SSC4
571582
tristate "STMicroelectronics SPI SSC-based driver"
572-
depends on ARCH_STI
583+
depends on ARCH_STI || COMPILE_TEST
573584
help
574585
STMicroelectronics SoCs support for SPI. If you say yes to
575586
this option, support will be included for the SSC driven SPI.
@@ -656,7 +667,7 @@ config SPI_XILINX
656667

657668
config SPI_XLP
658669
tristate "Netlogic XLP SPI controller driver"
659-
depends on CPU_XLP || COMPILE_TEST
670+
depends on CPU_XLP || ARCH_VULCAN || COMPILE_TEST
660671
help
661672
Enable support for the SPI controller on the Netlogic XLP SoCs.
662673
Currently supported XLP variants are XLP8XX, XLP3XX, XLP2XX, XLP9XX

drivers/spi/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ obj-$(CONFIG_SPI_OMAP_100K) += spi-omap-100k.o
6262
obj-$(CONFIG_SPI_OMAP24XX) += spi-omap2-mcspi.o
6363
obj-$(CONFIG_SPI_TI_QSPI) += spi-ti-qspi.o
6464
obj-$(CONFIG_SPI_ORION) += spi-orion.o
65+
obj-$(CONFIG_SPI_PIC32) += spi-pic32.o
66+
obj-$(CONFIG_SPI_PIC32_SQI) += spi-pic32-sqi.o
6567
obj-$(CONFIG_SPI_PL022) += spi-pl022.o
6668
obj-$(CONFIG_SPI_PPC4xx) += spi-ppc4xx.o
6769
spi-pxa2xx-platform-objs := spi-pxa2xx.o spi-pxa2xx-dma.o

drivers/spi/spi-axi-spi-engine.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@ static int spi_engine_probe(struct platform_device *pdev)
525525
if (ret)
526526
goto err_ref_clk_disable;
527527

528-
master->dev.parent = &pdev->dev;
529528
master->dev.of_node = pdev->dev.of_node;
530529
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE;
531530
master->bits_per_word_mask = SPI_BPW_MASK(8);

drivers/spi/spi-bcm53xx.c

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@
1010
#include "spi-bcm53xx.h"
1111

1212
#define BCM53XXSPI_MAX_SPI_BAUD 13500000 /* 216 MHz? */
13+
#define BCM53XXSPI_FLASH_WINDOW SZ_32M
1314

1415
/* The longest observed required wait was 19 ms */
1516
#define BCM53XXSPI_SPE_TIMEOUT_MS 80
1617

1718
struct bcm53xxspi {
1819
struct bcma_device *core;
1920
struct spi_master *master;
21+
void __iomem *mmio_base;
2022

2123
size_t read_offset;
24+
bool bspi; /* Boot SPI mode with memory mapping */
2225
};
2326

2427
static inline u32 bcm53xxspi_read(struct bcm53xxspi *b53spi, u16 offset)
@@ -32,6 +35,50 @@ static inline void bcm53xxspi_write(struct bcm53xxspi *b53spi, u16 offset,
3235
bcma_write32(b53spi->core, offset, value);
3336
}
3437

38+
static void bcm53xxspi_disable_bspi(struct bcm53xxspi *b53spi)
39+
{
40+
struct device *dev = &b53spi->core->dev;
41+
unsigned long deadline;
42+
u32 tmp;
43+
44+
if (!b53spi->bspi)
45+
return;
46+
47+
tmp = bcm53xxspi_read(b53spi, B53SPI_BSPI_MAST_N_BOOT_CTRL);
48+
if (tmp & 0x1)
49+
return;
50+
51+
deadline = jiffies + usecs_to_jiffies(200);
52+
do {
53+
tmp = bcm53xxspi_read(b53spi, B53SPI_BSPI_BUSY_STATUS);
54+
if (!(tmp & 0x1)) {
55+
bcm53xxspi_write(b53spi, B53SPI_BSPI_MAST_N_BOOT_CTRL,
56+
0x1);
57+
ndelay(200);
58+
b53spi->bspi = false;
59+
return;
60+
}
61+
udelay(1);
62+
} while (!time_after_eq(jiffies, deadline));
63+
64+
dev_warn(dev, "Timeout disabling BSPI\n");
65+
}
66+
67+
static void bcm53xxspi_enable_bspi(struct bcm53xxspi *b53spi)
68+
{
69+
u32 tmp;
70+
71+
if (b53spi->bspi)
72+
return;
73+
74+
tmp = bcm53xxspi_read(b53spi, B53SPI_BSPI_MAST_N_BOOT_CTRL);
75+
if (!(tmp & 0x1))
76+
return;
77+
78+
bcm53xxspi_write(b53spi, B53SPI_BSPI_MAST_N_BOOT_CTRL, 0x0);
79+
b53spi->bspi = true;
80+
}
81+
3582
static inline unsigned int bcm53xxspi_calc_timeout(size_t len)
3683
{
3784
/* Do some magic calculation based on length and buad. Add 10% and 1. */
@@ -176,6 +223,8 @@ static int bcm53xxspi_transfer_one(struct spi_master *master,
176223
u8 *buf;
177224
size_t left;
178225

226+
bcm53xxspi_disable_bspi(b53spi);
227+
179228
if (t->tx_buf) {
180229
buf = (u8 *)t->tx_buf;
181230
left = t->len;
@@ -206,6 +255,22 @@ static int bcm53xxspi_transfer_one(struct spi_master *master,
206255
return 0;
207256
}
208257

258+
static int bcm53xxspi_flash_read(struct spi_device *spi,
259+
struct spi_flash_read_message *msg)
260+
{
261+
struct bcm53xxspi *b53spi = spi_master_get_devdata(spi->master);
262+
int ret = 0;
263+
264+
if (msg->from + msg->len > BCM53XXSPI_FLASH_WINDOW)
265+
return -EINVAL;
266+
267+
bcm53xxspi_enable_bspi(b53spi);
268+
memcpy_fromio(msg->buf, b53spi->mmio_base + msg->from, msg->len);
269+
msg->retlen = msg->len;
270+
271+
return ret;
272+
}
273+
209274
/**************************************************
210275
* BCMA
211276
**************************************************/
@@ -222,6 +287,7 @@ MODULE_DEVICE_TABLE(bcma, bcm53xxspi_bcma_tbl);
222287

223288
static int bcm53xxspi_bcma_probe(struct bcma_device *core)
224289
{
290+
struct device *dev = &core->dev;
225291
struct bcm53xxspi *b53spi;
226292
struct spi_master *master;
227293
int err;
@@ -231,19 +297,27 @@ static int bcm53xxspi_bcma_probe(struct bcma_device *core)
231297
return -ENOTSUPP;
232298
}
233299

234-
master = spi_alloc_master(&core->dev, sizeof(*b53spi));
300+
master = spi_alloc_master(dev, sizeof(*b53spi));
235301
if (!master)
236302
return -ENOMEM;
237303

238304
b53spi = spi_master_get_devdata(master);
239305
b53spi->master = master;
240306
b53spi->core = core;
241307

308+
if (core->addr_s[0])
309+
b53spi->mmio_base = devm_ioremap(dev, core->addr_s[0],
310+
BCM53XXSPI_FLASH_WINDOW);
311+
b53spi->bspi = true;
312+
bcm53xxspi_disable_bspi(b53spi);
313+
242314
master->transfer_one = bcm53xxspi_transfer_one;
315+
if (b53spi->mmio_base)
316+
master->spi_flash_read = bcm53xxspi_flash_read;
243317

244318
bcma_set_drvdata(core, b53spi);
245319

246-
err = devm_spi_register_master(&core->dev, master);
320+
err = devm_spi_register_master(dev, master);
247321
if (err) {
248322
spi_master_put(master);
249323
bcma_set_drvdata(core, NULL);

0 commit comments

Comments
 (0)