Skip to content

Commit 52599a3

Browse files
committed
lotus: Add host command to get Expansion Bay Status
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 6b9fcb4 commit 52599a3

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

zephyr/program/lotus/include/board_host_command.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,26 @@ struct ec_response_uefi_app_btn_status {
312312
uint8_t status;
313313
} __ec_align1;
314314

315+
/*****************************************************************************/
316+
/*
317+
* Check state of the Expansion Bay
318+
*/
319+
#define EC_CMD_EXPANSION_BAY_STATUS 0x3E1B
320+
321+
enum ec_expansion_bay_states {
322+
/* Valid module present and switch closed */
323+
MODULE_ENABLED = BIT(0),
324+
/* Board ID invalid */
325+
MODULE_FAULT = BIT(1),
326+
/* Hatch switch open/closed status */
327+
HATCH_SWITCH_CLOSED = BIT(2),
328+
};
329+
330+
struct ec_response_expansion_bay_status {
331+
/* Check ec_expansion_bay_states */
332+
uint8_t state;
333+
uint8_t board_id_0;
334+
uint8_t board_id_1;
335+
} __ec_align1;
336+
315337
#endif /* __BOARD_HOST_COMMAND_H */

zephyr/program/lotus/lotus/src/gpu.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "gpu.h"
1616
#include "board_adc.h"
1717
#include "board_function.h"
18+
#include "board_host_command.h"
1819
#include "console.h"
1920
#include "driver/temp_sensor/f75303.h"
2021
#include "extpower.h"
@@ -39,6 +40,9 @@ LOG_MODULE_REGISTER(gpu, LOG_LEVEL_DBG);
3940

4041
static int module_present;
4142
static int module_fault;
43+
static int gpu_id_0;
44+
static int gpu_id_1;
45+
static int switch_status;
4246

4347
bool gpu_present(void)
4448
{
@@ -84,9 +88,9 @@ DECLARE_HOOK(HOOK_INIT, update_thermal_configuration, HOOK_PRIO_DEFAULT + 2);
8488

8589
void check_gpu_module(void)
8690
{
87-
int gpu_id_0 = get_hardware_id(ADC_GPU_BOARD_ID_0);
88-
int gpu_id_1 = get_hardware_id(ADC_GPU_BOARD_ID_1);
89-
int switch_status = 0;
91+
gpu_id_0 = get_hardware_id(ADC_GPU_BOARD_ID_0);
92+
gpu_id_1 = get_hardware_id(ADC_GPU_BOARD_ID_1);
93+
switch_status = 0;
9094

9195
if (board_get_version() >= BOARD_VERSION_7) {
9296
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_beam_open));
@@ -308,3 +312,27 @@ void gpu_power_enable_handler(void)
308312
hook_call_deferred(&gpu_board_f75303_initial_data, 500 * MSEC);
309313

310314
}
315+
316+
static enum ec_status host_command_expansion_bay_status(struct host_cmd_handler_args *args)
317+
{
318+
struct ec_response_expansion_bay_status *r = args->response;
319+
320+
r->state = 0;
321+
if (module_present) {
322+
r->state |= MODULE_ENABLED;
323+
}
324+
if (module_fault) {
325+
r->state |= MODULE_FAULT;
326+
}
327+
if (switch_status) {
328+
r->state |= HATCH_SWITCH_CLOSED;
329+
}
330+
r->board_id_0 = gpu_id_0;
331+
r->board_id_1 = gpu_id_1;
332+
333+
args->response_size = sizeof(*r);
334+
335+
return EC_RES_SUCCESS;
336+
}
337+
DECLARE_HOST_COMMAND(EC_CMD_EXPANSION_BAY_STATUS, host_command_expansion_bay_status,
338+
EC_VER_MASK(0));

0 commit comments

Comments
 (0)