HiKey 960 SPI Clock Frequency 25Mhz?


I am trying to configure SPI3 (on HS) at 25MHz. Looking at the SSP_pl022 spec and driver code, clock frequency is arrived at using SSPCLKOUT = SSPCLK / (CPSDVR x (1+SCR)).

Given that

  • minimum value of CPSDVR is 2 and it should be a even value
  • SCR can be 0-254
  • system clock rate is 80MHz

I can either get 20MHz or 40MHz but nothing in between.

Any suggestions as to how I can set 25MHz clock frequency? Any way to change the system clock rate?

Thank you!


What kind of SPI device do you want to control?

Max SPI rate for Hikey960 is 30 Mbit/s. You don’t need to hack the driver to adjust your clock, this can be done from userspace (if you control spi via userspace), from the spi driver you are using, and from the device tree ‘spi-max-frequency’ property of the spi device (cf Connecting MCP2515 via SPI for CAN driver with Android kernel 4.9).


From my driver, I am calling spi_setup after setting spi->max_speed_hz to 25MHz. The spi driver (spi-pl022.c) is dropping the frequency to 20MHz. The code in calculate_effective_freq is using clock divisors that drops the best frequency to 20MHz. With the combination of 80MHz clock and divisors, it does not look like it is possible to calculate any frequency > 20MHz and < 40MHz. Any suggestions here would help.