分析用的内核版本为5.1.3
1.MFD全称
Multi-function Device,多功能设备
2. 为何会出现MFD子系统
由于出现了一类具有多种功能的外围设备或cpu内部集成的硬件模块
3. 有哪些多功能设备呢?
3.1 PMIC,电源管理芯片
da9063: 调节器,led控制器,看门狗,实时时钟控制器,温度传感器,震动马达驱动,长按关机功能(ON key)
max77843: 调节器,充电器,燃油量表,触觉反馈,led控制器,micro USB接口控制器
wm831x: 调节器,时钟,实时时钟控制器,看门狗,触摸控制器,温度传感器,背光控制器,状态led控制器,GPIO,长按关机功能(ON key),ADC
其它: 甚至具有codec功能
3.2 atmel-hlcdc: 显示控制器和背光pwm
3.3 Diolan DLN2: USB转I2C,SPI和GPIO控制器
3.4 Realtek PCI-E读卡器: SD/MMC和记忆棒读取器
4. MFD子系统解决的主要问题
在不同的内核子系统中注册这些驱动。特别是外部外围设备仅仅由一个结构体struct device(或是指定的i2c_client或spi_device)呈现
5. MFD子系统的优点有哪些?
5.1 允许在多个子系统中注册相同的设备
5.2 MFD驱动必须能否复用总线(主要是关于锁的处理)和处理中断请求
5.3 处理时钟
5.4 需要配置IP
5.5 允许驱动重用,多个多功能设备能重用其它子系统中的驱动
6. MFD提供的API
int mfd_add_devices(struct device *parent,int id, const struct mfd_cell *cells, int n_devs,
struct resource *mem_base, int irq_base, struct irq_domain *irq_domain);
extern void mfd_remove_devices(struct device *parent);
这些接口定义在include/linux/mfd/core.h中,在drivers/mfd/mtd-core.c中被实现
7. MFD提供的结构体
struct mfd_cell { const char *name; int id; /* refcounting for multiple drivers to use a single cell */ atomic_t *usage_count; int (*enable)(struct platform_device *dev); int (*disable)(struct platform_device *dev); int (*suspend)(struct platform_device *dev); int (*resume)(struct platform_device *dev); /* platform data passed to the sub devices drivers */ void *platform_data; size_t pdata_size; /* device prope