|
| 1 | +/* Copyright 2024 The ChromiumOS Authors |
| 2 | + * Use of this source code is governed by a BSD-style license that can be |
| 3 | + * found in the LICENSE file. |
| 4 | + */ |
| 5 | + |
| 6 | + |
| 7 | +#include "config.h" |
| 8 | +#include "chipset.h" |
| 9 | +#include "charge_state.h" |
| 10 | +#include "driver/temp_sensor/f75303.h" |
| 11 | +#include "driver/temp_sensor/f75397.h" |
| 12 | +#include "temp_sensor.h" |
| 13 | +#include "console.h" |
| 14 | +#include "peci.h" |
| 15 | + |
| 16 | +/* update the mk temperature to offset EC_MEMMAP_CUSTOM_TEMP */ |
| 17 | +__override void board_update_temperature_mk(enum temp_sensor_id id) |
| 18 | +{ |
| 19 | + int temp_mk_ptr = KELVIN_TO_MILLI_KELVIN(C_TO_K(0)) / 100; |
| 20 | + const struct batt_params *batt = charger_current_battery_params(); |
| 21 | + |
| 22 | + switch (id) { |
| 23 | + case 0: |
| 24 | + /* QN3, local-f75397 */ |
| 25 | + f75397_get_val_mk(TEMP_SENSOR_LOCAL, |
| 26 | + &temp_mk_ptr); |
| 27 | + temp_mk_ptr = temp_mk_ptr / 100; |
| 28 | + break; |
| 29 | + case 1: |
| 30 | + f75303_get_val_mk(TEMP_SENSOR_CPU, |
| 31 | + &temp_mk_ptr); |
| 32 | + temp_mk_ptr = temp_mk_ptr / 100; |
| 33 | + /* QN2, cpu-f75303 */ |
| 34 | + break; |
| 35 | + case 2: |
| 36 | + /* battery temp */ |
| 37 | + temp_mk_ptr = batt->temperature; |
| 38 | + break; |
| 39 | + case 3: |
| 40 | + /* QN1, ddr_f75303 */ |
| 41 | + f75303_get_val_mk(TEMP_SENSOR_DDR, |
| 42 | + &temp_mk_ptr); |
| 43 | + temp_mk_ptr = temp_mk_ptr / 100; |
| 44 | + break; |
| 45 | + case 4: |
| 46 | + /* PECI temp */ |
| 47 | + peci_temp_sensor_get_val(0, &temp_mk_ptr); |
| 48 | + temp_mk_ptr = temp_mk_ptr * 10; |
| 49 | + break; |
| 50 | + default: |
| 51 | + break; |
| 52 | + } |
| 53 | + |
| 54 | + *host_get_memmap(EC_CUSTOMIZED_MEMMAP_DTT_TEMP + id * 2) = |
| 55 | + (uint8_t)(temp_mk_ptr & 0xFF); |
| 56 | + |
| 57 | + *host_get_memmap(EC_CUSTOMIZED_MEMMAP_DTT_TEMP + id * 2 + 1) = |
| 58 | + (uint8_t)((temp_mk_ptr >> 8) & 0xFF); |
| 59 | +} |
0 commit comments