162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * OMAP4 Bandgap temperature sensor driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
662306a36Sopenharmony_ci * Contact:
762306a36Sopenharmony_ci *   Eduardo Valentin <eduardo.valentin@ti.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci#ifndef __TI_BANDGAP_H
1062306a36Sopenharmony_ci#define __TI_BANDGAP_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/spinlock.h>
1362306a36Sopenharmony_ci#include <linux/types.h>
1462306a36Sopenharmony_ci#include <linux/err.h>
1562306a36Sopenharmony_ci#include <linux/cpu_pm.h>
1662306a36Sopenharmony_ci#include <linux/device.h>
1762306a36Sopenharmony_ci#include <linux/pm_runtime.h>
1862306a36Sopenharmony_ci#include <linux/pm.h>
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cistruct gpio_desc;
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/**
2362306a36Sopenharmony_ci * DOC: bandgap driver data structure
2462306a36Sopenharmony_ci * ==================================
2562306a36Sopenharmony_ci *
2662306a36Sopenharmony_ci *   +----------+----------------+
2762306a36Sopenharmony_ci *   | struct temp_sensor_regval |
2862306a36Sopenharmony_ci *   +---------------------------+
2962306a36Sopenharmony_ci *              * (Array of)
3062306a36Sopenharmony_ci *              |
3162306a36Sopenharmony_ci *              |
3262306a36Sopenharmony_ci *   +-------------------+   +-----------------+
3362306a36Sopenharmony_ci *   | struct ti_bandgap |-->| struct device * |
3462306a36Sopenharmony_ci *   +----------+--------+   +-----------------+
3562306a36Sopenharmony_ci *              |
3662306a36Sopenharmony_ci *              |
3762306a36Sopenharmony_ci *              V
3862306a36Sopenharmony_ci *   +------------------------+
3962306a36Sopenharmony_ci *   | struct ti_bandgap_data |
4062306a36Sopenharmony_ci *   +------------------------+
4162306a36Sopenharmony_ci *              |
4262306a36Sopenharmony_ci *              |
4362306a36Sopenharmony_ci *              * (Array of)
4462306a36Sopenharmony_ci * +------------+------------------------------------------------------+
4562306a36Sopenharmony_ci * | +----------+------------+   +-------------------------+           |
4662306a36Sopenharmony_ci * | | struct ti_temp_sensor |-->| struct temp_sensor_data |           |
4762306a36Sopenharmony_ci * | +-----------------------+   +------------+------------+           |
4862306a36Sopenharmony_ci * |            |                                                      |
4962306a36Sopenharmony_ci * |            +                                                      |
5062306a36Sopenharmony_ci * |            V                                                      |
5162306a36Sopenharmony_ci * | +----------+-------------------+                                  |
5262306a36Sopenharmony_ci * | | struct temp_sensor_registers |                                  |
5362306a36Sopenharmony_ci * | +------------------------------+                                  |
5462306a36Sopenharmony_ci * |                                                                   |
5562306a36Sopenharmony_ci * +-------------------------------------------------------------------+
5662306a36Sopenharmony_ci *
5762306a36Sopenharmony_ci * Above is a simple diagram describing how the data structure below
5862306a36Sopenharmony_ci * are organized. For each bandgap device there should be a ti_bandgap_data
5962306a36Sopenharmony_ci * containing the device instance configuration, as well as, an array of
6062306a36Sopenharmony_ci * sensors, representing every sensor instance present in this bandgap.
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/**
6462306a36Sopenharmony_ci * struct temp_sensor_registers - descriptor to access registers and bitfields
6562306a36Sopenharmony_ci * @temp_sensor_ctrl: TEMP_SENSOR_CTRL register offset
6662306a36Sopenharmony_ci * @bgap_tempsoff_mask: mask to temp_sensor_ctrl.tempsoff
6762306a36Sopenharmony_ci * @bgap_soc_mask: mask to temp_sensor_ctrl.soc
6862306a36Sopenharmony_ci * @bgap_eocz_mask: mask to temp_sensor_ctrl.eocz
6962306a36Sopenharmony_ci * @bgap_dtemp_mask: mask to temp_sensor_ctrl.dtemp
7062306a36Sopenharmony_ci * @bgap_mask_ctrl: BANDGAP_MASK_CTRL register offset
7162306a36Sopenharmony_ci * @mask_hot_mask: mask to bandgap_mask_ctrl.mask_hot
7262306a36Sopenharmony_ci * @mask_cold_mask: mask to bandgap_mask_ctrl.mask_cold
7362306a36Sopenharmony_ci * @mask_counter_delay_mask: mask to bandgap_mask_ctrl.mask_counter_delay
7462306a36Sopenharmony_ci * @mask_freeze_mask: mask to bandgap_mask_ctrl.mask_free
7562306a36Sopenharmony_ci * @bgap_mode_ctrl: BANDGAP_MODE_CTRL register offset
7662306a36Sopenharmony_ci * @mode_ctrl_mask: mask to bandgap_mode_ctrl.mode_ctrl
7762306a36Sopenharmony_ci * @bgap_counter: BANDGAP_COUNTER register offset
7862306a36Sopenharmony_ci * @counter_mask: mask to bandgap_counter.counter
7962306a36Sopenharmony_ci * @bgap_threshold: BANDGAP_THRESHOLD register offset (TALERT thresholds)
8062306a36Sopenharmony_ci * @threshold_thot_mask: mask to bandgap_threhold.thot
8162306a36Sopenharmony_ci * @threshold_tcold_mask: mask to bandgap_threhold.tcold
8262306a36Sopenharmony_ci * @tshut_threshold: TSHUT_THRESHOLD register offset (TSHUT thresholds)
8362306a36Sopenharmony_ci * @tshut_hot_mask: mask to tshut_threhold.thot
8462306a36Sopenharmony_ci * @tshut_cold_mask: mask to tshut_threhold.thot
8562306a36Sopenharmony_ci * @bgap_status: BANDGAP_STATUS register offset
8662306a36Sopenharmony_ci * @status_hot_mask: mask to bandgap_status.hot
8762306a36Sopenharmony_ci * @status_cold_mask: mask to bandgap_status.cold
8862306a36Sopenharmony_ci * @ctrl_dtemp_1: CTRL_DTEMP1 register offset
8962306a36Sopenharmony_ci * @ctrl_dtemp_2: CTRL_DTEMP2 register offset
9062306a36Sopenharmony_ci * @bgap_efuse: BANDGAP_EFUSE register offset
9162306a36Sopenharmony_ci *
9262306a36Sopenharmony_ci * The register offsets and bitfields might change across
9362306a36Sopenharmony_ci * OMAP and variants versions. Hence this struct serves as a
9462306a36Sopenharmony_ci * descriptor map on how to access the registers and the bitfields.
9562306a36Sopenharmony_ci *
9662306a36Sopenharmony_ci * This descriptor contains registers of all versions of bandgap chips.
9762306a36Sopenharmony_ci * Not all versions will use all registers, depending on the available
9862306a36Sopenharmony_ci * features. Please read TRMs for descriptive explanation on each bitfield.
9962306a36Sopenharmony_ci */
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistruct temp_sensor_registers {
10262306a36Sopenharmony_ci	u32	temp_sensor_ctrl;
10362306a36Sopenharmony_ci	u32	bgap_tempsoff_mask;
10462306a36Sopenharmony_ci	u32	bgap_soc_mask;
10562306a36Sopenharmony_ci	u32	bgap_eocz_mask;
10662306a36Sopenharmony_ci	u32	bgap_dtemp_mask;
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci	u32	bgap_mask_ctrl;
10962306a36Sopenharmony_ci	u32	mask_hot_mask;
11062306a36Sopenharmony_ci	u32	mask_cold_mask;
11162306a36Sopenharmony_ci	u32	mask_counter_delay_mask;
11262306a36Sopenharmony_ci	u32	mask_freeze_mask;
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci	u32	bgap_mode_ctrl;
11562306a36Sopenharmony_ci	u32	mode_ctrl_mask;
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci	u32	bgap_counter;
11862306a36Sopenharmony_ci	u32	counter_mask;
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci	u32	bgap_threshold;
12162306a36Sopenharmony_ci	u32	threshold_thot_mask;
12262306a36Sopenharmony_ci	u32	threshold_tcold_mask;
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci	u32	tshut_threshold;
12562306a36Sopenharmony_ci	u32	tshut_hot_mask;
12662306a36Sopenharmony_ci	u32	tshut_cold_mask;
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci	u32	bgap_status;
12962306a36Sopenharmony_ci	u32	status_hot_mask;
13062306a36Sopenharmony_ci	u32	status_cold_mask;
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci	u32	ctrl_dtemp_1;
13362306a36Sopenharmony_ci	u32	ctrl_dtemp_2;
13462306a36Sopenharmony_ci	u32	bgap_efuse;
13562306a36Sopenharmony_ci};
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/**
13862306a36Sopenharmony_ci * struct temp_sensor_data - The thresholds and limits for temperature sensors.
13962306a36Sopenharmony_ci * @tshut_hot: temperature to trigger a thermal reset (initial value)
14062306a36Sopenharmony_ci * @tshut_cold: temp to get the plat out of reset due to thermal (init val)
14162306a36Sopenharmony_ci * @t_hot: temperature to trigger a thermal alert (high initial value)
14262306a36Sopenharmony_ci * @t_cold: temperature to trigger a thermal alert (low initial value)
14362306a36Sopenharmony_ci * @min_freq: sensor minimum clock rate
14462306a36Sopenharmony_ci * @max_freq: sensor maximum clock rate
14562306a36Sopenharmony_ci *
14662306a36Sopenharmony_ci * This data structure will hold the required thresholds and temperature limits
14762306a36Sopenharmony_ci * for a specific temperature sensor, like shutdown temperature, alert
14862306a36Sopenharmony_ci * temperature, clock / rate used, ADC conversion limits and update intervals
14962306a36Sopenharmony_ci */
15062306a36Sopenharmony_cistruct temp_sensor_data {
15162306a36Sopenharmony_ci	u32	tshut_hot;
15262306a36Sopenharmony_ci	u32	tshut_cold;
15362306a36Sopenharmony_ci	u32	t_hot;
15462306a36Sopenharmony_ci	u32	t_cold;
15562306a36Sopenharmony_ci	u32	min_freq;
15662306a36Sopenharmony_ci	u32	max_freq;
15762306a36Sopenharmony_ci};
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_cistruct ti_bandgap_data;
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci/**
16262306a36Sopenharmony_ci * struct temp_sensor_regval - temperature sensor register values and priv data
16362306a36Sopenharmony_ci * @bg_mode_ctrl: temp sensor control register value
16462306a36Sopenharmony_ci * @bg_ctrl: bandgap ctrl register value
16562306a36Sopenharmony_ci * @bg_counter: bandgap counter value
16662306a36Sopenharmony_ci * @bg_threshold: bandgap threshold register value
16762306a36Sopenharmony_ci * @tshut_threshold: bandgap tshut register value
16862306a36Sopenharmony_ci * @data: private data
16962306a36Sopenharmony_ci *
17062306a36Sopenharmony_ci * Data structure to save and restore bandgap register set context. Only
17162306a36Sopenharmony_ci * required registers are shadowed, when needed.
17262306a36Sopenharmony_ci */
17362306a36Sopenharmony_cistruct temp_sensor_regval {
17462306a36Sopenharmony_ci	u32			bg_mode_ctrl;
17562306a36Sopenharmony_ci	u32			bg_ctrl;
17662306a36Sopenharmony_ci	u32			bg_counter;
17762306a36Sopenharmony_ci	u32			bg_threshold;
17862306a36Sopenharmony_ci	u32			tshut_threshold;
17962306a36Sopenharmony_ci	void			*data;
18062306a36Sopenharmony_ci};
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/**
18362306a36Sopenharmony_ci * struct ti_bandgap - bandgap device structure
18462306a36Sopenharmony_ci * @dev: struct device pointer
18562306a36Sopenharmony_ci * @base: io memory base address
18662306a36Sopenharmony_ci * @conf: struct with bandgap configuration set (# sensors, conv_table, etc)
18762306a36Sopenharmony_ci * @regval: temperature sensor register values
18862306a36Sopenharmony_ci * @fclock: pointer to functional clock of temperature sensor
18962306a36Sopenharmony_ci * @div_clk: pointer to divider clock of temperature sensor fclk
19062306a36Sopenharmony_ci * @lock: spinlock for ti_bandgap structure
19162306a36Sopenharmony_ci * @irq: MPU IRQ number for thermal alert
19262306a36Sopenharmony_ci * @tshut_gpio: GPIO where Tshut signal is routed
19362306a36Sopenharmony_ci * @clk_rate: Holds current clock rate
19462306a36Sopenharmony_ci *
19562306a36Sopenharmony_ci * The bandgap device structure representing the bandgap device instance.
19662306a36Sopenharmony_ci * It holds most of the dynamic stuff. Configurations and sensor specific
19762306a36Sopenharmony_ci * entries are inside the @conf structure.
19862306a36Sopenharmony_ci */
19962306a36Sopenharmony_cistruct ti_bandgap {
20062306a36Sopenharmony_ci	struct device			*dev;
20162306a36Sopenharmony_ci	void __iomem			*base;
20262306a36Sopenharmony_ci	const struct ti_bandgap_data	*conf;
20362306a36Sopenharmony_ci	struct temp_sensor_regval	*regval;
20462306a36Sopenharmony_ci	struct clk			*fclock;
20562306a36Sopenharmony_ci	struct clk			*div_clk;
20662306a36Sopenharmony_ci	spinlock_t			lock; /* shields this struct */
20762306a36Sopenharmony_ci	int				irq;
20862306a36Sopenharmony_ci	struct gpio_desc		*tshut_gpiod;
20962306a36Sopenharmony_ci	u32				clk_rate;
21062306a36Sopenharmony_ci	struct notifier_block		nb;
21162306a36Sopenharmony_ci	unsigned int is_suspended:1;
21262306a36Sopenharmony_ci};
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci/**
21562306a36Sopenharmony_ci * struct ti_temp_sensor - bandgap temperature sensor configuration data
21662306a36Sopenharmony_ci * @ts_data: pointer to struct with thresholds, limits of temperature sensor
21762306a36Sopenharmony_ci * @registers: pointer to the list of register offsets and bitfields
21862306a36Sopenharmony_ci * @domain: the name of the domain where the sensor is located
21962306a36Sopenharmony_ci * @slope_pcb: sensor gradient slope info for hotspot extrapolation equation
22062306a36Sopenharmony_ci *             with no external influence
22162306a36Sopenharmony_ci * @constant_pcb: sensor gradient const info for hotspot extrapolation equation
22262306a36Sopenharmony_ci *             with no external influence
22362306a36Sopenharmony_ci * @register_cooling: function to describe how this sensor is going to be cooled
22462306a36Sopenharmony_ci * @unregister_cooling: function to release cooling data
22562306a36Sopenharmony_ci *
22662306a36Sopenharmony_ci * Data structure to describe a temperature sensor handled by a bandgap device.
22762306a36Sopenharmony_ci * It should provide configuration details on this sensor, such as how to
22862306a36Sopenharmony_ci * access the registers affecting this sensor, shadow register buffer, how to
22962306a36Sopenharmony_ci * assess the gradient from hotspot, how to cooldown the domain when sensor
23062306a36Sopenharmony_ci * reports too hot temperature.
23162306a36Sopenharmony_ci */
23262306a36Sopenharmony_cistruct ti_temp_sensor {
23362306a36Sopenharmony_ci	struct temp_sensor_data		*ts_data;
23462306a36Sopenharmony_ci	struct temp_sensor_registers	*registers;
23562306a36Sopenharmony_ci	char				*domain;
23662306a36Sopenharmony_ci	/* for hotspot extrapolation */
23762306a36Sopenharmony_ci	const int			slope_pcb;
23862306a36Sopenharmony_ci	const int			constant_pcb;
23962306a36Sopenharmony_ci	int (*register_cooling)(struct ti_bandgap *bgp, int id);
24062306a36Sopenharmony_ci	int (*unregister_cooling)(struct ti_bandgap *bgp, int id);
24162306a36Sopenharmony_ci};
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/**
24462306a36Sopenharmony_ci * DOC: ti bandgap feature types
24562306a36Sopenharmony_ci *
24662306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_TSHUT - used when the thermal shutdown signal output
24762306a36Sopenharmony_ci *      of a bandgap device instance is routed to the processor. This means
24862306a36Sopenharmony_ci *      the system must react and perform the shutdown by itself (handle an
24962306a36Sopenharmony_ci *      IRQ, for instance).
25062306a36Sopenharmony_ci *
25162306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_TSHUT_CONFIG - used when the bandgap device has control
25262306a36Sopenharmony_ci *      over the thermal shutdown configuration. This means that the thermal
25362306a36Sopenharmony_ci *      shutdown thresholds are programmable, for instance.
25462306a36Sopenharmony_ci *
25562306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_TALERT - used when the bandgap device instance outputs
25662306a36Sopenharmony_ci *      a signal representing violation of programmable alert thresholds.
25762306a36Sopenharmony_ci *
25862306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_MODE_CONFIG - used when it is possible to choose which
25962306a36Sopenharmony_ci *      mode, continuous or one shot, the bandgap device instance will operate.
26062306a36Sopenharmony_ci *
26162306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_COUNTER - used when the bandgap device instance allows
26262306a36Sopenharmony_ci *      programming the update interval of its internal state machine.
26362306a36Sopenharmony_ci *
26462306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_POWER_SWITCH - used when the bandgap device allows
26562306a36Sopenharmony_ci *      itself to be switched on/off.
26662306a36Sopenharmony_ci *
26762306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_CLK_CTRL - used when the clocks feeding the bandgap
26862306a36Sopenharmony_ci *      device are gateable or not.
26962306a36Sopenharmony_ci *
27062306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_FREEZE_BIT - used when the bandgap device features
27162306a36Sopenharmony_ci *      a history buffer that its update can be freezed/unfreezed.
27262306a36Sopenharmony_ci *
27362306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_COUNTER_DELAY - used when the bandgap device features
27462306a36Sopenharmony_ci *	a delay programming based on distinct values.
27562306a36Sopenharmony_ci *
27662306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
27762306a36Sopenharmony_ci *	a history buffer of temperatures.
27862306a36Sopenharmony_ci *
27962306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
28062306a36Sopenharmony_ci *	has Errata 814
28162306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_UNRELIABLE - used when the sensor readings are too
28262306a36Sopenharmony_ci *	inaccurate.
28362306a36Sopenharmony_ci * TI_BANDGAP_FEATURE_CONT_MODE_ONLY - used when single mode hangs the sensor
28462306a36Sopenharmony_ci * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
28562306a36Sopenharmony_ci *      specific feature (above) or not. Return non-zero, if yes.
28662306a36Sopenharmony_ci */
28762306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_TSHUT		BIT(0)
28862306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_TSHUT_CONFIG		BIT(1)
28962306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_TALERT		BIT(2)
29062306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_MODE_CONFIG		BIT(3)
29162306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_COUNTER		BIT(4)
29262306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_POWER_SWITCH		BIT(5)
29362306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_CLK_CTRL		BIT(6)
29462306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
29562306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
29662306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
29762306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_ERRATA_814		BIT(10)
29862306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_UNRELIABLE		BIT(11)
29962306a36Sopenharmony_ci#define TI_BANDGAP_FEATURE_CONT_MODE_ONLY	BIT(12)
30062306a36Sopenharmony_ci#define TI_BANDGAP_HAS(b, f)			\
30162306a36Sopenharmony_ci			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci/**
30462306a36Sopenharmony_ci * struct ti_bandgap_data - ti bandgap data configuration structure
30562306a36Sopenharmony_ci * @features: a bitwise flag set to describe the device features
30662306a36Sopenharmony_ci * @conv_table: Pointer to ADC to temperature conversion table
30762306a36Sopenharmony_ci * @adc_start_val: ADC conversion table starting value
30862306a36Sopenharmony_ci * @adc_end_val: ADC conversion table ending value
30962306a36Sopenharmony_ci * @fclock_name: clock name of the functional clock
31062306a36Sopenharmony_ci * @div_ck_name: clock name of the clock divisor
31162306a36Sopenharmony_ci * @sensor_count: count of temperature sensor within this bandgap device
31262306a36Sopenharmony_ci * @report_temperature: callback to report thermal alert to thermal API
31362306a36Sopenharmony_ci * @expose_sensor: callback to export sensor to thermal API
31462306a36Sopenharmony_ci * @remove_sensor: callback to destroy sensor from thermal API
31562306a36Sopenharmony_ci * @sensors: array of sensors present in this bandgap instance
31662306a36Sopenharmony_ci *
31762306a36Sopenharmony_ci * This is a data structure which should hold most of the static configuration
31862306a36Sopenharmony_ci * of a bandgap device instance. It should describe which features this instance
31962306a36Sopenharmony_ci * is capable of, the clock names to feed this device, the amount of sensors and
32062306a36Sopenharmony_ci * their configuration representation, and how to export and unexport them to
32162306a36Sopenharmony_ci * a thermal API.
32262306a36Sopenharmony_ci */
32362306a36Sopenharmony_cistruct ti_bandgap_data {
32462306a36Sopenharmony_ci	unsigned int			features;
32562306a36Sopenharmony_ci	const int			*conv_table;
32662306a36Sopenharmony_ci	u32				adc_start_val;
32762306a36Sopenharmony_ci	u32				adc_end_val;
32862306a36Sopenharmony_ci	char				*fclock_name;
32962306a36Sopenharmony_ci	char				*div_ck_name;
33062306a36Sopenharmony_ci	int				sensor_count;
33162306a36Sopenharmony_ci	int (*report_temperature)(struct ti_bandgap *bgp, int id);
33262306a36Sopenharmony_ci	int (*expose_sensor)(struct ti_bandgap *bgp, int id, char *domain);
33362306a36Sopenharmony_ci	int (*remove_sensor)(struct ti_bandgap *bgp, int id);
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci	/* this needs to be at the end */
33662306a36Sopenharmony_ci	struct ti_temp_sensor		sensors[];
33762306a36Sopenharmony_ci};
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_ciint ti_bandgap_read_thot(struct ti_bandgap *bgp, int id, int *thot);
34062306a36Sopenharmony_ciint ti_bandgap_write_thot(struct ti_bandgap *bgp, int id, int val);
34162306a36Sopenharmony_ciint ti_bandgap_read_tcold(struct ti_bandgap *bgp, int id, int *tcold);
34262306a36Sopenharmony_ciint ti_bandgap_write_tcold(struct ti_bandgap *bgp, int id, int val);
34362306a36Sopenharmony_ciint ti_bandgap_read_update_interval(struct ti_bandgap *bgp, int id,
34462306a36Sopenharmony_ci				    int *interval);
34562306a36Sopenharmony_ciint ti_bandgap_write_update_interval(struct ti_bandgap *bgp, int id,
34662306a36Sopenharmony_ci				     u32 interval);
34762306a36Sopenharmony_ciint ti_bandgap_read_temperature(struct ti_bandgap *bgp, int id,
34862306a36Sopenharmony_ci				  int *temperature);
34962306a36Sopenharmony_ciint ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
35062306a36Sopenharmony_civoid *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
35162306a36Sopenharmony_ciint ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
35262306a36Sopenharmony_ci
35362306a36Sopenharmony_ci#ifdef CONFIG_OMAP3_THERMAL
35462306a36Sopenharmony_ciextern const struct ti_bandgap_data omap34xx_data;
35562306a36Sopenharmony_ciextern const struct ti_bandgap_data omap36xx_data;
35662306a36Sopenharmony_ci#else
35762306a36Sopenharmony_ci#define omap34xx_data					NULL
35862306a36Sopenharmony_ci#define omap36xx_data					NULL
35962306a36Sopenharmony_ci#endif
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ci#ifdef CONFIG_OMAP4_THERMAL
36262306a36Sopenharmony_ciextern const struct ti_bandgap_data omap4430_data;
36362306a36Sopenharmony_ciextern const struct ti_bandgap_data omap4460_data;
36462306a36Sopenharmony_ciextern const struct ti_bandgap_data omap4470_data;
36562306a36Sopenharmony_ci#else
36662306a36Sopenharmony_ci#define omap4430_data					NULL
36762306a36Sopenharmony_ci#define omap4460_data					NULL
36862306a36Sopenharmony_ci#define omap4470_data					NULL
36962306a36Sopenharmony_ci#endif
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci#ifdef CONFIG_OMAP5_THERMAL
37262306a36Sopenharmony_ciextern const struct ti_bandgap_data omap5430_data;
37362306a36Sopenharmony_ci#else
37462306a36Sopenharmony_ci#define omap5430_data					NULL
37562306a36Sopenharmony_ci#endif
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ci#ifdef CONFIG_DRA752_THERMAL
37862306a36Sopenharmony_ciextern const struct ti_bandgap_data dra752_data;
37962306a36Sopenharmony_ci#else
38062306a36Sopenharmony_ci#define dra752_data					NULL
38162306a36Sopenharmony_ci#endif
38262306a36Sopenharmony_ci#endif
383