diff options
author | Chris Packham <judge.packham@gmail.com> | 2016-10-27 21:16:05 +1300 |
---|---|---|
committer | Jagan Teki <jagan@openedev.com> | 2016-11-18 13:04:52 +0530 |
commit | ebfa18cb3d8b5e6f57ac22e39b21c4fc1c1d3597 (patch) | |
tree | c05005b35591ae1a99f010d1dbad4ebc7899119f /drivers/spi/kirkwood_spi.c | |
parent | c2cbd164ea5b5f564fcf03447c7bf9ec4a9f5699 (diff) | |
download | u-boot-imx-ebfa18cb3d8b5e6f57ac22e39b21c4fc1c1d3597.zip u-boot-imx-ebfa18cb3d8b5e6f57ac22e39b21c4fc1c1d3597.tar.gz u-boot-imx-ebfa18cb3d8b5e6f57ac22e39b21c4fc1c1d3597.tar.bz2 |
spi: kirkwood_spi: implement mvebu_spi_set_mode()
Set the appropriate bits in the interface config register based
on the SPI_ mode flags.
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Jagan Teki <jteki@openedev.com>
Signed-off-by: Chris Packham <judge.packham@gmail.com>
Diffstat (limited to 'drivers/spi/kirkwood_spi.c')
-rw-r--r-- | drivers/spi/kirkwood_spi.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index 6851ba9..791f3e8 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -271,6 +271,21 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz) static int mvebu_spi_set_mode(struct udevice *bus, uint mode) { + struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct kwspi_registers *reg = plat->spireg; + u32 data = readl(®->cfg); + + data &= ~(KWSPI_CPHA | KWSPI_CPOL | KWSPI_RXLSBF | KWSPI_TXLSBF); + + if (mode & SPI_CPHA) + data |= KWSPI_CPHA; + if (mode & SPI_CPOL) + data |= KWSPI_CPOL; + if (mode & SPI_LSB_FIRST) + data |= (KWSPI_RXLSBF | KWSPI_TXLSBF); + + writel(data, ®->cfg); + return 0; } |