[Linux Basics] - MFD subsystem in the Linux kernel

1. Full name of MFD

Multi-function Device: Multi-function device

2. Why does the MFD subsystem appear

Due to the emergence of a type of peripheral equipment with multiple functions or a hardware module integrated inside the cpu

3. What are the multifunctional equipment

3.1, PMIC: power management chip

da9063: regulator, led controller, watchdog, real-time clock controller, temperature sensor, vibration motor drive, long press shutdown function (ON key)

max77843: regulator, charger, fuel gauge, tactile feedback, led controller, micro USB interface controller

wm831x: regulator, clock, real-time clock controller, watchdog, touch controller, temperature sensor, backlight controller, status led controller, GPIO, long press shutdown function (ON key), ADC

Other: even with codec function

3.2. atmel-hlcdc: display controller and backlight pwm

3.3 Diolan DLN2: USB to I2C, SPI and GPIO controller

3.4. Realtek PCI-E card reader: SD/MMC and memory stick reader

Fourth, the main problems solved by the MFD subsystem

Register these drivers in different kernel subsystems. Especially the external peripheral device is only presented by a structure struct device (or specify i2c_client or spi_device)

5. What are the advantages of the MFD subsystem

1. Allow the same device to be registered in multiple subsystems

2. The MFD driver must be able to multiplex the bus (mainly about lock processing) and handle interrupt requests

3. Deal with the clock

4. Need to configure IP

5. Allow driver reuse, multiple multi-function devices reuse drivers in other subsystems

6. API provided by MFD

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

Seven, the structure provided by 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;
};

Guess you like

Origin blog.csdn.net/u014674293/article/details/111313661