Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi/orion: Add SPI_CHPA and SPI_CPOL support to kirkwood driver.

Support these transfer modes from the SPI layer by setting
the appropriate register bits before doing the transfer.

This was tested on the Marvell kirkwood SOC that uses this driver.

Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Rolf Manderscheid <rvm@obsidianresearch.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

authored by

Jason Gunthorpe and committed by
Grant Likely
b15d5d70 746aeffd

+24 -1
+24 -1
drivers/spi/spi-orion.c
··· 32 32 #define ORION_SPI_DATA_IN_REG 0x0c 33 33 #define ORION_SPI_INT_CAUSE_REG 0x10 34 34 35 + #define ORION_SPI_MODE_CPOL (1 << 11) 36 + #define ORION_SPI_MODE_CPHA (1 << 12) 35 37 #define ORION_SPI_IF_8_16_BIT_MODE (1 << 5) 36 38 #define ORION_SPI_CLK_PRESCALE_MASK 0x1F 39 + #define ORION_SPI_MODE_MASK (ORION_SPI_MODE_CPOL | \ 40 + ORION_SPI_MODE_CPHA) 37 41 38 42 struct orion_spi { 39 43 struct spi_master *master; ··· 127 123 return 0; 128 124 } 129 125 126 + static void 127 + orion_spi_mode_set(struct spi_device *spi) 128 + { 129 + u32 reg; 130 + struct orion_spi *orion_spi; 131 + 132 + orion_spi = spi_master_get_devdata(spi->master); 133 + 134 + reg = readl(spi_reg(orion_spi, ORION_SPI_IF_CONFIG_REG)); 135 + reg &= ~ORION_SPI_MODE_MASK; 136 + if (spi->mode & SPI_CPOL) 137 + reg |= ORION_SPI_MODE_CPOL; 138 + if (spi->mode & SPI_CPHA) 139 + reg |= ORION_SPI_MODE_CPHA; 140 + writel(reg, spi_reg(orion_spi, ORION_SPI_IF_CONFIG_REG)); 141 + } 142 + 130 143 /* 131 144 * called only when no transfer is active on the bus 132 145 */ ··· 162 141 163 142 if ((t != NULL) && t->bits_per_word) 164 143 bits_per_word = t->bits_per_word; 144 + 145 + orion_spi_mode_set(spi); 165 146 166 147 rc = orion_spi_baudrate_set(spi, speed); 167 148 if (rc) ··· 422 399 } 423 400 424 401 /* we support only mode 0, and no options */ 425 - master->mode_bits = 0; 402 + master->mode_bits = SPI_CPHA | SPI_CPOL; 426 403 427 404 master->setup = orion_spi_setup; 428 405 master->transfer_one_message = orion_spi_transfer_one_message;