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 CPLD_OFFSET_BOARD_REV_ID 0x14
28#define CPLD_OFFSET_VR_VENDER_TYPE 0x15
29#define CPLD_OFFSET_POWER_CLAMP 0x25
30#define CPLD_OFFSET_USERCODE 0x32
31#define CPLD_OFFSET_MMC_PWR_EN 0x38
32#define CPLD_OFFSET_ASIC_BOARD_ID 0x3C
33#define CPLD_OFFSET_ADC_IDX 0xA0
34#define CPLD_OFFSET_ASIC_RST_DELAY 0xA4
35#define CPLD_OFFSET_MODULE_PG_DELAY 0xA5
36#define VR_AND_CLK_EN 0x3E
37#define VR_1_EN 0x3F
38#define VR_2_EN 0x40
39#define VR_3_EN 0x41
40#define VR_4_EN 0x42
41#define CPLD_HAMSA_PCIE0_PERST_DELAY_REG 0x9D
42#define CPLD_HAMSA_PCIE1_PERST_DELAY_REG 0xB3
43#define CPLD_HAMSA_PCIE2_PERST_DELAY_REG 0xB4
44#define CPLD_HAMSA_PCIE3_PERST_DELAY_REG 0xB5
45#define CPLD_POWER_INFO_0_REG 0xB6
46#define CPLD_POWER_INFO_1_REG 0xB7
47#define PREST_DELAY_REG 0x9D
48#define VR_SMBUS_ALERT_EVENT_LOG_REG 0x26
49#define HAMSA_MFIO_REG 0x17
50#define VR_AND_CLK_EN_PIN_CTRL 0xA1
51#define ASIC_VR_HOT_SWITCH 0x12
52#define ASIC_JTAG_MUX_SEL 0x39
53#define ASIC_VQPS 0x13
54#define VR_PWRGD_PIN_READING_1_REG 0x07
55#define VR_PWRGD_PIN_READING_2_REG 0x08
56#define VR_PWRGD_PIN_READING_3_REG 0x09
57#define VR_PWRGD_PIN_READING_4_REG 0x0A
58#define VR_PWRGD_PIN_READING_5_REG 0x0B
59#define VR_PWRGD_PIN_READING_6_REG 0x0C
60#define VR_CLK_ENABLE_PIN_CTRL_REG 0xA1 // pin control (1-step only)
61#define VR_1STEP_FUNC_EN_REG 0xA9
62
63#define CPLD_ADDR (0x4C >> 1)
64#define I2C_BUS_CPLD I2C_BUS11
65typedef struct _cpld_info_ cpld_info;
66
67typedef struct _cpld_info_ {
68 uint8_t cpld_offset;
70 uint8_t dc_on_defaut;
71 bool is_fault_log; // if true, check the value is defaut or not
72 uint8_t is_fault_bit_map; //flag for fault
73
74 //flag for 1st polling
76
77 //flag for 1st polling after changing DC status
79
80 //temp data for last polling
82
83 bool (*status_changed_cb)(cpld_info *, uint8_t *);
84
85 uint8_t bit_check_mask; //bit check mask
86
87 uint8_t event_type;
88
89} cpld_info;
90
91typedef struct {
92 const char *name;
93 uint8_t bit;
94 uint8_t offset;
96
97void check_ubc_delayed(struct k_work *work);
99bool plat_read_cpld(uint8_t offset, uint8_t *data, uint8_t len);
100bool plat_write_cpld(uint8_t offset, uint8_t *data);
101void init_cpld_polling(void);
103void check_ubc_delayed_timer_handler(struct k_timer *timer);
104bool set_cpld_bit(uint8_t cpld_offset, uint8_t bit, uint8_t value);
107#endif
uint8_t data[]
Definition: isl69259.c:2
struct _cpld_info_ cpld_info
Definition: plat_cpld.h:65
void give_all_vr_pm_alert_sem()
Definition: plat_cpld.c:218
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:42
bool is_ubc_enabled_delayed_enabled(void)
Definition: plat_event.c:437
void get_cpld_polling_power_info(int *reading)
Definition: plat_cpld.c:99
bool set_cpld_bit(uint8_t cpld_offset, uint8_t bit, uint8_t value)
Definition: plat_cpld.c:352
void init_cpld_polling(void)
Definition: plat_event.c:799
bool plat_read_cpld(uint8_t offset, uint8_t *data, uint8_t len)
Definition: plat_cpld.c:37
uint32_t offset
Definition: pldm_firmware_update.h:0
uint8_t reading[1]
Definition: pldm_monitor.h:3
Definition: plat_cpld.h:67
bool is_first_polling
Definition: plat_cpld.h:75
uint8_t last_polling_value
Definition: plat_cpld.h:81
bool is_first_polling_after_dc_change
Definition: plat_cpld.h:78
uint8_t bit_check_mask
Definition: plat_cpld.h:85
uint8_t dc_on_defaut
Definition: plat_cpld.h:70
uint8_t is_fault_bit_map
Definition: plat_cpld.h:72
uint8_t dc_off_defaut
Definition: plat_cpld.h:69
bool(* status_changed_cb)(cpld_info *, uint8_t *)
Definition: plat_cpld.h:83
bool is_fault_log
Definition: plat_cpld.h:71
uint8_t event_type
Definition: plat_cpld.h:87
uint8_t cpld_offset
Definition: plat_cpld.h:68
Definition: plat_cpld.h:91
uint8_t bit
Definition: plat_cpld.h:93
const char * name
Definition: plat_cpld.h:92
uint8_t offset
Definition: plat_cpld.h:94