diff --git a/modules/fru.c b/modules/fru.c index 2a1cc93e4..2c32c67ae 100644 --- a/modules/fru.c +++ b/modules/fru.c @@ -94,11 +94,11 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) fru[id].cfg.read_f( fru[id].cfg.eeprom_id, 0x00, &common_header[0], 8, 0 ); } - printf("[FRU] Asserting FRU information integrity\n"); + printf("[FRU][%s] Asserting FRU information integrity\n", id == FRU_AMC ? "AMC" : "RTM"); total_len += 8; if ( !((calculate_chksum( &common_header[0], 8 ) == 0) && common_header[0] == 1) ) { /* Wrong checksum */ - printf("[FRU] Error in COMMON HEADER checksum\n"); + printf("[FRU][%s] Error in COMMON HEADER checksum\n", id == FRU_AMC ? "AMC" : "RTM"); return 0; } @@ -108,7 +108,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) multirec_off = 8*common_header[5]; if (chassis_off > 0) { - printf("[FRU] Checking CHASSIS AREA record..."); + printf("[FRU][%s] Checking CHASSIS AREA record...", id == FRU_AMC ? "AMC" : "RTM"); if (fru[id].runtime) { rec_len = fru[id].buffer[chassis_off+1]; } else { @@ -133,7 +133,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) } if (board_off > 0) { - printf("[FRU] Checking BOARD AREA record..."); + printf("[FRU][%s] Checking BOARD AREA record...", id == FRU_AMC ? "AMC" : "RTM"); if (fru[id].runtime) { rec_len = fru[id].buffer[board_off+1]; } else { @@ -159,7 +159,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) } if (product_off > 0) { - printf("[FRU] Checking PRODUCT AREA record..."); + printf("[FRU][%s] Checking PRODUCT AREA record...", id == FRU_AMC ? "AMC" : "RTM"); if (fru[id].runtime) { rec_len = fru[id].buffer[product_off+1]; } else { @@ -188,7 +188,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) uint8_t eol = 0; uint8_t rec_chksum; rec_len = 0; - printf("[FRU] Checking MULTIRECORD AREA records...\n"); + printf("[FRU][%s] Checking MULTIRECORD AREA records...\n", id == FRU_AMC ? "AMC" : "RTM"); do { if (fru[id].runtime) { memcpy( &rec_buff[0], &fru[id].buffer[multirec_off], 5); @@ -198,7 +198,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) /* Calculate Multirecord header checksum */ if ( !(calculate_chksum( &rec_buff[0], 5 ) == 0) ) { /* Wrong checksum */ - printf("[FRU] Error in MULTIRECORD AREA HEADER integrity check!\n"); + printf("[FRU][%s] Error in MULTIRECORD AREA HEADER integrity check!\n", id == FRU_AMC ? "AMC" : "RTM"); return 0; } multirec_off += 5; @@ -215,7 +215,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) } if ( !((calculate_chksum( &rec_buff[0], rec_len ) == rec_chksum)) ) { /* Wrong checksum */ - printf("[FRU] Error in MULTIRECORD AREA integrity check!\n"); + printf("[FRU][%s] Error in MULTIRECORD AREA integrity check!\n", id == FRU_AMC ? "AMC" : "RTM"); return 0; } else { total_len += rec_len; @@ -229,7 +229,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) *fru_size = total_len; } - printf("[FRU] FRU info is healthy!\n"); + printf("[FRU][%s] FRU info is healthy!\n", id == FRU_AMC ? "AMC" : "RTM"); vPortFree(rec_buff); return 1; diff --git a/modules/ipmi.c b/modules/ipmi.c index 63920f4e1..73535cd57 100644 --- a/modules/ipmi.c +++ b/modules/ipmi.c @@ -289,16 +289,16 @@ IPMI_HANDLER(ipmi_picmg_cmd_fru_control, NETFN_GRPEXT, IPMI_PICMG_CMD_FRU_CONTRO switch (fru_ctl) { case FRU_CTLCODE_COLD_RST: - payload_send_message( fru_id, PAYLOAD_MESSAGE_COLD_RST); + payload_send_message(fru_id, PAYLOAD_MESSAGE_COLD_RST); break; case FRU_CTLCODE_WARM_RST: - payload_send_message( fru_id, PAYLOAD_MESSAGE_WARM_RST); + payload_send_message(fru_id, PAYLOAD_MESSAGE_WARM_RST); break; case FRU_CTLCODE_REBOOT: - payload_send_message( fru_id, PAYLOAD_MESSAGE_REBOOT); + payload_send_message(fru_id, PAYLOAD_MESSAGE_REBOOT); break; case FRU_CTLCODE_QUIESCE: - payload_send_message( fru_id, PAYLOAD_MESSAGE_QUIESCED); + payload_send_message(fru_id, PAYLOAD_MESSAGE_QUIESCE); break; default: rsp->completion_code = IPMI_CC_INV_DATA_FIELD_IN_REQ; diff --git a/modules/rtm.c b/modules/rtm.c index 0b8fa554e..ec9f0acdc 100644 --- a/modules/rtm.c +++ b/modules/rtm.c @@ -35,43 +35,40 @@ #include "hotswap.h" #include "payload.h" #include "uart_debug.h" +#include "led.h" -volatile bool rtm_present = false; -volatile uint8_t rtm_power_level = 0; extern EventGroupHandle_t rtm_payload_evt; void RTM_Manage( void * Parameters ) { uint8_t ps_old_state = 0xFF; uint8_t ps_new_state; - bool rtm_compatible; + bool rtm_compatible = false; extern sensor_t * hotswap_rtm_sensor; - EventBits_t current_evt; + uint8_t rtm_hs_state; - /* A local copy of rtm_power_level to check if it's changed status */ - uint8_t rtm_pwr_lvl_change = rtm_power_level; + /* Defaults to not present */ + rtm_present = false; /* Start with RTM payload disabled */ rtm_disable_payload_power(); -#ifdef BENCH_TEST - rtm_power_level = 0x01; - rtm_pwr_lvl_change = 0x00; -#endif - for ( ;; ) { - vTaskDelay(100); + vTaskDelay(500); rtm_check_presence( &ps_new_state ); if ( ps_new_state ^ ps_old_state ) { if ( ps_new_state == HOTSWAP_STATE_URTM_PRSENT ) { - printf("RTM Board detected!\n"); + printf("[RTM] Rear Board detected!\n"); rtm_present = true; + /* Initialize basic hardware to enable communication */ + rtm_hardware_init(); + /* Create/Read the RTM FRU info before sending the hotswap event */ fru_init(FRU_RTM); @@ -83,14 +80,25 @@ void RTM_Manage( void * Parameters ) /* Check the Zone3 compatibility records */ rtm_compatible = rtm_compatibility_check(); if ( rtm_compatible ) { - printf("RTM Board is compatible! Initializing...\n"); + printf("[RTM] Rear Board is compatible! Initializing...\n"); /* Send RTM Compatible message */ hotswap_send_event( hotswap_rtm_sensor, HOTSWAP_STATE_URTM_COMPATIBLE ); hotswap_set_mask_bit( HOTSWAP_RTM, HOTSWAP_URTM_COMPATIBLE_MASK ); - rtm_hardware_init(); + /* Perform hotswap first read */ + while (!rtm_get_hotswap_handle_status( &rtm_hs_state )); + + /* Override RTM state so that if the handle is closed when the MMC is starting, + * the LED and payload power remains in the correct state */ + if ( rtm_hs_state == 0 ) { + LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_OFF, 0, 0 ); + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE); + } else { + LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_ON, 0, 0 ); + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE); + } } else { - printf("RTM Board is not compatible.\n"); + printf("[RTM] Rear Board is not compatible.\n"); /* Send RTM Incompatible message */ hotswap_send_event( hotswap_rtm_sensor, HOTSWAP_STATE_URTM_INCOMPATIBLE ); hotswap_clear_mask_bit( HOTSWAP_RTM, HOTSWAP_URTM_COMPATIBLE_MASK ); @@ -102,7 +110,7 @@ void RTM_Manage( void * Parameters ) } else if ( ps_new_state == HOTSWAP_STATE_URTM_ABSENT ) { //sdr_disable_sensors(); /* Not implemented yet */ - printf("RTM Board disconnected!\n"); + printf("[RTM] Rear Board disconnected!\n"); rtm_present = false; @@ -113,39 +121,36 @@ void RTM_Manage( void * Parameters ) ps_old_state = ps_new_state; } - if ( rtm_pwr_lvl_change ^ rtm_power_level ) { - rtm_pwr_lvl_change = rtm_power_level; - - if ( rtm_power_level == 0x01 ) { - hotswap_clear_mask_bit( HOTSWAP_RTM, HOTSWAP_QUIESCED_MASK ); - - printf("Enabling RTM Payload power...\n"); - rtm_enable_payload_power(); - } else { - printf("Disabling RTM Payload power...\n"); - rtm_disable_payload_power(); - } - } - + /* Check enable/disable events */ current_evt = xEventGroupGetBits( rtm_payload_evt ); - if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) { + if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) { if ( rtm_quiesce() ) { /* Quiesced event */ - printf("RTM Quiesced successfuly!\n"); + printf("[RTM] Quiesced RTM successfuly!\n"); hotswap_set_mask_bit( HOTSWAP_RTM, HOTSWAP_QUIESCED_MASK ); hotswap_send_event( hotswap_rtm_sensor, HOTSWAP_STATE_QUIESCED ); - xEventGroupClearBits( rtm_payload_evt, PAYLOAD_MESSAGE_QUIESCED ); + } else { + printf("[RTM] RTM failed to quiesce!\n"); + } + xEventGroupClearBits( rtm_payload_evt, PAYLOAD_MESSAGE_QUIESCE ); + + } else if ( current_evt & PAYLOAD_MESSAGE_RTM_ENABLE ) { + if (rtm_compatible) { + hotswap_clear_mask_bit( HOTSWAP_RTM, HOTSWAP_QUIESCED_MASK ); + printf("[RTM] Enabling RTM Payload power...\n"); + rtm_enable_payload_power(); + } else { + printf("[RTM] Impossible to enable payload power to an incompatible RTM board!\n"); } + xEventGroupClearBits( rtm_payload_evt, PAYLOAD_MESSAGE_RTM_ENABLE ); } } } void rtm_manage_init( void ) { - rtm_power_level = 0; - - xTaskCreate( RTM_Manage, "RTM Manage", 100, (void *) NULL, tskRTM_MANAGE_PRIORITY, (TaskHandle_t *) NULL ); + xTaskCreate( RTM_Manage, "RTM Manage", 150, (void *) NULL, tskRTM_MANAGE_PRIORITY, (TaskHandle_t *) NULL ); } /* Set Power Level Request handler */ @@ -154,9 +159,20 @@ IPMI_HANDLER(ipmi_picmg_set_power_level, NETFN_GRPEXT, IPMI_PICMG_CMD_SET_POWER_ { int len = rsp->data_len = 0; uint8_t fru_id = req->data[1]; - - if ( fru_id == FRU_RTM ) { - rtm_power_level = req->data[2]; + uint8_t power_level = req->data[2]; + + /* + * Power Level: + * 00h = Power off + * 01h - 14h = Select power level, if available + * 0xFF = Do not change power level + */ + if ( fru_id == FRU_RTM && power_level != 0xFF ) { + if (power_level == 0x00) { + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE); + } else { + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE); + } } rsp->completion_code = IPMI_CC_OK; diff --git a/modules/rtm.h b/modules/rtm.h index 80ea7bb17..e0608392a 100644 --- a/modules/rtm.h +++ b/modules/rtm.h @@ -33,6 +33,8 @@ #include "rtm_user.h" +volatile bool rtm_present; + /** * @brief Initialize RTM Manage task * diff --git a/modules/sensors/hotswap.c b/modules/sensors/hotswap.c index b45a52c76..8b587c2c3 100644 --- a/modules/sensors/hotswap.c +++ b/modules/sensors/hotswap.c @@ -41,6 +41,10 @@ #include "utils.h" #include "uart_debug.h" +#ifdef MODULE_RTM +#include "rtm.h" +#endif + TaskHandle_t vTaskHotSwap_Handle; static bool hotswap_get_handle_status( uint8_t *state ) @@ -106,7 +110,6 @@ void vTaskHotSwap( void *Parameters ) static uint8_t new_state_amc = 0x01, old_state_amc = 0xFF; #ifdef MODULE_RTM static uint8_t new_state_rtm = 0x01, old_state_rtm = 0xFF; - extern bool rtm_present; #endif TickType_t xLastWakeTime; @@ -122,17 +125,6 @@ void vTaskHotSwap( void *Parameters ) LEDUpdate( FRU_AMC, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_ON, 0, 0 ); } -#ifdef MODULE_RTM - /* Perform hotswap first read */ - while (!rtm_get_hotswap_handle_status( &new_state_rtm )); - - /* Override RTM Blue LED state so that if the handle is closed when the MMC is starting, the LED remains in the correct state */ - if ( new_state_rtm == 0 ) { - LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_OFF, 0, 0 ); - } else { - LEDUpdate( FRU_RTM, LED_BLUE, LEDMODE_OVERRIDE, LEDINIT_ON, 0, 0 ); - } -#endif /* Initialise the xLastWakeTime variable with the current time. */ xLastWakeTime = xTaskGetTickCount(); @@ -173,8 +165,14 @@ void vTaskHotSwap( void *Parameters ) if ( new_state_rtm ^ old_state_rtm ) { if ( new_state_rtm == 0 ) { printf("RTM Hotswap handle pressed!\n"); +#ifdef BENCH_TEST + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE); +#endif } else { - printf("RTM Hotswap handle released!\n"); + printf("RTM Hotswap handle released!\n"); +#ifdef BENCH_TEST + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE); +#endif } if ( hotswap_send_event( hotswap_rtm_sensor, new_state_rtm ) == ipmb_error_success ) { hotswap_set_mask_bit( HOTSWAP_RTM, 1 << new_state_rtm ); diff --git a/port/board/afc-bpm/v3_0/payload.c b/port/board/afc-bpm/v3_0/payload.c index d31a64d33..9da4381c6 100644 --- a/port/board/afc-bpm/v3_0/payload.c +++ b/port/board/afc-bpm/v3_0/payload.c @@ -224,9 +224,9 @@ void vTaskPayload( void *pvParameters ) DCDC_good = 0; xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_DCDC_PGOODn ); } - if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) { + if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) { QUIESCED_req = 1; - xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCED ); + xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCE ); } if ( current_evt & PAYLOAD_MESSAGE_COLD_RST ) { state = PAYLOAD_SWITCHING_OFF; diff --git a/port/board/afc-bpm/v3_0/payload.h b/port/board/afc-bpm/v3_0/payload.h index 98974a41a..06f921d40 100644 --- a/port/board/afc-bpm/v3_0/payload.h +++ b/port/board/afc-bpm/v3_0/payload.h @@ -68,7 +68,7 @@ enum { #define PAYLOAD_MESSAGE_COLD_RST (1 << 4) #define PAYLOAD_MESSAGE_WARM_RST (1 << 5) #define PAYLOAD_MESSAGE_REBOOT (1 << 6) -#define PAYLOAD_MESSAGE_QUIESCED (1 << 7) +#define PAYLOAD_MESSAGE_QUIESCE (1 << 7) /** * @} */ diff --git a/port/board/afc-bpm/v3_1/payload.c b/port/board/afc-bpm/v3_1/payload.c index b76437c15..bcb1ded5c 100644 --- a/port/board/afc-bpm/v3_1/payload.c +++ b/port/board/afc-bpm/v3_1/payload.c @@ -232,9 +232,9 @@ void vTaskPayload( void *pvParameters ) current_evt = xEventGroupGetBits( amc_payload_evt ); - if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) { + if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) { QUIESCED_req = 1; - xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCED ); + xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCE ); } if ( current_evt & PAYLOAD_MESSAGE_COLD_RST ) { diff --git a/port/board/afc-bpm/v3_1/payload.h b/port/board/afc-bpm/v3_1/payload.h index 90bed30b6..d2ee2117c 100644 --- a/port/board/afc-bpm/v3_1/payload.h +++ b/port/board/afc-bpm/v3_1/payload.h @@ -59,7 +59,7 @@ enum { #define PAYLOAD_MESSAGE_COLD_RST (1 << 0) #define PAYLOAD_MESSAGE_WARM_RST (1 << 1) #define PAYLOAD_MESSAGE_REBOOT (1 << 2) -#define PAYLOAD_MESSAGE_QUIESCED (1 << 3) +#define PAYLOAD_MESSAGE_QUIESCE (1 << 3) /** * @} */ diff --git a/port/board/afc-timing/payload.c b/port/board/afc-timing/payload.c index 7bd4762a6..bd0dab0c7 100644 --- a/port/board/afc-timing/payload.c +++ b/port/board/afc-timing/payload.c @@ -232,9 +232,9 @@ void vTaskPayload( void *pvParameters ) current_evt = xEventGroupGetBits( amc_payload_evt ); - if ( current_evt & PAYLOAD_MESSAGE_QUIESCED ) { + if ( current_evt & PAYLOAD_MESSAGE_QUIESCE ) { QUIESCED_req = 1; - xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCED ); + xEventGroupClearBits( amc_payload_evt, PAYLOAD_MESSAGE_QUIESCE ); } if ( current_evt & PAYLOAD_MESSAGE_COLD_RST ) { diff --git a/port/board/afc-timing/payload.h b/port/board/afc-timing/payload.h index 90bed30b6..4dbfa146a 100644 --- a/port/board/afc-timing/payload.h +++ b/port/board/afc-timing/payload.h @@ -59,7 +59,8 @@ enum { #define PAYLOAD_MESSAGE_COLD_RST (1 << 0) #define PAYLOAD_MESSAGE_WARM_RST (1 << 1) #define PAYLOAD_MESSAGE_REBOOT (1 << 2) -#define PAYLOAD_MESSAGE_QUIESCED (1 << 3) +#define PAYLOAD_MESSAGE_QUIESCE (1 << 3) +#define PAYLOAD_MESSAGE_RTM_ENABLE (1 << 4) /** * @} */ diff --git a/port/board/rtm-8sfp/rtm_user.c b/port/board/rtm-8sfp/rtm_user.c index 0ef2ac030..b5b53619a 100644 --- a/port/board/rtm-8sfp/rtm_user.c +++ b/port/board/rtm-8sfp/rtm_user.c @@ -35,19 +35,11 @@ void rtm_enable_payload_power( void ) { gpio_set_pin_state( PIN_PORT(GPIO_EN_RTM_PWR), PIN_NUMBER(GPIO_EN_RTM_PWR), 1 ); - /* Debug LEDs */ - pca9554_write_pin( RTM_GPIO_LED_RED, 1 ); - pca9554_write_pin( RTM_GPIO_LED_BLUE, 1 ); - pca9554_write_pin( RTM_GPIO_LED_GREEN, 0 ); } void rtm_disable_payload_power( void ) { gpio_set_pin_state( PIN_PORT(GPIO_EN_RTM_PWR), PIN_NUMBER(GPIO_EN_RTM_PWR), 0 ); - /* Debug LEDs */ - pca9554_write_pin( RTM_GPIO_LED_RED, 0 ); - pca9554_write_pin( RTM_GPIO_LED_BLUE, 0 ); - pca9554_write_pin( RTM_GPIO_LED_GREEN, 1 ); } uint8_t rtm_get_hotswap_handle_status( uint8_t *state ) @@ -81,27 +73,21 @@ void rtm_check_presence( uint8_t *status ) uint8_t i2c_addr, i2c_interface; uint8_t dumb; - if (i2c_take_by_chipid( CHIP_ID_RTM_PCA9554, &i2c_addr, &i2c_interface, 0)) { + /* Defaults to absent - in case of I2C failure */ + *status = HOTSWAP_STATE_URTM_ABSENT; + + if (i2c_take_by_chipid( CHIP_ID_RTM_PCA9554, &i2c_addr, &i2c_interface, 100)) { if (xI2CMasterRead( i2c_interface, i2c_addr, &dumb, 1)) { *status = HOTSWAP_STATE_URTM_PRSENT; - } else { - *status = HOTSWAP_STATE_URTM_ABSENT; } i2c_give(i2c_interface); } - - //return gpio_read_pin( GPIO_RTM_PS_PORT, GPIO_RTM_PS_PIN ); } void rtm_hardware_init( void ) { rtm_enable_i2c(); pca9554_set_port_dir( 0x1F ); - - /* Turn on Blue LED and off Red and Green */ - pca9554_write_pin( RTM_GPIO_LED_BLUE, 0 ); - pca9554_write_pin( RTM_GPIO_LED_RED, 1 ); - pca9554_write_pin( RTM_GPIO_LED_GREEN, 1 ); } void rtm_enable_i2c( void )