android_kernel_xiaomi_sm8350/drivers/spi
Anton Vorontsov a44648b057 spi_mpc83xx: fix prescale modulus calculation
Long ago I've noticed (but didn't pay much attention) that
spi_mpc83xx using PM calculations that differs from what
specs describe. I.e.

u8 pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 4);

While specs says: "The SPI baud rate generator clock source (either
system clock or system clock divided by 16, depending on DIV16 bit) is
divided by 4 * ([PM] + 1), a range from 4 to 64.".

Thus " - 1" is missing in the spi_mpc83xx's formula.

Why nobody noticed that bug? Probably because sysclk usually less then
user expects, e.g. you expect 200 MHz, but real clock is 198 MHz,
and integer rounding helps when this formula is used.

Suppose it's SPI in QE, SYSCLK at 198 MHz, thus SPIBRG at 99MHz, 25 MHz
requested.

PM = (99MHz / ( 25 MHz * 4 )), PM == 0, output SPICLK will be 24.75 MHz

At lower frequencies this bug is more noticeable, though.

And this bug shows itself in all its beauty if SYSCLK is equal or a bit
more than you expect (200 MHz SYSCLK, 100 MHz SPIBRG):
PM = (100MHz / ( 25 MHz * 4 )), PM == 1, output SPICLK will be 12.625 MHz!

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>
2007-08-11 15:47:41 -07:00
..
at25.c sysfs: add parameter "struct bin_attribute *" in .read/.write methods for sysfs binary attributes 2007-07-11 16:09:09 -07:00
atmel_spi.c atmel_spi: don't always deselect chip between messages 2007-07-17 10:23:05 -07:00
atmel_spi.h [PATCH] SPI: atmel_spi driver 2007-02-14 08:09:53 -08:00
au1550_spi.c SPI controller drivers: check for unsupported modes 2007-07-17 10:23:04 -07:00
Kconfig spi_txx9 controller driver 2007-07-17 10:23:05 -07:00
Makefile spi_txx9 controller driver 2007-07-17 10:23:05 -07:00
mpc52xx_psc_spi.c SPI controller drivers: check for unsupported modes 2007-07-17 10:23:04 -07:00
omap2_mcspi.c SPI: omap2_mcspi driver 2007-07-17 10:23:05 -07:00
omap_uwire.c SPI controller drivers: check for unsupported modes 2007-07-17 10:23:04 -07:00
pxa2xx_spi.c SPI controller drivers: check for unsupported modes 2007-07-17 10:23:04 -07:00
spi_bfin5xx.c Blackfin SPI driver: fix bug SPI DMA incomplete transmission 2007-06-11 17:34:17 +08:00
spi_bitbang.c SPI controller drivers: check for unsupported modes 2007-07-17 10:23:04 -07:00
spi_butterfly.c minor spi_butterfly cleanup 2007-05-08 11:15:15 -07:00
spi_imx.c SPI controller drivers: check for unsupported modes 2007-07-17 10:23:04 -07:00
spi_lm70llp.c spi_lm70llp parport adapter driver 2007-07-17 10:23:04 -07:00
spi_mpc83xx.c spi_mpc83xx: fix prescale modulus calculation 2007-08-11 15:47:41 -07:00
spi_s3c24xx_gpio.c [PATCH] spi_s3c2410_gpio.c spi mode 2 and 3 support 2007-02-20 17:10:16 -08:00
spi_s3c24xx.c fixup s3c24xx build after arch moves 2007-07-26 11:35:16 -07:00
spi_txx9.c spi_txx9 controller driver 2007-07-17 10:23:05 -07:00
spi.c spi device setup gets better error checking 2007-07-31 15:39:44 -07:00
spidev.c spidev supports more communications modes 2007-07-31 15:39:40 -07:00
tle62x0.c SPI: tle620x power switch driver 2007-07-17 10:23:05 -07:00
xilinx_spi.c SPI master driver for Xilinx virtex 2007-07-17 10:23:05 -07:00