什么是platform device?

1 为了实现设备跟驱动的分离,linux开始引入platform模型。使用该模型的设备,通常是不可被“发现”的设备(它不像USB,PCI那样能够枚举),例如I2C,SPI设备。对于platform devices,我们必然清晰的了解他们的地址。

      摘自:kernel-xxx\Documentation\driver-model\platform.txt

Platform devices are devices that typically appear as autonomous
entities in the system. This includes legacy port-based devices and
host bridges to peripheral buses, and most controllers integrated
into system-on-chip platforms.  What they usually have in common
is direct addressing from a CPU bus.  Rarely, a platform_device will
be connected through a segment of some other kind of bus; but its
registers will still be directly addressable.

 

2 platform devices 通常是系统中重要的设备,他们在系统启动的时候,尽早的注册和加载,例如电源管理芯片。

3 platform devices 通常都会有IO配置,电源管理等需求。随着运行linux内核的移动设备的增加,电源管理变得越来越重要。

4 platform device 与 drivers 通过name来binding,当然,我们遵循先注册设备,再注册驱动的顺序。

struct platform_device {
    const char    *name;
    u32        id;
    struct device    dev;
    u32        num_resources;
    struct resource    *resource;
};
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;
};
//没有name?接着往下看
struct device_driver {
    const char        *name;
    struct bus_type        *bus;

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

    bool suppress_bind_attrs;    /* disables bind/unbind via sysfs */

    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);
    const struct attribute_group **groups;

    const struct dev_pm_ops *pm;

    struct driver_private *p;
};

 

posted @ 2016-03-03 20:35  still_waters  阅读(1677)  评论(0编辑  收藏  举报