diff --git a/meta-facebook/yv35-rf/CMakeLists.txt b/meta-facebook/yv35-rf/CMakeLists.txt index 5288e11df1..3d01995f38 100644 --- a/meta-facebook/yv35-rf/CMakeLists.txt +++ b/meta-facebook/yv35-rf/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: Apache-2.0 +#SPDX - License - Identifier : Apache - 2.0 cmake_minimum_required(VERSION 3.13.1) @@ -36,6 +36,7 @@ target_include_directories(app PRIVATE ${common_path}/service/ipmi/include) target_include_directories(app PRIVATE ${common_path}/service/logging) target_include_directories(app PRIVATE ${common_path}/service/mctp) target_include_directories(app PRIVATE ${common_path}/service/pldm) +target_include_directories(app PRIVATE ${common_path}/service/cci) target_include_directories(app PRIVATE ${common_path}/service/sensor) target_include_directories(app PRIVATE ${common_path}/service/usb) target_include_directories(app PRIVATE ${common_path}/shell/commands) diff --git a/meta-facebook/yv35-rf/src/platform/plat_def.h b/meta-facebook/yv35-rf/src/platform/plat_def.h index fd949ac7f0..b9c3ba4335 100644 --- a/meta-facebook/yv35-rf/src/platform/plat_def.h +++ b/meta-facebook/yv35-rf/src/platform/plat_def.h @@ -18,5 +18,7 @@ #define PLAT_DEF_H #define BMC_USB_PORT "CDC_ACM_0" +#define ENABLE_CCI +#define ENABLE_PM8702 #endif diff --git a/meta-facebook/yv35-rf/src/platform/plat_i2c_target.c b/meta-facebook/yv35-rf/src/platform/plat_i2c_target.c new file mode 100644 index 0000000000..453ce82798 --- /dev/null +++ b/meta-facebook/yv35-rf/src/platform/plat_i2c_target.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + NAME: I2C TARGET INIT + FILE: plat_i2c_target.c + DESCRIPTION: Provide i2c target EN/CFG table "I2C_TARGET_EN_TABLE[]/I2C_TARGET_CFG_TABLE[]" for init target config. + AUTHOR: MouchenHung + DATE/VERSION: 2021.11.26 - v1.1 + Note: + (1) "plat_i2c_target.h" is included by "hal_i2c_target.h" +*/ + +#include +#include +#include +#include "plat_i2c_target.h" + +/* I2C target init-enable table */ +const bool I2C_TARGET_ENABLE_TABLE[MAX_TARGET_NUM] = { + TARGET_DISABLE, TARGET_ENABLE, TARGET_DISABLE, TARGET_DISABLE, + TARGET_DISABLE, TARGET_DISABLE, TARGET_DISABLE, TARGET_DISABLE, + TARGET_DISABLE, TARGET_DISABLE, TARGET_DISABLE, TARGET_DISABLE, + TARGET_DISABLE, TARGET_DISABLE, TARGET_DISABLE, TARGET_DISABLE, +}; + +/* I2C target init-config table */ +const struct _i2c_target_config I2C_TARGET_CONFIG_TABLE[MAX_TARGET_NUM] = { + { 0x40, 0xA }, { 0x20, 0xA }, { 0x40, 0xA }, { 0x40, 0xA }, { 0xFF, 0xA }, { 0xFF, 0xA }, + { 0x40, 0x5 }, { 0xFF, 0xA }, { 0x40, 0x4 }, { 0xFF, 0xA }, { 0x40, 0xA }, { 0x40, 0xA }, + { 0x40, 0xA }, { 0x40, 0xA }, { 0xFF, 0xA }, { 0xFF, 0xA }, +}; \ No newline at end of file diff --git a/meta-facebook/yv35-rf/src/platform/plat_i2c_target.h b/meta-facebook/yv35-rf/src/platform/plat_i2c_target.h new file mode 100644 index 0000000000..d229a805c1 --- /dev/null +++ b/meta-facebook/yv35-rf/src/platform/plat_i2c_target.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PLAT_I2C_SLAVE_H +#define PLAT_I2C_SLAVE_H + +#include +#include "hal_i2c_target.h" + +#define TARGET_ENABLE 1 +#define TARGET_DISABLE 0 + +#endif \ No newline at end of file diff --git a/meta-facebook/yv35-rf/src/platform/plat_init.c b/meta-facebook/yv35-rf/src/platform/plat_init.c index 3482c35888..1254b23dd1 100644 --- a/meta-facebook/yv35-rf/src/platform/plat_init.c +++ b/meta-facebook/yv35-rf/src/platform/plat_init.c @@ -20,6 +20,9 @@ #include "plat_isr.h" #include "plat_power_seq.h" #include "power_status.h" +#include "cci.h" +#include "plat_mctp.h" +#include "plat_i2c_target.h" SCU_CFG scu_cfg[] = { //register value @@ -31,6 +34,15 @@ void pal_pre_init() { init_platform_config(); scu_init(scu_cfg, ARRAY_SIZE(scu_cfg)); + + /* init i2c target */ + for (int index = 0; index < MAX_TARGET_NUM; index++) { + if (I2C_TARGET_ENABLE_TABLE[index]) + i2c_target_control( + index, (struct _i2c_target_config *)&I2C_TARGET_CONFIG_TABLE[index], + 1); + } + plat_mctp_init(); } void pal_set_sys_status() diff --git a/meta-facebook/yv35-rf/src/platform/plat_mctp.c b/meta-facebook/yv35-rf/src/platform/plat_mctp.c new file mode 100644 index 0000000000..cae4e6d0ea --- /dev/null +++ b/meta-facebook/yv35-rf/src/platform/plat_mctp.c @@ -0,0 +1,230 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright (c) 2012-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include "libutil.h" +#include "mctp.h" +#include "mctp_ctrl.h" +#include "pldm.h" +#include "ipmi.h" +#include "sensor.h" +#include "plat_hook.h" +#include "plat_mctp.h" +#include "plat_gpio.h" +#include "cci.h" +#include "pm8702.h" + +LOG_MODULE_REGISTER(plat_mctp); +K_TIMER_DEFINE(send_cmd_timer, send_cmd_to_dev, NULL); +K_WORK_DEFINE(send_cmd_work, send_cmd_to_dev_handler); + +static mctp_smbus_port smbus_port[] = { + { .conf.smbus_conf.addr = I2C_ADDR_BIC, .conf.smbus_conf.bus = I2C_BUS_CXL }, +}; + +static mctp_route_entry mctp_route_tbl[] = { + { CXL_EID, I2C_BUS_CXL, I2C_ADDR_CXL0 }, +}; + +mctp *find_mctp_by_smbus(uint8_t bus) +{ + uint8_t i; + for (i = 0; i < ARRAY_SIZE(smbus_port); i++) { + mctp_smbus_port *p = smbus_port + i; + if (!p) { + return NULL; + } + if (bus == p->conf.smbus_conf.bus) { + return p->mctp_inst; + } + } + return NULL; +} + +static void set_endpoint_resp_handler(void *args, uint8_t *buf, uint16_t len) +{ + CHECK_NULL_ARG(args); + CHECK_NULL_ARG(buf); + LOG_HEXDUMP_INF(buf, len, __func__); +} + +static void set_endpoint_resp_timeout(void *args) +{ + CHECK_NULL_ARG(args); + mctp_route_entry *p = (mctp_route_entry *)args; + printk("[%s] Endpoint 0x%x set endpoint failed on bus %d \n", __func__, p->endpoint, + p->bus); +} + +static void set_dev_endpoint(void) +{ + for (uint8_t i = 0; i < ARRAY_SIZE(mctp_route_tbl); i++) { + mctp_route_entry *p = mctp_route_tbl + i; + for (uint8_t j = 0; j < ARRAY_SIZE(smbus_port); j++) { + if (!p) { + return; + } + if (p->bus != smbus_port[j].conf.smbus_conf.bus) { + continue; + } + printk("Prepare send endpoint bus 0x%x, addr 0x%x\n", p->bus, p->addr); + struct _set_eid_req req = { 0 }; + req.op = SET_EID_REQ_OP_SET_EID; + req.eid = p->endpoint; + + mctp_ctrl_msg msg; + memset(&msg, 0, sizeof(msg)); + msg.ext_params.type = MCTP_MEDIUM_TYPE_SMBUS; + msg.ext_params.smbus_ext_params.addr = p->addr; + + msg.hdr.cmd = MCTP_CTRL_CMD_SET_ENDPOINT_ID; + msg.hdr.rq = 1; + + msg.cmd_data = (uint8_t *)&req; + msg.cmd_data_len = sizeof(req); + + msg.recv_resp_cb_fn = set_endpoint_resp_handler; + msg.timeout_cb_fn = set_endpoint_resp_timeout; + msg.timeout_cb_fn_args = p; + + mctp_ctrl_send_msg(find_mctp_by_smbus(p->bus), &msg); + } + } +} + +static uint8_t mctp_msg_recv(void *mctp_p, uint8_t *buf, uint32_t len, mctp_ext_params ext_params) +{ + CHECK_NULL_ARG_WITH_RETURN(mctp_p, MCTP_ERROR); + CHECK_NULL_ARG_WITH_RETURN(buf, MCTP_ERROR); + + /* first byte is message type and ic */ + uint8_t msg_type = (buf[0] & MCTP_MSG_TYPE_MASK) >> MCTP_MSG_TYPE_SHIFT; + + switch (msg_type) { + case MCTP_MSG_TYPE_CTRL: + mctp_ctrl_cmd_handler(mctp_p, buf, len, ext_params); + break; + + case MCTP_MSG_TYPE_CCI: + mctp_cci_cmd_handler(mctp_p, buf, len, ext_params); + break; + + default: + LOG_WRN("Cannot find message receive function!!"); + return MCTP_ERROR; + } + + return MCTP_SUCCESS; +} + +uint8_t get_mctp_route_info(uint8_t dest_endpoint, void **mctp_inst, mctp_ext_params *ext_params) +{ + CHECK_NULL_ARG_WITH_RETURN(mctp_inst, MCTP_ERROR); + CHECK_NULL_ARG_WITH_RETURN(ext_params, MCTP_ERROR); + + uint8_t rc = MCTP_ERROR; + uint32_t i; + + for (i = 0; i < ARRAY_SIZE(mctp_route_tbl); i++) { + mctp_route_entry *p = mctp_route_tbl + i; + if (!p) { + return MCTP_ERROR; + } + if (p->endpoint == dest_endpoint) { + *mctp_inst = find_mctp_by_smbus(p->bus); + ext_params->type = MCTP_MEDIUM_TYPE_SMBUS; + ext_params->smbus_ext_params.addr = p->addr; + rc = MCTP_SUCCESS; + break; + } + } + return rc; +} + +uint8_t get_mctp_info(uint8_t dest_endpoint, mctp **mctp_inst, mctp_ext_params *ext_params) +{ + CHECK_NULL_ARG_WITH_RETURN(mctp_inst, MCTP_ERROR); + CHECK_NULL_ARG_WITH_RETURN(ext_params, MCTP_ERROR); + + uint8_t rc = MCTP_ERROR; + uint32_t i; + + for (i = 0; i < ARRAY_SIZE(mctp_route_tbl); i++) { + mctp_route_entry *p = mctp_route_tbl + i; + if (!p) { + return MCTP_ERROR; + } + if (p->endpoint == dest_endpoint) { + *mctp_inst = find_mctp_by_smbus(p->bus); + ext_params->type = MCTP_MEDIUM_TYPE_SMBUS; + ext_params->smbus_ext_params.addr = p->addr; + rc = MCTP_SUCCESS; + break; + } + } + return rc; +} + +void send_cmd_to_dev_handler(struct k_work *work) +{ + /* init the device endpoint */ + set_dev_endpoint(); +} +void send_cmd_to_dev(struct k_timer *timer) +{ + k_work_submit(&send_cmd_work); +} + +void plat_mctp_init() +{ + LOG_INF("plat_mctp_init"); + for (uint8_t i = 0; i < ARRAY_SIZE(smbus_port); i++) { + mctp_smbus_port *p = smbus_port + i; + if (!p) { + return; + } + /* init the mctp/cci instance */ + LOG_DBG("bus = %x, addr = %x", p->conf.smbus_conf.bus, p->conf.smbus_conf.addr); + + p->mctp_inst = mctp_init(); + if (!p->mctp_inst) { + LOG_ERR("mctp_init failed!!"); + } + LOG_DBG("mctp_inst = %p", p->mctp_inst); + uint8_t rc = + mctp_set_medium_configure(p->mctp_inst, MCTP_MEDIUM_TYPE_SMBUS, p->conf); + LOG_DBG("mctp_set_medium_configure %s", + (rc == MCTP_SUCCESS) ? "success" : "failed"); + + mctp_reg_endpoint_resolve_func(p->mctp_inst, get_mctp_route_info); + mctp_reg_msg_rx_func(p->mctp_inst, mctp_msg_recv); + mctp_start(p->mctp_inst); + } + /* Only send command to device when DC on */ + if (gpio_get(FM_POWER_EN) == POWER_ON) { + k_timer_start(&send_cmd_timer, K_MSEC(3000), K_NO_WAIT); + } +} \ No newline at end of file diff --git a/meta-facebook/yv35-rf/src/platform/plat_mctp.h b/meta-facebook/yv35-rf/src/platform/plat_mctp.h new file mode 100644 index 0000000000..f48575eae0 --- /dev/null +++ b/meta-facebook/yv35-rf/src/platform/plat_mctp.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _PLAT_MCTP_h +#define _PLAT_MCTP_h + +#include "storage_handler.h" +#define MCTP_MSG_TYPE_SHIFT 0 +#define MCTP_MSG_TYPE_MASK 0x7F +#define MCTP_IC_SHIFT 7 +#define MCTP_IC_MASK 0x80 + +/* i2c 8 bit address */ +#define I2C_ADDR_BIC 0x20 +#define I2C_ADDR_CXL0 0x74 +#define I2C_ADDR_CXL1 0xC2 +/* i2c dev bus */ +#define I2C_BUS_CXL 0x01 +/* mctp endpoint */ +#define CXL_EID 0x2E + +typedef struct _mctp_smbus_port { + mctp *mctp_inst; + mctp_medium_conf conf; + uint8_t user_idx; +} mctp_smbus_port; + +/* mctp route entry struct */ +typedef struct _mctp_route_entry { + uint8_t endpoint; + uint8_t bus; /* TODO: only consider smbus/i3c */ + uint8_t addr; /* TODO: only consider smbus/i3c */ + uint8_t dev_present_pin; +} mctp_route_entry; + +typedef struct _mctp_msg_handler { + MCTP_MSG_TYPE type; + mctp_fn_cb msg_handler_cb; +} mctp_msg_handler; + +/* init the mctp moduel for platform */ +void send_cmd_to_dev(struct k_timer *timer); +void send_cmd_to_dev_handler(struct k_work *work); +void plat_mctp_init(void); +uint8_t get_mctp_route_info(uint8_t dest_endpoint, void **mctp_inst, mctp_ext_params *ext_params); +mctp *find_mctp_by_smbus(uint8_t bus); +mctp *get_mctp_init(); +uint8_t get_mctp_info(uint8_t dest_endpoint, mctp **mctp_inst, mctp_ext_params *ext_params); + +#endif /* _PLAT_MCTP_h */ \ No newline at end of file diff --git a/meta-facebook/yv35-rf/src/platform/plat_sdr_table.c b/meta-facebook/yv35-rf/src/platform/plat_sdr_table.c index b44d6aea2b..4fbe85f114 100644 --- a/meta-facebook/yv35-rf/src/platform/plat_sdr_table.c +++ b/meta-facebook/yv35-rf/src/platform/plat_sdr_table.c @@ -22,6 +22,311 @@ #include "plat_sdr_table.h" SDR_Full_sensor plat_sdr_table[] = { + { + // CXL on board temperature + 0x00, + 0x00, // record ID + IPMI_SDR_VER_15, // SDR ver + IPMI_SDR_FULL_SENSOR, // record type + IPMI_SDR_FULL_SENSOR_MIN_LEN, // size of struct + + SELF_I2C_ADDRESS << 1, // owner id + 0x00, // owner lun + SENSOR_NUM_TEMP_CXL, // sensor number + + IPMI_SDR_ENTITY_ID_SYS_BOARD, // entity id + 0x00, // entity instance + IPMI_SDR_SENSOR_INIT_SCAN | IPMI_SDR_SENSOR_INIT_EVENT | + IPMI_SDR_SENSOR_INIT_THRESHOLD | IPMI_SDR_SENSOR_INIT_TYPE | + IPMI_SDR_SENSOR_INIT_DEF_EVENT | + IPMI_SDR_SENSOR_INIT_DEF_SCAN, // sensor init + IPMI_SDR_SENSOR_CAP_THRESHOLD_RW | + IPMI_SDR_SENSOR_CAP_EVENT_CTRL_NO, // sensor capabilities + IPMI_SDR_SENSOR_TYPE_TEMPERATURE, // sensor type + IPMI_SDR_EVENT_TYPE_THRESHOLD, // event/reading type + 0x00, // assert event mask + IPMI_SDR_CMP_RETURN_LCT | IPMI_SDR_ASSERT_MASK_UCT_HI | + IPMI_SDR_ASSERT_MASK_LCT_LO, // assert threshold reading mask + 0x00, // deassert event mask + IPMI_SDR_CMP_RETURN_UCT | IPMI_SDR_DEASSERT_MASK_UCT_LO | + IPMI_SDR_DEASSERT_MASK_LCT_HI, // deassert threshold reading mask + 0x00, // discrete reading mask/ settable + IPMI_SDR_UCT_SETTABLE | IPMI_SDR_LCT_SETTABLE | IPMI_SDR_UCT_READABLE | + IPMI_SDR_LCT_READABLE, // threshold mask/ readable threshold mask + 0x80, // sensor unit + IPMI_SENSOR_UNIT_DEGREE_C, // base unit + 0x00, // modifier unit + IPMI_SDR_LINEAR_LINEAR, // linearization + 0x01, // [7:0] M bits + 0x00, // [9:8] M bits, tolerance + 0x00, // [7:0] B bits + 0x00, // [9:8] B bits, tolerance + 0x00, // [7:4] accuracy , [3:2] accuracy exp, [1:0] sensor direction + 0x00, // Rexp, Bexp + 0x00, // analog characteristic + 0x00, // nominal reading + 0x00, // normal maximum + 0x00, // normal minimum + 0x00, // sensor maximum reading + 0x00, // sensor minimum reading + 0x00, // UNRT + 0x5A, // UCT + 0x00, // UNCT + 0x00, // LNRT + 0x00, // LCT + 0x00, // LNCT + 0x00, // positive-going threshold + 0x00, // negative-going threshold + 0x00, // reserved + 0x00, // reserved + 0x00, // OEM + IPMI_SDR_STRING_TYPE_ASCII_8, // ID len, should be same as "size of struct" + "RF_CXL_TEMP_C", + }, + { + // RF DIMMA temperature + 0x00, + 0x00, // record ID + IPMI_SDR_VER_15, // SDR ver + IPMI_SDR_FULL_SENSOR, // record type + IPMI_SDR_FULL_SENSOR_MIN_LEN, // size of struct + + SELF_I2C_ADDRESS << 1, // owner id + 0x00, // owner lun + SENSOR_NUM_TEMP_DIMMA, // sensor number + + IPMI_SDR_ENTITY_ID_SYS_BOARD, // entity id + 0x00, // entity instance + IPMI_SDR_SENSOR_INIT_SCAN | IPMI_SDR_SENSOR_INIT_EVENT | + IPMI_SDR_SENSOR_INIT_THRESHOLD | IPMI_SDR_SENSOR_INIT_TYPE | + IPMI_SDR_SENSOR_INIT_DEF_EVENT | + IPMI_SDR_SENSOR_INIT_DEF_SCAN, // sensor init + IPMI_SDR_SENSOR_CAP_THRESHOLD_RW | + IPMI_SDR_SENSOR_CAP_EVENT_CTRL_NO, // sensor capabilities + IPMI_SDR_SENSOR_TYPE_TEMPERATURE, // sensor type + IPMI_SDR_EVENT_TYPE_THRESHOLD, // event/reading type + 0x00, // assert event mask + IPMI_SDR_CMP_RETURN_LCT | IPMI_SDR_ASSERT_MASK_UCT_HI | + IPMI_SDR_ASSERT_MASK_LCT_LO, // assert threshold reading mask + 0x00, // deassert event mask + IPMI_SDR_CMP_RETURN_UCT | IPMI_SDR_DEASSERT_MASK_UCT_LO | + IPMI_SDR_DEASSERT_MASK_LCT_HI, // deassert threshold reading mask + 0x00, // discrete reading mask/ settable + IPMI_SDR_UCT_SETTABLE | IPMI_SDR_LCT_SETTABLE | IPMI_SDR_UCT_READABLE | + IPMI_SDR_LCT_READABLE, // threshold mask/ readable threshold mask + 0x80, // sensor unit + IPMI_SENSOR_UNIT_DEGREE_C, // base unit + 0x00, // modifier unit + IPMI_SDR_LINEAR_LINEAR, // linearization + 0x01, // [7:0] M bits + 0x00, // [9:8] M bits, tolerance + 0x00, // [7:0] B bits + 0x00, // [9:8] B bits, tolerance + 0x00, // [7:4] accuracy , [3:2] accuracy exp, [1:0] sensor direction + 0x00, // Rexp, Bexp + 0x00, // analog characteristic + 0x00, // nominal reading + 0x00, // normal maximum + 0x00, // normal minimum + 0x00, // sensor maximum reading + 0x00, // sensor minimum reading + 0x00, // UNRT + 0x55, // UCT + 0x00, // UNCT + 0x00, // LNRT + 0x00, // LCT + 0x00, // LNCT + 0x00, // positive-going threshold + 0x00, // negative-going threshold + 0x00, // reserved + 0x00, // reserved + 0x00, // OEM + IPMI_SDR_STRING_TYPE_ASCII_8, // ID len, should be same as "size of struct" + "RF_DIMM_A_TEMP_C", + }, + { + // RF DIMMB temperature + 0x00, + 0x00, // record ID + IPMI_SDR_VER_15, // SDR ver + IPMI_SDR_FULL_SENSOR, // record type + IPMI_SDR_FULL_SENSOR_MIN_LEN, // size of struct + + SELF_I2C_ADDRESS << 1, // owner id + 0x00, // owner lun + SENSOR_NUM_TEMP_DIMMB, // sensor number + + IPMI_SDR_ENTITY_ID_SYS_BOARD, // entity id + 0x00, // entity instance + IPMI_SDR_SENSOR_INIT_SCAN | IPMI_SDR_SENSOR_INIT_EVENT | + IPMI_SDR_SENSOR_INIT_THRESHOLD | IPMI_SDR_SENSOR_INIT_TYPE | + IPMI_SDR_SENSOR_INIT_DEF_EVENT | + IPMI_SDR_SENSOR_INIT_DEF_SCAN, // sensor init + IPMI_SDR_SENSOR_CAP_THRESHOLD_RW | + IPMI_SDR_SENSOR_CAP_EVENT_CTRL_NO, // sensor capabilities + IPMI_SDR_SENSOR_TYPE_TEMPERATURE, // sensor type + IPMI_SDR_EVENT_TYPE_THRESHOLD, // event/reading type + 0x00, // assert event mask + IPMI_SDR_CMP_RETURN_LCT | IPMI_SDR_ASSERT_MASK_UCT_HI | + IPMI_SDR_ASSERT_MASK_LCT_LO, // assert threshold reading mask + 0x00, // deassert event mask + IPMI_SDR_CMP_RETURN_UCT | IPMI_SDR_DEASSERT_MASK_UCT_LO | + IPMI_SDR_DEASSERT_MASK_LCT_HI, // deassert threshold reading mask + 0x00, // discrete reading mask/ settable + IPMI_SDR_UCT_SETTABLE | IPMI_SDR_LCT_SETTABLE | IPMI_SDR_UCT_READABLE | + IPMI_SDR_LCT_READABLE, // threshold mask/ readable threshold mask + 0x80, // sensor unit + IPMI_SENSOR_UNIT_DEGREE_C, // base unit + 0x00, // modifier unit + IPMI_SDR_LINEAR_LINEAR, // linearization + 0x01, // [7:0] M bits + 0x00, // [9:8] M bits, tolerance + 0x00, // [7:0] B bits + 0x00, // [9:8] B bits, tolerance + 0x00, // [7:4] accuracy , [3:2] accuracy exp, [1:0] sensor direction + 0x00, // Rexp, Bexp + 0x00, // analog characteristic + 0x00, // nominal reading + 0x00, // normal maximum + 0x00, // normal minimum + 0x00, // sensor maximum reading + 0x00, // sensor minimum reading + 0x00, // UNRT + 0x55, // UCT + 0x00, // UNCT + 0x00, // LNRT + 0x00, // LCT + 0x00, // LNCT + 0x00, // positive-going threshold + 0x00, // negative-going threshold + 0x00, // reserved + 0x00, // reserved + 0x00, // OEM + IPMI_SDR_STRING_TYPE_ASCII_8, // ID len, should be same as "size of struct" + "RF_DIMM_B_TEMP_C", + }, + { + // RF DIMMC temperature + 0x00, + 0x00, // record ID + IPMI_SDR_VER_15, // SDR ver + IPMI_SDR_FULL_SENSOR, // record type + IPMI_SDR_FULL_SENSOR_MIN_LEN, // size of struct + + SELF_I2C_ADDRESS << 1, // owner id + 0x00, // owner lun + SENSOR_NUM_TEMP_DIMMC, // sensor number + + IPMI_SDR_ENTITY_ID_SYS_BOARD, // entity id + 0x00, // entity instance + IPMI_SDR_SENSOR_INIT_SCAN | IPMI_SDR_SENSOR_INIT_EVENT | + IPMI_SDR_SENSOR_INIT_THRESHOLD | IPMI_SDR_SENSOR_INIT_TYPE | + IPMI_SDR_SENSOR_INIT_DEF_EVENT | + IPMI_SDR_SENSOR_INIT_DEF_SCAN, // sensor init + IPMI_SDR_SENSOR_CAP_THRESHOLD_RW | + IPMI_SDR_SENSOR_CAP_EVENT_CTRL_NO, // sensor capabilities + IPMI_SDR_SENSOR_TYPE_TEMPERATURE, // sensor type + IPMI_SDR_EVENT_TYPE_THRESHOLD, // event/reading type + 0x00, // assert event mask + IPMI_SDR_CMP_RETURN_LCT | IPMI_SDR_ASSERT_MASK_UCT_HI | + IPMI_SDR_ASSERT_MASK_LCT_LO, // assert threshold reading mask + 0x00, // deassert event mask + IPMI_SDR_CMP_RETURN_UCT | IPMI_SDR_DEASSERT_MASK_UCT_LO | + IPMI_SDR_DEASSERT_MASK_LCT_HI, // deassert threshold reading mask + 0x00, // discrete reading mask/ settable + IPMI_SDR_UCT_SETTABLE | IPMI_SDR_LCT_SETTABLE | IPMI_SDR_UCT_READABLE | + IPMI_SDR_LCT_READABLE, // threshold mask/ readable threshold mask + 0x80, // sensor unit + IPMI_SENSOR_UNIT_DEGREE_C, // base unit + 0x00, // modifier unit + IPMI_SDR_LINEAR_LINEAR, // linearization + 0x01, // [7:0] M bits + 0x00, // [9:8] M bits, tolerance + 0x00, // [7:0] B bits + 0x00, // [9:8] B bits, tolerance + 0x00, // [7:4] accuracy , [3:2] accuracy exp, [1:0] sensor direction + 0x00, // Rexp, Bexp + 0x00, // analog characteristic + 0x00, // nominal reading + 0x00, // normal maximum + 0x00, // normal minimum + 0x00, // sensor maximum reading + 0x00, // sensor minimum reading + 0x00, // UNRT + 0x55, // UCT + 0x00, // UNCT + 0x00, // LNRT + 0x00, // LCT + 0x00, // LNCT + 0x00, // positive-going threshold + 0x00, // negative-going threshold + 0x00, // reserved + 0x00, // reserved + 0x00, // OEM + IPMI_SDR_STRING_TYPE_ASCII_8, // ID len, should be same as "size of struct" + "RF_DIMM_C_TEMP_C", + }, + { + // RF DIMMD temperature + 0x00, + 0x00, // record ID + IPMI_SDR_VER_15, // SDR ver + IPMI_SDR_FULL_SENSOR, // record type + IPMI_SDR_FULL_SENSOR_MIN_LEN, // size of struct + + SELF_I2C_ADDRESS << 1, // owner id + 0x00, // owner lun + SENSOR_NUM_TEMP_DIMMD, // sensor number + + IPMI_SDR_ENTITY_ID_SYS_BOARD, // entity id + 0x00, // entity instance + IPMI_SDR_SENSOR_INIT_SCAN | IPMI_SDR_SENSOR_INIT_EVENT | + IPMI_SDR_SENSOR_INIT_THRESHOLD | IPMI_SDR_SENSOR_INIT_TYPE | + IPMI_SDR_SENSOR_INIT_DEF_EVENT | + IPMI_SDR_SENSOR_INIT_DEF_SCAN, // sensor init + IPMI_SDR_SENSOR_CAP_THRESHOLD_RW | + IPMI_SDR_SENSOR_CAP_EVENT_CTRL_NO, // sensor capabilities + IPMI_SDR_SENSOR_TYPE_TEMPERATURE, // sensor type + IPMI_SDR_EVENT_TYPE_THRESHOLD, // event/reading type + 0x00, // assert event mask + IPMI_SDR_CMP_RETURN_LCT | IPMI_SDR_ASSERT_MASK_UCT_HI | + IPMI_SDR_ASSERT_MASK_LCT_LO, // assert threshold reading mask + 0x00, // deassert event mask + IPMI_SDR_CMP_RETURN_UCT | IPMI_SDR_DEASSERT_MASK_UCT_LO | + IPMI_SDR_DEASSERT_MASK_LCT_HI, // deassert threshold reading mask + 0x00, // discrete reading mask/ settable + IPMI_SDR_UCT_SETTABLE | IPMI_SDR_LCT_SETTABLE | IPMI_SDR_UCT_READABLE | + IPMI_SDR_LCT_READABLE, // threshold mask/ readable threshold mask + 0x80, // sensor unit + IPMI_SENSOR_UNIT_DEGREE_C, // base unit + 0x00, // modifier unit + IPMI_SDR_LINEAR_LINEAR, // linearization + 0x01, // [7:0] M bits + 0x00, // [9:8] M bits, tolerance + 0x00, // [7:0] B bits + 0x00, // [9:8] B bits, tolerance + 0x00, // [7:4] accuracy , [3:2] accuracy exp, [1:0] sensor direction + 0x00, // Rexp, Bexp + 0x00, // analog characteristic + 0x00, // nominal reading + 0x00, // normal maximum + 0x00, // normal minimum + 0x00, // sensor maximum reading + 0x00, // sensor minimum reading + 0x00, // UNRT + 0x55, // UCT + 0x00, // UNCT + 0x00, // LNRT + 0x00, // LCT + 0x00, // LNCT + 0x00, // positive-going threshold + 0x00, // negative-going threshold + 0x00, // reserved + 0x00, // reserved + 0x00, // OEM + IPMI_SDR_STRING_TYPE_ASCII_8, // ID len, should be same as "size of struct" + "RF_DIMM_D_TEMP_C", + }, { // TMP75 on board temperature 0x00, diff --git a/meta-facebook/yv35-rf/src/platform/plat_sensor_table.c b/meta-facebook/yv35-rf/src/platform/plat_sensor_table.c index 0d6e3c83dc..86c3252090 100644 --- a/meta-facebook/yv35-rf/src/platform/plat_sensor_table.c +++ b/meta-facebook/yv35-rf/src/platform/plat_sensor_table.c @@ -23,6 +23,8 @@ #include "plat_sensor_table.h" #include "pmbus.h" #include "util_sys.h" +#include "cci.h" +#include "plat_mctp.h" static uint8_t INA233_DEVICE_ID[4] = { 0x02, 0x54, 0x49, 0xe2 }; @@ -35,6 +37,21 @@ sensor_cfg plat_sensor_config[] = { { SENSOR_NUM_TEMP_TMP75, sensor_dev_tmp75, I2C_BUS3, TMP75_MB_ADDR, TMP75_TEMP_OFFSET, stby_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL }, + { SENSOR_NUM_TEMP_CXL, sensor_dev_pm8702, CXL_EID, NONE, CHIP_TEMP_OFFSET, dc_access, 0, 0, + SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, + NULL, NULL, NULL, NULL, NULL }, + { SENSOR_NUM_TEMP_DIMMA, sensor_dev_pm8702, CXL_EID, DIMMA_TEMP_ADDR, DIMM_TEMP_OFFSET, + dc_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0, + SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL }, + { SENSOR_NUM_TEMP_DIMMB, sensor_dev_pm8702, CXL_EID, DIMMB_TEMP_ADDR, DIMM_TEMP_OFFSET, + dc_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0, + SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL }, + { SENSOR_NUM_TEMP_DIMMC, sensor_dev_pm8702, CXL_EID, DIMMC_TEMP_ADDR, DIMM_TEMP_OFFSET, + dc_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0, + SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL }, + { SENSOR_NUM_TEMP_DIMMD, sensor_dev_pm8702, CXL_EID, DIMMD_TEMP_ADDR, DIMM_TEMP_OFFSET, + dc_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0, + SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL }, { SENSOR_NUM_TEMP_CXL_CNTR, sensor_dev_tmp75, I2C_BUS2, TMP75_ASIC_ADDR, TMP75_TEMP_OFFSET, dc_access, 0, 0, SAMPLE_COUNT_DEFAULT, POLL_TIME_DEFAULT, ENABLE_SENSOR_POLLING, 0, SENSOR_INIT_STATUS, NULL, NULL, NULL, NULL, NULL }, diff --git a/meta-facebook/yv35-rf/src/platform/plat_sensor_table.h b/meta-facebook/yv35-rf/src/platform/plat_sensor_table.h index 9a02b43fad..d0f85d4858 100644 --- a/meta-facebook/yv35-rf/src/platform/plat_sensor_table.h +++ b/meta-facebook/yv35-rf/src/platform/plat_sensor_table.h @@ -39,8 +39,17 @@ #define SMBUS_TEMP_CMD 0x8D #define SMBUS_PWR_CMD 0x96 +#define CHIP_TEMP_OFFSET 0x00 +#define DIMM_TEMP_OFFSET 0x01 + +#define DIMMA_TEMP_ADDR 0x18 +#define DIMMB_TEMP_ADDR 0x19 +#define DIMMC_TEMP_ADDR 0x1A +#define DIMMD_TEMP_ADDR 0x1B + /* threshold sensor number, 1 based */ #define SENSOR_NUM_TEMP_TMP75 0x50 +#define SENSOR_NUM_TEMP_CXL 0x51 #define SENSOR_NUM_TEMP_CXL_CNTR 0x52 #define SENSOR_NUM_TEMP_DIMMA 0x53 #define SENSOR_NUM_TEMP_DIMMB 0x54 @@ -89,10 +98,11 @@ extern uint8_t plat_get_config_size(); extern void load_sensor_config(void); -enum { VR_INF = 0, - VR_RNS, - PWR_INA233, - PWR_SGY, +enum { + VR_INF = 0, + VR_RNS, + PWR_INA233, + PWR_SGY, }; #endif