背景

根据orangepi zero2用户手册说明,linux5.13内核不能使用 modprobe fbtft_device 驱动spi lcd

查看linux内核源码提交记录,发现在v5.4-rc3中删除了fbtft_device.c文件

commit如下

staging/fbtft: Remove fbtft_device
Commit c440eee ("Staging: fbtft: Switch to the gpio descriptor
interface") removed the gpio code from fbtft_device rendering it useless. fbtft_device is a module that was used on the Raspberry Pi to dynamically
add fbtft devices when the Pi didn't have Device Tree support.
Just remove the module since it's the responsibility of Device Tree, ACPI
or platform code to add devices. Fixes: c440eee ("Staging: fbtft: Switch to the gpio descriptor interface")
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Link: https://lore.kernel.org/r/20190917171843.10334-2-noralf@tronnes.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

“fbtft_device用来在树莓派没有设备树时,自动添加fbtft设备,删除这个模块因为添加设备是设备树、ACPI或者平台代码的责任”

所以是因为原来的代码不符合设备和驱动分离的原则,所以给删除了,但其实驱动程序依然在,理论上只需要将设备硬件信息注册到内核,就可以正常运行了,可以通过设备树或者模块

dts

下面看下orangepi官方修改后的内核源码中的设备树,分支orange-pi-6.1-sun50iw9

https://github.com/orangepi-xunlong/linux-orangepi

sun50i-h616.dtsi

从芯片级(h616)的dts可以看到spi有spi0和spi1,spi0有一个cs0,spi1有cs0和cs1

			/omit-if-no-ref/
spi0_pins: spi0-pins {
pins = "PC0", "PC2", "PC4";
function = "spi0";
}; /omit-if-no-ref/
spi0_cs0_pin: spi0-cs0-pin {
pins = "PC3";
function = "spi0";
}; /omit-if-no-ref/
spi1_pins: spi1-pins {
pins = "PH6", "PH7", "PH8";
function = "spi1";
}; /omit-if-no-ref/
spi1_cs0_pin: spi1-cs0-pin {
pins = "PH5";
function = "spi1";
}; /omit-if-no-ref/
spi1_cs1_pin: spi1-cs1-pin {
pins = "PH9";
function = "spi1";
};

spi1设备只添加了cs1,cs0引脚没有用在spi1上,而是复用在了i2c3

		spi0: spi@5010000 {
compatible = "allwinner,sun50i-h616-spi",
"allwinner,sun8i-h3-spi";
reg = <0x05010000 0x1000>;
interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>;
clock-names = "ahb", "mod";
resets = <&ccu RST_BUS_SPI0>;
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
dmas = <&dma 22>, <&dma 22>;
dma-names = "rx", "tx";
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
}; spi1: spi@5011000 {
compatible = "allwinner,sun50i-h616-spi",
"allwinner,sun8i-h3-spi";
reg = <0x05011000 0x1000>;
interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&ccu CLK_BUS_SPI1>, <&ccu CLK_SPI1>;
clock-names = "ahb", "mod";
resets = <&ccu RST_BUS_SPI1>;
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins>, <&spi1_cs1_pin>;
dmas = <&dma 23>, <&dma 23>;
dma-names = "rx", "tx";
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
};

sun50i-h616-orangepi-zero2.dts

从板级(orangepi zero2)dts可以看到添加了一个spidev@1设备,但是默认未启用

&spi1 {
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins>, <&spi1_cs1_pin>; spidev@1 {
compatible = "rohm,dh2228fv";
status = "disabled";
reg = <1>;
spi-max-frequency = <1000000>;
};
};

硬件

可以看到spi0用来连接NOR FLASH,所以肯定不可以再用来连接lcd了

spi1在26PIN引出,并且cs0和cs1都有,不过cs0复用在了i2c3的TWI3-SDA引脚上,所以我们使用spi1驱动lcd,并且使用cs1


硬件接线如下,实际上就是用户手册推荐的连接

dts替换

新建ili9341.dts文件

vim ili9341.dts

/dts-v1/;
/plugin/; / {
fragment@0 {
target = <&spi1>;
__overlay__ {
status = "okay";
ili9341: ili9341@0 {
compatible = "ilitek,ili9341";
reg = <1>;
spi-max-frequency = <40000000>;
rotate = <0>;
bgr;
fps = <30>;
buswidth = <8>;
reset-gpios = <&pio 2 9 1>;
dc-gpios = <&pio 2 6 0>;
led-gpios = <&pio 2 5 0>;
debug = <0>;
};
};
};
};

替换设备树,执行后reboot

orangepi-add-overlay ili9341.dts

不出意外的话,console默认会显示在lcd上,可以使用fbi指令测试

su root
apt update
apt install fbi
fbi -vt 1 -noverbose -d /dev/fb0 /boot/boot.bmp

关于pinctrl-0和cs-gpios

使用cs-gpios定义片选信号使用的引脚,来自ChatGPT3.5

spi@40013000 {
compatible = "some-vendor,spi-bus";
reg = <0x40013000>;
#address-cells = <1>;
#size-cells = <0>;
status = "okay"; cs-gpios = <&gpio1 10 0>, <&gpio1 11 0>; // 定义两个片选 GPIO spidev0: spidev@0 {
compatible = "some-vendor,spidev";
reg = <0>; // 对应 cs-gpios 的第一个 GPIO (gpio1 10)
spi-max-frequency = <10000000>;
status = "okay";
}; spidev1: spidev@1 {
compatible = "some-vendor,spidev";
reg = <1>; // 对应 cs-gpios 的第二个 GPIO (gpio1 11)
spi-max-frequency = <10000000>;
status = "okay";
};
};

pinctrl-0已经包含了spi1_cs1_pin,所以spidev的reg直接使用1也可以找到,就不需要cs-gpios了

&spi1 {
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins>, <&spi1_cs1_pin>; spidev@1 {
compatible = "rohm,dh2228fv";
status = "disabled";
reg = <1>;
spi-max-frequency = <1000000>;
};
};

orangepi zero2在linux5.4以上内核使用ili9341的更多相关文章

  1. 如何编译安装Linux内核

    操作系统环境 VMware workstation15 Pro ubuntu18.04 LTS 待编译内核5.3.10版本 内核下载地址 kernel.org 环境配置 在正式编译前需要安装部分软件. ...

  2. 联想ideapad-330C 在Ubuntu18.04 上安装Realtek 8821CE无线网卡驱动

    在新买的联想ideapad-330C笔记本上,安装Ubuntu 18.04后,悲催的发现,没有无线网络,幸好有线还能用,然后网上搜一波,发现不少人遇到这种问题,也有人给出解决方案 参考的链接: Thi ...

  3. 基于mykernel 2.0编写一个操作系统内核

    一.配置mykernel 2.0,熟悉Linux内核的编译 1.实验环境:VMware 15 Pro,Ubuntu 18.04.4 2.配置环境 1)在电脑上先下载好以下两个文件,之后通过共享文件夹, ...

  4. 小白自制Linux开发板 四. 通过SPI使用ESP8266做无线网卡

    本文章基于 WhyCan Forum(哇酷开发者社区) https://whycan.com/t_4149.htmlhttps://whycan.com/t_5870.html整理而成. 为了尊重原作 ...

  5. 小白自制Linux开发板 七. USB驱动配置

    本文章基于https://whycan.com/t_3087.htmlhttps://whycan.com/t_6021.html整理 F1c100s芯片支持USB的OTG模式,也就是可以通过更改Us ...

  6. 在CentOS上编译最新版linux内核(linux-5.19.9)

    从官网下载最新版的Linux内核源码,本教程使用linux-5.19.9进行编译. 实验环境(CentOS-Stream-8) $ uname -a Linux localhost.localdoma ...

  7. Deepin升级Linux5.0内核(目前最新5.3-rc7)

    copy from:https://bbs.deepin.org/forum.php?mod=viewthread&tid=175411&extra=&mobile=no 以下 ...

  8. linux5.8安装oracle10g过程记录,换实例一定要改profile的配置

    查看系统位数: [root@oracle /]# uname -aLinux oracle 2.6.18-308.el5 #1 SMP Fri Jan 27 17:21:15 EST 2012 i68 ...

  9. 分析Linux内核5.0系统调用处理过程

    学号: 363 本实验来源 https://github.com/mengning/linuxkernel/ 一.实验要求 1.编译内核5.02.qemu -kernel linux-5.0.1/ar ...

  10. 举例跟踪linux内核系统调用

    学号351+ 原创作品转载请注明出处 + 中科大孟宁老师的linux操作系统分析: https://github.com/mengning/linuxkernel/ 实验要求: 编译内核5.0 qem ...

随机推荐

  1. AI云增强升级!还原生动人像,拍出质感照片

    近期不少细心用户发现,在用HUAWEI Mate 60 Pro手机拍照后,使用相册中的AI云增强功能,照片变得更加细腻有质感.这是因为AI云增强升级并更新支持了人像模式拍摄的照片,高清自然的人像细节还 ...

  2. Linux Ubuntu安装配置教程

    Ubuntu是一个基于Linux的开源操作系统,它遵循GNU通用公共许可证,用户可以自由使用.复制.分发和修改.它提供直观易用的桌面环境,适合新手和有经验用户.Ubuntu有强大的软件中心,支持多硬件 ...

  3. CentOS 8 安装更新国内清华大学源手记【亲测成功】

    一直和各种OS打交道,仍觉得自己是小白,故深知小白们的困惑和蛋碎,特此将安装更新源的细节和步骤做了详细整理,供大家参考.红字是命令和提示,深灰色代码框中是源配置,本文采用了清华大学CentOS 8的源 ...

  4. Effective Python:简介

    作者:布雷特·斯拉特金 本书的大部分范例代码都遵循Python 3.7版本的语法规范,Python 3.7发布于2018年6月.另外,书里还会给出一些采用Python 3.8语法规范所写的范例,让大家 ...

  5. BGE M3-Embedding 模型介绍

    BGE M3-Embedding来自BAAI和中国科学技术大学,是BAAI开源的模型.相关论文在https://arxiv.org/abs/2402.03216,论文提出了一种新的embedding模 ...

  6. 特殊border的样式 -- CSS3实现三种切角效果

    效果一: 代码:<div class="cornerCut">corner cutcorner cutcorner cutcorner cut</div> ...

  7. 自动化部署脚本--一键部署单机版k8s

    cat danjiDeploy_k8s.sh #!/bin/bash . /etc/init.d/functions # 版本 VERSION=v1.0.1 # IP地址,默认为本机第一块网卡IP地址 ...

  8. Django框架——cookie与session简介、django操作cookie与session、django中间件

    cookie与session简介 """ 回忆:HTTP协议四大特性 1.基于请求响应 2.基于TCP.IP作用于应用层之上的协议 3.无状态 不保存客户端的状态 4.无 ...

  9. 力扣594(java&python)-最长和谐子序列(简单)

    题目: 和谐数组是指一个数组里元素的最大值和最小值之间的差别 正好是 1 . 现在,给你一个整数数组 nums ,请你在所有可能的子序列中找到最长的和谐子序列的长度. 数组的子序列是一个由数组派生出来 ...

  10. 消息队列Kafka「检索组件」重磅上线!

    ​简介:本文对消息队列 Kafka「检索组件」进行详细介绍,首先通过对消息队列使用过程中的痛点问题进行介绍,然后针对痛点问题提出相应的解决办法,并对关键技术技术进行解读,旨在帮助大家对消息队列 Kaf ...