mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-29 08:01:08 +00:00
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>
This commit is contained in:
parent
c2cbd164ea
commit
ebfa18cb3d
2 changed files with 19 additions and 0 deletions
|
@ -52,6 +52,10 @@ struct kwspi_registers {
|
||||||
#define KWSPI_ADRLEN_3BYTE (2 << 8)
|
#define KWSPI_ADRLEN_3BYTE (2 << 8)
|
||||||
#define KWSPI_ADRLEN_4BYTE (3 << 8)
|
#define KWSPI_ADRLEN_4BYTE (3 << 8)
|
||||||
#define KWSPI_ADRLEN_MASK (3 << 8)
|
#define KWSPI_ADRLEN_MASK (3 << 8)
|
||||||
|
#define KWSPI_CPOL (1 << 11)
|
||||||
|
#define KWSPI_CPHA (1 << 12)
|
||||||
|
#define KWSPI_TXLSBF (1 << 13)
|
||||||
|
#define KWSPI_RXLSBF (1 << 14)
|
||||||
|
|
||||||
#define KWSPI_IRQUNMASK 1 /* unmask SPI interrupt */
|
#define KWSPI_IRQUNMASK 1 /* unmask SPI interrupt */
|
||||||
#define KWSPI_IRQMASK 0 /* mask SPI interrupt */
|
#define KWSPI_IRQMASK 0 /* mask SPI interrupt */
|
||||||
|
|
|
@ -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)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue