-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
st7735s: add (step 1) simple module for spi and dts
Signed-off-by: Andrey Pahomov <[email protected]>
- Loading branch information
1 parent
f956c4c
commit a731247
Showing
4 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [email protected] | ||
#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 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* st7735s.c - Display driver | ||
* | ||
* Copyright (C) 2020 Andrey Pahomov <[email protected]> | ||
*/ | ||
#include <linux/init.h> | ||
#include <linux/module.h> | ||
#include <linux/device.h> | ||
#include <linux/err.h> | ||
#include <linux/spi/spi.h> | ||
|
||
|
||
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 <[email protected]>"); | ||
MODULE_DESCRIPTION("st7735s SPI display"); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_VERSION("0.1"); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* sun8i-h3-st7735s.dts - Display driver | ||
* | ||
* Copyright (C) 2020 Andrey Pahomov <[email protected]> | ||
*/ | ||
/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"; | ||
}; | ||
|
||
}; | ||
}; | ||
}; | ||
|