Skip to content

Commit c508709

Browse files
committed
Merge remote-tracking branches 'spi/topic/res', 'spi/topic/rockchip', 'spi/topic/sh', 'spi/topic/ti-qspi' and 'spi/topic/xilinx' into spi-next
6 parents b9facea + d649781 + 108b5c8 + 3aec316 + 4dea6c9 + 82b3aea commit c508709

File tree

6 files changed

+175
-56
lines changed

6 files changed

+175
-56
lines changed

Documentation/devicetree/bindings/spi/spi-rockchip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Required Properties:
99
"rockchip,rk3066-spi" for rk3066.
1010
"rockchip,rk3188-spi", "rockchip,rk3066-spi" for rk3188.
1111
"rockchip,rk3288-spi", "rockchip,rk3066-spi" for rk3288.
12+
"rockchip,rk3399-spi", "rockchip,rk3066-spi" for rk3399.
1213
- reg: physical base address of the controller and length of memory mapped
1314
region.
1415
- interrupts: The interrupt number to the cpu. The interrupt specifier format
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Xilinx SPI controller Device Tree Bindings
2+
-------------------------------------------------
3+
4+
Required properties:
5+
- compatible : Should be "xlnx,xps-spi-2.00.a" or "xlnx,xps-spi-2.00.b"
6+
- reg : Physical base address and size of SPI registers map.
7+
- interrupts : Property with a value describing the interrupt
8+
number.
9+
- interrupt-parent : Must be core interrupt controller
10+
11+
Optional properties:
12+
- xlnx,num-ss-bits : Number of chip selects used.
13+
14+
Example:
15+
axi_quad_spi@41e00000 {
16+
compatible = "xlnx,xps-spi-2.00.a";
17+
interrupt-parent = <&intc>;
18+
interrupts = <0 31 1>;
19+
reg = <0x41e00000 0x10000>;
20+
xlnx,num-ss-bits = <0x1>;
21+
};
22+

drivers/spi/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ config SPI_RB4XX
487487

488488
config SPI_RSPI
489489
tristate "Renesas RSPI/QSPI controller"
490-
depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
490+
depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
491491
help
492492
SPI driver for Renesas RSPI and QSPI blocks.
493493

@@ -537,7 +537,7 @@ config SPI_SC18IS602
537537
config SPI_SH_MSIOF
538538
tristate "SuperH MSIOF SPI controller"
539539
depends on HAVE_CLK && HAS_DMA
540-
depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
540+
depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
541541
help
542542
SPI driver for SuperH and SH Mobile MSIOF blocks.
543543

@@ -556,7 +556,7 @@ config SPI_SH_SCI
556556

557557
config SPI_SH_HSPI
558558
tristate "SuperH HSPI controller"
559-
depends on ARCH_SHMOBILE || COMPILE_TEST
559+
depends on ARCH_RENESAS || COMPILE_TEST
560560
help
561561
SPI driver for SuperH HSPI blocks.
562562

drivers/spi/spi-rockchip.c

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,14 @@
1313
*
1414
*/
1515

16-
#include <linux/init.h>
17-
#include <linux/module.h>
1816
#include <linux/clk.h>
19-
#include <linux/err.h>
20-
#include <linux/delay.h>
21-
#include <linux/interrupt.h>
17+
#include <linux/dmaengine.h>
18+
#include <linux/module.h>
19+
#include <linux/of.h>
2220
#include <linux/platform_device.h>
23-
#include <linux/slab.h>
2421
#include <linux/spi/spi.h>
25-
#include <linux/scatterlist.h>
26-
#include <linux/of.h>
2722
#include <linux/pm_runtime.h>
28-
#include <linux/io.h>
29-
#include <linux/dmaengine.h>
23+
#include <linux/scatterlist.h>
3024

3125
#define DRIVER_NAME "rockchip-spi"
3226

@@ -179,7 +173,7 @@ struct rockchip_spi {
179173
u8 tmode;
180174
u8 bpw;
181175
u8 n_bytes;
182-
u8 rsd_nsecs;
176+
u32 rsd_nsecs;
183177
unsigned len;
184178
u32 speed;
185179

@@ -192,8 +186,6 @@ struct rockchip_spi {
192186
/* protect state */
193187
spinlock_t lock;
194188

195-
struct completion xfer_completion;
196-
197189
u32 use_dma;
198190
struct sg_table tx_sg;
199191
struct sg_table rx_sg;
@@ -265,7 +257,10 @@ static inline u32 rx_max(struct rockchip_spi *rs)
265257
static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
266258
{
267259
u32 ser;
268-
struct rockchip_spi *rs = spi_master_get_devdata(spi->master);
260+
struct spi_master *master = spi->master;
261+
struct rockchip_spi *rs = spi_master_get_devdata(master);
262+
263+
pm_runtime_get_sync(rs->dev);
269264

270265
ser = readl_relaxed(rs->regs + ROCKCHIP_SPI_SER) & SER_MASK;
271266

@@ -290,6 +285,8 @@ static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
290285
ser &= ~(1 << spi->chip_select);
291286

292287
writel_relaxed(ser, rs->regs + ROCKCHIP_SPI_SER);
288+
289+
pm_runtime_put_sync(rs->dev);
293290
}
294291

295292
static int rockchip_spi_prepare_message(struct spi_master *master,
@@ -319,12 +316,12 @@ static void rockchip_spi_handle_err(struct spi_master *master,
319316
*/
320317
if (rs->use_dma) {
321318
if (rs->state & RXBUSY) {
322-
dmaengine_terminate_all(rs->dma_rx.ch);
319+
dmaengine_terminate_async(rs->dma_rx.ch);
323320
flush_fifo(rs);
324321
}
325322

326323
if (rs->state & TXBUSY)
327-
dmaengine_terminate_all(rs->dma_tx.ch);
324+
dmaengine_terminate_async(rs->dma_tx.ch);
328325
}
329326

330327
spin_unlock_irqrestore(&rs->lock, flags);
@@ -433,7 +430,7 @@ static void rockchip_spi_dma_txcb(void *data)
433430
spin_unlock_irqrestore(&rs->lock, flags);
434431
}
435432

436-
static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
433+
static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)
437434
{
438435
unsigned long flags;
439436
struct dma_slave_config rxconf, txconf;
@@ -456,6 +453,8 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
456453
rs->dma_rx.ch,
457454
rs->rx_sg.sgl, rs->rx_sg.nents,
458455
rs->dma_rx.direction, DMA_PREP_INTERRUPT);
456+
if (!rxdesc)
457+
return -EINVAL;
459458

460459
rxdesc->callback = rockchip_spi_dma_rxcb;
461460
rxdesc->callback_param = rs;
@@ -473,6 +472,11 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
473472
rs->dma_tx.ch,
474473
rs->tx_sg.sgl, rs->tx_sg.nents,
475474
rs->dma_tx.direction, DMA_PREP_INTERRUPT);
475+
if (!txdesc) {
476+
if (rxdesc)
477+
dmaengine_terminate_sync(rs->dma_rx.ch);
478+
return -EINVAL;
479+
}
476480

477481
txdesc->callback = rockchip_spi_dma_txcb;
478482
txdesc->callback_param = rs;
@@ -494,6 +498,8 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
494498
dmaengine_submit(txdesc);
495499
dma_async_issue_pending(rs->dma_tx.ch);
496500
}
501+
502+
return 0;
497503
}
498504

499505
static void rockchip_spi_config(struct rockchip_spi *rs)
@@ -503,7 +509,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
503509
int rsd = 0;
504510

505511
u32 cr0 = (CR0_BHT_8BIT << CR0_BHT_OFFSET)
506-
| (CR0_SSD_ONE << CR0_SSD_OFFSET);
512+
| (CR0_SSD_ONE << CR0_SSD_OFFSET)
513+
| (CR0_EM_BIG << CR0_EM_OFFSET);
507514

508515
cr0 |= (rs->n_bytes << CR0_DFS_OFFSET);
509516
cr0 |= ((rs->mode & 0x3) << CR0_SCPH_OFFSET);
@@ -606,12 +613,12 @@ static int rockchip_spi_transfer_one(
606613
if (rs->use_dma) {
607614
if (rs->tmode == CR0_XFM_RO) {
608615
/* rx: dma must be prepared first */
609-
rockchip_spi_prepare_dma(rs);
616+
ret = rockchip_spi_prepare_dma(rs);
610617
spi_enable_chip(rs, 1);
611618
} else {
612619
/* tx or tr: spi must be enabled first */
613620
spi_enable_chip(rs, 1);
614-
rockchip_spi_prepare_dma(rs);
621+
ret = rockchip_spi_prepare_dma(rs);
615622
}
616623
} else {
617624
spi_enable_chip(rs, 1);
@@ -717,8 +724,14 @@ static int rockchip_spi_probe(struct platform_device *pdev)
717724
master->handle_err = rockchip_spi_handle_err;
718725

719726
rs->dma_tx.ch = dma_request_slave_channel(rs->dev, "tx");
720-
if (!rs->dma_tx.ch)
727+
if (IS_ERR_OR_NULL(rs->dma_tx.ch)) {
728+
/* Check tx to see if we need defer probing driver */
729+
if (PTR_ERR(rs->dma_tx.ch) == -EPROBE_DEFER) {
730+
ret = -EPROBE_DEFER;
731+
goto err_get_fifo_len;
732+
}
721733
dev_warn(rs->dev, "Failed to request TX DMA channel\n");
734+
}
722735

723736
rs->dma_rx.ch = dma_request_slave_channel(rs->dev, "rx");
724737
if (!rs->dma_rx.ch) {
@@ -871,6 +884,7 @@ static const struct of_device_id rockchip_spi_dt_match[] = {
871884
{ .compatible = "rockchip,rk3066-spi", },
872885
{ .compatible = "rockchip,rk3188-spi", },
873886
{ .compatible = "rockchip,rk3288-spi", },
887+
{ .compatible = "rockchip,rk3399-spi", },
874888
{ },
875889
};
876890
MODULE_DEVICE_TABLE(of, rockchip_spi_dt_match);

0 commit comments

Comments
 (0)