Set host power LED based on chassis power status

parent 49908f27
...@@ -385,6 +385,27 @@ static void display_character(char character, int dp) ...@@ -385,6 +385,27 @@ static void display_character(char character, int dp)
gpio3_out_write(~(value | ((dp == 0) ? 0x0000 : 0x4000))); 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) static void set_led_bank_display(uint8_t bitfield)
{ {
gpio1_out_write(~bitfield); gpio1_out_write(~bitfield);
...@@ -1811,6 +1832,7 @@ static int process_interrupts_stage2(void) ...@@ -1811,6 +1832,7 @@ static int process_interrupts_stage2(void)
if (post_code == 0xfefe) if (post_code == 0xfefe)
{ {
host_power_status = HOST_POWER_STATUS_RUNNING; host_power_status = HOST_POWER_STATUS_RUNNING;
host_power_status_changed();
display_character('0' + 2 + host_power_status, 0); // STATUS CODE display_character('0' + 2 + host_power_status, 0); // STATUS CODE
} }
...@@ -2267,6 +2289,7 @@ void power_off_chassis(int has_lock) ...@@ -2267,6 +2289,7 @@ void power_off_chassis(int has_lock)
} }
host_power_status = HOST_POWER_STATUS_POWERING_OFF; host_power_status = HOST_POWER_STATUS_POWERING_OFF;
host_power_status_changed();
display_character('0' + 2 + host_power_status, 0); // STATUS CODE display_character('0' + 2 + host_power_status, 0); // STATUS CODE
// Disable PMBUS // Disable PMBUS
...@@ -2281,6 +2304,7 @@ void power_off_chassis(int has_lock) ...@@ -2281,6 +2304,7 @@ void power_off_chassis(int has_lock)
run_post_shutdown_bmc_peripheral_teardown(); run_post_shutdown_bmc_peripheral_teardown();
host_power_status = HOST_POWER_STATUS_OFFLINE; host_power_status = HOST_POWER_STATUS_OFFLINE;
host_power_status_changed();
display_character('0' + 2 + host_power_status, 0); // STATUS CODE display_character('0' + 2 + host_power_status, 0); // STATUS CODE
if (!has_lock) { if (!has_lock) {
...@@ -2304,6 +2328,7 @@ int power_on_chassis(int has_lock) ...@@ -2304,6 +2328,7 @@ int power_on_chassis(int has_lock)
} }
host_power_status = HOST_POWER_STATUS_POWERING_ON; host_power_status = HOST_POWER_STATUS_POWERING_ON;
host_power_status_changed();
display_character('0' + 2 + host_power_status, 0); // STATUS CODE display_character('0' + 2 + host_power_status, 0); // STATUS CODE
// Verify communication with platform control FPGA // Verify communication with platform control FPGA
...@@ -2311,6 +2336,7 @@ int power_on_chassis(int has_lock) ...@@ -2311,6 +2336,7 @@ int power_on_chassis(int has_lock)
if (platform_fpga_identifier[0] == 0xff) if (platform_fpga_identifier[0] == 0xff)
{ {
host_power_status = HOST_POWER_STATUS_OFFLINE; host_power_status = HOST_POWER_STATUS_OFFLINE;
host_power_status_changed();
display_character('0' + 2 + host_power_status, 0); // STATUS CODE display_character('0' + 2 + host_power_status, 0); // STATUS CODE
if (!has_lock) { if (!has_lock) {
k_sem_give(&chassis_control_semaphore); k_sem_give(&chassis_control_semaphore);
...@@ -2324,6 +2350,7 @@ int power_on_chassis(int has_lock) ...@@ -2324,6 +2350,7 @@ int power_on_chassis(int has_lock)
(platform_fpga_identifier[3] != 0x20)) (platform_fpga_identifier[3] != 0x20))
{ {
host_power_status = HOST_POWER_STATUS_OFFLINE; host_power_status = HOST_POWER_STATUS_OFFLINE;
host_power_status_changed();
display_character('0' + 2 + host_power_status, 0); // STATUS CODE display_character('0' + 2 + host_power_status, 0); // STATUS CODE
if (!has_lock) { if (!has_lock) {
k_sem_give(&chassis_control_semaphore); k_sem_give(&chassis_control_semaphore);
...@@ -2400,6 +2427,7 @@ int power_on_chassis(int has_lock) ...@@ -2400,6 +2427,7 @@ int power_on_chassis(int has_lock)
} }
host_power_status = HOST_POWER_STATUS_IPLING; host_power_status = HOST_POWER_STATUS_IPLING;
host_power_status_changed();
display_character('0' + 2 + host_power_status, 0); // STATUS CODE display_character('0' + 2 + host_power_status, 0); // STATUS CODE
if (!has_lock) { if (!has_lock) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment