From a7aacf4994895551649de799fb7d45241219083e Mon Sep 17 00:00:00 2001 From: SamulKyull Date: Mon, 15 Apr 2024 23:26:06 +0800 Subject: [PATCH] add fbtft module for spi display --- bsp/Kconfig | 3 + bsp/Makefile | 3 +- bsp/drivers/Makefile | 1 - bsp/modules/Kconfig | 4 + bsp/modules/Makefile | 4 + bsp/modules/fbtft/Kconfig | 21 + bsp/modules/fbtft/Makefile | 7 + bsp/modules/fbtft/README | 32 + bsp/modules/fbtft/TODO | 3 + bsp/modules/fbtft/fb_st7789v.c | 336 ++++++++ bsp/modules/fbtft/fbtft-bus.c | 243 ++++++ bsp/modules/fbtft/fbtft-core.c | 1361 +++++++++++++++++++++++++++++++ bsp/modules/fbtft/fbtft-io.c | 236 ++++++ bsp/modules/fbtft/fbtft-sysfs.c | 220 +++++ bsp/modules/fbtft/fbtft.h | 423 ++++++++++ bsp/modules/fbtft/internal.h | 13 + 16 files changed, 2908 insertions(+), 2 deletions(-) create mode 100644 bsp/modules/Kconfig create mode 100644 bsp/modules/Makefile create mode 100644 bsp/modules/fbtft/Kconfig create mode 100644 bsp/modules/fbtft/Makefile create mode 100644 bsp/modules/fbtft/README create mode 100644 bsp/modules/fbtft/TODO create mode 100644 bsp/modules/fbtft/fb_st7789v.c create mode 100644 bsp/modules/fbtft/fbtft-bus.c create mode 100644 bsp/modules/fbtft/fbtft-core.c create mode 100644 bsp/modules/fbtft/fbtft-io.c create mode 100644 bsp/modules/fbtft/fbtft-sysfs.c create mode 100644 bsp/modules/fbtft/fbtft.h create mode 100644 bsp/modules/fbtft/internal.h diff --git a/bsp/Kconfig b/bsp/Kconfig index 2facbe3af9..2b9635973d 100644 --- a/bsp/Kconfig +++ b/bsp/Kconfig @@ -6,4 +6,7 @@ source "bsp/platform/Kconfig" source "bsp/platform/Kconfig.debug" source "bsp/drivers/Kconfig" +# Avaota SBC Modules +source "bsp/modules/Kconfig" + endmenu diff --git a/bsp/Makefile b/bsp/Makefile index 1b9abd0048..f0d2169c43 100644 --- a/bsp/Makefile +++ b/bsp/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y += drivers/ \ No newline at end of file +obj-y += drivers/ +obj-y += modules/ \ No newline at end of file diff --git a/bsp/drivers/Makefile b/bsp/drivers/Makefile index 6909f8746a..f7b242eade 100644 --- a/bsp/drivers/Makefile +++ b/bsp/drivers/Makefile @@ -108,4 +108,3 @@ obj-y += fs/ #awlink obj-y += awlink/ - diff --git a/bsp/modules/Kconfig b/bsp/modules/Kconfig new file mode 100644 index 0000000000..9fe99faf7f --- /dev/null +++ b/bsp/modules/Kconfig @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +# spi tft +source "bsp/modules/fbtft/Kconfig" \ No newline at end of file diff --git a/bsp/modules/Makefile b/bsp/modules/Makefile new file mode 100644 index 0000000000..f0241ec4da --- /dev/null +++ b/bsp/modules/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +# spi tft +obj-y += fbtft/ \ No newline at end of file diff --git a/bsp/modules/fbtft/Kconfig b/bsp/modules/fbtft/Kconfig new file mode 100644 index 0000000000..c63523bc5c --- /dev/null +++ b/bsp/modules/fbtft/Kconfig @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0 +menuconfig AVA_FB_TFT + tristate "Support for onboard SPI TFT LCD display modules" + depends on FB && SPI + depends on GPIOLIB || COMPILE_TEST + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_SYS_FOPS + select FB_DEFERRED_IO + select FB_BACKLIGHT + +config AVA_FB_TFT_ST7789V + tristate "FB driver for the ST7789V LCD Controller" + depends on AVA_FB_TFT + help + This enables generic framebuffer support for the Sitronix ST7789V + display controller. The controller is intended for small color + displays with a resolution of up to 320x240 pixels. + + Say Y if you have such a display that utilizes this controller. diff --git a/bsp/modules/fbtft/Makefile b/bsp/modules/fbtft/Makefile new file mode 100644 index 0000000000..13ebbc54b8 --- /dev/null +++ b/bsp/modules/fbtft/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +# Core module +obj-$(CONFIG_AVA_FB_TFT) += fbtft.o +fbtft-y += fbtft-core.o fbtft-sysfs.o fbtft-bus.o fbtft-io.o + +# drivers +obj-$(CONFIG_AVA_FB_TFT_ST7789V) += fb_st7789v.o diff --git a/bsp/modules/fbtft/README b/bsp/modules/fbtft/README new file mode 100644 index 0000000000..ba4c74c92e --- /dev/null +++ b/bsp/modules/fbtft/README @@ -0,0 +1,32 @@ + FBTFT +========= + +Linux Framebuffer drivers for small TFT LCD display modules. +The module 'fbtft' makes writing drivers for some of these displays very easy. + +Development is done on a Raspberry Pi running the Raspbian "wheezy" distribution. + +INSTALLATION + Download kernel sources + + From Linux 3.15 + cd drivers/video/fbdev/fbtft + git clone https://github.com/notro/fbtft.git + + Add to drivers/video/fbdev/Kconfig: source "drivers/video/fbdev/fbtft/Kconfig" + Add to drivers/video/fbdev/Makefile: obj-y += fbtft/ + + Before Linux 3.15 + cd drivers/video + git clone https://github.com/notro/fbtft.git + + Add to drivers/video/Kconfig: source "drivers/video/fbtft/Kconfig" + Add to drivers/video/Makefile: obj-y += fbtft/ + + Enable driver(s) in menuconfig and build the kernel + + +See wiki for more information: https://github.com/notro/fbtft/wiki + + +Source: https://github.com/notro/fbtft/ diff --git a/bsp/modules/fbtft/TODO b/bsp/modules/fbtft/TODO new file mode 100644 index 0000000000..e72a08bf22 --- /dev/null +++ b/bsp/modules/fbtft/TODO @@ -0,0 +1,3 @@ +* convert all these over to drm_simple_display_pipe and submit for inclusion + into the DRM subsystem under drivers/gpu/drm - fbdev doesn't take any new + drivers anymore. diff --git a/bsp/modules/fbtft/fb_st7789v.c b/bsp/modules/fbtft/fb_st7789v.c new file mode 100644 index 0000000000..1e7a704bd2 --- /dev/null +++ b/bsp/modules/fbtft/fb_st7789v.c @@ -0,0 +1,336 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * FB driver for the ST7789V LCD Controller + * + * Copyright (C) 2015 Dennis Menschel + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include