Skip to content

Commit b340941

Browse files
committed
Merge remote-tracking branches 'spi/topic/octeon', 'spi/topic/omap2-mcspi', 'spi/topic/orion', 'spi/topic/pic32' and 'spi/topic/pic32-qspi' into spi-next
6 parents c36581c + 3ae36c8 + b085c61 + 710a1d5 + 866e48b + 21825ff commit b340941

File tree

8 files changed

+1697
-77
lines changed

8 files changed

+1697
-77
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+
};
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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,23 @@ config SPI_OMAP_100K
431431

432432
config SPI_ORION
433433
tristate "Orion SPI master"
434-
depends on PLAT_ORION || COMPILE_TEST
434+
depends on PLAT_ORION || ARCH_MVEBU || COMPILE_TEST
435435
help
436436
This enables using the SPI master controller on the Orion chips.
437437

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+
438451
config SPI_PL022
439452
tristate "ARM AMBA PL022 SSP controller"
440453
depends on ARM_AMBA

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-octeon.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ static int octeon_spi_transfer_one_message(struct spi_master *master,
175175
static int octeon_spi_probe(struct platform_device *pdev)
176176
{
177177
struct resource *res_mem;
178+
void __iomem *reg_base;
178179
struct spi_master *master;
179180
struct octeon_spi *p;
180181
int err = -ENOENT;
@@ -186,19 +187,13 @@ static int octeon_spi_probe(struct platform_device *pdev)
186187
platform_set_drvdata(pdev, master);
187188

188189
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
189-
190-
if (res_mem == NULL) {
191-
dev_err(&pdev->dev, "found no memory resource\n");
192-
err = -ENXIO;
193-
goto fail;
194-
}
195-
if (!devm_request_mem_region(&pdev->dev, res_mem->start,
196-
resource_size(res_mem), res_mem->name)) {
197-
dev_err(&pdev->dev, "request_mem_region failed\n");
190+
reg_base = devm_ioremap_resource(&pdev->dev, res_mem);
191+
if (IS_ERR(reg_base)) {
192+
err = PTR_ERR(reg_base);
198193
goto fail;
199194
}
200-
p->register_base = (u64)devm_ioremap(&pdev->dev, res_mem->start,
201-
resource_size(res_mem));
195+
196+
p->register_base = (u64)reg_base;
202197

203198
master->num_chipselect = 4;
204199
master->mode_bits = SPI_CPHA |

drivers/spi/spi-omap2-mcspi.c

Lines changed: 18 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <linux/delay.h>
2424
#include <linux/dma-mapping.h>
2525
#include <linux/dmaengine.h>
26-
#include <linux/omap-dma.h>
2726
#include <linux/pinctrl/consumer.h>
2827
#include <linux/platform_device.h>
2928
#include <linux/err.h>
@@ -103,9 +102,6 @@ struct omap2_mcspi_dma {
103102
struct dma_chan *dma_tx;
104103
struct dma_chan *dma_rx;
105104

106-
int dma_tx_sync_dev;
107-
int dma_rx_sync_dev;
108-
109105
struct completion dma_tx_completion;
110106
struct completion dma_rx_completion;
111107

@@ -964,43 +960,33 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
964960
struct spi_master *master = spi->master;
965961
struct omap2_mcspi *mcspi;
966962
struct omap2_mcspi_dma *mcspi_dma;
967-
dma_cap_mask_t mask;
968-
unsigned sig;
963+
int ret = 0;
969964

970965
mcspi = spi_master_get_devdata(master);
971966
mcspi_dma = mcspi->dma_channels + spi->chip_select;
972967

973968
init_completion(&mcspi_dma->dma_rx_completion);
974969
init_completion(&mcspi_dma->dma_tx_completion);
975970

976-
dma_cap_zero(mask);
977-
dma_cap_set(DMA_SLAVE, mask);
978-
sig = mcspi_dma->dma_rx_sync_dev;
979-
980-
mcspi_dma->dma_rx =
981-
dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
982-
&sig, &master->dev,
983-
mcspi_dma->dma_rx_ch_name);
984-
if (!mcspi_dma->dma_rx)
971+
mcspi_dma->dma_rx = dma_request_chan(&master->dev,
972+
mcspi_dma->dma_rx_ch_name);
973+
if (IS_ERR(mcspi_dma->dma_rx)) {
974+
ret = PTR_ERR(mcspi_dma->dma_rx);
975+
mcspi_dma->dma_rx = NULL;
985976
goto no_dma;
977+
}
986978

987-
sig = mcspi_dma->dma_tx_sync_dev;
988-
mcspi_dma->dma_tx =
989-
dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
990-
&sig, &master->dev,
991-
mcspi_dma->dma_tx_ch_name);
992-
993-
if (!mcspi_dma->dma_tx) {
979+
mcspi_dma->dma_tx = dma_request_chan(&master->dev,
980+
mcspi_dma->dma_tx_ch_name);
981+
if (IS_ERR(mcspi_dma->dma_tx)) {
982+
ret = PTR_ERR(mcspi_dma->dma_tx);
983+
mcspi_dma->dma_tx = NULL;
994984
dma_release_channel(mcspi_dma->dma_rx);
995985
mcspi_dma->dma_rx = NULL;
996-
goto no_dma;
997986
}
998987

999-
return 0;
1000-
1001988
no_dma:
1002-
dev_warn(&spi->dev, "not using DMA for McSPI\n");
1003-
return -EAGAIN;
989+
return ret;
1004990
}
1005991

1006992
static int omap2_mcspi_setup(struct spi_device *spi)
@@ -1039,8 +1025,9 @@ static int omap2_mcspi_setup(struct spi_device *spi)
10391025

10401026
if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
10411027
ret = omap2_mcspi_request_dma(spi);
1042-
if (ret < 0 && ret != -EAGAIN)
1043-
return ret;
1028+
if (ret)
1029+
dev_warn(&spi->dev, "not using DMA for McSPI (%d)\n",
1030+
ret);
10441031
}
10451032

10461033
ret = pm_runtime_get_sync(mcspi->dev);
@@ -1434,42 +1421,8 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
14341421
}
14351422

14361423
for (i = 0; i < master->num_chipselect; i++) {
1437-
char *dma_rx_ch_name = mcspi->dma_channels[i].dma_rx_ch_name;
1438-
char *dma_tx_ch_name = mcspi->dma_channels[i].dma_tx_ch_name;
1439-
struct resource *dma_res;
1440-
1441-
sprintf(dma_rx_ch_name, "rx%d", i);
1442-
if (!pdev->dev.of_node) {
1443-
dma_res =
1444-
platform_get_resource_byname(pdev,
1445-
IORESOURCE_DMA,
1446-
dma_rx_ch_name);
1447-
if (!dma_res) {
1448-
dev_dbg(&pdev->dev,
1449-
"cannot get DMA RX channel\n");
1450-
status = -ENODEV;
1451-
break;
1452-
}
1453-
1454-
mcspi->dma_channels[i].dma_rx_sync_dev =
1455-
dma_res->start;
1456-
}
1457-
sprintf(dma_tx_ch_name, "tx%d", i);
1458-
if (!pdev->dev.of_node) {
1459-
dma_res =
1460-
platform_get_resource_byname(pdev,
1461-
IORESOURCE_DMA,
1462-
dma_tx_ch_name);
1463-
if (!dma_res) {
1464-
dev_dbg(&pdev->dev,
1465-
"cannot get DMA TX channel\n");
1466-
status = -ENODEV;
1467-
break;
1468-
}
1469-
1470-
mcspi->dma_channels[i].dma_tx_sync_dev =
1471-
dma_res->start;
1472-
}
1424+
sprintf(mcspi->dma_channels[i].dma_rx_ch_name, "rx%d", i);
1425+
sprintf(mcspi->dma_channels[i].dma_tx_ch_name, "tx%d", i);
14731426
}
14741427

14751428
if (status < 0)

0 commit comments

Comments
 (0)