Set platform status LEDs during IPL

parent 47e20429
......@@ -51,6 +51,7 @@ LOG_MODULE_REGISTER(kestrel_core, LOG_LEVEL_DBG);
// General RCS platform registers
#define HOST_PLATFORM_FPGA_I2C_REG_STATUS 0x7
#define HOST_PLATFORM_FPGA_I2C_REG_STA_LED 0x10
#define HOST_PLATFORM_FPGA_I2C_REG_MFR_OVR 0x33
// Host platform configuration
......@@ -386,6 +387,60 @@ static void set_led_bank_display(uint8_t bitfield)
gpio1_out_write(~bitfield);
}
static void display_post_code(uint16_t post_code)
{
uint8_t host_status_led_post_code;
uint8_t major_istep = ((post_code >> 8) & 0xff);
uint8_t led_post_code = (((post_code >> 8) & 0xf) << 4) | (post_code & 0xf);
if (post_code == 0xfefe)
{
// IPL complete!
set_led_bank_display(0);
i2c_write_register_byte((uint8_t *)I2CMASTER4_BASE, HOST_PLATFORM_FPGA_I2C_ADDRESS, HOST_PLATFORM_FPGA_I2C_REG_STA_LED, 0x00);
}
else if (post_code == 0x0)
{
// System offline
set_led_bank_display(0);
i2c_write_register_byte((uint8_t *)I2CMASTER4_BASE, HOST_PLATFORM_FPGA_I2C_ADDRESS, HOST_PLATFORM_FPGA_I2C_REG_STA_LED, 0x00);
}
else {
// Show major ISTEP on LED bank
// On Talos we only have three LEDs plus a fourth indicator modification bit, but the major ISTEPs range from 2 to 21
// Try to condense that down to something more readily displayable
switch (major_istep)
{
case 2: host_status_led_post_code = 1; break;
case 3: host_status_led_post_code = 1; break;
case 4: host_status_led_post_code = 2; break;
case 5: host_status_led_post_code = 2; break;
case 6: host_status_led_post_code = 3; break;
case 7: host_status_led_post_code = 3; break;
case 8: host_status_led_post_code = 4; break;
case 9: host_status_led_post_code = 4; break;
case 10: host_status_led_post_code = 5; break;
case 11: host_status_led_post_code = 5; break;
case 12: host_status_led_post_code = 6; break;
case 13: host_status_led_post_code = 6; break;
case 14: host_status_led_post_code = 7; break;
case 15: host_status_led_post_code = 7; break;
case 16: host_status_led_post_code = 9; break;
case 17: host_status_led_post_code = 9; break;
case 18: host_status_led_post_code = 10; break;
case 19: host_status_led_post_code = 10; break;
case 20: host_status_led_post_code = 11; break;
case 21: host_status_led_post_code = 11; break;
case 22: host_status_led_post_code = 12; break;
case 23: host_status_led_post_code = 12; break;
default: host_status_led_post_code = 0;
}
set_led_bank_display(led_post_code);
i2c_write_register_byte((uint8_t *)I2CMASTER4_BASE, HOST_PLATFORM_FPGA_I2C_ADDRESS, HOST_PLATFORM_FPGA_I2C_REG_STA_LED, 0x80 | host_status_led_post_code);
}
}
static void gpio_init(void)
{
// Set up discrete LED bank
......@@ -1748,13 +1803,11 @@ static int process_interrupts_stage2(void)
while (read_position < post_code_incoming_interrupt_transient_buffer_pos)
{
uint16_t post_code = post_code_incoming_interrupt_transient_buffer[read_position];
uint8_t led_post_code = (((post_code >> 8) & 0xf) << 4) | (post_code & 0xf);
set_led_bank_display(led_post_code);
display_post_code(post_code);
if (post_code == 0xfefe)
{
host_power_status = HOST_POWER_STATUS_RUNNING;
set_led_bank_display(0);
display_character('0' + 2 + host_power_status, 0); // STATUS CODE
}
......@@ -1874,7 +1927,7 @@ static void run_pre_ipl_bmc_peripheral_setup(void)
// Reset POST codes and display
post_code_high = 0;
post_code_low = 0;
set_led_bank_display(0x00);
display_post_code(0x0000);
// Deactivate interrupts on entering critical section
int key = irq_lock();
......@@ -2058,7 +2111,7 @@ static void run_post_shutdown_bmc_peripheral_teardown(void)
// Reset POST codes and display
post_code_high = 0;
post_code_low = 0;
set_led_bank_display(0x00);
display_post_code(0x0000);
}
static int apply_avsbus_workarounds_cpu(const cpu_info_t *cpu)
......@@ -2564,7 +2617,7 @@ static int host_background_service_task_event_loop(void)
else if (address == 0x82)
{
post_code_low = post_code;
set_led_bank_display(((post_code_high & 0xf) << 4) | (post_code_low & 0xf));
display_post_code(((post_code_high & 0xff) << 8) | (post_code_low & 0xff));
if (enable_post_code_console_output)
{
......@@ -2709,7 +2762,7 @@ int host_console_event_loop(const struct shell *shell)
switch (escape_sequence_state)
{
case 0:
if (character == '\n')
if ((character == '\n') || (character == '\r'))
{
escape_sequence_state = 1;
}
......
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