FAQ资料:如何在MT8516平台上添加I2C驱动程序

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/szx940213/article/details/81981041

MTK FAQ资料:

如何在MT8516平台上添加I2C驱动程序

驱动DTS节点:

dts Path: src/kernel/linux/v4.4/arch/arm64/boot/dts/mediatek/xxxx.dts

file: xxxx.dts
&i2c0 {

status = "okay";
clock-frequency = <400000>;
xxx@2c {                                                            // add i2c device node into dts file
compatible = "xxxx,xxx";
reg = <0x2c>;                                                    //i2c address

};

}

I2C驱动程序示例代码:

I2C设备驱动程序:

static const struct i2c_device_id xxx_id_table[] = {                      static void __init xxx_init(void)
{ I2C_DRIVER_NAME, 0 },                                                               {
{ }                                                                                                          int ret = 0;
};                                                                                                                //your code here
static const struct of_device_id xx_of_match[] = {                                i2c_add_driver( &xxx_driver );
{.compatible = “xxxx,xxx”},                                                                            return ret;
{},                                                                                                                   static void __exit xxx_exit(void)
};                                                                                                                {
static struct i2c_driver xxx_driver = {                                                           //your code here
.driver = {                                                                                                          i2c_del_driver(&xxx_driver);
.name = DEVICE_DRIVER_NAME,
.of_match_table = xx_of_match,
.owner = THIS_MODULE,
},
.probe = xxx_probe,
.remove = xxx_remove,
.id_table = xxx_id_table,
};

如何配置eTIN:

 Eint用法:

请求_irq/请求线程_irq

方法1:1.从xx.dts调用Platform_GET_Irq获取LinuxIRQ号和中断标志。2.调用内核标准API请求_irq/请求_线程_irq注册Irq处理程序

方法2:1。调用GPIO_to_Irq直接获取LinuxIRQ号。调用内核标准API请求_irq/请求_线程_irq注册Irq

 如何配置GPIO:

 GPIO使用:

 Pinctrl API使用:

 如何配置功率:

样本代码:

 内核配置:

内核配置路径:

src/kernel/linux/v4.4/arch/arm64/configs/xxxx_defconfig
src/kernel/linux/v4.4/arch/arm64/configs/xxxx_debug_defconfig

 驱动程序kconfig&make文件:

驱动路径:src/kernel/linux/v4.4/drivers/leds/xxxx

Kconfig will explain the CONFIG_LEDS_LP5523

驱动路径:src/kernel/linux/v4.4/drivers/misc/mediatek/accelerometer/xxxx

以mc 3433为例:

驱动程序kconfig&make文件-第一层:

 第一层的kconfig需要配置以搜索第二层的kconfig。

根据Defconfig配置编译mc3433文件夹的makefile

 

 驱动程序kconfig&make文件-第二层:

Kconfig will explain the CONFIG_MTK_MC3433

Makefile config to compile mc3433.c

 

了解更多资料,可到一牛网论坛。 

猜你喜欢

转载自blog.csdn.net/szx940213/article/details/81981041