soctherm.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef __DRIVERS_THERMAL_TEGRA_SOCTHERM_H
  16. #define __DRIVERS_THERMAL_TEGRA_SOCTHERM_H
  17. #define THERMCTL_LEVEL0_GROUP_CPU 0x0
  18. #define THERMCTL_LEVEL0_GROUP_GPU 0x4
  19. #define THERMCTL_LEVEL0_GROUP_MEM 0x8
  20. #define THERMCTL_LEVEL0_GROUP_TSENSE 0xc
  21. #define SENSOR_CONFIG2 8
  22. #define SENSOR_CONFIG2_THERMA_MASK (0xffff << 16)
  23. #define SENSOR_CONFIG2_THERMA_SHIFT 16
  24. #define SENSOR_CONFIG2_THERMB_MASK 0xffff
  25. #define SENSOR_CONFIG2_THERMB_SHIFT 0
  26. #define THERMCTL_THERMTRIP_CTL 0x80
  27. /* BITs are defined in device file */
  28. #define THERMCTL_INTR_ENABLE 0x88
  29. #define THERMCTL_INTR_DISABLE 0x8c
  30. #define TH_INTR_UP_DN_EN 0x3
  31. #define THERM_IRQ_MEM_MASK (TH_INTR_UP_DN_EN << 24)
  32. #define THERM_IRQ_GPU_MASK (TH_INTR_UP_DN_EN << 16)
  33. #define THERM_IRQ_CPU_MASK (TH_INTR_UP_DN_EN << 8)
  34. #define THERM_IRQ_TSENSE_MASK (TH_INTR_UP_DN_EN << 0)
  35. #define SENSOR_PDIV 0x1c0
  36. #define SENSOR_PDIV_CPU_MASK (0xf << 12)
  37. #define SENSOR_PDIV_GPU_MASK (0xf << 8)
  38. #define SENSOR_PDIV_MEM_MASK (0xf << 4)
  39. #define SENSOR_PDIV_PLLX_MASK (0xf << 0)
  40. #define SENSOR_HOTSPOT_OFF 0x1c4
  41. #define SENSOR_HOTSPOT_CPU_MASK (0xff << 16)
  42. #define SENSOR_HOTSPOT_GPU_MASK (0xff << 8)
  43. #define SENSOR_HOTSPOT_MEM_MASK (0xff << 0)
  44. #define SENSOR_TEMP1 0x1c8
  45. #define SENSOR_TEMP1_CPU_TEMP_MASK (0xffff << 16)
  46. #define SENSOR_TEMP1_GPU_TEMP_MASK 0xffff
  47. #define SENSOR_TEMP2 0x1cc
  48. #define SENSOR_TEMP2_MEM_TEMP_MASK (0xffff << 16)
  49. #define SENSOR_TEMP2_PLLX_TEMP_MASK 0xffff
  50. #define FUSE_VSENSOR_CALIB 0x08c
  51. #define FUSE_TSENSOR_COMMON 0x180
  52. /**
  53. * struct tegra_tsensor_group - SOC_THERM sensor group data
  54. * @name: short name of the temperature sensor group
  55. * @id: numeric ID of the temperature sensor group
  56. * @sensor_temp_offset: offset of the SENSOR_TEMP* register
  57. * @sensor_temp_mask: bit mask for this sensor group in SENSOR_TEMP* register
  58. * @pdiv: the sensor count post-divider to use during runtime
  59. * @pdiv_ate: the sensor count post-divider used during automated test
  60. * @pdiv_mask: register bitfield mask for the PDIV field for this sensor
  61. * @pllx_hotspot_diff: hotspot offset from the PLLX sensor, must be 0 for
  62. PLLX sensor group
  63. * @pllx_hotspot_mask: register bitfield mask for the HOTSPOT field
  64. */
  65. struct tegra_tsensor_group {
  66. const char *name;
  67. u8 id;
  68. u16 sensor_temp_offset;
  69. u32 sensor_temp_mask;
  70. u32 pdiv, pdiv_ate, pdiv_mask;
  71. u32 pllx_hotspot_diff, pllx_hotspot_mask;
  72. u32 thermtrip_enable_mask;
  73. u32 thermtrip_any_en_mask;
  74. u32 thermtrip_threshold_mask;
  75. u32 thermctl_isr_mask;
  76. u16 thermctl_lvl0_offset;
  77. u32 thermctl_lvl0_up_thresh_mask;
  78. u32 thermctl_lvl0_dn_thresh_mask;
  79. };
  80. struct tegra_tsensor_configuration {
  81. u32 tall, tiddq_en, ten_count, pdiv, pdiv_ate, tsample, tsample_ate;
  82. };
  83. struct tegra_tsensor {
  84. const char *name;
  85. const u32 base;
  86. const struct tegra_tsensor_configuration *config;
  87. const u32 calib_fuse_offset;
  88. /*
  89. * Correction values used to modify values read from
  90. * calibration fuses
  91. */
  92. const s32 fuse_corr_alpha, fuse_corr_beta;
  93. const struct tegra_tsensor_group *group;
  94. };
  95. struct tsensor_group_thermtrips {
  96. u8 id;
  97. u32 temp;
  98. };
  99. struct tegra_soctherm_fuse {
  100. u32 fuse_base_cp_mask, fuse_base_cp_shift;
  101. u32 fuse_shift_cp_mask, fuse_shift_cp_shift;
  102. u32 fuse_base_ft_mask, fuse_base_ft_shift;
  103. u32 fuse_shift_ft_mask, fuse_shift_ft_shift;
  104. u32 fuse_common_reg, fuse_spare_realignment;
  105. u32 nominal_calib_ft;
  106. };
  107. struct tsensor_shared_calib {
  108. u32 base_cp, base_ft;
  109. u32 actual_temp_cp, actual_temp_ft;
  110. };
  111. struct tegra_soctherm_soc {
  112. const struct tegra_tsensor *tsensors;
  113. const unsigned int num_tsensors;
  114. const struct tegra_tsensor_group **ttgs;
  115. const unsigned int num_ttgs;
  116. const struct tegra_soctherm_fuse *tfuse;
  117. const int thresh_grain;
  118. const unsigned int bptt;
  119. const bool use_ccroc;
  120. struct tsensor_group_thermtrips *thermtrips;
  121. };
  122. int tegra_calc_shared_calib(const struct tegra_soctherm_fuse *tfuse,
  123. struct tsensor_shared_calib *shared);
  124. int tegra_calc_tsensor_calib(const struct tegra_tsensor *sensor,
  125. const struct tsensor_shared_calib *shared,
  126. u32 *calib);
  127. #ifdef CONFIG_ARCH_TEGRA_114_SOC
  128. extern const struct tegra_soctherm_soc tegra114_soctherm;
  129. #endif
  130. #ifdef CONFIG_ARCH_TEGRA_124_SOC
  131. extern const struct tegra_soctherm_soc tegra124_soctherm;
  132. #endif
  133. #ifdef CONFIG_ARCH_TEGRA_132_SOC
  134. extern const struct tegra_soctherm_soc tegra132_soctherm;
  135. #endif
  136. #ifdef CONFIG_ARCH_TEGRA_210_SOC
  137. extern const struct tegra_soctherm_soc tegra210_soctherm;
  138. #endif
  139. #endif