Skip to content

Commit e892a4d

Browse files
LeoCX-TsaiJohnAZoidberg
authored andcommitted
hx30: implement intel dtt support
reference PR#955 Signed-off-by: LeoCX_Tsai <LeoCX_Tsai@compal.com>
1 parent 6bac8fc commit e892a4d

7 files changed

Lines changed: 87 additions & 0 deletions

File tree

board/hx30/board.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@
363363
#define EC_MEMMAP_ER1_BATT_MANUF_DAY 0x44 /* Manufacturer date - day */
364364
#define EC_MEMMAP_ER1_BATT_MANUF_MONTH 0x45 /* Manufacturer date - month */
365365
#define EC_MEMMAP_ER1_BATT_MANUF_YEAR 0x46 /* Manufacturer date - year */
366+
#define EC_CUSTOMIZED_MEMMAP_DTT_TEMP 0x60
367+
366368

367369
#define EC_BATT_FLAG_FULL BIT(0) /* Full Charged */
368370
#define EC_BATT_TYPE BIT(1) /* (0: NiMh,1: LION) */
@@ -463,6 +465,12 @@
463465
*/
464466
#define CONFIG_FAN_VIRTUAL_TEMP
465467

468+
/*
469+
* Enable more temp memmap for intel DTT
470+
*/
471+
#define CONFIG_DTT_SUPPORT
472+
473+
#define CONFIG_CUSTOMIZED_DESIGN
466474

467475
/* LED signals */
468476
/*

board/hx30/build.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ board-$(CONFIG_POWER_BUTTON_CUSTOM) += power_button_x86.o
2525
board-$(CONFIG_PECI) += peci_customization.o peci_over_espi.o
2626
board-$(HAS_TASK_HOSTCMD) += host_command_customization.o
2727
board-$(CONFIG_I2C_HID_MEDIAKEYS) += i2c_hid_mediakeys.o
28+
board-$(CONFIG_DTT_SUPPORT) += temperature.o

board/hx30/temperature.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
}

common/temp_sensor.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ static void update_mapped_memory(void)
5151
break;
5252
case EC_SUCCESS:
5353
*mptr = t - EC_TEMP_SENSOR_OFFSET;
54+
#ifdef CONFIG_CUSTOMIZED_DESIGN
55+
board_update_temperature_mk(i);
56+
#endif
5457
break;
5558
default:
5659
*mptr = EC_TEMP_SENSOR_ERROR;

common/thermal.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
/*****************************************************************************/
2727
/* EC-specific thermal controls */
2828

29+
#ifdef CONFIG_CUSTOMIZED_DESIGN
30+
31+
__overridable void board_update_temperature_mk(enum temp_sensor_id id)
32+
{
33+
}
34+
35+
#endif
36+
2937
test_mockable_static void smi_sensor_failure_warning(void)
3038
{
3139
CPRINTS("can't read any temp sensors!");

include/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
#define K_TO_C(temp_c) ((temp_c) - 273)
201201
#define CELSIUS_TO_DECI_KELVIN(temp_c) ((temp_c) * 10 + 2731)
202202
#define MILLI_CELSIUS_TO_MILLI_KELVIN(temp_mc) ((temp_mc) + 273150)
203+
#define KELVIN_TO_MILLI_KELVIN(temp_k) ((temp_k) * 1000)
203204
#define DECI_KELVIN_TO_CELSIUS(temp_dk) ((temp_dk - 2731) / 10)
204205
#define MILLI_KELVIN_TO_KELVIN(temp_mk) (round_divide((temp_mk), 1000))
205206

include/temp_sensor.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,12 @@ extern const struct temp_sensor_t temp_sensors[];
5656
* @return EC_SUCCESS, or non-zero if error.
5757
*/
5858
int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr);
59+
#ifdef CONFIG_CUSTOMIZED_DESIGN
5960

61+
/**
62+
* Update the mk unit namespace for intel DTT feature
63+
*/
64+
__override_proto void board_update_temperature_mk(enum temp_sensor_id id);
65+
66+
#endif
6067
#endif /* __CROS_EC_TEMP_SENSOR_H */

0 commit comments

Comments
 (0)