Enable spi dma on Rockchip RK3399
Subsystems (3)
cover Enable spi dma on Rockchip RK3399
Hi all,
The first three patches in this series enable spi dma on rk3399, while the remaining patches are meant to be decreasingly obvious cleanups to the rockchip spi driver.
Unfortunately I only have rk3399-gru-kevin hardware to test this on, so it would be nice if someone would test this on other rockchips.
/Emil
Emil Renner Berthing (5):
arm64: dts: rockchip: add rk3399 SPI DMAs
spi: rockchip: remove unneeded dma_caps
spi: rockchip: mark use_dma as bool
spi: rockchip: directly use direction constants
spi: rockchip: simplify spi enable logic
Huibin Hong (2):
spi: rockchip: initialize dma_slave_config properly
spi: rockchip: adjust dma watermark and burstlen
arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 ++++ drivers/spi/spi-rockchip.c | 62 +++++++++--------------- 2 files changed, 32 insertions(+), 40 deletions(-)
Signature · 1 line
2.19.1
PATCH 1/7 spi: rockchip: initialize dma_slave_config properly
From: Huibin Hong <[email protected]>
The rxconf and txconf structs are allocated on the stack, so make sure we zero them before filling out the relevant fields.
--- drivers/spi/spi-rockchip.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/spi/spi-rockchip.c +3 -0
@@ -445,6 +445,9 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)struct dma_slave_config rxconf, txconf;struct dma_async_tx_descriptor *rxdesc, *txdesc; +memset (&rxconf,0 ,sizeof (rxconf)); +memset (&txconf,0 ,sizeof (txconf)); +spin_lock_irqsave (&rs->lock, flags); rs->state &= ~RXBUSY ; rs->state &= ~TXBUSY ;
Signature · 1 line
2.19.1
PATCH 2/7 spi: rockchip: adjust dma watermark and burstlen
In reply to Emil Renner BerthingFrom: Huibin Hong <[email protected]>
Signal tx dma when spi fifo is less than half full, and limit tx bursts to half the fifo length.
Clamp rx burst length to 1 to avoid alignment issues.
--- drivers/spi/spi-rockchip.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/spi/spi-rockchip.c +3 -9
@@ -458,10 +458,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxconf.direction = rs->dma_rx.direction; rxconf.src_addr = rs->dma_rx.addr; rxconf.src_addr_width = rs->n_bytes; -if (rs->dma_caps.max_burst >4 ) - rxconf.src_maxburst =4 ; -else - rxconf.src_maxburst =1 ; + rxconf.src_maxburst =1 ;dmaengine_slave_config (rs->dma_rx.ch, &rxconf); rxdesc = dmaengine_prep_slave_sg(
@@ -480,10 +477,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txconf.direction = rs->dma_tx.direction; txconf.dst_addr = rs->dma_tx.addr; txconf.dst_addr_width = rs->n_bytes; -if (rs->dma_caps.max_burst >4 ) - txconf.dst_maxburst =4 ; -else - txconf.dst_maxburst =1 ; + txconf.dst_maxburst = rs->fifo_len /2 ;dmaengine_slave_config (rs->dma_tx.ch, &txconf); txdesc = dmaengine_prep_slave_sg(
@@ -581,7 +575,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs)writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_TXFTLR );writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_RXFTLR ); -writel_relaxed (0 , rs->regs +ROCKCHIP_SPI_DMATDLR ); +writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_DMATDLR );writel_relaxed (0 , rs->regs +ROCKCHIP_SPI_DMARDLR );writel_relaxed (dmacr, rs->regs +ROCKCHIP_SPI_DMACR );
Signature · 1 line
2.19.1
PATCH 3/7 arm64: dts: rockchip: add rk3399 SPI DMAs
In reply to Emil Renner BerthingAdd spi dma channels as specified by the rk3399 TRM.
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +10 -0
@@ -653,6 +653,8 @@ clocks = <&cru SCLK_SPI0>, <&cru PCLK_SPI0>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 10>, <&dmac_peri 11>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi0_clk &spi0_tx &spi0_rx &spi0_cs0>; #address-cells = <1>;
@@ -666,6 +668,8 @@ clocks = <&cru SCLK_SPI1>, <&cru PCLK_SPI1>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 12>, <&dmac_peri 13>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi1_clk &spi1_tx &spi1_rx &spi1_cs0>; #address-cells = <1>;
@@ -679,6 +683,8 @@ clocks = <&cru SCLK_SPI2>, <&cru PCLK_SPI2>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 14>, <&dmac_peri 15>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi2_clk &spi2_tx &spi2_rx &spi2_cs0>; #address-cells = <1>;
@@ -692,6 +698,8 @@ clocks = <&cru SCLK_SPI4>, <&cru PCLK_SPI4>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 18>, <&dmac_peri 19>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi4_clk &spi4_tx &spi4_rx &spi4_cs0>; #address-cells = <1>;
@@ -705,6 +713,8 @@ clocks = <&cru SCLK_SPI5>, <&cru PCLK_SPI5>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 132 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_bus 8>, <&dmac_bus 9>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi5_clk &spi5_tx &spi5_rx &spi5_cs0>; power-domains = <&power RK3399_PD_SDIOAUDIO>;
Signature · 1 line
2.19.1
PATCH 4/7 spi: rockchip: remove unneeded dma_caps
In reply to Emil Renner BerthingWe no longer need the dma_caps since the dma driver already clamps the burst length to the hardware limit, so don't request and store dma_caps in device data.
--- drivers/spi/spi-rockchip.c | 2 -- 1 file changed, 2 deletions(-)
drivers/spi/spi-rockchip.c +0 -2
@@ -207,7 +207,6 @@ struct rockchip_spi {struct sg_table rx_sg;struct rockchip_spi_dma_data dma_rx;struct rockchip_spi_dma_data dma_tx; -struct dma_slave_caps dma_caps; };static inline void spi_enable_chip (struct rockchip_spi *rs,int enable)
@@ -777,7 +776,6 @@ static int rockchip_spi_probe(struct platform_device *pdev) }if (rs->dma_tx.ch && rs->dma_rx.ch) { -dma_get_slave_caps (rs->dma_rx.ch, &(rs->dma_caps)); rs->dma_tx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_TXDR ); rs->dma_rx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_RXDR ); rs->dma_tx.direction =DMA_MEM_TO_DEV ;
Signature · 1 line
2.19.1
PATCH 5/7 spi: rockchip: mark use_dma as bool
In reply to Emil Renner BerthingThe driver data has a u32 field use_dma which is
only ever used as a boolean, so change its type
to reflect that.
--- drivers/spi/spi-rockchip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-rockchip.c +3 -3
@@ -202,7 +202,7 @@ struct rockchip_spi {bool cs_asserted[ROCKCHIP_SPI_MAX_CS_NUM ]; -u32 use_dma; +bool use_dma;struct sg_table tx_sg;struct sg_table rx_sg;struct rockchip_spi_dma_data dma_rx;
@@ -631,9 +631,9 @@ static int rockchip_spi_transfer_one(/* we need prepare dma before spi was enabled */ if (master->can_dma && master->can_dma (master, spi, xfer)) - rs->use_dma =1 ; + rs->use_dma = true;else - rs->use_dma =0 ; + rs->use_dma = false;rockchip_spi_config (rs);
Signature · 1 line
2.19.1
PATCH 6/7 spi: rockchip: directly use direction constants
In reply to Emil Renner BerthingThe dma direction for the tx and rx dma channels never change, so just use the constants directly rather than storing them in device data.
--- drivers/spi/spi-rockchip.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/spi/spi-rockchip.c +4 -7
@@ -164,7 +164,6 @@ enum rockchip_ssi_type {struct rockchip_spi_dma_data {struct dma_chan *ch; -enum dma_transfer_direction direction;dma_addr_t addr; };
@@ -454,7 +453,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxdesc =NULL ;if (rs->rx) { - rxconf.direction = rs->dma_rx.direction; + rxconf.direction =DMA_DEV_TO_MEM ; rxconf.src_addr = rs->dma_rx.addr; rxconf.src_addr_width = rs->n_bytes; rxconf.src_maxburst =1 ;
@@ -463,7 +462,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxdesc =dmaengine_prep_slave_sg ( rs->dma_rx.ch, rs->rx_sg.sgl, rs->rx_sg.nents, - rs->dma_rx.direction,DMA_PREP_INTERRUPT ); +DMA_DEV_TO_MEM ,DMA_PREP_INTERRUPT );if (!rxdesc)return -EINVAL ;
@@ -473,7 +472,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txdesc =NULL ;if (rs->tx) { - txconf.direction = rs->dma_tx.direction; + txconf.direction =DMA_MEM_TO_DEV ; txconf.dst_addr = rs->dma_tx.addr; txconf.dst_addr_width = rs->n_bytes; txconf.dst_maxburst = rs->fifo_len /2 ;
@@ -482,7 +481,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txdesc =dmaengine_prep_slave_sg ( rs->dma_tx.ch, rs->tx_sg.sgl, rs->tx_sg.nents, - rs->dma_tx.direction,DMA_PREP_INTERRUPT ); +DMA_MEM_TO_DEV ,DMA_PREP_INTERRUPT );if (!txdesc) {if (rxdesc)dmaengine_terminate_sync (rs->dma_rx.ch);
@@ -778,8 +777,6 @@ static int rockchip_spi_probe(struct platform_device *pdev)if (rs->dma_tx.ch && rs->dma_rx.ch) { rs->dma_tx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_TXDR ); rs->dma_rx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_RXDR ); - rs->dma_tx.direction =DMA_MEM_TO_DEV ; - rs->dma_rx.direction =DMA_DEV_TO_MEM ; master->can_dma = rockchip_spi_can_dma; master->dma_tx = rs->dma_tx.ch;
Signature · 1 line
2.19.1
PATCH 7/7 spi: rockchip: simplify spi enable logic
In reply to Emil Renner BerthingLet the dma/non-dma code paths handle the spi enable flag themselves. This removes some logic to determine if the flag should be turned on before or after dma and also don't leave the spi enabled if the dma path fails.
--- drivers/spi/spi-rockchip.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/spi/spi-rockchip.c +9 -19
@@ -379,6 +379,8 @@ static int rockchip_spi_pio_transfer(struct rockchip_spi *rs) {int remain =0 ; +spi_enable_chip (rs,1 ); + do { if (rs->tx) { remain = rs->tx_end - rs->tx;
@@ -501,6 +503,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)dma_async_issue_pending (rs->dma_rx.ch); } +spi_enable_chip (rs,1 ); +if (txdesc) {spin_lock_irqsave (&rs->lock, flags); rs->state |=TXBUSY ;
@@ -509,7 +513,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)dma_async_issue_pending (rs->dma_tx.ch); } -return 0 ; +/* 1 means the transfer is in progress */ +return 1 ; }static void rockchip_spi_config (struct rockchip_spi *rs)
@@ -592,7 +597,6 @@ static int rockchip_spi_transfer_one(struct spi_device *spi, struct spi_transfer *xfer) { - int ret = 0; struct rockchip_spi *rs = spi_master_get_devdata(master); WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
@@ -636,24 +640,10 @@ static int rockchip_spi_transfer_one(rockchip_spi_config (rs); -if (rs->use_dma) { -if (rs->tmode ==CR0_XFM_RO ) { -/* rx: dma must be prepared first */ - ret =rockchip_spi_prepare_dma (rs); -spi_enable_chip (rs,1 ); - }else { -/* tx or tr: spi must be enabled first */ -spi_enable_chip (rs,1 ); - ret =rockchip_spi_prepare_dma (rs); - } -/* successful DMA prepare means the transfer is in progress */ - ret = ret ? ret :1 ; - }else { -spi_enable_chip (rs,1 ); - ret =rockchip_spi_pio_transfer (rs); - } +if (rs->use_dma) +return rockchip_spi_prepare_dma (rs); -return ret; +return rockchip_spi_pio_transfer (rs); } static bool rockchip_spi_can_dma(struct spi_master *master,
Signature · 1 line
2.19.1
Mark Brown
maintainerApplied "spi: rockchip: simplify spi enable logic" to the spi tree
The patch
spi: rockchip: simplify spi enable logic
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a3c174021ce780f5d2e9b2105e2cb4903a37226dMon Sep 17 00:00:00 2001
From: Emil Renner Berthing <[email protected]>
Date: Wed, 10 Oct 2018 11:00:38 +0200
Subject: [PATCH] spi: rockchip: simplify spi enable logic
Let the dma/non-dma code paths handle the spi enable flag themselves. This removes some logic to determine if the flag should be turned on before or after dma and also don't leave the spi enabled if the dma path fails.
--- drivers/spi/spi-rockchip.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/spi/spi-rockchip.c +9 -19
@@ -379,6 +379,8 @@ static int rockchip_spi_pio_transfer(struct rockchip_spi *rs) {int remain =0 ; +spi_enable_chip (rs,1 ); + do { if (rs->tx) { remain = rs->tx_end - rs->tx;
@@ -498,6 +500,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)dma_async_issue_pending (rs->dma_rx.ch); } +spi_enable_chip (rs,1 ); +if (txdesc) {spin_lock_irqsave (&rs->lock, flags); rs->state |=TXBUSY ;
@@ -506,7 +510,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)dma_async_issue_pending (rs->dma_tx.ch); } -return 0 ; +/* 1 means the transfer is in progress */ +return 1 ; }static void rockchip_spi_config (struct rockchip_spi *rs)
@@ -589,7 +594,6 @@ static int rockchip_spi_transfer_one(struct spi_device *spi, struct spi_transfer *xfer) { - int ret = 0; struct rockchip_spi *rs = spi_master_get_devdata(master); WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
@@ -633,24 +637,10 @@ static int rockchip_spi_transfer_one(rockchip_spi_config (rs); -if (rs->use_dma) { -if (rs->tmode ==CR0_XFM_RO ) { -/* rx: dma must be prepared first */ - ret =rockchip_spi_prepare_dma (rs); -spi_enable_chip (rs,1 ); - }else { -/* tx or tr: spi must be enabled first */ -spi_enable_chip (rs,1 ); - ret =rockchip_spi_prepare_dma (rs); - } -/* successful DMA prepare means the transfer is in progress */ - ret = ret ? ret :1 ; - }else { -spi_enable_chip (rs,1 ); - ret =rockchip_spi_pio_transfer (rs); - } +if (rs->use_dma) +return rockchip_spi_prepare_dma (rs); -return ret; +return rockchip_spi_pio_transfer (rs); } static bool rockchip_spi_can_dma(struct spi_master *master,
Signature · 1 line
2.19.0.rc2
Mark Brown
maintainerApplied "spi: rockchip: directly use direction constants" to the spi tree
In reply to Emil Renner BerthingThe patch
spi: rockchip: directly use direction constants
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
d9071b7e9fc474e474e3b865428a8d30d88daaf4Mon Sep 17 00:00:00 2001
From: Emil Renner Berthing <[email protected]>
Date: Wed, 10 Oct 2018 11:00:37 +0200
Subject: [PATCH] spi: rockchip: directly use direction constants
The dma direction for the tx and rx dma channels never change, so just use the constants directly rather than storing them in device data.
--- drivers/spi/spi-rockchip.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/spi/spi-rockchip.c +4 -7
@@ -164,7 +164,6 @@ enum rockchip_ssi_type {struct rockchip_spi_dma_data {struct dma_chan *ch; -enum dma_transfer_direction direction;dma_addr_t addr; };
@@ -451,7 +450,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxdesc =NULL ;if (rs->rx) { - rxconf.direction = rs->dma_rx.direction; + rxconf.direction =DMA_DEV_TO_MEM ; rxconf.src_addr = rs->dma_rx.addr; rxconf.src_addr_width = rs->n_bytes; rxconf.src_maxburst =1 ;
@@ -460,7 +459,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxdesc =dmaengine_prep_slave_sg ( rs->dma_rx.ch, rs->rx_sg.sgl, rs->rx_sg.nents, - rs->dma_rx.direction,DMA_PREP_INTERRUPT ); +DMA_DEV_TO_MEM ,DMA_PREP_INTERRUPT );if (!rxdesc)return -EINVAL ;
@@ -470,7 +469,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txdesc =NULL ;if (rs->tx) { - txconf.direction = rs->dma_tx.direction; + txconf.direction =DMA_MEM_TO_DEV ; txconf.dst_addr = rs->dma_tx.addr; txconf.dst_addr_width = rs->n_bytes; txconf.dst_maxburst = rs->fifo_len /2 ;
@@ -479,7 +478,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txdesc =dmaengine_prep_slave_sg ( rs->dma_tx.ch, rs->tx_sg.sgl, rs->tx_sg.nents, - rs->dma_tx.direction,DMA_PREP_INTERRUPT ); +DMA_MEM_TO_DEV ,DMA_PREP_INTERRUPT );if (!txdesc) {if (rxdesc)dmaengine_terminate_sync (rs->dma_rx.ch);
@@ -775,8 +774,6 @@ static int rockchip_spi_probe(struct platform_device *pdev)if (rs->dma_tx.ch && rs->dma_rx.ch) { rs->dma_tx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_TXDR ); rs->dma_rx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_RXDR ); - rs->dma_tx.direction =DMA_MEM_TO_DEV ; - rs->dma_rx.direction =DMA_DEV_TO_MEM ; master->can_dma = rockchip_spi_can_dma; master->dma_tx = rs->dma_tx.ch;
Signature · 1 line
2.19.0.rc2
Mark Brown
maintainerApplied "spi: rockchip: mark use_dma as bool" to the spi tree
In reply to Emil Renner BerthingThe patch
spi: rockchip: mark use_dma as bool
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
f340b920511a666b02d371e88801d3817ea7a880Mon Sep 17 00:00:00 2001
From: Emil Renner Berthing <[email protected]>
Date: Wed, 10 Oct 2018 11:00:36 +0200
Subject: [PATCH] spi: rockchip: mark use_dma as bool
The driver data has a u32 field use_dma which is
only ever used as a boolean, so change its type
to reflect that.
--- drivers/spi/spi-rockchip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-rockchip.c +3 -3
@@ -202,7 +202,7 @@ struct rockchip_spi {bool cs_asserted[ROCKCHIP_SPI_MAX_CS_NUM ]; -u32 use_dma; +bool use_dma;struct sg_table tx_sg;struct sg_table rx_sg;struct rockchip_spi_dma_data dma_rx;
@@ -628,9 +628,9 @@ static int rockchip_spi_transfer_one(/* we need prepare dma before spi was enabled */ if (master->can_dma && master->can_dma (master, spi, xfer)) - rs->use_dma =1 ; + rs->use_dma = true;else - rs->use_dma =0 ; + rs->use_dma = false;rockchip_spi_config (rs);
Signature · 1 line
2.19.0.rc2
Mark Brown
maintainerApplied "spi: rockchip: remove unneeded dma_caps" to the spi tree
In reply to Emil Renner BerthingThe patch
spi: rockchip: remove unneeded dma_caps
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
058f7c509e84abd36f988d4e16432366bd793d8fMon Sep 17 00:00:00 2001
From: Emil Renner Berthing <[email protected]>
Date: Wed, 10 Oct 2018 11:00:35 +0200
Subject: [PATCH] spi: rockchip: remove unneeded dma_caps
We no longer need the dma_caps since the dma driver already clamps the burst length to the hardware limit, so don't request and store dma_caps in device data.
--- drivers/spi/spi-rockchip.c | 2 -- 1 file changed, 2 deletions(-)
drivers/spi/spi-rockchip.c +0 -2
@@ -207,7 +207,6 @@ struct rockchip_spi {struct sg_table rx_sg;struct rockchip_spi_dma_data dma_rx;struct rockchip_spi_dma_data dma_tx; -struct dma_slave_caps dma_caps; };static inline void spi_enable_chip (struct rockchip_spi *rs,int enable)
@@ -774,7 +773,6 @@ static int rockchip_spi_probe(struct platform_device *pdev) }if (rs->dma_tx.ch && rs->dma_rx.ch) { -dma_get_slave_caps (rs->dma_rx.ch, &(rs->dma_caps)); rs->dma_tx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_TXDR ); rs->dma_rx.addr = (dma_addr_t)(mem->start +ROCKCHIP_SPI_RXDR ); rs->dma_tx.direction =DMA_MEM_TO_DEV ;
Signature · 1 line
2.19.0.rc2
Mark Brown
maintainerApplied "spi: rockchip: adjust dma watermark and burstlen" to the spi tree
In reply to Emil Renner BerthingThe patch
spi: rockchip: adjust dma watermark and burstlen
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
dcfc861d24ec19f0d0d3d55bb016646794571fbbMon Sep 17 00:00:00 2001
From: Huibin Hong <[email protected]>
Date: Wed, 10 Oct 2018 11:00:33 +0200
Subject: [PATCH] spi: rockchip: adjust dma watermark and burstlen
Signal tx dma when spi fifo is less than half full, and limit tx bursts to half the fifo length.
Clamp rx burst length to 1 to avoid alignment issues.
--- drivers/spi/spi-rockchip.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/spi/spi-rockchip.c +3 -9
@@ -455,10 +455,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) rxconf.direction = rs->dma_rx.direction; rxconf.src_addr = rs->dma_rx.addr; rxconf.src_addr_width = rs->n_bytes; -if (rs->dma_caps.max_burst >4 ) - rxconf.src_maxburst =4 ; -else - rxconf.src_maxburst =1 ; + rxconf.src_maxburst =1 ;dmaengine_slave_config (rs->dma_rx.ch, &rxconf); rxdesc = dmaengine_prep_slave_sg(
@@ -477,10 +474,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs) txconf.direction = rs->dma_tx.direction; txconf.dst_addr = rs->dma_tx.addr; txconf.dst_addr_width = rs->n_bytes; -if (rs->dma_caps.max_burst >4 ) - txconf.dst_maxburst =4 ; -else - txconf.dst_maxburst =1 ; + txconf.dst_maxburst = rs->fifo_len /2 ;dmaengine_slave_config (rs->dma_tx.ch, &txconf); txdesc = dmaengine_prep_slave_sg(
@@ -578,7 +572,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs)writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_TXFTLR );writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_RXFTLR ); -writel_relaxed (0 , rs->regs +ROCKCHIP_SPI_DMATDLR ); +writel_relaxed (rs->fifo_len /2 -1 , rs->regs +ROCKCHIP_SPI_DMATDLR );writel_relaxed (0 , rs->regs +ROCKCHIP_SPI_DMARDLR );writel_relaxed (dmacr, rs->regs +ROCKCHIP_SPI_DMACR );
Signature · 1 line
2.19.0.rc2
Mark Brown
maintainerApplied "spi: rockchip: initialize dma_slave_config properly" to the spi tree
In reply to Emil Renner BerthingThe patch
spi: rockchip: initialize dma_slave_config properly
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
dd8fd2cbc73f8650f651da71fc61a6e4f30c1566Mon Sep 17 00:00:00 2001
From: Huibin Hong <[email protected]>
Date: Wed, 10 Oct 2018 11:00:32 +0200
Subject: [PATCH] spi: rockchip: initialize dma_slave_config properly
The rxconf and txconf structs are allocated on the stack, so make sure we zero them before filling out the relevant fields.
--- drivers/spi/spi-rockchip.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/spi/spi-rockchip.c +3 -0
@@ -445,6 +445,9 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs)struct dma_slave_config rxconf, txconf;struct dma_async_tx_descriptor *rxdesc, *txdesc; +memset (&rxconf,0 ,sizeof (rxconf)); +memset (&txconf,0 ,sizeof (txconf)); +spin_lock_irqsave (&rs->lock, flags); rs->state &= ~RXBUSY ; rs->state &= ~TXBUSY ;
Signature · 1 line
2.19.0.rc2
Re: [PATCH 3/7] arm64: dts: rockchip: add rk3399 SPI DMAs
In reply to Emil Renner BerthingHi Emil,
Many thanks for the patches.
Missatge de Emil Renner Berthing <[email protected]> del dia dc., 10 d’oct. 2018 a les 11:03:
Quoted 58 lines
Add spi dma channels as specified by the rk3399 TRM.
Signed-off-by Emil Renner Berthing <[email protected]>--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)arch/arm64/boot/dts/rockchip/rk3399.dtsi +10
-1@@ -653,6 +653,8 @@ clocks = <&cru SCLK_SPI0>, <&cru PCLK_SPI0>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 10>, <&dmac_peri 11>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi0_clk &spi0_tx &spi0_rx &spi0_cs0>; #address-cells = <1>;@@ -666,6 +668,8 @@ clocks = <&cru SCLK_SPI1>, <&cru PCLK_SPI1>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 12>, <&dmac_peri 13>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi1_clk &spi1_tx &spi1_rx &spi1_cs0>; #address-cells = <1>;@@ -679,6 +683,8 @@ clocks = <&cru SCLK_SPI2>, <&cru PCLK_SPI2>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 14>, <&dmac_peri 15>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi2_clk &spi2_tx &spi2_rx &spi2_cs0>; #address-cells = <1>;@@ -692,6 +698,8 @@ clocks = <&cru SCLK_SPI4>, <&cru PCLK_SPI4>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_peri 18>, <&dmac_peri 19>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi4_clk &spi4_tx &spi4_rx &spi4_cs0>; #address-cells = <1>;@@ -705,6 +713,8 @@ clocks = <&cru SCLK_SPI5>, <&cru PCLK_SPI5>; clock-names = "spiclk", "apb_pclk"; interrupts = <GIC_SPI 132 IRQ_TYPE_LEVEL_HIGH 0>; + dmas = <&dmac_bus 8>, <&dmac_bus 9>; + dma-names = "tx", "rx"; pinctrl-names = "default"; pinctrl-0 = <&spi5_clk &spi5_tx &spi5_rx &spi5_cs0>; power-domains = <&power RK3399_PD_SDIOAUDIO>; --
Quoted 3 lines
2.19.1
As an extra note, the patches get rid of the following messages:
[ 1.722875] rockchip-spi ff1d0000.spi: Failed to request TX DMA channel
[ 1.730297] rockchip-spi ff1d0000.spi: Failed to request RX DMA channel
[ 1.744614] rockchip-spi ff1e0000.spi: Failed to request TX DMA channel
[ 1.752034] rockchip-spi ff1e0000.spi: Failed to request RX DMA channel
[ 1.759948] rockchip-spi ff200000.spi: Failed to request TX DMA channel
[ 1.767360] rockchip-spi ff200000.spi: Failed to request RX DMA channel
And works on my Samsung Chromebook Plus when I stress spi comunications to the EC, so
Quoted 6 lines
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Heiko Stuebner
maintainerRe: [PATCH 3/7] arm64: dts: rockchip: add rk3399 SPI DMAs
In reply to Emil Renner BerthingAm Mittwoch, 10. Oktober 2018, 11:00:34 CEST schrieb Emil Renner Berthing:
Quoted 3 lines
Add spi dma channels as specified by the rk3399 TRM.
Signed-off-by Emil Renner Berthing <[email protected]>
applied for 4.21 with Enric's test-tag
Thanks
Heiko