mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2026-03-07 17:57:38 +01:00
Fix two issues with the calculation of pre_div and post_div:
1. pre_div: While the calculation of pre_div looks correct, to set the
CONREG[15-12] bits pre_div needs to be decremented by 1:
The i.MX 6Dual/6Quad Applications Processor Reference Manual (IMX6DQRM
Rev. 0, 11/2012) states:
CONREG[15-12]: PRE_DIVIDER
0000 Divide by 1
0001 Divide by 2
0010 Divide by 3
...
1101 Divide by 14
1110 Divide by 15
1111 Divide by 16
I.e. if we want to divide by 2, we have to write 1 to CONREG[15-12].
2. In case the post divider becomes necessary, pre_div will be divided by
16. So set pre_div to 16, too. And not 15.
Both issues above are tested using the following examples:
clk_src = 60000000 (60MHz, default i.MX6 ECSPI clock)
a) max_hz == 23000000 (23MHz, max i.MX6 ECSPI read clock)
-> pre_div = 3 (divide by 3 => CONREG[15-12] == 2)
-> post_div = 0 (divide by 1 => CONREG[11- 8] == 0)
=> 60MHz / 3 = 20MHz SPI clock
b) max_hz == 2000000 (2MHz)
-> pre_div = 16 (divide by 16 => CONREG[15-12] == 15)
-> post_div = 1 (divide by 2 => CONREG[11- 8] == 1)
=> 60MHz / 32 = 1.875MHz SPI clock
c) max_hz == 1000000 (1MHz)
-> pre_div = 16 (divide by 16 => CONREG[15-12] == 15)
-> post_div = 2 (divide by 4 => CONREG[11- 8] == 2)
=> 60MHz / 64 = 937.5kHz SPI clock
d) max_hz == 500000 (500kHz)
-> pre_div = 16 (divide by 16 => CONREG[15-12] == 15)
-> post_div = 3 (divide by 8 => CONREG[11- 8] == 3)
=> 60MHz / 128 = 468.75kHz SPI clock
Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
|
||
|---|---|---|
| .. | ||
| altera_spi.c | ||
| andes_spi.c | ||
| andes_spi.h | ||
| armada100_spi.c | ||
| atmel_dataflash_spi.c | ||
| atmel_spi.c | ||
| atmel_spi.h | ||
| bfin_spi.c | ||
| bfin_spi6xx.c | ||
| cf_qspi.c | ||
| cf_spi.c | ||
| davinci_spi.c | ||
| davinci_spi.h | ||
| exynos_spi.c | ||
| fdt_spi.c | ||
| fsl_espi.c | ||
| ich.c | ||
| ich.h | ||
| kirkwood_spi.c | ||
| Makefile | ||
| mpc8xxx_spi.c | ||
| mpc52xx_spi.c | ||
| mxc_spi.c | ||
| mxs_spi.c | ||
| oc_tiny_spi.c | ||
| omap3_spi.c | ||
| omap3_spi.h | ||
| sh_spi.c | ||
| sh_spi.h | ||
| soft_spi.c | ||
| spi.c | ||
| tegra20_sflash.c | ||
| tegra20_slink.c | ||
| tegra114_spi.c | ||
| xilinx_spi.c | ||
| xilinx_spi.h | ||