LCD模组驱动开发
TinyVision 配套 LCD 模组使用 ST7789V 作为主控,模组大小为1.4寸。
Linux 5.15 内核适配
驱动勾选
由于使用的是 SPI0,所以 TinyVision 的 LCD 模块并不支持使用MIPI-DBI进行驱动,这里我们使用普通的SPI模拟时序。
勾选 SPI 驱动
这里我们使用 SPI-NG 驱动,勾选 <*> SPI NG Driver Support for Allwinner SoCs
勾选 Linux FrameBuffer 驱动
前往如下地址,勾选驱动
Device Drivers --->
Graphics support --->
Frame buffer Devices --->
<*> Support for frame buffer devices
Console display driver support --->
[*] Framebuffer Console support
[*] Map the console to the primary display device
[*] Staging drivers --->
<*> Support for small TFT LCD display modules --->
<*> FB driver for the ST7789V LCD Controller
适配 FBTFT 的设备树接口
进入内核文件夹,找到 kernel/linux-5.15/drivers/staging/fbtft/fbtft-core.c
添加头文件
#include <linux/gpio.h>
#include <linux/of_gpio.h>
修改 fbtft_request_one_gpio
函数,如下
static int fbtft_request_one_gpio(struct fbtft_par *par,
const char *name, int index,
struct gpio_desc **gpiop)
{
struct device *dev = par->info->device;
struct device_node *node = dev->of_node;
int gpio, flags, ret = 0;
enum of_gpio_flags of_flags;
if (of_find_property(node, name, NULL)) {
gpio = of_get_named_gpio_flags(node, name, index, &of_flags);
if (gpio == -ENOENT)
return 0;
if (gpio == -EPROBE_DEFER)
return gpio;
if (gpio < 0) {
dev_err(dev,
"failed to get '%s' from DT\n", name);
return gpio;
}
flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
GPIOF_OUT_INIT_HIGH;
ret = devm_gpio_request_one(dev, gpio, flags,
dev->