Last active
January 13, 2025 20:36
-
-
Save miathedev/f5a502eec78e4bc113cdb82935824a4e to your computer and use it in GitHub Desktop.
MilkV st7735 buildroot patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 72b54c40a8f0b618d54f9ca32c05b2e9f9f650d2 Mon Sep 17 00:00:00 2001 | |
From: Your Name <[email protected]> | |
Date: Mon, 13 Jan 2025 20:35:18 +0000 | |
Subject: [PATCH] st7735 patch | |
--- | |
.../dts_riscv/cv1813h_milkv_duos_sd.dts | 17 ++++++- | |
.../cvitek_cv1813h_milkv_duos_sd_defconfig | 2 + | |
.../milkv-duos-sd_musl_riscv64_defconfig | 5 +- | |
linux_5.10/drivers/staging/fbtft/fbtft-core.c | 46 ++++++++++++++----- | |
4 files changed, 56 insertions(+), 14 deletions(-) | |
diff --git a/build/boards/cv181x/cv1813h_milkv_duos_sd/dts_riscv/cv1813h_milkv_duos_sd.dts b/build/boards/cv181x/cv1813h_milkv_duos_sd/dts_riscv/cv1813h_milkv_duos_sd.dts | |
index 1ea1d4632..46f161273 100644 | |
--- a/build/boards/cv181x/cv1813h_milkv_duos_sd/dts_riscv/cv1813h_milkv_duos_sd.dts | |
+++ b/build/boards/cv181x/cv1813h_milkv_duos_sd/dts_riscv/cv1813h_milkv_duos_sd.dts | |
@@ -43,9 +43,24 @@ | |
&spi3 { | |
status = "okay"; | |
+ /delete-node/ spidev@0; | |
- spidev@0 { | |
+ st7735r: st7735r@0{ | |
+ compatible = "sitronix,st7735r"; | |
+ reg = <0>; | |
status = "okay"; | |
+ spi-max-frequency = <48000000>; | |
+ spi-cpol; | |
+ spi-cpha; | |
+ rotate = <0>; | |
+ fps = <60>; | |
+ rgb; | |
+ buswidth = <8>; | |
+ | |
+ dc = <&porta 18 GPIO_ACTIVE_HIGH>; | |
+ reset = <&porta 28 GPIO_ACTIVE_HIGH>; | |
+ | |
+ debug = <0x0>; | |
}; | |
}; | |
diff --git a/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig b/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig | |
index 3003163a0..1d5f0d00b 100644 | |
--- a/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig | |
+++ b/build/boards/cv181x/cv1813h_milkv_duos_sd/linux/cvitek_cv1813h_milkv_duos_sd_defconfig | |
@@ -165,6 +165,8 @@ CONFIG_WATCHDOG=y | |
CONFIG_FB=y | |
CONFIG_FB_SIMPLE=y | |
CONFIG_FB_CVITEK=m | |
+CONFIG_FB_TFT=y | |
+CONFIG_FB_TFT_ST7735R=y | |
CONFIG_SOUND=y | |
CONFIG_SND=y | |
# CONFIG_SND_SUPPORT_OLD_API is not set | |
diff --git a/buildroot-2021.05/configs/milkv-duos-sd_musl_riscv64_defconfig b/buildroot-2021.05/configs/milkv-duos-sd_musl_riscv64_defconfig | |
index dcafbf2bb..357e1b358 100644 | |
--- a/buildroot-2021.05/configs/milkv-duos-sd_musl_riscv64_defconfig | |
+++ b/buildroot-2021.05/configs/milkv-duos-sd_musl_riscv64_defconfig | |
@@ -36,6 +36,10 @@ BR2_PACKAGE_STRESS_NG=y | |
BR2_PACKAGE_TREE=y | |
BR2_PACKAGE_E2FSPROGS=y | |
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y | |
+BR2_PACKAGE_FB_TEST_APP=y | |
+BR2_PACKAGE_FBSET=y | |
+BR2_PACKAGE_FBTERM=y | |
+BR2_PACKAGE_FBV=y | |
BR2_PACKAGE_EVTEST=y | |
BR2_PACKAGE_I2C_TOOLS=y | |
BR2_PACKAGE_PARTED=y | |
@@ -57,7 +61,6 @@ BR2_PACKAGE_PYTHON_SPIDEV=y | |
BR2_PACKAGE_CA_CERTIFICATES=y | |
BR2_PACKAGE_LIBOPENSSL_BIN=y | |
BR2_PACKAGE_LIBOPENSSL_ENGINES=y | |
-BR2_PACKAGE_FREETYPE=y | |
BR2_PACKAGE_C_PERIPHERY=y | |
BR2_PACKAGE_LIBUSB=y | |
BR2_PACKAGE_LIBUSB_EXAMPLES=y | |
diff --git a/linux_5.10/drivers/staging/fbtft/fbtft-core.c b/linux_5.10/drivers/staging/fbtft/fbtft-core.c | |
index 4f362dad4..2576046ac 100644 | |
--- a/linux_5.10/drivers/staging/fbtft/fbtft-core.c | |
+++ b/linux_5.10/drivers/staging/fbtft/fbtft-core.c | |
@@ -27,6 +27,9 @@ | |
#include <video/mipi_display.h> | |
+#include <linux/gpio.h> | |
+#include <linux/of_gpio.h> | |
+ | |
#include "fbtft.h" | |
#include "internal.h" | |
@@ -72,22 +75,39 @@ void fbtft_dbg_hex(const struct device *dev, int groupsize, | |
EXPORT_SYMBOL(fbtft_dbg_hex); | |
static int fbtft_request_one_gpio(struct fbtft_par *par, | |
- const char *name, int index, | |
- struct gpio_desc **gpiop) | |
+ const char *name, int index, | |
+ struct gpio_desc **gpiop) | |
{ | |
struct device *dev = par->info->device; | |
- int ret = 0; | |
+ struct device_node *node = dev->of_node; | |
+ int gpio, flags, ret = 0; | |
+ enum of_gpio_flags of_flags; | |
- *gpiop = devm_gpiod_get_index_optional(dev, name, index, | |
- GPIOD_OUT_HIGH); | |
- if (IS_ERR(*gpiop)) { | |
- ret = PTR_ERR(*gpiop); | |
- dev_err(dev, | |
- "Failed to request %s GPIO: %d\n", name, ret); | |
- return ret; | |
+ 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; | |
+ } | |
+ | |
+ //active low translates to initially low | |
+ 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); | |
} | |
- fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' GPIO\n", | |
- __func__, name); | |
return ret; | |
} | |
@@ -231,6 +251,8 @@ static void fbtft_reset(struct fbtft_par *par) | |
usleep_range(20, 40); | |
gpiod_set_value_cansleep(par->gpio.reset, 0); | |
msleep(120); | |
+ gpiod_set_value_cansleep(par->gpio.reset, 1); | |
+ msleep(10); | |
} | |
static void fbtft_update_display(struct fbtft_par *par, unsigned int start_line, | |
-- | |
2.34.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test with executing fb-test