Skip to content

Commit 993b916

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 ce5c251 commit 993b916

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
@@ -563,4 +563,53 @@ enum battery_extender_cmd {
563563
BATT_EXTENDER_READ_CMD,
564564
};
565565

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

@@ -96,3 +98,45 @@ __override int board_get_version(void)
9698
return version;
9799
}
98100

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

0 commit comments

Comments
 (0)