spi_mpc83xx: support loopback mode
This exposes the hardware loopback mode to drivers, primarily for testing. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
22b238bdb9
commit
2a485d7ad2
1 changed files with 6 additions and 2 deletions
|
@ -39,6 +39,7 @@ struct mpc83xx_spi_reg {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* SPI Controller mode register definitions */
|
/* SPI Controller mode register definitions */
|
||||||
|
#define SPMODE_LOOP (1 << 30)
|
||||||
#define SPMODE_CI_INACTIVEHIGH (1 << 29)
|
#define SPMODE_CI_INACTIVEHIGH (1 << 29)
|
||||||
#define SPMODE_CP_BEGIN_EDGECLK (1 << 28)
|
#define SPMODE_CP_BEGIN_EDGECLK (1 << 28)
|
||||||
#define SPMODE_DIV16 (1 << 27)
|
#define SPMODE_DIV16 (1 << 27)
|
||||||
|
@ -155,7 +156,7 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
|
||||||
/* mask out bits we are going to set */
|
/* mask out bits we are going to set */
|
||||||
regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH
|
regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH
|
||||||
| SPMODE_LEN(0xF) | SPMODE_DIV16
|
| SPMODE_LEN(0xF) | SPMODE_DIV16
|
||||||
| SPMODE_PM(0xF) | SPMODE_REV);
|
| SPMODE_PM(0xF) | SPMODE_REV | SPMODE_LOOP);
|
||||||
|
|
||||||
if (spi->mode & SPI_CPHA)
|
if (spi->mode & SPI_CPHA)
|
||||||
regval |= SPMODE_CP_BEGIN_EDGECLK;
|
regval |= SPMODE_CP_BEGIN_EDGECLK;
|
||||||
|
@ -163,6 +164,8 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
|
||||||
regval |= SPMODE_CI_INACTIVEHIGH;
|
regval |= SPMODE_CI_INACTIVEHIGH;
|
||||||
if (!(spi->mode & SPI_LSB_FIRST))
|
if (!(spi->mode & SPI_LSB_FIRST))
|
||||||
regval |= SPMODE_REV;
|
regval |= SPMODE_REV;
|
||||||
|
if (spi->mode & SPI_LOOP)
|
||||||
|
regval |= SPMODE_LOOP;
|
||||||
|
|
||||||
regval |= SPMODE_LEN(len);
|
regval |= SPMODE_LEN(len);
|
||||||
|
|
||||||
|
@ -273,7 +276,8 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the spi->mode bits understood by this driver: */
|
/* the spi->mode bits understood by this driver: */
|
||||||
#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST)
|
#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \
|
||||||
|
| SPI_LSB_FIRST | SPI_LOOP)
|
||||||
|
|
||||||
static int mpc83xx_spi_setup(struct spi_device *spi)
|
static int mpc83xx_spi_setup(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue