diff options
author | Stefan Roese <sr@denx.de> | 2015-11-20 07:44:21 (GMT) |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2016-01-14 13:08:59 (GMT) |
commit | 18dd3b2221d305d58fcc7b9fb3ab2db905582cc5 (patch) | |
tree | 936cefa121e4f1eb045302b14d135118bfd346f9 /drivers/spi/kirkwood_spi.c | |
parent | 6451223a8d1dc57cf0edc7f41799ec79468959c8 (diff) | |
download | u-boot-fsl-qoriq-18dd3b2221d305d58fcc7b9fb3ab2db905582cc5.tar.xz |
spi: kirkwood_spi.c: Prepare for driver model support
This patch prepares the Kirkwood SPI driver, also used on the MVEBU board
(Armada XP / 38x), for the conversion to driver model.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Jagan Teki <jteki@openedev.com>
Cc: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/spi/kirkwood_spi.c')
-rw-r--r-- | drivers/spi/kirkwood_spi.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index e7b0982..08bf432 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -145,33 +145,42 @@ void spi_init(void) { } +static void _spi_cs_activate(struct kwspi_registers *reg) +{ + setbits_le32(®->ctrl, KWSPI_CSN_ACT); +} + +static void _spi_cs_deactivate(struct kwspi_registers *reg) +{ + clrbits_le32(®->ctrl, KWSPI_CSN_ACT); +} + void spi_cs_activate(struct spi_slave *slave) { - setbits_le32(&spireg->ctrl, KWSPI_CSN_ACT); + _spi_cs_activate(spireg); } void spi_cs_deactivate(struct spi_slave *slave) { - clrbits_le32(&spireg->ctrl, KWSPI_CSN_ACT); + _spi_cs_deactivate(spireg); } -int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, - void *din, unsigned long flags) +static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen, + const void *dout, void *din, unsigned long flags) { unsigned int tmpdout, tmpdin; int tm, isread = 0; - debug("spi_xfer: slave %u:%u dout %p din %p bitlen %u\n", - slave->bus, slave->cs, dout, din, bitlen); + debug("spi_xfer: dout %p din %p bitlen %u\n", dout, din, bitlen); if (flags & SPI_XFER_BEGIN) - spi_cs_activate(slave); + _spi_cs_activate(reg); /* * handle data in 8-bit chunks * TBD: 2byte xfer mode to be enabled */ - clrsetbits_le32(&spireg->cfg, KWSPI_XFERLEN_MASK, KWSPI_XFERLEN_1BYTE); + clrsetbits_le32(®->cfg, KWSPI_XFERLEN_MASK, KWSPI_XFERLEN_1BYTE); while (bitlen > 4) { debug("loopstart bitlen %d\n", bitlen); @@ -181,8 +190,8 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, if (dout) tmpdout = *(u32 *)dout & 0xff; - clrbits_le32(&spireg->irq_cause, KWSPI_SMEMRDIRQ); - writel(tmpdout, &spireg->dout); /* Write the data out */ + clrbits_le32(®->irq_cause, KWSPI_SMEMRDIRQ); + writel(tmpdout, ®->dout); /* Write the data out */ debug("*** spi_xfer: ... %08x written, bitlen %d\n", tmpdout, bitlen); @@ -192,9 +201,9 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, * The NE event must be read and cleared first */ for (tm = 0, isread = 0; tm < KWSPI_TIMEOUT; ++tm) { - if (readl(&spireg->irq_cause) & KWSPI_SMEMRDIRQ) { + if (readl(®->irq_cause) & KWSPI_SMEMRDIRQ) { isread = 1; - tmpdin = readl(&spireg->din); + tmpdin = readl(®->din); debug("spi_xfer: din %p..%08x read\n", din, tmpdin); @@ -216,7 +225,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, } if (flags & SPI_XFER_END) - spi_cs_deactivate(slave); + _spi_cs_deactivate(reg); return 0; } + +int spi_xfer(struct spi_slave *slave, unsigned int bitlen, + const void *dout, void *din, unsigned long flags) +{ + return _spi_xfer(spireg, bitlen, dout, din, flags); +} |