soctherm.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  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. #ifndef __DRIVERS_THERMAL_TEGRA_SOCTHERM_H
  15. #define __DRIVERS_THERMAL_TEGRA_SOCTHERM_H
  16. #define THERMCTL_LEVEL0_GROUP_CPU 0x0
  17. #define THERMCTL_LEVEL0_GROUP_GPU 0x4
  18. #define THERMCTL_LEVEL0_GROUP_MEM 0x8
  19. #define THERMCTL_LEVEL0_GROUP_TSENSE 0xc
  20. #define SENSOR_CONFIG2 8
  21. #define SENSOR_CONFIG2_THERMA_MASK (0xffff << 16)
  22. #define SENSOR_CONFIG2_THERMA_SHIFT 16
  23. #define SENSOR_CONFIG2_THERMB_MASK 0xffff
  24. #define SENSOR_CONFIG2_THERMB_SHIFT 0
  25. #define THERMCTL_THERMTRIP_CTL 0x80
  26. /* BITs are defined in device file */
  27. #define SENSOR_PDIV 0x1c0
  28. #define SENSOR_PDIV_CPU_MASK (0xf << 12)
  29. #define SENSOR_PDIV_GPU_MASK (0xf << 8)
  30. #define SENSOR_PDIV_MEM_MASK (0xf << 4)
  31. #define SENSOR_PDIV_PLLX_MASK (0xf << 0)
  32. #define SENSOR_HOTSPOT_OFF 0x1c4
  33. #define SENSOR_HOTSPOT_CPU_MASK (0xff << 16)
  34. #define SENSOR_HOTSPOT_GPU_MASK (0xff << 8)
  35. #define SENSOR_HOTSPOT_MEM_MASK (0xff << 0)
  36. #define SENSOR_TEMP1 0x1c8
  37. #define SENSOR_TEMP1_CPU_TEMP_MASK (0xffff << 16)
  38. #define SENSOR_TEMP1_GPU_TEMP_MASK 0xffff
  39. #define SENSOR_TEMP2 0x1cc
  40. #define SENSOR_TEMP2_MEM_TEMP_MASK (0xffff << 16)
  41. #define SENSOR_TEMP2_PLLX_TEMP_MASK 0xffff
  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. */
  55. struct 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. u32 thermtrip_enable_mask;
  63. u32 thermtrip_any_en_mask;
  64. u32 thermtrip_threshold_mask;
  65. u16 thermctl_lvl0_offset;
  66. u32 thermctl_lvl0_up_thresh_mask;
  67. u32 thermctl_lvl0_dn_thresh_mask;
  68. };
  69. struct tegra_tsensor_configuration {
  70. u32 tall, tiddq_en, ten_count, pdiv, pdiv_ate, tsample, tsample_ate;
  71. };
  72. struct tegra_tsensor {
  73. const char *name;
  74. const u32 base;
  75. const struct tegra_tsensor_configuration *config;
  76. const u32 calib_fuse_offset;
  77. /*
  78. * Correction values used to modify values read from
  79. * calibration fuses
  80. */
  81. const s32 fuse_corr_alpha, fuse_corr_beta;
  82. const struct tegra_tsensor_group *group;
  83. };
  84. struct tegra_soctherm_fuse {
  85. u32 fuse_base_cp_mask, fuse_base_cp_shift;
  86. u32 fuse_base_ft_mask, fuse_base_ft_shift;
  87. u32 fuse_shift_ft_mask, fuse_shift_ft_shift;
  88. u32 fuse_spare_realignment;
  89. };
  90. struct tsensor_shared_calib {
  91. u32 base_cp, base_ft;
  92. u32 actual_temp_cp, actual_temp_ft;
  93. };
  94. struct tegra_soctherm_soc {
  95. const struct tegra_tsensor *tsensors;
  96. const unsigned int num_tsensors;
  97. const struct tegra_tsensor_group **ttgs;
  98. const unsigned int num_ttgs;
  99. const struct tegra_soctherm_fuse *tfuse;
  100. const int thresh_grain;
  101. const unsigned int bptt;
  102. const bool use_ccroc;
  103. };
  104. int tegra_calc_shared_calib(const struct tegra_soctherm_fuse *tfuse,
  105. struct tsensor_shared_calib *shared);
  106. int tegra_calc_tsensor_calib(const struct tegra_tsensor *sensor,
  107. const struct tsensor_shared_calib *shared,
  108. u32 *calib);
  109. #ifdef CONFIG_ARCH_TEGRA_124_SOC
  110. extern const struct tegra_soctherm_soc tegra124_soctherm;
  111. #endif
  112. #ifdef CONFIG_ARCH_TEGRA_132_SOC
  113. extern const struct tegra_soctherm_soc tegra132_soctherm;
  114. #endif
  115. #ifdef CONFIG_ARCH_TEGRA_210_SOC
  116. extern const struct tegra_soctherm_soc tegra210_soctherm;
  117. #endif
  118. #endif