Skip to content

Commit 1c0acf5

Browse files
authored
reprogram the GPU PCB sn if it was loaded and valid (#866)
Signed-off-by: Kieran Levin <[email protected]>
1 parent 7f7d43b commit 1c0acf5

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

zephyr/program/lotus/include/lotus/gpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ int get_gpu_gpio(enum gpu_gpio_purpose gpu_gpio);
2626

2727
int get_gpu_latch(void);
2828

29+
bool gpu_fan_board_present(void);
30+
2931
#endif /* __BOARD_GPU_H__ */

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ bool gpu_module_fault(void)
5151
return module_fault;
5252
}
5353

54+
bool gpu_fan_board_present(void)
55+
{
56+
return fan_present;
57+
}
58+
5459
void update_gpu_ac_power_state(void)
5560
{
5661
int level = extpower_is_present();

zephyr/program/lotus/lotus/src/gpu_configuration.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -979,18 +979,25 @@ static enum ec_status get_gpu_serial(struct host_cmd_handler_args *args)
979979
{
980980
const struct ec_params_gpu_serial *p = args->params;
981981
struct ec_response_get_gpu_serial *r = args->response;
982-
if (!gpu_cfg_descriptor_valid) {
983-
return EC_RES_UNAVAILABLE;
984-
}
985982

986-
r->idx = p->idx;
987-
r->valid = true;
988-
if (p->idx == 0) {
989-
memcpy(r->serial, gpu_descriptor.serial, sizeof(r->serial));
990-
} else if (p->idx < GPU_SUBSYS_MAX){
991-
memcpy(r->serial, gpu_subsys_serials[p->idx-1], sizeof(r->serial));
983+
memset(r->serial, 0x00, GPU_SERIAL_LEN);
984+
if (gpu_cfg_descriptor_valid) {
985+
r->idx = p->idx;
986+
r->valid = true;
987+
if (p->idx == 0) {
988+
memcpy(r->serial, gpu_descriptor.serial, sizeof(r->serial));
989+
} else if (p->idx < GPU_SUBSYS_MAX) {
990+
memcpy(r->serial, gpu_subsys_serials[p->idx-1], sizeof(r->serial));
991+
}
992+
} else if (gpu_fan_board_present()) {
993+
r->idx = 0;
994+
r->valid = true;
995+
memcpy(r->serial, "UMA FAN", sizeof("UMA FAN"));
996+
} else {
997+
r->idx = 0;
998+
r->valid = true;
999+
memcpy(r->serial, "Not detected", sizeof("Not detected"));
9921000
}
993-
9941001
args->response_size = sizeof(*r);
9951002

9961003
return EC_RES_SUCCESS;
@@ -1040,7 +1047,6 @@ static int program_eeprom(const char * serial, struct gpu_cfg_descriptor * descr
10401047
k_msleep(5);
10411048
rv = i2c_read8(I2C_PORT_GPU0, 0x50, 0x00, &d);
10421049
} while(++i < 32 && rv != EC_SUCCESS);
1043-
10441050
}
10451051
return rv;
10461052
}
@@ -1052,14 +1058,17 @@ static enum ec_status hc_program_gpu_eeprom(struct host_cmd_handler_args *args)
10521058

10531059
if (p->magic == 0x0D) {
10541060
r->valid = 1;
1061+
/* copy PCBA serial to output struct */
1062+
if (gpu_cfg_descriptor_valid) {
1063+
memcpy(gpu_cfg.pcba_serial.serial, gpu_subsys_serials[0], GPU_SERIAL_LEN);
1064+
}
10551065
program_eeprom(p->serial, (void *)&gpu_cfg, sizeof(gpu_cfg));
10561066
} else if (p->magic == 0x55) {
10571067
r->valid = 1;
10581068
program_eeprom(p->serial, (void *)&ssd_cfg, sizeof(ssd_cfg));
10591069
} else {
10601070
r->valid = 0;
10611071
}
1062-
10631072

10641073
args->response_size = sizeof(*r);
10651074

0 commit comments

Comments
 (0)