Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * Various NB initialization services |
| 6 | * |
| 7 | * |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: GNB |
| 12 | * @e \$Revision: 39275 $ @e \$Date: 2010-10-09 08:22:05 +0800 (Sat, 09 Oct 2010) $ |
| 13 | * |
| 14 | */ |
| 15 | /* |
| 16 | ***************************************************************************** |
| 17 | * |
| 18 | * Copyright (c) 2011, Advanced Micro Devices, Inc. |
| 19 | * All rights reserved. |
Edward O'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 20 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 21 | * Redistribution and use in source and binary forms, with or without |
| 22 | * modification, are permitted provided that the following conditions are met: |
| 23 | * * Redistributions of source code must retain the above copyright |
| 24 | * notice, this list of conditions and the following disclaimer. |
| 25 | * * Redistributions in binary form must reproduce the above copyright |
| 26 | * notice, this list of conditions and the following disclaimer in the |
| 27 | * documentation and/or other materials provided with the distribution. |
Edward O'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 28 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 29 | * its contributors may be used to endorse or promote products derived |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 30 | * from this software without specific prior written permission. |
Edward O'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 31 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 35 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 36 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 37 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 38 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 39 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 40 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 41 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Edward O'Callaghan | e963b38 | 2014-07-06 19:27:14 +1000 | [diff] [blame] | 42 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 43 | * *************************************************************************** |
| 44 | * |
| 45 | */ |
| 46 | #ifndef _NBSMULIB_H_ |
| 47 | #define _NBSMULIB_H_ |
| 48 | |
| 49 | |
| 50 | #define SMU_EXT_SERVICE_FLAGS_POLL_ACK 0x1 |
| 51 | #define SMU_EXT_SERVICE_FLAGS_POLL_DONE 0x2 |
| 52 | #define SMU_GMM_TO_FCR(GmmReg) ((GmmReg >> 2) | 0xFF300000) |
| 53 | |
| 54 | #pragma pack (push, 1) |
| 55 | /// SMU Register Entry |
| 56 | typedef struct { |
| 57 | UINT16 Reg; ///< Register address |
| 58 | UINT32 Value; ///< Register data |
| 59 | } SMU_REGISTER_ENTRY; |
| 60 | |
| 61 | /// SMU Firmware revision |
| 62 | typedef struct { |
| 63 | UINT16 MajorRev; ///< Major revision |
| 64 | UINT16 MinorRev; ///< Minor revision |
| 65 | } SMU_FIRMWARE_REV; |
| 66 | |
| 67 | /// Firmware block |
| 68 | typedef struct { |
| 69 | UINT16 Address; ///< Block Address |
| 70 | UINT16 Length; ///< Block length in DWORD |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 71 | CONST UINT32 *Data; ///< Pointer to data array |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 72 | } SMU_FIRMWARE_BLOCK; |
| 73 | |
| 74 | /// Firmware header |
| 75 | typedef struct { |
| 76 | SMU_FIRMWARE_REV Revision; ///< Revision info |
| 77 | UINT16 NumberOfBlock; ///< Number of blocks |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 78 | CONST SMU_FIRMWARE_BLOCK *BlockArray; ///< Pointer to block definition array |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 79 | } SMU_FIRMWARE_HEADER; |
| 80 | |
| 81 | /// SMU indirect register write data context |
| 82 | typedef struct { |
| 83 | UINT8 Address; ///< SMU indirect register address |
| 84 | ACCESS_WIDTH Width; ///< SMU indirect register width |
| 85 | UINT32 Value; ///< Value |
| 86 | } SMU_INDIRECT_WRITE_DATA; |
| 87 | #pragma pack (pop) |
| 88 | |
| 89 | VOID |
| 90 | NbSmuIndirectRead ( |
| 91 | IN UINT8 Address, |
| 92 | IN ACCESS_WIDTH Width, |
| 93 | OUT VOID *Value, |
| 94 | IN AMD_CONFIG_PARAMS *StdHeader |
| 95 | ); |
| 96 | |
| 97 | VOID |
| 98 | NbSmuIndirectPoll ( |
| 99 | IN UINT8 Address, |
| 100 | IN ACCESS_WIDTH Width, |
| 101 | IN UINT32 Mask, |
| 102 | IN UINT32 CompateData, |
| 103 | IN AMD_CONFIG_PARAMS *StdHeader |
| 104 | ); |
| 105 | |
| 106 | VOID |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 107 | NbSmuIndirectWriteEx ( |
| 108 | IN UINT8 Address, |
| 109 | IN ACCESS_WIDTH Width, |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 110 | CONST IN VOID *Value, |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 111 | IN AMD_CONFIG_PARAMS *StdHeader |
| 112 | ); |
| 113 | |
| 114 | VOID |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 115 | NbSmuIndirectWrite ( |
| 116 | IN UINT8 Address, |
| 117 | IN ACCESS_WIDTH Width, |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 118 | CONST IN VOID *Value, |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 119 | IN AMD_CONFIG_PARAMS *StdHeader |
| 120 | ); |
| 121 | |
| 122 | VOID |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 123 | NbSmuIndirectWriteS3Script ( |
| 124 | IN AMD_CONFIG_PARAMS *StdHeader, |
| 125 | IN UINT16 ContextLength, |
| 126 | IN VOID* Context |
| 127 | ); |
| 128 | |
| 129 | VOID |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 130 | NbSmuRcuRegisterWrite ( |
| 131 | IN UINT16 Address, |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 132 | CONST IN UINT32 *Value, |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 133 | IN UINT32 Count, |
| 134 | IN BOOLEAN S3Save, |
| 135 | IN AMD_CONFIG_PARAMS *StdHeader |
| 136 | ); |
| 137 | |
| 138 | VOID |
| 139 | NbSmuRcuRegisterRead ( |
| 140 | IN UINT16 Address, |
| 141 | OUT UINT32 *Value, |
| 142 | IN UINT32 Count, |
| 143 | IN AMD_CONFIG_PARAMS *StdHeader |
| 144 | ); |
| 145 | |
| 146 | VOID |
| 147 | NbSmuSrbmRegisterRead ( |
| 148 | IN UINT32 Address, |
| 149 | OUT UINT32 *Value, |
| 150 | IN AMD_CONFIG_PARAMS *StdHeader |
| 151 | ); |
| 152 | |
| 153 | VOID |
| 154 | NbSmuSrbmRegisterWrite ( |
| 155 | IN UINT32 Address, |
| 156 | IN UINT32 *Value, |
| 157 | IN BOOLEAN S3Save, |
| 158 | IN AMD_CONFIG_PARAMS *StdHeader |
| 159 | ); |
| 160 | |
| 161 | VOID |
| 162 | NbSmuServiceRequestEx ( |
| 163 | IN UINT8 RequestId, |
| 164 | IN UINT8 Flags, |
| 165 | IN AMD_CONFIG_PARAMS *StdHeader |
| 166 | ); |
| 167 | |
| 168 | VOID |
| 169 | NbSmuServiceRequest ( |
| 170 | IN UINT8 RequestId, |
| 171 | IN BOOLEAN S3Save, |
| 172 | IN AMD_CONFIG_PARAMS *StdHeader |
| 173 | ); |
| 174 | |
| 175 | VOID |
| 176 | NbSmuServiceRequestS3Script ( |
| 177 | IN AMD_CONFIG_PARAMS *StdHeader, |
| 178 | IN UINT16 ContextLength, |
| 179 | IN VOID* Context |
| 180 | ); |
| 181 | |
| 182 | UINT32 |
| 183 | NbSmuReadEfuse ( |
| 184 | IN UINT32 Address, |
| 185 | IN AMD_CONFIG_PARAMS *StdHeader |
| 186 | ); |
| 187 | |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 188 | UINT32 |
| 189 | NbSmuReadEfuseField ( |
| 190 | IN UINT8 Chain, |
| 191 | IN UINT16 Offset, |
| 192 | IN UINT8 Length, |
| 193 | IN AMD_CONFIG_PARAMS *StdHeader |
| 194 | ); |
| 195 | |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 196 | VOID |
| 197 | NbSmuFirmwareDownload ( |
Arthur Heymans | 704ccaf | 2022-05-16 14:55:46 +0200 | [diff] [blame] | 198 | CONST IN SMU_FIRMWARE_HEADER *Firmware, |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 199 | IN AMD_CONFIG_PARAMS *StdHeader |
| 200 | ); |
| 201 | |
| 202 | SMU_FIRMWARE_REV |
| 203 | NbSmuFirmwareRevision ( |
| 204 | IN AMD_CONFIG_PARAMS *StdHeader |
| 205 | ); |
| 206 | |
| 207 | #define SMI_FIRMWARE_REVISION(x) ((x.MajorRev << 16) | x.MinorRev) |
| 208 | #endif |