初始化流程
Read time: 1 minute(s)
TSensor 模块完全遵循 driver 的通用初始化流程,申请 regs 资源、clk、reset,另外需要使用 Thermal 子系统的注册接口
thermal_zone_device_register() 来注册 zone
设备。
struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, void *, struct thermal_zone_device_ops *, struct thermal_zone_params *, int, int);
其中关键参数有:设备名称、zone 设备的 ops、以及私有数据等,ops 中我们暂时只提供 get_temp()
接口的定义:
static struct thermal_zone_device_ops tsen_cpu_ops = { .get_temp = tsen_cpu_get_temp, }; static struct thermal_zone_device_ops tsen_adc_ops = { .get_temp = tsen_adc_get_temp, };