From a731247ad0fa7113db05d3b67123eac94455a61f Mon Sep 17 00:00:00 2001 From: Andrey Pahomov Date: Fri, 17 Jan 2020 02:53:22 +0200 Subject: [PATCH] st7735s: add (step 1) simple module for spi and dts Signed-off-by: Andrey Pahomov --- st7735s/Makefile | 43 ++++++++++++++++++++ st7735s/env.sh | 12 ++++++ st7735s/st7735s.c | 79 ++++++++++++++++++++++++++++++++++++ st7735s/sun8i-h3-st7735s.dts | 36 ++++++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 st7735s/Makefile create mode 100755 st7735s/env.sh create mode 100644 st7735s/st7735s.c create mode 100644 st7735s/sun8i-h3-st7735s.dts diff --git a/st7735s/Makefile b/st7735s/Makefile new file mode 100644 index 0000000..7a56dea --- /dev/null +++ b/st7735s/Makefile @@ -0,0 +1,43 @@ +MODULE_NAME=st7735s + +ifneq ($(KERNELRELEASE),) + +obj-m :=$(MODULE_NAME).o + +else + +ccflags-y := -Wall +DT_SRCS=$(wildcard *.dts) +DT_OBJS=$(DT_SRCS:.dts=.dtbo) +DTC_FLAGS ?= -i $(DCT_EXTRA_PATH) + + +.PHONY: all clean + +all: $(DT_OBJS) + $(MAKE) -C $(BUILD_KERNEL) M=$(PWD) modules + +clean: + $(MAKE) -C $(BUILD_KERNEL) M=$(PWD) clean + -rm ./*.dtbo + + +$(DT_OBJS): $(DT_SRCS) + $(DTC) -@ -I dts -O dtb -o $@ $< + + +upload_config: + ssh-copy-id -i ~/.ssh/id_rsa.pub $(SSH_ORANGE) + echo $(KERNEL_VERSION) + -ssh $(SSH_ORANGE) '[ ! -d "/lib/modules/$(KERNEL_VERSION)/kernel/drivers/" ] && mkdir -p "/lib/modules/$(KERNEL_VERSION)/kernel/drivers/"' + +upload_dtso: $(DT_OBJS) + -scp $< $(SSH_ORANGE):/boot/dtb/overlay/ + +upload_module: $(MODULE_NAME).ko + -scp $< $(SSH_ORANGE):/lib/modules/$(KERNEL_VERSION)/kernel/drivers/ + -ssh $(SSH_ORANGE) 'depmod' + +upload: upload_dtso upload_module + +endif diff --git a/st7735s/env.sh b/st7735s/env.sh new file mode 100755 index 0000000..5c87bd9 --- /dev/null +++ b/st7735s/env.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export BUILD_KERNEL=$(pwd)/../../build/kernel_opi +export KERNEL_VERSION=5.4.0-rc1-00258-g2d00aee21a5d +export DTC=$BUILD_KERNEL/scripts/dtc/dtc +export CROSS_COMPILE=$(pwd)/../../toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- +export ARCH=arm +export SSH_ORANGE=root@192.168.1.105 +#export INCLUDE_DTS=/home/tymbys/WORK/GL/linux/arch/arm/boot/dts +export DCT_EXTRA_PATH=/home/tymbys/WORK/GL/linux/ + +make clean && make && make upload \ No newline at end of file diff --git a/st7735s/st7735s.c b/st7735s/st7735s.c new file mode 100644 index 0000000..12bf612 --- /dev/null +++ b/st7735s/st7735s.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * st7735s.c - Display driver + * + * Copyright (C) 2020 Andrey Pahomov + */ +#include +#include +#include +#include +#include + + +static int st7735s_probe(struct spi_device *spi) +{ + int ret; + + dev_info(&spi->dev, "%s:%d\n", __func__, __LINE__); + + spi->bits_per_word = 8; + spi->mode = SPI_MODE_0; + spi->max_speed_hz = 500000; + ret = spi_setup(spi); + if (ret < 0) + return ret; + + dev_info(&spi->dev, "%s:%d\n", __func__, __LINE__); + return 0; + +} + + +static int st7735s_remove(struct spi_device *spi) +{ + return 0; +} + + + +static const struct of_device_id of_tbl[] = { + {.compatible = "st7735s",}, + {}, +}; + +MODULE_DEVICE_TABLE(of, of_tbl); + +static struct spi_driver st7735s_driver = { + .driver = { + .name = "st7735s", + .of_match_table = of_tbl, + .owner = THIS_MODULE, + }, + + .probe = st7735s_probe, + .remove = st7735s_remove, +}; + + + + +static int st7735s_init(void) +{ + pr_info("%s:%d\n", __func__, __LINE__); + return spi_register_driver(&st7735s_driver); +} + +static void st7735s_exit(void) +{ + pr_info("%s:%d\n", __func__, __LINE__); + spi_unregister_driver(&st7735s_driver); +} + +module_init(st7735s_init); +module_exit(st7735s_exit); + +MODULE_AUTHOR("Andrey Pahomov "); +MODULE_DESCRIPTION("st7735s SPI display"); +MODULE_LICENSE("GPL"); +MODULE_VERSION("0.1"); diff --git a/st7735s/sun8i-h3-st7735s.dts b/st7735s/sun8i-h3-st7735s.dts new file mode 100644 index 0000000..28bacb8 --- /dev/null +++ b/st7735s/sun8i-h3-st7735s.dts @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * sun8i-h3-st7735s.dts - Display driver + * + * Copyright (C) 2020 Andrey Pahomov + */ +/dts-v1/; +/plugin/; + +/ { + compatible = "allwinner,sun8i-h3"; + + fragment@0 { + target-path = "/soc/spi@1c68000"; + __overlay__ { + status = "okay"; +/* + spidev@0 { + compatible = "spidev"; + spi-max-frequency = <10000000>; + reg = <0>; + status = "okay"; + }; +*/ + + st7735s { + compatible = "st7735s"; + spi-max-frequency = <10000000>; + reg = <0>; + status = "okay"; + }; + + }; + }; +}; +