1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
8 #define ICE_NVM_CMD_READ 0x0000000B
9 #define ICE_NVM_CMD_WRITE 0x0000000C
11 /* NVM Access config bits */
12 #define ICE_NVM_CFG_MODULE_M MAKEMASK(0xFF, 0)
13 #define ICE_NVM_CFG_MODULE_S 0
14 #define ICE_NVM_CFG_FLAGS_M MAKEMASK(0xF, 8)
15 #define ICE_NVM_CFG_FLAGS_S 8
16 #define ICE_NVM_CFG_EXT_FLAGS_M MAKEMASK(0xF, 12)
17 #define ICE_NVM_CFG_EXT_FLAGS_S 12
18 #define ICE_NVM_CFG_ADAPTER_INFO_M MAKEMASK(0xFFFF, 16)
19 #define ICE_NVM_CFG_ADAPTER_INFO_S 16
21 /* NVM Read Get Driver Features */
22 #define ICE_NVM_GET_FEATURES_MODULE 0xE
23 #define ICE_NVM_GET_FEATURES_FLAGS 0xF
25 /* NVM Read/Write Mapped Space */
26 #define ICE_NVM_REG_RW_MODULE 0x0
27 #define ICE_NVM_REG_RW_FLAGS 0x1
30 struct ice_orom_civd_info {
31 u8 signature[4]; /* Must match ASCII '$CIV' characters */
32 u8 checksum; /* Simple modulo 256 sum of all structure bytes must equal 0 */
33 __le32 combo_ver; /* Combo Image Version number */
34 u8 combo_name_len; /* Length of the unicode combo image version string, max of 32 */
35 __le16 combo_name[32]; /* Unicode string representing the Combo Image version */
40 #define ICE_NVM_ACCESS_MAJOR_VER 0
41 #define ICE_NVM_ACCESS_MINOR_VER 5
43 /* NVM Access feature flags. Other bits in the features field are reserved and
44 * should be set to zero when reporting the ice_nvm_features structure.
46 #define ICE_NVM_FEATURES_0_REG_ACCESS BIT(1)
48 /* NVM Access Features */
49 struct ice_nvm_features {
50 u8 major; /* Major version (informational only) */
51 u8 minor; /* Minor version (informational only) */
52 u16 size; /* size of ice_nvm_features structure */
53 u8 features[12]; /* Array of feature bits */
56 /* NVM Access command */
57 struct ice_nvm_access_cmd {
58 u32 command; /* NVM command: READ or WRITE */
59 u32 config; /* NVM command configuration */
60 u32 offset; /* offset to read/write, in bytes */
61 u32 data_size; /* size of data field, in bytes */
65 union ice_nvm_access_data {
66 u32 regval; /* Storage for register value */
67 struct ice_nvm_features drv_features; /* NVM features */
70 /* NVM Access registers */
71 #define GL_HIDA(_i) (0x00082000 + ((_i) * 4))
72 #define GL_HIBA(_i) (0x00081000 + ((_i) * 4))
73 #define GL_HICR 0x00082040
74 #define GL_HICR_EN 0x00082044
75 #define GLGEN_CSR_DEBUG_C 0x00075750
76 #define GLPCI_LBARCTRL 0x0009DE74
77 #define GLNVM_GENS 0x000B6100
78 #define GLNVM_FLA 0x000B6108
80 #define ICE_NVM_ACCESS_GL_HIDA_MAX 15
81 #define ICE_NVM_ACCESS_GL_HIBA_MAX 1023
83 u32 ice_nvm_access_get_module(struct ice_nvm_access_cmd *cmd);
84 u32 ice_nvm_access_get_flags(struct ice_nvm_access_cmd *cmd);
85 u32 ice_nvm_access_get_adapter(struct ice_nvm_access_cmd *cmd);
87 ice_nvm_access_read(struct ice_hw *hw, struct ice_nvm_access_cmd *cmd,
88 union ice_nvm_access_data *data);
90 ice_nvm_access_write(struct ice_hw *hw, struct ice_nvm_access_cmd *cmd,
91 union ice_nvm_access_data *data);
93 ice_nvm_access_get_features(struct ice_nvm_access_cmd *cmd,
94 union ice_nvm_access_data *data);
96 ice_handle_nvm_access(struct ice_hw *hw, struct ice_nvm_access_cmd *cmd,
97 union ice_nvm_access_data *data);
99 ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access);
100 void ice_release_nvm(struct ice_hw *hw);
102 ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, u16 length,
103 void *data, bool last_command, bool read_shadow_ram,
104 struct ice_sq_cd *cd);
106 ice_read_flat_nvm(struct ice_hw *hw, u32 offset, u32 *length, u8 *data,
107 bool read_shadow_ram);
109 ice_get_pfa_module_tlv(struct ice_hw *hw, u16 *module_tlv, u16 *module_tlv_len,
112 ice_get_inactive_orom_ver(struct ice_hw *hw, struct ice_orom_info *orom);
114 ice_read_pba_string(struct ice_hw *hw, u8 *pba_num, u32 pba_num_size);
115 enum ice_status ice_init_nvm(struct ice_hw *hw);
116 enum ice_status ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data);
118 ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words, u16 *data);
119 enum ice_status ice_nvm_validate_checksum(struct ice_hw *hw);
120 #endif /* _ICE_NVM_H_ */