diff --git a/kestrel/src/kestrel.c b/kestrel/src/kestrel.c index 76eb362d750f6f9b70567c6981b9a66e2727d0f0..afacfdb94b4f11ba92feda8802e9f295b965532d 100644 --- a/kestrel/src/kestrel.c +++ b/kestrel/src/kestrel.c @@ -385,6 +385,27 @@ static void display_character(char character, int dp) gpio3_out_write(~(value | ((dp == 0) ? 0x0000 : 0x4000))); } +static void host_power_status_changed(void) +{ + uint32_t dword; + int power_led_on = 0; + + // Set power LED based on host status + if (host_power_status == HOST_POWER_STATUS_OFFLINE) + { + power_led_on = 0; + } + else { + power_led_on = 1; + } + + // Write power LED status to GPIO register + dword = gpio3_out_read(); + dword &= ~(0x1 << 15); + dword |= (power_led_on & 0x1) << 15; + gpio3_out_write(dword); +} + static void set_led_bank_display(uint8_t bitfield) { gpio1_out_write(~bitfield); @@ -1811,6 +1832,7 @@ static int process_interrupts_stage2(void) if (post_code == 0xfefe) { host_power_status = HOST_POWER_STATUS_RUNNING; + host_power_status_changed(); display_character('0' + 2 + host_power_status, 0); // STATUS CODE } @@ -2267,6 +2289,7 @@ void power_off_chassis(int has_lock) } host_power_status = HOST_POWER_STATUS_POWERING_OFF; + host_power_status_changed(); display_character('0' + 2 + host_power_status, 0); // STATUS CODE // Disable PMBUS @@ -2281,6 +2304,7 @@ void power_off_chassis(int has_lock) run_post_shutdown_bmc_peripheral_teardown(); host_power_status = HOST_POWER_STATUS_OFFLINE; + host_power_status_changed(); display_character('0' + 2 + host_power_status, 0); // STATUS CODE if (!has_lock) { @@ -2304,6 +2328,7 @@ int power_on_chassis(int has_lock) } host_power_status = HOST_POWER_STATUS_POWERING_ON; + host_power_status_changed(); display_character('0' + 2 + host_power_status, 0); // STATUS CODE // Verify communication with platform control FPGA @@ -2311,6 +2336,7 @@ int power_on_chassis(int has_lock) if (platform_fpga_identifier[0] == 0xff) { host_power_status = HOST_POWER_STATUS_OFFLINE; + host_power_status_changed(); display_character('0' + 2 + host_power_status, 0); // STATUS CODE if (!has_lock) { k_sem_give(&chassis_control_semaphore); @@ -2324,6 +2350,7 @@ int power_on_chassis(int has_lock) (platform_fpga_identifier[3] != 0x20)) { host_power_status = HOST_POWER_STATUS_OFFLINE; + host_power_status_changed(); display_character('0' + 2 + host_power_status, 0); // STATUS CODE if (!has_lock) { k_sem_give(&chassis_control_semaphore); @@ -2400,6 +2427,7 @@ int power_on_chassis(int has_lock) } host_power_status = HOST_POWER_STATUS_IPLING; + host_power_status_changed(); display_character('0' + 2 + host_power_status, 0); // STATUS CODE if (!has_lock) {