OpenBIC
OpenSource Bridge-IC
plat_dev.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_DEV
18#define PLAT_DEV
19
20#include <stdint.h>
21#include "sensor.h"
22
23#define CLOCK_GEN_ADDR (0xD0 >> 1)
24#define FREYA_STATUS_BLOCK_OFFSET 0x00
25#define FREYA_STATUS_BLOCK_LENGTH 0x08
26#define FREYA_READY_STATUS_BIT BIT(6)
27#define FREYA_READY_STATUS_OFFSET 0x01
28#define FREYA_READY_STATUS_LENGTH 1
29#define NVME_TEMPERATURE_INDEX 3
30#define FREYA_MODULE_IDENTIFIER_BLOCK_OFFSET 0x20
31#define FREYA_MODULE_IDENTIFIER_BLOCK_LENGTH 0x37
32#define IS_FREYA_MODULE_IDENTIFIER_SUPPORT 0x01
33#define FREYA_MODULE_IDENTIFIER_OFFSET 0x01
34#define FREYA_MODULE_IDENTIFIER_LENGTH 1
35#define FREYA_FFI_OFFSET 0x2B
36#define FREYA_FFI_LENGTH 1
37#define FREYA_FIRMWARE_VERSION_BLOCK_OFFSET 0x68
38#define FREYA_FIRMWARE_VERSION_BLOCK_LENGTH 0x08
39#define FREYA_FIRMWARE_VERSION_OFFSET 0x02
40#define FREYA_FIRMWARE_VERSION_LENGTH 5
41#define FREYA_NOT_READY_RET_CODE -2
42#define FREYA_NOT_SUPPORT_MODULE_IDENTIFIER_RET_CODE -3
43#define WAIT_FIRMWARE_READY_DELAY_S 1
44#define UNKNOWN_TYPE 0xFF
45
46typedef struct _freya_fw_info {
49 uint8_t form_factor_info; // FFI
56
57typedef struct _freya_info {
63
64typedef struct _vr_fw_info {
65 uint8_t checksum[4];
67 uint8_t vendor;
68 bool is_init;
70
74 uint8_t device_type;
75 uint32_t error_status;
76 struct k_work_delayable add_sel_work;
78
82};
83
85 bool is_init;
87 uint8_t bus;
88 uint8_t addr;
89 uint8_t type;
90 uint8_t status;
91 uint8_t result;
92 uint8_t timeout_s;
93 struct k_work_delayable wait_firmware_work;
95
100 EXEC_STATUS_TIMEOUT, // Add for BIC trace exec status
102};
103
109};
110
115
116int get_boot1_complete_bit(uint8_t bus, uint8_t addr, uint8_t *bit);
117void clear_freya_cache_flag(uint8_t card_id);
119int get_freya_fw_info(uint8_t bus, uint8_t addr, freya_fw_info *fw_info);
120bool is_sw_ready(uint8_t sensor_num);
123void get_switch_error_status(uint8_t sensor_num, uint8_t bus, uint8_t addr, uint8_t index);
124bool init_vr_write_protect(uint8_t bus, uint8_t addr, uint8_t default_val);
125int atm_fw_update(uint8_t bus, uint8_t addr, uint32_t offset, uint8_t *msg_buf, uint16_t buf_len,
126 uint32_t image_size, bool is_end_package);
128
129#endif
switch_error_check_info sw_error_check_info[]
Definition: plat_dev.c:223
struct _vr_fw_info vr_fw_info
bool init_vr_write_protect(uint8_t bus, uint8_t addr, uint8_t default_val)
Definition: plat_dev.c:572
bool is_sw_ready(uint8_t sensor_num)
Definition: plat_dev.c:453
ATM_EXEC_RESULT
Definition: plat_dev.h:104
@ EXEC_RESULT_ABORTED
Definition: plat_dev.h:106
@ EXEC_RESULT_FAIL
Definition: plat_dev.h:107
@ EXEC_RESULT_DEFAULT
Definition: plat_dev.h:108
@ EXEC_RESULT_PASS
Definition: plat_dev.h:105
int get_boot1_complete_bit(uint8_t bus, uint8_t addr, uint8_t *bit)
Definition: plat_dev.c:650
struct _wait_fw_update_status_info wait_fw_update_status_info
wait_fw_update_status_info atm_wait_fw_info
void init_clk_gen_spread_spectrum_control_register()
Definition: plat_dev.c:1293
void get_switch_error_status(uint8_t sensor_num, uint8_t bus, uint8_t addr, uint8_t index)
Definition: plat_dev.c:543
struct _freya_fw_info freya_fw_info
FREYA_ID
Definition: plat_dev.h:79
@ FREYA_ID1
Definition: plat_dev.h:80
@ FREYA_ID2
Definition: plat_dev.h:81
void clear_sw_error_check_flag()
Definition: plat_dev.c:475
vr_fw_info cb_vr_fw_info
Definition: plat_dev.c:221
int get_freya_fw_info(uint8_t bus, uint8_t addr, freya_fw_info *fw_info)
Definition: plat_dev.c:266
int atm_fw_update(uint8_t bus, uint8_t addr, uint32_t offset, uint8_t *msg_buf, uint16_t buf_len, uint32_t image_size, bool is_end_package)
Definition: plat_dev.c:1118
freya_info accl_freya_info[]
Definition: plat_dev.c:206
struct _freya_info freya_info
ATM_EXEC_STATUS
Definition: plat_dev.h:96
@ EXEC_STATUS_RUNNING
Definition: plat_dev.h:98
@ EXEC_STATUS_DEFAULT
Definition: plat_dev.h:101
@ EXEC_STATUS_TIMEOUT
Definition: plat_dev.h:100
@ EXEC_STATUS_IDLE
Definition: plat_dev.h:97
@ EXEC_STATUS_COMPLETE
Definition: plat_dev.h:99
void clear_accl_cable_power_fault_flag()
Definition: plat_dev.c:258
void clear_freya_cache_flag(uint8_t card_id)
Definition: plat_dev.c:232
struct _switch_error_check_info switch_error_check_info
void init_sw_heartbeat_work()
Definition: plat_dev.c:467
uint8_t addr
Definition: isl69259.c:0
uint32_t offset
Definition: pldm_firmware_update.h:0
uint8_t sensor_num
Definition: storage_handler.h:6
Definition: plat_dev.h:46
uint8_t is_freya_ready
Definition: plat_dev.h:47
uint8_t minor_version
Definition: plat_dev.h:51
uint8_t additional_version
Definition: plat_dev.h:52
uint8_t major_version
Definition: plat_dev.h:50
uint8_t form_factor_info
Definition: plat_dev.h:49
uint8_t secondary_major_version
Definition: plat_dev.h:53
uint8_t secondary_minor_version
Definition: plat_dev.h:54
uint8_t is_module_identifier_support
Definition: plat_dev.h:48
Definition: plat_dev.h:57
freya_fw_info freya1_fw_info
Definition: plat_dev.h:60
bool is_cache_freya2_info
Definition: plat_dev.h:59
bool is_cache_freya1_info
Definition: plat_dev.h:58
freya_fw_info freya2_fw_info
Definition: plat_dev.h:61
Definition: plat_dev.h:71
bool is_init_work
Definition: plat_dev.h:73
uint8_t device_type
Definition: plat_dev.h:74
struct k_work_delayable add_sel_work
Definition: plat_dev.h:76
bool is_addsel
Definition: plat_dev.h:72
uint32_t error_status
Definition: plat_dev.h:75
Definition: plat_dev.h:64
bool is_init
Definition: plat_dev.h:68
uint8_t remaining_write
Definition: plat_dev.h:66
uint8_t vendor
Definition: plat_dev.h:67
uint8_t checksum[4]
Definition: plat_dev.h:65
Definition: plat_dev.h:84
uint8_t addr
Definition: plat_dev.h:88
struct k_work_delayable wait_firmware_work
Definition: plat_dev.h:93
uint8_t bus
Definition: plat_dev.h:87
bool is_work_done
Definition: plat_dev.h:86
bool is_init
Definition: plat_dev.h:85
uint8_t status
Definition: plat_dev.h:90
uint8_t timeout_s
Definition: plat_dev.h:92
uint8_t result
Definition: plat_dev.h:91
uint8_t type
Definition: plat_dev.h:89