summaryrefslogtreecommitdiff
path: root/driver/amd_stt.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /driver/amd_stt.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14333.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'driver/amd_stt.c')
-rw-r--r--driver/amd_stt.c143
1 files changed, 0 insertions, 143 deletions
diff --git a/driver/amd_stt.c b/driver/amd_stt.c
deleted file mode 100644
index 90fd82523b..0000000000
--- a/driver/amd_stt.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "amd_stt.h"
-#include "common.h"
-#include "chipset.h"
-#include "console.h"
-#include "driver/sb_rmi.h"
-#include "hooks.h"
-#include "math_util.h"
-#include "temp_sensor.h"
-#include "util.h"
-
-/* Debug flag can be toggled with console command: stt debug */
-static bool amd_stt_debug;
-
-/* Console output macros */
-#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
-#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args)
-
-static const char * const amd_stt_sensor_name[] = {
- [AMD_STT_PCB_SENSOR_APU] = "APU",
- [AMD_STT_PCB_SENSOR_REMOTE] = "Ambient",
- [AMD_STT_PCB_SENSOR_GPU] = "GPU",
-};
-
-/**
- * Write temperature sensor value to AP via SB-RMI
- *
- * sensor:
- * AMD_STT_PCB_SENSOR_APU
- * AMD_STT_PCB_SENSOR_REMOTE
- * AMD_STT_PCB_SENSOR_GPU
- *
- * temp_mk:
- * Temperature in degrees milli kelvin
- */
-static int write_stt_sensor_val(enum amd_stt_pcb_sensor sensor, int temp_mk)
-{
- uint32_t msgIn = 0;
- uint32_t msgOut;
- int temp_mc;
- int temp_c_fp_msb;
- int temp_c_fp_lsb;
-
- temp_mc = MILLI_KELVIN_TO_MILLI_CELSIUS(temp_mk);
-
- if (amd_stt_debug)
- CPRINTS("STT: %s = %d.%d °C", amd_stt_sensor_name[sensor],
- temp_mc / 1000, temp_mc % 1000);
-
- /* Divide by 1000 to get MSB of fixed point temp */
- temp_c_fp_msb = temp_mc / 1000;
- /* Modulus 1000 and multiply by 256/1000 to get LSB of fixed point*/
- temp_c_fp_lsb = ((temp_mc % 1000) << 8) / 1000;
-
- /*
- * [15:0]: temperature as signed integer with 8 fractional bits.
- * [23:16]: sensor index
- * [31:24]: unused
- */
- msgIn |= (temp_c_fp_lsb & 0xff);
- msgIn |= (temp_c_fp_msb & 0xff) << 8;
- msgIn |= (sensor & 0xff) << 16;
- return sb_rmi_mailbox_xfer(SB_RMI_WRITE_STT_SENSOR_CMD, msgIn, &msgOut);
-}
-
-static void amd_stt_handler(void)
-{
- int rv;
- int soc_temp_mk;
- int ambient_temp_mk;
-
- /* STT interface is only active in S0 */
- if (!chipset_in_state(CHIPSET_STATE_ON))
- return;
-
- /*
- * TODO(b/192391025): Replace with temp_sensor_read_mk(TEMP_SENSOR_SOC)
- */
- rv = board_get_soc_temp_mk(&soc_temp_mk);
- if (rv) {
- CPRINTS("STT: Failed to read SOC temp rv:%d", rv);
- return;
- }
-
- rv = write_stt_sensor_val(AMD_STT_PCB_SENSOR_APU, soc_temp_mk);
- if (rv) {
- CPRINTS("STT: Failed to write SOC temp rv:%d", rv);
- return;
- }
-
- /*
- * TODO(b/192391025): Replace with
- * temp_sensor_read_mk(TEMP_SENSOR_AMBIENT)
- */
- rv = board_get_ambient_temp_mk(&ambient_temp_mk);
- if (rv) {
- CPRINTS("STT: Failed to read AMBIENT temp rv:%d", rv);
- return;
- }
-
- rv = write_stt_sensor_val(AMD_STT_PCB_SENSOR_REMOTE, ambient_temp_mk);
- if (rv) {
- CPRINTS("STT: Failed to write AMBIENT temp rv:%d", rv);
- return;
- }
-}
-DECLARE_HOOK(HOOK_SECOND, amd_stt_handler, HOOK_PRIO_TEMP_SENSOR+1);
-
-static int command_stt(int argc, char **argv)
-{
- int sensor_id;
- int temp;
-
- if (argc < 2)
- return EC_ERROR_PARAM1;
- else if (!strcasecmp(argv[1], "debug")) {
- amd_stt_debug = !amd_stt_debug;
- return EC_SUCCESS;
- } else if (argc != 3)
- return EC_ERROR_PARAM2;
- else if (!strcasecmp(argv[1],
- amd_stt_sensor_name[AMD_STT_PCB_SENSOR_APU]))
- sensor_id = AMD_STT_PCB_SENSOR_APU;
- else if (!strcasecmp(argv[1],
- amd_stt_sensor_name[AMD_STT_PCB_SENSOR_REMOTE]))
- sensor_id = AMD_STT_PCB_SENSOR_REMOTE;
- else if (!strcasecmp(argv[1],
- amd_stt_sensor_name[AMD_STT_PCB_SENSOR_GPU]))
- sensor_id = AMD_STT_PCB_SENSOR_GPU;
- else
- return EC_ERROR_PARAM2;
-
- temp = atoi(argv[2]);
-
- return write_stt_sensor_val(sensor_id, temp);
-}
-DECLARE_CONSOLE_COMMAND(stt, command_stt,
- "<apu|ambient|gpu|debug> <temp in mK>",
- "Write an STT mK temperature to AP");