149 lines
4.4 KiB
Diff
149 lines
4.4 KiB
Diff
From 1b60568adb073e0b76b8bb7cb59419aa11feb7cb Mon Sep 17 00:00:00 2001
|
|
From: YuzukiTsuru <gloomyghost@gloomyghost.com>
|
|
Date: Sun, 20 Feb 2022 16:40:40 +0800
|
|
Subject: [PATCH] fbtft: support kernel 5.4 add st7789v
|
|
|
|
---
|
|
drivers/staging/fbtft/fb_st7789v.c | 4 +-
|
|
drivers/staging/fbtft/fbtft-core.c | 89 ++++++++++++++++++++----------
|
|
2 files changed, 63 insertions(+), 30 deletions(-)
|
|
|
|
diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c
|
|
index 3c3f38793..eb6f55600 100644
|
|
--- a/drivers/staging/fbtft/fb_st7789v.c
|
|
+++ b/drivers/staging/fbtft/fb_st7789v.c
|
|
@@ -230,8 +230,8 @@ static int blank(struct fbtft_par *par, bool on)
|
|
|
|
static struct fbtft_display display = {
|
|
.regwidth = 8,
|
|
- .width = 240,
|
|
- .height = 320,
|
|
+ .width = 135,
|
|
+ .height = 240,
|
|
.gamma_num = 2,
|
|
.gamma_len = 14,
|
|
.gamma = DEFAULT_GAMMA,
|
|
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
|
|
index 771697508..f8e1bb369 100644
|
|
--- a/drivers/staging/fbtft/fbtft-core.c
|
|
+++ b/drivers/staging/fbtft/fbtft-core.c
|
|
@@ -26,6 +26,9 @@
|
|
#include <linux/of.h>
|
|
#include <video/mipi_display.h>
|
|
|
|
+#include <linux/gpio.h>
|
|
+#include <linux/of_gpio.h>
|
|
+
|
|
#include "fbtft.h"
|
|
#include "internal.h"
|
|
|
|
@@ -71,24 +74,42 @@ EXPORT_SYMBOL(fbtft_dbg_hex);
|
|
|
|
#ifdef CONFIG_OF
|
|
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;
|
|
-
|
|
- *gpiop = devm_gpiod_get_index_optional(dev, name, index,
|
|
- GPIOD_OUT_LOW);
|
|
- if (IS_ERR(*gpiop)) {
|
|
- ret = PTR_ERR(*gpiop);
|
|
- dev_err(dev,
|
|
- "Failed to request %s GPIO: %d\n", name, ret);
|
|
- return ret;
|
|
- }
|
|
- fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' GPIO\n",
|
|
- __func__, name);
|
|
-
|
|
- return ret;
|
|
+ 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;
|
|
}
|
|
|
|
static int fbtft_request_gpios_dt(struct fbtft_par *par)
|
|
@@ -211,6 +232,20 @@ EXPORT_SYMBOL(fbtft_register_backlight);
|
|
static void fbtft_set_addr_win(struct fbtft_par *par, int xs, int ys, int xe,
|
|
int ye)
|
|
{
|
|
+ switch(par->info->var.rotate)
|
|
+ {
|
|
+ case 0: xs+=53;xe+=53;ys+=40;ye+=40;
|
|
+ break;
|
|
+ case 90: xs+=40;xe+=40;ys+=53;ye+=53;
|
|
+ break;
|
|
+ case 180: xs+=53;xe+=53;ys+=40;ye+=40;
|
|
+ break;
|
|
+ case 270: xs+=40;xe+=40;ys+=53;ye+=53;
|
|
+ break;
|
|
+ default :
|
|
+ break;
|
|
+ }
|
|
+
|
|
write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
|
|
(xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF);
|
|
|
|
@@ -222,17 +257,15 @@ static void fbtft_set_addr_win(struct fbtft_par *par, int xs, int ys, int xe,
|
|
|
|
static void fbtft_reset(struct fbtft_par *par)
|
|
{
|
|
- if (!par->gpio.reset)
|
|
- return;
|
|
-
|
|
- fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
|
|
-
|
|
- gpiod_set_value_cansleep(par->gpio.reset, 1);
|
|
- usleep_range(20, 40);
|
|
- gpiod_set_value_cansleep(par->gpio.reset, 0);
|
|
- msleep(120);
|
|
-
|
|
- gpiod_set_value_cansleep(par->gpio.cs, 1); /* Activate chip */
|
|
+ if (!par->gpio.reset)
|
|
+ return;
|
|
+ fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
|
|
+ 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);
|
|
}
|
|
|
|
static void fbtft_update_display(struct fbtft_par *par, unsigned int start_line,
|
|
--
|
|
2.17.1
|