Skip to content

Commit 2e516b5

Browse files
committed
fwk: Add host command to get hw diag
I need it to check if the fan is present or not. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 52599a3 commit 2e516b5

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

zephyr/program/lotus/include/board_host_command.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,16 @@ struct ec_response_expansion_bay_status {
334334
uint8_t board_id_1;
335335
} __ec_align1;
336336

337+
/*****************************************************************************/
338+
/*
339+
* Get hardware diagnostics
340+
*/
341+
#define EC_CMD_GET_HW_DIAG 0x3E1C
342+
343+
/* See enum diagnostics_device_idx */
344+
struct ec_response_get_hw_diag {
345+
uint32_t hw_diagnostics;
346+
uint8_t bios_complete;
347+
} __ec_align1;
348+
337349
#endif /* __BOARD_HOST_COMMAND_H */

zephyr/program/lotus/include/diagnostics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ enum diagnostics_device_idx {
4848
*/
4949
void set_diagnostic(enum diagnostics_device_idx idx, bool error);
5050

51+
uint32_t get_hw_diagnostic(void);
52+
uint8_t is_bios_complete(void);
53+
5154
void set_bios_diagnostic(uint8_t code);
5255

5356
void reset_diagnostics(void);

zephyr/program/lotus/lotus/src/project_diagnostics.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ void check_device_deferred(void)
4343
if (!(fan_get_rpm_actual(1) > 100) && !get_standalone_mode())
4444
set_diagnostic(DIAGNOSTICS_NO_LEFT_FAN, true);
4545

46+
/* TODO: Add something to know whether check has run or not */
47+
4648
/* Exit the duty mode and let thermal to control the fan */
4749
dptf_set_fan_duty_target(-1);
4850

zephyr/program/lotus/src/board_host_command.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ static enum ec_status cmd_diagnosis(struct host_cmd_handler_args *args)
226226
DECLARE_HOST_COMMAND(EC_CMD_DIAGNOSIS, cmd_diagnosis,
227227
EC_VER_MASK(0));
228228

229+
static enum ec_status cmd_get_hw_diag(struct host_cmd_handler_args *args)
230+
{
231+
struct ec_response_get_hw_diag *r = args->response;
232+
233+
r->hw_diagnostics = get_hw_diagnostic();
234+
r->bios_complete = is_bios_complete();
235+
236+
args->response_size = sizeof(*r);
237+
238+
return EC_RES_SUCCESS;
239+
}
240+
DECLARE_HOST_COMMAND(EC_CMD_GET_HW_DIAG, cmd_get_hw_diag,
241+
EC_VER_MASK(0));
242+
229243
#ifdef CONFIG_BOARD_AZALEA
230244
static enum ec_status update_keyboard_matrix(struct host_cmd_handler_args *args)
231245
{

zephyr/program/lotus/src/diagnostics.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ uint32_t diagnostics_ctr;
3535
uint32_t bios_code;
3636

3737
uint8_t bios_complete;
38-
uint8_t fan_seen;
38+
uint8_t fan_seen; /* TODO: Unused so far */
3939
uint8_t run_diagnostics;
4040

4141
int standalone_mode;
@@ -157,3 +157,13 @@ static void diagnostics_check(void)
157157

158158
}
159159
DECLARE_HOOK(HOOK_CHIPSET_RESUME, diagnostics_check, HOOK_PRIO_DEFAULT);
160+
161+
uint32_t get_hw_diagnostic(void)
162+
{
163+
return hw_diagnostics;
164+
}
165+
166+
uint8_t is_bios_complete(void)
167+
{
168+
return bios_complete;
169+
}

0 commit comments

Comments
 (0)