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

spi: spi-omap2-mcspi.c: Toggle CS after each word

This patch allows the board code to define SPI devices which needs to
toggle the chip select after every word send. This is needed to get a
better resolution reading e.g. an ADC data stream.
Apart from that, as in the normal code CS is controlled by software,
a transfer is done much faster.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Matthias Brugger and committed by
Mark Brown
5cbc7ca9 18dd6199

+21
+18
drivers/spi/spi-omap2-mcspi.c
··· 927 927 928 928 struct spi_device *spi; 929 929 struct spi_transfer *t = NULL; 930 + struct spi_master *master; 930 931 int cs_active = 0; 931 932 struct omap2_mcspi_cs *cs; 932 933 struct omap2_mcspi_device_config *cd; ··· 936 935 u32 chconf; 937 936 938 937 spi = m->spi; 938 + master = spi->master; 939 939 cs = spi->controller_state; 940 940 cd = spi->controller_data; 941 941 ··· 954 952 if (!t->speed_hz && !t->bits_per_word) 955 953 par_override = 0; 956 954 } 955 + if (cd && cd->cs_per_word) { 956 + chconf = mcspi->ctx.modulctrl; 957 + chconf &= ~OMAP2_MCSPI_MODULCTRL_SINGLE; 958 + mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf); 959 + mcspi->ctx.modulctrl = 960 + mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL); 961 + } 962 + 957 963 958 964 if (!cs_active) { 959 965 omap2_mcspi_force_cs(spi, 1); ··· 1022 1012 1023 1013 if (cs_active) 1024 1014 omap2_mcspi_force_cs(spi, 0); 1015 + 1016 + if (cd && cd->cs_per_word) { 1017 + chconf = mcspi->ctx.modulctrl; 1018 + chconf |= OMAP2_MCSPI_MODULCTRL_SINGLE; 1019 + mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf); 1020 + mcspi->ctx.modulctrl = 1021 + mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL); 1022 + } 1025 1023 1026 1024 omap2_mcspi_set_enable(spi, 0); 1027 1025
+3
include/linux/platform_data/spi-omap2-mcspi.h
··· 22 22 23 23 struct omap2_mcspi_device_config { 24 24 unsigned turbo_mode:1; 25 + 26 + /* toggle chip select after every word */ 27 + unsigned cs_per_word:1; 25 28 }; 26 29 27 30 #endif