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
   //pinmux_config(PINMUX_SPI2);
  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)
CONFIG_SPI_MASTER=y
CONFIG_SPI_SPIDEV=y
CONFIG_SPI_DESIGNWARE=y
CONFIG_SPI_DW_MMIO=y

Then the spidev should show up :slight_smile:

1 Like

大佬,按照这个教程配置完成后,没有在/dev/目录下生成相关节点怎么回事?能不能指点一下?

这个启用方法spi可以驱动成功屏幕,点亮了,驱动还有点问题。

1 Like