美文网首页
设备<=>驱动匹配

设备<=>驱动匹配

作者: 4c6ed2800025 | 来源:发表于2021-04-24 23:22 被阅读0次
struct device_driver {
    const char      *name;
    struct bus_type     *bus;

    struct module       *owner;
    const char      *mod_name;  /* used for built-in modules */

    const struct of_device_id   *of_match_table;
    const struct acpi_device_id *acpi_match_table;

    int (*probe) (struct device *dev);
    int (*remove) (struct device *dev);
    void (*shutdown) (struct device *dev);
    int (*suspend) (struct device *dev, pm_message_t state);
    int (*resume) (struct device *dev);
    [...]
};
struct device {
    struct device       *parent;

    struct device_private   *p;

    struct kobject kobj;
    const char      *init_name; /* initial name of the device */
    const struct device_type *type;

    struct bus_type *bus;       /* type of bus device is on */
    struct device_driver *driver;   /* which driver has allocated this
                       device */
    void        *platform_data; /* Platform specific data, device
                       core doesn't touch it */
    void        *driver_data;   /* Driver data, set and get with
                       dev_set/get_drvdata */
    /* arch specific additions */
    struct dev_archdata archdata;

    struct device_node  *of_node; /* associated device tree node */
    struct fwnode_handle    *fwnode; /* firmware device node */

    dev_t           devt;   /* dev_t, creates the sysfs "dev" */
    u32         id; /* device instance */

    struct class        *class;
    const struct attribute_group **groups;  /* optional groups */

};
struct platform_driver {
    int (*probe)(struct platform_device *);
    int (*remove)(struct platform_device *);
    void (*shutdown)(struct platform_device *);
    int (*suspend)(struct platform_device *, pm_message_t state);
    int (*resume)(struct platform_device *);
    struct device_driver driver;
    const struct platform_device_id *id_table;
    bool prevent_deferred_probe;
};
struct platform_device {
    const char  *name;
    int     id;
    bool        id_auto;
    struct device   dev;
    u32     num_resources;
    struct resource *resource;

    const struct platform_device_id *id_entry;
    char *driver_override; /* Driver name to force a match */

    /* arch specific additions */
    struct pdev_archdata    archdata;
};

平台设备(platform device):buses, hardware device called controller; cant be removed, non-discoverable; I2C, UART, SPI, and other devices not wired
to enumeration-capable buses.
片上设备(on-chip device):hard-wired into chip

平台设备不一定都是由platform bus 处理, spi i2c设备都是平台设备,但是分别由spi,i2c总线,而不是平台总线处理;

image.png

相关文章

网友评论

      本文标题:设备<=>驱动匹配

      本文链接:https://www.haomeiwen.com/subject/rlalrltx.html