OpenBIC
OpenSource Bridge-IC
plat_cpld.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_CPLD_H
18#define PLAT_CPLD_H
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <stdint.h>
23#include <stdbool.h>
24#include <zephyr.h>
25
26#define RESET 0x00
27#define VR_EN_PIN_READING_5 0x05
28#define CPLD_OFFSET_BOARD_REV_ID 0x14
29#define CPLD_OFFSET_VR_VENDER_TYPE 0x15
30#define CPLD_OFFSET_POWER_CLAMP 0x25
31#define CPLD_OFFSET_USERCODE 0x32
32#define CPLD_OFFSET_POWER_CAPPING_LV1_TIME 0x36
33#define CPLD_OFFSET_MMC_PWR_EN 0x38
34#define CPLD_OFFSET_ASIC_BOARD_ID 0x3C
35#define CPLD_OFFSET_ADC_IDX 0xA0
36#define CPLD_OFFSET_ASIC_RST_DELAY 0xA4
37#define CPLD_OFFSET_MODULE_PG_DELAY 0xA5
38#define VR_AND_CLK_EN 0x3E
39#define VR_1_EN 0x3F
40#define VR_2_EN 0x40
41#define VR_3_EN 0x41
42#define VR_4_EN 0x42
43#define CPLD_HAMSA_PCIE0_PERST_DELAY_REG 0x9D
44#define CPLD_HAMSA_PCIE1_PERST_DELAY_REG 0xB3
45#define CPLD_HAMSA_PCIE2_PERST_DELAY_REG 0xB4
46#define CPLD_HAMSA_PCIE3_PERST_DELAY_REG 0xB5
47#define CPLD_POWER_INFO_0_REG 0xB6
48#define CPLD_POWER_INFO_1_REG 0xB7
49#define PREST_DELAY_REG 0x9D
50#define VR_SMBUS_ALERT_EVENT_LOG_REG 0x26
51#define HAMSA_MFIO_REG 0x17
52#define VR_AND_CLK_EN_PIN_CTRL 0xA1
53#define ASIC_VR_HOT_SWITCH 0x12
54#define ASIC_JTAG_MUX_SEL 0x39
55#define ASIC_VQPS 0x13
56#define VR_PWRGD_PIN_READING_1_REG 0x07
57#define VR_PWRGD_PIN_READING_2_REG 0x08
58#define VR_PWRGD_PIN_READING_3_REG 0x09
59#define VR_PWRGD_PIN_READING_4_REG 0x0A
60#define VR_PWRGD_PIN_READING_5_REG 0x0B
61#define VR_PWRGD_PIN_READING_6_REG 0x0C
62#define VR_CLK_ENABLE_PIN_CTRL_REG 0xA1 // pin control (1-step only)
63#define CPLD_ASIC_RESET_STATUS_REG 0xA2
64#define VR_1STEP_FUNC_EN_REG 0xA9
65#define HBM_CATTRIP_LOG_REG 0x27
66#define ASIC_TEMP_OVER_LOG_REG 0x29
67#define PWRGD_EVENT_LATCH_1_REG 0xBE
68#define PWRGD_EVENT_LATCH_2_REG 0xBF
69#define PWRGD_EVENT_LATCH_3_REG 0xC0
70#define PWRGD_EVENT_LATCH_4_REG 0xC1
71#define PWRGD_EVENT_LATCH_5_REG 0xC2
72#define PWRGD_EVENT_LATCH_6_REG 0xC3
73
74#define CPLD_ADDR (0x4C >> 1)
75#define I2C_BUS_CPLD I2C_BUS11
76typedef struct _cpld_info_ cpld_info;
77
78typedef struct _cpld_info_ {
79 uint8_t cpld_offset;
81 uint8_t dc_on_defaut;
82 bool is_fault_log; // if true, check the value is defaut or not
83 uint8_t is_fault_bit_map; //flag for fault
84
85 //flag for 1st polling
86 const bool is_send_bmc;
87
88 //temp data for last polling
90
91 bool (*status_changed_cb)(cpld_info *, uint8_t *);
92
93 uint8_t bit_check_mask; //bit check mask
94
95} cpld_info;
96
97typedef struct {
98 const char *name;
99 uint8_t bit;
100 uint8_t offset;
102
103void check_ubc_delayed(struct k_work *work);
105bool plat_read_cpld(uint8_t offset, uint8_t *data, uint8_t len);
106bool plat_write_cpld(uint8_t offset, uint8_t *data);
107void init_cpld_polling(void);
109void check_ubc_delayed_timer_handler(struct k_timer *timer);
110bool set_cpld_bit(uint8_t cpld_offset, uint8_t bit, uint8_t value);
114void reset_error_log_states(uint8_t err_type);
115struct k_timer *get_ubc_delaytimer();
116#endif
uint8_t data[]
Definition: isl69259.c:2
uint8_t status
Definition: mctp_ctrl.h:1
struct _cpld_info_ cpld_info
Definition: plat_cpld.h:76
void give_all_vr_pm_alert_sem()
Definition: plat_cpld.c:212
void check_ubc_delayed(struct k_work *work)
Definition: plat_event.c:347
void check_ubc_delayed_timer_handler(struct k_timer *timer)
Definition: plat_event.c:53
void check_cpld_polling_alert_status(void)
Definition: plat_event.c:330
bool plat_write_cpld(uint8_t offset, uint8_t *data)
Definition: plat_cpld.c:48
bool is_ubc_enabled_delayed_enabled(void)
Definition: plat_event.c:437
void get_cpld_polling_power_info(int *reading)
Definition: plat_cpld.c:112
struct k_timer * get_ubc_delaytimer()
Definition: plat_cpld.c:64
bool set_cpld_bit(uint8_t cpld_offset, uint8_t bit, uint8_t value)
Definition: plat_cpld.c:398
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:43
uint32_t offset
Definition: pldm_firmware_update.h:0
uint8_t reading[1]
Definition: pldm_monitor.h:3
Definition: plat_cpld.h:78
uint8_t last_polling_value
Definition: plat_cpld.h:89
const bool is_send_bmc
Definition: plat_cpld.h:86
uint8_t bit_check_mask
Definition: plat_cpld.h:93
uint8_t dc_on_defaut
Definition: plat_cpld.h:81
uint8_t is_fault_bit_map
Definition: plat_cpld.h:83
uint8_t dc_off_defaut
Definition: plat_cpld.h:80
bool(* status_changed_cb)(cpld_info *, uint8_t *)
Definition: plat_cpld.h:91
bool is_fault_log
Definition: plat_cpld.h:82
uint8_t cpld_offset
Definition: plat_cpld.h:79
Definition: plat_cpld.h:97
uint8_t bit
Definition: plat_cpld.h:99
const char * name
Definition: plat_cpld.h:98
uint8_t offset
Definition: plat_cpld.h:100