1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * ST Thermal Sensor Driver for STi series of SoCs
4 * Author: Ajit Pal Singh <ajitpal.singh@st.com>
6 * Copyright (C) 2003-2014 STMicroelectronics (R&D) Limited
9 #ifndef __STI_THERMAL_SYSCFG_H
10 #define __STI_THERMAL_SYSCFG_H
12 #include <linux/interrupt.h>
13 #include <linux/platform_device.h>
14 #include <linux/regmap.h>
15 #include <linux/thermal.h>
17 enum st_thermal_regfield_ids
{
18 INT_THRESH_HI
= 0, /* Top two regfield IDs are mutually exclusive */
28 /* Thermal sensor power states */
29 enum st_thermal_power_state
{
34 struct st_thermal_sensor
;
37 * Description of private thermal sensor ops.
39 * @power_ctrl: Function for powering on/off a sensor. Clock to the
40 * sensor is also controlled from this function.
41 * @alloc_regfields: Allocate regmap register fields, specific to a sensor.
42 * @do_memmap_regmap: Memory map the thermal register space and init regmap
43 * instance or find regmap instance.
44 * @register_irq: Register an interrupt handler for a sensor.
46 struct st_thermal_sensor_ops
{
47 int (*power_ctrl
)(struct st_thermal_sensor
*, enum st_thermal_power_state
);
48 int (*alloc_regfields
)(struct st_thermal_sensor
*);
49 int (*regmap_init
)(struct st_thermal_sensor
*);
50 int (*register_enable_irq
)(struct st_thermal_sensor
*);
51 int (*enable_irq
)(struct st_thermal_sensor
*);
55 * Description of thermal driver compatible data.
57 * @reg_fields: Pointer to the regfields array for a sensor.
58 * @sys_compat: Pointer to the syscon node compatible string.
59 * @ops: Pointer to private thermal ops for a sensor.
60 * @calibration_val: Default calibration value to be written to the DCORRECT
61 * register field for a sensor.
62 * @temp_adjust_val: Value to be added/subtracted from the data read from
63 * the sensor. If value needs to be added please provide a
64 * positive value and if it is to be subtracted please
65 * provide a negative value.
66 * @crit_temp: The temperature beyond which the SoC should be shutdown
69 struct st_thermal_compat_data
{
71 const struct reg_field
*reg_fields
;
72 const struct st_thermal_sensor_ops
*ops
;
73 unsigned int calibration_val
;
78 struct st_thermal_sensor
{
80 struct thermal_zone_device
*thermal_dev
;
81 const struct st_thermal_sensor_ops
*ops
;
82 const struct st_thermal_compat_data
*cdata
;
84 struct regmap
*regmap
;
85 struct regmap_field
*pwr
;
86 struct regmap_field
*dcorrect
;
87 struct regmap_field
*overflow
;
88 struct regmap_field
*temp_data
;
89 struct regmap_field
*int_thresh_hi
;
90 struct regmap_field
*int_enable
;
92 void __iomem
*mmio_base
;
95 extern int st_thermal_register(struct platform_device
*pdev
,
96 const struct of_device_id
*st_thermal_of_match
);
97 extern void st_thermal_unregister(struct platform_device
*pdev
);
98 extern const struct dev_pm_ops st_thermal_pm_ops
;
100 #endif /* __STI_RESET_SYSCFG_H */