OpenBIC
OpenSource Bridge-IC
plat_dimm.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 PLAT_DIMM_H
18#define PLAT_DIMM_H
19
20#include "plat_i3c.h"
21
22#define DIMM_SPD_A_G_ADDR (0xA0 >> 1)
23#define DIMM_SPD_B_H_ADDR (0xA2 >> 1)
24#define DIMM_SPD_C_I_ADDR (0xA4 >> 1)
25#define DIMM_SPD_D_J_ADDR (0xA6 >> 1)
26#define DIMM_SPD_E_K_ADDR (0xA8 >> 1)
27#define DIMM_SPD_F_L_ADDR (0xAA >> 1)
28
29#define DIMM_PMIC_A_G_ADDR 0x48
30#define DIMM_PMIC_B_H_ADDR 0x49
31#define DIMM_PMIC_C_I_ADDR 0x4A
32#define DIMM_PMIC_D_J_ADDR 0x4B
33#define DIMM_PMIC_E_K_ADDR 0x4C
34#define DIMM_PMIC_F_L_ADDR 0x4D
35
36#define CPLD_ADDR 0x21
37
38#define MAX_LEN_I3C_GET_PMIC_ERR 47
39#define MAX_LEN_I3C_GET_PMIC_PWR 1
40#define MAX_LEN_I3C_GET_SPD_TEMP 2
41
42#define DIMM_I3C_MUX_CONTROL_OFFSET 0x0C
43#define I3C_MUX_BIC_TO_DIMMA_TO_F 0x02
44#define I3C_MUX_BIC_TO_DIMMG_TO_L 0x03
45#define I3C_MUX_CPU_TO_DIMM 0x00
46
47#define DIMM_I3C_MUX_STATUS_OFFSET 0x0D
48#define I3C_MUX_STATUS_ENABLE_FUNCTION_CHECK 7
49#define I3C_MUX_STATUS_PD_SPD_1_REMOTE_EN 6
50#define I3C_MUX_STATUS_PD_SPD_2_REMOTE_EN 5
51#define I3C_MUX_STATUS_SPD_MASK 0x60
52
53#define I3C_DIMM_MUTEX_TIMEOUT_MS 1000
54#define GET_DIMM_INFO_TIME_MS 1000
55#define GET_DIMM_INFO_STACK_SIZE 2304
56
57#define SPD_MFG_START 0x200
58#define SPD_MFG_TOTAL_LEN 128
59#define SPD_TEMP_DATA_LEN 2
60#define PMIC_PWR_DATA_LEN 1
61#define SPD_RAW_LEN 0x50
62
63#define SPD_TYPE 0x00 /* 0x02 (1) */
64#define SPD_SZ_B4 0x01 /* 0x04 (size_die) (1) */
65#define SPD_SZ_B6 0x02 /* 0x06 (device_width) (1) */
66#define SPD_SPEED_L 0x03 /* 0x14 (1) */
67#define SPD_SPEED_H 0x04 /* 0x15 (1) */
68#define SPD_PMICVEN_L 0x05 /* 0xC6 (1) */
69#define SPD_PMICVEN_H 0x06 /* 0xC7 (1) */
70#define SPD_REGVEN_L 0x07 /* 0xF0 (1) */
71#define SPD_REGVEN_H 0x08 /* 0xF1 (1) */
72#define SPD_SZ_BEA 0x09 /* 0xEA (pkg_rank) (1) */
73#define SPD_SZ_BEB 0x0A /* 0xEB (bus_width/ch) (1) */
74#define SPD_MFG_ID_L 0x0B /* 0x200 (1) */
75#define SPD_MFG_ID_H 0x0C /* 0x201 (1) */
76#define SPD_MFG_LOC 0x0D /* 0x202 (1) */
77#define SPD_MFG_YY 0x0E /* 0x203 (year) (1) */
78#define SPD_MFG_WW 0x0F /* 0x204 (week) (1) */
79#define SPD_SN_OFF 0x10 /* 0x205..0x208 (4) */
80#define SPD_SN_LEN 4
81#define SPD_PN_OFF 0x14 /* 0x209..0x226 (30) */
82#define SPD_PN_LEN 30
83#define SPD_PAYLOAD_LEN (SPD_C_PN_OFF + SPD_C_PN_LEN) /* = 50 bytes */
84#ifndef SPD_OEM_PRESENT
85#define SPD_OEM_PRESENT 0x4E /* 1 byte: 1=present, 0=not present */
86#endif
87#ifndef SPD_OEM_STATUS
88#define SPD_OEM_STATUS 0x4F /* 1 byte: bit0=SPD compact ready */
89#endif
90#define SPD_OEM_STATUS_SPD_READY 0x01
91
92typedef struct dimm_info {
93 uint8_t is_present;
100
114};
115
129};
130
146};
147
151};
152
154 DIMM_SPD = 0x00,
156 DIMM_PMIC = 0x02,
158};
159extern struct k_mutex i3c_dimm_mutex;
160extern uint8_t spd_i3c_addr_list[];
161extern uint8_t pmic_i3c_addr_list[];
162
165uint8_t sensor_num_map_dimm_id(uint8_t sensor_num);
166int pal_get_spd_temp(uint8_t sensor_num, uint8_t *data);
167int pal_get_pmic_pwr(uint8_t sensor_num, uint8_t *data);
168void clear_unaccessible_dimm_data(uint8_t dimm_id);
169int switch_i3c_dimm_mux(uint8_t i3c_ctrl_mux_data);
170int check_i3c_dimm_mux(uint8_t *status_data);
171int all_brocast_ccc(I3C_MSG *i3c_msg);
173uint8_t get_dimm_present(uint8_t dimm_id);
174void set_spd_raw_ready(uint8_t dimm_id, bool ready);
175bool get_spd_raw_ready(uint8_t dimm_id);
176int plat_get_spd_raw(uint8_t dimm_id, uint8_t **buf_out, bool *ready_out);
177
178#endif
uint8_t data[]
Definition: isl69259.c:2
uint8_t sensor_num
Definition: storage_handler.h:6
Definition: hal_i3c.h:105
Definition: plat_dimm.h:71
bool is_spd_raw_ready
Definition: plat_dimm.h:95
uint8_t pmic_pwr_data[MAX_LEN_I3C_GET_PMIC_PWR]
Definition: plat_dimm.h:74
bool is_ready_monitor
Definition: plat_dimm.h:81
uint8_t is_present
Definition: plat_dimm.h:93
uint8_t spd_raw_data[SPD_RAW_LEN]
Definition: plat_dimm.h:96
uint8_t spd_temp_data[MAX_LEN_I3C_GET_SPD_TEMP]
Definition: plat_dimm.h:75
struct dimm_info dimm_info
void start_get_dimm_info_thread()
Definition: plat_dimm.c:50
int all_brocast_ccc(I3C_MSG *i3c_msg)
Definition: plat_dimm.c:307
DIMM_DEVICE_TYPE
Definition: plat_dimm.h:65
@ DIMM_PMIC
Definition: plat_dimm.h:68
@ DIMM_SPD
Definition: plat_dimm.h:66
@ DIMM_SPD_NVM
Definition: plat_dimm.h:67
uint8_t sensor_num_map_dimm_id(uint8_t sensor_num)
Definition: plat_dimm.c:365
void clear_unaccessible_dimm_data(uint8_t dimm_id)
Definition: plat_dimm.c:444
void get_dimm_info_handler()
Definition: plat_dimm.c:114
uint8_t pmic_i3c_addr_list[MAX_COUNT_DIMM/2]
Definition: plat_dimm.c:41
DIMM_ID
Definition: plat_dimm.h:43
@ DIMM_ID_UNKNOWN
Definition: plat_dimm.h:50
uint8_t spd_i3c_addr_list[MAX_COUNT_DIMM/2]
Definition: plat_dimm.c:43
int switch_i3c_dimm_mux(uint8_t i3c_mux_position, uint8_t dimm_mux_position)
Definition: plat_dimm.c:248
struct k_mutex i3c_dimm_mutex
Definition: plat_dimm.c:45
@ DIMM_SPD_CACHE
Definition: plat_dimm.h:157
void set_spd_raw_ready(uint8_t dimm_id, bool ready)
uint8_t get_dimm_present(uint8_t dimm_id)
Definition: plat_dimm.c:589
#define MAX_LEN_I3C_GET_PMIC_PWR
Definition: plat_dimm.h:39
int pal_get_pmic_pwr(uint8_t sensor_num, uint8_t *data)
Definition: i3c_dimm.c:26
int pal_get_spd_temp(uint8_t sensor_num, uint8_t *data)
Definition: i3c_dimm.c:31
#define SPD_RAW_LEN
Definition: plat_dimm.h:61
NUMBER_DIMM_TEMP
Definition: plat_dimm.h:101
@ NUM_DIMM_D_TEMP
Definition: plat_dimm.h:105
@ NUM_DIMM_A_TEMP
Definition: plat_dimm.h:102
@ NUM_DIMM_G_TEMP
Definition: plat_dimm.h:108
@ NUM_DIMM_I_TEMP
Definition: plat_dimm.h:110
@ NUM_DIMM_C_TEMP
Definition: plat_dimm.h:104
@ NUM_DIMM_B_TEMP
Definition: plat_dimm.h:103
@ NUM_DIMM_E_TEMP
Definition: plat_dimm.h:106
@ NUM_DIMM_H_TEMP
Definition: plat_dimm.h:109
@ NUM_DIMM_F_TEMP
Definition: plat_dimm.h:107
@ NUM_DIMM_J_TEMP
Definition: plat_dimm.h:111
@ NUM_DIMM_K_TEMP
Definition: plat_dimm.h:112
@ NUM_DIMM_L_TEMP
Definition: plat_dimm.h:113
int check_i3c_dimm_mux(uint8_t *status_data)
Definition: plat_dimm.c:470
int init_dimm_prsnt_status()
Definition: plat_dimm.c:512
@ DIMM_ID_H
Definition: plat_dimm.h:139
@ DIMM_ID_C
Definition: plat_dimm.h:134
@ DIMM_ID_E
Definition: plat_dimm.h:136
@ DIMM_ID_K
Definition: plat_dimm.h:142
@ DIMM_ID_J
Definition: plat_dimm.h:141
@ DIMM_ID_A
Definition: plat_dimm.h:132
@ DIMM_ID_B
Definition: plat_dimm.h:133
@ DIMM_ID_D
Definition: plat_dimm.h:135
@ DIMM_ID_L
Definition: plat_dimm.h:143
@ DIMM_ID_G
Definition: plat_dimm.h:138
@ DIMM_ID_F
Definition: plat_dimm.h:137
@ DIMM_ID_MAX
Definition: plat_dimm.h:144
@ DIMM_ID_I
Definition: plat_dimm.h:140
#define MAX_LEN_I3C_GET_SPD_TEMP
Definition: plat_dimm.h:40
DIMM_PRSNT_STATUS
Definition: plat_dimm.h:148
@ DIMM_PRSNT
Definition: plat_dimm.h:149
@ DIMM_NOT_PRSNT
Definition: plat_dimm.h:150
bool get_spd_raw_ready(uint8_t dimm_id)
Definition: plat_dimm.c:429
NUMBER_DIMM_PMIC_PWR
Definition: plat_dimm.h:116
@ NUM_DIMM_E_PMIC_PWR
Definition: plat_dimm.h:121
@ NUM_DIMM_G_PMIC_PWR
Definition: plat_dimm.h:123
@ NUM_DIMM_F_PMIC_PWR
Definition: plat_dimm.h:122
@ NUM_DIMM_C_PMIC_PWR
Definition: plat_dimm.h:119
@ NUM_DIMM_J_PMIC_PWR
Definition: plat_dimm.h:126
@ NUM_DIMM_B_PMIC_PWR
Definition: plat_dimm.h:118
@ NUM_DIMM_I_PMIC_PWR
Definition: plat_dimm.h:125
@ NUM_DIMM_K_PMIC_PWR
Definition: plat_dimm.h:127
@ NUM_DIMM_H_PMIC_PWR
Definition: plat_dimm.h:124
@ NUM_DIMM_L_PMIC_PWR
Definition: plat_dimm.h:128
@ NUM_DIMM_D_PMIC_PWR
Definition: plat_dimm.h:120
@ NUM_DIMM_A_PMIC_PWR
Definition: plat_dimm.h:117
int plat_get_spd_raw(uint8_t dimm_id, uint8_t **buf_out, bool *ready_out)
Definition: plat_dimm.c:436