Firefly开源社区

标题: 怎样让px30支持spi slave, 内核版本4.4 [打印本页]

作者: wly    时间: 2022-1-20 19:22
标题: 怎样让px30支持spi slave, 内核版本4.4
px30 kernel4.4默认不支持spi slave模式,有什么补丁让它支持spi slave吗

作者: 时间的蝴蝶    时间: 2022-1-21 09:44
参考 SDK 文档:SDK/docs/Common/SPI/
https://gitlab.com/firefly-linux/docs/-/tree/firefly/Common/SPI
作者: wly    时间: 2022-1-21 16:13
时间的蝴蝶 发表于 2022-1-21 09:44
参考 SDK 文档:SDK/docs/Common/SPI/
https://gitlab.com/firefly-linux/docs/-/tree/firefly/Common/SPI

我按照文档添加了补丁,可以接收数据,但是数据总是不对,您知道啥原因吗,理论收到的数据应该都是:00 00 00 02,而我实际收到的数据确是如下:
RX | 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00
RX | 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00
RX | 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00
RX | 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00
RX | 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00
RX | 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00
RX | 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00
RX | 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00
RX | 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00
RX | 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00
RX | 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00
RX | 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00 00 00 04 00
RX | 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00
RX | 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00
RX | 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00
RX | 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00
RX | 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02
RX | 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02
RX | 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02
RX | 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 02
作者: 时间的蝴蝶    时间: 2022-1-22 09:51
wly 发表于 2022-1-21 16:13
我按照文档添加了补丁,可以接收数据,但是数据总是不对,您知道啥原因吗,理论收到的数据应该都是:00 0 ...

看样子像是数据错开了一位,降低下通讯时钟呢?
作者: wly    时间: 2022-1-22 12:52
时间的蝴蝶 发表于 2022-1-22 09:51
看样子像是数据错开了一位,降低下通讯时钟呢?

现在时钟降到800hz了,还是这个情况,直接读取spi的RXDR寄存器值也是有时候是00 00 00 01,有时候是00 00 00 02,有时候是00 00 40 00,等等。
有一个比较特别的情况就是,我应用层调用spi_read去读取数据,每一次读取的结果是一样的,比如:
我第1次调用spi_read读取512字节数据,读取到的数据都是00 00 00 01,
第2次调用spi_read读取512字节数据,读取到的数据都是00 00 00 02,
第3次调用spi_read读取512字节数据,读取到的数据都是00 00 40 00,
不会出现说我第1次读取到的数据里既有00 00 00 01,也有00 00 00 02的情况。
而我用逻辑分析抓取到数据解析结果一直都是正确的:00 00 00 02.
作者: 时间的蝴蝶    时间: 2022-1-24 09:26
wly 发表于 2022-1-22 12:52
现在时钟降到800hz了,还是这个情况,直接读取spi的RXDR寄存器值也是有时候是00 00 00 01,有时候是00 00 ...

那就尴尬了~有没有留意里面的注意事项、调试方法和问题说明?
或者对照下 rk356x 的 4.19 kernel 驱动。


作者: wly    时间: 2022-1-24 09:48
时间的蝴蝶 发表于 2022-1-24 09:26
那就尴尬了~有没有留意里面的注意事项、调试方法和问题说明?
或者对照下 rk356x 的 4.19 kernel 驱动 ...

我一开始也怀疑我移植的驱动问题,所以升级了内核重新测试,还是一样的问题,现在的内核是4.19,就感觉不知道哪里出了问题,时序也对上了,就是接收的数据不对




欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/) Powered by Discuz! X3.1