使用芯片为stm32mp157,目前尝试更改设备树文件中spi-max-frequency参数,以及在用户空间程序中使用(ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed_hz)进行spi通讯速度的修改。无论将频率调高或调低,都未能生效。目前时钟频率被固定在125kHz,请问要如何才能调整这个软件模式spi的时钟频率?设备树节点定义如下
gpio_spi_drv_dac: spi@1 {
compatible = "spi-gpio";
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
sck-gpios = <&gpiod 8 0>;
mosi-gpios = <&gpioh 15 0>;
miso-gpios = <&gpioi 4 0>;
cs-gpios = <&gpioi 0 0>;
num-chipselects = <1>;
/* Clients */
spidev@0 {
reg = <0>;
compatible = "linux,spidev";
spi-max-frequency = <500000>;
};
};
用户空间程序中配置spi速率函数如下:
int set_spi_speed(int fd, unsigned int speed_hz) {
if (ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed_hz) < 0) {
perror("Failed to set SPI speed");
return errno;
}
return 0;
}
|