commit 5144b762b471d67c360a3d0e57447ba3d30fce8a Author: Yu Xifeng Date: Tue Nov 19 11:37:38 2024 +0800 LubanCat driver初始源码 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01b16aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.*.cmd +*.mod* +*.o +*odule*.* +bin/ \ No newline at end of file diff --git a/EmbedCharDev/1_SupportMoreDev/1_SupportMoreDev.c b/EmbedCharDev/1_SupportMoreDev/1_SupportMoreDev.c new file mode 100644 index 0000000..899c6b7 --- /dev/null +++ b/EmbedCharDev/1_SupportMoreDev/1_SupportMoreDev.c @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include +#define DEV_NAME "EmbedCharDev" +#define DEV_CNT (2) +#define BUFF_SIZE 128 +//定义字符设备的设备号 +static dev_t devno; +//定义字符设备结构体chr_dev +static struct cdev chr_dev; +//数据缓冲区 +static char vbuf1[BUFF_SIZE]; +static char vbuf2[BUFF_SIZE]; +static int chr_dev_open(struct inode *inode, struct file *filp); +static int chr_dev_release(struct inode *inode, struct file *filp); +static ssize_t chr_dev_write(struct file *filp, const char __user * buf, size_t count, loff_t *ppos); +static ssize_t chr_dev_read(struct file *filp, char __user * buf, size_t count, loff_t *ppos); +static struct file_operations chr_dev_fops = +{ + .owner = THIS_MODULE, + .open = chr_dev_open, + .release = chr_dev_release, + .write = chr_dev_write, + .read = chr_dev_read, +}; + +static int chr_dev_open(struct inode *inode, struct file *filp) +{ + printk("\nopen\n "); + switch(MINOR(inode->i_rdev)) + { + case 0 : + { + filp->private_data = vbuf1; + break; + } + case 1 : + { + filp->private_data = vbuf2; + break; + } + } + return 0; +} + +static int chr_dev_release(struct inode *inode, struct file *filp) +{ + printk("\nrelease\n"); + return 0; +} + +static ssize_t chr_dev_write(struct file *filp, const char __user * buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + int ret; + char *vbuf = filp->private_data; + int tmp = count ; + if(p > BUFF_SIZE) + return 0; + if(tmp > BUFF_SIZE - p) + tmp = BUFF_SIZE - p; + ret = copy_from_user(vbuf, buf, tmp); + *ppos += tmp; + return tmp; +} + +static ssize_t chr_dev_read(struct file *filp, char __user * buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + int ret; + int tmp = count ; + char *vbuf = filp->private_data; + if(p >= BUFF_SIZE) + return 0; + if(tmp > BUFF_SIZE - p) + tmp = BUFF_SIZE - p; + ret = copy_to_user(buf, vbuf+p, tmp); + *ppos +=tmp; + return tmp; +} + +static int __init chrdev_init(void) +{ + int ret = 0; + printk("chrdev init\n"); + //第一步 + //采用动态分配的方式,获取设备编号,次设备号为0, + //设备名称为EmbedCharDev,可通过命令cat /proc/devices查看 + //DEV_CNT为1,当前只申请一个设备编号 + ret = alloc_chrdev_region(&devno, 0, DEV_CNT, DEV_NAME); + if(ret < 0){ + printk("fail to alloc devno\n"); + goto alloc_err; + } + //第二步 + //关联字符设备结构体cdev与文件操作结构体file_operations + cdev_init(&chr_dev, &chr_dev_fops); + //第三步 + //添加设备至cdev_map散列表中 + ret = cdev_add(&chr_dev, devno, DEV_CNT); + if(ret < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + return 0; + +add_err: + //添加设备失败时,需要注销设备号 + unregister_chrdev_region(devno, DEV_CNT); +alloc_err: + return ret; +} +module_init(chrdev_init); + +static void __exit chrdev_exit(void) +{ + printk("chrdev exit\n"); + unregister_chrdev_region(devno, DEV_CNT); + + cdev_del(&chr_dev); +} +module_exit(chrdev_exit); + +MODULE_LICENSE("GPL"); + diff --git a/EmbedCharDev/1_SupportMoreDev/Makefile b/EmbedCharDev/1_SupportMoreDev/Makefile new file mode 100644 index 0000000..905158e --- /dev/null +++ b/EmbedCharDev/1_SupportMoreDev/Makefile @@ -0,0 +1,14 @@ +KERNEL_DIR=../../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := 1_SupportMoreDev.o + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean diff --git a/EmbedCharDev/2_SupportMoreDev/2_SupportMoreDev.c b/EmbedCharDev/2_SupportMoreDev/2_SupportMoreDev.c new file mode 100644 index 0000000..1625464 --- /dev/null +++ b/EmbedCharDev/2_SupportMoreDev/2_SupportMoreDev.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include + +#define DEV_NAME "EmbedCharDev" +#define DEV_CNT (2) +#define BUFF_SIZE 128 +//定义字符设备的设备号 +static dev_t devno; + +//虚拟字符设备 +struct chr_dev{ + struct cdev dev; + char vbuf[BUFF_SIZE]; +}; +//字符设备1 +static struct chr_dev vcdev1; +//字符设备2 +static struct chr_dev vcdev2; + +static int chr_dev_open(struct inode *inode, struct file *filp); +static int chr_dev_release(struct inode *inode, struct file *filp); +static ssize_t chr_dev_write(struct file *filp, const char __user * buf, size_t count, loff_t *ppos); +static ssize_t chr_dev_read(struct file *filp, char __user * buf, size_t count, loff_t *ppos); + +static struct file_operations chr_dev_fops = { + .owner = THIS_MODULE, + .open = chr_dev_open, + .release = chr_dev_release, + .write = chr_dev_write, + .read = chr_dev_read, +}; +static int chr_dev_open(struct inode *inode, struct file *filp) +{ + printk("open\n"); + filp->private_data = container_of(inode->i_cdev, struct chr_dev, dev); + return 0; +} + +static int chr_dev_release(struct inode *inode, struct file *filp) +{ + printk("\nrelease\n"); + return 0; +} + +static ssize_t chr_dev_write(struct file *filp, const char __user * buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + int ret; + //获取文件的私有数据 + struct chr_dev *dev = filp->private_data; + char *vbuf = dev->vbuf; + + int tmp = count ; + if(p > BUFF_SIZE) + return 0; + if(tmp > BUFF_SIZE - p) + tmp = BUFF_SIZE - p; + ret = copy_from_user(vbuf, buf, tmp); + *ppos += tmp; + return tmp; +} + +static ssize_t chr_dev_read(struct file *filp, char __user * buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + int ret; + int tmp = count ; + //获取文件的私有数据 + struct chr_dev *dev = filp->private_data; + char *vbuf = dev->vbuf; + if(p >= BUFF_SIZE) + return 0; + if(tmp > BUFF_SIZE - p) + tmp = BUFF_SIZE - p; + ret = copy_to_user(buf, vbuf+p, tmp); + *ppos +=tmp; + return tmp; +} + + +static int __init chrdev_init(void) +{ + int ret; + printk("chrdev init\n"); + ret = alloc_chrdev_region(&devno, 0, DEV_CNT, DEV_NAME); + if(ret < 0) + goto alloc_err; + + //关联第一个设备:vdev1 + cdev_init(&vcdev1.dev, &chr_dev_fops); + ret = cdev_add(&vcdev1.dev, devno+0, 1); + if(ret < 0){ + printk("fail to add vcdev1 "); + goto add_err1; + } + //关联第二个设备:vdev2 + cdev_init(&vcdev2.dev, &chr_dev_fops); + ret = cdev_add(&vcdev2.dev, devno+1, 1); + if(ret < 0){ + printk("fail to add vcdev2 "); + goto add_err2; + } + return 0; +add_err2: + cdev_del(&(vcdev1.dev)); +add_err1: + unregister_chrdev_region(devno, DEV_CNT); +alloc_err: + return ret; + +} + +module_init(chrdev_init); + + + +static void __exit chrdev_exit(void) +{ + printk("chrdev exit\n"); + unregister_chrdev_region(devno, DEV_CNT); + cdev_del(&(vcdev1.dev)); + cdev_del(&(vcdev2.dev)); +} +module_exit(chrdev_exit); + + +MODULE_LICENSE("GPL"); diff --git a/EmbedCharDev/2_SupportMoreDev/Makefile b/EmbedCharDev/2_SupportMoreDev/Makefile new file mode 100644 index 0000000..0d1fd3a --- /dev/null +++ b/EmbedCharDev/2_SupportMoreDev/Makefile @@ -0,0 +1,14 @@ +KERNEL_DIR=../../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := 2_SupportMoreDev.o + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean diff --git a/EmbedCharDev/CharDev/Makefile b/EmbedCharDev/CharDev/Makefile new file mode 100644 index 0000000..c1ca3e7 --- /dev/null +++ b/EmbedCharDev/CharDev/Makefile @@ -0,0 +1,17 @@ +KERNEL_DIR=../../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := chrdev.o +out = chrdev_test + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + $(CROSS_COMPILE)gcc -o $(out) main.c + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + rm $(out) diff --git a/EmbedCharDev/CharDev/chrdev.c b/EmbedCharDev/CharDev/chrdev.c new file mode 100644 index 0000000..b633d11 --- /dev/null +++ b/EmbedCharDev/CharDev/chrdev.c @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include +#define DEV_NAME "EmbedCharDev" +#define DEV_CNT (1) +#define BUFF_SIZE 128 +//定义字符设备的设备号 +static dev_t devno; +//定义字符设备结构体chr_dev +static struct cdev chr_dev; +//数据缓冲区 +static char vbuf[BUFF_SIZE]; +static int chr_dev_open(struct inode *inode, struct file *filp); +static int chr_dev_release(struct inode *inode, struct file *filp); +static ssize_t chr_dev_write(struct file *filp, const char __user * buf, size_t count, loff_t *ppos); +static ssize_t chr_dev_read(struct file *filp, char __user * buf, size_t count, loff_t *ppos); +static struct file_operations chr_dev_fops = +{ + .owner = THIS_MODULE, + .open = chr_dev_open, + .release = chr_dev_release, + .write = chr_dev_write, + .read = chr_dev_read, +}; + +static int chr_dev_open(struct inode *inode, struct file *filp) +{ + printk("\nopen\n"); + return 0; +} + +static int chr_dev_release(struct inode *inode, struct file *filp) +{ + printk("\nrelease\n"); + return 0; +} + +static ssize_t chr_dev_write(struct file *filp, const char __user * buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + int ret; + int tmp = count ; + if(p > BUFF_SIZE) + return 0; + if(tmp > BUFF_SIZE - p) + tmp = BUFF_SIZE - p; + ret = copy_from_user(vbuf, buf, tmp); + *ppos += tmp; + return tmp; +} + +static ssize_t chr_dev_read(struct file *filp, char __user * buf, size_t count, loff_t *ppos) +{ + unsigned long p = *ppos; + int ret; + int tmp = count ; + if(p >= BUFF_SIZE) + return 0; + if(tmp > BUFF_SIZE - p) + tmp = BUFF_SIZE - p; + ret = copy_to_user(buf, vbuf+p, tmp); + *ppos +=tmp; + return tmp; +} + +static int __init chrdev_init(void) +{ + int ret = 0; + printk("chrdev init\n"); + //第一步 + //采用动态分配的方式,获取设备编号,次设备号为0, + //设备名称为EmbedCharDev,可通过命令cat /proc/devices查看 + //DEV_CNT为1,当前只申请一个设备编号 + ret = alloc_chrdev_region(&devno, 0, DEV_CNT, DEV_NAME); + if(ret < 0){ + printk("fail to alloc devno\n"); + goto alloc_err; + } + //第二步 + //关联字符设备结构体cdev与文件操作结构体file_operations + cdev_init(&chr_dev, &chr_dev_fops); + //第三步 + //添加设备至cdev_map散列表中 + ret = cdev_add(&chr_dev, devno, DEV_CNT); + if(ret < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + return 0; + +add_err: + //添加设备失败时,需要注销设备号 + unregister_chrdev_region(devno, DEV_CNT); +alloc_err: + return ret; +} +module_init(chrdev_init); + +static void __exit chrdev_exit(void) +{ + printk("chrdev exit\n"); + unregister_chrdev_region(devno, DEV_CNT); + + cdev_del(&chr_dev); +} +module_exit(chrdev_exit); + +MODULE_LICENSE("GPL"); + diff --git a/EmbedCharDev/CharDev/main.c b/EmbedCharDev/CharDev/main.c new file mode 100644 index 0000000..78a5996 --- /dev/null +++ b/EmbedCharDev/CharDev/main.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include +char *wbuf = "Hello World\n"; +char rbuf[128]; +int main(void) +{ + printf("EmbedCharDev test\n"); + //打开文件 + int fd = open("/dev/chrdev", O_RDWR); + //写入数据 + write(fd, wbuf, strlen(wbuf)); + //写入完毕,关闭文件 + close(fd); + //打开文件 + fd = open("/dev/chrdev", O_RDWR); + //读取文件内容 + read(fd, rbuf, 128); + //打印读取的内容 + printf("The content : %s \n", rbuf); + //读取完毕,关闭文件 + close(fd); + return 0; +} diff --git a/I2c_MPU6050/Makefile b/I2c_MPU6050/Makefile new file mode 100644 index 0000000..d0d9e59 --- /dev/null +++ b/I2c_MPU6050/Makefile @@ -0,0 +1,18 @@ +KERNEL_DIR=../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := i2c_mpu6050.o + +out = 6050_test_app + +all: + $(MAKE) EXTRA_CFLAGS=-fno-pic -C $(KERNEL_DIR) M=$(CURDIR) modules + $(CROSS_COMPILE)gcc -o $(out) test_app.c + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + rm $(out) diff --git a/I2c_MPU6050/i2c_mpu6050.c b/I2c_MPU6050/i2c_mpu6050.c new file mode 100644 index 0000000..0d091eb --- /dev/null +++ b/I2c_MPU6050/i2c_mpu6050.c @@ -0,0 +1,313 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "i2c_mpu6050.h" + +/*------------------字符设备内容----------------------*/ +#define DEV_NAME "I2C1_mpu6050" +#define DEV_CNT (1) + +/*定义 led 资源结构体,保存获取得到的节点信息以及转换后的虚拟寄存器地址*/ +static dev_t mpu6050_devno; //定义字符设备的设备号 +static struct cdev mpu6050_chr_dev; //定义字符设备结构体chr_dev +struct class *class_mpu6050; //保存创建的类 +struct device *device_mpu6050; // 保存创建的设备 +struct device_node *mpu6050_device_node; //rgb_led的设备树节点结构体 + +/*------------------IIC设备内容----------------------*/ +struct i2c_client *mpu6050_client = NULL; //保存mpu6050设备对应的i2c_client结构体,匹配成功后由.prob函数带回。 + +/*通过i2c 向mpu6050写入数据 +*mpu6050_client:mpu6050的i2c_client结构体。 +*address, 数据要写入的地址, +*data, 要写入的数据 +*返回值,错误,-1。成功,0 +*/ +static int i2c_write_mpu6050(struct i2c_client *mpu6050_client, u8 address, u8 data) +{ + int error = 0; + u8 write_data[2]; + struct i2c_msg send_msg; //要发送的数据结构体 + + /*设置要发送的数据*/ + write_data[0] = address; + write_data[1] = data; + + /*发送 iic要写入的地址 reg*/ + send_msg.addr = mpu6050_client->addr; //mpu6050在 iic 总线上的地址 + send_msg.flags = 0; //标记为发送数据 + send_msg.buf = write_data; //写入的首地址 + send_msg.len = 2; //reg长度 + + /*执行发送*/ + error = i2c_transfer(mpu6050_client->adapter, &send_msg, 1); + if (error != 1) + { + printk(KERN_DEBUG "\n i2c_transfer error \n"); + return -1; + } + return 0; +} + +/*通过i2c 向mpu6050写入数据 +*mpu6050_client:mpu6050的i2c_client结构体。 +*address, 要读取的地址, +*data,保存读取得到的数据 +*length,读长度 +*返回值,错误,-1。成功,0 +*/ +static int i2c_read_mpu6050(struct i2c_client *mpu6050_client, u8 address, void *data, u32 length) +{ + int error = 0; + u8 address_data = address; + struct i2c_msg mpu6050_msg[2]; + /*设置读取位置msg*/ + mpu6050_msg[0].addr = mpu6050_client->addr; //mpu6050在 iic 总线上的地址 + mpu6050_msg[0].flags = 0; //标记为发送数据 + mpu6050_msg[0].buf = &address_data; //写入的首地址 + mpu6050_msg[0].len = 1; //写入长度 + + /*设置读取位置msg*/ + mpu6050_msg[1].addr = mpu6050_client->addr; //mpu6050在 iic 总线上的地址 + mpu6050_msg[1].flags = I2C_M_RD; //标记为读取数据 + mpu6050_msg[1].buf = data; //读取得到的数据保存位置 + mpu6050_msg[1].len = length; //读取长度 + + error = i2c_transfer(mpu6050_client->adapter, mpu6050_msg, 2); + + if (error != 2) + { + printk(KERN_DEBUG "\n i2c_read_mpu6050 error \n"); + return -1; + } + return 0; +} + +/*初始化i2c +*返回值,成功,返回0。失败,返回 -1 +*/ +static int mpu6050_init(void) +{ + int error = 0; + /*配置mpu6050*/ + error += i2c_write_mpu6050(mpu6050_client, PWR_MGMT_1, 0X00); + error += i2c_write_mpu6050(mpu6050_client, SMPLRT_DIV, 0X07); + error += i2c_write_mpu6050(mpu6050_client, CONFIG, 0X06); + error += i2c_write_mpu6050(mpu6050_client, ACCEL_CONFIG, 0X01); + + if (error < 0) + { + /*初始化错误*/ + printk(KERN_DEBUG "\n mpu6050_init error \n"); + return -1; + } + return 0; +} + +/*字符设备操作函数集,open函数实现*/ +static int mpu6050_open(struct inode *inode, struct file *filp) +{ + // printk("\n mpu6050_open \n"); + + /*向 mpu6050 发送配置数据,让mpu6050处于正常工作状态*/ + mpu6050_init(); + return 0; +} + +/*字符设备操作函数集,.read函数实现*/ +static ssize_t mpu6050_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off) +{ + char data_H; + char data_L; + int error; + short mpu6050_result[6]; //保存mpu6050转换得到的原始数据 + + // printk("\n mpu6050_read \n"); + + i2c_read_mpu6050(mpu6050_client, ACCEL_XOUT_H, &data_H, 1); + i2c_read_mpu6050(mpu6050_client, ACCEL_XOUT_L, &data_L, 1); + mpu6050_result[0] = data_H << 8; + mpu6050_result[0] += data_L; + + i2c_read_mpu6050(mpu6050_client, ACCEL_YOUT_H, &data_H, 1); + i2c_read_mpu6050(mpu6050_client, ACCEL_YOUT_L, &data_L, 1); + mpu6050_result[1] = data_H << 8; + mpu6050_result[1] += data_L; + + i2c_read_mpu6050(mpu6050_client, ACCEL_ZOUT_H, &data_H, 1); + i2c_read_mpu6050(mpu6050_client, ACCEL_ZOUT_L, &data_L, 1); + mpu6050_result[2] = data_H << 8; + mpu6050_result[2] += data_L; + + i2c_read_mpu6050(mpu6050_client, GYRO_XOUT_H, &data_H, 1); + i2c_read_mpu6050(mpu6050_client, GYRO_XOUT_L, &data_L, 1); + mpu6050_result[3] = data_H << 8; + mpu6050_result[3] += data_L; + + i2c_read_mpu6050(mpu6050_client, GYRO_YOUT_H, &data_H, 1); + i2c_read_mpu6050(mpu6050_client, GYRO_YOUT_L, &data_L, 1); + mpu6050_result[4] = data_H << 8; + mpu6050_result[4] += data_L; + + i2c_read_mpu6050(mpu6050_client, GYRO_ZOUT_H, &data_H, 1); + i2c_read_mpu6050(mpu6050_client, GYRO_ZOUT_L, &data_L, 1); + mpu6050_result[5] = data_H << 8; + mpu6050_result[5] += data_L; + + + // printk("AX=%d, AY=%d, AZ=%d \n",(int)mpu6050_result[0],(int)mpu6050_result[1],(int)mpu6050_result[2]); + // printk("GX=%d, GY=%d, GZ=%d \n \n",(int)mpu6050_result[3],(int)mpu6050_result[4],(int)mpu6050_result[5]); + + /*将读取得到的数据拷贝到用户空间*/ + error = copy_to_user(buf, mpu6050_result, cnt); + + if(error != 0) + { + printk("copy_to_user error!"); + return -1; + } + return 0; +} + +/*字符设备操作函数集,.release函数实现*/ +static int mpu6050_release(struct inode *inode, struct file *filp) +{ + // printk("\n mpu6050_release \n"); + + /*向mpu6050发送命令,使mpu6050进入关机状态*/ + return 0; +} + +/*字符设备操作函数集*/ +static struct file_operations mpu6050_chr_dev_fops = + { + .owner = THIS_MODULE, + .open = mpu6050_open, + .read = mpu6050_read, + .release = mpu6050_release, +}; + +/*----------------平台驱动函数集-----------------*/ +static int mpu6050_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + + int ret = -1; //保存错误状态码 + + printk(KERN_EMERG "\t match successed \n"); + /*---------------------注册 字符设备部分-----------------*/ + + //采用动态分配的方式,获取设备编号,次设备号为0, + //设备名称为rgb-leds,可通过命令cat /proc/devices查看 + //DEV_CNT为1,当前只申请一个设备编号 + ret = alloc_chrdev_region(&mpu6050_devno, 0, DEV_CNT, DEV_NAME); + if (ret < 0) + { + printk("fail to alloc mpu6050_devno\n"); + goto alloc_err; + } + + //关联字符设备结构体cdev与文件操作结构体file_operations + mpu6050_chr_dev.owner = THIS_MODULE; + cdev_init(&mpu6050_chr_dev, &mpu6050_chr_dev_fops); + + // 添加设备至cdev_map散列表中 + ret = cdev_add(&mpu6050_chr_dev, mpu6050_devno, DEV_CNT); + if (ret < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + + /*创建类 */ + class_mpu6050 = class_create(THIS_MODULE, DEV_NAME); + + /*创建设备 DEV_NAME 指定设备名,*/ + device_mpu6050 = device_create(class_mpu6050, NULL, mpu6050_devno, NULL, DEV_NAME); + mpu6050_client = client; + return 0; + +add_err: + // 添加设备失败时,需要注销设备号 + unregister_chrdev_region(mpu6050_devno, DEV_CNT); + printk("\n error! \n"); +alloc_err: + + return -1; +} + + +static int mpu6050_remove(struct i2c_client *client) +{ + /*删除设备*/ + device_destroy(class_mpu6050, mpu6050_devno); //清除设备 + class_destroy(class_mpu6050); //清除类 + cdev_del(&mpu6050_chr_dev); //清除设备号 + unregister_chrdev_region(mpu6050_devno, DEV_CNT); //取消注册字符设备 + return 0; +} + + + +/*定义ID 匹配表*/ +static const struct i2c_device_id gtp_device_id[] = { + {"fire,i2c_mpu6050", 0}, + {}}; + +/*定义设备树匹配表*/ +static const struct of_device_id mpu6050_of_match_table[] = { + {.compatible = "fire,i2c_mpu6050"}, + {/* sentinel */}}; + +/*定义i2c总线设备结构体*/ +struct i2c_driver mpu6050_driver = { + .probe = mpu6050_probe, + .remove = mpu6050_remove, + .id_table = gtp_device_id, + .driver = { + .name = "fire,i2c_mpu6050", + .owner = THIS_MODULE, + .of_match_table = mpu6050_of_match_table, + }, +}; + +/* +*驱动初始化函数 +*/ +static int __init mpu6050_driver_init(void) +{ + int ret; + pr_info("mpu6050_driver_init\n"); + ret = i2c_add_driver(&mpu6050_driver); + return ret; +} + +/* +*驱动注销函数 +*/ +static void __exit mpu6050_driver_exit(void) +{ + pr_info("mpu6050_driver_exit\n"); + i2c_del_driver(&mpu6050_driver); +} + +module_init(mpu6050_driver_init); +module_exit(mpu6050_driver_exit); + +MODULE_LICENSE("GPL"); diff --git a/I2c_MPU6050/i2c_mpu6050.h b/I2c_MPU6050/i2c_mpu6050.h new file mode 100644 index 0000000..f8f5d75 --- /dev/null +++ b/I2c_MPU6050/i2c_mpu6050.h @@ -0,0 +1,35 @@ + +#ifndef I2C_MPU6050_H +#define I2C_MPU6050_H + + +//宏定义 +#define SMPLRT_DIV 0x19 +#define CONFIG 0x1A +#define GYRO_CONFIG 0x1B +#define ACCEL_CONFIG 0x1C +#define ACCEL_XOUT_H 0x3B +#define ACCEL_XOUT_L 0x3C +#define ACCEL_YOUT_H 0x3D +#define ACCEL_YOUT_L 0x3E +#define ACCEL_ZOUT_H 0x3F +#define ACCEL_ZOUT_L 0x40 +#define TEMP_OUT_H 0x41 +#define TEMP_OUT_L 0x42 +#define GYRO_XOUT_H 0x43 +#define GYRO_XOUT_L 0x44 +#define GYRO_YOUT_H 0x45 +#define GYRO_YOUT_L 0x46 +#define GYRO_ZOUT_H 0x47 +#define GYRO_ZOUT_L 0x48 +#define PWR_MGMT_1 0x6B +#define WHO_AM_I 0x75 +#define SlaveAddress 0xD0 +#define Address 0x68 //MPU6050地址 +#define I2C_RETRIES 0x0701 +#define I2C_TIMEOUT 0x0702 +#define I2C_SLAVE 0x0703 //IIC从器件的地址设置 +#define I2C_BUS_MODE 0x0780 + + +#endif \ No newline at end of file diff --git a/I2c_MPU6050/test_app.c b/I2c_MPU6050/test_app.c new file mode 100644 index 0000000..790a388 --- /dev/null +++ b/I2c_MPU6050/test_app.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +int main(int argc, char *argv[]) +{ + + short resive_data[6]; //保存收到的 mpu6050转换结果数据,依次为 AX(x轴角度), AY, AZ 。GX(x轴加速度), GY ,GZ + + /*打开文件*/ + int fd = open("/dev/I2C1_mpu6050", O_RDWR); + if(fd < 0) + { + printf("open file : %s failed !\n", argv[0]); + return -1; + } + + /*读取数据*/ + int error = read(fd,resive_data,12); + if(error < 0) + { + printf("write file error! \n"); + close(fd); + /*判断是否关闭成功*/ + } + + /*打印数据*/ + printf("AX=%d, AY=%d, AZ=%d ",(int)resive_data[0],(int)resive_data[1],(int)resive_data[2]); + printf(" GX=%d, GY=%d, GZ=%d \n \n",(int)resive_data[3],(int)resive_data[4],(int)resive_data[5]); + + + /*关闭文件*/ + error = close(fd); + if(error < 0) + { + printf("close file error! \n"); + } + + return 0; +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d1b1ab --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# LubanCat_RK系列驱动教程配套例程 + +## 使用 + +把该例程linux_driver放到内核源码的同级目录下: + +. + +├── kernel + +└── linux_driver + +linux_driver中内核模块makefile的KERNEL_DIR都是指向kernel/build。 + +## 环境 + +PC系统:ubuntu18.04 + +板卡系统:ubuntu20.04 + +## 配套教程 + +**《 嵌入式Linux驱动开发实战指南——基于LubanCat_RK系列板卡 》** + diff --git a/SPI_OLED/Makefile b/SPI_OLED/Makefile new file mode 100644 index 0000000..a2f513c --- /dev/null +++ b/SPI_OLED/Makefile @@ -0,0 +1,15 @@ +KERNEL_DIR=../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := spi_oled.o + + +all: + $(MAKE) EXTRA_CFLAGS=-fno-pic -C $(KERNEL_DIR) M=$(CURDIR) modules + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean diff --git a/SPI_OLED/lubancat-spi3-m1-oled-overlay.dts b/SPI_OLED/lubancat-spi3-m1-oled-overlay.dts new file mode 100644 index 0000000..744a99f --- /dev/null +++ b/SPI_OLED/lubancat-spi3-m1-oled-overlay.dts @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 - All Rights Reserved by + * EmbedFire LubanCat + */ +/dts-v1/; +/plugin/; + +#include +#include +#include +#include + +&spi3{ + status = "okay"; + pinctrl-names = "default", "high_speed"; + pinctrl-0 = <&spi3m1_cs0 &spi3m1_pins>; + pinctrl-1 = <&spi3m1_cs0 &spi3m1_pins_hs>; + cs-gpios = <&gpio4 RK_PC6 GPIO_ACTIVE_LOW>; + + spi_oled@0 { + compatible = "fire,spi_oled"; + reg = <0>; //chip select 0:cs0 1:cs1 + spi-max-frequency = <24000000>; //spi output clock + dc_control_pin = <&gpio3 RK_PA7 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&spi_oled_pin>; + }; +}; + +&pinctrl { + spi_oled { + spi_oled_pin: spi_oled_pin { + rockchip,pins = <3 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; \ No newline at end of file diff --git a/SPI_OLED/spi_oled.c b/SPI_OLED/spi_oled.c new file mode 100644 index 0000000..901fec4 --- /dev/null +++ b/SPI_OLED/spi_oled.c @@ -0,0 +1,416 @@ +/* + * Copyright (C) 2022 - All Rights Reserved by + * EmbedFire LubanCat + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "spi_oled.h" + +/*------------------字符设备内容----------------------*/ +#define DEV_NAME "spi_oled" +#define DEV_CNT (1) + +static dev_t oled_devno; //定义字符设备的设备号 +static struct cdev oled_chr_dev; //定义字符设备结构体chr_dev +struct class *class_oled; //保存创建的类 +struct device *device_oled; // 保存创建的设备 + +/*------------------IIC设备内容----------------------*/ +struct spi_device *oled_spi_device; //保存oled设备对应的spi_device结构体,匹配成功后由.prob函数带回。 +struct device_node *oled_device_node; //spi_oled的设备树节点结构体 +int oled_control_pin_number; // 保存oled D/C控制引脚的引脚号(从对应设备树节点中获取) +u8 oled_init_data[] = { + 0xae, 0xae, 0x00, 0x10, 0x40, + 0x81, 0xcf, 0xa1, 0xc8, 0xa6, + 0xa8, 0x3f, 0xd3, 0x00, 0xd5, + 0x80, 0xd9, 0xf1, 0xda, 0x12, + 0xdb, 0x40, 0x20, 0x02, 0x8d, + 0x14, 0xa4, 0xa6, 0xaf}; + +/* +*函数功能:向oled发送一个命令 +*spi_device oled设备驱动对应的spi_device结构体。 +*command 要发送的数据。 +*返回值:成功,返回0 失败返回负数。 +*/ +static int oled_send_command(struct spi_device *spi_device, u8 command) +{ + int error = 0; + u8 tx_data = command; + struct spi_message message; //定义发送的消息 + struct spi_transfer *transfer; //定义传输结构体 + + /*设置 D/C引脚为低电平*/ + gpio_direction_output(oled_control_pin_number, 0); + + /*申请空间*/ + transfer = kzalloc(sizeof(struct spi_transfer), GFP_KERNEL); + + /*填充message和transfer结构体*/ + transfer->tx_buf = &tx_data; + transfer->len = 1; + spi_message_init(&message); + spi_message_add_tail(transfer, &message); + + error = spi_sync(spi_device, &message); + kfree(transfer); + if (error != 0) + { + printk("spi_sync error! \n"); + return -1; + } + gpio_direction_output(oled_control_pin_number, 1); + return 0; +} + + +/* +*函数功能:向oled发送一组命令 +*spi_device oled设备驱动对应的spi_device结构体。 +*commands 要发送的数据。 +*返回值:成功,返回0 失败返回负数。 +*/ +static int oled_send_commands(struct spi_device *spi_device, u8 *commands, u16 lenght) +{ + int error = 0; + int index ; + + for(index = 0; index < lenght; index++) + { + error = oled_send_command(spi_device, *(commands++)); + if(error < 0) + return -1; + } + + return 0; +} + +/* +*向 oled 发送一个字节 +*spi_device,指定oled 设备驱动的spi 结构体 +*data, 要发送数据 +*/ +static int oled_send_one_u8(struct spi_device *spi_device, u8 data) +{ + int error = 0; + u8 tx_data = data; + struct spi_message message; //定义发送的消息 + struct spi_transfer *transfer; //定义传输结构体 + + /*设置 D/C引脚为高电平*/ + gpio_direction_output(oled_control_pin_number, 1); + + /*申请空间*/ + transfer = kzalloc(sizeof(struct spi_transfer), GFP_KERNEL); + + /*填充message和transfer结构体*/ + transfer->tx_buf = &tx_data; + transfer->len = 1; + spi_message_init(&message); + spi_message_add_tail(transfer, &message); + + error = spi_sync(spi_device, &message); + kfree(transfer); + if (error != 0) + { + printk("spi_sync error! \n"); + return -1; + } + return 0; +} + + +/* +*向 oled 发送数据 +*spi_device,指定oled 设备驱动的spi 结构体 +*data, 要发送数据的地址 +*lenght,发送的数据长度 +*/ +static int oled_send_data(struct spi_device *spi_device, u8 *data, u16 lenght) +{ + int error = 0; + int index ; + + for(index = 0; index < lenght; index++) + { + error = oled_send_one_u8(spi_device, *(data++)); + if(error < 0) + return -1; + } + + return 0; +} + +/* +* 填充整个OLED 显示屏 +* bmp_dat, 填充的值 +*/ +void oled_fill(unsigned char bmp_dat) +{ + u8 y, x; + for (y = 0; y < 8; y++) + { + oled_send_command(oled_spi_device, 0xb0 + y); + oled_send_command(oled_spi_device, 0x01); + oled_send_command(oled_spi_device, 0x10); + for (x = 0; x < 128; x++) + { + oled_send_one_u8(oled_spi_device, bmp_dat); + } + } +} + + +/* +*向 oled 发送要显示的数据,x, y 指定显示的起始位置,支持自动换行 +*spi_device,指定oled 设备驱动的spi 结构体 +*display_buffer, 数据地址 +*x, y,起始坐标。 +*length, 发送长度 +*/ +static int oled_display_buffer(u8 *display_buffer, u8 x, u8 y, u16 length) +{ + u16 index = 0; + int error = 0; + + do + { + /*设置写入的起始坐标*/ + error += oled_send_command(oled_spi_device, 0xb0 + y); + error += oled_send_command(oled_spi_device, ((x & 0xf0) >> 4) | 0x10); + error += oled_send_command(oled_spi_device, (x & 0x0f) | 0x01); + + if (length > (X_WIDTH - x)) + { + error += oled_send_data(oled_spi_device, display_buffer + index, X_WIDTH - x); + length -= (X_WIDTH - x); + index += (X_WIDTH - x); + x = 0; + y++; + } + else + { + error += oled_send_data(oled_spi_device, display_buffer + index, length); + index += length; + // x += length; + length = 0; + } + + } while (length > 0); + + if (error != 0) + { + /*发送错误*/ + printk("oled_display_buffer error! %d \n",error); + return -1; + } + return index; +} + + +/*oled 初始化函数*/ +void spi_oled_init(void) +{ + /*初始化oled*/ + oled_send_commands(oled_spi_device, oled_init_data, sizeof(oled_init_data)); + + /*清屏*/ + oled_fill(0x00); +} + +/*字符设备操作函数集,open函数实现*/ +static int oled_open(struct inode *inode, struct file *filp) +{ + spi_oled_init(); //初始化显示屏 + return 0; +} + + +/*字符设备操作函数集,.write函数实现*/ +static ssize_t oled_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *off) +{ + int copy_number=0; + + /*申请内存*/ + oled_display_struct *write_data; + write_data = (oled_display_struct*)kzalloc(cnt, GFP_KERNEL); + + copy_number = copy_from_user(write_data, buf,cnt); + oled_display_buffer(write_data->display_buffer, write_data->x, write_data->y, write_data->length); + + /*释放内存*/ + kfree(write_data); + return 0; +} + + +/*字符设备操作函数集,.release函数实现*/ +static int oled_release(struct inode *inode, struct file *filp) +{ + oled_send_command(oled_spi_device, 0xae);//关闭显示 + return 0; +} + + +/*字符设备操作函数集*/ +static struct file_operations oled_chr_dev_fops = { + .owner = THIS_MODULE, + .open = oled_open, + .write = oled_write, + .release = oled_release}; + +/*----------------平台驱动函数集-----------------*/ +static int oled_probe(struct spi_device *spi) +{ + + struct device_node *node=spi->dev.of_node; + + printk(KERN_EMERG " match successed \n"); + + /*获取 oled 的 D/C 控制引脚并设置为输出,默认高电平*/ + oled_control_pin_number = of_get_named_gpio(node, "dc_control_pin", 0); + + printk("oled_control_pin_number = %d,\n ", oled_control_pin_number); + + gpio_request(oled_control_pin_number, "dc_control_pin"); + gpio_direction_output(oled_control_pin_number, 1); + + /*初始化spi*/ + oled_spi_device = spi; + oled_spi_device->mode = SPI_MODE_0; + oled_spi_device->max_speed_hz = 2000000; + spi_setup(oled_spi_device); + + /*打印oled_spi_device 部分内容*/ + printk("max_speed_hz = %d\n", oled_spi_device->max_speed_hz); + printk("chip_select = %d\n", (int)oled_spi_device->chip_select); + printk("bits_per_word = %d\n", (int)oled_spi_device->bits_per_word); + printk("mode = %02X\n", oled_spi_device->mode); + printk("cs_gpio = %02X\n", oled_spi_device->cs_gpio); + + return 0; + +} + +static int oled_remove(struct spi_device *spi) +{ + return 0; +} + +/*传统的方式指定 ID 匹配表*/ +static const struct spi_device_id oled_device_id[] = { + {"fire,spi_oled", 0}, + {}}; + +/*指定设备树匹配表*/ +static const struct of_device_id oled_of_match_table[] = { + {.compatible = "fire,spi_oled"}, + {}}; + +/*spi 总线设备结构体*/ +struct spi_driver oled_driver = { + .probe = oled_probe, + .remove = oled_remove, + .id_table = oled_device_id, + .driver = { + .name = "spi_oled", + .of_match_table = of_match_ptr(oled_of_match_table), + }, +}; + +/* +*驱动初始化函数 +*/ +static int __init oled_driver_init(void) +{ + int error; + int ret = -1; //保存错误状态码 + pr_info("oled_driver_init\n"); + + /*---------------------注册 字符设备部分-----------------*/ + + //采用动态分配的方式,获取设备编号,次设备号为0, + //设备名称spi_oled,可通过命令cat /proc/devices查看 + //DEV_CNT为1,当前只申请一个设备编号 + ret = alloc_chrdev_region(&oled_devno, 0, DEV_CNT, DEV_NAME); + if (ret < 0) + { + printk("fail to alloc oled_devno\n"); + goto alloc_err; + } + + //关联字符设备结构体cdev与文件操作结构体file_operations + oled_chr_dev.owner = THIS_MODULE; + cdev_init(&oled_chr_dev, &oled_chr_dev_fops); + + // 添加设备至cdev_map散列表中 + ret = cdev_add(&oled_chr_dev, oled_devno, DEV_CNT); + if (ret < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + + /*创建类 */ + class_oled = class_create(THIS_MODULE, DEV_NAME); + + /*创建设备 DEV_NAME 指定设备名,*/ + device_oled = device_create(class_oled, NULL, oled_devno, NULL, DEV_NAME); + + error = spi_register_driver(&oled_driver); + if (error < 0) { + device_destroy(class_oled, oled_devno); //清除设备 + class_destroy(class_oled); //清除类 + cdev_del(&oled_chr_dev); //清除设备号 + unregister_chrdev_region(oled_devno, DEV_CNT); //取消注册字符设备 + } + return error; + +add_err: + // 添加设备失败时,需要注销设备号 + unregister_chrdev_region(oled_devno, DEV_CNT); + printk(" error! \n"); +alloc_err: + + return -1; + +} + +/* +*驱动注销函数 +*/ +static void __exit oled_driver_exit(void) +{ + pr_info("oled_driver_exit\n"); + + spi_unregister_driver(&oled_driver); + gpio_free(oled_control_pin_number); + + /*删除设备*/ + device_destroy(class_oled, oled_devno); //清除设备 + class_destroy(class_oled); //清除类 + cdev_del(&oled_chr_dev); //清除设备号 + unregister_chrdev_region(oled_devno, DEV_CNT); //取消注册字符设备 +} + +module_init(oled_driver_init); +module_exit(oled_driver_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Embedfire"); diff --git a/SPI_OLED/spi_oled.h b/SPI_OLED/spi_oled.h new file mode 100644 index 0000000..6cdccc0 --- /dev/null +++ b/SPI_OLED/spi_oled.h @@ -0,0 +1,21 @@ +#ifndef ECSPI_OLED_H +#define ECSPI_OLED_H +#include + +//宏定义 +//oled显示屏列数 +#define X_WIDTH 128 +//oled显示屏行数 +#define Y_WIDTH 64 + + +/*数据发送结构体*/ +typedef struct oled_display_struct +{ + u8 x; + u8 y; + u32 length; + u8 display_buffer[]; +}oled_display_struct; + +#endif \ No newline at end of file diff --git a/SPI_OLED/test_app/makefile b/SPI_OLED/test_app/makefile new file mode 100644 index 0000000..baba378 --- /dev/null +++ b/SPI_OLED/test_app/makefile @@ -0,0 +1,11 @@ +out_file_name = "test_app" + +all: test_app.c oled_code_table.c + aarch64-linux-gnu-gcc $^ -o $(out_file_name) + + +.PHONY: clean +clean: + rm $(out_file_name) + + diff --git a/SPI_OLED/test_app/oled_code_table.c b/SPI_OLED/test_app/oled_code_table.c new file mode 100644 index 0000000..fcb51af --- /dev/null +++ b/SPI_OLED/test_app/oled_code_table.c @@ -0,0 +1,304 @@ +/** + ****************************************************************************** + + * @brief 128*64点阵的OLED显示测试工程,仅适用于SD1306驱动IIC通信方式显示屏 + ****************************************************************************** + * @attention * + * + * 1. 128*64点整OLED模块功能演示程序的字表,仅适用heltec.taobao.com所售产品; + * 2. 字表由打包资料中的"取字软件"计算得出; + * 3. 取字方式 -- 共阴、列行式、逆向输出 + * + * + ****************************************************************************** + */ + +extern unsigned char F16x16[]; +extern unsigned char F6x8[][6]; +extern unsigned char F8x16[][16]; +extern unsigned char BMP1[]; + +/***************************16*16的点阵字体取模方式:共阴——列行式——逆向输出*********/ +unsigned char F16x16[] = + +{ + + 0x00,0xFE,0x92,0x92,0xFE,0x92,0x92,0xFE,0x00,0x42,0x4A,0xD2,0x6A,0x46,0xC0,0x00, + 0x40,0xC4,0x44,0x44,0x3F,0x24,0x24,0x24,0x00,0x40,0x80,0x7F,0x00,0x01,0x00,0x00,/*"野",0*/ + + 0x00,0x00,0xC0,0x38,0x00,0x00,0x00,0xFF,0x00,0x00,0x40,0x20,0x18,0x00,0x00,0x00, + 0x80,0x81,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,/*"火",1*/ + + 0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00, + 0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,/*"科",2*/ + + 0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00, + 0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00/*"技",3*/ + +}; + + +/************************************6*8的点阵************************************/ +unsigned char F6x8[][6] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp + 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// ! + 0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// " + 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// # + 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $ + 0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// % + 0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// & + 0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// ' + 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// ( + 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// ) + 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// * + 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// + + 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// , + 0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// - + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// . + 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// / + 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 + 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 + 0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2 + 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 + 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 + 0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5 + 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 + 0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7 + 0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8 + 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 + 0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// : + 0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ; + 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// < + 0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// = + 0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// > + 0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ? + 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @ + 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A + 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B + 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C + 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D + 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E + 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F + 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G + 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H + 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I + 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J + 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K + 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L + 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M + 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N + 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O + 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P + 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q + 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R + 0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S + 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T + 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U + 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V + 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W + 0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X + 0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y + 0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z + 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [ + 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55 + 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ] + 0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^ + 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _ + 0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// ' + 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a + 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b + 0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c + 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d + 0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e + 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f + 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g + 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h + 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i + 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j + 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k + 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l + 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m + 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n + 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o + 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p + 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q + 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r + 0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s + 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t + 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u + 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v + 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w + 0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x + 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y + 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines +}; +/****************************************8*16的点阵************************************/ +unsigned char F8x16[][16]= +{ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0 + 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1 + 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2 + 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3 + 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4 + 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5 + 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6 + 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7 + 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8 + 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9 + 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10 + 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14 + 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15 + 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16 + 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17 + 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18 + 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19 + 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20 + 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21 + 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22 + 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23 + 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24 + 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25 + 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26 + 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27 + 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28 + 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29 + 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30 + 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31 + 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32 + 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33 + 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34 + 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35 + 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36 + 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37 + 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38 + 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39 + 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40 + 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41 + 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42 + 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43 + 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44 + 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45 + 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46 + 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47 + 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48 + 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49 + 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50 + 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51 + 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52 + 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53 + 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54 + 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55 + 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56 + 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57 + 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58 + 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59 + 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60 + 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61 + 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63 + 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65 + 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66 + 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67 + 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69 + 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70 + 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71 + 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72 + 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73 + 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74 + 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75 + 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76 + 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77 + 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78 + 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79 + 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80 + 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81 + 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82 + 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83 + 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84 + 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85 + 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86 + 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87 + 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88 + 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89 + 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90 + 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91 + 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92 + 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93 + 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94 +}; + +unsigned char BMP1[] = +{ + 0x00,0x03,0x05,0x09,0x11,0xFF,0x11,0x89,0x05,0xC3,0x00,0xE0,0x00,0xF0,0x00,0xF8, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFF,0x11,0xAA,0x44,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x01,0x38,0x44,0x82,0x92, + 0x92,0x74,0x01,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xC7,0x01,0x7D, + 0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0xFF,0x00, + 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00, + 0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00, + 0x6D,0x6D,0x6D,0x6D,0x6D,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x40,0x40, + 0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00, + 0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB, + 0xDB,0xDB,0xDB,0x00,0x00,0xDA,0xDA,0xDA,0xDA,0xDA,0x00,0x00,0xD8,0xD8,0xD8,0xD8, + 0xD8,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00, + 0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x80, + 0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00, + 0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06, + 0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0xE6,0x66,0x20,0x00,0x06,0x06,0x86,0x06, + 0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x86,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00, + 0x00,0x86,0x86,0x86,0x86,0x86,0x80,0x80,0x86,0x86,0x06,0x86,0x86,0xC0,0xC0,0x86, + 0x86,0x86,0x06,0x06,0xD0,0x30,0x76,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06, + 0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06, + 0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x1C,0x00,0xFE,0x00,0x01, + 0x02,0x00,0xC4,0x18,0x20,0x02,0x9E,0x63,0xB2,0x0E,0x00,0xFF,0x81,0x81,0xFF,0x00, + 0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0xFF,0x00,0x23,0xEA,0xAA,0xBF,0xAA, + 0xEA,0x03,0x3F,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x08,0x00,0x00,0x01,0x01,0x01, + 0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x81,0x80,0x80,0x81,0x80, + 0x81,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x01,0x00,0x01,0x01,0x09,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, + 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00, + 0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E,0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC1,0xC1,0xFF, + 0xFF,0xC1,0xC1,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0xFC,0xF3,0xEF,0xF3,0xFC, + 0x80,0xFF,0x80,0xEE,0xEE,0xEE,0xF5,0xFB,0xFF,0x9C,0xBE,0xB6,0xB6,0x88,0xFF,0x00,/*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/ +}; + diff --git a/SPI_OLED/test_app/test_app b/SPI_OLED/test_app/test_app new file mode 100755 index 0000000..bed4bf4 Binary files /dev/null and b/SPI_OLED/test_app/test_app differ diff --git a/SPI_OLED/test_app/test_app.c b/SPI_OLED/test_app/test_app.c new file mode 100644 index 0000000..672d10c --- /dev/null +++ b/SPI_OLED/test_app/test_app.c @@ -0,0 +1,278 @@ +#include +#include +#include +#include +#include + +#include "test_app.h" + +/*点阵数据*/ +extern unsigned char F16x16[]; +extern unsigned char F6x8[][6]; +extern unsigned char F8x16[][16]; +extern unsigned char BMP1[]; + +int main(int argc, char *argv[]) +{ + int error = -1; + /*打开文件*/ + int fd = open("/dev/spi_oled", O_RDWR); + if (fd < 0) + { + printf("open file : %s failed !\n", argv[0]); + return -1; + } + + while(1) + { + /*显示图片*/ + show_bmp(fd, 0, 0, BMP1, X_WIDTH*Y_WIDTH/8); + + sleep(2); + oled_fill(fd, 0, 0, 127, 7, 0x00); //清屏 + + oled_show_F16X16_letter(fd,0, 0, F16x16, 4); //显示汉字 + oled_show_F8X16_string(fd,0,2,"F8X16:THIS IS SPI TEST APP"); + oled_show_F6X8_string(fd, 0, 6,"F6X8:THIS IS SPI TEST APP"); + + sleep(2); + oled_fill(fd, 0, 0, 127, 7, 0x00); //清屏 + + oled_show_F8X16_string(fd,0,0,"Testing is completed"); + + sleep(2); + oled_fill(fd, 0, 0, 127, 7, 0x00); //清屏 + } + + /*关闭文件*/ + error = close(fd); + if(error < 0) + { + printf("close file error! \n"); + } + return 0; +} + + +/*显示图片 +*fd,打开文件描述符 +*x, 图片显示起始位置x坐标,常规图片要将x设置为0,或者将图片逐行显示, +*y, 图片显示起始位置y坐标 +*buffer,要显示的数据地址 +*length,数据长度 +*/ +int show_bmp(int fd, u8 x, u8 y, u8 *buffer, u32 length) +{ + int error; + struct oled_display_struct *display_struct; + + /*申请内存*/ + display_struct = malloc(sizeof(oled_display_struct) + length); + + /*填充发送结构体*/ + display_struct->x = x; + display_struct->y = y; + display_struct->length = length; + memcpy(display_struct->display_buffer, buffer, display_struct->length); + + /*执行写入*/ + error = write(fd, display_struct, sizeof(oled_display_struct) + display_struct->length); + + /*释放内存*/ + free(display_struct); + return error; +} + + + +/*显示色块(清屏或刷屏) +*fd,打开文件描述符 +*x,y, 起始坐标 +*end_x,end_y 结束坐标 +*data, 要显示的数据(0x00 黑屏,0xFF全亮。其他...) +*/ +int oled_fill(int fd, u8 start_x, u8 start_y, u8 end_x, u8 end_y, u8 data) +{ + struct oled_display_struct *display_struct = NULL; + int error; + + if ((end_x < start_x) || (end_y < start_y)) + { + return -1; + } + + /*填充要发送的数据*/ + display_struct = malloc(sizeof(oled_display_struct) + end_x - start_x + 1); + if (display_struct == NULL) + { + printf("oled_fill malloc error \n"); + return -1; + } + display_struct->length = end_x - start_x + 1; + memset(display_struct->display_buffer, data, display_struct->length); + + do + { + /*设置写入位置*/ + display_struct->x = start_x; + display_struct->y = start_y; + /*执行写入*/ + write(fd, display_struct, sizeof(oled_display_struct) + display_struct->length); + start_y++; + } while (start_y <= end_y); + + /*释放内存*/ + free(display_struct); + return 0; +} + +/*向 oled 写入一个字符 +*fd,打开文件描述符 +*x,y, 起始坐标 +*width, 字符宽度 +*high, 字符高度 +*data,字符数据地址 +*/ +int oled_show_one_letter(int fd, u8 x, u8 y, u8 width, u8 high, u8 *data) +{ + struct oled_display_struct *display_struct = NULL; + + if ((high % 8) != 0) + { + printf("oled_show_one_letter \"high\" set error! \n"); + return -1; + } + high = high/8; + + /*申请空间*/ + display_struct = malloc(sizeof(oled_display_struct) + width * high); + if (display_struct == NULL) + { + printf("oled_fill malloc error \n"); + return -1; + } + + do + { + display_struct->x = x; + display_struct->y = y; + display_struct->length = width; + memcpy(display_struct->display_buffer, data, display_struct->length); + write(fd, display_struct, sizeof(oled_display_struct) + display_struct->length); + data += display_struct->length; + high--; + y++; + } while (high > 0); + + /*释放空间*/ + free(display_struct); + return 0; +} + + +/*写入F16X16字符 +*fd,打开文件描述符 +*x,y, 起始坐标 +*data,字符数据地址 +*length,字符个数 +*/ +int oled_show_F16X16_letter(int fd, u8 x, u8 y, u8 *data, u32 length) +{ + /*判断数据是否有效*/ + if ((x > (127 - 16)) || (y > (7 - 2))) + { + printf("oled_show_F16X16_letter \"x\" or \"y\" set error! \n"); + return -1; + } + + do + { + oled_show_one_letter(fd, x, y, 16, 16, data); + /* 32 = 16(width) * 16(high) / 8(一个字节8位)*/ + data += 32; + length--; + x += 16; + if (x > 127-16) + { + /*清除未写入的区域*/ + /*清除未写入的区域*/ + // oled_fill(fd, x, y, 127, y+1, 0x00); + x = 0; + y += 2; + } + } while (length>0); + return 0; +} + + +/*写入F6x8字符串 +*fd,打开文件描述符 +*x,y, 起始坐标 +*data,字符数据地址 +*length,字符个数 +*/ +int oled_show_F6X8_string(int fd, u8 x, u8 y, u8 *string) +{ + u32 i = 0; + u8 value = 0; + /*判断数据是否有效*/ + if ((x > (127 - 6)) || (y > 7)||(string[0] == '\0')) + { + printf("oled_show_F16X16_letter \"x\" or \"y\" set error! \n"); + return -1; + } + + do + { + value = string[i] - 32; + oled_show_one_letter(fd, x, y, 6, 8, F6x8[value]); + /* 32 = 16(width) * 16(high) / 8(一个字节8位)*/ + x += 6; + i++; + if (x > (127-6)) + { + /*清除未写入的区域*/ + // oled_fill(fd, x, y, 127, y, 0x00); + x = 0; + y++; + } + } while ((y<=7)&&(string[i] != '\0')); + return 0; +} + + +/*写入F8X16字符串 +*fd,打开文件描述符 +*x,y, 起始坐标 +*data,字符数据地址 +*length,字符个数 +*/ +int oled_show_F8X16_string(int fd, u8 x, u8 y, u8 *string) +{ + u32 i = 0; + u8 value = 0; + /*判断数据是否有效*/ + if ((x > (127 - 8)) || (y > (7 - 1))||(string[0] == '\0')) + { + printf("oled_show_F16X16_letter \"x\" or \"y\" set error! \n"); + return -1; + } + + do + { + value = string[i] - 32; + oled_show_one_letter(fd, x, y, 8, 16, F8x16[value]); + /* 32 = 16(width) * 16(high) / 8(一个字节8位)*/ + x += 8; + i++; + if (x > (127-8)) + { + /*清除未写入的区域*/ + // oled_fill(fd, x, y, 127, y, 0x00); + x = 0; + y += 2; + } + } while ((y<=6)&&(string[i] != '\0')); + return 0; +} + diff --git a/SPI_OLED/test_app/test_app.h b/SPI_OLED/test_app/test_app.h new file mode 100644 index 0000000..c67598b --- /dev/null +++ b/SPI_OLED/test_app/test_app.h @@ -0,0 +1,30 @@ + +#ifndef TEST_APP_H +#define TEST_APP_H + + +//宏定义 +#define X_WIDTH 128 //oled显示屏列数 +#define Y_WIDTH 64 //oled显示屏行数 + +#define u8 unsigned char +#define u32 unsigned int + + +/*数据发送结构体*/ +typedef struct oled_display_struct +{ + u8 x; + u8 y; + u32 length; + u8 display_buffer[]; +}oled_display_struct; + +int show_bmp(int fd, u8 x, u8 y,u8* buffer, u32 length); +int oled_fill(int fd, u8 start_x, u8 start_y,u8 end_x, u8 end_y,u8 data); +int oled_show_one_letter(int fd, u8 x, u8 y, u8 width, u8 high, u8 *data); +int oled_show_F16X16_letter(int fd, u8 x, u8 y, u8 *data, u32 length); +int oled_show_F6X8_string(int fd, u8 x, u8 y, u8 *string); +int oled_show_F8X16_string(int fd, u8 x, u8 y, u8 *string); + +#endif \ No newline at end of file diff --git a/Sysfs/Makefile b/Sysfs/Makefile new file mode 100644 index 0000000..e67c0d4 --- /dev/null +++ b/Sysfs/Makefile @@ -0,0 +1,16 @@ +KERNEL_DIR=../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := sys_test.o + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + +.PHONE:clean + +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + diff --git a/Sysfs/sys_test.c b/Sysfs/sys_test.c new file mode 100644 index 0000000..d5d0c2e --- /dev/null +++ b/Sysfs/sys_test.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include + +volatile int test_value = 0; + +struct kobject *kobj_ref; + +/*该函数被调用在sysfs文件被读时*/ +static ssize_t sysfs_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + pr_info("读sysfs!\n"); + return sprintf(buf, "test_value = %d\n", test_value); +} + +/* 该函数被调用在sysfs文件被写时*/ +static ssize_t sysfs_store(struct kobject *kobj, + struct kobj_attribute *attr,const char *buf, size_t count) +{ + pr_info("写sysfs!\n"); + sscanf(buf,"%d",&test_value); + return count; +} + +struct kobj_attribute sysfs_test_attr = __ATTR(test_value, 0664, sysfs_show, sysfs_store); + +/*模块初始化函数*/ +static int __init sysfs_test_driver_init(void) +{ + /*创建一个目录在/sys下 */ + kobj_ref = kobject_create_and_add("sysfs_test",NULL); + + /*在sysfs_test目录下创建一个文件*/ + if(sysfs_create_file(kobj_ref,&sysfs_test_attr.attr)){ + pr_err("创建sysfs文件失败.....\n"); + goto error_sysfs; + } + + pr_info("驱动模块初始化完成!\n"); + return 0; + +error_sysfs: + kobject_put(kobj_ref); + sysfs_remove_file(kernel_kobj, &sysfs_test_attr.attr); + return -1; + +} + +/*模块退出函数*/ +static void __exit sysfs_test_driver_exit(void) +{ + kobject_put(kobj_ref); + sysfs_remove_file(kernel_kobj, &sysfs_test_attr.attr); + pr_info("设备驱动模块移除!\n"); +} + +module_init(sysfs_test_driver_init); +module_exit(sysfs_test_driver_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Embedfire"); +MODULE_DESCRIPTION("一个简单的使用sysfs的驱动程序"); \ No newline at end of file diff --git a/button_interrupt/README.txt b/button_interrupt/README.txt new file mode 100644 index 0000000..e69de29 diff --git a/button_interrupt/interrupt/Makefile b/button_interrupt/interrupt/Makefile new file mode 100644 index 0000000..f1d2465 --- /dev/null +++ b/button_interrupt/interrupt/Makefile @@ -0,0 +1,17 @@ +KERNEL_DIR=../../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := interrupt.o +out = test_app + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + $(CROSS_COMPILE)gcc -o $(out) test_app.c + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + rm test_app diff --git a/button_interrupt/interrupt/interrupt.c b/button_interrupt/interrupt/interrupt.c new file mode 100644 index 0000000..58ea004 --- /dev/null +++ b/button_interrupt/interrupt/interrupt.c @@ -0,0 +1,202 @@ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*------------------字符设备内容----------------------*/ +#define DEV_NAME "button" +#define DEV_CNT (1) + +static dev_t button_devno; //定义字符设备的设备号 +static struct cdev button_chr_dev; //定义字符设备结构体chr_dev +struct class *class_button; //保存创建的类 +struct device *device_button; // 保存创建的设备 + + +struct device_node *button_device_node = NULL; //定义按键设备节点结构体 +unsigned button_GPIO_number = 0; //保存button使用的GPIO引脚编号 +u32 interrupt_number = 0; // button 引脚中断编号 +atomic_t button_status = ATOMIC_INIT(0); //定义整型原子变量,保存按键状态 ,设置初始值为0 + +static irqreturn_t button_irq_hander(int irq, void *dev_id) +{ + atomic_inc(&button_status); + return IRQ_HANDLED; +} + +static int button_open(struct inode *inode, struct file *filp) +{ + int error = -1; + + /*获取按键 设备树节点*/ + button_device_node = of_find_node_by_path("/button_interrupt"); + if(NULL == button_device_node) + { + printk("of_find_node_by_path error!"); + return -1; + } + + /*获取按键使用的GPIO*/ + button_GPIO_number = of_get_named_gpio(button_device_node ,"button-gpios", 0); + if(!button_GPIO_number) + { + printk("of_get_named_gpio error"); + return -1; + } + printk("button_GPIO_number = %d \n", button_GPIO_number); + + /*申请GPIO , 记得释放*/ + error = gpio_request(button_GPIO_number, "button_gpios"); + if(error < 0) + { + printk("gpio_request error"); + gpio_free(button_GPIO_number); + return -1; + } + + error = gpio_direction_input(button_GPIO_number);//设置引脚为输入模式 + + /*获取中断号*/ + interrupt_number = irq_of_parse_and_map(button_device_node, 0); + printk("\n irq_of_parse_and_map = %d \n",interrupt_number); + + + /*申请中断, 记得释放*/ + error = request_irq(interrupt_number,button_irq_hander,IRQF_TRIGGER_FALLING,"button_interrupt",NULL); + if(error != 0) + { + printk("request_irq error"); + free_irq(interrupt_number, NULL); + return -1; + } + + /*申请之后已经开启了,切记不要再次打开,否则运行时报错*/ + // // enable_irq(interrupt_number); + + return 0; + +} + +static ssize_t button_read(struct file *filp, char __user *buf, size_t cnt, loff_t *offt) +{ + int error = -1; + int button_countervc = 0; + + /*读取按键状态值*/ + button_countervc = atomic_read(&button_status); + + /*结果拷贝到用户空间*/ + error = copy_to_user(buf, &button_countervc, sizeof(button_countervc)); + if(error < 0) + { + printk("copy_to_user error"); + return -1; + } + + /*清零按键状态值*/ + atomic_set(&button_status,0); + return 0; +} + +/*字符设备操作函数集,.release函数实现*/ +static int button_release(struct inode *inode, struct file *filp) +{ + /*释放申请的引脚,和中断*/ + printk("button_release\n"); + free_irq(interrupt_number, NULL); + gpio_free(button_GPIO_number); + return 0; +} + + + +/*字符设备操作函数集*/ +static struct file_operations button_chr_dev_fops = { + .owner = THIS_MODULE, + .open = button_open, + .read = button_read, + .release = button_release +}; + +/* +*驱动初始化函数 +*/ +static int __init button_driver_init(void) +{ + int error = -1; + + /*采用动态分配的方式,获取设备编号,次设备号为0,*/ + error = alloc_chrdev_region(&button_devno, 0, DEV_CNT, DEV_NAME); + if (error < 0) + { + printk("fail to alloc button_devno\n"); + goto alloc_err; + } + + /*关联字符设备结构体cdev与文件操作结构体file_operations*/ + button_chr_dev.owner = THIS_MODULE; + cdev_init(&button_chr_dev, &button_chr_dev_fops); + + /*添加设备至cdev_map散列表中*/ + error = cdev_add(&button_chr_dev, button_devno, DEV_CNT); + if (error < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + + class_button = class_create(THIS_MODULE, DEV_NAME); //创建类 + device_button = device_create(class_button, NULL, button_devno, NULL, DEV_NAME);//创建设备 DEV_NAME 指定设备名, + + return 0; + +add_err: + unregister_chrdev_region(button_devno, DEV_CNT); // 添加设备失败时,需要注销设备号 + printk("\n error! \n"); + +alloc_err: + return -1; +} + + + +/* +*驱动注销函数 +*/ +static void __exit button_driver_exit(void) +{ + pr_info("button_driver_exit\n"); + /*删除设备*/ + device_destroy(class_button, button_devno); //清除设备 + class_destroy(class_button); //清除类 + cdev_del(&button_chr_dev); //清除设备号 + unregister_chrdev_region(button_devno, DEV_CNT); //取消注册字符设备 +} + + + +module_init(button_driver_init); +module_exit(button_driver_exit); + +MODULE_LICENSE("GPL"); + + + + diff --git a/button_interrupt/interrupt/test_app.c b/button_interrupt/interrupt/test_app.c new file mode 100644 index 0000000..956dab2 --- /dev/null +++ b/button_interrupt/interrupt/test_app.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int error = -20; + int button_status = 0; + + /*打开文件*/ + int fd = open("/dev/button", O_RDWR); + if (fd < 0) + { + printf("open file : /dev/button error!\n"); + return -1; + } + + printf("wait button down... \n"); + + do + { + /*读取按键状态*/ + error = read(fd, &button_status, sizeof(button_status)); + if (error < 0) + { + printf("read file error! \n"); + } + usleep(1000 * 100); //延时100毫秒 + } while (0 == button_status); + printf("button Down !\n"); + + /*关闭文件*/ + error = close(fd); + if (error < 0) + { + printf("close file error! \n"); + } + return 0; +} diff --git a/button_interrupt/interrupt_tasklet/Makefile b/button_interrupt/interrupt_tasklet/Makefile new file mode 100644 index 0000000..f1d2465 --- /dev/null +++ b/button_interrupt/interrupt_tasklet/Makefile @@ -0,0 +1,17 @@ +KERNEL_DIR=../../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := interrupt.o +out = test_app + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + $(CROSS_COMPILE)gcc -o $(out) test_app.c + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + rm test_app diff --git a/button_interrupt/interrupt_tasklet/interrupt.c b/button_interrupt/interrupt_tasklet/interrupt.c new file mode 100644 index 0000000..e6533b8 --- /dev/null +++ b/button_interrupt/interrupt_tasklet/interrupt.c @@ -0,0 +1,224 @@ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*------------------字符设备内容----------------------*/ +#define DEV_NAME "button" +#define DEV_CNT (1) + +static dev_t button_devno; //定义字符设备的设备号 +static struct cdev button_chr_dev; //定义字符设备结构体chr_dev +struct class *class_button; //保存创建的类 +struct device *device_button; // 保存创建的设备 + + +struct device_node *button_device_node = NULL; //定义按键设备节点结构体 +unsigned button_GPIO_number = 0; //保存button使用的GPIO引脚编号 +u32 interrupt_number = 0; // button 引脚中断编号 +atomic_t button_status = ATOMIC_INIT(0); //定义整型原子变量,保存按键状态 ,设置初始值为0 + + +struct tasklet_struct button_tasklet; + + +void button_tasklet_hander(unsigned long data) +{ + int counter = 1; + mdelay(200); + printk(KERN_ERR "button_tasklet_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "button_tasklet_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "button_tasklet_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "button_tasklet_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "button_tasklet_hander counter = %d \n", counter++); +} + + + +static irqreturn_t button_irq_hander(int irq, void *dev_id) +{ + printk(KERN_ERR "button_irq_hander----------inter"); + /*按键状态加一*/ + atomic_inc(&button_status); + + tasklet_schedule(&button_tasklet); + + printk(KERN_ERR "button_irq_hander-----------exit"); + return IRQ_HANDLED; +} + +static int button_open(struct inode *inode, struct file *filp) +{ + int error = -1; + + /*获取按键 设备树节点*/ + button_device_node = of_find_node_by_path("/button_interrupt"); + if(NULL == button_device_node) + { + printk("of_find_node_by_path error!"); + return -1; + } + + /*获取按键使用的GPIO*/ + button_GPIO_number = of_get_named_gpio(button_device_node ,"button-gpios", 0); + if(0 == button_GPIO_number) + { + printk("of_get_named_gpio error"); + return -1; + } + + /*申请GPIO , 记得释放*/ + error = gpio_request(button_GPIO_number, "button_gpio"); + if(error < 0) + { + printk("gpio_request error"); + gpio_free(button_GPIO_number); + return -1; + } + + error = gpio_direction_input(button_GPIO_number);//设置引脚为输入模式 + + /*获取中断号*/ + interrupt_number = irq_of_parse_and_map(button_device_node, 0); + printk("irq_of_parse_and_map = %d \n",interrupt_number); + + /*申请中断, 记得释放*/ + error = request_irq(interrupt_number,button_irq_hander,IRQF_TRIGGER_RISING,"button_interrupt",device_button); + if(error != 0) + { + printk("request_irq error"); + free_irq(interrupt_number, device_button); + return -1; + } + + + /*初始化button_tasklet*/ + tasklet_init(&button_tasklet,button_tasklet_hander,0); + + /*申请之后已经开启了,切记不要再次打开,否则运行时报错*/ + // // enable_irq(interrupt_number); + + return 0; + +} + +static ssize_t button_read(struct file *filp, char __user *buf, size_t cnt, loff_t *offt) +{ + int error = -1; + int button_countervc = 0; + + /*读取按键状态值*/ + button_countervc = atomic_read(&button_status); + + /*结果拷贝到用户空间*/ + error = copy_to_user(buf, &button_countervc, sizeof(button_countervc)); + if(error < 0) + { + printk("copy_to_user error"); + return -1; + } + + /*清零按键状态值*/ + atomic_set(&button_status,0); + return 0; +} + +/*字符设备操作函数集,.release函数实现*/ +static int button_release(struct inode *inode, struct file *filp) +{ + /*释放申请的引脚,和中断*/ + free_irq(interrupt_number, device_button); + gpio_free(button_GPIO_number); + return 0; +} + +/*字符设备操作函数集*/ +static struct file_operations button_chr_dev_fops = { + .owner = THIS_MODULE, + .open = button_open, + .read = button_read, + .release = button_release +}; + +/* +*驱动初始化函数 +*/ +static int __init button_driver_init(void) +{ + int error = -1; + + /*采用动态分配的方式,获取设备编号,次设备号为0,*/ + error = alloc_chrdev_region(&button_devno, 0, DEV_CNT, DEV_NAME); + if (error < 0) + { + printk("fail to alloc button_devno\n"); + goto alloc_err; + } + + /*关联字符设备结构体cdev与文件操作结构体file_operations*/ + button_chr_dev.owner = THIS_MODULE; + cdev_init(&button_chr_dev, &button_chr_dev_fops); + + /*添加设备至cdev_map散列表中*/ + error = cdev_add(&button_chr_dev, button_devno, DEV_CNT); + if (error < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + + class_button = class_create(THIS_MODULE, DEV_NAME); //创建类 + device_button = device_create(class_button, NULL, button_devno, NULL, DEV_NAME);//创建设备 DEV_NAME 指定设备名, + + return 0; + +add_err: + unregister_chrdev_region(button_devno, DEV_CNT); // 添加设备失败时,需要注销设备号 + printk("\n error! \n"); + +alloc_err: + return -1; +} + +/* +*驱动注销函数 +*/ +static void __exit button_driver_exit(void) +{ + pr_info("button_driver_exit\n"); + /*删除设备*/ + device_destroy(class_button, button_devno); //清除设备 + class_destroy(class_button); //清除类 + cdev_del(&button_chr_dev); //清除设备号 + unregister_chrdev_region(button_devno, DEV_CNT); //取消注册字符设备 +} + + + +module_init(button_driver_init); +module_exit(button_driver_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("embedfire lubuncat , interrupt tasklet"); + + + diff --git a/button_interrupt/interrupt_tasklet/interrupt.h b/button_interrupt/interrupt_tasklet/interrupt.h new file mode 100644 index 0000000..7dc2840 --- /dev/null +++ b/button_interrupt/interrupt_tasklet/interrupt.h @@ -0,0 +1,9 @@ +#ifndef INTERRUPT_H +#define INTERRUPT_H +#include + + + + + +#endif \ No newline at end of file diff --git a/button_interrupt/interrupt_tasklet/interrupt.ko b/button_interrupt/interrupt_tasklet/interrupt.ko new file mode 100644 index 0000000..5169eed Binary files /dev/null and b/button_interrupt/interrupt_tasklet/interrupt.ko differ diff --git a/button_interrupt/interrupt_tasklet/test_app b/button_interrupt/interrupt_tasklet/test_app new file mode 100755 index 0000000..97419b8 Binary files /dev/null and b/button_interrupt/interrupt_tasklet/test_app differ diff --git a/button_interrupt/interrupt_tasklet/test_app.c b/button_interrupt/interrupt_tasklet/test_app.c new file mode 100644 index 0000000..28ea9fb --- /dev/null +++ b/button_interrupt/interrupt_tasklet/test_app.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int error = -20; + int button_status = 0; + + /*打开文件*/ + int fd = open("/dev/button", O_RDWR); + if (fd < 0) + { + printf("open file : /dev/button error!\n"); + return -1; + } + + printf("wait button down... \n"); + do + { + /*读取按键状态*/ + error = read(fd, &button_status, sizeof(button_status)); + if (error < 0) + { + printf("read file error! \n"); + } + usleep(1000 * 100); //延时100毫秒 + } while (0 == button_status); + printf("button Down !\n"); + + /*关闭文件*/ + error = close(fd); + if (error < 0) + { + printf("close file error! \n"); + } + return 0; +} diff --git a/button_interrupt/interrupt_work/Makefile b/button_interrupt/interrupt_work/Makefile new file mode 100644 index 0000000..f1d2465 --- /dev/null +++ b/button_interrupt/interrupt_work/Makefile @@ -0,0 +1,17 @@ +KERNEL_DIR=../../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := interrupt.o +out = test_app + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + $(CROSS_COMPILE)gcc -o $(out) test_app.c + +.PHONY:clean +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + rm test_app diff --git a/button_interrupt/interrupt_work/interrupt.c b/button_interrupt/interrupt_work/interrupt.c new file mode 100644 index 0000000..623abac --- /dev/null +++ b/button_interrupt/interrupt_work/interrupt.c @@ -0,0 +1,218 @@ +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/*------------------字符设备内容----------------------*/ +#define DEV_NAME "button" +#define DEV_CNT (1) + +static dev_t button_devno; //定义字符设备的设备号 +static struct cdev button_chr_dev; //定义字符设备结构体chr_dev +struct class *class_button; //保存创建的类 +struct device *device_button; // 保存创建的设备 + + +struct device_node *button_device_node = NULL; //定义按键设备节点结构体 +unsigned button_GPIO_number = 0; //保存button使用的GPIO引脚编号 +u32 interrupt_number = 0; // button 引脚中断编号 +atomic_t button_status = ATOMIC_INIT(0); //定义整型原子变量,保存按键状态 ,设置初始值为0 + +struct work_struct button_work; //定义工作结构体 + +/*定义工作执行函数*/ +void work_hander(struct work_struct *work) +{ + int counter = 1; + mdelay(200); + printk(KERN_ERR "work_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "work_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "work_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "work_hander counter = %d \n", counter++); + mdelay(200); + printk(KERN_ERR "work_hander counter = %d \n", counter++); +} + +/*定义按键中断服务函数*/ +static irqreturn_t button_irq_hander(int irq, void *dev_id) +{ + /*按键状态加一*/ + atomic_inc(&button_status); + schedule_work(&button_work); //触发工作 + + return IRQ_HANDLED; +} + +static int button_open(struct inode *inode, struct file *filp) +{ + int error = -1; + + /*获取按键 设备树节点*/ + button_device_node = of_find_node_by_path("/button_interrupt"); + if(NULL == button_device_node) + { + printk("of_find_node_by_path error!"); + return -1; + } + + /*获取按键使用的GPIO*/ + button_GPIO_number = of_get_named_gpio(button_device_node ,"button-gpios", 0); + if(0 == button_GPIO_number) + { + printk("of_get_named_gpio error"); + return -1; + } + + /*申请GPIO , 记得释放*/ + error = gpio_request(button_GPIO_number, "button_gpio"); + if(error < 0) + { + printk("gpio_request error"); + gpio_free(button_GPIO_number); + return -1; + } + + error = gpio_direction_input(button_GPIO_number);//设置引脚为输入模式 + + /*获取中断号*/ + interrupt_number = irq_of_parse_and_map(button_device_node, 0); + printk("irq_of_parse_and_map = %d \n",interrupt_number); + + + /*申请中断, 记得释放*/ + error = request_irq(interrupt_number,button_irq_hander,IRQF_TRIGGER_RISING,"button_interrupt",device_button); + if(error != 0) + { + printk("request_irq error"); + free_irq(interrupt_number, device_button); + return -1; + } + + + /*初始化button_work*/ + INIT_WORK(&button_work, work_hander); + + /*申请之后已经开启了,切记不要再次打开,否则运行时报错*/ + // // enable_irq(interrupt_number); + + return 0; + +} + +static ssize_t button_read(struct file *filp, char __user *buf, size_t cnt, loff_t *offt) +{ + int error = -1; + int button_countervc = 0; + + /*读取按键状态值*/ + button_countervc = atomic_read(&button_status); + + /*结果拷贝到用户空间*/ + error = copy_to_user(buf, &button_countervc, sizeof(button_countervc)); + if(error < 0) + { + printk("copy_to_user error"); + return -1; + } + + /*清零按键状态值*/ + atomic_set(&button_status,0); + return 0; +} + +/*字符设备操作函数集,.release函数实现*/ +static int button_release(struct inode *inode, struct file *filp) +{ + /*释放申请的引脚,和中断*/ + gpio_free(button_GPIO_number); + free_irq(interrupt_number, device_button); + return 0; +} + +/*字符设备操作函数集*/ +static struct file_operations button_chr_dev_fops = { + .owner = THIS_MODULE, + .open = button_open, + .read = button_read, + .release = button_release}; + +/* +*驱动初始化函数 +*/ +static int __init button_driver_init(void) +{ + int error = -1; + + /*采用动态分配的方式,获取设备编号,次设备号为0,*/ + error = alloc_chrdev_region(&button_devno, 0, DEV_CNT, DEV_NAME); + if (error < 0) + { + printk("fail to alloc button_devno\n"); + goto alloc_err; + } + + /*关联字符设备结构体cdev与文件操作结构体file_operations*/ + button_chr_dev.owner = THIS_MODULE; + cdev_init(&button_chr_dev, &button_chr_dev_fops); + + /*添加设备至cdev_map散列表中*/ + error = cdev_add(&button_chr_dev, button_devno, DEV_CNT); + if (error < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + + class_button = class_create(THIS_MODULE, DEV_NAME); //创建类 + device_button = device_create(class_button, NULL, button_devno, NULL, DEV_NAME);//创建设备 DEV_NAME 指定设备名, + + return 0; + +add_err: + unregister_chrdev_region(button_devno, DEV_CNT); // 添加设备失败时,需要注销设备号 + printk("\n error! \n"); + +alloc_err: + return -1; +} + + +/* +*驱动注销函数 +*/ +static void __exit button_driver_exit(void) +{ + pr_info("button_driver_exit\n"); + /*删除设备*/ + device_destroy(class_button, button_devno); //清除设备 + class_destroy(class_button); //清除类 + cdev_del(&button_chr_dev); //清除设备号 + unregister_chrdev_region(button_devno, DEV_CNT); //取消注册字符设备 +} + +module_init(button_driver_init); +module_exit(button_driver_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("embedfire lubuncat2_RK , interrupt work queue"); + + diff --git a/button_interrupt/interrupt_work/interrupt.ko b/button_interrupt/interrupt_work/interrupt.ko new file mode 100644 index 0000000..8bf1322 Binary files /dev/null and b/button_interrupt/interrupt_work/interrupt.ko differ diff --git a/button_interrupt/interrupt_work/test_app b/button_interrupt/interrupt_work/test_app new file mode 100755 index 0000000..56b6f04 Binary files /dev/null and b/button_interrupt/interrupt_work/test_app differ diff --git a/button_interrupt/interrupt_work/test_app.c b/button_interrupt/interrupt_work/test_app.c new file mode 100644 index 0000000..5cbe8a5 --- /dev/null +++ b/button_interrupt/interrupt_work/test_app.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int error = -20; + int button_status = 0; + + /*打开文件*/ + int fd = open("/dev/button", O_RDWR); + if (fd < 0) + { + printf("open file : /dev/button error!\n"); + return -1; + } + + printf("wait button down... \n"); + do + { + /*读取按键状态*/ + error = read(fd, &button_status, sizeof(button_status)); + if (error < 0) + { + printf("read file error! \n"); + } + usleep(1000 * 100); //延时100毫秒 + } while (0 == button_status); + + printf("button Down !\n"); + + usleep(1000 * 5000); + + /*关闭文件*/ + error = close(fd); + if (error < 0) + { + printf("close file error! \n"); + } + return 0; +} diff --git a/button_interrupt/lubancat-button-overlay.dts b/button_interrupt/lubancat-button-overlay.dts new file mode 100644 index 0000000..ba27c91 --- /dev/null +++ b/button_interrupt/lubancat-button-overlay.dts @@ -0,0 +1,26 @@ +/dts-v1/; +/plugin/; + +#include +#include +#include + +&{/} { + button_interrupt: button_interrupt { + status = "okay"; + compatible = "button_interrupt"; + pinctrl-names = "default"; + pinctrl-0 = <&button_interrupt_pin>; + interrupt-parent = <&gpio0>; + interrupts = ; + button-gpios = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>; + }; +}; + +&{/pinctrl} { + button_interrupt { + button_interrupt_pin: button_interrupt_pin { + rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; \ No newline at end of file diff --git a/cst816x-driver-main/Kconfig b/cst816x-driver-main/Kconfig new file mode 100644 index 0000000..c746fd7 --- /dev/null +++ b/cst816x-driver-main/Kconfig @@ -0,0 +1,11 @@ +config TOUCHSCREEN_HYNITRON_CST816X + tristate "Hynitron CST816X touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using a Hynitron + CST816X touchscreen controller. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hynitron-cst816x. diff --git a/cst816x-driver-main/Makefile b/cst816x-driver-main/Makefile new file mode 100644 index 0000000..9303da5 --- /dev/null +++ b/cst816x-driver-main/Makefile @@ -0,0 +1,20 @@ +KERNEL_DIR=../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=/opt/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- +export ARCH CROSS_COMPILE + + + +obj-m += hynitron-cst816x.o + + + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + +.PHONE:clean + +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + rm $(out) diff --git a/cst816x-driver-main/README.md b/cst816x-driver-main/README.md new file mode 100644 index 0000000..1a85700 --- /dev/null +++ b/cst816x-driver-main/README.md @@ -0,0 +1,259 @@ +# Linux Kernel driver for CST816S Touchscreen controller based on 1.28 Inch Round LCD display + +This guide will help you build, install, and set up your kernel module and CST816S Touch Screen device tree overlay for a Raspberry Pi. + + + +## Documentation + +**Raspberry Pi x Round display pinout** +| Module Pin | Raspberry Pi (BCM) | +|------------|--------------------| +| VCC | 3.3V | +| GND | GND | +| MISO | 9 | +| MOSI | 10 | +| SCLK | 11 | +| LCS_CS | 8 | +| LCS_DC | 25 | +| LCS_RST | 27 | +| LCS_BL | 18 | +| TP_SDA | 2 | +| TP_SCL | 3 | +| TP_INT | 4 | +| TP_RST | 17 | + +Follow the [Detailed guide](https://www.waveshare.com/wiki/1.28inch_Touch_LCD) provided by Waveshare to set up hardware connection. + +**Input device Capabilities Description** + +| Event Code | Description | +|--------------------|-----------------------| +| BTN_LEFT | Gesture Left | +| BTN_RIGHT | Gesture Right | +| BTN_FORWARD | Gesture Up | +| BTN_BACK | Gesture Down | +| BTN_TOUCH | Single Touch | +| BTN_TOOL_TRIPLETAP | Long press (hold) | + +**Testing environment** +1. [GC9A01 FBTFT overlay](https://github.com/juliannojungle/gc9a01-overlay) to draw graphics +2. [LVGL demo](https://github.com/lvgl/lv_port_linux) to test Touschreen functionality. + +Follow the steps to enable LVGL demo: + +**Enable Frame buffer** + +Need to enable Frame Buffer functionality inside LVGL header config (lv_conf.h). + +```c +#define LV_USE_LINUX_FBDEV 1 +``` + +**Initialize Frame buffer** + +```c +const char *device = getenv_default("LV_LINUX_FBDEV_DEVICE", "/dev/fbN"); +lv_display_t *disp = lv_linux_fbdev_create(); +lv_linux_fbdev_set_file(disp, device); +``` + +**Initialize Input Device (Linux Touchscreen Interface)** + +```c +lv_indev_t *input = lv_evdev_create(LV_INDEV_TYPE_POINTER, "/dev/input/eventN"); +lv_indev_set_display(input, disp); +``` + +** Initialize and start LWFS ** +```c +ui_init(); +while(1) { + format_linux_date(); + lv_timer_handler(); + usleep(1000); +} +``` + +## Kernel Module Setup Instructions + +### Build driver as External Kernel Module + +1. **Navigate to the kernel module directory**: + + ```sh + cd cst816x-driver/ + ``` + +2. **Build the module using the default kernel headers**: + + ```sh + make + ``` + + Alternatively, specify the kernel source directory manually: + + ```sh + make -C M=$PWD + ``` + +### Install driver as External Kernel Module + +1. **Install the module using the default kernel headers**: + + ```sh + make install + ``` + + Alternatively, specify the kernel source directory manually: + + ```sh + make -C M=$PWD install + ``` + +### Clean the Build Files + +1. **Clean the build files using the default kernel headers**: + + ```sh + make clean + ``` + + Alternatively, specify the kernel source directory manually: + + ```sh + make -C /home/pi/linux-6.9.y M=$PWD clean + ``` + +### Install as External Module + +1. **Insert the module into the kernel**: + + ```sh + sudo insmod hynitron-cst816x.ko + ``` + +2. **Check the module status**: + + ```sh + dmesg + ``` + + Example output: + + ```plaintext + [ 1593.107576] hynitron_cst816x: loading out-of-tree module taints kernel. + [ 1593.283284] input: Hynitron CST816X Touchscreen as /devices/platform/soc/fe804000.i2c/i2c-1/1-0015/input/inputN + ``` + +### Built-in Kernel driver +1. Append CST816X entry to Kernel Kconfig for input/touchscreen section: **drivers/input/touchscreen/Kconfig** + +```plaintext +config TOUCHSCREEN_HYNITRON_CST816X + tristate "Hynitron CST816X touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using a Hynitron + CST816X touchscreen controller. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hynitron-cst816x. +``` + +2. Append module entry to Makefile: **drivers/input/touchscreen/Makefile** + +```plaintext +obj-$(CONFIG_TOUCHSCREEN_GOODIX_BERLIN_I2C) += goodix_berlin_i2c.o +obj-$(CONFIG_TOUCHSCREEN_GOODIX_BERLIN_SPI) += goodix_berlin_spi.o +obj-$(CONFIG_TOUCHSCREEN_HIDEEP) += hideep.o ++obj-$(CONFIG_TOUCHSCREEN_HYNITRON_CST816X) += hynitron-cst816x.o +obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o +obj-$(CONFIG_TOUCHSCREEN_ILITEK) += ilitek_ts_i2c.o +``` + +3. Build Kernel, driver will included as built-in module + +## Device Tree setup steps +### Device Tree approach + +Include the following content in your device tree file (e.g., `hynitron-cst816s.dts`): + +```dts + #include + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + touchscreen@15 { + compatible = "hynitron,cst816s"; + reg = <0x15>; + interrupt-parent = <&gpio0>; + interrupts = <4 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + }; + }; +``` + +### Raspberry Pi DTS overlay approach + +1. **Navigate to the directory containing your device tree source file**: + + ```sh + cd cst816x-driver/rpi4b/ + ``` + +2. **Compile the device tree overlay**: + + ```sh + dtc -@ -I dts -O dtb -o cst816s.dtbo hynitron-cst816s.dts + ``` +3. **Copy the compiled overlay to the boot overlays directory**: + ```sh + sudo cp cst816s.dtbo /boot/overlays/ + ``` + +2. **Add the overlay to the `config.txt` file**: + + ```sh + sudo sh -c 'echo "dtoverlay=cst816s" >> /boot/config.txt' + ``` + +### Reboot the Device + +**Reboot your Raspberry Pi to apply the overlay**: +```sh + sudo reboot +``` + +Following these steps will build and install your kernel module and device tree overlay on a Raspberry Pi. Make sure to adjust any paths to match your specific environment. + +### Verify Input Device Capabilities +**You can find available capabilities showing that device operate properly** +```plaintext + evtest /dev/input/eventN + Input driver version is 1.0.1 + Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0 + Input device name: "Hynitron CST816X Touchscreen" + Supported events: + Event type 0 (EV_SYN) + Event type 1 (EV_KEY) + Event code 272 (BTN_LEFT) + Event code 273 (BTN_RIGHT) + Event code 277 (BTN_FORWARD) + Event code 278 (BTN_BACK) + Event code 330 (BTN_TOUCH) + Event code 334 (BTN_TOOL_TRIPLETAP) + Event type 3 (EV_ABS) + Event code 0 (ABS_X) + Value 0 + Min 0 + Max 240 + Event code 1 (ABS_Y) + Value 0 + Min 0 + Max 240 +``` diff --git a/cst816x-driver-main/hynitron,cst816s.yaml b/cst816x-driver-main/hynitron,cst816s.yaml new file mode 100644 index 0000000..ac9f1d8 --- /dev/null +++ b/cst816x-driver-main/hynitron,cst816s.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hynitron,cst816s.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hynitron CST816S Touchscreen controller + +description: + Hynitron CST816S Touchscreen controller for 1.28-inch 240x240 Resolution + Touch LCD Display Module + +maintainers: + - Oleh Kuzhylnyi + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hynitron,cst816s + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - reset-gpios + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + touchscreen@15 { + compatible = "hynitron,cst816s"; + reg = <0x15>; + interrupt-parent = <&gpio0>; + interrupts = <4 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/cst816x-driver-main/hynitron-cst816x.c b/cst816x-driver-main/hynitron-cst816x.c new file mode 100644 index 0000000..75b0d7a --- /dev/null +++ b/cst816x-driver-main/hynitron-cst816x.c @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Driver for I2C connected Hynitron CST816X Touchscreen + * + * Copyright (C) 2024 Oleh Kuzhylnyi + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#define CST816X_FRAME 0x01 + +struct cst816x_touch_info { + u8 gesture; + u8 touch; + __be16 abs_x; + __be16 abs_y; +} __packed; + +struct cst816x_event_map { + u8 gesture; + u16 code; +}; + +struct cst816x_priv { + struct i2c_client *client; + struct gpio_desc *reset; + struct input_dev *input; + struct cst816x_event_map event_map[16]; +}; + +static int cst816x_parse_dt_event_map(struct device *dev, + struct cst816x_priv *priv) +{ + struct device_node *np = dev->of_node; + struct device_node *ts, *child; + u32 gesture, code; + u8 index; + + ts = of_get_child_by_name(np, "touchscreen"); + if (!ts) + return -ENOENT; + + for_each_child_of_node(ts, child) { + if (of_property_read_u32(child, "cst816x,gesture", &gesture)) + continue; + + if (of_property_read_u32(child, "linux,code", &code)) + continue; + + index = gesture & 0x0F; + + priv->event_map[index].gesture = gesture; + priv->event_map[index].code = code; + } + + return 0; +} + +static int cst816x_i2c_read_register(struct cst816x_priv *priv, u8 reg, + void *buf, size_t len) +{ + int rc; + struct i2c_msg xfer[] = { + { + .addr = priv->client->addr, + .flags = 0, + .buf = ®, + .len = sizeof(reg), + }, + { + .addr = priv->client->addr, + .flags = I2C_M_RD, + .buf = buf, + .len = len, + }, + }; + + rc = i2c_transfer(priv->client->adapter, xfer, ARRAY_SIZE(xfer)); + if (rc != ARRAY_SIZE(xfer)) { + rc = rc < 0 ? rc : -EIO; + dev_err(&priv->client->dev, "i2c rx err: %d\n", rc); + return rc; + } + + return 0; +} + +static bool cst816x_process_touch(struct cst816x_priv *priv, + struct cst816x_touch_info *info) +{ + if (cst816x_i2c_read_register(priv, CST816X_FRAME, info, sizeof(*info))) + return false; + + info->abs_x = get_unaligned_be16(&info->abs_x) & GENMASK(11, 0); + info->abs_y = get_unaligned_be16(&info->abs_y) & GENMASK(11, 0); + + dev_dbg(&priv->client->dev, "x: %d, y: %d, t: %d, g: 0x%x\n", + info->abs_x, info->abs_y, info->touch, info->gesture); + + return true; +} + +static int cst816x_register_input(struct cst816x_priv *priv) +{ + int i; + priv->input = devm_input_allocate_device(&priv->client->dev); + if (!priv->input) + return -ENOMEM; + + priv->input->name = "Hynitron CST816X Touchscreen"; + priv->input->phys = "input/ts"; + priv->input->id.bustype = BUS_I2C; + input_set_drvdata(priv->input, priv); + + + for (i = 0; i < ARRAY_SIZE(priv->event_map); i++) + input_set_capability(priv->input, EV_KEY, + priv->event_map[i].code); + + input_set_abs_params(priv->input, ABS_X, 0, 240, 0, 0); + input_set_abs_params(priv->input, ABS_Y, 0, 240, 0, 0); + + return input_register_device(priv->input); +} + +static void cst816x_reset(struct cst816x_priv *priv) +{ + gpiod_set_value_cansleep(priv->reset, 1); + msleep(50); + gpiod_set_value_cansleep(priv->reset, 0); + msleep(100); +} + +static irqreturn_t cst816x_irq_cb(int irq, void *cookie) +{ + struct cst816x_priv *priv = cookie; + struct cst816x_touch_info info; + + if (!cst816x_process_touch(priv, &info)) + return IRQ_HANDLED; + + if (info.touch) { + input_report_abs(priv->input, ABS_X, info.abs_x); + input_report_abs(priv->input, ABS_Y, info.abs_y); + input_report_key(priv->input, BTN_TOUCH, 1); + } + + if (info.gesture) { + input_report_key(priv->input, + priv->event_map[info.gesture & 0x0F].code, + info.touch); + + if (!info.touch) + input_report_key(priv->input, BTN_TOUCH, 0); + } + + input_sync(priv->input); + + return IRQ_HANDLED; +} + +static int cst816x_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct cst816x_priv *priv; + struct device *dev = &client->dev; + int error; + (void)id; + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->client = client; + + priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(priv->reset)) + return dev_err_probe(dev, PTR_ERR(priv->reset), + "gpio reset request failed\n"); + + if (priv->reset) + cst816x_reset(priv); + + error = cst816x_parse_dt_event_map(dev, priv); + if (error) + dev_warn(dev, "no gestures specified in dt\n"); + + error = cst816x_register_input(priv); + if (error) + return dev_err_probe(dev, error, "input register failed\n"); + + error = devm_request_threaded_irq(dev, client->irq, NULL, cst816x_irq_cb, + IRQF_ONESHOT, dev->driver->name, priv); + if (error) + return dev_err_probe(dev, error, "irq request failed\n"); + + return 0; +} + +static const struct i2c_device_id cst816x_id[] = { + { .name = "cst816s", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, cst816x_id); + +static const struct of_device_id cst816x_of_match[] = { + { .compatible = "hynitron,cst816s", }, + { } +}; +MODULE_DEVICE_TABLE(of, cst816x_of_match); + +static struct i2c_driver cst816x_driver = { + .driver = { + .name = "cst816x", + .of_match_table = cst816x_of_match, + }, + .id_table = cst816x_id, + .probe = cst816x_probe, +}; + +module_i2c_driver(cst816x_driver); + +MODULE_AUTHOR("Oleh Kuzhylnyi "); +MODULE_DESCRIPTION("Hynitron CST816X Touchscreen Driver"); +MODULE_LICENSE("GPL"); diff --git a/cst816x-driver-main/hynitron-cst816x.ko b/cst816x-driver-main/hynitron-cst816x.ko new file mode 100644 index 0000000..b62a994 Binary files /dev/null and b/cst816x-driver-main/hynitron-cst816x.ko differ diff --git a/cst816x-driver-main/pictures/cst816s-ts.jpg b/cst816x-driver-main/pictures/cst816s-ts.jpg new file mode 100644 index 0000000..fa424af Binary files /dev/null and b/cst816x-driver-main/pictures/cst816s-ts.jpg differ diff --git a/cst816x-driver-main/pictures/cst816s-ts.png b/cst816x-driver-main/pictures/cst816s-ts.png new file mode 100644 index 0000000..208e56e Binary files /dev/null and b/cst816x-driver-main/pictures/cst816s-ts.png differ diff --git a/cst816x-driver-main/rpi4b/hynitron-cst816s.dts b/cst816x-driver-main/rpi4b/hynitron-cst816s.dts new file mode 100644 index 0000000..8d867d3 --- /dev/null +++ b/cst816x-driver-main/rpi4b/hynitron-cst816s.dts @@ -0,0 +1,49 @@ +/dts-v1/; +/plugin/; + +/ { + fragment@0 { + target = <&i2c1>; + __overlay__ { + cst816s: cst816s@15 { + compatible = "hynitron,cst816s"; + reg = <0x15>; + interrupt-parent = <&gpio>; + interrupts = <4 1>; /* IRQF_TRIGGER_RISING */ + reset-gpios = <&gpio 17 1>; /* GPIO_ACTIVE_LOW */ + + touchscreen { + swipe_up { + cst816x,gesture = <0x1>; + linux,code = <0x115>; // BTN_FORWARD + }; + + swipe_down { + cst816x,gesture = <0x2>; + linux,code = <0x116>; // BTN_BACK + }; + + swipe_left { + cst816x,gesture = <0x3>; + linux,code = <0x110>; // BTN_LEFT + }; + + swipe_right { + cst816x,gesture = <0x4>; + linux,code = <0x111>; // BTN_RIGHT + }; + + single_tap { + cst816x,gesture = <0x5>; + linux,code = <0x14A>; // BTN_TOUCH + }; + + long_press { + cst816x,gesture = <0xC>; + linux,code = <0x14E>; // BTN_TOOL_TRIPLETAP + }; + }; + }; + }; + }; +}; diff --git a/device_tree/Makefile b/device_tree/Makefile new file mode 100644 index 0000000..2a07ceb --- /dev/null +++ b/device_tree/Makefile @@ -0,0 +1,15 @@ +KERNEL_DIR=../../kernel/ + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := get_dts_info.o +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + +.PHONE:clean + +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + diff --git a/device_tree/README.txt b/device_tree/README.txt new file mode 100644 index 0000000..c87586c --- /dev/null +++ b/device_tree/README.txt @@ -0,0 +1 @@ +设备树获取节点属性实验 diff --git a/device_tree/get_dts_info.c b/device_tree/get_dts_info.c new file mode 100644 index 0000000..fa15d78 --- /dev/null +++ b/device_tree/get_dts_info.c @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2022 - All Rights Reserved by + * EmbedFire LubanCat +*/ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +struct device_node *led_test_device_node; //设备树节点 +struct device_node *led_device_node; //节点 +struct property *led_property; //定义属性结构体指针 +int size = 0 ; +unsigned int out_values[18]; //保存读取得到 属性值 + +static const struct of_device_id of_gpio_leds_match[] = { + {.compatible = "get_dts_info_test"}, + {}, +}; + +static int get_dts_info_probe(struct platform_device *pdev) +{ + int error_status = -1; + pr_info("%s\n",__func__); + + /*获取DTS属性信息*/ + led_test_device_node = of_find_node_by_path("/get_dts_info_test"); + if(led_test_device_node == NULL) + { + printk(KERN_ALERT "get led_device_node failed ! \n"); + return -1; + } + + /*根据 led_test_device_node 设备节点结构体输出节点的基本信息*/ + printk(KERN_ALERT "name: %s",led_test_device_node->name); //输出节点名 + printk(KERN_ALERT "child name: %s",led_test_device_node->child->name); //输出子节点的节点名 + + + /*获取 led_device_node 的子节点*/ + led_device_node = of_get_next_child(led_test_device_node,NULL); + if(led_device_node == NULL) + { + printk(KERN_ALERT "\n get led_device_node failed ! \n"); + return -1; + } + printk(KERN_ALERT "name: %s",led_device_node->name); //输出节点名 + printk(KERN_ALERT "parent name: %s",led_device_node->parent->name); //输出父节点的节点名 + + + /*获取 led_device_node 节点 的"compatible" 属性 */ + led_property = of_find_property(led_device_node,"compatible",&size); + if(led_property == NULL) + { + printk(KERN_ALERT "get led_property failed ! \n"); + return -1; + } + printk(KERN_ALERT "size = : %d",size); //实际读取得到的长度 + printk(KERN_ALERT "name: %s",led_property->name); //输出属性名 + printk(KERN_ALERT "length: %d",led_property->length); //输出属性长度 + printk(KERN_ALERT "value : %s",(char*)led_property->value); //属性值 + + + /*获取 reg 地址属性*/ + error_status = of_property_read_u32_array(led_device_node,"reg",out_values, 2); + if(error_status != 0) + { + printk(KERN_ALERT "get out_values failed ! \n"); + return -1; + } + printk(KERN_ALERT"0x%08X ", out_values[0]); + printk(KERN_ALERT"0x%08X ", out_values[1]); + + return 0; +} + +static int get_dts_info_remove(struct platform_device *pdev) +{ + pr_info("%s\n",__func__); + return 0; +} + +static struct platform_driver get_dts_info_driver = { + .probe = get_dts_info_probe, + .remove = get_dts_info_remove, + .driver = { + .name = "get_dts_info_test", + .of_match_table = of_match_ptr(of_gpio_leds_match), + }, +}; + +module_platform_driver(get_dts_info_driver); + + +MODULE_DESCRIPTION("平台驱动:一个简单获取设备树属性的实验"); +MODULE_LICENSE("GPL"); + diff --git a/device_tree/rk3568-lubancat2.dts b/device_tree/rk3568-lubancat2.dts new file mode 100644 index 0000000..4e44708 --- /dev/null +++ b/device_tree/rk3568-lubancat2.dts @@ -0,0 +1,1259 @@ +/* + * Copyright (C) 2022 - All Rights Reserved by + * EmbedFire LubanCat + */ + +/dts-v1/; + +#include +#include +#include +#include +#include +#include +#include "rk3568.dtsi" + +/ { + model = "EmbedFire LubanCat2 HDMI"; + compatible = "embedfire,lubancat2", "rockchip,rk3568"; + + chosen: chosen { + bootargs = "earlycon=uart8250,mmio32,0xfe660000 console=ttyFIQ0 root=PARTUUID=614e0000-0000 rw rootwait"; + }; + + fiq-debugger { + compatible = "rockchip,fiq-debugger"; + rockchip,serial-id = <2>; + rockchip,wake-irq = <0>; + /* If enable uart uses irq instead of fiq */ + rockchip,irq-mode-enable = <1>; + rockchip,baudrate = <1500000>; /* Only 115200 and 1500000 */ + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&uart2m0_xfer>; + status = "okay"; + }; + + debug: debug@fd904000 { + compatible = "rockchip,debug"; + reg = <0x0 0xfd904000 0x0 0x1000>, + <0x0 0xfd905000 0x0 0x1000>, + <0x0 0xfd906000 0x0 0x1000>, + <0x0 0xfd907000 0x0 0x1000>; + }; + + cspmu: cspmu@fd90c000 { + compatible = "rockchip,cspmu"; + reg = <0x0 0xfd90c000 0x0 0x1000>, + <0x0 0xfd90d000 0x0 0x1000>, + <0x0 0xfd90e000 0x0 0x1000>, + <0x0 0xfd90f000 0x0 0x1000>; + }; + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + ramoops: ramoops@110000 { + compatible = "ramoops"; + reg = <0x0 0x110000 0x0 0xf0000>; + record-size = <0x20000>; + console-size = <0x80000>; + ftrace-size = <0x00000>; + pmsg-size = <0x50000>; + }; + + abc: abc@80900000{ + reg = <0x0 0x80900000 0x0 0x100000>; + }; + }; + + adc_keys: adc-keys { + compatible = "adc-keys"; + io-channels = <&saradc 0>; + io-channel-names = "buttons"; + keyup-threshold-microvolt = <1800000>; + poll-interval = <100>; + + restart-key { + label = "restart"; + linux,code = ; + press-threshold-microvolt = <9>; + }; + }; + + dc_5v: dc-5v { + compatible = "regulator-fixed"; + regulator-name = "dc_5v"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + + vcc5v0_sys: vcc5v0-sys { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_sys"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&dc_5v>; + }; + + vcc3v3_sys: vcc3v3-sys { + compatible = "regulator-fixed"; + regulator-name = "vcc3v3_sys"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vcc5v0_sys>; + }; + + vcc5v0_usb20_host: vcc5v0-usb20-host-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio0 RK_PD5 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&vcc5v0_usb20_host_en>; + regulator-name = "vcc5v0_usb20_host"; + regulator-always-on; + }; + + vcc5v0_usb30_host: vcc5v0-usb30-host-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&vcc5v0_usb30_host_en>; + regulator-name = "vcc5v0_usb30_host"; + regulator-always-on; + }; + + vcc5v0_otg_vbus: vcc5v0-otg-vbus-regulator { + compatible = "regulator-fixed"; + enable-active-high; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio0 RK_PD3 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&vcc5v0_otg_vbus_en>; + regulator-name = "vcc5v0_otg_vbus"; + }; + + mini_pcie_3v3: mini-pcie-3v3-regulator { + compatible = "regulator-fixed"; + regulator-name = "minipcie_3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + enable-active-high; + regulator-always-on; + gpio = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>; + startup-delay-us = <5000>; + vin-supply = <&vcc5v0_sys>; + }; + + pcie30_3v3: gpio-regulator { + compatible = "regulator-gpio"; + regulator-name = "pcie30_3v3"; + regulator-min-microvolt = <100000>; + regulator-max-microvolt = <3300000>; + gpios = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>; + gpios-states = <0x1>; + states = <100000 0x0 + 3300000 0x1>; + }; + + mipi_dsi0_lcd_power: mipi-dsi0-lcd-power-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio3 RK_PA3 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&mipi_dsi0_lcd_pwr_en>; + regulator-name = "mipi_dsi0_lcd_power"; + regulator-always-on; + }; + + vdd_cam_5v: vdd-cam-5v-regulator { + compatible = "regulator-fixed"; + regulator-name = "vdd_cam_5v"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + gpio = <&gpio3 RK_PA4 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&cam_pwr_en>; + enable-active-high; + regulator-always-on; + }; + + cam_dovdd: cam-dovdd { + compatible = "regulator-fixed"; + regulator-name = "cam0_dovdd"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vdd_cam_5v>; + }; + + cam_avdd: cam-avdd { + compatible = "regulator-fixed"; + regulator-name = "cam0_avdd"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + vin-supply = <&vdd_cam_5v>; + }; + + cam_dvdd: cam-dvdd { + compatible = "regulator-fixed"; + regulator-name = "cam0_dvdd"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + vin-supply = <&vdd_cam_5v>; + }; + + leds: leds { + //status = "disabled"; + status = "okay"; + compatible = "gpio-leds"; + + sys_status_led: sys-status-led { + label = "sys_status_led"; + linux,default-trigger = "heartbeat"; + default-state = "on"; + gpios = <&gpio0 RK_PC7 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&sys_status_led_pin>; + }; + }; + + get_dts_info_test: get_dts_info_test{ + compatible = "get_dts_info_test"; + #address-cells = <1>; + #size-cells = <1>; + + led@0xfdd60000{//GPIO0_ fdd60000 GPIO4_ fe770000 + compatible = "fire,led_test"; + reg = <0xfdd60000 0x00000100>; + status = "okay"; + }; + }; + + rk809_sound: rk809-sound { + status = "okay"; + compatible = "simple-audio-card"; + simple-audio-card,format = "i2s"; + simple-audio-card,name = "rockchip,rk809-codec"; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphone Jack"; + simple-audio-card,routing = + "Mic Jack", "MICBIAS1", + "IN1P", "Mic Jack", + "Headphone Jack", "HPOL", + "Headphone Jack", "HPOR"; + simple-audio-card,cpu { + sound-dai = <&i2s1_8ch>; + }; + simple-audio-card,codec { + sound-dai = <&rk809_codec>; + }; + }; + + rk_headset: rk-headset { + status = "okay"; + compatible = "rockchip_headset"; + headset_gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&hp_det>; + io-channels = <&saradc 1>; + }; + + ext_cam_clk: external-camera-clock { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24000000>; + clock-output-names = "CLK_CAMERA1_24MHZ"; + }; + + backlight: backlight { + status = "okay"; + compatible = "pwm-backlight"; + pwms = <&pwm4 0 50000 0>; + brightness-levels = < + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 88 89 90 91 92 93 94 95 + 96 97 98 99 100 101 102 103 + 104 105 106 107 108 109 110 111 + 112 113 114 115 116 117 118 119 + 120 121 122 123 124 125 126 127 + 128 129 130 131 132 133 134 135 + 136 137 138 139 140 141 142 143 + 144 145 146 147 148 149 150 151 + 152 153 154 155 156 157 158 159 + 160 161 162 163 164 165 166 167 + 168 169 170 171 172 173 174 175 + 176 177 178 179 180 181 182 183 + 184 185 186 187 188 189 190 191 + 192 193 194 195 196 197 198 199 + 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 + 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 + 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 + 248 249 250 251 252 253 254 255 + >; + default-brightness-level = <200>; + }; +}; + +&saradc { + vref-supply = <&vcca_1v8>; + status = "okay"; +}; + +&tsadc { + status = "okay"; +}; + +&i2s1_8ch { + status = "okay"; + rockchip,clk-trcm = <1>; + /delete-property/ rockchip,playback-only; + pinctrl-names = "default"; + pinctrl-0 = <&i2s1m0_sclktx + &i2s1m0_lrcktx + &i2s1m0_sdi0 + &i2s1m0_sdo0>; +}; + +&pwm4 { + status = "okay"; +}; + +&pwm7 { + status = "okay"; + + compatible = "rockchip,remotectl-pwm"; + remote_pwm_id = <3>; + handle_cpu_id = <1>; + remote_support_psci = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pwm7_pins>; + + ir_key_lubancat{ + rockchip,usercode = <0xff00>; + rockchip,key_table = + <0xeb KEY_POWER>, + <0xec KEY_MENU>, + <0xfe KEY_BACK>, + <0xb7 KEY_HOME>, + <0xa3 KEY_WWW>, + <0xf4 KEY_VOLUMEUP>, + <0xa7 KEY_VOLUMEDOWN>, + <0xf8 KEY_REPLY>, + <0xfc KEY_UP>, + <0xfd KEY_DOWN>, + <0xf1 KEY_LEFT>, + <0xe5 KEY_RIGHT>; + }; +}; + +&cpu0 { + cpu-supply = <&vdd_cpu>; +}; + +&dfi { + status = "okay"; +}; + +&dmc { + system-status-freq = < + /*system status freq(KHz)*/ + SYS_STATUS_NORMAL 780000 + SYS_STATUS_REBOOT 1560000 + SYS_STATUS_SUSPEND 324000 + SYS_STATUS_VIDEO_1080P 528000 + SYS_STATUS_BOOST 1560000 + SYS_STATUS_ISP 1560000 + SYS_STATUS_PERFORMANCE 1560000 + >; + center-supply = <&vdd_logic>; + status = "okay"; +}; + +&dmc_opp_table { + opp-324000000 { + opp-hz = /bits/ 64 <324000000>; + opp-microvolt = <875000>; + opp-microvolt-L0 = <875000>; + opp-microvolt-L1 = <850000>; + }; + + opp-528000000 { + opp-hz = /bits/ 64 <528000000>; + opp-microvolt = <875000>; + opp-microvolt-L0 = <875000>; + opp-microvolt-L1 = <850000>; + }; + + opp-528000000 { + opp-hz = /bits/ 64 <780000000>; + opp-microvolt = <875000>; + opp-microvolt-L0 = <875000>; + opp-microvolt-L1 = <850000>; + }; + + opp-1560000000 { + opp-hz = /bits/ 64 <1560000000>; + opp-microvolt = <900000>; + opp-microvolt-L0 = <900000>; + opp-microvolt-L1 = <850000>; + }; +}; + +&gpu { + mali-supply = <&vdd_gpu>; + status = "okay"; +}; + +&xin32k { + status = "disabled"; +}; + +&i2c0 { + status = "okay"; + + vdd_cpu: tcs4525@1c { + compatible = "tcs,tcs452x"; + reg = <0x1c>; + vin-supply = <&vcc5v0_sys>; + regulator-compatible = "fan53555-reg"; + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <712500>; + regulator-max-microvolt = <1390000>; + regulator-ramp-delay = <2300>; + fcs,suspend-voltage-selector = <1>; + regulator-boot-on; + regulator-always-on; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; +/* + vdd_cpu: syr827@40 { + compatible = "silergy,syr827"; + reg = <0x40>; + fcs,suspend-voltage-selector = <1>; + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <712500>; + regulator-max-microvolt = <1390000>; + regulator-ramp-delay = <2300>; + regulator-always-on; + regulator-boot-on; + vin-supply = <&vcc5v0_sys>; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; +*/ + rk809: pmic@20 { + compatible = "rockchip,rk809"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + + pinctrl-names = "default", "pmic-sleep", + "pmic-power-off", "pmic-reset"; + pinctrl-0 = <&pmic_int>; + pinctrl-1 = <&soc_slppin_slp>, <&rk817_slppin_slp>; + pinctrl-2 = <&soc_slppin_gpio>, <&rk817_slppin_pwrdn>; + pinctrl-3 = <&soc_slppin_gpio>, <&rk817_slppin_rst>; + + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + clock-output-names = "rk808-clkout1", "rk808-clkout2"; + //fb-inner-reg-idxs = <2>; + /* 1: rst regs (default in codes), 0: rst the pmic */ + pmic-reset-func = <0>; + /* not save the PMIC_POWER_EN register in uboot */ + not-save-power-en = <1>; + + vcc1-supply = <&vcc3v3_sys>; + vcc2-supply = <&vcc3v3_sys>; + vcc3-supply = <&vcc3v3_sys>; + vcc4-supply = <&vcc3v3_sys>; + vcc5-supply = <&vcc3v3_sys>; + vcc6-supply = <&vcc3v3_sys>; + vcc7-supply = <&vcc3v3_sys>; + vcc8-supply = <&vcc3v3_sys>; + vcc9-supply = <&vcc3v3_sys>; + + pwrkey { + status = "okay"; + }; + + pinctrl_rk8xx: pinctrl_rk8xx { + gpio-controller; + #gpio-cells = <2>; + + rk817_slppin_null: rk817_slppin_null { + pins = "gpio_slp"; + function = "pin_fun0"; + }; + + rk817_slppin_slp: rk817_slppin_slp { + pins = "gpio_slp"; + function = "pin_fun1"; + }; + + rk817_slppin_pwrdn: rk817_slppin_pwrdn { + pins = "gpio_slp"; + function = "pin_fun2"; + }; + + rk817_slppin_rst: rk817_slppin_rst { + pins = "gpio_slp"; + function = "pin_fun3"; + }; + }; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1350000>; + regulator-init-microvolt = <900000>; + regulator-ramp-delay = <6001>; + regulator-initial-mode = <0x2>; + regulator-name = "vdd_logic"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vdd_gpu: DCDC_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1350000>; + regulator-init-microvolt = <900000>; + regulator-ramp-delay = <6001>; + regulator-initial-mode = <0x2>; + regulator-name = "vdd_gpu"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-initial-mode = <0x2>; + regulator-name = "vcc_ddr"; + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vdd_npu: DCDC_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1350000>; + regulator-init-microvolt = <900000>; + regulator-ramp-delay = <6001>; + regulator-initial-mode = <0x2>; + regulator-name = "vdd_npu"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vdda0v9_image: LDO_REG1 { + regulator-boot-on; + regulator-always-on; + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <900000>; + regulator-name = "vdda0v9_image"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vdda_0v9: LDO_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <900000>; + regulator-name = "vdda_0v9"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vdda0v9_pmu: LDO_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <900000>; + regulator-name = "vdda0v9_pmu"; + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <900000>; + }; + }; + + vccio_acodec: LDO_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_acodec"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_sd"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc3v3_pmu: LDO_REG6 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc3v3_pmu"; + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcca_1v8: LDO_REG7 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcca_1v8"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcca1v8_pmu: LDO_REG8 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcca1v8_pmu"; + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vcca1v8_image: LDO_REG9 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcca1v8_image"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_1v8: DCDC_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc_1v8"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_3v3: SWITCH_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_3v3"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc3v3_sd: SWITCH_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc3v3_sd"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + }; + + rk809_codec: codec { + #sound-dai-cells = <0>; + compatible = "rockchip,rk809-codec", "rockchip,rk817-codec"; + clocks = <&cru I2S1_MCLKOUT_TX>; + clock-names = "mclk"; + assigned-clocks = <&cru I2S1_MCLKOUT_TX>, <&cru I2S1_MCLK_TX_IOE>; + assigned-clock-rates = <12288000>; + assigned-clock-parents = <&cru CLK_I2S1_8CH_TX>, <&cru I2S1_MCLKOUT_TX>; + pinctrl-names = "default"; + pinctrl-0 = <&i2s1m0_mclk>; + hp-volume = <20>; + spk-volume = <3>; + //mic-in-differential; + status = "okay"; + }; + }; +}; + +&iep { + status = "okay"; +}; + +&iep_mmu { + status = "okay"; +}; + +&jpegd { + status = "okay"; +}; + +&jpegd_mmu { + status = "okay"; +}; + +&mpp_srv { + status = "okay"; +}; + +&pmu_io_domains { + status = "okay"; + pmuio1-supply = <&vcc3v3_pmu>; + pmuio2-supply = <&vcc3v3_pmu>; + vccio1-supply = <&vccio_acodec>; + vccio3-supply = <&vccio_sd>; + vccio4-supply = <&vcc_1v8>; + vccio5-supply = <&vcc_3v3>; + vccio6-supply = <&vcc_1v8>; + vccio7-supply = <&vcc_3v3>; +}; + +&rk_rga { + status = "okay"; +}; + +&rkvdec { + status = "okay"; +}; + +&rkvdec_mmu { + status = "okay"; +}; + +&rkvenc { + venc-supply = <&vdd_logic>; + status = "okay"; +}; + +&rkvenc_mmu { + status = "okay"; +}; + +&rknpu { + rknpu-supply = <&vdd_npu>; + status = "okay"; +}; + +&rknpu_mmu { + status = "okay"; +}; + +&bus_npu { + bus-supply = <&vdd_logic>; + pvtm-supply = <&vdd_cpu>; + status = "okay"; +}; + +&sdhci { + bus-width = <8>; + supports-emmc; + non-removable; + max-frequency = <200000000>; + status = "okay"; +}; + +&sdmmc0 { + max-frequency = <150000000>; + supports-sd; + bus-width = <4>; + cap-mmc-highspeed; + cap-sd-highspeed; + disable-wp; + sd-uhs-sdr104; + vmmc-supply = <&vcc3v3_sd>; + vqmmc-supply = <&vccio_sd>; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>; + status = "okay"; +}; + +&vdpu { + status = "okay"; +}; + +&vdpu_mmu { + status = "okay"; +}; + +&vepu { + status = "okay"; +}; + +&vepu_mmu { + status = "okay"; +}; + +&vop { + status = "okay"; + assigned-clocks = <&cru DCLK_VOP0>, <&cru DCLK_VOP1>; + assigned-clock-parents = <&pmucru PLL_HPLL>, <&cru PLL_VPLL>; +}; + +&vop_mmu { + status = "okay"; +}; + +&rng { + status = "okay"; +}; + +&rockchip_suspend { + status = "okay"; +}; + +&vop { + disable-win-move; +}; + +/* USB OTG/USB Host_1 USB 2.0 Comb */ +&usb2phy0 { + status = "okay"; +}; + +&u2phy0_host { + phy-supply = <&vcc5v0_usb30_host>; + status = "okay"; +}; + +&u2phy0_otg { + vbus-supply = <&vcc5v0_otg_vbus>; + status = "okay"; +}; + +&usb_host0_ehci { + status = "okay"; +}; + +&usb_host0_ohci { + status = "okay"; +}; + +/* USB Host_2/USB Host_3 USB 2.0 Comb */ +&usb2phy1 { + status = "okay"; +}; + +&u2phy1_otg { + phy-supply = <&vcc5v0_usb20_host>; + status = "okay"; +}; + +&u2phy1_host { + status = "okay"; +}; + +&usb_host1_ehci { + status = "okay"; +}; + +&usb_host1_ohci { + status = "okay"; +}; + +/* MULTI_PHY0 For SATA0, USB3.0 OTG Only USB2.0 */ +&combphy0_us { + status = "okay"; +}; + +&usbdrd30 { + status = "okay"; +}; + +&usbdrd_dwc3 { + phys = <&u2phy0_otg>; + phy-names = "usb2-phy"; + extcon = <&usb2phy0>; + maximum-speed = "high-speed"; + snps,dis_u2_susphy_quirk; + status = "okay"; +}; + +&sata0 { + status = "okay"; +}; + +/* USB3.0 Host */ +&combphy1_usq { + status = "okay"; +}; + +&usbhost30 { + status = "okay"; +}; + +&usbhost_dwc3 { + status = "okay"; +}; + +&gmac0 { + phy-mode = "rgmii"; + clock_in_out = "output"; + + snps,reset-gpio = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>; + snps,reset-active-low; + /* Reset time is 20ms, 100ms for rtl8211f */ + snps,reset-delays-us = <0 20000 100000>; + + assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>; + assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>, <&cru CLK_MAC0_2TOP>; + + pinctrl-names = "default"; + pinctrl-0 = <&gmac0_miim + &gmac0_tx_bus2 + &gmac0_rx_bus2 + &gmac0_rgmii_clk + &gmac0_rgmii_bus>; + + tx_delay = <0x22>; + rx_delay = <0x0e>; + + phy-handle = <&rgmii_phy0>; + status = "okay"; +}; + +&mdio0 { + rgmii_phy0: phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x0>; + }; +}; + +&gmac1 { + phy-mode = "rgmii"; + clock_in_out = "output"; + + snps,reset-gpio = <&gpio3 RK_PA2 GPIO_ACTIVE_LOW>; + snps,reset-active-low; + /* Reset time is 20ms, 100ms for rtl8211f */ + snps,reset-delays-us = <0 20000 100000>; + + assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>; + assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru CLK_MAC1_2TOP>; + + pinctrl-names = "default"; + pinctrl-0 = <&gmac1m1_miim + &gmac1m1_tx_bus2 + &gmac1m1_rx_bus2 + &gmac1m1_rgmii_clk + &gmac1m1_rgmii_bus>; + + tx_delay = <0x21>; + rx_delay = <0x0e>; + + phy-handle = <&rgmii_phy1>; + status = "okay"; +}; + +&mdio1 { + rgmii_phy1: phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x0>; + }; +}; + +&pcie30phy { + status = "okay"; +}; + +&pcie3x2 { + reset-gpios = <&gpio2 RK_PD6 GPIO_ACTIVE_HIGH>; + vpcie3v3-supply = <&pcie30_3v3>; + status = "okay"; +}; + +/* mini pcie */ +&pcie2x1 { + reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_HIGH>; + disable-gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_HIGH>; + vpcie3v3-supply = <&mini_pcie_3v3>; + status = "okay"; +}; + +&combphy2_psq { + status = "okay"; +}; + +&route_hdmi { + //status = "okay"; + status = "disabled"; + connect = <&vp0_out_hdmi>; +}; + +&hdmi_in_vp0 { + status = "disabled"; + //status = "okay"; +}; + +&hdmi_in_vp1 { + status = "disabled"; +}; + +&hdmi { + //status = "okay"; + status = "disabled"; +}; + +&i2c1 { + status = "okay"; + clock-frequency = <100000>; + goodix_ts@5d { + status = "okay"; + compatible = "goodix,gt911"; + reg = <0x5d>; + interrupt-parent = <&gpio0>; + interrupts = ; + reset-gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>; + irq-gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>; + }; + + dw9714: dw9714@0c { + status = "okay"; + compatible = "dongwoon,dw9714"; + reg = <0x0c>; + rockchip,camera-module-index = <0>; + rockchip,vcm-max-current = <100>; + rockchip,vcm-start-current = <0>; + rockchip,vcm-rated-current = <100>; + rockchip,vcm-step-mode = <0xd>; + rockchip,vcm-dlc-enable = <0>; + rockchip,vcm-mclk = <0>; + rockchip,vcm-t-src = <0>; + rockchip,camera-module-facing = "back"; + }; + + ov5648: camera@36 { + compatible = "ovti,ov5648"; + reg = <0x36>; + clocks = <&ext_cam_clk>; + clock-names = "xvclk"; + dovdd-supply= <&cam_dovdd>; /* 1.8v */ + avdd-supply = <&cam_avdd>; /* 2.8v */ + dvdd-supply = <&cam_dvdd>; /* 1.5v */ + pwdn-gpios = <&gpio0 RK_PC0 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_LOW>; + rotation = <180>; + status = "okay"; + + rockchip,camera-module-index = <0>; + rockchip,camera-module-facing = "back"; + rockchip,camera-module-name = "THDS11073"; + rockchip,camera-module-lens-name = "Largan-40122a1"; + lens-focus = <&dw9714>; + + port { + /* MIPI CSI-2 bus endpoint */ + cam0_ov5648_out: endpoint { + remote-endpoint = <&dphy1_in>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; +}; + +&csi2_dphy_hw { + status = "okay"; +}; + +&csi2_dphy1 { + status = "okay"; + /* + * dphy1 only used for split mode, + * can be used concurrently with dphy2 + * full mode and split mode are mutually exclusive + */ + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + dphy1_in: endpoint@1 { + reg = <1>; + remote-endpoint = <&cam0_ov5648_out>; + data-lanes = <1 2>; + }; + }; + + port@1 { + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + dphy1_out: endpoint@1 { + reg = <1>; + remote-endpoint = <&isp0_in>; + }; + }; + }; +}; + +&rkisp { + status = "okay"; +}; + +&rkisp_mmu { + status = "okay"; +}; + +&rkisp_vir0 { + status = "okay"; + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + isp0_in: endpoint@0 { + reg = <0>; + remote-endpoint = <&dphy1_out>; + }; + }; + }; +}; + +&pinctrl { + pmic { + pmic_int: pmic_int { + rockchip,pins = + <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = + <0 RK_PA2 RK_FUNC_GPIO &pcfg_output_low_pull_down>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = + <0 RK_PA2 RK_FUNC_1 &pcfg_pull_up>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = + <0 RK_PA2 RK_FUNC_2 &pcfg_pull_none>; + }; + + spk_ctl_gpio: spk_ctl_gpio { + rockchip,pins = <3 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + headphone { + hp_det: hp-det { + rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + usb { + vcc5v0_usb20_host_en: vcc5v0-usb20-host-en { + rockchip,pins = <0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + vcc5v0_usb30_host_en: vcc5v0-usb30-host-en { + rockchip,pins = <0 RK_PD6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + vcc5v0_otg_vbus_en: vcc5v0-otg-vbus-en { + rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + spi { + spi3_cs0: spi3-cs0 { + rockchip,pins = <4 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up_drv_level_1>; + }; + + spi3_cs1: spi3-cs1 { + rockchip,pins = <4 RK_PC4 RK_FUNC_GPIO &pcfg_pull_up_drv_level_1>; + }; + }; + + lcd { + mipi_dsi0_lcd_pwr_en: mipi-dsi0-lcd-pwr-en { + rockchip,pins = <3 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + cam { + cam_pwr_en: cam-pwr-en { + rockchip,pins = <3 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + leds { + sys_status_led_pin: sys-status-led-pin { + rockchip,pins = <0 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; diff --git a/device_tree/rk3568.dtsi b/device_tree/rk3568.dtsi new file mode 100644 index 0000000..cd3d80f --- /dev/null +++ b/device_tree/rk3568.dtsi @@ -0,0 +1,3622 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2020 Rockchip Electronics Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rk3568-dram-default-timing.dtsi" + +/ { + compatible = "rockchip,rk3568"; + + interrupt-parent = <&gic>; + #address-cells = <2>; + #size-cells = <2>; + + aliases { + csi2dphy0 = &csi2_dphy0; + csi2dphy1 = &csi2_dphy1; + csi2dphy2 = &csi2_dphy2; + dsi0 = &dsi0; + dsi1 = &dsi1; + ethernet0 = &gmac0; + ethernet1 = &gmac1; + gpio0 = &gpio0; + gpio1 = &gpio1; + gpio2 = &gpio2; + gpio3 = &gpio3; + gpio4 = &gpio4; + i2c0 = &i2c0; + i2c1 = &i2c1; + i2c2 = &i2c2; + i2c3 = &i2c3; + i2c4 = &i2c4; + i2c5 = &i2c5; + mmc0 = &sdhci; + mmc1 = &sdmmc0; + mmc2 = &sdmmc1; + mmc3 = &sdmmc2; + serial0 = &uart0; + serial1 = &uart1; + serial2 = &uart2; + serial3 = &uart3; + serial4 = &uart4; + serial5 = &uart5; + serial6 = &uart6; + serial7 = &uart7; + serial8 = &uart8; + serial9 = &uart9; + spi0 = &spi0; + spi1 = &spi1; + spi2 = &spi2; + spi3 = &spi3; + spi4 = &sfc; // for U-Boot + }; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a55"; + reg = <0x0 0x0>; + enable-method = "psci"; + clocks = <&scmi_clk 0>; + operating-points-v2 = <&cpu0_opp_table>; + cpu-idle-states = <&CPU_SLEEP>; + #cooling-cells = <2>; + dynamic-power-coefficient = <187>; + }; + + cpu1: cpu@100 { + device_type = "cpu"; + compatible = "arm,cortex-a55"; + reg = <0x0 0x100>; + enable-method = "psci"; + clocks = <&scmi_clk 0>; + operating-points-v2 = <&cpu0_opp_table>; + cpu-idle-states = <&CPU_SLEEP>; + }; + + cpu2: cpu@200 { + device_type = "cpu"; + compatible = "arm,cortex-a55"; + reg = <0x0 0x200>; + enable-method = "psci"; + clocks = <&scmi_clk 0>; + operating-points-v2 = <&cpu0_opp_table>; + cpu-idle-states = <&CPU_SLEEP>; + }; + + cpu3: cpu@300 { + device_type = "cpu"; + compatible = "arm,cortex-a55"; + reg = <0x0 0x300>; + enable-method = "psci"; + clocks = <&scmi_clk 0>; + operating-points-v2 = <&cpu0_opp_table>; + cpu-idle-states = <&CPU_SLEEP>; + }; + + idle-states { + entry-method = "psci"; + CPU_SLEEP: cpu-sleep { + compatible = "arm,idle-state"; + local-timer-stop; + arm,psci-suspend-param = <0x0010000>; + entry-latency-us = <100>; + exit-latency-us = <120>; + min-residency-us = <1000>; + }; + }; + }; + + cpu0_opp_table: cpu0-opp-table { + compatible = "operating-points-v2"; + opp-shared; + + mbist-vmin = <825000 900000 950000>; + nvmem-cells = <&cpu_leakage>, <&core_pvtm>, <&mbist_vmin>; + nvmem-cell-names = "leakage", "pvtm", "mbist-vmin"; + rockchip,pvtm-voltage-sel = < + 0 84000 0 + 84001 91000 1 + 91001 100000 2 + >; + rockchip,pvtm-freq = <408000>; + rockchip,pvtm-volt = <900000>; + rockchip,pvtm-ch = <0 5>; + rockchip,pvtm-sample-time = <1000>; + rockchip,pvtm-number = <10>; + rockchip,pvtm-error = <1000>; + rockchip,pvtm-ref-temp = <40>; + rockchip,pvtm-temp-prop = <26 26>; + rockchip,thermal-zone = "soc-thermal"; + rockchip,temp-hysteresis = <5000>; + rockchip,low-temp = <0>; + rockchip,low-temp-adjust-volt = < + /* MHz MHz uV */ + 0 1608 75000 + >; + + opp-408000000 { + opp-hz = /bits/ 64 <408000000>; + opp-microvolt = <850000 850000 1150000>; + opp-microvolt-L0 = <850000 850000 1150000>; + opp-microvolt-L1 = <825000 825000 1150000>; + opp-microvolt-L2 = <825000 825000 1150000>; + clock-latency-ns = <40000>; + }; + opp-600000000 { + opp-hz = /bits/ 64 <600000000>; + opp-microvolt = <850000 825000 1150000>; + opp-microvolt-L0 = <850000 850000 1150000>; + opp-microvolt-L1 = <825000 825000 1150000>; + opp-microvolt-L2 = <825000 825000 1150000>; + clock-latency-ns = <40000>; + }; + opp-816000000 { + opp-hz = /bits/ 64 <816000000>; + opp-microvolt = <850000 850000 1150000>; + opp-microvolt-L0 = <850000 850000 1150000>; + opp-microvolt-L1 = <825000 825000 1150000>; + opp-microvolt-L2 = <825000 825000 1150000>; + clock-latency-ns = <40000>; + opp-suspend; + }; + opp-1104000000 { + opp-hz = /bits/ 64 <1104000000>; + opp-microvolt = <900000 900000 1150000>; + opp-microvolt-L0 = <900000 900000 1150000>; + opp-microvolt-L1 = <825000 825000 1150000>; + opp-microvolt-L2 = <825000 825000 1150000>; + clock-latency-ns = <40000>; + }; + opp-1416000000 { + opp-hz = /bits/ 64 <1416000000>; + opp-microvolt = <1000000 1000000 1150000>; + opp-microvolt-L0 = <1000000 1000000 1150000>; + opp-microvolt-L1 = <925000 925000 1150000>; + opp-microvolt-L2 = <925000 925000 1150000>; + clock-latency-ns = <40000>; + }; + opp-1608000000 { + opp-hz = /bits/ 64 <1608000000>; + opp-microvolt = <1075000 1075000 1150000>; + opp-microvolt-L0 = <1075000 1075000 1150000>; + opp-microvolt-L1 = <1000000 1000000 1150000>; + opp-microvolt-L2 = <1000000 1000000 1150000>; + clock-latency-ns = <40000>; + }; + opp-1800000000 { + opp-hz = /bits/ 64 <1800000000>; + opp-microvolt = <1125000 1125000 1150000>; + opp-microvolt-L0 = <1125000 1125000 1150000>; + opp-microvolt-L1 = <1050000 1050000 1150000>; + opp-microvolt-L2 = <1050000 1050000 1150000>; + clock-latency-ns = <40000>; + }; + opp-1992000000 { + opp-hz = /bits/ 64 <1992000000>; + opp-microvolt = <1150000 1150000 1150000>; + opp-microvolt-L0 = <1150000 1150000 1150000>; + opp-microvolt-L1 = <1100000 1100000 1150000>; + opp-microvolt-L2 = <1075000 1075000 1150000>; + clock-latency-ns = <40000>; + }; + }; + + arm-pmu { + compatible = "arm,cortex-a55-pmu", "arm,armv8-pmuv3"; + interrupts = , + , + , + ; + interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>; + }; + + cpuinfo { + compatible = "rockchip,cpuinfo"; + nvmem-cells = <&otp_id>, <&otp_cpu_version>, <&cpu_code>; + nvmem-cell-names = "id", "cpu-version", "cpu-code"; + }; + + display_subsystem: display-subsystem { + compatible = "rockchip,display-subsystem"; + memory-region = <&drm_logo>, <&drm_cubic_lut>; + memory-region-names = "drm-logo", "drm-cubic-lut"; + ports = <&vop_out>; + devfreq = <&dmc>; + + route { + route_dsi0: route-dsi0 { + status = "disabled"; + logo,uboot = "logo.bmp"; + logo,kernel = "logo_kernel.bmp"; + logo,mode = "center"; + charge_logo,mode = "center"; + connect = <&vp0_out_dsi0>; + }; + route_dsi1: route-dsi1 { + status = "disabled"; + logo,uboot = "logo.bmp"; + logo,kernel = "logo_kernel.bmp"; + logo,mode = "center"; + charge_logo,mode = "center"; + connect = <&vp0_out_dsi1>; + }; + route_edp: route-edp { + status = "disabled"; + logo,uboot = "logo.bmp"; + logo,kernel = "logo_kernel.bmp"; + logo,mode = "center"; + charge_logo,mode = "center"; + connect = <&vp0_out_edp>; + }; + route_hdmi: route-hdmi { + status = "disabled"; + logo,uboot = "logo.bmp"; + logo,kernel = "logo_kernel.bmp"; + logo,mode = "center"; + charge_logo,mode = "center"; + connect = <&vp1_out_hdmi>; + }; + route_lvds: route-lvds { + status = "disabled"; + logo,uboot = "logo.bmp"; + logo,kernel = "logo_kernel.bmp"; + logo,mode = "center"; + charge_logo,mode = "center"; + connect = <&vp1_out_lvds>; + }; + route_rgb: route-rgb { + status = "disabled"; + logo,uboot = "logo.bmp"; + logo,kernel = "logo_kernel.bmp"; + logo,mode = "center"; + charge_logo,mode = "center"; + connect = <&vp2_out_rgb>; + }; + }; + }; + + firmware { + optee: optee { + compatible = "linaro,optee-tz"; + method = "smc"; + }; + + scmi: scmi { + compatible = "arm,scmi-smc"; + shmem = <&scmi_shmem>; + arm,smc-id = <0x82000010>; + #address-cells = <1>; + #size-cells = <0>; + + scmi_clk: protocol@14 { + reg = <0x14>; + #clock-cells = <1>; + + rockchip,clk-init = <1416000000>; + }; + }; + + sdei: sdei { + compatible = "arm,sdei-1.0"; + method = "smc"; + }; + }; + + mpp_srv: mpp-srv { + compatible = "rockchip,mpp-service"; + rockchip,taskqueue-count = <6>; + rockchip,resetgroup-count = <6>; + status = "disabled"; + }; + + psci { + compatible = "arm,psci-1.0"; + method = "smc"; + }; + + reserved_memory: reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + drm_logo: drm-logo@00000000 { + compatible = "rockchip,drm-logo"; + reg = <0x0 0x0 0x0 0x0>; + }; + + drm_cubic_lut: drm-cubic-lut@00000000 { + compatible = "rockchip,drm-cubic-lut"; + reg = <0x0 0x0 0x0 0x0>; + }; + }; + + rockchip_suspend: rockchip-suspend { + compatible = "rockchip,pm-rk3568"; + status = "disabled"; + rockchip,sleep-debug-en = <1>; + rockchip,sleep-mode-config = < + (0 + | RKPM_SLP_ARMOFF_LOGOFF + | RKPM_SLP_CENTER_OFF + | RKPM_SLP_HW_PLLS_OFF + | RKPM_SLP_PMUALIVE_32K + | RKPM_SLP_OSC_DIS + | RKPM_SLP_PMIC_LP + | RKPM_SLP_32K_PVTM + ) + >; + rockchip,wakeup-config = < + (0 + | RKPM_GPIO_WKUP_EN + ) + >; + }; + + rockchip_system_monitor: rockchip-system-monitor { + compatible = "rockchip,system-monitor"; + + rockchip,thermal-zone = "soc-thermal"; + }; + + thermal_zones: thermal-zones { + soc_thermal: soc-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + sustainable-power = <905>; /* milliwatts */ + + thermal-sensors = <&tsadc 0>; + trips { + threshold: trip-point-0 { + temperature = <75000>; + hysteresis = <2000>; + type = "passive"; + }; + target: trip-point-1 { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + soc_crit: soc-crit { + /* millicelsius */ + temperature = <115000>; + /* millicelsius */ + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&target>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + map1 { + trip = <&target>; + cooling-device = <&gpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + }; + }; + + gpu_thermal: gpu-thermal { + polling-delay-passive = <20>; /* milliseconds */ + polling-delay = <1000>; /* milliseconds */ + + thermal-sensors = <&tsadc 1>; + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupts = , + , + , + ; + arm,no-tick-in-suspend; + }; + + gmac0_clkin: external-gmac0-clock { + compatible = "fixed-clock"; + clock-frequency = <125000000>; + clock-output-names = "gmac0_clkin"; + #clock-cells = <0>; + }; + + gmac1_clkin: external-gmac1-clock { + compatible = "fixed-clock"; + clock-frequency = <125000000>; + clock-output-names = "gmac1_clkin"; + #clock-cells = <0>; + }; + + gmac0_xpcsclk: xpcs-gmac0-clock { + compatible = "fixed-clock"; + clock-frequency = <125000000>; + clock-output-names = "clk_gmac0_xpcs_mii"; + #clock-cells = <0>; + }; + + gmac1_xpcsclk: xpcs-gmac1-clock { + compatible = "fixed-clock"; + clock-frequency = <125000000>; + clock-output-names = "clk_gmac1_xpcs_mii"; + #clock-cells = <0>; + }; + + i2s1_mclkin_rx: i2s1-mclkin-rx { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <12288000>; + clock-output-names = "i2s1_mclkin_rx"; + }; + + i2s1_mclkin_tx: i2s1-mclkin-tx { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <12288000>; + clock-output-names = "i2s1_mclkin_tx"; + }; + + i2s2_mclkin: i2s2-mclkin { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <12288000>; + clock-output-names = "i2s2_mclkin"; + }; + + i2s3_mclkin: i2s3-mclkin { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <12288000>; + clock-output-names = "i2s3_mclkin"; + }; + + mpll: mpll { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <800000000>; + clock-output-names = "mpll"; + }; + + xin24m: xin24m { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24000000>; + clock-output-names = "xin24m"; + }; + + xin32k: xin32k { + compatible = "fixed-clock"; + clock-frequency = <32768>; + clock-output-names = "xin32k"; + #clock-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&clk32k_out0>; + }; + + scmi_shmem: scmi-shmem@10f000 { + compatible = "arm,scmi-shmem"; + reg = <0x0 0x0010f000 0x0 0x100>; + }; + + sata0: sata@fc000000 { + compatible = "snps,dwc-ahci"; + reg = <0 0xfc000000 0 0x1000>; + clocks = <&cru ACLK_SATA0>, <&cru CLK_SATA0_PMALIVE>, + <&cru CLK_SATA0_RXOOB>; + clock-names = "sata", "pmalive", "rxoob"; + interrupts = ; + interrupt-names = "hostc"; + phys = <&combphy0_us PHY_TYPE_SATA>; + phy-names = "sata-phy"; + ports-implemented = <0x1>; + power-domains = <&power RK3568_PD_PIPE>; + status = "disabled"; + }; + + sata1: sata@fc400000 { + compatible = "snps,dwc-ahci"; + reg = <0 0xfc400000 0 0x1000>; + clocks = <&cru ACLK_SATA1>, <&cru CLK_SATA1_PMALIVE>, + <&cru CLK_SATA1_RXOOB>; + clock-names = "sata", "pmalive", "rxoob"; + interrupts = ; + interrupt-names = "hostc"; + phys = <&combphy1_usq PHY_TYPE_SATA>; + phy-names = "sata-phy"; + ports-implemented = <0x1>; + power-domains = <&power RK3568_PD_PIPE>; + status = "disabled"; + }; + + sata2: sata@fc800000 { + compatible = "snps,dwc-ahci"; + reg = <0 0xfc800000 0 0x1000>; + clocks = <&cru ACLK_SATA2>, <&cru CLK_SATA2_PMALIVE>, + <&cru CLK_SATA2_RXOOB>; + clock-names = "sata", "pmalive", "rxoob"; + interrupts = ; + interrupt-names = "hostc"; + phys = <&combphy2_psq PHY_TYPE_SATA>; + phy-names = "sata-phy"; + ports-implemented = <0x1>; + power-domains = <&power RK3568_PD_PIPE>; + status = "disabled"; + }; + + usbdrd30: usbdrd { + compatible = "rockchip,rk3568-dwc3", "rockchip,rk3399-dwc3"; + clocks = <&cru CLK_USB3OTG0_REF>, <&cru CLK_USB3OTG0_SUSPEND>, + <&cru ACLK_USB3OTG0>, <&cru PCLK_PIPE>; + clock-names = "ref_clk", "suspend_clk", + "bus_clk", "pipe_clk"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + status = "disabled"; + + usbdrd_dwc3: dwc3@fcc00000 { + compatible = "snps,dwc3"; + reg = <0x0 0xfcc00000 0x0 0x400000>; + interrupts = ; + dr_mode = "otg"; + phys = <&u2phy0_otg>, <&combphy0_us PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + phy_type = "utmi_wide"; + power-domains = <&power RK3568_PD_PIPE>; + resets = <&cru SRST_USB3OTG0>; + reset-names = "usb3-otg"; + snps,dis_enblslpm_quirk; + snps,dis-u1u2-quirk; + snps,dis-u2-freeclk-exists-quirk; + snps,dis-del-phy-power-chg-quirk; + snps,dis-tx-ipgap-linecheck-quirk; + snps,dis_rxdet_inp3_quirk; + snps,xhci-trb-ent-quirk; + status = "disabled"; + }; + }; + + usbhost30: usbhost { + compatible = "rockchip,rk3568-dwc3", "rockchip,rk3399-dwc3"; + clocks = <&cru CLK_USB3OTG1_REF>, <&cru CLK_USB3OTG1_SUSPEND>, + <&cru ACLK_USB3OTG1>, <&cru PCLK_PIPE>; + clock-names = "ref_clk", "suspend_clk", + "bus_clk", "pipe_clk"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + status = "disabled"; + + usbhost_dwc3: dwc3@fd000000 { + compatible = "snps,dwc3"; + reg = <0x0 0xfd000000 0x0 0x400000>; + interrupts = ; + dr_mode = "host"; + phys = <&u2phy0_host>, <&combphy1_usq PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + phy_type = "utmi_wide"; + power-domains = <&power RK3568_PD_PIPE>; + resets = <&cru SRST_USB3OTG1>; + reset-names = "usb3-host"; + snps,dis_enblslpm_quirk; + snps,dis-u2-freeclk-exists-quirk; + snps,dis-del-phy-power-chg-quirk; + snps,dis-tx-ipgap-linecheck-quirk; + snps,dis_rxdet_inp3_quirk; + snps,xhci-trb-ent-quirk; + status = "disabled"; + }; + }; + + gic: interrupt-controller@fd400000 { + compatible = "arm,gic-v3"; + #interrupt-cells = <3>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + interrupt-controller; + + reg = <0x0 0xfd400000 0 0x10000>, /* GICD */ + <0x0 0xfd460000 0 0xc0000>; /* GICR */ + interrupts = ; + its: interrupt-controller@fd440000 { + compatible = "arm,gic-v3-its"; + msi-controller; + #msi-cells = <1>; + reg = <0x0 0xfd440000 0x0 0x20000>; + }; + }; + + usb_host0_ehci: usb@fd800000 { + compatible = "generic-ehci"; + reg = <0x0 0xfd800000 0x0 0x40000>; + interrupts = ; + clocks = <&cru HCLK_USB2HOST0>, <&cru HCLK_USB2HOST0_ARB>, + <&cru PCLK_USB>, <&usb2phy1>; + clock-names = "usbhost", "arbiter", "pclk", "utmi"; + phys = <&u2phy1_otg>; + phy-names = "usb2-phy"; + status = "disabled"; + }; + + usb_host0_ohci: usb@fd840000 { + compatible = "generic-ohci"; + reg = <0x0 0xfd840000 0x0 0x40000>; + interrupts = ; + clocks = <&cru HCLK_USB2HOST0>, <&cru HCLK_USB2HOST0_ARB>, + <&cru PCLK_USB>, <&usb2phy1>; + clock-names = "usbhost", "arbiter", "pclk", "utmi"; + phys = <&u2phy1_otg>; + phy-names = "usb2-phy"; + status = "disabled"; + }; + + usb_host1_ehci: usb@fd880000 { + compatible = "generic-ehci"; + reg = <0x0 0xfd880000 0x0 0x40000>; + interrupts = ; + clocks = <&cru HCLK_USB2HOST1>, <&cru HCLK_USB2HOST1_ARB>, + <&cru PCLK_USB>, <&usb2phy1>; + clock-names = "usbhost", "arbiter", "pclk", "utmi"; + phys = <&u2phy1_host>; + phy-names = "usb2-phy"; + status = "disabled"; + }; + + usb_host1_ohci: usb@fd8c0000 { + compatible = "generic-ohci"; + reg = <0x0 0xfd8c0000 0x0 0x40000>; + interrupts = ; + clocks = <&cru HCLK_USB2HOST1>, <&cru HCLK_USB2HOST1_ARB>, + <&cru PCLK_USB>, <&usb2phy1>; + clock-names = "usbhost", "arbiter", "pclk", "utmi"; + phys = <&u2phy1_host>; + phy-names = "usb2-phy"; + status = "disabled"; + }; + + xpcs: syscon@fda00000 { + compatible = "rockchip,rk3568-xpcs", "syscon"; + reg = <0x0 0xfda00000 0x0 0x200000>; + status = "disabled"; + }; + + pmugrf: syscon@fdc20000 { + compatible = "rockchip,rk3568-pmugrf", "syscon", "simple-mfd"; + reg = <0x0 0xfdc20000 0x0 0x10000>; + + pmu_io_domains: io-domains { + compatible = "rockchip,rk3568-pmu-io-voltage-domain"; + status = "disabled"; + }; + + reboot_mode: reboot-mode { + compatible = "syscon-reboot-mode"; + offset = <0x200>; + mode-bootloader = ; + mode-charge = ; + mode-fastboot = ; + mode-loader = ; + mode-normal = ; + mode-recovery = ; + mode-ums = ; + mode-panic = ; + mode-watchdog = ; + }; + }; + + pipegrf: syscon@fdc50000 { + compatible = "rockchip,rk3568-pipegrf", "syscon"; + reg = <0x0 0xfdc50000 0x0 0x1000>; + }; + + grf: syscon@fdc60000 { + compatible = "rockchip,rk3568-grf", "syscon", "simple-mfd"; + reg = <0x0 0xfdc60000 0x0 0x10000>; + + io_domains: io-domains { + compatible = "rockchip,rk3568-io-voltage-domain"; + status = "disabled"; + }; + + lvds: lvds { + compatible = "rockchip,rk3568-lvds"; + phys = <&video_phy0>; + phy-names = "phy"; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + lvds_in_vp1: endpoint@1 { + reg = <1>; + remote-endpoint = <&vp1_out_lvds>; + status = "disabled"; + }; + + lvds_in_vp2: endpoint@2 { + reg = <2>; + remote-endpoint = <&vp2_out_lvds>; + status = "disabled"; + }; + }; + }; + }; + + rgb: rgb { + compatible = "rockchip,rk3568-rgb"; + pinctrl-names = "default"; + pinctrl-0 = <&lcdc_ctl>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + rgb_in_vp2: endpoint@2 { + reg = <2>; + remote-endpoint = <&vp2_out_rgb>; + status = "disabled"; + }; + }; + }; + }; + + }; + + pipe_phy_grf0: syscon@fdc70000 { + compatible = "rockchip,pipe-phy-grf", "syscon"; + reg = <0x0 0xfdc70000 0x0 0x1000>; + }; + + pipe_phy_grf1: syscon@fdc80000 { + compatible = "rockchip,pipe-phy-grf", "syscon"; + reg = <0x0 0xfdc80000 0x0 0x1000>; + }; + + pipe_phy_grf2: syscon@fdc90000 { + compatible = "rockchip,pipe-phy-grf", "syscon"; + reg = <0x0 0xfdc90000 0x0 0x1000>; + }; + + usb2phy0_grf: syscon@fdca0000 { + compatible = "rockchip,rk3568-usb2phy-grf", "syscon"; + reg = <0x0 0xfdca0000 0x0 0x8000>; + }; + + usb2phy1_grf: syscon@fdca8000 { + compatible = "rockchip,rk3568-usb2phy-grf", "syscon"; + reg = <0x0 0xfdca8000 0x0 0x8000>; + }; + + edp_phy_grf: syscon@fdcb0000 { + compatible = "rockchip,rk3568-edp-phy-grf", "syscon", "simple-mfd"; + reg = <0x0 0xfdcb0000 0x0 0x100>; + clocks = <&cru PCLK_EDPPHY_GRF>; + + edp_phy: edp-phy { + compatible = "rockchip,rk3568-edp-phy"; + clocks = <&pmucru XIN_OSC0_EDPPHY_G>; + clock-names = "refclk"; + #phy-cells = <0>; + status = "disabled"; + }; + }; + + pcie30_phy_grf: syscon@fdcb8000 { + compatible = "rockchip,pcie30-phy-grf", "syscon"; + reg = <0x0 0xfdcb8000 0x0 0x10000>; + }; + + sram: sram@fdcc0000 { + compatible = "mmio-sram"; + reg = <0x0 0xfdcc0000 0x0 0xb000>; + + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x0 0xfdcc0000 0xb000>; + + /* start address and size should be 4k algin */ + rkvdec_sram: rkvdec-sram@0 { + reg = <0x0 0xb000>; + }; + }; + + pmucru: clock-controller@fdd00000 { + compatible = "rockchip,rk3568-pmucru"; + reg = <0x0 0xfdd00000 0x0 0x1000>; + rockchip,grf = <&grf>; + rockchip,pmugrf = <&pmugrf>; + #clock-cells = <1>; + #reset-cells = <1>; + + assigned-clocks = <&pmucru SCLK_32K_IOE>; + assigned-clock-parents = <&pmucru CLK_RTC_32K>; + }; + + cru: clock-controller@fdd20000 { + compatible = "rockchip,rk3568-cru"; + reg = <0x0 0xfdd20000 0x0 0x1000>; + rockchip,grf = <&grf>; + #clock-cells = <1>; + #reset-cells = <1>; + + assigned-clocks = + <&pmucru CLK_RTC_32K>, <&cru ACLK_RKVDEC_PRE>, + <&cru CLK_RKVDEC_CORE>, <&pmucru PLL_PPLL>, + <&pmucru PCLK_PMU>, <&cru PLL_CPLL>, + <&cru CPLL_500M>, <&cru CPLL_333M>, + <&cru CPLL_250M>, <&cru CPLL_125M>, + <&cru CPLL_100M>, <&cru CPLL_62P5M>, + <&cru CPLL_50M>, <&cru CPLL_25M>, + <&cru PLL_GPLL>, + <&cru ACLK_BUS>, <&cru PCLK_BUS>, + <&cru ACLK_TOP_HIGH>, <&cru ACLK_TOP_LOW>, + <&cru HCLK_TOP>, <&cru PCLK_TOP>, + <&cru ACLK_PERIMID>, <&cru HCLK_PERIMID>, + <&cru PLL_NPLL>, <&cru ACLK_PIPE>, + <&cru PCLK_PIPE>, <&cru CLK_I2S0_8CH_TX_SRC>, + <&cru CLK_I2S0_8CH_RX_SRC>, <&cru CLK_I2S1_8CH_TX_SRC>, + <&cru CLK_I2S1_8CH_RX_SRC>, <&cru CLK_I2S2_2CH_SRC>, + <&cru CLK_I2S2_2CH_SRC>, <&cru CLK_I2S3_2CH_RX_SRC>, + <&cru CLK_I2S3_2CH_TX_SRC>, <&cru MCLK_SPDIF_8CH_SRC>, + <&cru ACLK_VOP>; + assigned-clock-rates = + <32768>, <300000000>, + <300000000>, <200000000>, + <100000000>, <1000000000>, + <500000000>, <333000000>, + <250000000>, <125000000>, + <100000000>, <62500000>, + <50000000>, <25000000>, + <1188000000>, + <150000000>, <100000000>, + <500000000>, <400000000>, + <150000000>, <100000000>, + <300000000>, <150000000>, + <1200000000>, <400000000>, + <100000000>, <1188000000>, + <1188000000>, <1188000000>, + <1188000000>, <1188000000>, + <1188000000>, <1188000000>, + <1188000000>, <1188000000>, + <500000000>; + assigned-clock-parents = + <&pmucru CLK_RTC32K_FRAC>, <&cru PLL_GPLL>, + <&cru PLL_GPLL>; + }; + + i2c0: i2c@fdd40000 { + compatible = "rockchip,rk3399-i2c"; + reg = <0x0 0xfdd40000 0x0 0x1000>; + clocks = <&pmucru CLK_I2C0>, <&pmucru PCLK_I2C0>; + clock-names = "i2c", "pclk"; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_xfer>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + uart0: serial@fdd50000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfdd50000 0x0 0x100>; + interrupts = ; + clocks = <&pmucru SCLK_UART0>, <&pmucru PCLK_UART0>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 0>, <&dmac0 1>; + pinctrl-names = "default"; + pinctrl-0 = <&uart0_xfer>; + status = "disabled"; + }; + + pwm0: pwm@fdd70000 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfdd70000 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm0m0_pins>; + clocks = <&pmucru CLK_PWM0>, <&pmucru PCLK_PWM0>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm1: pwm@fdd70010 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfdd70010 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm1m0_pins>; + clocks = <&pmucru CLK_PWM0>, <&pmucru PCLK_PWM0>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm2: pwm@fdd70020 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfdd70020 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm2m0_pins>; + clocks = <&pmucru CLK_PWM0>, <&pmucru PCLK_PWM0>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm3: pwm@fdd70030 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfdd70030 0x0 0x10>; + interrupts = , + ; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm3_pins>; + clocks = <&pmucru CLK_PWM0>, <&pmucru PCLK_PWM0>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pmu: power-management@fdd90000 { + compatible = "rockchip,rk3568-pmu", "syscon", "simple-mfd"; + reg = <0x0 0xfdd90000 0x0 0x1000>; + + power: power-controller { + compatible = "rockchip,rk3568-power-controller"; + #power-domain-cells = <1>; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + /* These power domains are grouped by VD_NPU */ + pd_npu@RK3568_PD_NPU { + reg = ; + clocks = <&cru ACLK_NPU_PRE>, + <&cru HCLK_NPU_PRE>, + <&cru PCLK_NPU_PRE>; + pm_qos = <&qos_npu>; + }; + /* These power domains are grouped by VD_GPU */ + pd_gpu@RK3568_PD_GPU { + reg = ; + clocks = <&cru ACLK_GPU_PRE>, + <&cru PCLK_GPU_PRE>; + pm_qos = <&qos_gpu>; + }; + /* These power domains are grouped by VD_LOGIC */ + pd_vi@RK3568_PD_VI { + reg = ; + clocks = <&cru HCLK_VI>, + <&cru PCLK_VI>; + pm_qos = <&qos_isp>, + <&qos_vicap0>, + <&qos_vicap1>; + }; + pd_vo@RK3568_PD_VO { + reg = ; + clocks = <&cru HCLK_VO>, + <&cru PCLK_VO>, + <&cru ACLK_VOP_PRE>; + pm_qos = <&qos_hdcp>, + <&qos_vop_m0>, + <&qos_vop_m1>; + }; + pd_rga@RK3568_PD_RGA { + reg = ; + clocks = <&cru HCLK_RGA_PRE>, + <&cru PCLK_RGA_PRE>; + pm_qos = <&qos_ebc>, + <&qos_iep>, + <&qos_jpeg_dec>, + <&qos_jpeg_enc>, + <&qos_rga_rd>, + <&qos_rga_wr>; + }; + pd_vpu@RK3568_PD_VPU { + reg = ; + clocks = <&cru HCLK_VPU_PRE>; + pm_qos = <&qos_vpu>; + }; + pd_rkvdec@RK3568_PD_RKVDEC { + clocks = <&cru HCLK_RKVDEC_PRE>; + reg = ; + pm_qos = <&qos_rkvdec>; + }; + pd_rkvenc@RK3568_PD_RKVENC { + reg = ; + clocks = <&cru HCLK_RKVENC_PRE>; + pm_qos = <&qos_rkvenc_rd_m0>, + <&qos_rkvenc_rd_m1>, + <&qos_rkvenc_wr_m0>; + }; + pd_pipe@RK3568_PD_PIPE { + reg = ; + clocks = <&cru PCLK_PIPE>; + pm_qos = <&qos_pcie2x1>, + <&qos_pcie3x1>, + <&qos_pcie3x2>, + <&qos_sata0>, + <&qos_sata1>, + <&qos_sata2>, + <&qos_usb3_0>, + <&qos_usb3_1>; + }; + }; + }; + + pvtm@fde00000 { + compatible = "rockchip,rk3568-core-pvtm"; + reg = <0x0 0xfde00000 0x0 0x100>; + #address-cells = <1>; + #size-cells = <0>; + pvtm@0 { + reg = <0>; + clocks = <&cru CLK_CORE_PVTM>, <&cru PCLK_CORE_PVTM>; + clock-names = "clk", "pclk"; + resets = <&cru SRST_CORE_PVTM>, <&cru SRST_P_CORE_PVTM>; + reset-names = "rts", "rst-p"; + thermal-zone = "soc-thermal"; + }; + }; + + rknpu: npu@fde40000 { + compatible = "rockchip,rk3568-rknpu", "rockchip,rknpu"; + reg = <0x0 0xfde40000 0x0 0x10000>; + interrupts = ; + clocks = <&scmi_clk 2>, <&cru CLK_NPU>, <&cru ACLK_NPU>, <&cru HCLK_NPU>; + clock-names = "scmi_clk", "clk", "aclk", "hclk"; + assigned-clocks = <&cru CLK_NPU>; + assigned-clock-rates = <600000000>; + resets = <&cru SRST_A_NPU>, <&cru SRST_H_NPU>; + reset-names = "srst_a", "srst_h"; + power-domains = <&power RK3568_PD_NPU>; + operating-points-v2 = <&npu_opp_table>; + iommus = <&rknpu_mmu>; + status = "disabled"; + }; + + npu_opp_table: npu-opp-table { + compatible = "operating-points-v2"; + + mbist-vmin = <825000 900000 950000>; + nvmem-cells = <&npu_leakage>, <&core_pvtm>, <&mbist_vmin>; + nvmem-cell-names = "leakage", "pvtm", "mbist-vmin"; + rockchip,temp-hysteresis = <5000>; + rockchip,low-temp = <0>; + rockchip,low-temp-adjust-volt = < + /* MHz MHz uV */ + 0 700 50000 + >; + rockchip,pvtm-voltage-sel = < + 0 84000 0 + 84001 91000 1 + 91001 100000 2 + >; + rockchip,pvtm-ch = <0 5>; + + opp-200000000 { + opp-hz = /bits/ 64 <200000000>; + opp-microvolt = <850000 850000 1000000>; + opp-microvolt-L0 = <850000 850000 1000000>; + opp-microvolt-L1 = <825000 825000 1000000>; + opp-microvolt-L2 = <825000 825000 1000000>; + }; + opp-300000000 { + opp-hz = /bits/ 64 <297000000>; + opp-microvolt = <850000 850000 1000000>; + opp-microvolt-L0 = <850000 850000 1000000>; + opp-microvolt-L1 = <825000 825000 1000000>; + opp-microvolt-L2 = <825000 825000 1000000>; + }; + opp-400000000 { + opp-hz = /bits/ 64 <400000000>; + opp-microvolt = <850000 850000 1000000>; + opp-microvolt-L0 = <850000 850000 1000000>; + opp-microvolt-L1 = <825000 825000 1000000>; + opp-microvolt-L2 = <825000 825000 1000000>; + }; + opp-600000000 { + opp-hz = /bits/ 64 <600000000>; + opp-microvolt = <875000 875000 1000000>; + opp-microvolt-L0 = <875000 875000 1000000>; + opp-microvolt-L1 = <825000 825000 1000000>; + opp-microvolt-L2 = <825000 825000 1000000>; + }; + opp-700000000 { + opp-hz = /bits/ 64 <700000000>; + opp-microvolt = <900000 900000 1000000>; + opp-microvolt-L0 = <900000 900000 1000000>; + opp-microvolt-L1 = <850000 850000 1000000>; + opp-microvolt-L2 = <850000 850000 1000000>; + }; + opp-800000000 { + opp-hz = /bits/ 64 <800000000>; + opp-microvolt = <925000 925000 1000000>; + opp-microvolt-L0 = <925000 925000 1000000>; + opp-microvolt-L1 = <875000 875000 1000000>; + opp-microvolt-L2 = <875000 875000 1000000>; + }; + opp-900000000 { + opp-hz = /bits/ 64 <900000000>; + opp-microvolt = <975000 975000 1000000>; + opp-microvolt-L0 = <975000 975000 1000000>; + opp-microvolt-L1 = <925000 925000 1000000>; + opp-microvolt-L2 = <900000 900000 1000000>; + }; + opp-1000000000 { + opp-hz = /bits/ 64 <1000000000>; + opp-microvolt = <1000000 1000000 1000000>; + opp-microvolt-L0 = <1000000 1000000 1000000>; + opp-microvolt-L1 = <950000 950000 1000000>; + opp-microvolt-L2 = <925000 925000 1000000>; + status = "disabled"; + }; + }; + + bus_npu: bus-npu { + compatible = "rockchip,rk3568-bus"; + rockchip,busfreq-policy = "clkfreq"; + clocks = <&scmi_clk 2>; + clock-names = "bus"; + operating-points-v2 = <&bus_npu_opp_table>; + status = "disabled"; + }; + + bus_npu_opp_table: bus-npu-opp-table { + compatible = "operating-points-v2"; + opp-shared; + + nvmem-cells = <&core_pvtm>; + nvmem-cell-names = "pvtm"; + rockchip,pvtm-voltage-sel = < + 0 84000 0 + 84001 91000 1 + 91001 100000 2 + >; + rockchip,pvtm-ch = <0 5>; + + opp-700000000 { + opp-hz = /bits/ 64 <700000000>; + opp-microvolt = <0>; + }; + opp-900000000 { + opp-hz = /bits/ 64 <900000000>; + opp-microvolt = <900000>; + }; + opp-1000000000 { + opp-hz = /bits/ 64 <1000000000>; + opp-microvolt = <950000>; + opp-microvolt-L0 = <950000>; + opp-microvolt-L1 = <925000>; + opp-microvolt-L2 = <0>; + }; + }; + + rknpu_mmu: iommu@fde4b000 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfde4b000 0x0 0x40>; + interrupts = ; + interrupt-names = "rknpu_mmu"; + clocks = <&cru ACLK_NPU>, <&cru HCLK_NPU>; + clock-names = "aclk", "iface"; + power-domains = <&power RK3568_PD_NPU>; + #iommu-cells = <0>; + status = "disabled"; + }; + + gpu: gpu@fde60000 { + compatible = "arm,mali-bifrost"; + reg = <0x0 0xfde60000 0x0 0x4000>; + + interrupts = , + , + ; + interrupt-names = "GPU", "MMU", "JOB"; + + upthreshold = <40>; + downdifferential = <10>; + + clocks = <&scmi_clk 1>, <&cru CLK_GPU>; + clock-names = "clk_mali", "clk_gpu"; + power-domains = <&power RK3568_PD_GPU>; + #cooling-cells = <2>; + operating-points-v2 = <&gpu_opp_table>; + + status = "disabled"; + gpu_power_model: power-model { + compatible = "simple-power-model"; + leakage-range= <5 15>; + ls = <(-24002) 22823 0>; + static-coefficient = <100000>; + dynamic-coefficient = <953>; + ts = <(-108890) 63610 (-1355) 20>; + thermal-zone = "gpu-thermal"; + }; + }; + + gpu_opp_table: opp-table2 { + compatible = "operating-points-v2"; + + mbist-vmin = <825000 900000 950000>; + nvmem-cells = <&gpu_leakage>, <&core_pvtm>, <&mbist_vmin>; + nvmem-cell-names = "leakage", "pvtm", "mbist-vmin"; + rockchip,pvtm-voltage-sel = < + 0 84000 0 + 84001 91000 1 + 91001 100000 2 + >; + rockchip,pvtm-ch = <0 5>; + + opp-200000000 { + opp-hz = /bits/ 64 <200000000>; + opp-microvolt = <850000>; + opp-microvolt-L0 = <850000>; + opp-microvolt-L1 = <825000>; + opp-microvolt-L2 = <825000>; + }; + opp-300000000 { + opp-hz = /bits/ 64 <300000000>; + opp-microvolt = <850000>; + opp-microvolt-L0 = <850000>; + opp-microvolt-L1 = <825000>; + opp-microvolt-L2 = <825000>; + }; + opp-400000000 { + opp-hz = /bits/ 64 <400000000>; + opp-microvolt = <850000>; + opp-microvolt-L0 = <850000>; + opp-microvolt-L1 = <825000>; + opp-microvolt-L2 = <825000>; + }; + opp-600000000 { + opp-hz = /bits/ 64 <600000000>; + opp-microvolt = <875000>; + opp-microvolt-L0 = <875000>; + opp-microvolt-L1 = <825000>; + opp-microvolt-L2 = <825000>; + }; + opp-700000000 { + opp-hz = /bits/ 64 <700000000>; + opp-microvolt = <950000>; + opp-microvolt-L0 = <950000>; + opp-microvolt-L1 = <900000>; + opp-microvolt-L2 = <850000>; + }; + opp-800000000 { + opp-hz = /bits/ 64 <800000000>; + opp-microvolt = <1000000>; + opp-microvolt-L0 = <1000000>; + opp-microvolt-L1 = <950000>; + opp-microvolt-L2 = <900000>; + }; + }; + + pvtm@fde80000 { + compatible = "rockchip,rk3568-gpu-pvtm"; + reg = <0x0 0xfde80000 0x0 0x100>; + #address-cells = <1>; + #size-cells = <0>; + pvtm@1 { + reg = <1>; + clocks = <&cru CLK_GPU_PVTM>, <&cru PCLK_GPU_PVTM>; + clock-names = "clk", "pclk"; + resets = <&cru SRST_GPU_PVTM>, <&cru SRST_P_GPU_PVTM>; + reset-names = "rts", "rst-p"; + thermal-zone = "gpu-thermal"; + }; + }; + + pvtm@fde90000 { + compatible = "rockchip,rk3568-npu-pvtm"; + reg = <0x0 0xfde90000 0x0 0x100>; + #address-cells = <1>; + #size-cells = <0>; + pvtm@2 { + reg = <2>; + clocks = <&cru CLK_NPU_PVTM>, <&cru PCLK_NPU_PVTM>, + <&cru HCLK_NPU_PRE>; + clock-names = "clk", "pclk", "hclk"; + resets = <&cru SRST_NPU_PVTM>, <&cru SRST_P_NPU_PVTM>; + reset-names = "rts", "rst-p"; + thermal-zone = "soc-thermal"; + }; + }; + + vdpu: vdpu@fdea0400 { + compatible = "rockchip,vpu-decoder-v2"; + reg = <0x0 0xfdea0400 0x0 0x400>; + interrupts = ; + interrupt-names = "irq_dec"; + clocks = <&cru ACLK_VPU>, <&cru HCLK_VPU>; + clock-names = "aclk_vcodec", "hclk_vcodec"; + resets = <&cru SRST_A_VPU>, <&cru SRST_H_VPU>; + reset-names = "video_a", "video_h"; + iommus = <&vdpu_mmu>; + power-domains = <&power RK3568_PD_VPU>; + rockchip,srv = <&mpp_srv>; + rockchip,taskqueue-node = <0>; + rockchip,resetgroup-node = <0>; + status = "disabled"; + }; + + vdpu_mmu: iommu@fdea0800 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfdea0800 0x0 0x40>; + interrupts = ; + interrupt-names = "vdpu_mmu"; + clock-names = "aclk", "iface"; + clocks = <&cru ACLK_VPU>, <&cru HCLK_VPU>; + power-domains = <&power RK3568_PD_VPU>; + #iommu-cells = <0>; + status = "disabled"; + }; + + rk_rga: rk_rga@fdeb0000 { + compatible = "rockchip,rga2"; + reg = <0x0 0xfdeb0000 0x0 0x1000>; + interrupts = ; + clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru CLK_RGA_CORE>; + clock-names = "aclk_rga", "hclk_rga", "clk_rga"; + power-domains = <&power RK3568_PD_RGA>; + status = "disabled"; + }; + + ebc: ebc@fdec0000 { + compatible = "rockchip,rk3568-ebc-tcon"; + reg = <0x0 0xfdec0000 0x0 0x5000>; + interrupts = ; + clocks = <&cru HCLK_EBC>, <&cru DCLK_EBC>; + clock-names = "hclk", "dclk"; + power-domains = <&power RK3568_PD_RGA>; + rockchip,grf = <&grf>; + pinctrl-names = "default"; + pinctrl-0 = <&ebc_pins>; + status = "disabled"; + }; + + jpegd: jpegd@fded0000 { + compatible = "rockchip,rkv-jpeg-decoder-v1"; + reg = <0x0 0xfded0000 0x0 0x400>; + interrupts = ; + clocks = <&cru ACLK_JDEC>, <&cru HCLK_JDEC>; + clock-names = "aclk_vcodec", "hclk_vcodec"; + rockchip,disable-auto-freq; + resets = <&cru SRST_A_JDEC>, <&cru SRST_H_JDEC>; + reset-names = "video_a", "video_h"; + iommus = <&jpegd_mmu>; + rockchip,srv = <&mpp_srv>; + rockchip,taskqueue-node = <1>; + rockchip,resetgroup-node = <1>; + power-domains = <&power RK3568_PD_RGA>; + status = "disabled"; + }; + + jpegd_mmu: iommu@fded0480 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfded0480 0x0 0x40>; + interrupts = ; + interrupt-names = "jpegd_mmu"; + clock-names = "aclk", "iface"; + clocks = <&cru ACLK_JDEC>, <&cru HCLK_JDEC>; + power-domains = <&power RK3568_PD_RGA>; + #iommu-cells = <0>; + status = "disabled"; + }; + + vepu: vepu@fdee0000 { + compatible = "rockchip,vpu-encoder-v2"; + reg = <0x0 0xfdee0000 0x0 0x400>; + interrupts = ; + clocks = <&cru ACLK_JENC>, <&cru HCLK_JENC>; + clock-names = "aclk_vcodec", "hclk_vcodec"; + rockchip,disable-auto-freq; + resets = <&cru SRST_A_JENC>, <&cru SRST_H_JENC>; + reset-names = "video_a", "video_h"; + iommus = <&vepu_mmu>; + rockchip,srv = <&mpp_srv>; + rockchip,taskqueue-node = <2>; + rockchip,resetgroup-node = <2>; + power-domains = <&power RK3568_PD_RGA>; + status = "disabled"; + }; + + vepu_mmu: iommu@fdee0800 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfdee0800 0x0 0x40>; + interrupts = ; + interrupt-names = "vepu_mmu"; + clock-names = "aclk", "iface"; + clocks = <&cru ACLK_JENC>, <&cru HCLK_JENC>; + power-domains = <&power RK3568_PD_RGA>; + #iommu-cells = <0>; + status = "disabled"; + }; + + iep: iep@fdef0000 { + compatible = "rockchip,iep-v2"; + reg = <0x0 0xfdef0000 0x0 0x500>; + interrupts = ; + clocks = <&cru ACLK_IEP>, <&cru HCLK_IEP>, <&cru CLK_IEP_CORE>; + clock-names = "aclk", "hclk", "sclk"; + resets = <&cru SRST_A_IEP>, <&cru SRST_H_IEP>, + <&cru SRST_IEP_CORE>; + reset-names = "rst_a", "rst_h", "rst_s"; + power-domains = <&power RK3568_PD_RGA>; + rockchip,srv = <&mpp_srv>; + rockchip,taskqueue-node = <5>; + rockchip,resetgroup-node = <5>; + iommus = <&iep_mmu>; + status = "disabled"; + }; + + iep_mmu: iommu@fdef0800 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfdef0800 0x0 0x100>; + interrupts = ; + interrupt-names = "iep_mmu"; + clocks = <&cru ACLK_IEP>, <&cru HCLK_IEP>; + clock-names = "aclk", "iface"; + #iommu-cells = <0>; + power-domains = <&power RK3568_PD_RGA>; + //rockchip,disable-device-link-resume; + status = "disabled"; + }; + + eink: eink@fdf00000 { + compatible = "rockchip,rk3568-eink-tcon"; + reg = <0x0 0xfdf00000 0x0 0x74>; + interrupts = ; + clocks = <&cru PCLK_EINK>, <&cru HCLK_EINK>; + clock-names = "pclk", "hclk"; + status = "disabled"; + }; + + rkvenc: rkvenc@fdf40000 { + compatible = "rockchip,rkv-encoder-v1"; + reg = <0x0 0xfdf40000 0x0 0x400>; + interrupts = ; + interrupt-names = "irq_enc"; + clocks = <&cru ACLK_RKVENC>, <&cru HCLK_RKVENC>, + <&cru CLK_RKVENC_CORE>; + clock-names = "aclk_vcodec", "hclk_vcodec", "clk_core"; + rockchip,normal-rates = <297000000>, <0>, <297000000>; + resets = <&cru SRST_A_RKVENC>, <&cru SRST_H_RKVENC>, + <&cru SRST_RKVENC_CORE>; + reset-names = "video_a", "video_h", "video_core"; + assigned-clocks = <&cru ACLK_RKVENC>, <&cru CLK_RKVENC_CORE>; + assigned-clock-rates = <297000000>, <297000000>; + iommus = <&rkvenc_mmu>; + node-name = "rkvenc"; + rockchip,srv = <&mpp_srv>; + rockchip,taskqueue-node = <3>; + rockchip,resetgroup-node = <3>; + power-domains = <&power RK3568_PD_RKVENC>; + operating-points-v2 = <&rkvenc_opp_table>; + status = "disabled"; + }; + + rkvenc_opp_table: rkvenc-opp-table { + compatible = "operating-points-v2"; + + nvmem-cells = <&core_pvtm>; + nvmem-cell-names = "pvtm"; + rockchip,pvtm-voltage-sel = < + 0 84000 0 + 84001 91000 1 + 91001 100000 2 + >; + rockchip,pvtm-ch = <0 5>; + + opp-297000000 { + opp-hz = /bits/ 64 <297000000>; + opp-microvolt = <0>; + }; + opp-400000000 { + opp-hz = /bits/ 64 <400000000>; + opp-microvolt = <950000>; + opp-microvolt-L0 = <950000>; + opp-microvolt-L1 = <925000>; + opp-microvolt-L2 = <0>; + }; + }; + + rkvenc_mmu: iommu@fdf40f00 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfdf40f00 0x0 0x40>, <0x0 0xfdf40f40 0x0 0x40>; + interrupts = , + ; + interrupt-names = "rkvenc_mmu0", "rkvenc_mmu1"; + clocks = <&cru ACLK_RKVENC>, <&cru HCLK_RKVENC>; + clock-names = "aclk", "iface"; + rockchip,disable-mmu-reset; + rockchip,enable-cmd-retry; + #iommu-cells = <0>; + power-domains = <&power RK3568_PD_RKVENC>; + status = "disabled"; + }; + + rkvdec: rkvdec@fdf80200 { + compatible = "rockchip,rkv-decoder-rk3568", "rockchip,rkv-decoder-v2"; + reg = <0x0 0xfdf80200 0x0 0x400>, <0x0 0xfdf80100 0x0 0x100>; + reg-names = "regs", "link"; + interrupts = ; + interrupt-names = "irq_dec"; + clocks = <&cru ACLK_RKVDEC>, <&cru HCLK_RKVDEC>, + <&cru CLK_RKVDEC_CA>, <&cru CLK_RKVDEC_CORE>, + <&cru CLK_RKVDEC_HEVC_CA>; + clock-names = "aclk_vcodec", "hclk_vcodec","clk_cabac", + "clk_core", "clk_hevc_cabac"; + rockchip,normal-rates = <297000000>, <0>, <297000000>, + <297000000>, <600000000>; + rockchip,advanced-rates = <396000000>, <0>, <396000000>, + <396000000>, <600000000>; + rockchip,default-max-load = <2088960>; + resets = <&cru SRST_A_RKVDEC>, <&cru SRST_H_RKVDEC>, + <&cru SRST_RKVDEC_CA>, <&cru SRST_RKVDEC_CORE>, + <&cru SRST_RKVDEC_HEVC_CA>; + assigned-clocks = <&cru ACLK_RKVDEC>, <&cru CLK_RKVDEC_CA>, + <&cru CLK_RKVDEC_CORE>, <&cru CLK_RKVDEC_HEVC_CA>; + assigned-clock-rates = <297000000>, <297000000>, <297000000>, <297000000>; + reset-names = "video_a", "video_h", "video_cabac", + "video_core", "video_hevc_cabac"; + power-domains = <&power RK3568_PD_RKVDEC>; + operating-points-v2 = <&rkvdec_opp_table>; + vdec-supply = <&vdd_logic>; + iommus = <&rkvdec_mmu>; + rockchip,srv = <&mpp_srv>; + rockchip,taskqueue-node = <4>; + rockchip,resetgroup-node = <4>; + rockchip,sram = <&rkvdec_sram>; + /* rcb_iova: start and size */ + rockchip,rcb-iova = <0x10000000 65536>; + rockchip,rcb-min-width = <512>; + rockchip,task-capacity = <16>; + status = "disabled"; + }; + + rkvdec_opp_table: rkvdec-opp-table { + compatible = "operating-points-v2"; + + opp-297000000 { + opp-hz = /bits/ 64 <297000000>; + opp-microvolt = <0>; + }; + opp-400000000 { + opp-hz = /bits/ 64 <400000000>; + opp-microvolt = <900000>; + }; + }; + + rkvdec_mmu: iommu@fdf80800 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfdf80800 0x0 0x40>, <0x0 0xfdf80840 0x0 0x40>; + interrupts = ; + interrupt-names = "rkvdec_mmu"; + clocks = <&cru ACLK_RKVDEC>, <&cru HCLK_RKVDEC>; + clock-names = "aclk", "iface"; + power-domains = <&power RK3568_PD_RKVDEC>; + #iommu-cells = <0>; + status = "disabled"; + }; + + mipi_csi2: mipi-csi2@fdfb0000 { + compatible = "rockchip,rk3568-mipi-csi2"; + reg = <0x0 0xfdfb0000 0x0 0x10000>; + reg-names = "csihost_regs"; + interrupts = , + ; + interrupt-names = "csi-intr1", "csi-intr2"; + clocks = <&cru PCLK_CSI2HOST1>; + clock-names = "pclk_csi2host"; + resets = <&cru SRST_P_CSI2HOST1>; + reset-names = "srst_csihost_p"; + status = "disabled"; + }; + + rkcif: rkcif@fdfe0000 { + compatible = "rockchip,rk3568-cif"; + reg = <0x0 0xfdfe0000 0x0 0x8000>; + reg-names = "cif_regs"; + interrupts = ; + interrupt-names = "cif-intr"; + + clocks = <&cru ACLK_VICAP>, <&cru HCLK_VICAP>, + <&cru DCLK_VICAP>, <&cru ICLK_VICAP_G>; + clock-names = "aclk_cif", "hclk_cif", + "dclk_cif", "iclk_cif_g"; + resets = <&cru SRST_A_VICAP>, <&cru SRST_H_VICAP>, + <&cru SRST_D_VICAP>, <&cru SRST_P_VICAP>, + <&cru SRST_I_VICAP>; + reset-names = "rst_cif_a", "rst_cif_h", + "rst_cif_d", "rst_cif_p", + "rst_cif_i"; + assigned-clocks = <&cru DCLK_VICAP>; + assigned-clock-rates = <300000000>; + power-domains = <&power RK3568_PD_VI>; + rockchip,grf = <&grf>; + iommus = <&rkcif_mmu>; + status = "disabled"; + }; + + rkcif_mmu: iommu@fdfe0800 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfdfe0800 0x0 0x100>; + interrupts = ; + interrupt-names = "cif_mmu"; + clocks = <&cru ACLK_VICAP>, <&cru HCLK_VICAP>; + clock-names = "aclk", "iface"; + power-domains = <&power RK3568_PD_VI>; + rockchip,disable-mmu-reset; + #iommu-cells = <0>; + status = "disabled"; + }; + + rkcif_dvp: rkcif_dvp { + compatible = "rockchip,rkcif-dvp"; + rockchip,hw = <&rkcif>; + status = "disabled"; + }; + + rkcif_dvp_sditf: rkcif_dvp_sditf { + compatible = "rockchip,rkcif-sditf"; + rockchip,cif = <&rkcif_dvp>; + status = "disabled"; + }; + + rkcif_mipi_lvds: rkcif_mipi_lvds { + compatible = "rockchip,rkcif-mipi-lvds"; + rockchip,hw = <&rkcif>; + status = "disabled"; + }; + + rkcif_mipi_lvds_sditf: rkcif_mipi_lvds_sditf { + compatible = "rockchip,rkcif-sditf"; + rockchip,cif = <&rkcif_mipi_lvds>; + status = "disabled"; + }; + + rkisp: rkisp@fdff0000 { + compatible = "rockchip,rk3568-rkisp"; + reg = <0x0 0xfdff0000 0x0 0x10000>; + interrupts = , + , + ; + interrupt-names = "mipi_irq", "mi_irq", "isp_irq"; + clocks = <&cru ACLK_ISP>, <&cru HCLK_ISP>, <&cru CLK_ISP>; + clock-names = "aclk_isp", "hclk_isp", "clk_isp"; + resets = <&cru SRST_ISP>, <&cru SRST_H_ISP>; + reset-names = "isp", "isp-h"; + rockchip,grf = <&grf>; + power-domains = <&power RK3568_PD_VI>; + iommus = <&rkisp_mmu>; + rockchip,iq-feature = /bits/ 64 <0x3FBFFFE67FF>; + status = "disabled"; + }; + + rkisp_mmu: iommu@fdff1a00 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfdff1a00 0x0 0x100>; + interrupts = ; + interrupt-names = "isp_mmu"; + clocks = <&cru ACLK_ISP>, <&cru HCLK_ISP>; + clock-names = "aclk", "iface"; + power-domains = <&power RK3568_PD_VI>; + #iommu-cells = <0>; + rockchip,disable-mmu-reset; + status = "disabled"; + }; + + rkisp_vir0: rkisp-vir0 { + compatible = "rockchip,rkisp-vir"; + rockchip,hw = <&rkisp>; + status = "disabled"; + }; + + rkisp_vir1: rkisp-vir1 { + compatible = "rockchip,rkisp-vir"; + rockchip,hw = <&rkisp>; + status = "disabled"; + }; + + gmac0: ethernet@fe2a0000 { + compatible = "rockchip,rk3568-gmac", "snps,dwmac-4.20a"; + reg = <0x0 0xfe2a0000 0x0 0x10000>; + interrupts = , + ; + interrupt-names = "macirq", "eth_wake_irq"; + rockchip,grf = <&grf>; + clocks = <&cru SCLK_GMAC0>, <&cru SCLK_GMAC0_RX_TX>, + <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_MAC0_REFOUT>, + <&cru ACLK_GMAC0>, <&cru PCLK_GMAC0>, + <&cru SCLK_GMAC0_RX_TX>, <&cru CLK_GMAC0_PTP_REF>, + <&cru PCLK_XPCS>; + clock-names = "stmmaceth", "mac_clk_rx", + "mac_clk_tx", "clk_mac_refout", + "aclk_mac", "pclk_mac", + "clk_mac_speed", "ptp_ref", + "pclk_xpcs"; + resets = <&cru SRST_A_GMAC0>; + reset-names = "stmmaceth"; + + snps,mixed-burst; + snps,tso; + + snps,axi-config = <&gmac0_stmmac_axi_setup>; + snps,mtl-rx-config = <&gmac0_mtl_rx_setup>; + snps,mtl-tx-config = <&gmac0_mtl_tx_setup>; + status = "disabled"; + + mdio0: mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <0x1>; + #size-cells = <0x0>; + }; + + gmac0_stmmac_axi_setup: stmmac-axi-config { + snps,wr_osr_lmt = <4>; + snps,rd_osr_lmt = <8>; + snps,blen = <0 0 0 0 16 8 4>; + }; + + gmac0_mtl_rx_setup: rx-queues-config { + snps,rx-queues-to-use = <1>; + queue0 {}; + }; + + gmac0_mtl_tx_setup: tx-queues-config { + snps,tx-queues-to-use = <1>; + queue0 {}; + }; + }; + + gmac1: ethernet@fe010000 { + compatible = "rockchip,rk3568-gmac", "snps,dwmac-4.20a"; + reg = <0x0 0xfe010000 0x0 0x10000>; + interrupts = , + ; + interrupt-names = "macirq", "eth_wake_irq"; + rockchip,grf = <&grf>; + clocks = <&cru SCLK_GMAC1>, <&cru SCLK_GMAC1_RX_TX>, + <&cru SCLK_GMAC1_RX_TX>, <&cru CLK_MAC1_REFOUT>, + <&cru ACLK_GMAC1>, <&cru PCLK_GMAC1>, + <&cru SCLK_GMAC1_RX_TX>, <&cru CLK_GMAC1_PTP_REF>, + <&cru PCLK_XPCS>; + clock-names = "stmmaceth", "mac_clk_rx", + "mac_clk_tx", "clk_mac_refout", + "aclk_mac", "pclk_mac", + "clk_mac_speed", "ptp_ref", + "pclk_xpcs"; + resets = <&cru SRST_A_GMAC1>; + reset-names = "stmmaceth"; + + snps,mixed-burst; + snps,tso; + + snps,axi-config = <&gmac1_stmmac_axi_setup>; + snps,mtl-rx-config = <&gmac1_mtl_rx_setup>; + snps,mtl-tx-config = <&gmac1_mtl_tx_setup>; + status = "disabled"; + + mdio1: mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <0x1>; + #size-cells = <0x0>; + }; + + gmac1_stmmac_axi_setup: stmmac-axi-config { + snps,wr_osr_lmt = <4>; + snps,rd_osr_lmt = <8>; + snps,blen = <0 0 0 0 16 8 4>; + }; + + gmac1_mtl_rx_setup: rx-queues-config { + snps,rx-queues-to-use = <1>; + queue0 {}; + }; + + gmac1_mtl_tx_setup: tx-queues-config { + snps,tx-queues-to-use = <1>; + queue0 {}; + }; + }; + + vop: vop@fe040000 { + compatible = "rockchip,rk3568-vop"; + reg = <0x0 0xfe040000 0x0 0x3000>, <0x0 0xfe044000 0x0 0x1000>; + reg-names = "regs", "gamma_lut"; + rockchip,grf = <&grf>; + interrupts = ; + clocks = <&cru ACLK_VOP>, <&cru HCLK_VOP>, <&cru DCLK_VOP0>, <&cru DCLK_VOP1>, <&cru DCLK_VOP2>; + clock-names = "aclk_vop", "hclk_vop", "dclk_vp0", "dclk_vp1", "dclk_vp2"; + iommus = <&vop_mmu>; + power-domains = <&power RK3568_PD_VO>; + status = "disabled"; + + vop_out: ports { + #address-cells = <1>; + #size-cells = <0>; + + vp0: port@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + vp0_out_dsi0: endpoint@0 { + reg = <0>; + remote-endpoint = <&dsi0_in_vp0>; + }; + + vp0_out_dsi1: endpoint@1 { + reg = <1>; + remote-endpoint = <&dsi1_in_vp0>; + }; + + vp0_out_edp: endpoint@2 { + reg = <2>; + remote-endpoint = <&edp_in_vp0>; + }; + + vp0_out_hdmi: endpoint@3 { + reg = <3>; + remote-endpoint = <&hdmi_in_vp0>; + }; + }; + + vp1: port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + + vp1_out_dsi0: endpoint@0 { + reg = <0>; + remote-endpoint = <&dsi0_in_vp1>; + }; + + vp1_out_dsi1: endpoint@1 { + reg = <1>; + remote-endpoint = <&dsi1_in_vp1>; + }; + + vp1_out_edp: endpoint@2 { + reg = <2>; + remote-endpoint = <&edp_in_vp1>; + }; + + vp1_out_hdmi: endpoint@3 { + reg = <3>; + remote-endpoint = <&hdmi_in_vp1>; + }; + + vp1_out_lvds: endpoint@4 { + reg = <4>; + remote-endpoint = <&lvds_in_vp1>; + }; + }; + + vp2: port@2 { + #address-cells = <1>; + #size-cells = <0>; + + reg = <2>; + + vp2_out_lvds: endpoint@0 { + reg = <0>; + remote-endpoint = <&lvds_in_vp2>; + }; + + vp2_out_rgb: endpoint@1 { + reg = <1>; + remote-endpoint = <&rgb_in_vp2>; + }; + }; + }; + }; + + vop_mmu: iommu@fe043e00 { + compatible = "rockchip,iommu-v2"; + reg = <0x0 0xfe043e00 0x0 0x100>, <0x0 0xfe043f00 0x0 0x100>; + interrupts = ; + interrupt-names = "vop_mmu"; + clocks = <&cru ACLK_VOP>, <&cru HCLK_VOP>; + clock-names = "aclk", "iface"; + #iommu-cells = <0>; + status = "disabled"; + }; + + dsi0: dsi@fe060000 { + compatible = "rockchip,rk3568-mipi-dsi"; + reg = <0x0 0xfe060000 0x0 0x10000>; + interrupts = ; + clocks = <&cru PCLK_DSITX_0>, <&cru HCLK_VO>, <&video_phy0>; + clock-names = "pclk", "hclk", "hs_clk"; + resets = <&cru SRST_P_DSITX_0>; + reset-names = "apb"; + phys = <&video_phy0>; + phy-names = "mipi_dphy"; + power-domains = <&power RK3568_PD_VO>; + rockchip,grf = <&grf>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + dsi0_in: port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + dsi0_in_vp0: endpoint@0 { + reg = <0>; + remote-endpoint = <&vp0_out_dsi0>; + status = "disabled"; + }; + + dsi0_in_vp1: endpoint@1 { + reg = <1>; + remote-endpoint = <&vp1_out_dsi0>; + status = "disabled"; + }; + }; + }; + }; + + dsi1: dsi@fe070000 { + compatible = "rockchip,rk3568-mipi-dsi"; + reg = <0x0 0xfe070000 0x0 0x10000>; + interrupts = ; + clocks = <&cru PCLK_DSITX_1>, <&cru HCLK_VO>, <&video_phy1>; + clock-names = "pclk", "hclk", "hs_clk"; + resets = <&cru SRST_P_DSITX_1>; + reset-names = "apb"; + phys = <&video_phy1>; + phy-names = "mipi_dphy"; + power-domains = <&power RK3568_PD_VO>; + rockchip,grf = <&grf>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + dsi1_in: port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + dsi1_in_vp0: endpoint@0 { + reg = <0>; + remote-endpoint = <&vp0_out_dsi1>; + status = "disabled"; + }; + + dsi1_in_vp1: endpoint@1 { + reg = <1>; + remote-endpoint = <&vp1_out_dsi1>; + status = "disabled"; + }; + }; + }; + }; + + hdmi: hdmi@fe0a0000 { + compatible = "rockchip,rk3568-dw-hdmi"; + reg = <0x0 0xfe0a0000 0x0 0x20000>; + interrupts = ; + clocks = <&cru PCLK_HDMI_HOST>, + <&cru CLK_HDMI_SFR>, + <&cru CLK_HDMI_CEC>, + <&pmucru PLL_HPLL>, + <&cru HCLK_VOP>; + clock-names = "iahb", "isfr", "cec", "ref", "hclk"; + power-domains = <&power RK3568_PD_VO>; + reg-io-width = <4>; + rockchip,grf = <&grf>; + #sound-dai-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&hdmitx_scl &hdmitx_sda &hdmitxm0_cec>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + hdmi_in: port { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + hdmi_in_vp0: endpoint@0 { + reg = <0>; + remote-endpoint = <&vp0_out_hdmi>; + status = "disabled"; + }; + hdmi_in_vp1: endpoint@1 { + reg = <1>; + remote-endpoint = <&vp1_out_hdmi>; + status = "disabled"; + }; + }; + }; + }; + + edp: edp@fe0c0000 { + compatible = "rockchip,rk3568-edp"; + reg = <0x0 0xfe0c0000 0x0 0x10000>; + interrupts = ; + clocks = <&pmucru XIN_OSC0_EDPPHY_G>, <&cru PCLK_EDP_CTRL>, + <&cru CLK_EDP_200M>, <&cru HCLK_VO>; + clock-names = "dp", "pclk", "spdif", "hclk"; + resets = <&cru SRST_EDP_24M>, <&cru SRST_P_EDP_CTRL>; + reset-names = "dp", "apb"; + phys = <&edp_phy>; + phy-names = "dp"; + power-domains = <&power RK3568_PD_VO>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + edp_in: port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + edp_in_vp0: endpoint@0 { + reg = <0>; + remote-endpoint = <&vp0_out_edp>; + status = "disabled"; + }; + + edp_in_vp1: endpoint@1 { + reg = <1>; + remote-endpoint = <&vp1_out_edp>; + status = "disabled"; + }; + }; + }; + }; + + nocp_cpu: nocp-cpu@fe102000 { + compatible = "rockchip,rk3568-nocp"; + reg = <0x0 0xfe102000 0x0 0x400>; + }; + + nocp_gpu_vpu_rga_venc: nocp-gpu-vpu-rga-venc@fe102400 { + compatible = "rockchip,rk3568-nocp"; + reg = <0x0 0xfe102400 0x0 0x400>; + }; + + nocp_npu_vdec: nocp-vdec@fe102800 { + compatible = "rockchip,rk3568-nocp"; + reg = <0x0 0xfe102800 0x0 0x400>; + }; + + nocp_vi_usb_peri_pipe: nocp-vi-usb-peri-pipe@fe102c00 { + compatible = "rockchip,rk3568-nocp"; + reg = <0x0 0xfe102c00 0x0 0x400>; + }; + + nocp_vo: nocp-vo@fe103000 { + compatible = "rockchip,rk3568-nocp"; + reg = <0x0 0xfe103000 0x0 0x400>; + }; + + qos_gpu: qos@fe128000 { + compatible = "syscon"; + reg = <0x0 0xfe128000 0x0 0x20>; + }; + + qos_rkvenc_rd_m0: qos@fe138080 { + compatible = "syscon"; + reg = <0x0 0xfe138080 0x0 0x20>; + }; + + qos_rkvenc_rd_m1: qos@fe138100 { + compatible = "syscon"; + reg = <0x0 0xfe138100 0x0 0x20>; + }; + + qos_rkvenc_wr_m0: qos@fe138180 { + compatible = "syscon"; + reg = <0x0 0xfe138180 0x0 0x20>; + }; + + qos_isp: qos@fe148000 { + compatible = "syscon"; + reg = <0x0 0xfe148000 0x0 0x20>; + }; + + qos_vicap0: qos@fe148080 { + compatible = "syscon"; + reg = <0x0 0xfe148080 0x0 0x20>; + }; + + qos_vicap1: qos@fe148100 { + compatible = "syscon"; + reg = <0x0 0xfe148100 0x0 0x20>; + }; + + qos_vpu: qos@fe150000 { + compatible = "syscon"; + reg = <0x0 0xfe150000 0x0 0x20>; + }; + + qos_ebc: qos@fe158000 { + compatible = "syscon"; + reg = <0x0 0xfe158000 0x0 0x20>; + }; + + qos_iep: qos@fe158100 { + compatible = "syscon"; + reg = <0x0 0xfe158100 0x0 0x20>; + }; + + qos_jpeg_dec: qos@fe158180 { + compatible = "syscon"; + reg = <0x0 0xfe158180 0x0 0x20>; + }; + + qos_jpeg_enc: qos@fe158200 { + compatible = "syscon"; + reg = <0x0 0xfe158200 0x0 0x20>; + }; + + qos_rga_rd: qos@fe158280 { + compatible = "syscon"; + reg = <0x0 0xfe158280 0x0 0x20>; + }; + + qos_rga_wr: qos@fe158300 { + compatible = "syscon"; + reg = <0x0 0xfe158300 0x0 0x20>; + }; + + qos_npu: qos@fe180000 { + compatible = "syscon"; + reg = <0x0 0xfe180000 0x0 0x20>; + }; + + qos_pcie2x1: qos@fe190000 { + compatible = "syscon"; + reg = <0x0 0xfe190000 0x0 0x20>; + }; + + qos_pcie3x1: qos@fe190080 { + compatible = "syscon"; + reg = <0x0 0xfe190080 0x0 0x20>; + }; + + qos_pcie3x2: qos@fe190100 { + compatible = "syscon"; + reg = <0x0 0xfe190100 0x0 0x20>; + }; + + qos_sata0: qos@fe190200 { + compatible = "syscon"; + reg = <0x0 0xfe190200 0x0 0x20>; + }; + + qos_sata1: qos@fe190280 { + compatible = "syscon"; + reg = <0x0 0xfe190280 0x0 0x20>; + }; + + qos_sata2: qos@fe190300 { + compatible = "syscon"; + reg = <0x0 0xfe190300 0x0 0x20>; + }; + + qos_usb3_0: qos@fe190380 { + compatible = "syscon"; + reg = <0x0 0xfe190380 0x0 0x20>; + }; + + qos_usb3_1: qos@fe190400 { + compatible = "syscon"; + reg = <0x0 0xfe190400 0x0 0x20>; + }; + + qos_rkvdec: qos@fe198000 { + compatible = "syscon"; + reg = <0x0 0xfe198000 0x0 0x20>; + }; + + qos_hdcp: qos@fe1a8000 { + compatible = "syscon"; + reg = <0x0 0xfe1a8000 0x0 0x20>; + }; + + qos_vop_m0: qos@fe1a8080 { + compatible = "syscon"; + reg = <0x0 0xfe1a8080 0x0 0x20>; + }; + + qos_vop_m1: qos@fe1a8100 { + compatible = "syscon"; + reg = <0x0 0xfe1a8100 0x0 0x20>; + }; + + sdmmc2: dwmmc@fe000000 { + compatible = "rockchip,rk3568-dw-mshc", + "rockchip,rk3288-dw-mshc"; + reg = <0x0 0xfe000000 0x0 0x4000>; + interrupts = ; + max-frequency = <150000000>; + clocks = <&cru HCLK_SDMMC2>, <&cru CLK_SDMMC2>, + <&cru SCLK_SDMMC2_DRV>, <&cru SCLK_SDMMC2_SAMPLE>; + clock-names = "biu", "ciu", "ciu-drive", "ciu-sample"; + fifo-depth = <0x100>; + resets = <&cru SRST_SDMMC2>; + reset-names = "reset"; + status = "disabled"; + }; + + dfi: dfi@fe230000 { + reg = <0x00 0xfe230000 0x00 0x400>; + compatible = "rockchip,rk3568-dfi"; + rockchip,pmugrf = <&pmugrf>; + status = "disabled"; + }; + + dmc: dmc { + compatible = "rockchip,rk3568-dmc"; + interrupts = ; + interrupt-names = "complete"; + devfreq-events = <&dfi>, <&nocp_cpu>; + clocks = <&scmi_clk 3>; + clock-names = "dmc_clk"; + operating-points-v2 = <&dmc_opp_table>; + vop-bw-dmc-freq = < + /* min_bw(MB/s) max_bw(MB/s) freq(KHz) */ + 0 286 324000 + 287 99999 528000 + >; + vop-frame-bw-dmc-freq = < + /* min_bw(MB/s) max_bw(MB/s) freq(KHz) */ + 0 620 324000 + 621 99999 780000 + >; + cpu-bw-dmc-freq = < + /* min_bw(MB/s) max_bw(MB/s) freq(KHz) */ + 0 350 324000 + 351 400 528000 + 401 99999 780000 + >; + upthreshold = <40>; + downdifferential = <20>; + system-status-level = < + /*system status freq level*/ + SYS_STATUS_NORMAL DMC_FREQ_LEVEL_MID_HIGH + SYS_STATUS_REBOOT DMC_FREQ_LEVEL_HIGH + SYS_STATUS_SUSPEND DMC_FREQ_LEVEL_LOW + SYS_STATUS_VIDEO_4K DMC_FREQ_LEVEL_MID_HIGH + SYS_STATUS_VIDEO_4K_10B DMC_FREQ_LEVEL_MID_HIGH + SYS_STATUS_BOOST DMC_FREQ_LEVEL_HIGH + SYS_STATUS_ISP DMC_FREQ_LEVEL_HIGH + SYS_STATUS_PERFORMANCE DMC_FREQ_LEVEL_HIGH + SYS_STATUS_DUALVIEW DMC_FREQ_LEVEL_HIGH + >; + auto-min-freq = <324000>; + auto-freq-en = <1>; + #cooling-cells = <2>; + status = "disabled"; + }; + + dmc_fsp: dmc-fsp { + compatible = "rockchip,rk3568-dmc-fsp"; + + debug_print_level = <0>; + ddr3_params = <&ddr3_params>; + ddr4_params = <&ddr4_params>; + lpddr3_params = <&lpddr3_params>; + lpddr4_params = <&lpddr4_params>; + lpddr4x_params = <&lpddr4x_params>; + + status = "okay"; + }; + + dmc_opp_table: dmc-opp-table { + compatible = "operating-points-v2"; + + mbist-vmin = <825000 900000 950000>; + nvmem-cells = <&log_leakage>, <&core_pvtm>, <&mbist_vmin>; + nvmem-cell-names = "leakage", "pvtm", "mbist-vmin"; + rockchip,temp-hysteresis = <5000>; + rockchip,low-temp = <0>; + rockchip,low-temp-adjust-volt = < + /* MHz MHz uV */ + 0 1560 75000 + >; + rockchip,leakage-voltage-sel = < + 1 80 0 + 81 254 1 + >; + rockchip,pvtm-voltage-sel = < + 0 84000 0 + 84001 100000 1 + >; + rockchip,pvtm-ch = <0 5>; + + opp-1560000000 { + opp-hz = /bits/ 64 <1560000000>; + opp-microvolt = <900000>; + opp-microvolt-L0 = <900000>; + opp-microvolt-L1 = <850000>; + }; + }; + + dmcdbg: dmcdbg { + compatible = "rockchip,rk3568-dmcdbg"; + status = "disabled"; + }; + + pcie2x1: pcie@fe260000 { + compatible = "rockchip,rk3568-pcie", "snps,dw-pcie"; + #address-cells = <3>; + #size-cells = <2>; + bus-range = <0x0 0xf>; + clocks = <&cru ACLK_PCIE20_MST>, <&cru ACLK_PCIE20_SLV>, + <&cru ACLK_PCIE20_DBI>, <&cru PCLK_PCIE20>, + <&cru CLK_PCIE20_AUX_NDFT>; + clock-names = "aclk_mst", "aclk_slv", + "aclk_dbi", "pclk", "aux"; + device_type = "pci"; + interrupts = , + , + , + , + ; + interrupt-names = "sys", "pmc", "msg", "legacy", "err"; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &pcie2x1_intc 0>, + <0 0 0 2 &pcie2x1_intc 1>, + <0 0 0 3 &pcie2x1_intc 2>, + <0 0 0 4 &pcie2x1_intc 3>; + linux,pci-domain = <0>; + num-ib-windows = <6>; + num-viewport = <8>; + num-ob-windows = <2>; + max-link-speed = <2>; + msi-map = <0x0 &its 0x0 0x1000>; + num-lanes = <1>; + phys = <&combphy2_psq PHY_TYPE_PCIE>; + phy-names = "pcie-phy"; + power-domains = <&power RK3568_PD_PIPE>; + ranges = <0x00000800 0x0 0xf4000000 0x0 0xf4000000 0x0 0x100000 + 0x81000000 0x0 0xf4100000 0x0 0xf4100000 0x0 0x100000 + 0x82000000 0x0 0xf4200000 0x0 0xf4200000 0x0 0x1e00000 + 0xc3000000 0x3 0x00000000 0x3 0x00000000 0x0 0x40000000>; + reg = <0x3 0xc0000000 0x0 0x400000>, + <0x0 0xfe260000 0x0 0x10000>; + reg-names = "pcie-dbi", "pcie-apb"; + resets = <&cru SRST_PCIE20_POWERUP>; + reset-names = "pipe"; + status = "disabled"; + + pcie2x1_intc: legacy-interrupt-controller { + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-parent = <&gic>; + interrupts = ; + }; + }; + + pcie3x1: pcie@fe270000 { + compatible = "rockchip,rk3568-pcie", "snps,dw-pcie"; + #address-cells = <3>; + #size-cells = <2>; + bus-range = <0x10 0x1f>; + clocks = <&cru ACLK_PCIE30X1_MST>, <&cru ACLK_PCIE30X1_SLV>, + <&cru ACLK_PCIE30X1_DBI>, <&cru PCLK_PCIE30X1>, + <&cru CLK_PCIE30X1_AUX_NDFT>; + clock-names = "aclk_mst", "aclk_slv", + "aclk_dbi", "pclk", "aux"; + device_type = "pci"; + interrupts = , + , + , + , + ; + interrupt-names = "sys", "pmc", "msg", "legacy", "err"; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &pcie3x1_intc 0>, + <0 0 0 2 &pcie3x1_intc 1>, + <0 0 0 3 &pcie3x1_intc 2>, + <0 0 0 4 &pcie3x1_intc 3>; + linux,pci-domain = <1>; + num-ib-windows = <6>; + num-ob-windows = <2>; + num-viewport = <8>; + max-link-speed = <3>; + msi-map = <0x1000 &its 0x1000 0x1000>; + num-lanes = <1>; + phys = <&pcie30phy>; + phy-names = "pcie-phy"; + power-domains = <&power RK3568_PD_PIPE>; + ranges = <0x00000800 0x0 0xf2000000 0x0 0xf2000000 0x0 0x100000 + 0x81000000 0x0 0xf2100000 0x0 0xf2100000 0x0 0x100000 + 0x82000000 0x0 0xf2200000 0x0 0xf2200000 0x0 0x1e00000 + 0xc3000000 0x3 0x40000000 0x3 0x40000000 0x0 0x40000000>; + reg = <0x3 0xc0400000 0x0 0x400000>, + <0x0 0xfe270000 0x0 0x10000>; + reg-names = "pcie-dbi", "pcie-apb"; + resets = <&cru SRST_PCIE30X1_POWERUP>; + reset-names = "pipe"; + /* rockchip,bifurcation; lane1 when using 1+1 */ + status = "disabled"; + + pcie3x1_intc: legacy-interrupt-controller { + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-parent = <&gic>; + interrupts = ; + }; + }; + + pcie3x2: pcie@fe280000 { + compatible = "rockchip,rk3568-pcie", "snps,dw-pcie"; + #address-cells = <3>; + #size-cells = <2>; + bus-range = <0x20 0x2f>; + clocks = <&cru ACLK_PCIE30X2_MST>, <&cru ACLK_PCIE30X2_SLV>, + <&cru ACLK_PCIE30X2_DBI>, <&cru PCLK_PCIE30X2>, + <&cru CLK_PCIE30X2_AUX_NDFT>; + clock-names = "aclk_mst", "aclk_slv", + "aclk_dbi", "pclk", "aux"; + device_type = "pci"; + interrupts = , + , + , + , + ; + interrupt-names = "sys", "pmc", "msg", "legacy", "err"; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &pcie3x2_intc 0>, + <0 0 0 2 &pcie3x2_intc 1>, + <0 0 0 3 &pcie3x2_intc 2>, + <0 0 0 4 &pcie3x2_intc 3>; + linux,pci-domain = <2>; + num-ib-windows = <6>; + num-viewport = <8>; + num-ob-windows = <2>; + max-link-speed = <3>; + msi-map = <0x2000 &its 0x2000 0x1000>; + num-lanes = <2>; + phys = <&pcie30phy>; + phy-names = "pcie-phy"; + power-domains = <&power RK3568_PD_PIPE>; + ranges = <0x00000800 0x0 0xf0000000 0x0 0xf0000000 0x0 0x100000 + 0x81000000 0x0 0xf0100000 0x0 0xf0100000 0x0 0x100000 + 0x82000000 0x0 0xf0200000 0x0 0xf0200000 0x0 0x1e00000 + 0xc3000000 0x3 0x80000000 0x3 0x80000000 0x0 0x40000000>; + reg = <0x3 0xc0800000 0x0 0x400000>, + <0x0 0xfe280000 0x0 0x10000>; + reg-names = "pcie-dbi", "pcie-apb"; + resets = <&cru SRST_PCIE30X2_POWERUP>; + reset-names = "pipe"; + /* rockchip,bifurcation; lane0 when using 1+1 */ + status = "disabled"; + + pcie3x2_intc: legacy-interrupt-controller { + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-parent = <&gic>; + interrupts = ; + }; + }; + + sdmmc0: dwmmc@fe2b0000 { + compatible = "rockchip,rk3568-dw-mshc", + "rockchip,rk3288-dw-mshc"; + reg = <0x0 0xfe2b0000 0x0 0x4000>; + interrupts = ; + max-frequency = <150000000>; + clocks = <&cru HCLK_SDMMC0>, <&cru CLK_SDMMC0>, + <&cru SCLK_SDMMC0_DRV>, <&cru SCLK_SDMMC0_SAMPLE>; + clock-names = "biu", "ciu", "ciu-drive", "ciu-sample"; + fifo-depth = <0x100>; + resets = <&cru SRST_SDMMC0>; + reset-names = "reset"; + status = "disabled"; + }; + + sdmmc1: dwmmc@fe2c0000 { + compatible = "rockchip,rk3568-dw-mshc", + "rockchip,rk3288-dw-mshc"; + reg = <0x0 0xfe2c0000 0x0 0x4000>; + interrupts = ; + max-frequency = <150000000>; + clocks = <&cru HCLK_SDMMC1>, <&cru CLK_SDMMC1>, + <&cru SCLK_SDMMC1_DRV>, <&cru SCLK_SDMMC1_SAMPLE>; + clock-names = "biu", "ciu", "ciu-drive", "ciu-sample"; + fifo-depth = <0x100>; + resets = <&cru SRST_SDMMC1>; + reset-names = "reset"; + status = "disabled"; + }; + + sfc: sfc@fe300000 { + compatible = "rockchip,sfc"; + reg = <0x0 0xfe300000 0x0 0x4000>; + interrupts = ; + clocks = <&cru SCLK_SFC>, <&cru HCLK_SFC>; + clock-names = "clk_sfc", "hclk_sfc"; + assigned-clocks = <&cru SCLK_SFC>; + assigned-clock-rates = <100000000>; + status = "disabled"; + }; + + sdhci: sdhci@fe310000 { + compatible = "rockchip,dwcmshc-sdhci", "snps,dwcmshc-sdhci"; + reg = <0x0 0xfe310000 0x0 0x10000>; + interrupts = ; + assigned-clocks = <&cru BCLK_EMMC>, <&cru TCLK_EMMC>, + <&cru CCLK_EMMC>; + assigned-clock-rates = <200000000>, <24000000>, <200000000>; + clocks = <&cru CCLK_EMMC>, <&cru HCLK_EMMC>, + <&cru ACLK_EMMC>, <&cru BCLK_EMMC>, + <&cru TCLK_EMMC>; + clock-names = "core", "bus", "axi", "block", "timer"; + status = "disabled"; + }; + + nandc0: nandc@fe330000 { + compatible = "rockchip,rk-nandc-v9"; + reg = <0x0 0xfe330000 0x0 0x4000>; + interrupts = ; + nandc_id = <0>; + clocks = <&cru NCLK_NANDC>, <&cru HCLK_NANDC>; + clock-names = "clk_nandc", "hclk_nandc"; + status = "disabled"; + }; + + crypto: crypto@fe380000 { + compatible = "rockchip,rk3568-crypto"; + reg = <0x0 0xfe380000 0x0 0x4000>; + interrupts = ; + clocks = <&cru ACLK_CRYPTO_NS>, <&cru HCLK_CRYPTO_NS>, + <&cru CLK_CRYPTO_NS_CORE>, <&cru CLK_CRYPTO_NS_PKA>; + clock-names = "aclk", "hclk", "sclk", "apb_pclk"; + assigned-clocks = <&cru CLK_CRYPTO_NS_CORE>; + assigned-clock-rates = <200000000>; + resets = <&cru SRST_CRYPTO_NS_CORE>; + reset-names = "crypto-rst"; + status = "disabled"; + }; + + rng: rng@fe388000 { + compatible = "rockchip,cryptov2-rng"; + reg = <0x0 0xfe388000 0x0 0x2000>; + clocks = <&cru CLK_TRNG_NS>, <&cru HCLK_TRNG_NS>; + clock-names = "clk_trng", "hclk_trng"; + resets = <&cru SRST_TRNG_NS>; + reset-names = "reset"; + status = "disabled"; + }; + + otp: otp@fe38c000 { + compatible = "rockchip,rk3568-otp"; + reg = <0x0 0xfe38c000 0x0 0x4000>; + #address-cells = <1>; + #size-cells = <1>; + clocks = <&cru CLK_OTPC_NS_USR>, <&cru CLK_OTPC_NS_SBPI>, + <&cru PCLK_OTPC_NS>, <&cru PCLK_OTPPHY>; + clock-names = "usr", "sbpi", "apb", "phy"; + resets = <&cru SRST_OTPPHY>; + reset-names = "otp_phy"; + + /* Data cells */ + cpu_code: cpu-code@2 { + reg = <0x02 0x2>; + }; + otp_cpu_version: cpu-version@8 { + reg = <0x08 0x1>; + bits = <3 3>; + }; + mbist_vmin: mbist-vmin@9 { + reg = <0x09 0x1>; + bits = <0 4>; + }; + otp_id: id@a { + reg = <0x0a 0x10>; + }; + cpu_leakage: cpu-leakage@1a { + reg = <0x1a 0x1>; + }; + log_leakage: log-leakage@1b { + reg = <0x1b 0x1>; + }; + npu_leakage: npu-leakage@1c { + reg = <0x1c 0x1>; + }; + gpu_leakage: gpu-leakage@1d { + reg = <0x1d 0x1>; + }; + core_pvtm:core-pvtm@2a { + reg = <0x2a 0x2>; + }; + }; + + i2s0_8ch: i2s@fe400000 { + compatible = "rockchip,rk3568-i2s-tdm"; + reg = <0x0 0xfe400000 0x0 0x1000>; + interrupts = ; + clocks = <&cru MCLK_I2S0_8CH_TX>, <&cru MCLK_I2S0_8CH_RX>, <&cru HCLK_I2S0_8CH>; + clock-names = "mclk_tx", "mclk_rx", "hclk"; + dmas = <&dmac1 0>; + dma-names = "tx"; + resets = <&cru SRST_M_I2S0_8CH_TX>, <&cru SRST_M_I2S0_8CH_RX>; + reset-names = "tx-m", "rx-m"; + rockchip,cru = <&cru>; + rockchip,grf = <&grf>; + rockchip,playback-only; + #sound-dai-cells = <0>; + status = "disabled"; + }; + + i2s1_8ch: i2s@fe410000 { + compatible = "rockchip,rk3568-i2s-tdm"; + reg = <0x0 0xfe410000 0x0 0x1000>; + interrupts = ; + clocks = <&cru MCLK_I2S1_8CH_TX>, <&cru MCLK_I2S1_8CH_RX>, <&cru HCLK_I2S1_8CH>; + clock-names = "mclk_tx", "mclk_rx", "hclk"; + dmas = <&dmac1 2>, <&dmac1 3>; + dma-names = "tx", "rx"; + resets = <&cru SRST_M_I2S1_8CH_TX>, <&cru SRST_M_I2S1_8CH_RX>; + reset-names = "tx-m", "rx-m"; + rockchip,cru = <&cru>; + rockchip,grf = <&grf>; + #sound-dai-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&i2s1m0_sclktx + &i2s1m0_sclkrx + &i2s1m0_lrcktx + &i2s1m0_lrckrx + &i2s1m0_sdi0 + &i2s1m0_sdi1 + &i2s1m0_sdi2 + &i2s1m0_sdi3 + &i2s1m0_sdo0 + &i2s1m0_sdo1 + &i2s1m0_sdo2 + &i2s1m0_sdo3>; + status = "disabled"; + }; + + i2s2_2ch: i2s@fe420000 { + compatible = "rockchip,rk3568-i2s-tdm"; + reg = <0x0 0xfe420000 0x0 0x1000>; + interrupts = ; + clocks = <&cru MCLK_I2S2_2CH>, <&cru MCLK_I2S2_2CH>, <&cru HCLK_I2S2_2CH>; + clock-names = "mclk_tx", "mclk_rx", "hclk"; + dmas = <&dmac1 4>, <&dmac1 5>; + dma-names = "tx", "rx"; + rockchip,cru = <&cru>; + rockchip,grf = <&grf>; + rockchip,clk-trcm = <1>; + #sound-dai-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&i2s2m0_sclktx + &i2s2m0_lrcktx + &i2s2m0_sdi + &i2s2m0_sdo>; + status = "disabled"; + }; + + i2s3_2ch: i2s@fe430000 { + compatible = "rockchip,rk3568-i2s-tdm"; + reg = <0x0 0xfe430000 0x0 0x1000>; + interrupts = ; + clocks = <&cru MCLK_I2S3_2CH_TX>, <&cru MCLK_I2S3_2CH_RX>, <&cru HCLK_I2S3_2CH>; + clock-names = "mclk_tx", "mclk_rx", "hclk"; + dmas = <&dmac1 6>, <&dmac1 7>; + dma-names = "tx", "rx"; + resets = <&cru SRST_M_I2S3_2CH_TX>, <&cru SRST_M_I2S3_2CH_RX>; + reset-names = "tx-m", "rx-m"; + rockchip,cru = <&cru>; + rockchip,grf = <&grf>; + rockchip,clk-trcm = <1>; + #sound-dai-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&i2s3m0_sclk + &i2s3m0_lrck + &i2s3m0_sdi + &i2s3m0_sdo>; + status = "disabled"; + }; + + pdm: pdm@fe440000 { + compatible = "rockchip,rk3568-pdm"; + reg = <0x0 0xfe440000 0x0 0x1000>; + clocks = <&cru MCLK_PDM>, <&cru HCLK_PDM>; + clock-names = "pdm_clk", "pdm_hclk"; + dmas = <&dmac1 9>; + dma-names = "rx"; + pinctrl-names = "default"; + pinctrl-0 = <&pdmm0_clk + &pdmm0_clk1 + &pdmm0_sdi0 + &pdmm0_sdi1 + &pdmm0_sdi2 + &pdmm0_sdi3>; + #sound-dai-cells = <0>; + status = "disabled"; + }; + + vad: vad@fe450000 { + compatible = "rockchip,rk3568-vad"; + reg = <0x0 0xfe450000 0x0 0x10000>; + reg-names = "vad"; + clocks = <&cru HCLK_VAD>; + clock-names = "hclk"; + interrupts = ; + rockchip,audio-src = <0>; + rockchip,det-channel = <0>; + rockchip,mode = <0>; + #sound-dai-cells = <0>; + status = "disabled"; + }; + + spdif_8ch: spdif@fe460000 { + compatible = "rockchip,rk3568-spdif"; + reg = <0x0 0xfe460000 0x0 0x1000>; + interrupts = ; + dmas = <&dmac1 1>; + dma-names = "tx"; + clock-names = "mclk", "hclk"; + clocks = <&cru MCLK_SPDIF_8CH>, <&cru HCLK_SPDIF_8CH>; + #sound-dai-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&spdifm0_tx>; + status = "disabled"; + }; + + audpwm: audpwm@fe470000 { + compatible = "rockchip,rk3568-audio-pwm", "rockchip,audio-pwm-v1"; + reg = <0x0 0xfe470000 0x0 0x1000>; + clocks = <&cru SCLK_AUDPWM>, <&cru HCLK_AUDPWM>; + clock-names = "clk", "hclk"; + dmas = <&dmac1 8>; + dma-names = "tx"; + #sound-dai-cells = <0>; + rockchip,sample-width-bits = <11>; + rockchip,interpolat-points = <1>; + status = "disabled"; + }; + + dig_acodec: codec-digital@fe478000 { + compatible = "rockchip,rk3568-codec-digital", "rockchip,codec-digital-v1"; + reg = <0x0 0xfe478000 0x0 0x1000>; + clocks = <&cru CLK_ACDCDIG_ADC>, <&cru CLK_ACDCDIG_DAC>, + <&cru CLK_ACDCDIG_I2C>, <&cru HCLK_ACDCDIG>; + clock-names = "adc", "dac", "i2c", "pclk"; + pinctrl-names = "default"; + pinctrl-0 = <&acodec_pins>; + resets = <&cru SRST_ACDCDIG>; + reset-names = "reset" ; + rockchip,grf = <&grf>; + #sound-dai-cells = <0>; + status = "disabled"; + }; + + dmac0: dmac@fe530000 { + compatible = "arm,pl330", "arm,primecell"; + reg = <0x0 0xfe530000 0x0 0x4000>; + interrupts = , + ; + clocks = <&cru ACLK_BUS>; + clock-names = "apb_pclk"; + #dma-cells = <1>; + arm,pl330-periph-burst; + }; + + dmac1: dmac@fe550000 { + compatible = "arm,pl330", "arm,primecell"; + reg = <0x0 0xfe550000 0x0 0x4000>; + interrupts = , + ; + clocks = <&cru ACLK_BUS>; + clock-names = "apb_pclk"; + #dma-cells = <1>; + arm,pl330-periph-burst; + }; + + scr: rkscr@fe560000 { + compatible = "rockchip-scr"; + reg = <0x0 0xfe560000 0x0 0x10000>; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&scr_pins>; + clocks = <&cru PCLK_SCR>; + clock-names = "g_pclk_sim_card"; + status = "disabled"; + }; + + can0: can@fe570000 { + compatible = "rockchip,canfd-1.0"; + reg = <0x0 0xfe570000 0x0 0x1000>; + interrupts = ; + clocks = <&cru CLK_CAN0>, <&cru PCLK_CAN0>; + clock-names = "baudclk", "apb_pclk"; + resets = <&cru SRST_CAN0>, <&cru SRST_P_CAN0>; + reset-names = "can", "can-apb"; + tx-fifo-depth = <1>; + rx-fifo-depth = <6>; + status = "disabled"; + }; + + can1: can@fe580000 { + compatible = "rockchip,canfd-1.0"; + reg = <0x0 0xfe580000 0x0 0x1000>; + interrupts = ; + clocks = <&cru CLK_CAN1>, <&cru PCLK_CAN1>; + clock-names = "baudclk", "apb_pclk"; + resets = <&cru SRST_CAN1>, <&cru SRST_P_CAN1>; + reset-names = "can", "can-apb"; + tx-fifo-depth = <1>; + rx-fifo-depth = <6>; + status = "disabled"; + }; + + can2: can@fe590000 { + compatible = "rockchip,canfd-1.0"; + reg = <0x0 0xfe590000 0x0 0x1000>; + interrupts = ; + clocks = <&cru CLK_CAN2>, <&cru PCLK_CAN2>; + clock-names = "baudclk", "apb_pclk"; + resets = <&cru SRST_CAN2>, <&cru SRST_P_CAN2>; + reset-names = "can", "can-apb"; + tx-fifo-depth = <1>; + rx-fifo-depth = <6>; + status = "disabled"; + }; + + i2c1: i2c@fe5a0000 { + compatible = "rockchip,rk3399-i2c"; + reg = <0x0 0xfe5a0000 0x0 0x1000>; + clocks = <&cru CLK_I2C1>, <&cru PCLK_I2C1>; + clock-names = "i2c", "pclk"; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_xfer>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c2: i2c@fe5b0000 { + compatible = "rockchip,rk3399-i2c"; + reg = <0x0 0xfe5b0000 0x0 0x1000>; + clocks = <&cru CLK_I2C2>, <&cru PCLK_I2C2>; + clock-names = "i2c", "pclk"; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&i2c2m0_xfer>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c3: i2c@fe5c0000 { + compatible = "rockchip,rk3399-i2c"; + reg = <0x0 0xfe5c0000 0x0 0x1000>; + clocks = <&cru CLK_I2C3>, <&cru PCLK_I2C3>; + clock-names = "i2c", "pclk"; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&i2c3m0_xfer>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c4: i2c@fe5d0000 { + compatible = "rockchip,rk3399-i2c"; + reg = <0x0 0xfe5d0000 0x0 0x1000>; + clocks = <&cru CLK_I2C4>, <&cru PCLK_I2C4>; + clock-names = "i2c", "pclk"; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&i2c4m0_xfer>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + i2c5: i2c@fe5e0000 { + compatible = "rockchip,rk3399-i2c"; + reg = <0x0 0xfe5e0000 0x0 0x1000>; + clocks = <&cru CLK_I2C5>, <&cru PCLK_I2C5>; + clock-names = "i2c", "pclk"; + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&i2c5m0_xfer>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + rktimer: timer@fe5f0000 { + compatible = "rockchip,rk3568-timer", "rockchip,rk3288-timer"; + reg = <0x0 0xfe5f0000 0x0 0x1000>; + interrupts = ; + clocks = <&cru PCLK_TIMER>, <&cru CLK_TIMER0>; + clock-names = "pclk", "timer"; + }; + + wdt: watchdog@fe600000 { + compatible = "snps,dw-wdt"; + reg = <0x0 0xfe600000 0x0 0x100>; + clocks = <&cru TCLK_WDT_NS>, <&cru PCLK_WDT_NS>; + clock-names = "tclk", "pclk"; + interrupts = ; + status = "okay"; + }; + + spi0: spi@fe610000 { + compatible = "rockchip,rk3066-spi"; + reg = <0x0 0xfe610000 0x0 0x1000>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&cru CLK_SPI0>, <&cru PCLK_SPI0>; + clock-names = "spiclk", "apb_pclk"; + dmas = <&dmac0 20>, <&dmac0 21>; + dma-names = "tx", "rx"; + pinctrl-names = "default", "high_speed"; + pinctrl-0 = <&spi0m0_cs0 &spi0m0_cs1 &spi0m0_pins>; + pinctrl-1 = <&spi0m0_cs0 &spi0m0_cs1 &spi0m0_pins_hs>; + status = "disabled"; + }; + + spi1: spi@fe620000 { + compatible = "rockchip,rk3066-spi"; + reg = <0x0 0xfe620000 0x0 0x1000>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&cru CLK_SPI1>, <&cru PCLK_SPI1>; + clock-names = "spiclk", "apb_pclk"; + dmas = <&dmac0 22>, <&dmac0 23>; + dma-names = "tx", "rx"; + pinctrl-names = "default", "high_speed"; + pinctrl-0 = <&spi1m0_cs0 &spi1m0_cs1 &spi1m0_pins>; + pinctrl-1 = <&spi1m0_cs0 &spi1m0_cs1 &spi1m0_pins_hs>; + status = "disabled"; + }; + + spi2: spi@fe630000 { + compatible = "rockchip,rk3066-spi"; + reg = <0x0 0xfe630000 0x0 0x1000>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&cru CLK_SPI2>, <&cru PCLK_SPI2>; + clock-names = "spiclk", "apb_pclk"; + dmas = <&dmac0 24>, <&dmac0 25>; + dma-names = "tx", "rx"; + pinctrl-names = "default", "high_speed"; + pinctrl-0 = <&spi2m0_cs0 &spi2m0_cs1 &spi2m0_pins>; + pinctrl-1 = <&spi2m0_cs0 &spi2m0_cs1 &spi2m0_pins_hs>; + status = "disabled"; + }; + + spi3: spi@fe640000 { + compatible = "rockchip,rk3066-spi"; + reg = <0x0 0xfe640000 0x0 0x1000>; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&cru CLK_SPI3>, <&cru PCLK_SPI3>; + clock-names = "spiclk", "apb_pclk"; + dmas = <&dmac0 26>, <&dmac0 27>; + dma-names = "tx", "rx"; + pinctrl-names = "default", "high_speed"; + pinctrl-0 = <&spi3m0_cs0 &spi3m0_cs1 &spi3m0_pins>; + pinctrl-1 = <&spi3m0_cs0 &spi3m0_cs1 &spi3m0_pins_hs>; + status = "disabled"; + }; + + uart1: serial@fe650000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe650000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART1>, <&cru PCLK_UART1>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 2>, <&dmac0 3>; + pinctrl-names = "default"; + pinctrl-0 = <&uart1m0_xfer>; + status = "disabled"; + }; + + uart2: serial@fe660000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe660000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART2>, <&cru PCLK_UART2>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 4>, <&dmac0 5>; + pinctrl-names = "default"; + pinctrl-0 = <&uart2m0_xfer>; + status = "disabled"; + }; + + uart3: serial@fe670000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe670000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART3>, <&cru PCLK_UART3>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 6>, <&dmac0 7>; + pinctrl-names = "default"; + pinctrl-0 = <&uart3m0_xfer>; + status = "disabled"; + }; + + uart4: serial@fe680000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe680000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART4>, <&cru PCLK_UART4>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 8>, <&dmac0 9>; + pinctrl-names = "default"; + pinctrl-0 = <&uart4m0_xfer>; + status = "disabled"; + }; + + uart5: serial@fe690000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe690000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART5>, <&cru PCLK_UART5>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 10>, <&dmac0 11>; + pinctrl-names = "default"; + pinctrl-0 = <&uart5m0_xfer>; + status = "disabled"; + }; + + uart6: serial@fe6a0000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe6a0000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART6>, <&cru PCLK_UART6>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 12>, <&dmac0 13>; + pinctrl-names = "default"; + pinctrl-0 = <&uart6m0_xfer>; + status = "disabled"; + }; + + uart7: serial@fe6b0000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe6b0000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART7>, <&cru PCLK_UART7>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 14>, <&dmac0 15>; + pinctrl-names = "default"; + pinctrl-0 = <&uart7m0_xfer>; + status = "disabled"; + }; + + uart8: serial@fe6c0000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe6c0000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART8>, <&cru PCLK_UART8>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 16>, <&dmac0 17>; + pinctrl-names = "default"; + pinctrl-0 = <&uart8m0_xfer>; + status = "disabled"; + }; + + uart9: serial@fe6d0000 { + compatible = "rockchip,rk3568-uart", "snps,dw-apb-uart"; + reg = <0x0 0xfe6d0000 0x0 0x100>; + interrupts = ; + clocks = <&cru SCLK_UART9>, <&cru PCLK_UART9>; + clock-names = "baudclk", "apb_pclk"; + reg-shift = <2>; + reg-io-width = <4>; + dmas = <&dmac0 18>, <&dmac0 19>; + pinctrl-names = "default"; + pinctrl-0 = <&uart9m0_xfer>; + status = "disabled"; + }; + + pwm4: pwm@fe6e0000 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6e0000 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm4_pins>; + clocks = <&cru CLK_PWM1>, <&cru PCLK_PWM1>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm5: pwm@fe6e0010 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6e0010 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm5_pins>; + clocks = <&cru CLK_PWM1>, <&cru PCLK_PWM1>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm6: pwm@fe6e0020 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6e0020 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm6_pins>; + clocks = <&cru CLK_PWM1>, <&cru PCLK_PWM1>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm7: pwm@fe6e0030 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6e0030 0x0 0x10>; + interrupts = , + ; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm7_pins>; + clocks = <&cru CLK_PWM1>, <&cru PCLK_PWM1>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm8: pwm@fe6f0000 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6f0000 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm8m0_pins>; + clocks = <&cru CLK_PWM2>, <&cru PCLK_PWM2>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm9: pwm@fe6f0010 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6f0010 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm9m0_pins>; + clocks = <&cru CLK_PWM2>, <&cru PCLK_PWM2>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm10: pwm@fe6f0020 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6f0020 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm10m0_pins>; + clocks = <&cru CLK_PWM2>, <&cru PCLK_PWM2>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm11: pwm@fe6f0030 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe6f0030 0x0 0x10>; + interrupts = , + ; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm11m0_pins>; + clocks = <&cru CLK_PWM2>, <&cru PCLK_PWM2>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm12: pwm@fe700000 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe700000 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm12m0_pins>; + clocks = <&cru CLK_PWM3>, <&cru PCLK_PWM3>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm13: pwm@fe700010 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe700010 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm13m0_pins>; + clocks = <&cru CLK_PWM3>, <&cru PCLK_PWM3>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm14: pwm@fe700020 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe700020 0x0 0x10>; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm14m0_pins>; + clocks = <&cru CLK_PWM3>, <&cru PCLK_PWM3>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + pwm15: pwm@fe700030 { + compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm"; + reg = <0x0 0xfe700030 0x0 0x10>; + interrupts = , + ; + #pwm-cells = <3>; + pinctrl-names = "active"; + pinctrl-0 = <&pwm15m0_pins>; + clocks = <&cru CLK_PWM3>, <&cru PCLK_PWM3>; + clock-names = "pwm", "pclk"; + status = "disabled"; + }; + + tsadc: tsadc@fe710000 { + compatible = "rockchip,rk3568-tsadc"; + reg = <0x0 0xfe710000 0x0 0x100>; + interrupts = ; + rockchip,grf = <&grf>; + clocks = <&cru CLK_TSADC>, <&cru PCLK_TSADC>; + clock-names = "tsadc", "apb_pclk"; + assigned-clocks = <&cru CLK_TSADC_TSEN>, <&cru CLK_TSADC>; + assigned-clock-rates = <17000000>, <700000>; + resets = <&cru SRST_TSADC>, <&cru SRST_P_TSADC>, + <&cru SRST_TSADCPHY>; + reset-names = "tsadc", "tsadc-apb", "tsadc-phy"; + #thermal-sensor-cells = <1>; + rockchip,hw-tshut-temp = <120000>; + rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */ + rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */ + pinctrl-names = "gpio", "otpout"; + pinctrl-0 = <&tsadc_gpio_func>; + pinctrl-1 = <&tsadc_shutorg>; + status = "disabled"; + }; + + saradc: saradc@fe720000 { + compatible = "rockchip,rk3568-saradc", "rockchip,rk3399-saradc"; + reg = <0x0 0xfe720000 0x0 0x100>; + interrupts = ; + #io-channel-cells = <1>; + clocks = <&cru CLK_SARADC>, <&cru PCLK_SARADC>; + clock-names = "saradc", "apb_pclk"; + resets = <&cru SRST_P_SARADC>; + reset-names = "saradc-apb"; + status = "disabled"; + }; + + mailbox: mailbox@fe780000 { + compatible = "rockchip,rk3568-mailbox", + "rockchip,rk3368-mailbox"; + reg = <0x0 0xfe780000 0x0 0x1000>; + interrupts = , + , + , + ; + clocks = <&cru PCLK_MAILBOX>; + clock-names = "pclk_mailbox"; + #mbox-cells = <1>; + status = "disabled"; + }; + + combphy0_us: phy@fe820000 { + compatible = "rockchip,rk3568-naneng-combphy"; + reg = <0x0 0xfe820000 0x0 0x100>; + #phy-cells = <1>; + clocks = <&pmucru CLK_PCIEPHY0_REF>, <&cru PCLK_PIPEPHY0>, + <&cru PCLK_PIPE>; + clock-names = "refclk", "apbclk", "pipe_clk"; + assigned-clocks = <&pmucru CLK_PCIEPHY0_REF>; + assigned-clock-rates = <100000000>; + resets = <&cru SRST_P_PIPEPHY0>, <&cru SRST_PIPEPHY0>; + reset-names = "combphy-apb", "combphy"; + rockchip,pipe-grf = <&pipegrf>; + rockchip,pipe-phy-grf = <&pipe_phy_grf0>; + status = "disabled"; + }; + + combphy1_usq: phy@fe830000 { + compatible = "rockchip,rk3568-naneng-combphy"; + reg = <0x0 0xfe830000 0x0 0x100>; + #phy-cells = <1>; + clocks = <&pmucru CLK_PCIEPHY1_REF>, <&cru PCLK_PIPEPHY1>, + <&cru PCLK_PIPE>; + clock-names = "refclk", "apbclk", "pipe_clk"; + assigned-clocks = <&pmucru CLK_PCIEPHY1_REF>; + assigned-clock-rates = <100000000>; + resets = <&cru SRST_P_PIPEPHY1>, <&cru SRST_PIPEPHY1>; + reset-names = "combphy-apb", "combphy"; + rockchip,pipe-grf = <&pipegrf>; + rockchip,pipe-phy-grf = <&pipe_phy_grf1>; + status = "disabled"; + }; + + combphy2_psq: phy@fe840000 { + compatible = "rockchip,rk3568-naneng-combphy"; + reg = <0x0 0xfe840000 0x0 0x100>; + #phy-cells = <1>; + clocks = <&pmucru CLK_PCIEPHY2_REF>, <&cru PCLK_PIPEPHY2>, + <&cru PCLK_PIPE>; + clock-names = "refclk", "apbclk", "pipe_clk"; + assigned-clocks = <&pmucru CLK_PCIEPHY2_REF>; + assigned-clock-rates = <100000000>; + resets = <&cru SRST_P_PIPEPHY2>, <&cru SRST_PIPEPHY2>; + reset-names = "combphy-apb", "combphy"; + rockchip,pipe-grf = <&pipegrf>; + rockchip,pipe-phy-grf = <&pipe_phy_grf2>; + status = "disabled"; + }; + + video_phy0: video-phy@fe850000 { + compatible = "rockchip,rk3568-video-phy"; + reg = <0x0 0xfe850000 0x0 0x10000>, + <0x0 0xfe060000 0x0 0x10000>; + clocks = <&pmucru CLK_MIPIDSIPHY0_REF>, + <&cru PCLK_MIPIDSIPHY0>, <&cru PCLK_DSITX_0>; + clock-names = "ref", "pclk_phy", "pclk_host"; + #clock-cells = <0>; + resets = <&cru SRST_P_MIPIDSIPHY0>; + reset-names = "rst"; + power-domains = <&power RK3568_PD_VO>; + #phy-cells = <0>; + status = "disabled"; + }; + + video_phy1: video-phy@fe860000 { + compatible = "rockchip,rk3568-video-phy"; + reg = <0x0 0xfe860000 0x0 0x10000>, + <0x0 0xfe070000 0x0 0x10000>; + clocks = <&pmucru CLK_MIPIDSIPHY1_REF>, + <&cru PCLK_MIPIDSIPHY1>, <&cru PCLK_DSITX_1>; + clock-names = "ref", "pclk_phy", "pclk_host"; + #clock-cells = <0>; + resets = <&cru SRST_P_MIPIDSIPHY1>; + reset-names = "rst"; + power-domains = <&power RK3568_PD_VO>; + #phy-cells = <0>; + status = "disabled"; + }; + + csi2_dphy_hw: csi2-dphy-hw@fe870000 { + compatible = "rockchip,rk3568-csi2-dphy-hw"; + reg = <0x0 0xfe870000 0x0 0x1000>; + clocks = <&cru PCLK_MIPICSIPHY>; + clock-names = "pclk"; + rockchip,grf = <&grf>; + status = "disabled"; + }; + + /* + * csi2_dphy0: used for csi2 dphy full mode, + is mutually exclusive with + csi2_dphy1 and csi2_dphy2 + * csi2_dphy1: used for csi2 dphy split mode, + physical lanes use lane0 and lane1, + can be used with csi2_dphy2 parallel + * csi2_dphy2: used for csi2 dphy split mode, + physical lanes use lane2 and lane3, + can be used with csi2_dphy1 parallel + */ + csi2_dphy0: csi2-dphy0 { + compatible = "rockchip,rk3568-csi2-dphy"; + rockchip,hw = <&csi2_dphy_hw>; + status = "disabled"; + }; + + csi2_dphy1: csi2-dphy1 { + compatible = "rockchip,rk3568-csi2-dphy"; + rockchip,hw = <&csi2_dphy_hw>; + status = "disabled"; + }; + + csi2_dphy2: csi2-dphy2 { + compatible = "rockchip,rk3568-csi2-dphy"; + rockchip,hw = <&csi2_dphy_hw>; + status = "disabled"; + }; + + usb2phy0: usb2-phy@fe8a0000 { + compatible = "rockchip,rk3568-usb2phy"; + reg = <0x0 0xfe8a0000 0x0 0x10000>; + interrupts = ; + clocks = <&pmucru CLK_USBPHY0_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + assigned-clocks = <&cru USB480M>; + assigned-clock-parents = <&usb2phy0>; + clock-output-names = "usb480m_phy"; + rockchip,usbgrf = <&usb2phy0_grf>; + status = "disabled"; + + u2phy0_host: host-port { + #phy-cells = <0>; + status = "disabled"; + }; + + u2phy0_otg: otg-port { + #phy-cells = <0>; + status = "disabled"; + }; + }; + + usb2phy1: usb2-phy@fe8b0000 { + compatible = "rockchip,rk3568-usb2phy"; + reg = <0x0 0xfe8b0000 0x0 0x10000>; + interrupts = ; + clocks = <&pmucru CLK_USBPHY1_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + rockchip,usbgrf = <&usb2phy1_grf>; + status = "disabled"; + + u2phy1_host: host-port { + #phy-cells = <0>; + status = "disabled"; + }; + + u2phy1_otg: otg-port { + #phy-cells = <0>; + status = "disabled"; + }; + }; + + pcie30phy: phy@fe8c0000 { + compatible = "rockchip,rk3568-pcie3-phy"; + reg = <0x0 0xfe8c0000 0x0 0x20000>; + #phy-cells = <0>; + clocks = <&pmucru CLK_PCIE30PHY_REF_M>, <&pmucru CLK_PCIE30PHY_REF_N>, + <&cru PCLK_PCIE30PHY>; + clock-names = "refclk_m", "refclk_n", "pclk"; + resets = <&cru SRST_PCIE30PHY>; + reset-names = "phy"; + rockchip,phy-grf = <&pcie30_phy_grf>; + status = "disabled"; + }; + + pinctrl: pinctrl { + compatible = "rockchip,rk3568-pinctrl"; + rockchip,grf = <&grf>; + rockchip,pmu = <&pmugrf>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + gpio0: gpio@fdd60000 { + compatible = "rockchip,gpio-bank"; + reg = <0x0 0xfdd60000 0x0 0x100>; + interrupts = ; + clocks = <&pmucru PCLK_GPIO0>, <&pmucru DBCLK_GPIO0>; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl 0 0 32>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + gpio1: gpio@fe740000 { + compatible = "rockchip,gpio-bank"; + reg = <0x0 0xfe740000 0x0 0x100>; + interrupts = ; + clocks = <&cru PCLK_GPIO1>, <&cru DBCLK_GPIO1>; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl 0 32 32>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + gpio2: gpio@fe750000 { + compatible = "rockchip,gpio-bank"; + reg = <0x0 0xfe750000 0x0 0x100>; + interrupts = ; + clocks = <&cru PCLK_GPIO2>, <&cru DBCLK_GPIO2>; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl 0 64 32>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + gpio3: gpio@fe760000 { + compatible = "rockchip,gpio-bank"; + reg = <0x0 0xfe760000 0x0 0x100>; + interrupts = ; + clocks = <&cru PCLK_GPIO3>, <&cru DBCLK_GPIO3>; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl 0 96 32>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + gpio4: gpio@fe770000 { + compatible = "rockchip,gpio-bank"; + reg = <0x0 0xfe770000 0x0 0x100>; + interrupts = ; + clocks = <&cru PCLK_GPIO4>, <&cru DBCLK_GPIO4>; + + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl 0 128 32>; + interrupt-controller; + #interrupt-cells = <2>; + }; + }; +}; + +#include "rk3568-pinctrl.dtsi" diff --git a/device_tree_led/Makefile b/device_tree_led/Makefile new file mode 100644 index 0000000..bc38f5a --- /dev/null +++ b/device_tree_led/Makefile @@ -0,0 +1,20 @@ +# 指定内核目录,根据实际编译内核时指定的输出目录,编译时没有指定,就是内核源码目录 +KERNEL_DIR=../../kernel + +ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +export ARCH CROSS_COMPILE + +obj-m := led_test.o +out = test_app + +all: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + $(CROSS_COMPILE)gcc -o $(out) test_app.c + +.PHONE:clean + +clean: + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean + rm $(out) + diff --git a/device_tree_led/README.md b/device_tree_led/README.md new file mode 100644 index 0000000..9b660ed --- /dev/null +++ b/device_tree_led/README.md @@ -0,0 +1,3 @@ +## Linux设备树——LED灯实验 + +参考教程https://doc.embedfire.com/linux/rk356x/driver/zh/latest/linux_driver/base_device_tree_rgb_led.html diff --git a/device_tree_led/led_test.c b/device_tree_led/led_test.c new file mode 100644 index 0000000..3211198 --- /dev/null +++ b/device_tree_led/led_test.c @@ -0,0 +1,227 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*------------------字符设备内容----------------------*/ +#define DEV_NAME "led_test" +#define DEV_CNT (1) + +/*定义 led 资源结构体,保存获取得到的节点信息以及转换后的虚拟寄存器地址*/ +struct led_resource +{ + struct device_node *device_node; //led的设备树节点 + void __iomem *va_DR; + void __iomem *va_DDR; +}; + +static dev_t led_devno; //定义字符设备的设备号 +static struct cdev led_chr_dev; //定义字符设备结构体chr_dev +struct class *class_led; //保存创建的类 +struct device *device; // 保存创建的设备 +struct device_node *led_test_device_node; //led_test的设备树节点结构体 + +/*定义led灯的led_resource 结构体,保存获取得到的节点信息*/ +struct led_resource led_res; + +/*字符设备操作函数集,open函数*/ +static int led_chr_dev_open(struct inode *inode, struct file *filp) +{ + printk("\n led_chr_dev_open \n"); + return 0; +} + +/*字符设备操作函数集,write函数*/ +static ssize_t led_chr_dev_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offt) +{ + + unsigned int register_data = 0; //暂存读取得到的寄存器数据 + unsigned char write_data; //用于保存接收到的数据 + + int error = copy_from_user(&write_data, buf, cnt); + if (error < 0) + { + return -1; + } + /*设置led引脚 输出电平*/ + if (write_data) + { + register_data |= ((unsigned int)0x1 << (23)); + register_data |= ((unsigned int)0x1 << (7)); + writel(register_data, led_res.va_DR); // GPIO0_C7引脚输出高电平,红灯灭 + } + else + { + register_data |= ((unsigned int)0x1 << (23)); + register_data &= ~((unsigned int)0x1 << (7)); + writel(register_data, led_res.va_DR); // GPIO0_C7引脚输出低电平,红灯亮 + } + + return 0; + +} + +/*字符设备操作函数集*/ +static struct file_operations led_chr_dev_fops = + { + .owner = THIS_MODULE, + .open = led_chr_dev_open, + .write = led_chr_dev_write, +}; + +/*----------------平台驱动函数集-----------------*/ +static int led_probe(struct platform_device *pdv) +{ + + int ret = -1; //保存错误状态码 + unsigned int register_data = 0; + + printk(KERN_EMERG "\t match successed \n"); + + /*获取led_test的设备树节点*/ + led_test_device_node = of_find_node_by_path("/led_test"); + if (led_test_device_node == NULL) + { + printk(KERN_ERR "\t get led_test failed! \n"); + return -1; + } + + /*获取led节点*/ + led_res.device_node = of_find_node_by_name(led_test_device_node,"led"); + if (led_res.device_node == NULL) + { + printk(KERN_ERR "\n get led_device_node failed ! \n"); + return -1; + } + + /*获取 reg 属性并转化为虚拟地址*/ + led_res.va_DR = of_iomap(led_res.device_node, 0); + if(led_res.va_DR == NULL){ + printk("of_iomap is error \n"); + return -1; + } + + led_res.va_DDR = of_iomap(led_res.device_node, 1); + if(led_res.va_DDR == NULL){ + printk("of_iomap is error \n"); + return -1; + } + + // 设置模式寄存器:输出模式 + register_data = readl(led_res.va_DDR); + register_data |= ((unsigned int)0x1 << (23)); + register_data |= ((unsigned int)0x1 << (7)); + writel(register_data,led_res.va_DDR); + + // 设置置位寄存器:默认输出高电平 + register_data = readl(led_res.va_DR); + register_data |= ((unsigned int)0x1 << (23)); + register_data |= ((unsigned int)0x1 << (7)); + writel(register_data, led_res.va_DR); + + /*---------------------注册 字符设备部分-----------------*/ + + //第一步 + //采用动态分配的方式,获取设备编号,次设备号为0, + //DEV_CNT为1,当前只申请一个设备编号 + ret = alloc_chrdev_region(&led_devno, 0, DEV_CNT, DEV_NAME); + if (ret < 0) + { + printk("fail to alloc led_devno\n"); + goto alloc_err; + } + //第二步 + //关联字符设备结构体cdev与文件操作结构体file_operations + led_chr_dev.owner = THIS_MODULE; + cdev_init(&led_chr_dev, &led_chr_dev_fops); + + //第三步 + //添加设备至cdev_map散列表中 + ret = cdev_add(&led_chr_dev, led_devno, DEV_CNT); + if (ret < 0) + { + printk("fail to add cdev\n"); + goto add_err; + } + + //第四步 + /*创建类 */ + class_led = class_create(THIS_MODULE, DEV_NAME); + + /*创建设备*/ + device = device_create(class_led, NULL, led_devno, NULL, DEV_NAME); + + return 0; + +add_err: + //添加设备失败时,需要注销设备号 + unregister_chrdev_region(led_devno, DEV_CNT); + printk("\n error! \n"); +alloc_err: + + return -1; +} + +static const struct of_device_id led_ids[] = { + {.compatible = "fire,led_test"}, + {/* sentinel */} +}; + +/*定义平台设备结构体*/ +struct platform_driver led_platform_driver = { + .probe = led_probe, + .driver = { + .name = "leds-platform", + .owner = THIS_MODULE, + .of_match_table = led_ids, + }}; + +/* +*驱动初始化函数 +*/ +static int __init led_platform_driver_init(void) +{ + int DriverState; + DriverState = platform_driver_register(&led_platform_driver); + printk(KERN_EMERG "\tDriverState is %d\n", DriverState); + return 0; +} + +/* +*驱动注销函数 +*/ +static void __exit led_platform_driver_exit(void) +{ + /*取消物理地址映射到虚拟地址*/ + iounmap(led_res.va_DR); + iounmap(led_res.va_DDR); + + /*删除设备*/ + device_destroy(class_led, led_devno); //清除设备 + class_destroy(class_led); //清除类 + cdev_del(&led_chr_dev); //清除设备号 + unregister_chrdev_region(led_devno, DEV_CNT); //取消注册字符设备 + + /*注销字符设备*/ + platform_driver_unregister(&led_platform_driver); + + printk(KERN_EMERG "dts test led exit!\n"); +} + +module_init(led_platform_driver_init); +module_exit(led_platform_driver_exit); + +MODULE_LICENSE("GPL"); diff --git a/device_tree_led/rk3568-lubancat-2.dts b/device_tree_led/rk3568-lubancat-2.dts new file mode 100644 index 0000000..7596a0a --- /dev/null +++ b/device_tree_led/rk3568-lubancat-2.dts @@ -0,0 +1,1260 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2020 Rockchip Electronics Co., Ltd. + * + */ + + /dts-v1/; + +#include +#include +#include +#include +#include +#include +#include +#include "rk3568.dtsi" + +//MIPI摄像头配置 +#include "rk3568-lubancat-csi2.dtsi" + +// MIPI屏幕设置,通用镜像使用设备树插件 +//专用镜像如果要开启MIPI屏幕支持,按屏幕型号开启1-3 +//以下3个配置互斥,不可同时开启 +// #include "rk3568-lubancat-dsi0-ebf410125_720p.dtsi" //野火5.5寸 720P +// #include "rk3568-lubancat-dsi0-ebf410125_1080p.dtsi" //野火5.5寸 1080P +// #include "rk3568-lubancat-dsi0-rpi.dtsi" //树莓派 5寸 800x480 + + +/ { + model = "EmbedFire LubanCat-2"; + compatible = "embedfire,lubancat-2", "rockchip,rk3568"; + + chosen: chosen { + bootargs = "earlycon=uart8250,mmio32,0xfe660000 console=ttyFIQ0 root=PARTUUID=614e0000-0000 rw rootwait"; + }; + + fiq-debugger { + compatible = "rockchip,fiq-debugger"; + rockchip,serial-id = <2>; + rockchip,wake-irq = <0>; + /* If enable uart uses irq instead of fiq */ + rockchip,irq-mode-enable = <1>; + rockchip,baudrate = <1500000>; /* Only 115200 and 1500000 */ + interrupts = ; + pinctrl-names = "default"; + pinctrl-0 = <&uart2m0_xfer>; + status = "okay"; + }; + + debug: debug@fd904000 { + compatible = "rockchip,debug"; + reg = <0x0 0xfd904000 0x0 0x1000>, + <0x0 0xfd905000 0x0 0x1000>, + <0x0 0xfd906000 0x0 0x1000>, + <0x0 0xfd907000 0x0 0x1000>; + }; + + cspmu: cspmu@fd90c000 { + compatible = "rockchip,cspmu"; + reg = <0x0 0xfd90c000 0x0 0x1000>, + <0x0 0xfd90d000 0x0 0x1000>, + <0x0 0xfd90e000 0x0 0x1000>, + <0x0 0xfd90f000 0x0 0x1000>; + }; + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + ramoops: ramoops@110000 { + compatible = "ramoops"; + reg = <0x0 0x110000 0x0 0xf0000>; + record-size = <0x20000>; + console-size = <0x80000>; + ftrace-size = <0x00000>; + pmsg-size = <0x50000>; + }; + + abc: abc@80900000{ + reg = <0x0 0x80900000 0x0 0x100000>; + }; + }; + + adc_keys: adc-keys { + compatible = "adc-keys"; + io-channels = <&saradc 0>; + io-channel-names = "buttons"; + keyup-threshold-microvolt = <1800000>; + poll-interval = <100>; + + restart-key { + label = "restart"; + linux,code = ; + press-threshold-microvolt = <9>; + }; + }; + + dc_5v: dc-5v { + compatible = "regulator-fixed"; + regulator-name = "dc_5v"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + + vcc5v0_sys: vcc5v0-sys { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_sys"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&dc_5v>; + }; + + vcc3v3_sys: vcc3v3-sys { + compatible = "regulator-fixed"; + regulator-name = "vcc3v3_sys"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vcc5v0_sys>; + }; + + vcc5v0_usb20_host: vcc5v0-usb20-host-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio0 RK_PD5 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&vcc5v0_usb20_host_en>; + regulator-name = "vcc5v0_usb20_host"; + regulator-always-on; + }; + + vcc5v0_usb30_host: vcc5v0-usb30-host-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&vcc5v0_usb30_host_en>; + regulator-name = "vcc5v0_usb30_host"; + regulator-always-on; + }; + + vcc5v0_otg_vbus: vcc5v0-otg-vbus-regulator { + compatible = "regulator-fixed"; + enable-active-high; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio0 RK_PD3 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&vcc5v0_otg_vbus_en>; + regulator-name = "vcc5v0_otg_vbus"; + }; + + mini_pcie_3v3: mini-pcie-3v3-regulator { + compatible = "regulator-fixed"; + regulator-name = "minipcie_3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + enable-active-high; + regulator-always-on; + gpio = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>; + startup-delay-us = <5000>; + vin-supply = <&vcc5v0_sys>; + }; + + pcie30_3v3: gpio-regulator { + compatible = "regulator-gpio"; + regulator-name = "pcie30_3v3"; + regulator-min-microvolt = <100000>; + regulator-max-microvolt = <3300000>; + gpios = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>; + gpios-states = <0x1>; + states = <100000 0x0 + 3300000 0x1>; + }; + + mipi_dsi0_power: mipi-dsi0-power-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio3 RK_PA3 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&mipi_dsi0_pwr_en>; + regulator-name = "mipi_dsi0_power"; + regulator-always-on; + }; + + vdd_cam_5v: vdd-cam-5v-regulator { + compatible = "regulator-fixed"; + regulator-name = "vdd_cam_5v"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + gpio = <&gpio3 RK_PA4 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&cam_pwr_en>; + enable-active-high; + regulator-always-on; + }; + + cam_dovdd: cam-dovdd { + compatible = "regulator-fixed"; + regulator-name = "cam_dovdd"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vdd_cam_5v>; + }; + + cam_avdd: cam-avdd { + compatible = "regulator-fixed"; + regulator-name = "cam_avdd"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + vin-supply = <&vdd_cam_5v>; + }; + + cam_dvdd: cam-dvdd { + compatible = "regulator-fixed"; + regulator-name = "cam_dvdd"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + vin-supply = <&vdd_cam_5v>; + }; + + // leds: leds { + // status = "disabled"; + // //status = "okay"; + // compatible = "gpio-leds"; + + // sys_status_led: sys-status-led { + // label = "sys_status_led"; + // linux,default-trigger = "heartbeat"; + // default-state = "on"; + // gpios = <&gpio0 RK_PC7 GPIO_ACTIVE_LOW>; + // pinctrl-names = "default"; + // pinctrl-0 = <&sys_status_led_pin>; + // }; + // }; + + /*添加led_test节点,*/ + led_test{ + #address-cells = <1>; + #size-cells = <1>; + compatible = "fire,led_test"; + ranges; + + //例程是控制lubancat2的系统灯 GPIO0_C7 + led@0xfdd60004{ + //reg = < 0xfe770004 0x00000004 0xfe77000C 0x00000004>; //GPIO4_D2 + reg = <0xfdd60004 0x00000004 0xfdd6000C 0x00000004>; //GPIO0_H 的数据寄存器和数据方向寄存器 + status = "okay"; + }; + }; + + rk809_sound: rk809-sound { + status = "okay"; + compatible = "simple-audio-card"; + simple-audio-card,format = "i2s"; + simple-audio-card,name = "rockchip,rk809-codec"; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphone Jack"; + simple-audio-card,routing = + "Mic Jack", "MICBIAS1", + "IN1P", "Mic Jack", + "Headphone Jack", "HPOL", + "Headphone Jack", "HPOR"; + simple-audio-card,cpu { + sound-dai = <&i2s1_8ch>; + }; + simple-audio-card,codec { + sound-dai = <&rk809_codec>; + }; + }; + + rk_headset: rk-headset { + status = "okay"; + compatible = "rockchip_headset"; + headset_gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&hp_det>; + io-channels = <&saradc 1>; + }; + + ext_cam_clk: external-camera-clock { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24000000>; + clock-output-names = "CLK_CAMERA1_24MHZ"; + }; + + backlight: backlight { + status = "okay"; + compatible = "pwm-backlight"; + pwms = <&pwm4 0 50000 0>; + brightness-levels = < + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 95 95 95 95 95 95 95 95 + 88 89 90 91 92 93 94 95 + 96 97 98 99 100 101 102 103 + 104 105 106 107 108 109 110 111 + 112 113 114 115 116 117 118 119 + 120 121 122 123 124 125 126 127 + 128 129 130 131 132 133 134 135 + 136 137 138 139 140 141 142 143 + 144 145 146 147 148 149 150 151 + 152 153 154 155 156 157 158 159 + 160 161 162 163 164 165 166 167 + 168 169 170 171 172 173 174 175 + 176 177 178 179 180 181 182 183 + 184 185 186 187 188 189 190 191 + 192 193 194 195 196 197 198 199 + 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 + 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 + 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 + 248 249 250 251 252 253 254 255 + >; + default-brightness-level = <200>; + }; + + test-power { + status = "okay"; + }; +}; + +&saradc { + vref-supply = <&vcca_1v8>; + status = "okay"; +}; + +&tsadc { + status = "okay"; +}; + +&i2s1_8ch { + status = "okay"; + rockchip,clk-trcm = <1>; + /delete-property/ rockchip,playback-only; + pinctrl-names = "default"; + pinctrl-0 = <&i2s1m0_sclktx + &i2s1m0_lrcktx + &i2s1m0_sdi0 + &i2s1m0_sdo0>; +}; + +&pwm4 { + status = "okay"; +}; + +&pwm7 { + status = "okay"; + + compatible = "rockchip,remotectl-pwm"; + interrupts = ; + remote_pwm_id = <3>; + handle_cpu_id = <1>; + remote_support_psci = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pwm7_pins>; + + ir_key_lubancat{ + rockchip,usercode = <0x909>; + rockchip,key_table = + <0xf4 KEY_POWER>, + <0xe6 KEY_SLEEP>, + <0xe4 KEY_WAKEUP>, + <0xed KEY_VOLUMEUP>, + <0xec KEY_VOLUMEDOWN>, + <0xef KEY_UP>, + <0xee KEY_DOWN>; + }; + + ir_key1 { + rockchip,usercode = <0x4040>; + rockchip,key_table = + <0xf2 KEY_REPLY>, + <0xba KEY_BACK>, + <0xf4 KEY_UP>, + <0xf1 KEY_DOWN>, + <0xef KEY_LEFT>, + <0xee KEY_RIGHT>, + <0xbd KEY_HOME>, + <0xea KEY_VOLUMEUP>, + <0xe3 KEY_VOLUMEDOWN>, + <0xe2 KEY_SEARCH>, + <0xb2 KEY_POWER>, + <0xbc KEY_MUTE>, + <0xec KEY_MENU>, + <0xbf 0x190>, + <0xe0 0x191>, + <0xe1 0x192>, + <0xe9 183>, + <0xe6 248>, + <0xe8 185>, + <0xe7 186>, + <0xf0 388>, + <0xbe 0x175>; + }; + + ir_key2 { + rockchip,usercode = <0xff00>; + rockchip,key_table = + <0xf9 KEY_HOME>, + <0xbf KEY_BACK>, + <0xfb KEY_MENU>, + <0xaa KEY_REPLY>, + <0xb9 KEY_UP>, + <0xe9 KEY_DOWN>, + <0xb8 KEY_LEFT>, + <0xea KEY_RIGHT>, + <0xeb KEY_VOLUMEDOWN>, + <0xef KEY_VOLUMEUP>, + <0xf7 KEY_MUTE>, + <0xe7 KEY_POWER>, + <0xfc KEY_POWER>, + <0xa9 KEY_VOLUMEDOWN>, + <0xa8 KEY_VOLUMEDOWN>, + <0xe0 KEY_VOLUMEDOWN>, + <0xa5 KEY_VOLUMEDOWN>, + <0xab 183>, + <0xb7 388>, + <0xe8 388>, + <0xf8 184>, + <0xaf 185>, + <0xed KEY_VOLUMEDOWN>, + <0xee 186>, + <0xb3 KEY_VOLUMEDOWN>, + <0xf1 KEY_VOLUMEDOWN>, + <0xf2 KEY_VOLUMEDOWN>, + <0xf3 KEY_SEARCH>, + <0xb4 KEY_VOLUMEDOWN>, + <0xbe KEY_SEARCH>; + }; + + ir_key3 { + rockchip,usercode = <0x1dcc>; + rockchip,key_table = + <0xee KEY_REPLY>, + <0xf0 KEY_BACK>, + <0xf8 KEY_UP>, + <0xbb KEY_DOWN>, + <0xef KEY_LEFT>, + <0xed KEY_RIGHT>, + <0xfc KEY_HOME>, + <0xf1 KEY_VOLUMEUP>, + <0xfd KEY_VOLUMEDOWN>, + <0xb7 KEY_SEARCH>, + <0xff KEY_POWER>, + <0xf3 KEY_MUTE>, + <0xbf KEY_MENU>, + <0xf9 0x191>, + <0xf5 0x192>, + <0xb3 388>, + <0xbe KEY_1>, + <0xba KEY_2>, + <0xb2 KEY_3>, + <0xbd KEY_4>, + <0xf9 KEY_5>, + <0xb1 KEY_6>, + <0xfc KEY_7>, + <0xf8 KEY_8>, + <0xb0 KEY_9>, + <0xb6 KEY_0>, + <0xb5 KEY_BACKSPACE>; + }; +}; + +&cpu0 { + cpu-supply = <&vdd_cpu>; +}; + +&dfi { + status = "okay"; +}; + +&dmc { + system-status-freq = < + /*system status freq(KHz)*/ + SYS_STATUS_NORMAL 780000 + SYS_STATUS_REBOOT 1560000 + SYS_STATUS_SUSPEND 324000 + SYS_STATUS_VIDEO_1080P 528000 + SYS_STATUS_BOOST 1560000 + SYS_STATUS_ISP 1560000 + SYS_STATUS_PERFORMANCE 1560000 + >; + center-supply = <&vdd_logic>; + status = "okay"; +}; + +&dmc_opp_table { + opp-324000000 { + opp-hz = /bits/ 64 <324000000>; + opp-microvolt = <875000>; + opp-microvolt-L0 = <875000>; + opp-microvolt-L1 = <850000>; + }; + + opp-528000000 { + opp-hz = /bits/ 64 <528000000>; + opp-microvolt = <875000>; + opp-microvolt-L0 = <875000>; + opp-microvolt-L1 = <850000>; + }; + + opp-528000000 { + opp-hz = /bits/ 64 <780000000>; + opp-microvolt = <875000>; + opp-microvolt-L0 = <875000>; + opp-microvolt-L1 = <850000>; + }; + + opp-1560000000 { + opp-hz = /bits/ 64 <1560000000>; + opp-microvolt = <900000>; + opp-microvolt-L0 = <900000>; + opp-microvolt-L1 = <850000>; + }; +}; + +&gpu { + mali-supply = <&vdd_gpu>; + status = "okay"; +}; + +&xin32k { + status = "disabled"; +}; + +&i2c0 { + status = "okay"; + + vdd_cpu: tcs4525@1c { + compatible = "tcs,tcs452x"; + reg = <0x1c>; + vin-supply = <&vcc5v0_sys>; + regulator-compatible = "fan53555-reg"; + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <712500>; + regulator-max-microvolt = <1390000>; + regulator-ramp-delay = <2300>; + fcs,suspend-voltage-selector = <1>; + regulator-boot-on; + regulator-always-on; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; +/* + vdd_cpu: syr827@40 { + compatible = "silergy,syr827"; + reg = <0x40>; + fcs,suspend-voltage-selector = <1>; + regulator-name = "vdd_cpu"; + regulator-min-microvolt = <712500>; + regulator-max-microvolt = <1390000>; + regulator-ramp-delay = <2300>; + regulator-always-on; + regulator-boot-on; + vin-supply = <&vcc5v0_sys>; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; +*/ + rk809: pmic@20 { + compatible = "rockchip,rk809"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + + pinctrl-names = "default", "pmic-sleep", + "pmic-power-off", "pmic-reset"; + pinctrl-0 = <&pmic_int>; + pinctrl-1 = <&soc_slppin_slp>, <&rk817_slppin_slp>; + pinctrl-2 = <&soc_slppin_gpio>, <&rk817_slppin_pwrdn>; + pinctrl-3 = <&soc_slppin_gpio>, <&rk817_slppin_rst>; + + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + clock-output-names = "rk808-clkout1", "rk808-clkout2"; + //fb-inner-reg-idxs = <2>; + /* 1: rst regs (default in codes), 0: rst the pmic */ + pmic-reset-func = <0>; + /* not save the PMIC_POWER_EN register in uboot */ + not-save-power-en = <1>; + + vcc1-supply = <&vcc3v3_sys>; + vcc2-supply = <&vcc3v3_sys>; + vcc3-supply = <&vcc3v3_sys>; + vcc4-supply = <&vcc3v3_sys>; + vcc5-supply = <&vcc3v3_sys>; + vcc6-supply = <&vcc3v3_sys>; + vcc7-supply = <&vcc3v3_sys>; + vcc8-supply = <&vcc3v3_sys>; + vcc9-supply = <&vcc3v3_sys>; + + pwrkey { + status = "okay"; + }; + + pinctrl_rk8xx: pinctrl_rk8xx { + gpio-controller; + #gpio-cells = <2>; + + rk817_slppin_null: rk817_slppin_null { + pins = "gpio_slp"; + function = "pin_fun0"; + }; + + rk817_slppin_slp: rk817_slppin_slp { + pins = "gpio_slp"; + function = "pin_fun1"; + }; + + rk817_slppin_pwrdn: rk817_slppin_pwrdn { + pins = "gpio_slp"; + function = "pin_fun2"; + }; + + rk817_slppin_rst: rk817_slppin_rst { + pins = "gpio_slp"; + function = "pin_fun3"; + }; + }; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1350000>; + regulator-init-microvolt = <900000>; + regulator-ramp-delay = <6001>; + regulator-initial-mode = <0x2>; + regulator-name = "vdd_logic"; + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vdd_gpu: DCDC_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1350000>; + regulator-init-microvolt = <900000>; + regulator-ramp-delay = <6001>; + regulator-initial-mode = <0x2>; + regulator-name = "vdd_gpu"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-initial-mode = <0x2>; + regulator-name = "vcc_ddr"; + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vdd_npu: DCDC_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1350000>; + regulator-init-microvolt = <900000>; + regulator-ramp-delay = <6001>; + regulator-initial-mode = <0x2>; + regulator-name = "vdd_npu"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vdda0v9_image: LDO_REG1 { + regulator-boot-on; + regulator-always-on; + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <900000>; + regulator-name = "vdda0v9_image"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vdda_0v9: LDO_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <900000>; + regulator-name = "vdda_0v9"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vdda0v9_pmu: LDO_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <900000>; + regulator-name = "vdda0v9_pmu"; + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <900000>; + }; + }; + + vccio_acodec: LDO_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_acodec"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vccio_sd"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc3v3_pmu: LDO_REG6 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc3v3_pmu"; + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcca_1v8: LDO_REG7 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcca_1v8"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcca1v8_pmu: LDO_REG8 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcca1v8_pmu"; + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vcca1v8_image: LDO_REG9 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcca1v8_image"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_1v8: DCDC_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "vcc_1v8"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_3v3: SWITCH_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_3v3"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc3v3_sd: SWITCH_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc3v3_sd"; + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + }; + + rk809_codec: codec { + #sound-dai-cells = <0>; + compatible = "rockchip,rk809-codec", "rockchip,rk817-codec"; + clocks = <&cru I2S1_MCLKOUT_TX>; + clock-names = "mclk"; + assigned-clocks = <&cru I2S1_MCLKOUT_TX>, <&cru I2S1_MCLK_TX_IOE>; + assigned-clock-rates = <12288000>; + assigned-clock-parents = <&cru CLK_I2S1_8CH_TX>, <&cru I2S1_MCLKOUT_TX>; + pinctrl-names = "default"; + pinctrl-0 = <&i2s1m0_mclk>; + hp-volume = <20>; + spk-volume = <3>; + //mic-in-differential; + status = "okay"; + }; + }; +}; + +&i2c1 { + status = "okay"; + clock-frequency = <100000>; + + rockpi_ft5406: rockpi_ft5406@38 { + compatible = "rockpi_ft5406"; + reg = <0x38>; + status = "okay"; + }; +}; + +&iep { + status = "okay"; +}; + +&iep_mmu { + status = "okay"; +}; + +&jpegd { + status = "okay"; +}; + +&jpegd_mmu { + status = "okay"; +}; + +&mpp_srv { + status = "okay"; +}; + +&pmu_io_domains { + status = "okay"; + pmuio1-supply = <&vcc3v3_pmu>; + pmuio2-supply = <&vcc3v3_pmu>; + vccio1-supply = <&vccio_acodec>; + vccio3-supply = <&vccio_sd>; + vccio4-supply = <&vcc_1v8>; + vccio5-supply = <&vcc_3v3>; + vccio6-supply = <&vcc_1v8>; + vccio7-supply = <&vcc_3v3>; +}; + +&rk_rga { + status = "okay"; +}; + +&rkvdec { + status = "okay"; +}; + +&rkvdec_mmu { + status = "okay"; +}; + +&rkvenc { + venc-supply = <&vdd_logic>; + status = "okay"; +}; + +&rkvenc_mmu { + status = "okay"; +}; + +&rknpu { + rknpu-supply = <&vdd_npu>; + status = "okay"; +}; + +&rknpu_mmu { + status = "okay"; +}; + +&bus_npu { + bus-supply = <&vdd_logic>; + pvtm-supply = <&vdd_cpu>; + status = "okay"; +}; + +&sdhci { + bus-width = <8>; + supports-emmc; + non-removable; + max-frequency = <200000000>; + status = "okay"; +}; + +&sdmmc0 { + max-frequency = <150000000>; + supports-sd; + bus-width = <4>; + cap-mmc-highspeed; + cap-sd-highspeed; + disable-wp; + sd-uhs-sdr104; + vmmc-supply = <&vcc3v3_sd>; + vqmmc-supply = <&vccio_sd>; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>; + status = "okay"; +}; + +&vdpu { + status = "okay"; +}; + +&vdpu_mmu { + status = "okay"; +}; + +&vepu { + status = "okay"; +}; + +&vepu_mmu { + status = "okay"; +}; + +&vop { + status = "okay"; + assigned-clocks = <&cru DCLK_VOP0>, <&cru DCLK_VOP1>; + assigned-clock-parents = <&pmucru PLL_HPLL>, <&cru PLL_VPLL>; + disable-win-move; +}; + +&vop_mmu { + status = "okay"; +}; + +&vp0 { + cursor-win-id = ; +}; + +&rng { + status = "okay"; +}; + +&rockchip_suspend { + status = "okay"; +}; + +/* USB OTG/USB Host_1 USB 2.0 Comb */ +&usb2phy0 { + status = "okay"; +}; + +&u2phy0_host { + phy-supply = <&vcc5v0_usb30_host>; + status = "okay"; +}; + +&u2phy0_otg { + vbus-supply = <&vcc5v0_otg_vbus>; + status = "okay"; +}; + +&usb_host0_ehci { + status = "okay"; +}; + +&usb_host0_ohci { + status = "okay"; +}; + +/* USB Host_2/USB Host_3 USB 2.0 Comb */ +&usb2phy1 { + status = "okay"; +}; + +&u2phy1_otg { + phy-supply = <&vcc5v0_usb20_host>; + status = "okay"; +}; + +&u2phy1_host { + status = "okay"; +}; + +&usb_host1_ehci { + status = "okay"; +}; + +&usb_host1_ohci { + status = "okay"; +}; + +/* MULTI_PHY0 For SATA0, USB3.0 OTG Only USB2.0 */ +&combphy0_us { + status = "okay"; +}; + +&usbdrd30 { + status = "okay"; +}; + +&usbdrd_dwc3 { + phys = <&u2phy0_otg>; + phy-names = "usb2-phy"; + extcon = <&usb2phy0>; + maximum-speed = "high-speed"; + snps,dis_u2_susphy_quirk; + status = "okay"; +}; + +&sata0 { + status = "okay"; +}; + +/* USB3.0 Host */ +&combphy1_usq { + status = "okay"; +}; + +&usbhost30 { + status = "okay"; +}; + +&usbhost_dwc3 { + status = "okay"; +}; + +&gmac0 { + phy-mode = "rgmii"; + clock_in_out = "output"; + + snps,reset-gpio = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>; + snps,reset-active-low; + /* Reset time is 75ms, 100ms */ + snps,reset-delays-us = <0 75000 100000>; + + assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>; + assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>, <&cru CLK_MAC0_2TOP>; + assigned-clock-rates = <0>, <125000000>; + + pinctrl-names = "default"; + pinctrl-0 = <&gmac0_miim + &gmac0_tx_bus2 + &gmac0_rx_bus2 + &gmac0_rgmii_clk + &gmac0_rgmii_bus>; + + tx_delay = <0x22>; + rx_delay = <0x0e>; + + phy-handle = <&rgmii_phy0>; + status = "okay"; +}; + +&mdio0 { + rgmii_phy0: phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x0>; + }; +}; + +&gmac1 { + phy-mode = "rgmii"; + clock_in_out = "output"; + + snps,reset-gpio = <&gpio3 RK_PA2 GPIO_ACTIVE_LOW>; + snps,reset-active-low; + /* Reset time is 75ms, 100ms */ + snps,reset-delays-us = <0 75000 100000>; + + assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>; + assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru CLK_MAC1_2TOP>; + assigned-clock-rates = <0>, <125000000>; + + pinctrl-names = "default"; + pinctrl-0 = <&gmac1m1_miim + &gmac1m1_tx_bus2 + &gmac1m1_rx_bus2 + &gmac1m1_rgmii_clk + &gmac1m1_rgmii_bus>; + + /* RTL8211F */ + // tx_delay = <0x1c>; + // rx_delay = <0x0c>; + + /* JL2101 */ + tx_delay = <0x22>; + rx_delay = <0x07>; + + phy-handle = <&rgmii_phy1>; + status = "okay"; +}; + +&mdio1 { + rgmii_phy1: phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x0>; + }; +}; + +&pcie30phy { + status = "okay"; +}; + +&pcie3x2 { + reset-gpios = <&gpio2 RK_PD6 GPIO_ACTIVE_HIGH>; + vpcie3v3-supply = <&pcie30_3v3>; + status = "okay"; +}; + +/* mini pcie */ +&pcie2x1 { + reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_HIGH>; + disable-gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_HIGH>; + vpcie3v3-supply = <&mini_pcie_3v3>; + status = "okay"; +}; + +&combphy2_psq { + status = "okay"; +}; + +&route_hdmi { + status = "okay"; + connect = <&vp0_out_hdmi>; +}; + +&hdmi_in_vp0 { + status = "okay"; +}; + +&hdmi_in_vp1 { + status = "disabled"; +}; + +&hdmi { + status = "okay"; +}; + +&pinctrl { + pmic { + pmic_int: pmic_int { + rockchip,pins = + <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = + <0 RK_PA2 RK_FUNC_GPIO &pcfg_output_low_pull_down>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = + <0 RK_PA2 RK_FUNC_1 &pcfg_pull_up>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = + <0 RK_PA2 RK_FUNC_2 &pcfg_pull_none>; + }; + + spk_ctl_gpio: spk_ctl_gpio { + rockchip,pins = <3 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + headphone { + hp_det: hp-det { + rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + usb { + vcc5v0_usb20_host_en: vcc5v0-usb20-host-en { + rockchip,pins = <0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + vcc5v0_usb30_host_en: vcc5v0-usb30-host-en { + rockchip,pins = <0 RK_PD6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + vcc5v0_otg_vbus_en: vcc5v0-otg-vbus-en { + rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + spi { + spi3_cs0: spi3-cs0 { + rockchip,pins = <4 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up_drv_level_1>; + }; + + spi3_cs1: spi3-cs1 { + rockchip,pins = <4 RK_PC4 RK_FUNC_GPIO &pcfg_pull_up_drv_level_1>; + }; + }; + + lcd { + mipi_dsi0_pwr_en: mipi-dsi0-pwr-en { + rockchip,pins = <3 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + cam { + cam_pwr_en: cam-pwr-en { + rockchip,pins = <3 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + leds { + sys_status_led_pin: sys-status-led-pin { + rockchip,pins = <0 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; diff --git a/device_tree_led/test_app.c b/device_tree_led/test_app.c new file mode 100644 index 0000000..bd8d7ec --- /dev/null +++ b/device_tree_led/test_app.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include +int main(int argc, char *argv[]) +{ + printf("led test_app\n"); + + /*判断输入的命令是否合法*/ + if(argc != 2) + { + printf(" command error ! \n"); + printf(" usage : sudo test_app num [num can be 0 or 1]\n"); + return -1; + } + + /*打开文件*/ + int fd = open("/dev/led_test", O_RDWR); + if(fd < 0) + { + printf("open file : %s failed !\n", argv[0]); + return -1; + } + + unsigned char commend = atoi(argv[1]); //将接收值转化为数字; + + /*写入命令*/ + int error = write(fd,&commend,sizeof(commend)); + if(error < 0) + { + printf("write file error! \n"); + close(fd); + /*判断是否关闭成功*/ + } + + /*关闭文件*/ + error = close(fd); + if(error < 0) + { + printf("close file error! \n"); + } + + return 0; +} diff --git a/dynamic_device_tree/leds-gpio.c b/dynamic_device_tree/leds-gpio.c new file mode 100644 index 0000000..764c313 --- /dev/null +++ b/dynamic_device_tree/leds-gpio.c @@ -0,0 +1,293 @@ +/* + * LEDs driver for GPIOs + * + * Copyright (C) 2007 8D Technologies inc. + * Raphael Assenat + * Copyright (C) 2008 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct gpio_led_data { + struct led_classdev cdev; + struct gpio_desc *gpiod; + u8 can_sleep; + u8 blinking; + gpio_blink_set_t platform_gpio_blink_set; +}; + +static inline struct gpio_led_data * + cdev_to_gpio_led_data(struct led_classdev *led_cdev) +{ + return container_of(led_cdev, struct gpio_led_data, cdev); +} + +static void gpio_led_set(struct led_classdev *led_cdev, + enum led_brightness value) +{ + struct gpio_led_data *led_dat = cdev_to_gpio_led_data(led_cdev); + int level; + + if (value == LED_OFF) + level = 0; + else + level = 1; + + if (led_dat->blinking) { + led_dat->platform_gpio_blink_set(led_dat->gpiod, level, + NULL, NULL); + led_dat->blinking = 0; + } else { + if (led_dat->can_sleep) + gpiod_set_value_cansleep(led_dat->gpiod, level); + else + gpiod_set_value(led_dat->gpiod, level); + } +} + +static int gpio_led_set_blocking(struct led_classdev *led_cdev, + enum led_brightness value) +{ + gpio_led_set(led_cdev, value); + return 0; +} + +static int gpio_blink_set(struct led_classdev *led_cdev, + unsigned long *delay_on, unsigned long *delay_off) +{ + struct gpio_led_data *led_dat = cdev_to_gpio_led_data(led_cdev); + + led_dat->blinking = 1; + return led_dat->platform_gpio_blink_set(led_dat->gpiod, GPIO_LED_BLINK, + delay_on, delay_off); +} + +static int create_gpio_led(const struct gpio_led *template, + struct gpio_led_data *led_dat, struct device *parent, + struct device_node *np, gpio_blink_set_t blink_set) +{ + int ret, state; + + led_dat->gpiod = template->gpiod; + if (!led_dat->gpiod) { + /* + * This is the legacy code path for platform code that + * still uses GPIO numbers. Ultimately we would like to get + * rid of this block completely. + */ + unsigned long flags = GPIOF_OUT_INIT_LOW; + + /* skip leds that aren't available */ + if (!gpio_is_valid(template->gpio)) { + dev_info(parent, "Skipping unavailable LED gpio %d (%s)\n", + template->gpio, template->name); + return 0; + } + + if (template->active_low) + flags |= GPIOF_ACTIVE_LOW; + + ret = devm_gpio_request_one(parent, template->gpio, flags, + template->name); + if (ret < 0) + return ret; + + led_dat->gpiod = gpio_to_desc(template->gpio); + if (!led_dat->gpiod) + return -EINVAL; + } + + led_dat->cdev.name = template->name; + led_dat->cdev.default_trigger = template->default_trigger; + led_dat->can_sleep = gpiod_cansleep(led_dat->gpiod); + if (!led_dat->can_sleep) + led_dat->cdev.brightness_set = gpio_led_set; + else + led_dat->cdev.brightness_set_blocking = gpio_led_set_blocking; + led_dat->blinking = 0; + if (blink_set) { + led_dat->platform_gpio_blink_set = blink_set; + led_dat->cdev.blink_set = gpio_blink_set; + } + if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) { + state = gpiod_get_value_cansleep(led_dat->gpiod); + if (state < 0) + return state; + } else { + state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); + } + led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; + if (!template->retain_state_suspended) + led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; + if (template->panic_indicator) + led_dat->cdev.flags |= LED_PANIC_INDICATOR; + if (template->retain_state_shutdown) + led_dat->cdev.flags |= LED_RETAIN_AT_SHUTDOWN; + + ret = gpiod_direction_output(led_dat->gpiod, state); + if (ret < 0) + return ret; + + return devm_of_led_classdev_register(parent, np, &led_dat->cdev); +} + +struct gpio_leds_priv { + int num_leds; + struct gpio_led_data leds[]; +}; + +static inline int sizeof_gpio_leds_priv(int num_leds) +{ + return sizeof(struct gpio_leds_priv) + + (sizeof(struct gpio_led_data) * num_leds); +} + +static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct fwnode_handle *child; + struct gpio_leds_priv *priv; + int count, ret; + + count = device_get_child_node_count(dev); + if (!count) + return ERR_PTR(-ENODEV); + + priv = devm_kzalloc(dev, sizeof_gpio_leds_priv(count), GFP_KERNEL); + if (!priv) + return ERR_PTR(-ENOMEM); + + device_for_each_child_node(dev, child) { + struct gpio_led_data *led_dat = &priv->leds[priv->num_leds]; + struct gpio_led led = {}; + const char *state = NULL; + struct device_node *np = to_of_node(child); + + ret = fwnode_property_read_string(child, "label", &led.name); + if (ret && IS_ENABLED(CONFIG_OF) && np) + led.name = np->name; + if (!led.name) { + fwnode_handle_put(child); + return ERR_PTR(-EINVAL); + } + + led.gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL, child, + GPIOD_ASIS, + led.name); + if (IS_ERR(led.gpiod)) { + fwnode_handle_put(child); + return ERR_CAST(led.gpiod); + } + + fwnode_property_read_string(child, "linux,default-trigger", + &led.default_trigger); + + if (!fwnode_property_read_string(child, "default-state", + &state)) { + if (!strcmp(state, "keep")) + led.default_state = LEDS_GPIO_DEFSTATE_KEEP; + else if (!strcmp(state, "on")) + led.default_state = LEDS_GPIO_DEFSTATE_ON; + else + led.default_state = LEDS_GPIO_DEFSTATE_OFF; + } + + if (fwnode_property_present(child, "retain-state-suspended")) + led.retain_state_suspended = 1; + if (fwnode_property_present(child, "retain-state-shutdown")) + led.retain_state_shutdown = 1; + if (fwnode_property_present(child, "panic-indicator")) + led.panic_indicator = 1; + + ret = create_gpio_led(&led, led_dat, dev, np, NULL); + if (ret < 0) { + fwnode_handle_put(child); + return ERR_PTR(ret); + } + led_dat->cdev.dev->of_node = np; + priv->num_leds++; + } + + return priv; +} + +static const struct of_device_id of_gpio_leds_match[] = { + { .compatible = "gpio-leds", }, + {}, +}; + +MODULE_DEVICE_TABLE(of, of_gpio_leds_match); + +static int gpio_led_probe(struct platform_device *pdev) +{ + struct gpio_led_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct gpio_leds_priv *priv; + int i, ret = 0; + + if (pdata && pdata->num_leds) { + priv = devm_kzalloc(&pdev->dev, + sizeof_gpio_leds_priv(pdata->num_leds), + GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->num_leds = pdata->num_leds; + for (i = 0; i < priv->num_leds; i++) { + ret = create_gpio_led(&pdata->leds[i], &priv->leds[i], + &pdev->dev, NULL, + pdata->gpio_blink_set); + if (ret < 0) + return ret; + } + } else { + priv = gpio_leds_create(pdev); + if (IS_ERR(priv)) + return PTR_ERR(priv); + } + + platform_set_drvdata(pdev, priv); + + return 0; +} + +static void gpio_led_shutdown(struct platform_device *pdev) +{ + struct gpio_leds_priv *priv = platform_get_drvdata(pdev); + int i; + + for (i = 0; i < priv->num_leds; i++) { + struct gpio_led_data *led = &priv->leds[i]; + + if (!(led->cdev.flags & LED_RETAIN_AT_SHUTDOWN)) + gpio_led_set(&led->cdev, LED_OFF); + } +} + +static struct platform_driver gpio_led_driver = { + .probe = gpio_led_probe, + .shutdown = gpio_led_shutdown, + .driver = { + .name = "leds-gpio", + .of_match_table = of_gpio_leds_match, + }, +}; + +module_platform_driver(gpio_led_driver); + +MODULE_AUTHOR("Raphael Assenat , Trent Piepho "); +MODULE_DESCRIPTION("GPIO LED driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:leds-gpio"); diff --git a/dynamic_device_tree/lubancat-led-overlay.dts b/dynamic_device_tree/lubancat-led-overlay.dts new file mode 100644 index 0000000..c993730 --- /dev/null +++ b/dynamic_device_tree/lubancat-led-overlay.dts @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2022 - All Rights Reserved by + * EmbedFire LubanCat + */ +/dts-v1/; +/plugin/; + +#include +#include + +&{/leds} { + status = "okay"; + led_test: led_test{ + label = "led_test"; + default-state = "on"; + //gpios = <&gpio0 RK_PC7 GPIO_ACTIVE_LOW>; + gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&led_test_pin>; + }; +}; + +&{/pinctrl} { + led_test { + led_test_pin: led_test_pin { + rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; \ No newline at end of file diff --git a/fbtft-st7796-5.10/Kbuild b/fbtft-st7796-5.10/Kbuild new file mode 100644 index 0000000..6687de6 --- /dev/null +++ b/fbtft-st7796-5.10/Kbuild @@ -0,0 +1 @@ +obj-m += fb_st7796.o diff --git a/fbtft-st7796-5.10/Makefile b/fbtft-st7796-5.10/Makefile new file mode 100644 index 0000000..91d0f16 --- /dev/null +++ b/fbtft-st7796-5.10/Makefile @@ -0,0 +1,10 @@ +KDIR ?= /lib/modules/`uname -r`/build + +default: + $(MAKE) -C $(KDIR) M=$$PWD + +install: + $(MAKE) -C $(KDIR) M=$$PWD modules_install + +clean: + $(MAKE) -C $(KDIR) M=$$PWD clean diff --git a/fbtft-st7796-5.10/README.md b/fbtft-st7796-5.10/README.md new file mode 100644 index 0000000..91a8746 --- /dev/null +++ b/fbtft-st7796-5.10/README.md @@ -0,0 +1,13 @@ +# FBTFT driver for ST7796 (?) + +Tested with linux kernel 5.10.160 + +**Caution**: The store I bought the display from lists the panel as ST7796U, but when I try to use [initialization sequence for ST7796](https://github.com/birdtechstep/tinydrm/blob/master/st7796.c#L112-L196) it didn't work. However I used the sequence for ST7789 and it worked, but I still had to use [ST7796's screen orientation settings](https://github.com/birdtechstep/tinydrm/blob/master/st7796.c#L179-L196), so I'm not sure which controller it actually is. If it doesn't work for you, you can override it in `init` property. + +## Usage +```sh +make +make install +depmod -A +``` + diff --git a/fbtft-st7796-5.10/fb_st7796.c b/fbtft-st7796-5.10/fb_st7796.c new file mode 100644 index 0000000..fdfe610 --- /dev/null +++ b/fbtft-st7796-5.10/fb_st7796.c @@ -0,0 +1,279 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * FB driver for the ST7796 LCD Controller + * + * Copyright (C) 2015 Dennis Menschel + */ + +#include +#include +#include +#include +#include +#include