OpenBIC
OpenSource Bridge-IC
plat_power_seq.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_PWRSEQ_H
18#define PLAT_PWRSEQ_H
19
20#include "hal_gpio.h"
21#include "plat_gpio.h"
22
23#define MAX_E1S_IDX 5
24#define MAX_PWR_ON_DATA 10
25#define MAX_PWR_OFF_DATA 10
26#define OPA_MAX_E1S_IDX 3
27#define ALL_E1S 0xFF
28#define POWER_SEQ_CTRL_STACK_SIZE 1000
29#define CHKPWR_DELAY_MSEC 100
30#define RETIMER_DELAY_MSEC 2000
31#define DEV_RESET_DELAY_USEC 100
32#define PWR_INIT_DATA 0xFF
33
39};
40
52};
53
65};
66
70 CHECK_POWER_SEQ_03 = OPA_PWRGD_P1V8_VR,
71 CHECK_POWER_SEQ_04 = OPA_PWRGD_P0V9_VR,
72 CHECK_POWER_SEQ_05 = OPA_PWRGD_EXP_PWR,
73 CHECK_POWER_SEQ_06 = OPA_CLKBUF_RTM_OE_N,
74 CHECK_POWER_SEQ_07 = OPA_RESET_BIC_RTM_N,
75 CHECK_POWER_SEQ_08 = OPA_PERST_BIC_RTM_N,
76};
77
82};
83
84typedef enum {
88
90 uint8_t present;
95 uint8_t clkbuf_oe_en;
99
102
103bool get_e1s_present(uint8_t index);
104bool get_e1s_power_good(uint8_t index);
106uint8_t get_e1s_pcie_reset_status(uint8_t index);
108void set_sequence_status(uint8_t index, bool status);
109bool is_all_sequence_done(uint8_t status);
110bool is_retimer_done(void);
111void abort_e1s_power_thread(uint8_t index);
112void e1s_power_on_thread(uint8_t index, uint8_t initial_stage);
113void e1s_power_off_thread(uint8_t index);
114void control_power_on_sequence(void *initial_stage, void *arvg0, void *arvg1);
116void control_power_stage(uint8_t control_mode, uint8_t control_seq);
117int check_power_stage(uint8_t check_mode, uint8_t check_seq);
118bool e1s_power_on_handler(uint8_t initial_stage, e1s_power_control_gpio *e1s_gpio,
119 uint8_t device_index);
120bool e1s_power_off_handler(uint8_t initial_stage, e1s_power_control_gpio *e1s_gpio,
121 uint8_t device_index);
122bool power_on_handler(uint8_t initial_stage);
123bool power_off_handler(uint8_t initial_stage);
124bool notify_cpld_e1s_present(uint8_t index, uint8_t present);
128
129#endif
uint8_t status
Definition: mctp_ctrl.h:1
#define PWRGD_P12V_MAIN
Definition: plat_gpio.h:474
#define FM_EXP_MAIN_PWR_EN
Definition: plat_gpio.h:473
void control_power_on_sequence(void *initial_stage, void *arvg0, void *arvg1)
Definition: plat_power_seq.c:1354
void control_power_stage(uint8_t control_mode, uint8_t control_seq)
Definition: plat_power_seq.c:305
void control_power_off_sequence()
Definition: plat_power_seq.c:1368
void e1s_power_off_thread(uint8_t index)
Definition: plat_power_seq.c:792
POWER_HANDLER_STATUS
Definition: plat_power_seq.h:78
@ POWER_HANDLER_DONE
Definition: plat_power_seq.h:79
@ POWER_ON_HANDLER
Definition: plat_power_seq.h:80
@ POWER_OFF_HANDLER
Definition: plat_power_seq.h:81
bool power_on_handler(uint8_t initial_stage)
Definition: plat_power_seq.c:880
void set_sequence_status(uint8_t index, bool status)
POWER_OFF_STAGE
Definition: plat_power_seq.h:54
@ RETIMER_POWER_OFF_STAGE0
Definition: plat_power_seq.h:59
@ E1S_POWER_OFF_STAGE3
Definition: plat_power_seq.h:58
@ E1S_POWER_OFF_STAGE2
Definition: plat_power_seq.h:57
@ BOARD_POWER_OFF_STAGE0
Definition: plat_power_seq.h:62
@ RETIMER_POWER_OFF_STAGE2
Definition: plat_power_seq.h:61
@ BOARD_POWER_OFF_STAGE1
Definition: plat_power_seq.h:63
@ RETIMER_POWER_OFF_STAGE1
Definition: plat_power_seq.h:60
@ E1S_POWER_OFF_STAGE1
Definition: plat_power_seq.h:56
@ E1S_POWER_OFF_STAGE0
Definition: plat_power_seq.h:55
@ BOARD_POWER_OFF_STAGE2
Definition: plat_power_seq.h:64
void init_sequence_status()
Definition: plat_power_seq.c:214
struct _e1s_power_control_gpio e1s_power_control_gpio
void e1s_power_on_thread(uint8_t index, uint8_t initial_stage)
Definition: plat_power_seq.c:763
bool notify_cpld_e1s_present(uint8_t index, uint8_t present)
Definition: plat_power_seq.c:356
bool e1s_power_off_handler(uint8_t initial_stage, e1s_power_control_gpio *e1s_gpio, uint8_t device_index)
Definition: plat_power_seq.c:589
void abort_cpu_perst_low_thread()
Definition: plat_power_seq.c:854
e1s_power_control_gpio opa_e1s_power_control_gpio[]
Definition: plat_power_seq.c:60
bool is_retimer_done(void)
Definition: plat_power_seq.c:300
bool get_edge_power_good()
Definition: plat_power_seq.c:175
uint8_t get_e1s_pcie_reset_status(uint8_t index)
Definition: plat_power_seq.c:195
CONTROL_POWER_MODE
Definition: plat_power_seq.h:34
@ DISABLE_POWER_MODE
Definition: plat_power_seq.h:37
@ HIGH_DISABLE_POWER_MODE
Definition: plat_power_seq.h:38
@ ENABLE_POWER_MODE
Definition: plat_power_seq.h:35
@ LOW_ENABLE_POWER_MODE
Definition: plat_power_seq.h:36
bool e1s_power_on_handler(uint8_t initial_stage, e1s_power_control_gpio *e1s_gpio, uint8_t device_index)
Definition: plat_power_seq.c:440
bool power_off_handler(uint8_t initial_stage)
Definition: plat_power_seq.c:1160
e1s_power_control_gpio opb_e1s_power_control_gpio[]
Definition: plat_power_seq.c:87
POWER_ON_STAGE
Definition: plat_power_seq.h:41
@ RETIMER_POWER_ON_STAGE0
Definition: plat_power_seq.h:45
@ E1S_POWER_ON_STAGE2
Definition: plat_power_seq.h:50
@ RETIMER_POWER_ON_STAGE2
Definition: plat_power_seq.h:47
@ BOARD_POWER_ON_STAGE1
Definition: plat_power_seq.h:43
@ E1S_POWER_ON_STAGE1
Definition: plat_power_seq.h:49
@ BOARD_POWER_ON_STAGE2
Definition: plat_power_seq.h:44
@ E1S_POWER_ON_STAGE3
Definition: plat_power_seq.h:51
@ E1S_POWER_ON_STAGE0
Definition: plat_power_seq.h:48
@ RETIMER_POWER_ON_STAGE1
Definition: plat_power_seq.h:46
@ BOARD_POWER_ON_STAGE0
Definition: plat_power_seq.h:42
bool is_all_sequence_done(uint8_t status)
Definition: plat_power_seq.c:257
bool get_e1s_power_good(uint8_t index)
Definition: plat_power_seq.c:153
E1S_POWER_ON_STATUS
Definition: plat_power_seq.h:84
@ E1S_PERST_SUCCESS
Definition: plat_power_seq.h:86
@ E1S_POWER_SUCCESS
Definition: plat_power_seq.h:85
void cpu_perst_low_thread()
Definition: plat_power_seq.c:862
void abort_e1s_power_thread(uint8_t index)
Definition: plat_power_seq.c:755
CHECK_POWER_SEQ_NUM_MAPPING
Definition: plat_power_seq.h:67
@ CHECK_POWER_SEQ_03
Definition: plat_power_seq.h:70
@ CHECK_POWER_SEQ_01
Definition: plat_power_seq.h:68
@ CHECK_POWER_SEQ_06
Definition: plat_power_seq.h:73
@ CHECK_POWER_SEQ_05
Definition: plat_power_seq.h:72
@ CHECK_POWER_SEQ_07
Definition: plat_power_seq.h:74
@ CHECK_POWER_SEQ_02
Definition: plat_power_seq.h:69
@ CHECK_POWER_SEQ_08
Definition: plat_power_seq.h:75
@ CHECK_POWER_SEQ_04
Definition: plat_power_seq.h:71
int get_power_handler_status()
Definition: plat_power_seq.c:1383
bool get_e1s_present(uint8_t index)
Definition: plat_power_seq.c:130
int check_power_stage(uint8_t check_mode, uint8_t check_seq)
Definition: plat_power_seq.c:326
Definition: plat_power_seq.h:89
uint8_t p12v_efuse_enable
Definition: plat_power_seq.h:91
uint8_t present
Definition: plat_power_seq.h:90
uint8_t cpu_pcie_reset
Definition: plat_power_seq.h:96
uint8_t clkbuf_oe_en
Definition: plat_power_seq.h:95
uint8_t p3v3_efuse_power_good
Definition: plat_power_seq.h:94
uint8_t p12v_efuse_power_good
Definition: plat_power_seq.h:92
uint8_t p3v3_efuse_enable
Definition: plat_power_seq.h:93
uint8_t e1s_pcie_reset
Definition: plat_power_seq.h:97