Skip to content

Commit

Permalink
Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/st-ssc4…
Browse files Browse the repository at this point in the history
…' and 'spi/topic/stm32' into spi-next
  • Loading branch information
Mark Brown committed Jul 3, 2017
4 parents cc7e35b + f792943 + 0b0cda4 + 7b821a6 commit 082f696
Show file tree
Hide file tree
Showing 6 changed files with 1,412 additions and 29 deletions.
59 changes: 59 additions & 0 deletions Documentation/devicetree/bindings/spi/spi-stm32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
STMicroelectronics STM32 SPI Controller

The STM32 SPI controller is used to communicate with external devices using
the Serial Peripheral Interface. It supports full-duplex, half-duplex and
simplex synchronous serial communication with external devices. It supports
from 4 to 32-bit data size. Although it can be configured as master or slave,
only master is supported by the driver.

Required properties:
- compatible: Must be "st,stm32h7-spi".
- reg: Offset and length of the device's register set.
- interrupts: Must contain the interrupt id.
- clocks: Must contain an entry for spiclk (which feeds the internal clock
generator).
- #address-cells: Number of cells required to define a chip select address.
- #size-cells: Should be zero.

Optional properties:
- resets: Must contain the phandle to the reset controller.
- A pinctrl state named "default" may be defined to set pins in mode of
operation for SPI transfer.
- dmas: DMA specifiers for tx and rx dma. DMA fifo mode must be used. See the
STM32 DMA bindings, Documentation/devicetree/bindings/dma/stm32-dma.txt.
- dma-names: DMA request names should include "tx" and "rx" if present.
- cs-gpios: list of GPIO chip selects. See the SPI bus bindings,
Documentation/devicetree/bindings/spi/spi-bus.txt


Child nodes represent devices on the SPI bus
See ../spi/spi-bus.txt

Optional properties:
- st,spi-midi-ns: (Master Inter-Data Idleness) minimum time delay in
nanoseconds inserted between two consecutive data frames.


Example:
spi2: spi@40003800 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "st,stm32h7-spi";
reg = <0x40003800 0x400>;
interrupts = <36>;
clocks = <&rcc SPI2_CK>;
resets = <&rcc 1166>;
dmas = <&dmamux1 0 39 0x400 0x01>,
<&dmamux1 1 40 0x400 0x01>;
dma-names = "rx", "tx";
pinctrl-0 = <&spi2_pins_b>;
pinctrl-names = "default";
cs-gpios = <&gpioa 11 0>;

aardvark@0 {
compatible = "totalphase,aardvark";
reg = <0>;
spi-max-frequency = <4000000>;
st,spi-midi-ns = <4000>;
};
};
10 changes: 10 additions & 0 deletions drivers/spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,16 @@ config SPI_SIRF
help
SPI driver for CSR SiRFprimaII SoCs

config SPI_STM32
tristate "STMicroelectronics STM32 SPI controller"
depends on ARCH_STM32 || COMPILE_TEST
help
SPI driver for STMicroelectonics STM32 SoCs.

STM32 SPI controller supports DMA and PIO modes. When DMA
is not available, the driver automatically falls back to
PIO mode.

config SPI_ST_SSC4
tristate "STMicroelectronics SPI SSC-based driver"
depends on ARCH_STI || COMPILE_TEST
Expand Down
1 change: 1 addition & 0 deletions drivers/spi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ obj-$(CONFIG_SPI_SH_HSPI) += spi-sh-hspi.o
obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o
obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o
obj-$(CONFIG_SPI_SIRF) += spi-sirf.o
obj-$(CONFIG_SPI_STM32) += spi-stm32.o
obj-$(CONFIG_SPI_ST_SSC4) += spi-st-ssc4.o
obj-$(CONFIG_SPI_SUN4I) += spi-sun4i.o
obj-$(CONFIG_SPI_SUN6I) += spi-sun6i.o
Expand Down
38 changes: 19 additions & 19 deletions drivers/spi/spi-st-ssc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,42 +229,42 @@ static int spi_st_setup(struct spi_device *spi)
"setting baudrate:target= %u hz, actual= %u hz, sscbrg= %u\n",
hz, spi_st->baud, sscbrg);

/* Set SSC_CTL and enable SSC */
var = readl_relaxed(spi_st->base + SSC_CTL);
var |= SSC_CTL_MS;
/* Set SSC_CTL and enable SSC */
var = readl_relaxed(spi_st->base + SSC_CTL);
var |= SSC_CTL_MS;

if (spi->mode & SPI_CPOL)
if (spi->mode & SPI_CPOL)
var |= SSC_CTL_PO;
else
else
var &= ~SSC_CTL_PO;

if (spi->mode & SPI_CPHA)
if (spi->mode & SPI_CPHA)
var |= SSC_CTL_PH;
else
else
var &= ~SSC_CTL_PH;

if ((spi->mode & SPI_LSB_FIRST) == 0)
if ((spi->mode & SPI_LSB_FIRST) == 0)
var |= SSC_CTL_HB;
else
else
var &= ~SSC_CTL_HB;

if (spi->mode & SPI_LOOP)
if (spi->mode & SPI_LOOP)
var |= SSC_CTL_LPB;
else
else
var &= ~SSC_CTL_LPB;

var &= ~SSC_CTL_DATA_WIDTH_MSK;
var |= (spi->bits_per_word - 1);
var &= ~SSC_CTL_DATA_WIDTH_MSK;
var |= (spi->bits_per_word - 1);

var |= SSC_CTL_EN_TX_FIFO | SSC_CTL_EN_RX_FIFO;
var |= SSC_CTL_EN;
var |= SSC_CTL_EN_TX_FIFO | SSC_CTL_EN_RX_FIFO;
var |= SSC_CTL_EN;

writel_relaxed(var, spi_st->base + SSC_CTL);
writel_relaxed(var, spi_st->base + SSC_CTL);

/* Clear the status register */
readl_relaxed(spi_st->base + SSC_RBUF);
/* Clear the status register */
readl_relaxed(spi_st->base + SSC_RBUF);

return 0;
return 0;

out_free_gpio:
gpio_free(cs);
Expand Down
Loading

0 comments on commit 082f696

Please sign in to comment.