OpenBIC
OpenSource Bridge-IC
plat_i2c_target.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_I2C_SLAVE_H
18#define PLAT_I2C_SLAVE_H
19
20#include <drivers/i2c.h>
21#include "hal_i2c_target.h"
22
23#define TARGET_ENABLE 1
24#define TARGET_DISABLE 0
25
26#endif
27
28// i2c target register
29#define SENSOR_INIT_DATA_0_REG 0x00
30#define SENSOR_INIT_DATA_1_REG 0x01
31#define SENSOR_READING_0_REG 0x02
32#define SENSOR_READING_1_REG 0x03
33#define SENSOR_READING_2_REG 0x04
34#define SENSOR_READING_3_REG 0x05
35#define INVENTORY_IDS_REG 0x06
36#define STRAP_CAPABILTITY_REG 0x08
37#define WRITE_STRAP_PIN_VALUE_REG 0x09
38#define I2C_BRIDGE_COMMAND_REG 0x40
39#define I2C_BRIDGE_COMMAND_STATUS_REG 0x41
40#define I2C_BRIDGE_COMMAND_RESPONSE_REG 0x42
41
42#define FRU_BOARD_PART_NUMBER_REG 0x60
43#define FRU_BOARD_SERIAL_NUMBER_REG 0x61
44#define FRU_BOARD_PRODUCT_NAME_REG 0x62
45#define FRU_BOARD_CUSTOM_DATA_1_REG 0x63
46#define FRU_BOARD_CUSTOM_DATA_2_REG 0x64
47#define FRU_BOARD_CUSTOM_DATA_3_REG 0x65
48#define FRU_BOARD_CUSTOM_DATA_4_REG 0x66
49#define FRU_BOARD_CUSTOM_DATA_5_REG 0x67
50#define FRU_BOARD_CUSTOM_DATA_6_REG 0x68
51#define FRU_BOARD_CUSTOM_DATA_7_REG 0x69
52#define FRU_BOARD_CUSTOM_DATA_8_REG 0x6A
53#define FRU_BOARD_CUSTOM_DATA_9_REG 0x6B
54#define FRU_BOARD_CUSTOM_DATA_10_REG 0x6C
55
56#define FRU_PRODUCT_NAME_REG 0x70
57#define FRU_PRODUCT_PART_NUMBER_REG 0x71
58#define FRU_PRODUCT_PART_VERSION_REG 0x72
59#define FRU_PRODUCT_SERIAL_NUMBER_REG 0x73
60#define FRU_PRODUCT_ASSET_TAG_REG 0x74
61#define FRU_PRODUCT_CUSTOM_DATA_1_REG 0x75
62#define FRU_PRODUCT_CUSTOM_DATA_2_REG 0x76
63
64#define CONTROL_VOL_VR_ASIC_P0V75_VDDPHY_HBM0246_REG 0x80
65#define CONTROL_VOL_VR_ASIC_P0V75_VDDPHY_HBM1357_REG 0x81
66#define CONTROL_VOL_VR_ASIC_P1V05_VDDC_HBM0246_REG 0x82
67#define CONTROL_VOL_VR_ASIC_P1V05_VDDC_HBM1357_REG 0x83
68#define CONTROL_VOL_VR_ASIC_P0V4_VDDQL_HBM0246_REG 0x84
69#define CONTROL_VOL_VR_ASIC_P0V4_VDDQL_HBM1357_REG 0x85
70#define CONTROL_VOL_VR_ASIC_P1V8_VPP_HBM0246_REG 0x86
71#define CONTROL_VOL_VR_ASIC_P1V8_VPP_HBM1357_REG 0x87
72#define CONTROL_VOL_VR_ASIC_P0V75_NUWA0_VDD_REG 0x88
73#define CONTROL_VOL_VR_ASIC_P0V75_NUWA1_VDD_REG 0x89
74#define LEVEL_1_PWR_ALERT_THRESHOLD_TIME_REG 0x90
75#define LEVEL_2_PWR_ALERT_THRESHOLD_TIME_REG 0x91
76#define LEVEL_3_PWR_ALERT_THRESHOLD_TIME_REG 0x92
77#define VR_POWER_READING_REG 0x93
78#define NUWA_SENSOR_VALUE_REG 0x94
79#define POWER_CAPPING_METHOD_REG 0x95
80#define NUWA_POWER_SOURCE_REG 0x96
81#define POLLING_RATE_TELEMETRY_REG 0x97
82#define TRAY_INFO_REG 0x98
83#define SET_THERMAL_THRESHOLD 0x62
84
85#define SET_SENSOR_POLLING_COMMAND_REG 0xF0
86
87// telemetry
89typedef struct _telemetry_info_ {
90 uint8_t telemetry_offset;
91 uint16_t data_size;
92 bool (*telemetry_table_init)(telemetry_info *, uint8_t *);
94
95typedef struct __attribute__((__packed__)) {
96 uint8_t device_type;
97 uint8_t register_layout_version;
98 uint8_t num_idx; //Number of PDR indexes in this register
99 uint8_t reserved_1;
100
101 uint16_t sbi; //Sensor base index (SBI= 248*R) used in this register's array
102 uint16_t max_pdr_idx; //Max PDR sensor index exported in total (MAX_PDRIDX)
103
104 uint8_t sensor_r_len[]; //sensor[0] reading length ~ sensor[247] reading length
106
107typedef struct __attribute__((__packed__)) {
108 uint8_t sensor_index_offset; // Sensor index offset (e.g. PDR sensor index offset)
109 uint32_t sensor_value; // Sensor value (4 bytes)
111
112typedef struct __attribute__((__packed__)) {
113 uint8_t device_type; // Device type (Aegis = 0x01, Rainbow = 0x02, Electra = 0x03, etc.)
114 uint8_t register_layout_version; // Register layout version (e.g. VERSION_1 = 0x01)
115 uint16_t sensor_base_index; // Sensor base index (SBI)
116 uint8_t max_sbi_off; // Max sensor base index offset in this register (0 <= MAX_SBI_OFF <= 49)
117 // The following is a flexible array of sensor entries.
118 // The number of entries is (max_sbi_off + 1)
119 sensor_entry sensor_entries[];
121
122typedef struct __attribute__((__packed__)) {
123 uint16_t carrier_board_id; // MTIA Gen1 - Aegis=0x00
124 uint32_t bic_fw_version;
125 uint32_t cpld_fw_version;
127
128typedef struct __attribute__((__packed__)) {
129 uint8_t strap_set_index;
130 uint8_t strap_set_value;
131 uint8_t strap_set_type;
132 // b7 No Drive-Input, b6 PushPull-Output, b5 OpenDrain-Output, b4-b3: Reserved,
133 // b2: DriveType(0:OpenDrain,1:PushPull), b1: Direction(0:output,1:input), b0: Reserved
135typedef struct __attribute__((__packed__)) {
136 uint8_t strap_data_length;
137 strap_entry strap_set_format[];
139
140typedef struct __attribute__((__packed__)) {
141 uint8_t data_length;
142 uint8_t fru_data[];
144
145typedef struct __attribute__((__packed__)) {
146 struct k_work work;
147 uint8_t bus; // 0 base (0,1,2,3,4,..)
148 uint8_t addr; // 7 bit addr
149 uint8_t read_len;
150 uint8_t write_len; // include data[0]
151 uint8_t data[]; // data[0]: offset
153
154typedef struct __attribute__((__packed__)) {
155 uint8_t data_status;
157
158typedef struct __attribute__((__packed__)) {
159 uint8_t data_length;
160 uint8_t response_data[];
162
168
169// command_reply_data_handle
170typedef struct voltage_rail_mapping_sensor {
171 uint8_t control_vol_reg;
172 uint8_t vr_rail_e;
174
180};
181
182typedef struct {
183 uint8_t index;
184 uint8_t i2c_bus;
186
187typedef struct __attribute__((__packed__)) {
188 struct k_work work;
189 uint8_t rail;
190 uint16_t set_value;
192typedef struct __attribute__((__packed__)) {
193 struct k_work work;
194 uint8_t lv;
195 uint8_t in_data[8];
197typedef struct __attribute__((__packed__)) {
198 struct k_work work;
199 uint8_t set_value;
201typedef struct __attribute__((__packed__)) {
202 struct k_work work;
203 uint8_t set_value;
205
206void update_sensor_reading_by_sensor_number(uint8_t sensor_number);
207int get_cached_sensor_reading_by_sensor_number(uint8_t sensor_number);
uint8_t data[]
Definition: isl69259.c:2
uint8_t addr
Definition: isl69259.c:0
void plat_telemetry_table_init(void)
Definition: plat_i2c_target.c:1128
void update_strap_capability_table(void)
Definition: plat_i2c_target.c:690
i2c_bridge_command_error
Definition: plat_i2c_target.h:87
@ I2C_BRIDGE_COMMAND_SUCCESS
Definition: plat_i2c_target.h:88
@ I2C_BRIDGE_COMMAND_IN_PROCESS
Definition: plat_i2c_target.h:89
@ I2C_BRIDGE_COMMAND_FAILURE
Definition: plat_i2c_target.h:90
struct _telemetry_info_ telemetry_info
Definition: plat_i2c_target.h:98
uint8_t set_value
Definition: pldm_oem.h:1
uint32_t data_length
Definition: pldm_oem.h:1
plat_fru_data
Definition: plat_i2c_target.h:143
plat_control_voltage
Definition: plat_i2c_target.h:191
plat_i2c_bridge_command_status
Definition: plat_i2c_target.h:156
plat_power_capping_threshold_time_t
Definition: plat_i2c_target.h:196
plat_control_sensor_polling
Definition: plat_i2c_target.h:204
plat_i2c_bridge_command_response_data
Definition: plat_i2c_target.h:161
plat_inventory_ids
Definition: plat_i2c_target.h:126
plat_sensor_init_data
Definition: plat_i2c_target.h:105
void update_sensor_reading_by_sensor_number(uint8_t sensor_number)
Definition: plat_i2c_target.c:190
strap_entry
Definition: plat_i2c_target.h:134
plat_power_capping_method_t
Definition: plat_i2c_target.h:200
struct voltage_rail_mapping_sensor voltage_rail_mapping_sensor
int get_cached_sensor_reading_by_sensor_number(uint8_t sensor_number)
Definition: plat_i2c_target.c:209
sensor_entry
Definition: plat_i2c_target.h:110
I2C_TARGET_BUS_IDX
Definition: plat_i2c_target.h:175
@ ASIC_I2C_BUS_IDX_MAX
Definition: plat_i2c_target.h:179
@ NUWA1_I2C_BUS_IDX
Definition: plat_i2c_target.h:178
@ HAMSA_I2C_BUS_IDX
Definition: plat_i2c_target.h:176
@ NUWA0_I2C_BUS_IDX
Definition: plat_i2c_target.h:177
plat_strap_capability
Definition: plat_i2c_target.h:138
plat_sensor_reading
Definition: plat_i2c_target.h:120
plat_i2c_bridge_command_config
Definition: plat_i2c_target.h:152
Definition: pldm_smbios.h:61
Definition: plat_i2c_target.h:100
uint16_t data_size
Definition: plat_i2c_target.h:102
uint8_t telemetry_offset
Definition: plat_i2c_target.h:101
bool(* telemetry_table_init)(telemetry_info *, uint8_t *)
Definition: plat_i2c_target.h:103
Definition: plat_i2c_target.h:182
uint8_t i2c_bus
Definition: plat_i2c_target.h:184
uint8_t index
Definition: plat_i2c_target.h:183
Definition: plat_i2c_target.c:144
uint8_t vr_rail_e
Definition: plat_i2c_target.c:146
uint8_t control_vol_reg
Definition: plat_i2c_target.c:145