whycanservice2 发布的最佳帖子
-
全志v851s使用fbtft驱动0.96寸st7735屏分享
最近打算做个小玩意,需要驱动0.96寸的st7735,为此也踩了些坑,特此记录分享。
直接上配置吧:
1.电路图:
这里使用到spi0 以及 PD2 PD4 还有PH0 作为pwm0 没截图显示。
2.board.dts配置&pio{ ..... spi0_pins_a: spi0@0 { allwinner,pins = "PC0", "PC2"; allwinner,pname = "spi0_sclk", "spi0_mosi"; allwinner,function = "spi0"; allwinner,muxsel = <4>; allwinner,drive = <1>; allwinner,pull = <0>; }; spi0_pins_b: spi0@1 { allwinner,pins = "PC1"; allwinner,pname = "spi0_cs0"; 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"; allwinner,function = "io_disabled"; allwinner,muxsel = <0xf>; allwinner,drive = <1>; allwinner,pull = <0>; }; ................ };
以上为引脚配置,
&spi0 { clock-frequency = <100000000>; pinctrl-0 = <&spi0_pins_a &spi0_pins_b>; pinctrl-1 = <&spi0_pins_c>; pinctrl-names = "default", "sleep"; spi0_cs_number = <1>; spi1_cs_bitmap = <1>; spi_slave_mode = <0>; spi_dbi_enable = <0>; status = "okay"; st7789v@0 { status = "okay"; compatible = "sitronix,st7735r"; reg = <0>; spi-max-frequency = <32000000>; rotate = <90>; bgr; fps = <60>; buswidth = <8>; reset-gpios = <&pio PD 2 1 1 2 1>; dc-gpios = <&pio PD 4 1 1 2 0>; led-gpios = <&pio PH 0 1 1 2 1>; debug = <1>; }; };
这里是spi0配置。
2.内核配置(可以选择关闭disp2,以及 设备树 删除disp lcd0 部分)
切记。一定要关闭uboot disp2 。
3.修改驱动代码
.../linux-4.9/drivers/staging/fbtft/fbtft-core.c 文件中
static int fbtft_request_one_gpio(struct fbtft_par *par, const char *name, int index, int *gpiop) 函数,修改后代码如下: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; }
修改 .../linux-4.9/drivers/staging/fbtft/fb_st7735r.c 文件
主要修改一下驱动初始化代码列表:
static int default_init_sequence[] = { -1, MIPI_DCS_SOFT_RESET, -2, 150, /* delay */ -1, MIPI_DCS_EXIT_SLEEP_MODE, -2, 500, /* delay */ /* FRMCTR1 - frame rate control: normal mode * frame rate = fosc / (1 x 2 + 40) * (LINE + 2C + 2D) */ -1, 0xB1, 0x05, 0x3C, 0x3C, /* FRMCTR2 - frame rate control: idle mode * frame rate = fosc / (1 x 2 + 40) * (LINE + 2C + 2D) */ -1, 0xB2, 0x05, 0x3C, 0x3C, /* FRMCTR3 - frame rate control - partial mode * dot inversion mode, line inversion mode */ -1, 0xB3, 0x05, 0x3C, 0x3C, 0x05, 0x3C, 0x3C, /* INVCTR - display inversion control * no inversion */ -1, 0xB4, 0x03, /* PWCTR1 - Power Control * -4.6V, AUTO mode */ -1, 0xC0, 0xAB, 0x0B, 0x04, /* PWCTR2 - Power Control * VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD */ -1, 0xC1, 0xC5, /* PWCTR3 - Power Control * Opamp current small, Boost frequency */ -1, 0xC2, 0x0D, 0x00, /* PWCTR4 - Power Control * BCLK/2, Opamp current small & Medium low */ -1, 0xC3, 0x8D, 0x6A, /* PWCTR5 - Power Control */ -1, 0xC4, 0x8D, 0xEE, /* VMCTR1 - Power Control */ -1, 0xC5, 0x0F, -1, 0x21, -1, 0x3A, 0x05, -1, MIPI_DCS_SET_DISPLAY_ON, -2, 100, /* delay */ -1, MIPI_DCS_ENTER_NORMAL_MODE, -2, 10, /* delay */ /* end marker */ -3 };
!!修改屏偏移
static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) { xs = xs + 1 ; xe = xe + 1 ; ys = ys + 26 ; ye = ye + 26; write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF); write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF); write_reg(par, MIPI_DCS_WRITE_MEMORY_START); }
修改屏参数:
static struct fbtft_display display = { .regwidth = 8, .width = 80, .height = 160, .init_sequence = default_init_sequence, .gamma_num = 2, .gamma_len = 16, .gamma = DEFAULT_GAMMA, .fbtftops = { .set_addr_win = set_addr_win, .set_var = set_var, .set_gamma = set_gamma, }, };
至此编译即可在小机端看到有fb0生成,屏幕点亮。
最后一图:
如有疑问,请跟贴。
-
回复: T113-S3 SD卡启动问题
@wjp2547532 这个问题有硬件部分的问题,也有软件部分的问题。
先说硬件,硬件这部分涉及较多,总的来说简单解决办法是在卡供电与3.3V电源之间串一个2.2R的电阻来解决插入重启的问题。
软件部分是因为这个芯片启动的bios逻辑是优先卡启动,如果在卡中没有找到系统引导则转为检查其他存储设备,这里注意是检查系统引导。这也是后面你格式化了但还是被引导启动了的原因,因为普通格式化仅仅是擦除了卡内的分区信息及文件信息,实际内容并没有擦除。所以依旧可以引导启动,但是又由于分区信息擦除,导致被引导的系统拿不到正确的分区信息,所以又启动失败了。 -
回复: d1s + st7701s RGB颜色异常
@ggy321 在 d1s + st7701s RGB颜色异常 中说:
lcd_frm = <1>;这个配置要看你的屏驱动配置的是多少bit位宽的数据,如果配置不正确就是你看到的这样。过渡不平滑
-
回复: T113 I2S 音频输出至 Lontium 芯片 / T113 I2S Audio Output to Lontium chip
修改如下:
daudio2_pins_a: daudio2@0 { /* I2S_PIN: MCLK, BCLK, LRCK */ pins = "PB7", "PB5", "PB6"; function = "i2s2"; drive-strength = <20>; bias-disable; }; daudio2_pins_b: daudio2@1 { /* I2S_PIN: DOUT0 */ pins = "PB4"; function = "i2s2_dout"; drive-strength = <20>; bias-disable; }; daudio2_pins_c: daudio2@2 { /* I2S_PIN: DIN0 */ pins = “PB7", "PB5", "PB6", "PB4"; function = "io_disabled"; drive-strength = <20>; bias-disable; };
-
回复: 【开源游戏机】新开源机器预告(全志A133芯片/Android)
@jordonwu 全志A133 跑安卓12.屏幕800*480 样机3.97寸屏无触摸,后面应该是用4.45寸屏带触摸。
whycanservice2 发布的最新帖子
-
回复: T113 I2S 音频输出至 Lontium 芯片 / T113 I2S Audio Output to Lontium chip
修改如下:
daudio2_pins_a: daudio2@0 { /* I2S_PIN: MCLK, BCLK, LRCK */ pins = "PB7", "PB5", "PB6"; function = "i2s2"; drive-strength = <20>; bias-disable; }; daudio2_pins_b: daudio2@1 { /* I2S_PIN: DOUT0 */ pins = "PB4"; function = "i2s2_dout"; drive-strength = <20>; bias-disable; }; daudio2_pins_c: daudio2@2 { /* I2S_PIN: DIN0 */ pins = “PB7", "PB5", "PB6", "PB4"; function = "io_disabled"; drive-strength = <20>; bias-disable; };
-
回复: T113 I2S 音频输出至 Lontium 芯片 / T113 I2S Audio Output to Lontium chip
@dazb3 在 T113 I2S 音频输出至 Lontium 芯片 / T113 I2S Audio Output to Lontium chip 中说:
> &daudio2 { > mclk_div = <0x00>; > frametype = <0x00>; > tdm_config = <0x01>; > sign_extend = <0x00>; > tx_data_mode = <0x00>; > rx_data_mode = <0x00>; > msb_lsb_first = <0x00>; > pcm_lrck_period = <0x20>; > slot_width_select = <0x20>; > asrc_function_en = <0x00>; > pinctrl-names = "default", "sleep"; > pinctrl-0 = <&daudio2_pins_a &daudio2_pins_b>; > pinctrl-1 = <&daudio2_pins_c>; > pinctrl_used = <0x0>; > daudio_type = <0x1>; > status = "okay"; > };
-
回复: d1s + st7701s RGB颜色异常
@ggy321 在 d1s + st7701s RGB颜色异常 中说:
lcd_frm = <1>;这个配置要看你的屏驱动配置的是多少bit位宽的数据,如果配置不正确就是你看到的这样。过渡不平滑