Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions common/lib/expansion_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ void init_sys_board_id(uint8_t board_id)
case RAINBOW_FALLS:
system_board_id = RAINBOW_FALLS;
break;
case WAIMANO_FALLS:
system_board_id = WAIMANO_FALLS;
break;
case VERNAL_FALLS:
system_board_id = VERNAL_FALLS;
system_board_id = VERNAL_FALLS_BOARD_TYPE;
break;
default:
printf("[%s] input board id not support: 0x%x\n", __func__, board_id);
Expand Down
2 changes: 2 additions & 0 deletions common/lib/expansion_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ enum BOARD_ID {
UNKNOWN_BOARD = 0xFF,
};

#define VERNAL_FALLS_BOARD_TYPE 0x07 // VF return board_type instead of board_id

void init_platform_config();
void init_sys_board_id(uint8_t board_id);
uint8_t get_board_id();
Expand Down
5 changes: 3 additions & 2 deletions common/lib/util_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "libutil.h"

#define WORKER_STACK_SIZE 10000
#define WORKER_PRIORITY osPriorityBelowNormal
#define WORKER_PRIORITY CONFIG_MAIN_THREAD_PRIORITY

#define MAX_WORK_COUNT 32
#define WARN_WORK_PROC_TIME_MS 1000
Expand Down Expand Up @@ -42,7 +42,7 @@ static void work_handler(struct k_work *item)

/* Processing time too long, print warning message */
if ((fn_finish_time - fn_start_time) > WARN_WORK_PROC_TIME_MS) {
printf("WARN: work %s Processing time too long, %lld ms\n", work_job->name,
printf("WARN: work %s Processing time too long, %llu ms\n", work_job->name,
(fn_finish_time - fn_start_time));
}
}
Expand Down Expand Up @@ -122,6 +122,7 @@ int add_work(worker_job *job)
}
work_count++;
k_mutex_unlock(&mutex_use_count);
// free new_job in work_handler()
return ret;

error:
Expand Down
2 changes: 2 additions & 0 deletions common/lib/util_worker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef SMC_WORKER_H
#define SMC_WORKER_H

#include <stdint.h>

#define MAX_WORK_NAME_LEN 32

/* A structure used to submit work. */
Expand Down
3 changes: 3 additions & 0 deletions common/service/ipmi/include/ipmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ enum {
CMD_OEM_1S_SENSOR_POLL_EN = 0x30,
CMD_OEM_1S_GET_BIC_STATUS = 0x31,
CMD_OEM_1S_RESET_BIC = 0x32,
CMD_OEM_1S_GET_SET_M2 = 0x34,
CMD_OEM_1S_SET_SSD_LED = 0x39,
CMD_OEM_1S_GET_SSD_STATUS = 0x3A,
CMD_OEM_1S_GET_SET_GPIO = 0x41,
CMD_OEM_1S_GET_FW_SHA256 = 0x43,
CMD_OEM_1S_CONTROL_SENSOR_POLLING = 0x45,
Expand Down
45 changes: 45 additions & 0 deletions common/service/ipmi/oem_1s_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,42 @@ __weak void OEM_1S_RESET_BIC(ipmi_msg *msg)
return;
}

__weak void OEM_1S_GET_SET_M2(ipmi_msg *msg)
{
if (msg == NULL) {
printf("%s failed due to parameter *msg is NULL\n", __func__);
return;
}

msg->data_len = 0;
msg->completion_code = CC_INVALID_CMD;
return;
}

__weak void OEM_1S_SET_SSD_LED(ipmi_msg *msg)
{
if (msg == NULL) {
printf("%s failed due to parameter *msg is NULL\n", __func__);
return;
}

msg->data_len = 0;
msg->completion_code = CC_INVALID_CMD;
return;
}

__weak void OEM_1S_GET_SSD_STATUS(ipmi_msg *msg)
{
if (msg == NULL) {
printf("%s failed due to parameter *msg is NULL\n", __func__);
return;
}

msg->data_len = 0;
msg->completion_code = CC_INVALID_CMD;
return;
}

__weak void OEM_1S_12V_CYCLE_SLOT(ipmi_msg *msg)
{
if (msg == NULL) {
Expand Down Expand Up @@ -1731,6 +1767,15 @@ void IPMI_OEM_1S_handler(ipmi_msg *msg)
case CMD_OEM_1S_RESET_BIC:
OEM_1S_RESET_BIC(msg);
break;
case CMD_OEM_1S_GET_SET_M2:
OEM_1S_GET_SET_M2(msg);
break;
case CMD_OEM_1S_SET_SSD_LED:
OEM_1S_SET_SSD_LED(msg);
break;
case CMD_OEM_1S_GET_SSD_STATUS:
OEM_1S_GET_SSD_STATUS(msg);
break;
case CMD_OEM_1S_12V_CYCLE_SLOT:
OEM_1S_12V_CYCLE_SLOT(msg);
break;
Expand Down
12 changes: 12 additions & 0 deletions meta-facebook/yv3-vf/boards/ast1030_evb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@ CONFIG_GPIO_ASPEED=y
CONFIG_SPI_ASPEED=y
CONFIG_I2C_ASPEED=y
CONFIG_ADC_ASPEED=y
CONFIG_USB_ASPEED=y
CONFIG_WDT_ASPEED=y

#USB
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM"
CONFIG_USB_CDC_ACM=y
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=576
CONFIG_USB_DEVICE_VID=0x1d6b
CONFIG_USB_DEVICE_PID=0x0104
CONFIG_LOG_BUFFER_SIZE=5120
#USB
4 changes: 4 additions & 0 deletions meta-facebook/yv3-vf/boards/ast1030_evb.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@
&sram0 {
reg = <0 DT_SIZE_K(608)>, <0x98000 DT_SIZE_K(160)>;
};

&udc {
status = "okay";
};
187 changes: 187 additions & 0 deletions meta-facebook/yv3-vf/src/ipmi/plat_ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,190 @@
#include "libutil.h"

#include "plat_class.h"
#include "plat_m2.h"
#include "plat_led.h"
#include "plat_power_seq.h"

// for GET_SET_M2
#define DRIVE_PWR_OFF 0 /* normal device power off/on */
#define DRIVE_PWR_ON 1
#define DRIVE_GET_STATE 3
#define DRIVE_PWR_OFF_BY_PWRDIS 4 /* power off/on device by PWRDIS pin */
#define DRIVE_PWR_ON_BY_PWRDIS 5
#define DRIVE_PWR_OFF_ALL 6 /* power off/on device by PWRDIS/12V/3V3 */
#define DRIVE_PWR_ON_ALL 7
#define DRIVE_PWR_OFF_BY_12V_3V3 8 /* power off/on device by 12V/3V3 */
#define DRIVE_PWR_ON_BY_12V_3V3 9

void OEM_1S_GET_BOARD_ID(ipmi_msg *msg)
{
if (msg == NULL) {
printf("%s failed due to parameter *msg is NULL\n", __func__);
return;
}

if (msg->data_len != 0) {
msg->data_len = 0;
msg->completion_code = CC_INVALID_LENGTH;
return;
}

msg->data_len = 1;
msg->data[0] = get_board_id();
msg->completion_code = CC_SUCCESS;
return;
}

void OEM_1S_SET_SSD_LED(ipmi_msg *msg)
{
if (msg == NULL) {
printf("%s failed due to parameter *msg is NULL\n", __func__);
return;
}

if (msg->data_len != 2) {
msg->data_len = 0;
msg->completion_code = CC_INVALID_LENGTH;
return;
}

uint8_t dev = msg->data[0];

if (!m2_prsnt(dev)) {
msg->data_len = 0;
msg->completion_code = 0x80; //ssd not present response complete code
return;
}

if (SSDLEDCtrl(dev, msg->data[1])) {
msg->data_len = 0;
msg->completion_code = CC_INVALID_DATA_FIELD;
return;
}

msg->data_len = 0;
msg->completion_code = CC_SUCCESS;
}

void OEM_1S_GET_SSD_STATUS(ipmi_msg *msg)
{
if (msg == NULL) {
printf("%s failed due to parameter *msg is NULL\n", __func__);
return;
}

if (msg->data_len != 1) {
msg->data_len = 0;
msg->completion_code = CC_INVALID_LENGTH;
return;
}

uint8_t dev = msg->data[0];
if (!m2_prsnt(dev)) {
msg->data_len = 0;
msg->completion_code = 0x80; //ssd not present response complete code
return;
}

msg->data_len = 1;
msg->data[0] = GetAmberLEDStat(dev);
msg->completion_code = CC_SUCCESS;
}

void OEM_1S_GET_SET_M2(ipmi_msg *msg)
{
if (msg == NULL) {
printf("%s failed due to parameter *msg is NULL\n", __func__);
return;
}

if (msg->data_len != 2) {
msg->data_len = 0;
msg->completion_code = CC_INVALID_LENGTH;
return;
}

msg->completion_code = CC_INVALID_DATA_FIELD;
msg->data_len = 0;
uint8_t val, dev, is_on;
uint8_t func = msg->data[1];
uint8_t change_dev = msg->data[0] - 1; // Shift for 0 based
change_dev = exchange_m2_idx(change_dev); // exchange m2 idx

switch (func) {
case DRIVE_PWR_OFF:
case DRIVE_PWR_ON:
dev = change_dev;
val = DEV_CHK_DISABLE | DEV_PWR_CTRL | DEV_PCIE_RST |
((func == 1) ? DEV_PWR_ON : 0);

if (dev >= M2_IDX_E_MAX)
return;

device_all_power_set(dev, val);

msg->completion_code = CC_SUCCESS;
break;

case DRIVE_GET_STATE:
dev = msg->data[0];

if (!dev) {
/* get all m2 device status */
uint16_t *tmp = (uint16_t *)(msg->data + 1);
uint8_t i;

*tmp = 0;
for (i = 0; i < M2_IDX_E_MAX; i++)
*tmp |= (m2_pwrgd(i) && m2_prsnt(i)) << i;

msg->data_len += 2;
msg->completion_code = CC_SUCCESS;
} else {
dev = change_dev;
if (dev >= M2_IDX_E_MAX)
return;

/* get specific m2 device status */
//buf[1] = m2_pwrgd((M2_IDX_E)dev) && m2_prsnt((M2_IDX_E)dev); //remove for now, will add back
msg->data[0] = m2_pwrgd(dev);
msg->data_len += 1;
msg->completion_code = CC_SUCCESS;
}
break;

case DRIVE_PWR_OFF_BY_PWRDIS:
case DRIVE_PWR_ON_BY_PWRDIS:
case DRIVE_PWR_OFF_ALL:
case DRIVE_PWR_ON_ALL:
dev = change_dev;
is_on = (func == DRIVE_PWR_ON_BY_PWRDIS || func == DRIVE_PWR_ON_ALL);

if (dev >= M2_IDX_E_MAX)
return;

val = DEV_PRSNT_SET | DEV_PWRDIS_EN | DEV_FORCE_3V3 | (is_on ? DEV_PWR_ON : 0);
if (func == DRIVE_PWR_OFF_ALL || func == DRIVE_PWR_ON_ALL)
val |= DEV_PWR_CTRL;

device_all_power_set(dev, val);

msg->completion_code = CC_SUCCESS;
break;

case DRIVE_PWR_OFF_BY_12V_3V3:
case DRIVE_PWR_ON_BY_12V_3V3:
dev = change_dev;
is_on = (func == DRIVE_PWR_ON_BY_12V_3V3);

if (dev >= M2_IDX_E_MAX)
return;

val = DEV_PWR_CTRL | DEV_PRSNT_SET | DEV_FORCE_3V3 | DEV_PCIE_RST |
(is_on ? DEV_PWR_ON : 0);
device_all_power_set(dev, val);

msg->completion_code = CC_SUCCESS;
break;
}
}
2 changes: 1 addition & 1 deletion meta-facebook/yv3-vf/src/platform/plat_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ uint8_t get_e1s_pwrgd()
default:
return gpio_get(FM_POWER_EN);
}
}
}
10 changes: 10 additions & 0 deletions meta-facebook/yv3-vf/src/platform/plat_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
#include "hal_gpio.h"
#include "plat_gpio.h"

enum PALTFORM_BOARD_ID {
FM_BOARD_ID_0 = BOARD_ID0,
FM_BOARD_ID_1 = BOARD_ID1,
FM_BOARD_ID_2 = BOARD_ID2,
FM_BOARD_ID_3 = BOARD_ID3,
};

enum E1S_CONFIG_HSC {
CONFIG_HSC_ADM1278 = 0x00,
CONFIG_HSC_MAXIN,
Expand All @@ -16,7 +23,10 @@ enum E1S_CONFIG_ADC {
CONFIG_ADC_ISL28022,
};

void init_platform_config();
void init_e1s_config();
void init_sys_board_id(uint8_t board_id);
uint8_t get_board_id();
uint8_t get_e1s_hsc_config();
uint8_t get_e1s_adc_config();
uint8_t get_e1s_pwrgd();
Expand Down
2 changes: 2 additions & 0 deletions meta-facebook/yv3-vf/src/platform/plat_def.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef PLAT_DEF_H
#define PLAT_DEF_H

#define BMC_USB_PORT "CDC_ACM_0"

#endif
Loading