rk3399 spi1 w25q64 问题
驱动W25Q64 flash,手册里erase write enable 等CMD都需要在CMD发送后将CS脚拉高,在DTS里设置spi-cs-high,在dmesg里看到如下错误:
[ 0.972435] spi spi32766.0: setup: unsupported mode bits 4
[ 0.972451] rockchip-spi ff1d0000.spi: can't setup spi32766.0, status -22
[ 0.972461] spi_master spi32766: spi_device register error /spi@ff1d0000/w25q64@00
[ 0.972473] spi_master spi32766: Failed to create SPI device for /spi@ff1d0000/w25q64@00
有大佬帮忙解答吗,
如何才能正确的erase write enable,
确认引脚没复用,write protect 脚拉高了,
能读到flash的全FF数据。
&spi1 {
status = "okay";
max-freq = <48000000>;
dev-port = <1>;
w25q64: w25q64@00 {
status = "okay";
compatible = "rockchip,spidev";
reg = <0x00>;
spi-max-frequency = <24000000>;
wp-gpio = <&gpio0 12 GPIO_ACTIVE_HIGH>; /*GPIO0_B4*/
spi-cs-high;
//spi-cpha; /*SPI mode: CPHA = 1*/
//spi-cpol; /*SPI mode: CPOL = 1*/
};
};
解决了,确实不能支持spi-cs-high。
根据W25Q64手册,erase write enable等操作,需要在CMD发出后将CS脚拉高
用逻辑分析仪看:
在调用spidev_sync(spidev, &m),其中spi_message视为一次传输的包,即传输完毕后CS将会自动拉高
因此只需要把CMD作为一次单独的spi_message即可让flash处理相应CMD,如:
static int firefly_spi_w25x_write_enable(struct spi_device *spi)
{
int status;
char cmd_buf = {WRITE_ENABLE};
struct spi_transfer cmd = {
.tx_buf = cmd_buf,
.len = ARRAY_SIZE(cmd_buf),
};
struct spi_message m;
spi_message_init(&m);
spi_message_add_tail(&cmd, &m);
status = spi_sync(spi, &m);
dev_dbg(&spi->dev, "write enable\n");
return status;
}
页:
[1]