OpenBIC
OpenSource Bridge-IC
plat_cpld.h
Go to the documentation of this file.
1#ifndef PLAT_CPLD_H
2#define PLAT_CPLD_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <stdint.h>
7#include <zephyr.h>
8
9// VR power fault registers
10#define VR_POWER_FAULT_1_REG 0x0D
11#define VR_POWER_FAULT_2_REG 0x0E
12#define VR_POWER_FAULT_3_REG 0x0F
13#define VR_POWER_FAULT_4_REG 0x10
14#define VR_POWER_FAULT_5_REG 0x11
15
16// ASIC fault registers
17#define LEAK_DETECT_REG 0x24
18#define VR_SMBUS_ALERT_EVENT_LOG_REG 0x26
19#define HBM_CATTRIP_REG 0x27
20#define SYSTEM_ALERT_FAULT_REG 0x28
21#define ASIC_TEMP_OVER_REG 0x29
22#define TEMP_IC_OVER_FAULT_REG 0x2A
23
24// CPLD VR hot registers
25#define ASIC_VR_HOT_SWITCH 0x12
26
27// TMP75 type thermal sensor alert register,
28// TMP432 handle by itself
29#define TMP75_ALERT_CPLD_OFFSET 0x2F
30
31// CPLD power steps on registers
32#define VR_AND_CLK_EN 0x3E
33#define VR_1_EN 0x3F
34#define VR_2_EN 0x40
35#define VR_3_EN 0x41
36#define VR_4_EN 0x42
37#define VR_AND_CLK_EN_PIN_CTRL 0xA1 // pin control (1-step only)
38#define VR_1STEP_FUNC_EN_REG 0xA9
39
40// CPLD power good status registers
41#define VR_PWRGD_PIN_READING_1_REG 0x07
42#define VR_PWRGD_PIN_READING_2_REG 0x08
43#define VR_PWRGD_PIN_READING_3_REG 0x09
44#define VR_PWRGD_PIN_READING_4_REG 0x0A
45#define VR_PWRGD_PIN_READING_5_REG 0x0B
46#define VR_PWRGD_PIN_READING_6_REG 0x0C
47
48// PDB1 power reading registers
49#define CPLD_POWER_INFO_0_REG 0xB6
50#define CPLD_POWER_INFO_1_REG 0xB7
51
52// Power sequence fail log registers, CPLD not ready
53#define PWRGD_EVENT_LATCH_1_REG 0xBE
54#define PWRGD_EVENT_LATCH_2_REG 0xBF
55#define PWRGD_EVENT_LATCH_3_REG 0xC0
56#define PWRGD_EVENT_LATCH_4_REG 0xC1
57#define PWRGD_EVENT_LATCH_5_REG 0xC2
58#define PWRGD_EVENT_LATCH_6_REG 0xC3
59
60// ASIC_THERMTRIP_TRIGGER_CAUSE log register
61#define HBM_CATTRIP_LOG_REG 0x27
62
63// CPLD bootstrap mapping and MFIO debug registers
64#define HAMSA_STRAP 0x16
65#define HAMSA_MFIO_REG 0x17
66#define HAMSA_CONTROL_IO 0x18
67#define HAMSA_JTAG_JTCE 0x19
68#define NUWA0_STRAP 0x1A
69#define NUWA0_CONTROL_IO 0x1B
70#define NUWA1_STRAP 0x1C
71#define NUWA1_CONTROL_IO 0x1D
72#define NUWA_MFIO_REG 0x1E
73#define NUWA_JTAG_JTCE 0x1F
74#define OWL_CONTROL_IO 0x20
75#define OWL_JTAG_SEL 0x21
76#define OWL_UART_SEL 0x22
77#define OWL_DVT_ENABLE 0x9E
78// (High -> OUT, Low -> IN)
79#define HAMSA_MFIO12_13_14_CTRL 0xB8
80#define NUWA_MFIO12_13_14_CTRL 0xB9
81#define HAMSA_MFIO12_13_14_INPUT 0xBA
82#define NUWA_MFIO12_13_14_INPUT 0xBB
83
84// CPLD platform info
85#define CPLD_OFFSET_BOARD_REV_ID 0x14
86#define CPLD_OFFSET_VR_VENDER_TYPE 0x15
87#define CPLD_OFFSET_ASIC_BOARD_ID 0x3C
88
89// CPLD power capping
90#define CPLD_OFFSET_POWER_CLAMP 0x25
91#define CPLD_OFFSET_POWER_CAPPING_LV1_TIME 0x36
92
93// power information from BMC reg
94#define CPLD_POWER_INFO_0_REG 0xB6
95#define CPLD_POWER_INFO_1_REG 0xB7
96
97// delay pcie perst
98#define CPLD_PERST_DELAY_0_REG 0x9D
99#define CPLD_PERST_DELAY_1_REG 0xB3
100#define CPLD_PERST_DELAY_2_REG 0xB4
101#define CPLD_PERST_DELAY_3_REG 0xB5
102
103// delay asic rst
104#define CPLD_OFFSET_ASIC_RST_DELAY 0xA4
105
106// delay module pg
107#define CPLD_OFFSET_MODULE_PG_DELAY 0xA5
108
109// strap_control_manual
110#define CPLD_OFFSE_MANUAL_CONTROL_STRAP 0xB2
111
112// Other CPLD registers
113#define CPLD_OFFSET_ASIC_RESET 0x00
114#define VR_EN_PIN_READING_5 0x05
115#define CPLD_OFFSET_USERCODE 0x32
116#define CPLD_OFFSET_MMC_PWR_EN 0x38
117#define ASIC_JTAG_MUX_SEL 0x39
118#define CPLD_OFFSET_ADC_IDX 0xA0
119#define CPLD_ASIC_RESET_STATUS_REG 0xA2
120
121typedef struct _cpld_info_ cpld_info;
122
123typedef struct _cpld_info_ {
124 uint8_t cpld_offset;
127 bool is_fault_log; // if true, check the value is defaut or not
128 uint8_t is_fault_bit_map; //flag for fault
129
130 /* is_send_bmc in electra */
131 bool send_to_bmc_flag; //flag for sending alert to bmc
132
133 //temp data for last polling
135
136 bool (*status_changed_cb)(cpld_info *, uint8_t *);
137
138 uint8_t bit_check_mask; //bit check mask
139
140} cpld_info;
141
142typedef struct {
143 const char *name;
144 uint8_t bit;
145 uint8_t offset;
147
148bool plat_read_cpld(uint8_t offset, uint8_t *data, uint8_t len);
149bool plat_write_cpld(uint8_t offset, uint8_t *data);
150bool set_cpld_bit(uint8_t cpld_offset, uint8_t bit, uint8_t value);
151void init_cpld_polling(void);
154void reset_error_log_states(uint8_t err_type);
155
156#endif
uint8_t data[]
Definition: isl69259.c:2
uint8_t status
Definition: mctp_ctrl.h:1
uint32_t offset
Definition: pldm_firmware_update.h:0
uint8_t reading[1]
Definition: pldm_monitor.h:3
struct _cpld_info_ cpld_info
Definition: plat_cpld.h:121
bool plat_write_cpld(uint8_t offset, uint8_t *data)
Definition: plat_cpld.c:31
void get_cpld_polling_power_info(int *reading)
Definition: plat_cpld.c:199
bool set_cpld_bit(uint8_t cpld_offset, uint8_t bit, uint8_t value)
Definition: plat_cpld.c:36
void set_cpld_polling_enable_flag(bool status)
Definition: plat_event.c:335
void init_cpld_polling(void)
Definition: plat_event.c:799
void reset_error_log_states(uint8_t err_type)
Definition: plat_event.c:447
bool plat_read_cpld(uint8_t offset, uint8_t *data, uint8_t len)
Definition: plat_cpld.c:26
Definition: plat_cpld.h:123
bool send_to_bmc_flag
Definition: plat_cpld.h:131
uint8_t last_polling_value
Definition: plat_cpld.h:134
uint8_t bit_check_mask
Definition: plat_cpld.h:138
bool(* status_changed_cb)(cpld_info *, uint8_t *)
Definition: plat_cpld.h:136
uint8_t dc_on_defaut
Definition: plat_cpld.h:126
uint8_t is_fault_bit_map
Definition: plat_cpld.h:128
uint8_t dc_off_defaut
Definition: plat_cpld.h:125
bool is_fault_log
Definition: plat_cpld.h:127
uint8_t cpld_offset
Definition: plat_cpld.h:124
Definition: plat_cpld.h:142
uint8_t bit
Definition: plat_cpld.h:144
const char * name
Definition: plat_cpld.h:143
uint8_t offset
Definition: plat_cpld.h:145