Skip to content

Commit c1e834b

Browse files
committed
fwk: Add EC_CMD_READ_BOARDID
Add a host command to read board ID. BUG=https://app.clickup.com/t/86ev8c9qb BUG=https://app.clickup.com/t/86ev63cvg BUG=So that BIOS and OS can detect different touchpads and audio boards TEST=Send host command with channel 0 (mainboard) and make sure it reports something between 0 and 14 (inclusive) BRANCH=fwk-main Signed-off-by: Daniel Schaefer <dhs@frame.work> (cherry picked from commit 290e7f609cdc8a619d93b41bb9fadfe15069dd18)
1 parent 9010bdf commit c1e834b

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

zephyr/program/framework/include/board_host_command.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,4 +573,53 @@ enum battery_extender_cmd {
573573
BATT_EXTENDER_READ_CMD,
574574
};
575575

576+
/*****************************************************************************/
577+
/*
578+
* Measure a Board ID to see what's currently populated
579+
*
580+
* Similar to EC_CMD_GET_CROS_BOARD_INFO. But that is only measured once,
581+
* not for hotpluggable components.
582+
* We use the board ID for hotpluggable components like the inputmodules,
583+
* touchpad, powerbutton board and audio board.
584+
* To detect whether these are plugged in and which version of the is plugged in,
585+
* the board ID needs to be measured at run-time.
586+
*
587+
* For the Framework 16 inputmodules there is a dedicated command, which abstracts the logic,
588+
* because there is also a mux involed: EC_CMD_CHECK_DECK_STATE
589+
*
590+
* For Framework 13 we have multiple versions of the touchpad and speakers (audio board)
591+
* that BIOS/OS need to distinguish through this host command.
592+
*
593+
* Compared to EC_CMD_ADC_READ this host command adds the board specific logic
594+
* to convert the voltage level into the board ID index.
595+
*/
596+
#define EC_CMD_READ_BOARDID 0x3E26
597+
598+
enum ec_board_id_type {
599+
/* Mainboard - any system */
600+
HC_BOARD_ID_MAINBOARD = 0,
601+
/* Power button board - Framework 12 */
602+
HC_BOARD_ID_POWERBUTTON_BOARD = 1,
603+
/* Power button board - Framework 12, 13, 16 */
604+
HC_BOARD_ID_TOUCHPAD = 2,
605+
/* Power button board - Framework 12, 13 */
606+
HC_BOARD_ID_AUDIO_BOARD = 3,
607+
/* dGPU board - Framework 16 */
608+
HC_BOARD_ID_DGPU0 = 4,
609+
/* dGPU board - Framework 16 */
610+
HC_BOARD_ID_DGPU1 = 5,
611+
};
612+
613+
struct ec_params_read_boardid {
614+
/* See enum ec_board_id_type */
615+
uint8_t board_id_type;
616+
} __ec_align1;
617+
618+
struct ec_response_read_boardid {
619+
/* -1 if unknown (some issue reading it)
620+
* Otherwise 0-15
621+
*/
622+
int8_t board_id;
623+
} __ec_align1;
624+
576625
#endif /* __BOARD_HOST_COMMAND_H */

zephyr/program/framework/src/adc.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
#include "adc.h"
99
#include "board_adc.h"
10+
#include "board_host_command.h"
1011
#include "console.h"
12+
#include "ec_commands.h"
1113
#include "system.h"
1214
#include "hooks.h"
1315

@@ -99,3 +101,45 @@ __override int board_get_version(void)
99101
return version;
100102
}
101103

104+
/* Host command */
105+
static enum ec_status hc_read_boardid(struct host_cmd_handler_args *args)
106+
{
107+
const struct ec_params_read_boardid *p = args->params;
108+
struct ec_response_read_boardid *r = args->response;
109+
110+
switch (p->board_id_type) {
111+
case HC_BOARD_ID_MAINBOARD:
112+
r->board_id = get_hardware_id(ADC_MAIN_BOARD_ID);
113+
break;
114+
#ifdef ADC_POWER_BUTTON_BOARD_ID
115+
case HC_BOARD_ID_POWERBUTTON_BOARD:
116+
r->board_id = get_hardware_id(ADC_POWER_BUTTON_BOARD_ID);
117+
break;
118+
#endif
119+
#ifdef ADC_TOUCHPAD_ID
120+
case HC_BOARD_ID_TOUCHPAD:
121+
r->board_id = get_hardware_id(ADC_TOUCHPAD_ID);
122+
break;
123+
#endif
124+
#ifdef ADC_AUDIO_ID
125+
case HC_BOARD_ID_AUDIO_BOARD:
126+
r->board_id = get_hardware_id(ADC_AUDIO_ID);
127+
break;
128+
#endif
129+
#ifdef CONFIG_PLATFORM_EC_FRAMEWORK_LAPTOP_16
130+
case HC_BOARD_ID_DGPU0:
131+
r->board_id = get_hardware_id(ADC_GPU_BOARD_ID_0);
132+
break;
133+
case HC_BOARD_ID_DGPU1:
134+
r->board_id = get_hardware_id(ADC_GPU_BOARD_ID_1);
135+
break;
136+
#endif
137+
default:
138+
return EC_ERROR_INVAL;
139+
}
140+
141+
args->response_size = sizeof(*r);
142+
143+
return EC_RES_SUCCESS;
144+
}
145+
DECLARE_HOST_COMMAND(EC_CMD_READ_BOARDID, hc_read_boardid, EC_VER_MASK(0));

0 commit comments

Comments
 (0)