Debian Codegraph @

src/soc/mediatek/mt8196/thermal_sram.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2
3 #include <arch/cache.h>
4 #include <assert.h>
5 #include <device/mmio.h>
6 #include <soc/thermal.h>
7
8 /* SRAM for Thermal */
9 #define THERMAL_REBOOT_TEMP_SRAM_OFFSET 0x39C
10 #define THERMAL_REBOOT_MSR_SRAM_OFFSET 0x340
11 #define THERMAL_REBOOT_MSR_SRAM_LEN (6 * 4)
12
13 /* SRAM for GPU Thermal state */
14 #define GPU_THERMAL_STAT_SRAM_BASE ((uintptr_t)_sram + 0x00017C00)
15 #define GPU_THERMAL_STAT_SRAM_LEN 0x400
16
17 static void thermal_gpu_stat_cls_sram(void)
18 {
19 int i = 0;
20 const uint32_t pattern = 0xFFFFFFFF;
21 uint32_t *buff = (uint32_t *)GPU_THERMAL_STAT_SRAM_BASE;
22 for (i = 0; i < GPU_THERMAL_STAT_SRAM_LEN / sizeof(*buff); i++) {
23 *buff = pattern;
24 buff++;
25 }
26 dcache_clean_invalidate_by_mva((void *)GPU_THERMAL_STAT_SRAM_BASE,
27 GPU_THERMAL_STAT_SRAM_LEN);
28 }
29
30 void thermal_sram_init(void)
31 {
32 thermal_cls_sram();
33 thermal_stat_cls_sram();
34 thermal_gpu_stat_cls_sram();
35 }
36
37 void thermal_write_reboot_temp_sram(uint32_t value)
38 {
39 write32(THERMAL_SRAM_BASE + THERMAL_REBOOT_TEMP_SRAM_OFFSET, value);
40 }
41
42 void thermal_write_reboot_msr_sram(unsigned int idx, uint32_t value)
43 {
44 unsigned int offset = 0;
45
46 assert((idx * 4) < THERMAL_REBOOT_MSR_SRAM_LEN);
47 offset = THERMAL_REBOOT_MSR_SRAM_OFFSET + idx * 4;
48 write32(THERMAL_SRAM_BASE + offset, value);
49 }