首页 > 其他分享 >✳驱动之ic_bus_type框架

✳驱动之ic_bus_type框架

时间:2022-11-09 21:26:54浏览次数:35  
标签:struct int bus adapter device ic i2c type

  •  

     

  • DTS中的 i2c设备节点(子节点) (例如:AT24C02)被转化为i2c_client结构体,其所在的 i2c控制器节点(父节点)转化为platform_device 结构体,匹配到对应的 platform_driver 结构体,调用对应的 probe 函数,该函数中实现:①分配、设置、注册 i2c_adapter 结构体;②解析字节点,分配、设置、注册 i2c_client 结构体,该结构体对应i2c_bus 总线框架,匹配到对应的 i2c_driver 驱动,调用其中的 probe 函数,实现major、file_operations、register_chrdev、class_create,入口出口等。
  • struct i2c_adapter {
        struct module *owner;
        unsigned int class;          /* classes to allow probing for */
        const struct i2c_algorithm *algo; /* the algorithm to access the bus */
        void *algo_data;
    
        /* data fields that are valid for all devices    */
        const struct i2c_lock_operations *lock_ops;
        struct rt_mutex bus_lock;
        struct rt_mutex mux_lock;
    
        int timeout;            /* in jiffies */
        int retries;
        struct device dev;        /* the adapter device */
    
        int nr;
        char name[48];
        struct completion dev_released;
    
        struct mutex userspace_clients_lock;
        struct list_head userspace_clients;
    
        struct i2c_bus_recovery_info *bus_recovery_info;
        const struct i2c_adapter_quirks *quirks;
    };
    struct i2c_client {
        unsigned short flags;        /* div., see below        */
        unsigned short addr;        /* chip address - NOTE: 7bit    */
                        /* addresses are stored in the    */
                        /* _LOWER_ 7 bits        */
        char name[I2C_NAME_SIZE];
        struct i2c_adapter *adapter;    /* the adapter we sit on    */
        struct device dev;        /* the device structure        */
        int irq;            /* irq issued by device        */
        struct list_head detected;
    #if IS_ENABLED(CONFIG_I2C_SLAVE)
        i2c_slave_cb_t slave_cb;    /* callback for slave mode    */
    #endif
    };

     

  • probe中应用输入系统框架:
  • 为了适配以前写好的应用程序,上述probe函数中 使用到了输入系统 input_dev;不再是实现 major 这些,因为以前的应用程序可能不会去open一个你创建的设备节点,现在要去适配以前的应用程序,所以用到输入系统。
  •  

标签:struct,int,bus,adapter,device,ic,i2c,type
From: https://www.cnblogs.com/xuan01/p/16875118.html

相关文章