Skip to content

Commit b271cf3

Browse files
committed
Merge series "spi: dw: Add generic DW DMA controller support" from Serge Semin <[email protected]>:
Baikal-T1 SoC provides a DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently the DMA-based transfers are supported by the DW APB SPI driver only as a middle layer code for Intel MID/Elkhart PCI devices. Seeing the same code can be used for normal platform DMAC device we introduced a set of patches to fix it within this series. First of all we need to add the Tx and Rx DMA channels support into the DW APB SSI binding. Then there are several fixes and cleanups provided as a initial preparation for the Generic DMA support integration: add Tx/Rx finish wait methods, clear DMAC register when done or stopped, Fix native CS being unset, enable interrupts in accordance with DMA xfer mode, discard static DW DMA slave structures, discard unused void priv pointer and dma_width member of the dw_spi structure, provide the DMA Tx/Rx burst length parametrisation and make sure it's optionally set in accordance with the DMA max-burst capability. In order to have the DW APB SSI MMIO driver working with DMA we need to initialize the paddr field with the physical base address of the DW APB SSI registers space. Then we unpin the Intel MID specific code from the generic DMA one and placed it into the spi-dw-pci.c driver, which is a better place for it anyway. After that the naming cleanups are performed since the code is going to be used for a generic DMAC device. Finally the Generic DMA initialization can be added to the generic version of the DW APB SSI IP. Last but not least we traditionally convert the legacy plain text-based dt-binding file with yaml-based one and as a cherry on a cake replace the manually written DebugFS registers read method with a ready-to-use for the same purpose regset32 DebugFS interface usage. This patchset is rebased and tested on the spi/for-next (5.7-rc5): base-commit: fe9fce6 ("Merge remote-tracking branch 'spi/for-5.8' into spi-next") Co-developed-by: Georgy Vlasov <[email protected]> Signed-off-by: Georgy Vlasov <[email protected]> Co-developed-by: Ramil Zaripov <[email protected]> Signed-off-by: Ramil Zaripov <[email protected]> Signed-off-by: Serge Semin <[email protected]> Cc: Alexey Malahov <[email protected]> Cc: Maxim Kaurkin <[email protected]> Cc: Pavel Parkhomenko <[email protected]> Cc: Ekaterina Skachko <[email protected]> Cc: Vadim Vlasov <[email protected]> Cc: Alexey Kolotnikov <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Paul Burton <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Allison Randal <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Gareth Williams <[email protected]> Cc: Rob Herring <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] --- Changelog v2: - Rebase on top of the spi repository for-next branch. - Move bindings conversion patch to the tail of the series. - Move fixes to the head of the series. - Apply as many changes as possible to be applied the Generic DMA functionality support is added and the spi-dw-mid is moved to the spi-dw-dma driver. - Discard patch "spi: dw: Fix dma_slave_config used partly uninitialized" since the problem has already been fixed. - Add new patch "spi: dw: Discard unused void priv pointer". - Add new patch "spi: dw: Discard dma_width member of the dw_spi structure". n_bytes member of the DW SPI data can be used instead. - Build the DMA functionality into the DW APB SSI core if required instead of creating a separate kernel module. - Use conditional statement instead of the ternary operator in the ref clock getter. Serge Semin (19): dt-bindings: spi: dw: Add Tx/Rx DMA properties spi: dw: Add Tx/Rx finish wait methods to the MID DMA spi: dw: Clear DMAC register when done or stopped spi: dw: Fix native CS being unset spi: dw: Enable interrupts in accordance with DMA xfer mode spi: dw: Discard static DW DMA slave structures spi: dw: Discard unused void priv pointer spi: dw: Discard dma_width member of the dw_spi structure spi: dw: Parameterize the DMA Rx/Tx burst length spi: dw: Use DMA max burst to set the request thresholds spi: dw: Initialize paddr in DW SPI MMIO private data spi: dw: Fix Rx-only DMA transfers spi: dw: Move Non-DMA code to the DW PCIe-SPI driver spi: dw: Remove DW DMA code dependency from DW_DMAC_PCI spi: dw: Add DW SPI DMA/PCI/MMIO dependency on the DW SPI core spi: dw: Cleanup generic DW DMA code namings spi: dw: Add DMA support to the DW SPI MMIO driver spi: dw: Use regset32 DebugFS method to create regdump file dt-bindings: spi: Convert DW SPI binding to DT schema .../bindings/spi/snps,dw-apb-ssi.txt | 42 --- .../bindings/spi/snps,dw-apb-ssi.yaml | 127 +++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 -- drivers/spi/Kconfig | 15 +- drivers/spi/Makefile | 7 +- drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} | 257 ++++++++++-------- drivers/spi/spi-dw-mmio.c | 9 +- drivers/spi/spi-dw-pci.c | 50 +++- drivers/spi/spi-dw.c | 98 +++---- drivers/spi/spi-dw.h | 33 ++- 10 files changed, 405 insertions(+), 257 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt rename drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} (53%) -- 2.25.1
2 parents eb1262e + 0327f0b commit b271cf3

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

drivers/spi/spi-dw-mid.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ static void mid_spi_dma_exit(struct dw_spi *dws)
106106
dmaengine_terminate_sync(dws->rxchan);
107107
dma_release_channel(dws->rxchan);
108108
}
109+
110+
dw_writel(dws, DW_SPI_DMACR, 0);
109111
}
110112

111113
static irqreturn_t dma_transfer(struct dw_spi *dws)
@@ -152,6 +154,8 @@ static void dw_spi_dma_tx_done(void *arg)
152154
clear_bit(TX_BUSY, &dws->dma_chan_busy);
153155
if (test_bit(RX_BUSY, &dws->dma_chan_busy))
154156
return;
157+
158+
dw_writel(dws, DW_SPI_DMACR, 0);
155159
spi_finalize_current_transfer(dws->master);
156160
}
157161

@@ -199,6 +203,8 @@ static void dw_spi_dma_rx_done(void *arg)
199203
clear_bit(RX_BUSY, &dws->dma_chan_busy);
200204
if (test_bit(TX_BUSY, &dws->dma_chan_busy))
201205
return;
206+
207+
dw_writel(dws, DW_SPI_DMACR, 0);
202208
spi_finalize_current_transfer(dws->master);
203209
}
204210

@@ -292,6 +298,8 @@ static void mid_spi_dma_stop(struct dw_spi *dws)
292298
dmaengine_terminate_sync(dws->rxchan);
293299
clear_bit(RX_BUSY, &dws->dma_chan_busy);
294300
}
301+
302+
dw_writel(dws, DW_SPI_DMACR, 0);
295303
}
296304

297305
static const struct dw_spi_dma_ops mfld_dma_ops = {

drivers/spi/spi-dw-mmio.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
184184
int (*init_func)(struct platform_device *pdev,
185185
struct dw_spi_mmio *dwsmmio);
186186
struct dw_spi_mmio *dwsmmio;
187+
struct resource *mem;
187188
struct dw_spi *dws;
188189
int ret;
189190
int num_cs;
@@ -196,10 +197,12 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
196197
dws = &dwsmmio->dws;
197198

198199
/* Get basic io resource and map it */
199-
dws->regs = devm_platform_ioremap_resource(pdev, 0);
200+
dws->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
200201
if (IS_ERR(dws->regs))
201202
return PTR_ERR(dws->regs);
202203

204+
dws->paddr = mem->start;
205+
203206
dws->irq = platform_get_irq(pdev, 0);
204207
if (dws->irq < 0)
205208
return dws->irq; /* -ENXIO */

drivers/spi/spi-dw.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ static inline void dw_spi_debugfs_remove(struct dw_spi *dws)
124124
void dw_spi_set_cs(struct spi_device *spi, bool enable)
125125
{
126126
struct dw_spi *dws = spi_controller_get_devdata(spi->controller);
127+
bool cs_high = !!(spi->mode & SPI_CS_HIGH);
127128

128-
if (!enable)
129+
/*
130+
* DW SPI controller demands any native CS being set in order to
131+
* proceed with data transfer. So in order to activate the SPI
132+
* communications we must set a corresponding bit in the Slave
133+
* Enable register no matter whether the SPI core is configured to
134+
* support active-high or active-low CS level.
135+
*/
136+
if (cs_high == enable)
129137
dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select));
130138
else if (dws->cs_override)
131139
dw_writel(dws, DW_SPI_SER, 0);

0 commit comments

Comments
 (0)