blob: ec4b87616d012f7943b11c15b7e4e92779759a1b [file] [log] [blame]
Wei Ni65b6d572016-03-29 18:29:14 +08001/*
2 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __DRIVERS_THERMAL_TEGRA_SOCTHERM_H
16#define __DRIVERS_THERMAL_TEGRA_SOCTHERM_H
17
18#define SENSOR_CONFIG2 8
Wei Nid753b222016-03-29 18:29:16 +080019#define SENSOR_CONFIG2_THERMA_MASK (0xffff << 16)
Wei Ni65b6d572016-03-29 18:29:14 +080020#define SENSOR_CONFIG2_THERMA_SHIFT 16
Wei Nid753b222016-03-29 18:29:16 +080021#define SENSOR_CONFIG2_THERMB_MASK 0xffff
Wei Ni65b6d572016-03-29 18:29:14 +080022#define SENSOR_CONFIG2_THERMB_SHIFT 0
23
24#define SENSOR_PDIV 0x1c0
25#define SENSOR_PDIV_CPU_MASK (0xf << 12)
26#define SENSOR_PDIV_GPU_MASK (0xf << 8)
27#define SENSOR_PDIV_MEM_MASK (0xf << 4)
28#define SENSOR_PDIV_PLLX_MASK (0xf << 0)
29
30#define SENSOR_HOTSPOT_OFF 0x1c4
31#define SENSOR_HOTSPOT_CPU_MASK (0xff << 16)
32#define SENSOR_HOTSPOT_GPU_MASK (0xff << 8)
33#define SENSOR_HOTSPOT_MEM_MASK (0xff << 0)
34
35#define SENSOR_TEMP1 0x1c8
36#define SENSOR_TEMP1_CPU_TEMP_MASK (0xffff << 16)
37#define SENSOR_TEMP1_GPU_TEMP_MASK 0xffff
38#define SENSOR_TEMP2 0x1cc
39#define SENSOR_TEMP2_MEM_TEMP_MASK (0xffff << 16)
40#define SENSOR_TEMP2_PLLX_TEMP_MASK 0xffff
41
42/**
43 * struct tegra_tsensor_group - SOC_THERM sensor group data
44 * @name: short name of the temperature sensor group
45 * @id: numeric ID of the temperature sensor group
46 * @sensor_temp_offset: offset of the SENSOR_TEMP* register
47 * @sensor_temp_mask: bit mask for this sensor group in SENSOR_TEMP* register
48 * @pdiv: the sensor count post-divider to use during runtime
49 * @pdiv_ate: the sensor count post-divider used during automated test
50 * @pdiv_mask: register bitfield mask for the PDIV field for this sensor
51 * @pllx_hotspot_diff: hotspot offset from the PLLX sensor, must be 0 for
52 PLLX sensor group
53 * @pllx_hotspot_mask: register bitfield mask for the HOTSPOT field
54 */
55struct tegra_tsensor_group {
56 const char *name;
57 u8 id;
58 u16 sensor_temp_offset;
59 u32 sensor_temp_mask;
60 u32 pdiv, pdiv_ate, pdiv_mask;
61 u32 pllx_hotspot_diff, pllx_hotspot_mask;
62};
63
64struct tegra_tsensor_configuration {
65 u32 tall, tiddq_en, ten_count, pdiv, pdiv_ate, tsample, tsample_ate;
66};
67
68struct tegra_tsensor {
69 const char *name;
70 const u32 base;
71 const struct tegra_tsensor_configuration *config;
72 const u32 calib_fuse_offset;
73 /*
74 * Correction values used to modify values read from
75 * calibration fuses
76 */
77 const s32 fuse_corr_alpha, fuse_corr_beta;
78 const struct tegra_tsensor_group *group;
79};
80
81struct tegra_soctherm_fuse {
82 u32 fuse_base_cp_mask, fuse_base_cp_shift;
83 u32 fuse_base_ft_mask, fuse_base_ft_shift;
84 u32 fuse_shift_ft_mask, fuse_shift_ft_shift;
85 u32 fuse_spare_realignment;
86};
87
88struct tsensor_shared_calib {
89 u32 base_cp, base_ft;
90 u32 actual_temp_cp, actual_temp_ft;
91};
92
93struct tegra_soctherm_soc {
94 const struct tegra_tsensor *tsensors;
95 const unsigned int num_tsensors;
96 const struct tegra_tsensor_group **ttgs;
97 const unsigned int num_ttgs;
98 const struct tegra_soctherm_fuse *tfuse;
99};
100
101int tegra_calc_shared_calib(const struct tegra_soctherm_fuse *tfuse,
102 struct tsensor_shared_calib *shared);
103int tegra_calc_tsensor_calib(const struct tegra_tsensor *sensor,
104 const struct tsensor_shared_calib *shared,
105 u32 *calib);
106
107#ifdef CONFIG_ARCH_TEGRA_124_SOC
108extern const struct tegra_soctherm_soc tegra124_soctherm;
109#endif
110
Wei Ni82041042016-03-29 18:29:15 +0800111#ifdef CONFIG_ARCH_TEGRA_210_SOC
112extern const struct tegra_soctherm_soc tegra210_soctherm;
113#endif
114
Wei Ni65b6d572016-03-29 18:29:14 +0800115#endif
116