第一步:在arch/arm64/configs/rockchip_defconfig添加对应的宏,且属性设置为y,即编译进内核,这里是CONFIG_AS2056_I2C:
+++ b/arch/arm64/configs/rockchip_defconfig
@@ -421,6 +421,7 @@ CONFIG_SERIAL_8250_DW=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_GPIO=y
CONFIG_I2C_RK3X=y
+CONFIG_AS2056_I2C=y
CONFIG_SPI=y
CONFIG_SPI_ROCKCHIP=y
第二步:drivers/Kconfig添加对应source Kconfig
+++ b/drivers/Kconfig
@@ -206,4 +206,6 @@ source "drivers/rk_nand/Kconfig"
source "drivers/headset_observe/Kconfig"
+source "drivers/as2056/Kconfig"
第三步:drivers/Makefile添加对应的编译语句,加上宏CONFIG_AS2056_I2C:
+++ b/drivers/Makefile
@@ -178,3 +178,4 @@ obj-$(CONFIG_FPGA) += fpga/
obj-$(CONFIG_TEE) += tee/
obj-$(CONFIG_RK_NAND) += rk_nand/
obj-$(CONFIG_RK_HEADSET) += headset_observe/
+obj-$(CONFIG_AS2056_I2C) += as2056/
第四部:对应驱动文件夹添加Kconfig和编译Makefile
Makefile文件内容:
caizd@ubt144c:/work/czd/rk3399_7.1_ind/kernel$ vi drivers/as2056/Makefile
obj-$(CONFIG_AS2056_I2C) += as2056_ctrl.o
Kconfig文件内容:
config AS2056_I2C
tristate "As2056 USB adapter"
depends on USB && I2C
help
If you say yes to this option, support will be included for As2056
a USB to I2C interface.
This driver can also be built as a module.
这样,如果要编译驱动as2056进内核,只需要在kernel先执行make ARCH=arm64 rockchip_defconfig即可配置编译。