Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: exynos: Add support for many TRIMINFO_CTRL registers

This patch support many TRIMINFO_CTRL registers if specific Exynos SoC
has one more TRIMINFO_CTRL registers. Also this patch uses proper 'RELOAD'
shift/mask bit operation to set RELOAD feature instead of static value.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Amit Daniel Kachhap <amit.daniel@samsung.com>
Reviewed-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>

authored by

Chanwoo Choi and committed by
Eduardo Valentin
56c64da7 60e203ec

+22 -6
+1
drivers/thermal/samsung/exynos_thermal_common.h
··· 27 27 #define SENSOR_NAME_LEN 16 28 28 #define MAX_TRIP_COUNT 8 29 29 #define MAX_COOLING_DEVICE 4 30 + #define MAX_TRIMINFO_CTRL_REG 2 30 31 31 32 #define ACTIVE_INTERVAL 500 32 33 #define IDLE_INTERVAL 10000
+12 -3
drivers/thermal/samsung/exynos_tmu.c
··· 127 127 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 128 128 struct exynos_tmu_platform_data *pdata = data->pdata; 129 129 const struct exynos_tmu_registers *reg = pdata->registers; 130 - unsigned int status, trim_info = 0, con; 130 + unsigned int status, trim_info = 0, con, ctrl; 131 131 unsigned int rising_threshold = 0, falling_threshold = 0; 132 132 int ret = 0, threshold_code, i; 133 133 ··· 144 144 } 145 145 } 146 146 147 - if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) 148 - __raw_writel(1, data->base + reg->triminfo_ctrl); 147 + if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) { 148 + for (i = 0; i < reg->triminfo_ctrl_count; i++) { 149 + if (pdata->triminfo_reload[i]) { 150 + ctrl = readl(data->base + 151 + reg->triminfo_ctrl[i]); 152 + ctrl |= pdata->triminfo_reload[i]; 153 + writel(ctrl, data->base + 154 + reg->triminfo_ctrl[i]); 155 + } 156 + } 157 + } 149 158 150 159 /* Save trimming info in order to perform calibration */ 151 160 if (data->soc == SOC_ARCH_EXYNOS5440) {
+5 -2
drivers/thermal/samsung/exynos_tmu.h
··· 78 78 * slightly across different exynos SOC's. 79 79 * @triminfo_data: register containing 2 pont trimming data 80 80 * @triminfo_ctrl: trim info controller register. 81 + * @triminfo_ctrl_count: the number of trim info controller register. 81 82 * @tmu_ctrl: TMU main controller register. 82 83 * @test_mux_addr_shift: shift bits of test mux address. 83 84 * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register. ··· 113 112 struct exynos_tmu_registers { 114 113 u32 triminfo_data; 115 114 116 - u32 triminfo_ctrl; 117 - u32 triminfo_ctrl1; 115 + u32 triminfo_ctrl[MAX_TRIMINFO_CTRL_REG]; 116 + u32 triminfo_ctrl_count; 118 117 119 118 u32 tmu_ctrl; 120 119 u32 test_mux_addr_shift; ··· 201 200 * @second_point_trim: temp value of the second point trimming 202 201 * @default_temp_offset: default temperature offset in case of no trimming 203 202 * @test_mux; information if SoC supports test MUX 203 + * @triminfo_reload: reload value to read TRIMINFO register 204 204 * @cal_type: calibration type for temperature 205 205 * @freq_clip_table: Table representing frequency reduction percentage. 206 206 * @freq_tab_count: Count of the above table as frequency reduction may ··· 232 230 u8 second_point_trim; 233 231 u8 default_temp_offset; 234 232 u8 test_mux; 233 + u8 triminfo_reload[MAX_TRIMINFO_CTRL_REG]; 235 234 236 235 enum calibration_type cal_type; 237 236 enum soc_type type;
+3 -1
drivers/thermal/samsung/exynos_tmu_data.c
··· 169 169 #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250) 170 170 static const struct exynos_tmu_registers exynos4412_tmu_registers = { 171 171 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, 172 - .triminfo_ctrl = EXYNOS_TMU_TRIMINFO_CON, 172 + .triminfo_ctrl[0] = EXYNOS_TMU_TRIMINFO_CON, 173 + .triminfo_ctrl_count = 1, 173 174 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, 174 175 .test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT, 175 176 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, ··· 232 231 .temp_level = 95, \ 233 232 }, \ 234 233 .freq_tab_count = 2, \ 234 + .triminfo_reload[0] = EXYNOS_TRIMINFO_RELOAD_ENABLE, \ 235 235 .registers = &exynos4412_tmu_registers, \ 236 236 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ 237 237 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
+1
drivers/thermal/samsung/exynos_tmu_data.h
··· 51 51 #define EXYNOS_THD_TEMP_FALL 0x54 52 52 #define EXYNOS_EMUL_CON 0x80 53 53 54 + #define EXYNOS_TRIMINFO_RELOAD_ENABLE 1 54 55 #define EXYNOS_TRIMINFO_25_SHIFT 0 55 56 #define EXYNOS_TRIMINFO_85_SHIFT 8 56 57 #define EXYNOS_TMU_RISE_INT_MASK 0x111