Enable SPI2 and the corresponding spidev on Milk-V Duo

The Milk-V Duo has the SPI2 bus exposed via header pins. However, the node for SPI2 in dts is not enabled by default, nor are the config entries for dwspi drivers in kernel.
I’ve played with SDK and got SPI data out of it. Here are the steps:

  1. Pinmux setup
    It seems to be relatively easy to edit the board_init function in uboot init.
    Uncomment the line at u-boot-2021.10/board/cvitek/cv180x/board.c:230
  1. Edit devicetree
    Add the following node in build/boards/cv180x/cv1800b_sophpi_duo_sd/dts_riscv/cv1800b_sophpi_duo_sd.dts :
&spi2 {
	status = "okay";
	cs-gpios = <&porta 18 0>;

	spidev@0 {
		status = "okay";
  1. Enable kernel drivers
    Add the following entries in build/boards/cv180x/cv1800b_sophpi_duo_sd/linux/cvitek_cv1800b_sophpi_duo_sd_defconfig (or your own config file)

Then the spidev should show up :slight_smile:

1 Like



1 Like