想通过应用层操作spi
首先我保证这几个内核配置是开了的:
CONFIG_SPI_SUN6I=y
CONFIG_SPI=y
CONFIG_SPI_MASTER=y
CONFIG_SPI_SPIDEV=y
然后因为我用spi flash启动 已经占用了spi0 所以要加新的接口spi1
改设备树文件suniv.dtsi 通过参考spi0来增加
spi0_pins_a: spi0-pins-pc {
pins = "PC0", "PC1", "PC2", "PC3";
function = "spi0";
};
spi1_pins_a: spi1-pins-pa {
pins = "PA2", "PA0", "PA3", "PA1";
function = "spi1";
};
改设备树文件suniv-f1c100s-licheepi-nano.dts 通过参考spi0来增加
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins_a>;
status = "okay";
flash: w25q128@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "winbond,w25q128", "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
partitions{
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
lable = "u-boot";
reg = <0x000000 0x100000>;
read-only;
};
partition@100000 {
lable = "dtb";
reg = <0x100000 0x10000>;
read-only;
};
partition@110000 {
label = "kernel";
reg = <0x110000 0x400000>;
read-only;
};
partition@510000 {
label = "rootfs";
reg = <0x510000 0xAF0000>;
};
};
};
};
&spi1 {
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins_a>;
status = "okay";
};
然后编译内核和设备树重新打包下载进板子
如果添加spi1成功了 会多出来个/dev/spi1 但实际上没有 只有原来的spi0.0 说明可能哪里错了 大神来指点一下?
离线
操作一下 spi0.0
有可能就是你需要的,接逻辑分析仪到 cs# 引脚测试。
记错了 看了下 发现/dev/ 里面没有spi相关设备 是/sys/bus/spi/devices/spi0.0 这个应该不能操作吧
离线
原来是设备树没配好 重要的设备节点漏了
参考了链接 http://linux-sunxi.org/SPIdev
把/dev/spidev1.0配出来了
离线