OpenBIC
OpenSource Bridge-IC
vistara.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef VISTARA_H
18#define VISTARA_H
19
20#ifdef ENABLE_VISTARA
21#include "cci.h"
22#include <sys/byteorder.h>
23
24#define READ_DDR_TEMP_REQ_LEN 0
25#define READ_DDR_TEMP_RESP_LEN 32
26#define READ_DDR_SLOT_INFO_REQ_LEN 0
27#define READ_DDR_SLOT_INFO_RESP_LEN 68 // 4 + 4*16 bytes
28#define MAX_DIMM_PER_CXL 4
29#define MAX_CXL_COUNT 2
30
31#define VISTARA_SPD_DDR4_TOTAL_BYTES 512
32#define VISTARA_SPD_CHUNK_DEFAULT 64
33#define VISTARA_SPD_MODULE_SN_OFF 325
34#define VISTARA_SPD_MODULE_SN_LEN 4
35#define VISTARA_CCI_BUFFER_SIZE 256
36
37enum VISTARA_CCI_CMD_OEM_OPCODE {
38 CCI_OEM_OP_READ_DDR_TEMP = 0xC531,
39 CCI_OEM_OP_DIMM_SPD_READ = 0xC510,
40 CCI_OEM_OP_DIMM_SLOT_INFO = 0xC520,
41};
42
43enum VISTARA_SENSOR_TYPE {
44 DDR_TEMP,
45};
46
47enum VISTARA_DIMM_ID {
48 DIMMA_ID = 0,
49 DIMMB_ID,
50 DIMMC_ID,
51 DIMMD_ID,
52 MAX_DIMM_ID,
53};
54
55typedef struct {
56 uint8_t temp_valid;
57 uint8_t dimm_id;
58 uint8_t spd_id;
59 uint8_t reserved;
60 uint8_t dimm_temp[4];
61} read_ddr_temp_resp;
62
63struct vistara_dimm_spd_read_args {
64 uint32_t spd_id;
65 uint32_t offset;
66 uint32_t num_bytes;
67};
68
69static inline size_t vistara_encode_dimm_spd_read(uint8_t dst[12],
70 const struct vistara_dimm_spd_read_args *a)
71{
72 sys_put_le32(a->spd_id, &dst[0]);
73 sys_put_le32(a->offset, &dst[4]);
74 sys_put_le32(a->num_bytes, &dst[8]);
75 return 12;
76}
77
78typedef struct {
79 uint8_t spd_i2c_addr;
80 uint8_t channel_id;
81 uint8_t dimm_silk_screen;
82 uint8_t dimm_present;
83 uint8_t reserved[12]; // 16 bytes per slot
84} dimm_slot_info_t;
85
86typedef struct {
87 uint32_t num_dimm_slots;
88 dimm_slot_info_t dimm_info[MAX_DIMM_PER_CXL];
89} read_ddr_slot_info_resp;
90
91typedef struct {
92 bool valid;
93 uint32_t timestamp;
94 read_ddr_slot_info_resp slot_info[MAX_CXL_COUNT];
95 uint8_t master_dimm_id[MAX_CXL_COUNT];
96} ddr_slot_info_cache_t;
97
98extern ddr_slot_info_cache_t g_ddr_slot_cache;
99
100uint8_t plat_get_cxl_eid(uint8_t cxl_id);
101void plat_set_dimm_cache(uint8_t *resp_buf, uint8_t cxl_id, uint8_t status);
102float plat_get_dimm_cache(uint8_t cxl_id, uint8_t dimm_id);
103bool vistara_cci_command(uint8_t cxl_eid, mctp_cci_msg cci_msg, uint8_t *resp, uint8_t resp_len);
104bool vistara_read_ddr_temp(uint8_t cxl_eid, uint8_t *resp);
105int vistara_read_dimm_spd_chunk_eid(uint8_t cxl_eid, uint8_t dimm_idx, uint16_t offset,
106 uint8_t length, uint8_t *out);
107bool vistara_read_dimm_spd_ddr4(uint8_t cxl_eid, uint8_t dimm_idx,
108 uint8_t out512[VISTARA_SPD_DDR4_TOTAL_BYTES]);
109bool vistara_read_ddr_slot_info(uint8_t cxl_eid, uint8_t *resp);
110int vistara_init_ddr_slot_info(void);
111bool vistara_get_dimm_present_from_cache(uint8_t dimm_id);
112
113#endif
114#endif
int length
Definition: hal_jtag.h:1
uint32_t timestamp
Definition: ipmb.h:19
uint8_t status
Definition: mctp_ctrl.h:1
uint32_t reserved
Definition: plat_ncsi.h:4
uint32_t offset
Definition: pldm_firmware_update.h:0
Definition: plat_dimm.h:71
Definition: cci.h:71
uint8_t plat_get_cxl_eid(uint8_t cxl_id)
Definition: plat_mctp.c:439
void plat_set_dimm_cache(uint8_t *resp_buf, uint8_t cxl_id, uint8_t status)
Definition: plat_pldm_sensor.c:6764
float plat_get_dimm_cache(uint8_t cxl_id, uint8_t dimm_id)
Definition: plat_pldm_sensor.c:6750