[Linux 基础] -- Linux 内核中的 MFD 子系统

一、MFD全称

Multi-function Device:多功能设备

二、为何会出现 MFD 子系统

由于出现了一类具有多种功能的外围设备或 cpu 内部集成的硬件模块

三、有哪些多功能设备

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 和记忆棒读取器

四、MFD 子系统解决的主要问题

在不同的内核子系统中注册这些驱动。特别是外部外围设备仅仅由一个结构体 struct device(或是指定 i2c_client 或 spi_device)呈现

五、MFD 子系统的有点有哪些

1、允许在多个子系统中注册相同的设备

2、MFD 驱动必须能复用总线(主要是关于锁的处理)和处理中断请求

3、处理时钟

4、需要配置 IP

5、允许驱动重用,多个多功能设备重用其他子系统中的驱动

六、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);

七、 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 properties passed to the sub devices drivers */
    struct property_entry *properties;

    /*  
     * Device Tree compatible string
     * See: Documentation/devicetree/usage-model.txt Chapter 2.2 for details
     */
    const char      *of_compatible;

    /* Matches ACPI */
    const struct mfd_cell_acpi_match    *acpi_match;

    /*  
     * These resources can be specified relative to the parent device.
     * For accessing hardware you should use resources from the platform dev
     */
    int         num_resources;
    const struct resource   *resources;

    /* don't check for resource conflicts */
    bool            ignore_resource_conflicts;

    /*  
     * Disable runtime PM callbacks for this subdevice - see
     * pm_runtime_no_callbacks().
     */
    bool            pm_runtime_no_callbacks;

    /* A list of regulator supplies that should be mapped to the MFD
     * device rather than the child device when requested
     */
    const char * const  *parent_supplies;
    int         num_parent_supplies;
};

猜你喜欢

转载自blog.csdn.net/u014674293/article/details/111313661