#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/thermal.h>
#include <linux/reset.h>
#include <linux/types.h>
#include "../thermal_hwmon.h"
#define AUXADC_CON1_SET_V …
#define AUXADC_CON1_CLR_V …
#define AUXADC_CON2_V …
#define AUXADC_DATA(channel) …
#define APMIXED_SYS_TS_CON0 …
#define APMIXED_SYS_TS_CON1 …
#define TEMP_MONCTL0 …
#define TEMP_MONCTL1 …
#define TEMP_MONCTL2 …
#define TEMP_MONIDET0 …
#define TEMP_MONIDET1 …
#define TEMP_MSRCTL0 …
#define TEMP_MSRCTL1 …
#define TEMP_AHBPOLL …
#define TEMP_AHBTO …
#define TEMP_ADCPNP0 …
#define TEMP_ADCPNP1 …
#define TEMP_ADCPNP2 …
#define TEMP_ADCPNP3 …
#define TEMP_ADCMUX …
#define TEMP_ADCEN …
#define TEMP_PNPMUXADDR …
#define TEMP_ADCMUXADDR …
#define TEMP_ADCENADDR …
#define TEMP_ADCVALIDADDR …
#define TEMP_ADCVOLTADDR …
#define TEMP_RDCTRL …
#define TEMP_ADCVALIDMASK …
#define TEMP_ADCVOLTAGESHIFT …
#define TEMP_ADCWRITECTRL …
#define TEMP_MSR0 …
#define TEMP_MSR1 …
#define TEMP_MSR2 …
#define TEMP_MSR3 …
#define TEMP_SPARE0 …
#define TEMP_ADCPNP0_1 …
#define TEMP_ADCPNP1_1 …
#define TEMP_ADCPNP2_1 …
#define TEMP_MSR0_1 …
#define TEMP_MSR1_1 …
#define TEMP_MSR2_1 …
#define TEMP_ADCPNP3_1 …
#define TEMP_MSR3_1 …
#define PTPCORESEL …
#define TEMP_MONCTL1_PERIOD_UNIT(x) …
#define TEMP_MONCTL2_FILTER_INTERVAL(x) …
#define TEMP_MONCTL2_SENSOR_INTERVAL(x) …
#define TEMP_AHBPOLL_ADC_POLL_INTERVAL(x) …
#define TEMP_ADCWRITECTRL_ADC_PNP_WRITE …
#define TEMP_ADCWRITECTRL_ADC_MUX_WRITE …
#define TEMP_ADCVALIDMASK_VALID_HIGH …
#define TEMP_ADCVALIDMASK_VALID_POS(bit) …
#define MT8173_TS1 …
#define MT8173_TS2 …
#define MT8173_TS3 …
#define MT8173_TS4 …
#define MT8173_TSABB …
#define MT8173_TEMP_AUXADC_CHANNEL …
#define MT8173_NUM_SENSORS …
#define MT8173_NUM_ZONES …
#define MT8173_NUM_SENSORS_PER_ZONE …
#define MT8173_NUM_CONTROLLER …
#define MT8173_CALIBRATION …
#define MT8173_TEMP_MIN …
#define MT8173_TEMP_MAX …
#define CALIB_BUF0_VALID_V1 …
#define CALIB_BUF1_ADC_GE_V1(x) …
#define CALIB_BUF0_VTS_TS1_V1(x) …
#define CALIB_BUF0_VTS_TS2_V1(x) …
#define CALIB_BUF1_VTS_TS3_V1(x) …
#define CALIB_BUF2_VTS_TS4_V1(x) …
#define CALIB_BUF2_VTS_TS5_V1(x) …
#define CALIB_BUF2_VTS_TSABB_V1(x) …
#define CALIB_BUF0_DEGC_CALI_V1(x) …
#define CALIB_BUF0_O_SLOPE_V1(x) …
#define CALIB_BUF0_O_SLOPE_SIGN_V1(x) …
#define CALIB_BUF1_ID_V1(x) …
#define CALIB_BUF0_ADC_OE_V2(x) …
#define CALIB_BUF0_ADC_GE_V2(x) …
#define CALIB_BUF0_DEGC_CALI_V2(x) …
#define CALIB_BUF0_O_SLOPE_V2(x) …
#define CALIB_BUF1_VTS_TS1_V2(x) …
#define CALIB_BUF1_VTS_TS2_V2(x) …
#define CALIB_BUF1_VTS_TSABB_V2(x) …
#define CALIB_BUF1_VALID_V2(x) …
#define CALIB_BUF1_O_SLOPE_SIGN_V2(x) …
#define CALIB_BUF0_ADC_GE_V3(x) …
#define CALIB_BUF0_DEGC_CALI_V3(x) …
#define CALIB_BUF0_O_SLOPE_V3(x) …
#define CALIB_BUF1_VTS_TS1_V3(x) …
#define CALIB_BUF1_VTS_TS2_V3(x) …
#define CALIB_BUF1_VTS_TSABB_V3(x) …
#define CALIB_BUF1_VALID_V3(x) …
#define CALIB_BUF1_O_SLOPE_SIGN_V3(x) …
#define CALIB_BUF1_ID_V3(x) …
enum { … };
enum mtk_thermal_version { … };
#define MT2701_TS1 …
#define MT2701_TS2 …
#define MT2701_TSABB …
#define MT2701_TEMP_AUXADC_CHANNEL …
#define MT2701_NUM_SENSORS …
#define MT2701_NUM_SENSORS_PER_ZONE …
#define MT2701_NUM_CONTROLLER …
#define MT2701_CALIBRATION …
#define MT2712_TS1 …
#define MT2712_TS2 …
#define MT2712_TS3 …
#define MT2712_TS4 …
#define MT2712_TEMP_AUXADC_CHANNEL …
#define MT2712_NUM_SENSORS …
#define MT2712_NUM_SENSORS_PER_ZONE …
#define MT2712_NUM_CONTROLLER …
#define MT2712_CALIBRATION …
#define MT7622_TEMP_AUXADC_CHANNEL …
#define MT7622_NUM_SENSORS …
#define MT7622_NUM_ZONES …
#define MT7622_NUM_SENSORS_PER_ZONE …
#define MT7622_TS1 …
#define MT7622_NUM_CONTROLLER …
#define MAX_NUM_ZONES …
#define MT7622_CALIBRATION …
#define MT8183_TS1 …
#define MT8183_TS2 …
#define MT8183_TS3 …
#define MT8183_TS4 …
#define MT8183_TS5 …
#define MT8183_TSABB …
#define MT8183_TEMP_AUXADC_CHANNEL …
#define MT8183_NUM_SENSORS …
#define MT8183_NUM_ZONES …
#define MT8183_NUM_SENSORS_PER_ZONE …
#define MT8183_NUM_CONTROLLER …
#define MT8183_CALIBRATION …
#define MT7986_TEMP_AUXADC_CHANNEL …
#define MT7986_NUM_SENSORS …
#define MT7986_NUM_ZONES …
#define MT7986_NUM_SENSORS_PER_ZONE …
#define MT7986_TS1 …
#define MT7986_NUM_CONTROLLER …
#define MT7986_CALIBRATION …
#define MT8365_TEMP_AUXADC_CHANNEL …
#define MT8365_CALIBRATION …
#define MT8365_NUM_CONTROLLER …
#define MT8365_NUM_BANKS …
#define MT8365_NUM_SENSORS …
#define MT8365_NUM_SENSORS_PER_ZONE …
#define MT8365_TS1 …
#define MT8365_TS2 …
#define MT8365_TS3 …
struct mtk_thermal;
struct thermal_bank_cfg { … };
struct mtk_thermal_bank { … };
struct mtk_thermal_data { … };
struct mtk_thermal { … };
static const int mt8183_bank_data[MT8183_NUM_SENSORS] = …;
static const int mt8183_msr[MT8183_NUM_SENSORS_PER_ZONE] = …;
static const int mt8183_adcpnp[MT8183_NUM_SENSORS_PER_ZONE] = …;
static const int mt8183_mux_values[MT8183_NUM_SENSORS] = …;
static const int mt8183_tc_offset[MT8183_NUM_CONTROLLER] = …;
static const int mt8183_vts_index[MT8183_NUM_SENSORS] = …;
static const int mt8173_bank_data[MT8173_NUM_ZONES][3] = …;
static const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = …;
static const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = …;
static const int mt8173_mux_values[MT8173_NUM_SENSORS] = …;
static const int mt8173_tc_offset[MT8173_NUM_CONTROLLER] = …;
static const int mt8173_vts_index[MT8173_NUM_SENSORS] = …;
static const int mt2701_bank_data[MT2701_NUM_SENSORS] = …;
static const int mt2701_msr[MT2701_NUM_SENSORS_PER_ZONE] = …;
static const int mt2701_adcpnp[MT2701_NUM_SENSORS_PER_ZONE] = …;
static const int mt2701_mux_values[MT2701_NUM_SENSORS] = …;
static const int mt2701_tc_offset[MT2701_NUM_CONTROLLER] = …;
static const int mt2701_vts_index[MT2701_NUM_SENSORS] = …;
static const int mt2712_bank_data[MT2712_NUM_SENSORS] = …;
static const int mt2712_msr[MT2712_NUM_SENSORS_PER_ZONE] = …;
static const int mt2712_adcpnp[MT2712_NUM_SENSORS_PER_ZONE] = …;
static const int mt2712_mux_values[MT2712_NUM_SENSORS] = …;
static const int mt2712_tc_offset[MT2712_NUM_CONTROLLER] = …;
static const int mt2712_vts_index[MT2712_NUM_SENSORS] = …;
static const int mt7622_bank_data[MT7622_NUM_SENSORS] = …;
static const int mt7622_msr[MT7622_NUM_SENSORS_PER_ZONE] = …;
static const int mt7622_adcpnp[MT7622_NUM_SENSORS_PER_ZONE] = …;
static const int mt7622_mux_values[MT7622_NUM_SENSORS] = …;
static const int mt7622_vts_index[MT7622_NUM_SENSORS] = …;
static const int mt7622_tc_offset[MT7622_NUM_CONTROLLER] = …;
static const int mt7986_bank_data[MT7986_NUM_SENSORS] = …;
static const int mt7986_msr[MT7986_NUM_SENSORS_PER_ZONE] = …;
static const int mt7986_adcpnp[MT7986_NUM_SENSORS_PER_ZONE] = …;
static const int mt7986_mux_values[MT7986_NUM_SENSORS] = …;
static const int mt7986_vts_index[MT7986_NUM_SENSORS] = …;
static const int mt7986_tc_offset[MT7986_NUM_CONTROLLER] = …;
static const int mt8365_bank_data[MT8365_NUM_SENSORS] = …;
static const int mt8365_msr[MT8365_NUM_SENSORS_PER_ZONE] = …;
static const int mt8365_adcpnp[MT8365_NUM_SENSORS_PER_ZONE] = …;
static const int mt8365_mux_values[MT8365_NUM_SENSORS] = …;
static const int mt8365_tc_offset[MT8365_NUM_CONTROLLER] = …;
static const int mt8365_vts_index[MT8365_NUM_SENSORS] = …;
static const struct mtk_thermal_data mt8173_thermal_data = …;
static const struct mtk_thermal_data mt2701_thermal_data = …;
static const struct mtk_thermal_data mt8365_thermal_data = …;
static const struct mtk_thermal_data mt2712_thermal_data = …;
static const struct mtk_thermal_data mt7622_thermal_data = …;
static const struct mtk_thermal_data mt8183_thermal_data = …;
static const struct mtk_thermal_data mt7986_thermal_data = …;
static bool mtk_thermal_temp_is_valid(int temp)
{ … }
static int raw_to_mcelsius_v1(struct mtk_thermal *mt, int sensno, s32 raw)
{ … }
static int raw_to_mcelsius_v2(struct mtk_thermal *mt, int sensno, s32 raw)
{ … }
static int raw_to_mcelsius_v3(struct mtk_thermal *mt, int sensno, s32 raw)
{ … }
static void mtk_thermal_get_bank(struct mtk_thermal_bank *bank)
{ … }
static void mtk_thermal_put_bank(struct mtk_thermal_bank *bank)
{ … }
static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
{ … }
static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature)
{ … }
static const struct thermal_zone_device_ops mtk_thermal_ops = …;
static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num,
u32 apmixed_phys_base, u32 auxadc_phys_base,
int ctrl_id)
{ … }
static u64 of_get_phys_base(struct device_node *np)
{ … }
static int mtk_thermal_extract_efuse_v1(struct mtk_thermal *mt, u32 *buf)
{ … }
static int mtk_thermal_extract_efuse_v2(struct mtk_thermal *mt, u32 *buf)
{ … }
static int mtk_thermal_extract_efuse_v3(struct mtk_thermal *mt, u32 *buf)
{ … }
static int mtk_thermal_get_calibration_data(struct device *dev,
struct mtk_thermal *mt)
{ … }
static const struct of_device_id mtk_thermal_of_match[] = …;
MODULE_DEVICE_TABLE(of, mtk_thermal_of_match);
static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt,
void __iomem *apmixed_base)
{ … }
static void mtk_thermal_release_periodic_ts(struct mtk_thermal *mt,
void __iomem *auxadc_base)
{ … }
static int mtk_thermal_probe(struct platform_device *pdev)
{ … }
static struct platform_driver mtk_thermal_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;