LCD模组驱动开发

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 devicesConsole 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->driver->name);if (ret) {dev_err(dev,"gpio_request_one('%s'=%d) failed with %d\n",name, gpio, ret);return ret;}*gpiop = gpio_to_desc(gpio);fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",__func__, name, gpio);}return ret;
}

编写配套屏幕 ST7789v 驱动

进入内核文件夹,找到 kernel/linux-5.15/drivers/staging/fbtft/fb_st7789v.c 修改文件如下:

// SPDX-License-Identifier: GPL-2.0+
/** FB driver for the ST7789V LCD Controller** Copyright (C) 2015 Dennis Menschel*/#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/completion.h>
#include <linux/module.h>#include <video/mipi_display.h>#include "fbtft.h"#define DRVNAME "fb_st7789v"#define DEFAULT_GAMMA \"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25\n" \"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25"#define HSD20_IPS_GAMMA \"D0 05 0A 09 08 05 2E 44 45 0F 17 16 2B 33\n" \"D0 05 0A 09 08 05 2E 43 45 0F 16 16 2B 33"#define HSD20_IPS 1/*** enum st7789v_command - ST7789V display controller commands** @PORCTRL: porch setting* @GCTRL: gate control* @VCOMS: VCOM setting* @VDVVRHEN: VDV and VRH command enable* @VRHS: VRH set* @VDVS: VDV set* @VCMOFSET: VCOM offset set* @PWCTRL1: power control 1* @PVGAMCTRL: positive voltage gamma control* @NVGAMCTRL: negative voltage gamma control** The command names are the same as those found in the datasheet to ease* looking up their semantics and usage.** Note that the ST7789V display controller offers quite a few more commands* which have been omitted from this list as they are not used at the moment.* Furthermore, commands that are compliant with the MIPI DCS have been left* out as well to avoid duplicate entries.*/
enum st7789v_command {PORCTRL = 0xB2,GCTRL = 0xB7,VCOMS = 0xBB,VDVVRHEN = 0xC2,VRHS = 0xC3,VDVS = 0xC4,VCMOFSET = 0xC5,PWCTRL1 = 0xD0,PVGAMCTRL = 0xE0,NVGAMCTRL = 0xE1,
};#define MADCTL_BGR BIT(3) /* bitmask for RGB/BGR order */
#define MADCTL_MV BIT(5) /* bitmask for page/column order */
#define MADCTL_MX BIT(6) /* bitmask for column address order */
#define MADCTL_MY BIT(7) /* bitmask for page address order *//* 60Hz for 16.6ms, configured as 2*16.6ms */
#define PANEL_TE_TIMEOUT_MS  33static struct completion panel_te; /* completion for panel TE line */
static int irq_te; /* Linux IRQ for LCD TE line */static irqreturn_t panel_te_handler(int irq, void *data)
{complete(&panel_te);return IRQ_HANDLED;
}/*** init_display() - initialize the display controller** @par: FBTFT parameter object** Most of the commands in this init function set their parameters to the* same default values which are already in place after the display has been* powered up. (The main exception to this rule is the pixel format which* would default to 18 instead of 16 bit per pixel.)* Nonetheless, this sequence can be used as a template for concrete* displays which usually need some adjustments.** Return: 0 on success, < 0 if error occurred.*/
static int init_display(struct fbtft_par *par)
{par->fbtftops.reset(par);mdelay(50);write_reg(par,0x36,0x00);write_reg(par,0x3A,0x05);write_reg(par,0xB2,0x1F,0x1F,0x00,0x33,0x33);write_reg(par,0xB7,0x35);write_reg(par,0xBB,0x20);write_reg(par,0xC0,0x2C);write_reg(par,0xC2,0x01);write_reg(par,0xC3,0x01);write_reg(par,0xC4,0x18);write_reg(par,0xC6,0x13);write_reg(par,0xD0,0xA4,0xA1);write_reg(par,0xE0,0xF0,0x04,0x07,0x04,0x04,0x04,0x25,0x33,0x3C,0x36,0x14,0x12,0x29,0x30);write_reg(par,0xE1,0xF0,0x02,0x04,0x05,0x05,0x21,0x25,0x32,0x3B,0x38,0x12,0x14,0x27,0x31);write_reg(par,0xE4,0x1D,0x00,0x00);write_reg(par,0x21);write_reg(par,0x11);mdelay(50);write_reg(par,0x29);mdelay(200);return 0;
}/** write_vmem() - write data to display.* @par: FBTFT parameter object.* @offset: offset from screen_buffer.* @len: the length of data to be writte.** Return: 0 on success, or a negative error code otherwise.*/
static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
{struct device *dev = par->info->device;int ret;if (irq_te) {enable_irq(irq_te);reinit_completion(&panel_te);ret = wait_for_completion_timeout(&panel_te,msecs_to_jiffies(PANEL_TE_TIMEOUT_MS));if (ret == 0)dev_err(dev, "wait panel TE timeout\n");disable_irq(irq_te);}switch (par->pdata->display.buswidth) {case 8:ret = fbtft_write_vmem16_bus8(par, offset, len);break;case 9:ret = fbtft_write_vmem16_bus9(par, offset, len);break;case 16:ret = fbtft_write_vmem16_bus16(par, offset, len);break;default:dev_err(dev, "Unsupported buswidth %d\n",par->pdata->display.buswidth);ret = 0;break;}return ret;
}/*** set_var() - apply LCD properties like rotation and BGR mode** @par: FBTFT parameter object** Return: 0 on success, < 0 if error occurred.*/
static int set_var(struct fbtft_par *par)
{u8 madctl_par = 0;if (par->bgr)madctl_par |= MADCTL_BGR;switch (par->info->var.rotate) {case 0:break;case 90:madctl_par |= (MADCTL_MV | MADCTL_MY);break;case 180:madctl_par |= (MADCTL_MX | MADCTL_MY);break;case 270:madctl_par |= (MADCTL_MV | MADCTL_MX);break;default:return -EINVAL;}write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, madctl_par);return 0;
}/*** set_gamma() - set gamma curves** @par: FBTFT parameter object* @curves: gamma curves** Before the gamma curves are applied, they are preprocessed with a bitmask* to ensure syntactically correct input for the display controller.* This implies that the curves input parameter might be changed by this* function and that illegal gamma values are auto-corrected and not* reported as errors.** Return: 0 on success, < 0 if error occurred.*/
static int set_gamma(struct fbtft_par *par, u32 *curves)
{int i;int j;int c; /* curve index offset *//** Bitmasks for gamma curve command parameters.* The masks are the same for both positive and negative voltage* gamma curves.*/static const u8 gamma_par_mask[] = {0xFF, /* V63[3:0], V0[3:0]*/0x3F, /* V1[5:0] */0x3F, /* V2[5:0] */0x1F, /* V4[4:0] */0x1F, /* V6[4:0] */0x3F, /* J0[1:0], V13[3:0] */0x7F, /* V20[6:0] */0x77, /* V36[2:0], V27[2:0] */0x7F, /* V43[6:0] */0x3F, /* J1[1:0], V50[3:0] */0x1F, /* V57[4:0] */0x1F, /* V59[4:0] */0x3F, /* V61[5:0] */0x3F, /* V62[5:0] */};for (i = 0; i < par->gamma.num_curves; i++) {c = i * par->gamma.num_values;for (j = 0; j < par->gamma.num_values; j++)curves[c + j] &= gamma_par_mask[j];write_reg(par, PVGAMCTRL + i,curves[c + 0],  curves[c + 1],  curves[c + 2],curves[c + 3],  curves[c + 4],  curves[c + 5],curves[c + 6],  curves[c + 7],  curves[c + 8],curves[c + 9],  curves[c + 10], curves[c + 11],curves[c + 12], curves[c + 13]);}return 0;
}/*** blank() - blank the display** @par: FBTFT parameter object* @on: whether to enable or disable blanking the display** Return: 0 on success, < 0 if error occurred.*/
static int blank(struct fbtft_par *par, bool on)
{if (on)write_reg(par, MIPI_DCS_SET_DISPLAY_OFF);elsewrite_reg(par, MIPI_DCS_SET_DISPLAY_ON);return 0;
}static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
{switch(par->info->var.rotate){case   0: break;case  90: xs+=80;xe+=80;break;case 180:break;case 270: xs+=80;xe+=80;break;default :break;}write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,(xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF);write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,(ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF);write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
}static void reset(struct fbtft_par *par)
{if (!par->gpio.reset)return;gpiod_set_value_cansleep(par->gpio.reset, 1);msleep(10);gpiod_set_value_cansleep(par->gpio.reset, 0);msleep(200);gpiod_set_value_cansleep(par->gpio.reset, 1);msleep(10);gpiod_set_value_cansleep(par->gpio.cs, 1);  /* Activate chip */
}static struct fbtft_display display = {.regwidth = 8,.width = 240,.height = 240,.gamma_num = 2,.gamma_len = 14,.gamma = HSD20_IPS_GAMMA,.fbtftops = {.init_display = init_display,.set_addr_win = set_addr_win,.write_vmem = write_vmem,.set_var = set_var,.set_gamma = set_gamma,.blank = blank,.reset = reset,},
};FBTFT_REGISTER_DRIVER(DRVNAME, "sitronix,st7789v", &display);MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME);
MODULE_ALIAS("spi:st7789v");
MODULE_ALIAS("platform:st7789v");MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller");
MODULE_AUTHOR("Dennis Menschel");
MODULE_LICENSE("GPL");

编写设备树

&pio {spi0_pins_default: spi0@0 {pins = "PC0", "PC2", "PC3"; /* clk, mosi, miso */function = "spi0";drive-strength = <10>;};spi0_pins_cs: spi0@1 {pins = "PC1", "PC4", "PC5"; /* cs, wp, hold */function = "spi0";drive-strength = <10>;bias-pull-up;};spi0_pins_lcd: spi0@2 {pins = "PC0", "PC2"; /* clk, mosi */function = "spi0";drive-strength = <10>;};spi0_pins_lcd_cs: spi0@3 {pins = "PC1"; /* cs */function = "spi0";drive-strength = <10>;};spi0_pins_sleep: spi0@4 {pins = "PC0", "PC2", "PC3", "PC1", "PC4", "PC5";function = "gpio_in";drive-strength = <10>;};
};&spi0 {pinctrl-0 = <&spi0_pins_lcd &spi0_pins_lcd_cs>;pinctrl-1 = <&spi0_pins_sleep>;pinctrl-names = "default", "sleep";sunxi,spi-bus-mode = <SUNXI_SPI_BUS_MASTER>;sunxi,spi-cs-mode = <SUNXI_SPI_CS_AUTO>;status = "okay";st7789v@0 {status = "okay";compatible = "sitronix,st7789v";reg = <0>;spi-max-frequency = <30000000>;rotate = <0>;bgr;fps = <30>;buswidth = <8>;reset = <&pio PC 5 GPIO_ACTIVE_LOW>;dc = <&pio PC 4 GPIO_ACTIVE_LOW>;debug = <1>;};
};

Linux 4.9 内核适配

驱动勾选

由于使用的是 SPI0,所以 TinyVision 的 LCD 模块并不支持使用MIPI-DBI进行驱动,这里我们使用普通的SPI模拟时序。

勾选 SPI 驱动

这里我们使用 SPI-NG 驱动,勾选 Device Drivers ---> [*] SPI support ---><*> SUNXI SPI Controller

在这里插入图片描述

勾选 Linux FrameBuffer 驱动

前往如下地址,勾选驱动

Device Drivers  --->Graphics support  --->Frame buffer Devices  ---><*> Support for frame buffer devicesConsole 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 的设备树接口

进入内核文件夹,找到 lichee/linux-4.9/drivers/staging/fbtft/fbtft-core.c

添加头文件

#include <linux/sunxi-gpio.h>

修改驱动注册接口

static int fbtft_request_one_gpio(struct fbtft_par *par,const char *name, int index, int *gpiop)
{struct device *dev = par->info->device;struct device_node *node = dev->of_node;int gpio, flags, ret = 0;struct gpio_config gpio_of_flags;if (of_find_property(node, name, NULL)) {gpio = of_get_named_gpio_flags(node, name, index, (enum of_gpio_flags *)&gpio_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;}/* active low translates to initially low */flags = (gpio_of_flags.data & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :GPIOF_OUT_INIT_HIGH;ret = devm_gpio_request_one(dev, gpio, flags,dev->driver->name);if (ret) {dev_err(dev,"gpio_request_one('%s'=%d) failed with %d\n",name, gpio, ret);return ret;}if (gpiop)*gpiop = gpio;fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",__func__, name, gpio);}return ret;
}static int fbtft_request_gpios_dt(struct fbtft_par *par)
{int i;int ret;if (!par->info->device->of_node)return -EINVAL;ret = fbtft_request_one_gpio(par, "reset", 0, &par->gpio.reset);if (ret)return ret;ret = fbtft_request_one_gpio(par, "dc", 0, &par->gpio.dc);if (ret)return ret;ret = fbtft_request_one_gpio(par, "rd", 0, &par->gpio.rd);if (ret)return ret;ret = fbtft_request_one_gpio(par, "wr", 0, &par->gpio.wr);if (ret)return ret;ret = fbtft_request_one_gpio(par, "cs", 0, &par->gpio.cs);if (ret)return ret;ret = fbtft_request_one_gpio(par, "latch", 0, &par->gpio.latch);if (ret)return ret;for (i = 0; i < 16; i++) {ret = fbtft_request_one_gpio(par, "db", i,&par->gpio.db[i]);if (ret)return ret;ret = fbtft_request_one_gpio(par, "led", i,&par->gpio.led[i]);if (ret)return ret;ret = fbtft_request_one_gpio(par, "aux", i,&par->gpio.aux[i]);if (ret)return ret;}return 0;
}

编写配套屏幕 ST7789v 驱动

/** FB driver for the ST7789V LCD Controller** Copyright (C) 2015 Dennis Menschel** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.*/#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <video/mipi_display.h>#include "fbtft.h"#define DRVNAME "fb_st7789v"#define DEFAULT_GAMMA \"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25\n" \"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25"#define HSD20_IPS_GAMMA \"D0 05 0A 09 08 05 2E 44 45 0F 17 16 2B 33\n" \"D0 05 0A 09 08 05 2E 43 45 0F 16 16 2B 33"/*** enum st7789v_command - ST7789V display controller commands** @PORCTRL: porch setting* @GCTRL: gate control* @VCOMS: VCOM setting* @VDVVRHEN: VDV and VRH command enable* @VRHS: VRH set* @VDVS: VDV set* @VCMOFSET: VCOM offset set* @PWCTRL1: power control 1* @PVGAMCTRL: positive voltage gamma control* @NVGAMCTRL: negative voltage gamma control** The command names are the same as those found in the datasheet to ease* looking up their semantics and usage.** Note that the ST7789V display controller offers quite a few more commands* which have been omitted from this list as they are not used at the moment.* Furthermore, commands that are compliant with the MIPI DCS have been left* out as well to avoid duplicate entries.*/
enum st7789v_command {PORCTRL = 0xB2,GCTRL = 0xB7,VCOMS = 0xBB,VDVVRHEN = 0xC2,VRHS = 0xC3,VDVS = 0xC4,VCMOFSET = 0xC5,PWCTRL1 = 0xD0,PVGAMCTRL = 0xE0,NVGAMCTRL = 0xE1,
};#define MADCTL_BGR BIT(3) /* bitmask for RGB/BGR order */
#define MADCTL_MV BIT(5) /* bitmask for page/column order */
#define MADCTL_MX BIT(6) /* bitmask for column address order */
#define MADCTL_MY BIT(7) /* bitmask for page address order *//*** init_display() - initialize the display controller** @par: FBTFT parameter object** Most of the commands in this init function set their parameters to the* same default values which are already in place after the display has been* powered up. (The main exception to this rule is the pixel format which* would default to 18 instead of 16 bit per pixel.)* Nonetheless, this sequence can be used as a template for concrete* displays which usually need some adjustments.** Return: 0 on success, < 0 if error occurred.*/
static int init_display(struct fbtft_par *par)
{par->fbtftops.reset(par);mdelay(50);write_reg(par,0x36,0x00);write_reg(par,0x3A,0x05);write_reg(par,0xB2,0x1F,0x1F,0x00,0x33,0x33);write_reg(par,0xB7,0x35);write_reg(par,0xBB,0x20);write_reg(par,0xC0,0x2C);write_reg(par,0xC2,0x01);write_reg(par,0xC3,0x01);write_reg(par,0xC4,0x18);write_reg(par,0xC6,0x13);write_reg(par,0xD0,0xA4,0xA1);write_reg(par,0xE0,0xF0,0x04,0x07,0x04,0x04,0x04,0x25,0x33,0x3C,0x36,0x14,0x12,0x29,0x30);write_reg(par,0xE1,0xF0,0x02,0x04,0x05,0x05,0x21,0x25,0x32,0x3B,0x38,0x12,0x14,0x27,0x31);write_reg(par,0xE4,0x1D,0x00,0x00);write_reg(par,0x21);write_reg(par,0x11);mdelay(50);write_reg(par,0x29);mdelay(200);return 0;return 0;
}/*** set_var() - apply LCD properties like rotation and BGR mode** @par: FBTFT parameter object** Return: 0 on success, < 0 if error occurred.*/
static int set_var(struct fbtft_par *par)
{u8 madctl_par = 0;if (par->bgr)madctl_par |= MADCTL_BGR;switch (par->info->var.rotate) {case 0:break;case 90:madctl_par |= (MADCTL_MV | MADCTL_MY);break;case 180:madctl_par |= (MADCTL_MX | MADCTL_MY);break;case 270:madctl_par |= (MADCTL_MV | MADCTL_MX);break;default:return -EINVAL;}write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, madctl_par);return 0;
}/*** set_gamma() - set gamma curves** @par: FBTFT parameter object* @curves: gamma curves** Before the gamma curves are applied, they are preprocessed with a bitmask* to ensure syntactically correct input for the display controller.* This implies that the curves input parameter might be changed by this* function and that illegal gamma values are auto-corrected and not* reported as errors.** Return: 0 on success, < 0 if error occurred.*/
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
{int i;int j;int c; /* curve index offset *//** Bitmasks for gamma curve command parameters.* The masks are the same for both positive and negative voltage* gamma curves.*/const u8 gamma_par_mask[] = {0xFF, /* V63[3:0], V0[3:0]*/0x3F, /* V1[5:0] */0x3F, /* V2[5:0] */0x1F, /* V4[4:0] */0x1F, /* V6[4:0] */0x3F, /* J0[1:0], V13[3:0] */0x7F, /* V20[6:0] */0x77, /* V36[2:0], V27[2:0] */0x7F, /* V43[6:0] */0x3F, /* J1[1:0], V50[3:0] */0x1F, /* V57[4:0] */0x1F, /* V59[4:0] */0x3F, /* V61[5:0] */0x3F, /* V62[5:0] */};for (i = 0; i < par->gamma.num_curves; i++) {c = i * par->gamma.num_values;for (j = 0; j < par->gamma.num_values; j++)curves[c + j] &= gamma_par_mask[j];write_reg(par, PVGAMCTRL + i,curves[c + 0], curves[c + 1], curves[c + 2],curves[c + 3], curves[c + 4], curves[c + 5],curves[c + 6], curves[c + 7], curves[c + 8],curves[c + 9], curves[c + 10], curves[c + 11],curves[c + 12], curves[c + 13]);}return 0;
}/*** blank() - blank the display** @par: FBTFT parameter object* @on: whether to enable or disable blanking the display** Return: 0 on success, < 0 if error occurred.*/
static int blank(struct fbtft_par *par, bool on)
{if (on)write_reg(par, MIPI_DCS_SET_DISPLAY_OFF);elsewrite_reg(par, MIPI_DCS_SET_DISPLAY_ON);return 0;
}static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
{switch(par->info->var.rotate){case   0: break;case  90: xs+=80;xe+=80;break;case 180:break;case 270: xs+=80;xe+=80;break;default :break;}write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,(xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF);write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,(ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF);write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
}static void reset(struct fbtft_par *par)
{if (par->gpio.reset == -1)return;fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);gpio_set_value(par->gpio.reset, 1);mdelay(20);gpio_set_value(par->gpio.reset, 0);mdelay(20);gpio_set_value(par->gpio.reset, 1);mdelay(120);
}static struct fbtft_display display = {.regwidth = 8,.width = 240,.height = 240,.gamma_num = 2,.gamma_len = 14,.gamma = HSD20_IPS_GAMMA,.fbtftops = {.init_display = init_display,.set_addr_win = set_addr_win,.set_var = set_var,.set_gamma = set_gamma,.blank = blank,.reset = reset,},
};FBTFT_REGISTER_DRIVER(DRVNAME, "sitronix,st7789v", &display);MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME);
MODULE_ALIAS("spi:st7789v");
MODULE_ALIAS("platform:st7789v");MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller");
MODULE_AUTHOR("Dennis Menschel");
MODULE_LICENSE("GPL");

编写设备树

&pio {spi0_pins_a: spi0@0 {allwinner,pins = "PC0", "PC2", "PC3";allwinner,pname = "spi0_sclk", "spi0_mosi", "spi0_miso";allwinner,function = "spi0";allwinner,muxsel = <4>;allwinner,drive = <1>;allwinner,pull = <0>;};spi0_pins_b: spi0@1 {allwinner,pins = "PC1", "PC5", "PC4";allwinner,pname = "spi0_cs0", "spi0_hold", "spi0_wp";allwinner,function = "spi0";allwinner,muxsel = <4>;allwinner,drive = <1>;allwinner,pull = <1>;   // only CS should be pulled up};spi0_pins_c: spi0@2 {allwinner,pins = "PC0", "PC1", "PC2", "PC3", "PC4", "PC5";allwinner,function = "io_disabled";allwinner,muxsel = <7>;allwinner,drive = <1>;allwinner,pull = <0>;};spi0_pins_lcd: spi0@3 {allwinner,pins = "PC0", "PC2"; /* clk, mosi */allwinner,function = "spi0";allwinner,muxsel = <4>;allwinner,drive = <1>;allwinner,pull = <0>;};spi0_pins_lcd_cs: spi0@4 {allwinner,pins = "PC1"; /* cs */allwinner,function = "spi0";allwinner,muxsel = <4>;allwinner,pull = <1>;allwinner,drive = <1>;};
};&spi0 {clock-frequency = <100000000>;pinctrl-0 = <&spi0_pins_lcd &spi0_pins_lcd_cs>;pinctrl-1 = <&spi0_pins_c>;pinctrl-names = "default", "sleep";spi_slave_mode = <0>;spi_dbi_enable = <0>;spi0_cs_number = <1>;status = "okay";st7789v@0 {status = "okay";compatible = "sitronix,st7789v";reg = <0>;spi-max-frequency = <30000000>;rotate = <0>;bgr;fps = <30>;buswidth = <8>;reset = <&pio PC 5 1 1 2 1>;dc = <&pio PC 4 1 1 2 0>;debug = <1>;};
};

显示 Linux 终端

前往驱动勾选如下选项

Device Drivers  --->Graphics support  --->Frame buffer Devices  ---><*> Support for frame buffer devicesConsole display driver support  --->[*] Framebuffer Console support[*]   Map the console to the primary display device

在这里插入图片描述

然后在 bootargs 添加一行 console=tty0 即可显示。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/411501.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

图解计算机网络:一条 HTTP 请求的网络拓扑之旅

引言 常见的网络拓扑结构如下图所示&#xff1a; 在此拓扑中&#xff0c;终端设备通过 WiFi 连接到路由器&#xff0c;路由器再连接到光猫&#xff08;或终端设备通过移动网络 4G/5G 连接到基站&#xff09;&#xff0c;之后 ISP 网络服务提供商接管网络通信&#xff0c;将请求…

Sweet Home 3D:Mac 与 Win 平台的强大 3D 室内装潢设计软件

在当今数字化的时代&#xff0c;一款优秀的室内装潢设计软件可以让你的家居梦想轻松变为现实。Sweet Home 3D for Mac/win 便是这样一款令人惊艳的 3D 室内装潢设计软件&#xff0c;它以其强大的功能和便捷的操作&#xff0c;成为了众多设计师和家居爱好者的首选。 一、功能强…

[数据集][目标检测]考场行为作弊检测数据集VOC+YOLO格式4413张4类别

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;4413 标注数量(xml文件个数)&#xff1a;4413 标注数量(txt文件个数)&#xff1a;4413 标注…

是否应该使用WordPress自动更新的功能

开源程序例如WordPress&#xff0c;使许多人能够轻松创建自己的网站。然而&#xff0c;却存在一个棘手的问题是黑客攻击。开源的性质及其安全透明性让黑客、机器人和脚本小子提供了不断攻击的机会。防止WordPress网站被黑的首要方法是保持WordPress版本、主题和插件的更新。对于…

代码随想录算法训练营第30天 | 452.用最少数量的箭引爆气球、435.无重叠区间、763.划分字母区间

代码随想录算法训练营第30天 | 452.用最少数量的箭引爆气球、435.无重叠区间、763.划分字母区间 文章目录 代码随想录算法训练营第30天 | 452.用最少数量的箭引爆气球、435.无重叠区间、763.划分字母区间452.用最少数量的箭引爆气球解题思路代码实现题目总结 435.无重叠区间解题…

硬盘数据如何恢复?别慌!5 大策略帮您恢复硬盘数据!

在日常生活和工作里&#xff0c;硬盘数据丢失着实让人头疼。不管是不小心误删重要文件&#xff0c;还是对硬盘进行格式化操作、重新安装电脑系统&#xff0c;又或是遭受病毒恶意攻击&#xff0c;都可能让珍贵的数据瞬间没了踪影。 不过别慌&#xff0c;下面为您介绍 5 种应对策…

手动安装Git,手动在右击菜单注册git运行程序

当我们有git的zip压缩包后&#xff0c;只将压缩包解压也是可以用的&#xff0c;但是每次使用时还得去git的安装包下启动git项目&#xff0c;这样就很麻烦。一般情况下都是右击就有git运行程序的选项&#xff0c;直接点击就好&#xff0c;这时用.exe文件安装就没问题&#xff0c…

SQL慢查询优化方式

目录 一、SQL语句优化 1. 避免使用 SELECT * &#xff0c;而是具体字段 2.避免使用 % 开头的 LIKE 的查询 3.避免使用子查询&#xff0c;使用JOIN 4.使用EXISTS代替IN 5.使用LIMIT 1优化查询 6.使用批量插入、优化INSERT操作 7.其他方式 二、SQL索引优化 1.在查询条件…

商圣集团:数字创新,引领智慧生活新篇章

在全球化经济不断演进的大潮中&#xff0c;数字经济已成为推动社会进步的关键引擎&#xff0c;重塑着我们的生产与生活模式。商圣集团&#xff0c;以服务社会、创新驱动为核心价值观&#xff0c;致力于利用数字化技术&#xff0c;为个人和企业带来高效、便捷的服务体验&#xf…

自省式RAG与LangGraph:探索高效实践之路

研究背景 由于大多数大型语言模型&#xff08;LLMs&#xff09;通常只针对大量公共数据进行周期性训练&#xff0c;它们往往缺少最新信息或不能接触到无法用于训练的私有数据。检索增强生成&#xff08;RAG&#xff09;模式恰好解决了这个问题&#xff0c;它通过将大型语言模型…

前端速通面经八股系列(五)—— Vue(上)

Vue系列目录 一、Vue 基础1. Vue的基本原理2. 双向数据绑定的原理3. 使用 Object.defineProperty() 来进行数据劫持有什么缺点&#xff1f;4. MVVM、MVC、MVP的区别5. Computed 和 Watch 的区别6. Computed 和 Methods 的区别7. slot是什么&#xff1f;有什么作用&#xff1f;原…

计算机视觉编程 1(图片处理)

目录 灰色度 缩略图 拷贝粘贴区域 调整图像尺寸 旋转图像45 画图线、描点 灰色度 灰度是指图像中每个像素的亮度值&#xff0c;用来描述图像中各个像素的明暗程度。在计算机视觉中&#xff0c;灰度可以通过以下方式来计算&#xff1a; 1. 平均值法&#xff1a;将图像中每…

E:Failed to fetch的解决方案——Linux换源方法

错误描述 在sudo apt-get时报错 E: Failed to fetch https://mirrors.bupt.edu.cn/ubuntu/pool/universe/libc/libcanberra/libcanberra-gtk0_0.30-7ubuntu1_amd64.deb 403 Forbidden 这种错通常是该源在当前网络下无法连接导致&#xff08;如笔者从教育网换回家里的网&#x…

Kubernetes存储Volume

数据是一个企业的发展核心,他涉及到数据存储和数据交换的内容。在生产环境中尤为重要的一部分&#xff0c;在 Kubernetes 中另一个重要的概念就是数据持久化 Volume。 一、Volume的概念 对于大多数的项目而言&#xff0c;数据文件的存储是非常常见的需求&#xff0c;比如存储用…

大模型低显存推理优化-Offload技术

近两年大模型火出天际&#xff1b;同时&#xff0c;也诞生了大量针对大模型的优化技术。本系列将针对一些常见大模型优化技术进行讲解。 [大模型推理优化技术-KV Cache][大模型推理服务调度优化技术-Continuous batching]大模型显存优化技术-PagedAttention大模型低显存推理优…

爬虫入门学习

流程 获取网页内容 HTTP请求 Python Requests解析网页内容 HTML网页结构 Python Beautiful Soup储存或分析数据 HTTP (Hypertext Transfer Protocol) 客户端和服务器之间的请求-响应协议 Get方法&#xff1a;获得数据 POST方法&#xff1a;创建数据 HTTP请求 请求行 方法类型…

零基础国产GD32单片机编程入门(二)GPIO输入中断含源码

文章目录 一.概要二.可嵌套的向量中断控制器 (NVIC)三.中断向量表四.中断优先级详解五.GD32外部中断控制器(EXTI)1.EXTI简介2.EXTI在中断向量表的位置3.EXTI外部中断产生的信号流向4.EXTI中断产生后的中断服务程序 六.GPIO输入中断的例程实验七.工程源代码下载八.小结 一.概要 …

Django+vue自动化测试平台(29)--测试平台集成playwright录制pytest文件执行

需求背景 一、 系统目标与功能概述 脚本管理: 系统需要能够组织和存储所有通过playwright官方插件录制的脚本。这包括脚本的上传、编辑、删除和版本控制功能。 脚本执行: 用户应该能够在后台界面上查看所有可用的脚本&#xff0c;并能够通过简单的点击操作来启动特定脚本的执…

Visual Basic 6.0教程/Visual Basic从入门到实践/Visual Basic学习视频教程

Visual Basic 6.0教程/Visual Basic从入门到实践/Visual Basic学习视频教程 李天生VB从入门到精通 第一章 VisualBasic6基本介绍 第二章 VisualBasic6的数据类型与运算符表达式 第三章 VisualBasic6的内部函数 第四章 VisualBasic6的基本语句 第五章 VisualBasic6的数组 第六章…

RX 8000系显卡规格曝光,全系GDDR6纯过渡产品

原文转载修改自&#xff08;更多互联网新闻/搞机小知识&#xff09;&#xff1a; RX 8000系显卡规格首曝&#xff0c;GDDR6显存就很骨感 前天&#xff0c;我们刚刚聊过有过新一代RTX 50系消息&#xff0c;虽然是按部就班地升级&#xff0c;但好在也是在升级。50系换核心升级显…