12b27bdccSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2eb982001SEduardo Valentin /*
3eb982001SEduardo Valentin  * OMAP4 Bandgap temperature sensor driver
4eb982001SEduardo Valentin  *
5eb982001SEduardo Valentin  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6eb982001SEduardo Valentin  * Contact:
7eb982001SEduardo Valentin  *   Eduardo Valentin <eduardo.valentin@ti.com>
8eb982001SEduardo Valentin  */
9eb982001SEduardo Valentin #ifndef __TI_BANDGAP_H
10eb982001SEduardo Valentin #define __TI_BANDGAP_H
11eb982001SEduardo Valentin 
12eb982001SEduardo Valentin #include <linux/spinlock.h>
13eb982001SEduardo Valentin #include <linux/types.h>
14eb982001SEduardo Valentin #include <linux/err.h>
155093402eSAdam Ford #include <linux/cpu_pm.h>
165093402eSAdam Ford #include <linux/device.h>
175093402eSAdam Ford #include <linux/pm_runtime.h>
185093402eSAdam Ford #include <linux/pm.h>
19eb982001SEduardo Valentin 
207375f2acSLinus Walleij struct gpio_desc;
217375f2acSLinus Walleij 
22eb982001SEduardo Valentin /**
23eb982001SEduardo Valentin  * DOC: bandgap driver data structure
24eb982001SEduardo Valentin  * ==================================
25eb982001SEduardo Valentin  *
26eb982001SEduardo Valentin  *   +----------+----------------+
27eb982001SEduardo Valentin  *   | struct temp_sensor_regval |
28eb982001SEduardo Valentin  *   +---------------------------+
29eb982001SEduardo Valentin  *              * (Array of)
30eb982001SEduardo Valentin  *              |
31eb982001SEduardo Valentin  *              |
32eb982001SEduardo Valentin  *   +-------------------+   +-----------------+
33eb982001SEduardo Valentin  *   | struct ti_bandgap |-->| struct device * |
34eb982001SEduardo Valentin  *   +----------+--------+   +-----------------+
35eb982001SEduardo Valentin  *              |
36eb982001SEduardo Valentin  *              |
37eb982001SEduardo Valentin  *              V
38eb982001SEduardo Valentin  *   +------------------------+
39eb982001SEduardo Valentin  *   | struct ti_bandgap_data |
40eb982001SEduardo Valentin  *   +------------------------+
41eb982001SEduardo Valentin  *              |
42eb982001SEduardo Valentin  *              |
43eb982001SEduardo Valentin  *              * (Array of)
44eb982001SEduardo Valentin  * +------------+------------------------------------------------------+
45eb982001SEduardo Valentin  * | +----------+------------+   +-------------------------+           |
46eb982001SEduardo Valentin  * | | struct ti_temp_sensor |-->| struct temp_sensor_data |           |
47eb982001SEduardo Valentin  * | +-----------------------+   +------------+------------+           |
48eb982001SEduardo Valentin  * |            |                                                      |
49eb982001SEduardo Valentin  * |            +                                                      |
50eb982001SEduardo Valentin  * |            V                                                      |
51eb982001SEduardo Valentin  * | +----------+-------------------+                                  |
52eb982001SEduardo Valentin  * | | struct temp_sensor_registers |                                  |
53eb982001SEduardo Valentin  * | +------------------------------+                                  |
54eb982001SEduardo Valentin  * |                                                                   |
55eb982001SEduardo Valentin  * +-------------------------------------------------------------------+
56eb982001SEduardo Valentin  *
57eb982001SEduardo Valentin  * Above is a simple diagram describing how the data structure below
58eb982001SEduardo Valentin  * are organized. For each bandgap device there should be a ti_bandgap_data
59eb982001SEduardo Valentin  * containing the device instance configuration, as well as, an array of
60eb982001SEduardo Valentin  * sensors, representing every sensor instance present in this bandgap.
61eb982001SEduardo Valentin  */
62eb982001SEduardo Valentin 
63eb982001SEduardo Valentin /**
64eb982001SEduardo Valentin  * struct temp_sensor_registers - descriptor to access registers and bitfields
65eb982001SEduardo Valentin  * @temp_sensor_ctrl: TEMP_SENSOR_CTRL register offset
66eb982001SEduardo Valentin  * @bgap_tempsoff_mask: mask to temp_sensor_ctrl.tempsoff
67eb982001SEduardo Valentin  * @bgap_soc_mask: mask to temp_sensor_ctrl.soc
68eb982001SEduardo Valentin  * @bgap_eocz_mask: mask to temp_sensor_ctrl.eocz
69eb982001SEduardo Valentin  * @bgap_dtemp_mask: mask to temp_sensor_ctrl.dtemp
70eb982001SEduardo Valentin  * @bgap_mask_ctrl: BANDGAP_MASK_CTRL register offset
71eb982001SEduardo Valentin  * @mask_hot_mask: mask to bandgap_mask_ctrl.mask_hot
72eb982001SEduardo Valentin  * @mask_cold_mask: mask to bandgap_mask_ctrl.mask_cold
73eb982001SEduardo Valentin  * @mask_counter_delay_mask: mask to bandgap_mask_ctrl.mask_counter_delay
74eb982001SEduardo Valentin  * @mask_freeze_mask: mask to bandgap_mask_ctrl.mask_free
75eb982001SEduardo Valentin  * @bgap_mode_ctrl: BANDGAP_MODE_CTRL register offset
76eb982001SEduardo Valentin  * @mode_ctrl_mask: mask to bandgap_mode_ctrl.mode_ctrl
77eb982001SEduardo Valentin  * @bgap_counter: BANDGAP_COUNTER register offset
78eb982001SEduardo Valentin  * @counter_mask: mask to bandgap_counter.counter
79eb982001SEduardo Valentin  * @bgap_threshold: BANDGAP_THRESHOLD register offset (TALERT thresholds)
80eb982001SEduardo Valentin  * @threshold_thot_mask: mask to bandgap_threhold.thot
81eb982001SEduardo Valentin  * @threshold_tcold_mask: mask to bandgap_threhold.tcold
82eb982001SEduardo Valentin  * @tshut_threshold: TSHUT_THRESHOLD register offset (TSHUT thresholds)
83eb982001SEduardo Valentin  * @tshut_hot_mask: mask to tshut_threhold.thot
84eb982001SEduardo Valentin  * @tshut_cold_mask: mask to tshut_threhold.thot
85eb982001SEduardo Valentin  * @bgap_status: BANDGAP_STATUS register offset
86eb982001SEduardo Valentin  * @status_hot_mask: mask to bandgap_status.hot
87eb982001SEduardo Valentin  * @status_cold_mask: mask to bandgap_status.cold
88eb982001SEduardo Valentin  * @ctrl_dtemp_1: CTRL_DTEMP1 register offset
89eb982001SEduardo Valentin  * @ctrl_dtemp_2: CTRL_DTEMP2 register offset
90eb982001SEduardo Valentin  * @bgap_efuse: BANDGAP_EFUSE register offset
91eb982001SEduardo Valentin  *
92eb982001SEduardo Valentin  * The register offsets and bitfields might change across
93eb982001SEduardo Valentin  * OMAP and variants versions. Hence this struct serves as a
94eb982001SEduardo Valentin  * descriptor map on how to access the registers and the bitfields.
95eb982001SEduardo Valentin  *
96eb982001SEduardo Valentin  * This descriptor contains registers of all versions of bandgap chips.
97eb982001SEduardo Valentin  * Not all versions will use all registers, depending on the available
98eb982001SEduardo Valentin  * features. Please read TRMs for descriptive explanation on each bitfield.
99eb982001SEduardo Valentin  */
100eb982001SEduardo Valentin 
101eb982001SEduardo Valentin struct temp_sensor_registers {
102eb982001SEduardo Valentin 	u32	temp_sensor_ctrl;
103eb982001SEduardo Valentin 	u32	bgap_tempsoff_mask;
104eb982001SEduardo Valentin 	u32	bgap_soc_mask;
1059bebf348SBartlomiej Zolnierkiewicz 	u32	bgap_eocz_mask;
106eb982001SEduardo Valentin 	u32	bgap_dtemp_mask;
107eb982001SEduardo Valentin 
108eb982001SEduardo Valentin 	u32	bgap_mask_ctrl;
109eb982001SEduardo Valentin 	u32	mask_hot_mask;
110eb982001SEduardo Valentin 	u32	mask_cold_mask;
111eb982001SEduardo Valentin 	u32	mask_counter_delay_mask;
112eb982001SEduardo Valentin 	u32	mask_freeze_mask;
113eb982001SEduardo Valentin 
114eb982001SEduardo Valentin 	u32	bgap_mode_ctrl;
115eb982001SEduardo Valentin 	u32	mode_ctrl_mask;
116eb982001SEduardo Valentin 
117eb982001SEduardo Valentin 	u32	bgap_counter;
118eb982001SEduardo Valentin 	u32	counter_mask;
119eb982001SEduardo Valentin 
120eb982001SEduardo Valentin 	u32	bgap_threshold;
121eb982001SEduardo Valentin 	u32	threshold_thot_mask;
122eb982001SEduardo Valentin 	u32	threshold_tcold_mask;
123eb982001SEduardo Valentin 
124eb982001SEduardo Valentin 	u32	tshut_threshold;
125eb982001SEduardo Valentin 	u32	tshut_hot_mask;
126eb982001SEduardo Valentin 	u32	tshut_cold_mask;
127eb982001SEduardo Valentin 
128eb982001SEduardo Valentin 	u32	bgap_status;
129eb982001SEduardo Valentin 	u32	status_hot_mask;
130eb982001SEduardo Valentin 	u32	status_cold_mask;
131eb982001SEduardo Valentin 
1329bebf348SBartlomiej Zolnierkiewicz 	u32	ctrl_dtemp_1;
1339bebf348SBartlomiej Zolnierkiewicz 	u32	ctrl_dtemp_2;
134eb982001SEduardo Valentin 	u32	bgap_efuse;
135eb982001SEduardo Valentin };
136eb982001SEduardo Valentin 
137eb982001SEduardo Valentin /**
138eb982001SEduardo Valentin  * struct temp_sensor_data - The thresholds and limits for temperature sensors.
139eb982001SEduardo Valentin  * @tshut_hot: temperature to trigger a thermal reset (initial value)
140eb982001SEduardo Valentin  * @tshut_cold: temp to get the plat out of reset due to thermal (init val)
141eb982001SEduardo Valentin  * @t_hot: temperature to trigger a thermal alert (high initial value)
142eb982001SEduardo Valentin  * @t_cold: temperature to trigger a thermal alert (low initial value)
143eb982001SEduardo Valentin  * @min_freq: sensor minimum clock rate
144eb982001SEduardo Valentin  * @max_freq: sensor maximum clock rate
145eb982001SEduardo Valentin  *
146eb982001SEduardo Valentin  * This data structure will hold the required thresholds and temperature limits
147eb982001SEduardo Valentin  * for a specific temperature sensor, like shutdown temperature, alert
148eb982001SEduardo Valentin  * temperature, clock / rate used, ADC conversion limits and update intervals
149eb982001SEduardo Valentin  */
150eb982001SEduardo Valentin struct temp_sensor_data {
151eb982001SEduardo Valentin 	u32	tshut_hot;
152eb982001SEduardo Valentin 	u32	tshut_cold;
153eb982001SEduardo Valentin 	u32	t_hot;
154eb982001SEduardo Valentin 	u32	t_cold;
155eb982001SEduardo Valentin 	u32	min_freq;
156eb982001SEduardo Valentin 	u32	max_freq;
157eb982001SEduardo Valentin };
158eb982001SEduardo Valentin 
159eb982001SEduardo Valentin struct ti_bandgap_data;
160eb982001SEduardo Valentin 
161eb982001SEduardo Valentin /**
162eb982001SEduardo Valentin  * struct temp_sensor_regval - temperature sensor register values and priv data
163eb982001SEduardo Valentin  * @bg_mode_ctrl: temp sensor control register value
164eb982001SEduardo Valentin  * @bg_ctrl: bandgap ctrl register value
165eb982001SEduardo Valentin  * @bg_counter: bandgap counter value
166eb982001SEduardo Valentin  * @bg_threshold: bandgap threshold register value
167eb982001SEduardo Valentin  * @tshut_threshold: bandgap tshut register value
168eb982001SEduardo Valentin  * @data: private data
169eb982001SEduardo Valentin  *
170eb982001SEduardo Valentin  * Data structure to save and restore bandgap register set context. Only
171eb982001SEduardo Valentin  * required registers are shadowed, when needed.
172eb982001SEduardo Valentin  */
173eb982001SEduardo Valentin struct temp_sensor_regval {
174eb982001SEduardo Valentin 	u32			bg_mode_ctrl;
175eb982001SEduardo Valentin 	u32			bg_ctrl;
176eb982001SEduardo Valentin 	u32			bg_counter;
177eb982001SEduardo Valentin 	u32			bg_threshold;
178eb982001SEduardo Valentin 	u32			tshut_threshold;
179eb982001SEduardo Valentin 	void			*data;
180eb982001SEduardo Valentin };
181eb982001SEduardo Valentin 
182eb982001SEduardo Valentin /**
183eb982001SEduardo Valentin  * struct ti_bandgap - bandgap device structure
184eb982001SEduardo Valentin  * @dev: struct device pointer
185eb982001SEduardo Valentin  * @base: io memory base address
186eb982001SEduardo Valentin  * @conf: struct with bandgap configuration set (# sensors, conv_table, etc)
187eb982001SEduardo Valentin  * @regval: temperature sensor register values
188eb982001SEduardo Valentin  * @fclock: pointer to functional clock of temperature sensor
189eb982001SEduardo Valentin  * @div_clk: pointer to divider clock of temperature sensor fclk
190eb982001SEduardo Valentin  * @lock: spinlock for ti_bandgap structure
191eb982001SEduardo Valentin  * @irq: MPU IRQ number for thermal alert
192eb982001SEduardo Valentin  * @tshut_gpio: GPIO where Tshut signal is routed
193eb982001SEduardo Valentin  * @clk_rate: Holds current clock rate
194eb982001SEduardo Valentin  *
195eb982001SEduardo Valentin  * The bandgap device structure representing the bandgap device instance.
196eb982001SEduardo Valentin  * It holds most of the dynamic stuff. Configurations and sensor specific
197eb982001SEduardo Valentin  * entries are inside the @conf structure.
198eb982001SEduardo Valentin  */
199eb982001SEduardo Valentin struct ti_bandgap {
200eb982001SEduardo Valentin 	struct device			*dev;
201eb982001SEduardo Valentin 	void __iomem			*base;
202eb982001SEduardo Valentin 	const struct ti_bandgap_data	*conf;
203eb982001SEduardo Valentin 	struct temp_sensor_regval	*regval;
204eb982001SEduardo Valentin 	struct clk			*fclock;
205eb982001SEduardo Valentin 	struct clk			*div_clk;
206eb982001SEduardo Valentin 	spinlock_t			lock; /* shields this struct */
207eb982001SEduardo Valentin 	int				irq;
2087375f2acSLinus Walleij 	struct gpio_desc		*tshut_gpiod;
209eb982001SEduardo Valentin 	u32				clk_rate;
2105093402eSAdam Ford 	struct notifier_block		nb;
2115093402eSAdam Ford 	unsigned int is_suspended:1;
212eb982001SEduardo Valentin };
213eb982001SEduardo Valentin 
214eb982001SEduardo Valentin /**
215eb982001SEduardo Valentin  * struct ti_temp_sensor - bandgap temperature sensor configuration data
216eb982001SEduardo Valentin  * @ts_data: pointer to struct with thresholds, limits of temperature sensor
217eb982001SEduardo Valentin  * @registers: pointer to the list of register offsets and bitfields
218eb982001SEduardo Valentin  * @domain: the name of the domain where the sensor is located
219eb982001SEduardo Valentin  * @slope_pcb: sensor gradient slope info for hotspot extrapolation equation
220eb982001SEduardo Valentin  *             with no external influence
221eb982001SEduardo Valentin  * @constant_pcb: sensor gradient const info for hotspot extrapolation equation
222eb982001SEduardo Valentin  *             with no external influence
223eb982001SEduardo Valentin  * @register_cooling: function to describe how this sensor is going to be cooled
224eb982001SEduardo Valentin  * @unregister_cooling: function to release cooling data
225eb982001SEduardo Valentin  *
226eb982001SEduardo Valentin  * Data structure to describe a temperature sensor handled by a bandgap device.
227eb982001SEduardo Valentin  * It should provide configuration details on this sensor, such as how to
228eb982001SEduardo Valentin  * access the registers affecting this sensor, shadow register buffer, how to
229eb982001SEduardo Valentin  * assess the gradient from hotspot, how to cooldown the domain when sensor
230eb982001SEduardo Valentin  * reports too hot temperature.
231eb982001SEduardo Valentin  */
232eb982001SEduardo Valentin struct ti_temp_sensor {
233eb982001SEduardo Valentin 	struct temp_sensor_data		*ts_data;
234eb982001SEduardo Valentin 	struct temp_sensor_registers	*registers;
235eb982001SEduardo Valentin 	char				*domain;
236eb982001SEduardo Valentin 	/* for hotspot extrapolation */
237eb982001SEduardo Valentin 	const int			slope_pcb;
238eb982001SEduardo Valentin 	const int			constant_pcb;
239eb982001SEduardo Valentin 	int (*register_cooling)(struct ti_bandgap *bgp, int id);
240eb982001SEduardo Valentin 	int (*unregister_cooling)(struct ti_bandgap *bgp, int id);
241eb982001SEduardo Valentin };
242eb982001SEduardo Valentin 
243eb982001SEduardo Valentin /**
244eb982001SEduardo Valentin  * DOC: ti bandgap feature types
245eb982001SEduardo Valentin  *
246eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_TSHUT - used when the thermal shutdown signal output
247eb982001SEduardo Valentin  *      of a bandgap device instance is routed to the processor. This means
248eb982001SEduardo Valentin  *      the system must react and perform the shutdown by itself (handle an
249eb982001SEduardo Valentin  *      IRQ, for instance).
250eb982001SEduardo Valentin  *
251eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_TSHUT_CONFIG - used when the bandgap device has control
252eb982001SEduardo Valentin  *      over the thermal shutdown configuration. This means that the thermal
253eb982001SEduardo Valentin  *      shutdown thresholds are programmable, for instance.
254eb982001SEduardo Valentin  *
255eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_TALERT - used when the bandgap device instance outputs
256eb982001SEduardo Valentin  *      a signal representing violation of programmable alert thresholds.
257eb982001SEduardo Valentin  *
258eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_MODE_CONFIG - used when it is possible to choose which
259eb982001SEduardo Valentin  *      mode, continuous or one shot, the bandgap device instance will operate.
260eb982001SEduardo Valentin  *
261eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_COUNTER - used when the bandgap device instance allows
262eb982001SEduardo Valentin  *      programming the update interval of its internal state machine.
263eb982001SEduardo Valentin  *
264eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_POWER_SWITCH - used when the bandgap device allows
265eb982001SEduardo Valentin  *      itself to be switched on/off.
266eb982001SEduardo Valentin  *
267eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_CLK_CTRL - used when the clocks feeding the bandgap
268eb982001SEduardo Valentin  *      device are gateable or not.
269eb982001SEduardo Valentin  *
270eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_FREEZE_BIT - used when the bandgap device features
271eb982001SEduardo Valentin  *      a history buffer that its update can be freezed/unfreezed.
272eb982001SEduardo Valentin  *
273eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_COUNTER_DELAY - used when the bandgap device features
274eb982001SEduardo Valentin  *	a delay programming based on distinct values.
275eb982001SEduardo Valentin  *
276eb982001SEduardo Valentin  * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
277eb982001SEduardo Valentin  *	a history buffer of temperatures.
278eb982001SEduardo Valentin  *
27979010636SKeerthy  * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
28079010636SKeerthy  *	has Errata 814
2819c5c87e5SPavel Machek  * TI_BANDGAP_FEATURE_UNRELIABLE - used when the sensor readings are too
2829c5c87e5SPavel Machek  *	inaccurate.
283*735c3535STony Lindgren  * TI_BANDGAP_FEATURE_CONT_MODE_ONLY - used when single mode hangs the sensor
284eb982001SEduardo Valentin  * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
285eb982001SEduardo Valentin  *      specific feature (above) or not. Return non-zero, if yes.
286eb982001SEduardo Valentin  */
287eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_TSHUT		BIT(0)
288eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_TSHUT_CONFIG		BIT(1)
289eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_TALERT		BIT(2)
290eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_MODE_CONFIG		BIT(3)
291eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_COUNTER		BIT(4)
292eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_POWER_SWITCH		BIT(5)
293eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_CLK_CTRL		BIT(6)
294eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
295eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
296eb982001SEduardo Valentin #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
29779010636SKeerthy #define TI_BANDGAP_FEATURE_ERRATA_814		BIT(10)
2989bebf348SBartlomiej Zolnierkiewicz #define TI_BANDGAP_FEATURE_UNRELIABLE		BIT(11)
299*735c3535STony Lindgren #define TI_BANDGAP_FEATURE_CONT_MODE_ONLY	BIT(12)
300eb982001SEduardo Valentin #define TI_BANDGAP_HAS(b, f)			\
301eb982001SEduardo Valentin 			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
302eb982001SEduardo Valentin 
303eb982001SEduardo Valentin /**
304eb982001SEduardo Valentin  * struct ti_bandgap_data - ti bandgap data configuration structure
305eb982001SEduardo Valentin  * @features: a bitwise flag set to describe the device features
306eb982001SEduardo Valentin  * @conv_table: Pointer to ADC to temperature conversion table
307eb982001SEduardo Valentin  * @adc_start_val: ADC conversion table starting value
308eb982001SEduardo Valentin  * @adc_end_val: ADC conversion table ending value
309eb982001SEduardo Valentin  * @fclock_name: clock name of the functional clock
310eb982001SEduardo Valentin  * @div_ck_name: clock name of the clock divisor
311eb982001SEduardo Valentin  * @sensor_count: count of temperature sensor within this bandgap device
312eb982001SEduardo Valentin  * @report_temperature: callback to report thermal alert to thermal API
313eb982001SEduardo Valentin  * @expose_sensor: callback to export sensor to thermal API
314eb982001SEduardo Valentin  * @remove_sensor: callback to destroy sensor from thermal API
315eb982001SEduardo Valentin  * @sensors: array of sensors present in this bandgap instance
316eb982001SEduardo Valentin  *
317eb982001SEduardo Valentin  * This is a data structure which should hold most of the static configuration
318eb982001SEduardo Valentin  * of a bandgap device instance. It should describe which features this instance
319eb982001SEduardo Valentin  * is capable of, the clock names to feed this device, the amount of sensors and
320eb982001SEduardo Valentin  * their configuration representation, and how to export and unexport them to
321eb982001SEduardo Valentin  * a thermal API.
322eb982001SEduardo Valentin  */
323eb982001SEduardo Valentin struct ti_bandgap_data {
324eb982001SEduardo Valentin 	unsigned int			features;
325eb982001SEduardo Valentin 	const int			*conv_table;
326eb982001SEduardo Valentin 	u32				adc_start_val;
327eb982001SEduardo Valentin 	u32				adc_end_val;
328eb982001SEduardo Valentin 	char				*fclock_name;
329eb982001SEduardo Valentin 	char				*div_ck_name;
330eb982001SEduardo Valentin 	int				sensor_count;
331eb982001SEduardo Valentin 	int (*report_temperature)(struct ti_bandgap *bgp, int id);
332eb982001SEduardo Valentin 	int (*expose_sensor)(struct ti_bandgap *bgp, int id, char *domain);
333eb982001SEduardo Valentin 	int (*remove_sensor)(struct ti_bandgap *bgp, int id);
334eb982001SEduardo Valentin 
335eb982001SEduardo Valentin 	/* this needs to be at the end */
336eb982001SEduardo Valentin 	struct ti_temp_sensor		sensors[];
337eb982001SEduardo Valentin };
338eb982001SEduardo Valentin 
339eb982001SEduardo Valentin int ti_bandgap_read_thot(struct ti_bandgap *bgp, int id, int *thot);
340eb982001SEduardo Valentin int ti_bandgap_write_thot(struct ti_bandgap *bgp, int id, int val);
341eb982001SEduardo Valentin int ti_bandgap_read_tcold(struct ti_bandgap *bgp, int id, int *tcold);
342eb982001SEduardo Valentin int ti_bandgap_write_tcold(struct ti_bandgap *bgp, int id, int val);
343eb982001SEduardo Valentin int ti_bandgap_read_update_interval(struct ti_bandgap *bgp, int id,
344eb982001SEduardo Valentin 				    int *interval);
345eb982001SEduardo Valentin int ti_bandgap_write_update_interval(struct ti_bandgap *bgp, int id,
346eb982001SEduardo Valentin 				     u32 interval);
347eb982001SEduardo Valentin int ti_bandgap_read_temperature(struct ti_bandgap *bgp, int id,
348eb982001SEduardo Valentin 				  int *temperature);
349eb982001SEduardo Valentin int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
350eb982001SEduardo Valentin void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
351eb982001SEduardo Valentin int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
352eb982001SEduardo Valentin 
3539c5c87e5SPavel Machek #ifdef CONFIG_OMAP3_THERMAL
3549c5c87e5SPavel Machek extern const struct ti_bandgap_data omap34xx_data;
355b840b6e6SEduardo Valentin extern const struct ti_bandgap_data omap36xx_data;
3569c5c87e5SPavel Machek #else
3579c5c87e5SPavel Machek #define omap34xx_data					NULL
358b840b6e6SEduardo Valentin #define omap36xx_data					NULL
3599c5c87e5SPavel Machek #endif
3609c5c87e5SPavel Machek 
361eb982001SEduardo Valentin #ifdef CONFIG_OMAP4_THERMAL
362eb982001SEduardo Valentin extern const struct ti_bandgap_data omap4430_data;
363eb982001SEduardo Valentin extern const struct ti_bandgap_data omap4460_data;
364eb982001SEduardo Valentin extern const struct ti_bandgap_data omap4470_data;
365eb982001SEduardo Valentin #else
366eb982001SEduardo Valentin #define omap4430_data					NULL
367eb982001SEduardo Valentin #define omap4460_data					NULL
368eb982001SEduardo Valentin #define omap4470_data					NULL
369eb982001SEduardo Valentin #endif
370eb982001SEduardo Valentin 
371eb982001SEduardo Valentin #ifdef CONFIG_OMAP5_THERMAL
372eb982001SEduardo Valentin extern const struct ti_bandgap_data omap5430_data;
373eb982001SEduardo Valentin #else
374eb982001SEduardo Valentin #define omap5430_data					NULL
375eb982001SEduardo Valentin #endif
376eb982001SEduardo Valentin 
37725870e62SEduardo Valentin #ifdef CONFIG_DRA752_THERMAL
37825870e62SEduardo Valentin extern const struct ti_bandgap_data dra752_data;
37925870e62SEduardo Valentin #else
38025870e62SEduardo Valentin #define dra752_data					NULL
38125870e62SEduardo Valentin #endif
382eb982001SEduardo Valentin #endif
383