|
关于AIO-3399J使用SPI2
发表于 2018-5-10 10:56:41
浏览:12748
|
回复:3
打印
只看该作者
[复制链接]
楼主
本帖最后由 cdworld 于 2018-5-10 10:56 编辑
内核代码获取途径:https://TeeFirefly@gitlab.com/TeeFirefly/linux-kernel.git.
硬件接口:spi2
测试代码:linux-kernel-gitlab-firefly/Documentation/spi/spidev_test.c
由于AIO-3399J的spi1被用于其他功能上,板卡上只有spi2口
使用的设备树文件:
linux-kernel-gitlab-firefly/arch/arm64/boot/dts/rockchip/rk3399-firefly-aio-linux.dts
修改如下:
&spi1 {
status = "disabled";
};
&spi2 {
status = "okay";
spi_sm: spi_sm@0xff1e0000{
compatible = "rockchip,rk3399-spi", "rockchip,rk3066-spi";
reg = <0x0 0xff1e0000 0x0 0x1000>;
spi-max-frequency = <10000000>; //spi-cpha; /* SPI mode: CPHA=1 */
spi-cpol; /* SPI mode: CPOL=1 */
status = "okay";
};
}
linux-kernel-gitlab-firefly/arch/arm64/boot/dts/rockchip/rk339.dtsi文件
spi2修改如下:
spi2: spi@ff1e0000 {
compatible = "rockchip,rk3399-spi", "rockchip,rk3066-spi";
reg = <0x0 0xff1e0000 0x0 0x1000>;
clocks = <&cru SCLK_SPI2>, <&cru PCLK_SPI2>;
clock-names = "spiclk", "apb_pclk";
interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH 0>;
pinctrl-names = "default";
pinctrl-0 = <&spi2_clk &spi2_tx &spi2_rx &spi2_cs0>;
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
};
本文件中Makefile注释所有的编译选项
linux-kernel-gitlab-firefly文件下make menuconfig
-> Device Driver
-> SPI support (SPI [=y])
中关闭wk2xxx Spi Switch Uart编译入内核
编译dtb
sudo make CROSS_COMPILE=你的交叉编译工具链路径 dtbs
编译内核
sudo make ARCH=arm64CROSS_COMPILE=你的交叉编译工具链路径 rk3399-firefly-aio-linux.img -j8
编写Makefile,交叉编译spidev_test.c文件
硬件操作:短接spi2 的 TX 和 RX 。
./spidev_test -D /dev/spidev32766.0
结果如下:
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
RX | FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF | ................................
|
|