Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (c) 2010 Matthias Wenzel <bios at mazzoo dot de> |
| 5 | * Copyright (c) 2011 Stefan Tauner |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
Thomas Heijligen | 3f4d35d | 2022-01-17 15:11:43 +0100 | [diff] [blame] | 18 | #include "hwaccess_physmap.h" |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 19 | #include "ich_descriptors.h" |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 20 | |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 21 | #ifdef ICH_DESCRIPTORS_FROM_DUMP_ONLY |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 22 | #include <stdio.h> |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 23 | #include <string.h> |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 24 | #define print(t, ...) printf(__VA_ARGS__) |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 25 | #endif |
| 26 | |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 27 | #define DESCRIPTOR_MODE_SIGNATURE 0x0ff0a55a |
| 28 | /* The upper map is located in the word before the 256B-long OEM section at the |
| 29 | * end of the 4kB-long flash descriptor. |
| 30 | */ |
| 31 | #define UPPER_MAP_OFFSET (4096 - 256 - 4) |
| 32 | #define getVTBA(flumap) (((flumap)->FLUMAP1 << 4) & 0x00000ff0) |
| 33 | |
Felix Singer | d68a0ec | 2022-08-19 03:23:35 +0200 | [diff] [blame] | 34 | #include <stdbool.h> |
Nico Huber | 4d440a7 | 2017-08-15 11:26:48 +0200 | [diff] [blame] | 35 | #include <sys/types.h> |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 36 | #include <string.h> |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 37 | #include "flash.h" /* for msg_* */ |
| 38 | #include "programmer.h" |
| 39 | |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 40 | ssize_t ich_number_of_regions(const enum ich_chipset cs, const struct ich_desc_content *const cont) |
| 41 | { |
| 42 | switch (cs) { |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 43 | case CHIPSET_APOLLO_LAKE: |
Angel Pons | 4db0fdf | 2020-07-10 17:04:10 +0200 | [diff] [blame] | 44 | case CHIPSET_GEMINI_LAKE: |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 45 | return 6; |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 46 | case CHIPSET_C620_SERIES_LEWISBURG: |
Nico Huber | 2a5dfaf | 2019-07-04 16:01:51 +0200 | [diff] [blame] | 47 | case CHIPSET_300_SERIES_CANNON_POINT: |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 48 | case CHIPSET_500_SERIES_TIGER_POINT: |
Werner Zeh | e57d4e4 | 2022-01-03 09:44:29 +0100 | [diff] [blame] | 49 | case CHIPSET_ELKHART_LAKE: |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 50 | return 16; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 51 | case CHIPSET_100_SERIES_SUNRISE_POINT: |
| 52 | return 10; |
| 53 | case CHIPSET_9_SERIES_WILDCAT_POINT_LP: |
| 54 | case CHIPSET_9_SERIES_WILDCAT_POINT: |
| 55 | case CHIPSET_8_SERIES_LYNX_POINT_LP: |
| 56 | case CHIPSET_8_SERIES_LYNX_POINT: |
| 57 | case CHIPSET_8_SERIES_WELLSBURG: |
| 58 | if (cont->NR <= 6) |
| 59 | return cont->NR + 1; |
| 60 | else |
| 61 | return -1; |
| 62 | default: |
| 63 | if (cont->NR <= 4) |
| 64 | return cont->NR + 1; |
| 65 | else |
| 66 | return -1; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | ssize_t ich_number_of_masters(const enum ich_chipset cs, const struct ich_desc_content *const cont) |
| 71 | { |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 72 | switch (cs) { |
| 73 | case CHIPSET_C620_SERIES_LEWISBURG: |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 74 | case CHIPSET_APOLLO_LAKE: |
Angel Pons | 4db0fdf | 2020-07-10 17:04:10 +0200 | [diff] [blame] | 75 | case CHIPSET_GEMINI_LAKE: |
Werner Zeh | e57d4e4 | 2022-01-03 09:44:29 +0100 | [diff] [blame] | 76 | case CHIPSET_ELKHART_LAKE: |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 77 | if (cont->NM <= MAX_NUM_MASTERS) |
| 78 | return cont->NM; |
Richard Hughes | db7482b | 2018-12-19 12:04:30 +0000 | [diff] [blame] | 79 | break; |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 80 | default: |
| 81 | if (cont->NM < MAX_NUM_MASTERS) |
| 82 | return cont->NM + 1; |
| 83 | } |
| 84 | |
| 85 | return -1; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 86 | } |
| 87 | |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 88 | void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity, bool print_vcl) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 89 | { |
| 90 | print(verbosity, "BES=0x%x, ", (reg_val & VSCC_BES) >> VSCC_BES_OFF); |
| 91 | print(verbosity, "WG=%d, ", (reg_val & VSCC_WG) >> VSCC_WG_OFF); |
| 92 | print(verbosity, "WSR=%d, ", (reg_val & VSCC_WSR) >> VSCC_WSR_OFF); |
| 93 | print(verbosity, "WEWS=%d, ", (reg_val & VSCC_WEWS) >> VSCC_WEWS_OFF); |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 94 | print(verbosity, "EO=0x%x", (reg_val & VSCC_EO) >> VSCC_EO_OFF); |
| 95 | if (print_vcl) |
| 96 | print(verbosity, ", VCL=%d", (reg_val & VSCC_VCL) >> VSCC_VCL_OFF); |
| 97 | print(verbosity, "\n"); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | #define getFCBA(cont) (((cont)->FLMAP0 << 4) & 0x00000ff0) |
| 101 | #define getFRBA(cont) (((cont)->FLMAP0 >> 12) & 0x00000ff0) |
| 102 | #define getFMBA(cont) (((cont)->FLMAP1 << 4) & 0x00000ff0) |
| 103 | #define getFISBA(cont) (((cont)->FLMAP1 >> 12) & 0x00000ff0) |
| 104 | #define getFMSBA(cont) (((cont)->FLMAP2 << 4) & 0x00000ff0) |
| 105 | |
Nico Huber | 67d7179 | 2017-06-17 03:10:15 +0200 | [diff] [blame] | 106 | void prettyprint_ich_chipset(enum ich_chipset cs) |
| 107 | { |
| 108 | static const char *const chipset_names[] = { |
| 109 | "Unknown ICH", "ICH8", "ICH9", "ICH10", |
| 110 | "5 series Ibex Peak", "6 series Cougar Point", "7 series Panther Point", |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 111 | "Baytrail", "8 series Lynx Point", "8 series Lynx Point LP", "8 series Wellsburg", |
Nico Huber | 67d7179 | 2017-06-17 03:10:15 +0200 | [diff] [blame] | 112 | "9 series Wildcat Point", "9 series Wildcat Point LP", "100 series Sunrise Point", |
Angel Pons | 4db0fdf | 2020-07-10 17:04:10 +0200 | [diff] [blame] | 113 | "C620 series Lewisburg", "300/400 series Cannon/Comet Point", |
Nico Huber | 29c23dd | 2022-12-21 15:25:09 +0000 | [diff] [blame] | 114 | "500/600 series Tiger/Alder Point", "Apollo Lake", "Gemini Lake", "Elkhart Lake", |
Nico Huber | 67d7179 | 2017-06-17 03:10:15 +0200 | [diff] [blame] | 115 | }; |
| 116 | if (cs < CHIPSET_ICH8 || cs - CHIPSET_ICH8 + 1 >= ARRAY_SIZE(chipset_names)) |
| 117 | cs = 0; |
| 118 | else |
| 119 | cs = cs - CHIPSET_ICH8 + 1; |
| 120 | msg_pdbg2("Assuming chipset '%s'.\n", chipset_names[cs]); |
| 121 | } |
| 122 | |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 123 | void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc) |
| 124 | { |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 125 | prettyprint_ich_descriptor_content(cs, &desc->content); |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 126 | prettyprint_ich_descriptor_component(cs, desc); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 127 | prettyprint_ich_descriptor_region(cs, desc); |
| 128 | prettyprint_ich_descriptor_master(cs, desc); |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 129 | #ifdef ICH_DESCRIPTORS_FROM_DUMP_ONLY |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 130 | if (cs >= CHIPSET_ICH8) { |
| 131 | prettyprint_ich_descriptor_upper_map(&desc->upper); |
| 132 | prettyprint_ich_descriptor_straps(cs, desc); |
| 133 | } |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 134 | #endif /* ICH_DESCRIPTORS_FROM_DUMP_ONLY */ |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 137 | void prettyprint_ich_descriptor_content(enum ich_chipset cs, const struct ich_desc_content *cont) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 138 | { |
| 139 | msg_pdbg2("=== Content Section ===\n"); |
| 140 | msg_pdbg2("FLVALSIG 0x%08x\n", cont->FLVALSIG); |
| 141 | msg_pdbg2("FLMAP0 0x%08x\n", cont->FLMAP0); |
| 142 | msg_pdbg2("FLMAP1 0x%08x\n", cont->FLMAP1); |
| 143 | msg_pdbg2("FLMAP2 0x%08x\n", cont->FLMAP2); |
| 144 | msg_pdbg2("\n"); |
| 145 | |
| 146 | msg_pdbg2("--- Details ---\n"); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 147 | msg_pdbg2("NR (Number of Regions): %5zd\n", ich_number_of_regions(cs, cont)); |
| 148 | msg_pdbg2("FRBA (Flash Region Base Address): 0x%03x\n", getFRBA(cont)); |
| 149 | msg_pdbg2("NC (Number of Components): %5d\n", cont->NC + 1); |
| 150 | msg_pdbg2("FCBA (Flash Component Base Address): 0x%03x\n", getFCBA(cont)); |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 151 | msg_pdbg2("ISL (ICH/PCH/SoC Strap Length): %5d\n", cont->ISL); |
| 152 | msg_pdbg2("FISBA/FPSBA (Flash ICH/PCH/SoC Strap Base Addr): 0x%03x\n", getFISBA(cont)); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 153 | msg_pdbg2("NM (Number of Masters): %5zd\n", ich_number_of_masters(cs, cont)); |
| 154 | msg_pdbg2("FMBA (Flash Master Base Address): 0x%03x\n", getFMBA(cont)); |
| 155 | msg_pdbg2("MSL/PSL (MCH/PROC Strap Length): %5d\n", cont->MSL); |
| 156 | msg_pdbg2("FMSBA (Flash MCH/PROC Strap Base Address): 0x%03x\n", getFMSBA(cont)); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 157 | msg_pdbg2("\n"); |
| 158 | } |
| 159 | |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 160 | static unsigned int get_density_index( |
| 161 | enum ich_chipset cs, const struct ich_descriptors *desc, unsigned int component) |
| 162 | { |
| 163 | if (cs < CHIPSET_HAS_NEW_COMPONENT_DENSITY) { |
| 164 | if (component == 0) |
| 165 | return desc->component.dens_old.comp1_density; |
| 166 | else |
| 167 | return desc->component.dens_old.comp2_density; |
| 168 | } else { |
| 169 | if (component == 0) |
| 170 | return desc->component.dens_new.comp1_density; |
| 171 | else |
| 172 | return desc->component.dens_new.comp2_density; |
| 173 | } |
| 174 | } |
| 175 | |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 176 | static const char *pprint_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx) |
| 177 | { |
| 178 | if (idx > 1) { |
| 179 | msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n"); |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 180 | return "unknown"; |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 181 | } |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 182 | if (cs == CHIPSET_ICH_UNKNOWN) |
| 183 | return "unknown"; |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 184 | |
| 185 | if (desc->content.NC == 0 && idx > 0) |
| 186 | return "unused"; |
| 187 | |
| 188 | static const char * const size_str[] = { |
| 189 | "512 kB", /* 0000 */ |
| 190 | "1 MB", /* 0001 */ |
| 191 | "2 MB", /* 0010 */ |
| 192 | "4 MB", /* 0011 */ |
| 193 | "8 MB", /* 0100 */ |
| 194 | "16 MB", /* 0101 */ /* Maximum up to Lynx Point (excl.) */ |
| 195 | "32 MB", /* 0110 */ |
| 196 | "64 MB", /* 0111 */ |
| 197 | }; |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 198 | const unsigned int max_idx = cs < CHIPSET_HAS_NEW_COMPONENT_DENSITY ? 5 : 7; |
| 199 | const unsigned int size_idx = get_density_index(cs, desc, idx); |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 200 | |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 201 | if (size_idx > max_idx) |
| 202 | return "reserved"; |
| 203 | |
| 204 | return size_str[size_idx]; |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | static const char *pprint_freq(enum ich_chipset cs, uint8_t value) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 208 | { |
Werner Zeh | e57d4e4 | 2022-01-03 09:44:29 +0100 | [diff] [blame] | 209 | static const char *const freq_str[5][8] = { { |
Nico Huber | 129e938 | 2019-06-06 15:43:27 +0200 | [diff] [blame] | 210 | "20 MHz", |
| 211 | "33 MHz", |
| 212 | "reserved", |
| 213 | "reserved", |
| 214 | "50 MHz", /* New since Ibex Peak */ |
| 215 | "reserved", |
| 216 | "reserved", |
| 217 | "reserved" |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 218 | }, { |
Nico Huber | 129e938 | 2019-06-06 15:43:27 +0200 | [diff] [blame] | 219 | "reserved", |
| 220 | "reserved", |
| 221 | "48 MHz", |
| 222 | "reserved", |
| 223 | "30 MHz", |
| 224 | "reserved", |
| 225 | "17 MHz", |
| 226 | "reserved" |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 227 | }, { |
| 228 | "reserved", |
| 229 | "50 MHz", |
| 230 | "40 MHz", |
| 231 | "reserved", |
| 232 | "25 MHz", |
| 233 | "reserved", |
| 234 | "14 MHz / 17 MHz", |
| 235 | "reserved" |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 236 | }, { |
| 237 | "100 MHz", |
| 238 | "50 MHz", |
| 239 | "reserved", |
| 240 | "33 MHz", |
| 241 | "25 MHz", |
| 242 | "reserved", |
| 243 | "14 MHz", |
| 244 | "reserved" |
Werner Zeh | e57d4e4 | 2022-01-03 09:44:29 +0100 | [diff] [blame] | 245 | }, { |
| 246 | "reserved", |
| 247 | "50 MHz", |
| 248 | "reserved", |
| 249 | "reserved", |
| 250 | "33 MHz", |
| 251 | "20 MHz", |
| 252 | "reserved", |
| 253 | "reserved", |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 254 | }}; |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 255 | |
| 256 | switch (cs) { |
| 257 | case CHIPSET_ICH8: |
| 258 | case CHIPSET_ICH9: |
| 259 | case CHIPSET_ICH10: |
| 260 | if (value > 1) |
| 261 | return "reserved"; |
Richard Hughes | db7482b | 2018-12-19 12:04:30 +0000 | [diff] [blame] | 262 | /* Fall through. */ |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 263 | case CHIPSET_5_SERIES_IBEX_PEAK: |
| 264 | case CHIPSET_6_SERIES_COUGAR_POINT: |
| 265 | case CHIPSET_7_SERIES_PANTHER_POINT: |
| 266 | case CHIPSET_8_SERIES_LYNX_POINT: |
Duncan Laurie | 4095ed7 | 2014-08-20 15:39:32 +0000 | [diff] [blame] | 267 | case CHIPSET_BAYTRAIL: |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 268 | case CHIPSET_8_SERIES_LYNX_POINT_LP: |
| 269 | case CHIPSET_8_SERIES_WELLSBURG: |
Duncan Laurie | 823096e | 2014-08-20 15:39:38 +0000 | [diff] [blame] | 270 | case CHIPSET_9_SERIES_WILDCAT_POINT: |
Nico Huber | 5120591 | 2017-03-17 17:59:54 +0100 | [diff] [blame] | 271 | case CHIPSET_9_SERIES_WILDCAT_POINT_LP: |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 272 | return freq_str[0][value]; |
| 273 | case CHIPSET_100_SERIES_SUNRISE_POINT: |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 274 | case CHIPSET_C620_SERIES_LEWISBURG: |
Nico Huber | 2a5dfaf | 2019-07-04 16:01:51 +0200 | [diff] [blame] | 275 | case CHIPSET_300_SERIES_CANNON_POINT: |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 276 | return freq_str[1][value]; |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 277 | case CHIPSET_APOLLO_LAKE: |
Angel Pons | 4db0fdf | 2020-07-10 17:04:10 +0200 | [diff] [blame] | 278 | case CHIPSET_GEMINI_LAKE: |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 279 | return freq_str[2][value]; |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 280 | case CHIPSET_500_SERIES_TIGER_POINT: |
| 281 | return freq_str[3][value]; |
Werner Zeh | e57d4e4 | 2022-01-03 09:44:29 +0100 | [diff] [blame] | 282 | case CHIPSET_ELKHART_LAKE: |
| 283 | return freq_str[4][value]; |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 284 | case CHIPSET_ICH_UNKNOWN: |
| 285 | default: |
| 286 | return "unknown"; |
| 287 | } |
| 288 | } |
| 289 | |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 290 | static void pprint_read_freq(enum ich_chipset cs, uint8_t value) |
| 291 | { |
| 292 | static const char *const freq_str[1][8] = { { |
| 293 | "20 MHz", |
| 294 | "24 MHz", |
| 295 | "30 MHz", |
| 296 | "48 MHz", |
| 297 | "60 MHz", |
| 298 | "reserved", |
| 299 | "reserved", |
| 300 | "reserved" |
| 301 | }}; |
| 302 | |
| 303 | switch (cs) { |
| 304 | case CHIPSET_300_SERIES_CANNON_POINT: |
| 305 | msg_pdbg2("eSPI/EC Bus Clock Frequency: %s\n", freq_str[0][value]); |
| 306 | return; |
| 307 | case CHIPSET_500_SERIES_TIGER_POINT: |
| 308 | msg_pdbg2("Read Clock Frequency: %s\n", "reserved"); |
| 309 | return; |
| 310 | default: |
| 311 | msg_pdbg2("Read Clock Frequency: %s\n", pprint_freq(cs, value)); |
| 312 | return; |
| 313 | } |
| 314 | } |
| 315 | |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 316 | void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_descriptors *desc) |
| 317 | { |
Nico Huber | b2ad9fd | 2024-07-14 23:18:53 +0200 | [diff] [blame] | 318 | const bool has_flill1 = cs >= SPI_ENGINE_PCH100; |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 319 | |
| 320 | msg_pdbg2("=== Component Section ===\n"); |
| 321 | msg_pdbg2("FLCOMP 0x%08x\n", desc->component.FLCOMP); |
| 322 | msg_pdbg2("FLILL 0x%08x\n", desc->component.FLILL ); |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 323 | if (has_flill1) |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 324 | msg_pdbg2("FLILL1 0x%08x\n", desc->component.FLILL1); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 325 | msg_pdbg2("\n"); |
| 326 | |
| 327 | msg_pdbg2("--- Details ---\n"); |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 328 | msg_pdbg2("Component 1 density: %s\n", pprint_density(cs, desc, 0)); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 329 | if (desc->content.NC) |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 330 | msg_pdbg2("Component 2 density: %s\n", pprint_density(cs, desc, 1)); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 331 | else |
| 332 | msg_pdbg2("Component 2 is not used.\n"); |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 333 | |
| 334 | pprint_read_freq(cs, desc->component.modes.freq_read); |
| 335 | |
Tai-Hong Wu | 60dead4 | 2015-01-05 23:00:14 +0000 | [diff] [blame] | 336 | msg_pdbg2("Read ID and Status Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_read_id)); |
| 337 | msg_pdbg2("Write and Erase Clock Freq.: %s\n", pprint_freq(cs, desc->component.modes.freq_write)); |
| 338 | msg_pdbg2("Fast Read is %ssupported.\n", desc->component.modes.fastread ? "" : "not "); |
| 339 | if (desc->component.modes.fastread) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 340 | msg_pdbg2("Fast Read Clock Frequency: %s\n", |
Tai-Hong Wu | 60dead4 | 2015-01-05 23:00:14 +0000 | [diff] [blame] | 341 | pprint_freq(cs, desc->component.modes.freq_fastread)); |
Nico Huber | 3f75d44 | 2024-07-14 19:17:56 +0200 | [diff] [blame] | 342 | switch (cs) { |
| 343 | case CHIPSET_7_SERIES_PANTHER_POINT: |
| 344 | case CHIPSET_8_SERIES_LYNX_POINT: |
| 345 | case CHIPSET_BAYTRAIL: |
| 346 | case CHIPSET_8_SERIES_LYNX_POINT_LP: |
| 347 | case CHIPSET_8_SERIES_WELLSBURG: |
| 348 | case CHIPSET_9_SERIES_WILDCAT_POINT: |
| 349 | case CHIPSET_9_SERIES_WILDCAT_POINT_LP: |
| 350 | case CHIPSET_100_SERIES_SUNRISE_POINT: |
| 351 | case CHIPSET_APOLLO_LAKE: |
| 352 | case CHIPSET_C620_SERIES_LEWISBURG: |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 353 | msg_pdbg2("Dual Output Fast Read Support: %sabled\n", |
Werner Zeh | d3e8fd9 | 2022-01-25 07:02:49 +0100 | [diff] [blame] | 354 | desc->component.modes.dual_output ? "en" : "dis"); |
Nico Huber | 3f75d44 | 2024-07-14 19:17:56 +0200 | [diff] [blame] | 355 | break; |
| 356 | default: |
| 357 | break; |
| 358 | } |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 359 | |
Felix Singer | d68a0ec | 2022-08-19 03:23:35 +0200 | [diff] [blame] | 360 | bool has_forbidden_opcode = false; |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 361 | if (desc->component.FLILL != 0) { |
Felix Singer | d68a0ec | 2022-08-19 03:23:35 +0200 | [diff] [blame] | 362 | has_forbidden_opcode = true; |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 363 | msg_pdbg2("Invalid instruction 0: 0x%02x\n", |
| 364 | desc->component.invalid_instr0); |
| 365 | msg_pdbg2("Invalid instruction 1: 0x%02x\n", |
| 366 | desc->component.invalid_instr1); |
| 367 | msg_pdbg2("Invalid instruction 2: 0x%02x\n", |
| 368 | desc->component.invalid_instr2); |
| 369 | msg_pdbg2("Invalid instruction 3: 0x%02x\n", |
| 370 | desc->component.invalid_instr3); |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 371 | } |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 372 | if (has_flill1) { |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 373 | if (desc->component.FLILL1 != 0) { |
Felix Singer | d68a0ec | 2022-08-19 03:23:35 +0200 | [diff] [blame] | 374 | has_forbidden_opcode = true; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 375 | msg_pdbg2("Invalid instruction 4: 0x%02x\n", |
| 376 | desc->component.invalid_instr4); |
| 377 | msg_pdbg2("Invalid instruction 5: 0x%02x\n", |
| 378 | desc->component.invalid_instr5); |
| 379 | msg_pdbg2("Invalid instruction 6: 0x%02x\n", |
| 380 | desc->component.invalid_instr6); |
| 381 | msg_pdbg2("Invalid instruction 7: 0x%02x\n", |
| 382 | desc->component.invalid_instr7); |
| 383 | } |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 384 | } |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 385 | if (!has_forbidden_opcode) |
| 386 | msg_pdbg2("No forbidden opcodes.\n"); |
| 387 | |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 388 | msg_pdbg2("\n"); |
| 389 | } |
| 390 | |
| 391 | static void pprint_freg(const struct ich_desc_region *reg, uint32_t i) |
| 392 | { |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 393 | static const char *const region_names[] = { |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 394 | "Descr.", "BIOS", "ME", "GbE", "Platf.", "DevExp", "BIOS2", "unknown", |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 395 | "EC/BMC", "unknown", "IE", "10GbE", "unknown", "unknown", "unknown", "unknown" |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 396 | }; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 397 | if (i >= ARRAY_SIZE(region_names)) { |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 398 | msg_pdbg2("%s: region index too high.\n", __func__); |
| 399 | return; |
| 400 | } |
| 401 | uint32_t base = ICH_FREG_BASE(reg->FLREGs[i]); |
| 402 | uint32_t limit = ICH_FREG_LIMIT(reg->FLREGs[i]); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 403 | msg_pdbg2("Region %d (%-7s) ", i, region_names[i]); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 404 | if (base > limit) |
| 405 | msg_pdbg2("is unused.\n"); |
| 406 | else |
Nico Huber | 0bb3f71 | 2017-03-29 16:44:33 +0200 | [diff] [blame] | 407 | msg_pdbg2("0x%08x - 0x%08x\n", base, limit); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 410 | void prettyprint_ich_descriptor_region(const enum ich_chipset cs, const struct ich_descriptors *const desc) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 411 | { |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 412 | ssize_t i; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 413 | const ssize_t nr = ich_number_of_regions(cs, &desc->content); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 414 | msg_pdbg2("=== Region Section ===\n"); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 415 | if (nr < 0) { |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 416 | msg_pdbg2("%s: number of regions too high (%d).\n", __func__, |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 417 | desc->content.NR + 1); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 418 | return; |
| 419 | } |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 420 | for (i = 0; i < nr; i++) |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 421 | msg_pdbg2("FLREG%zd 0x%08x\n", i, desc->region.FLREGs[i]); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 422 | msg_pdbg2("\n"); |
| 423 | |
| 424 | msg_pdbg2("--- Details ---\n"); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 425 | for (i = 0; i < nr; i++) |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 426 | pprint_freg(&desc->region, (uint32_t)i); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 427 | msg_pdbg2("\n"); |
| 428 | } |
| 429 | |
Nico Huber | b3cc2c6 | 2024-07-15 00:45:17 +0200 | [diff] [blame] | 430 | static char prettify_flag(const unsigned int mask, const unsigned int bit, const char flag) |
| 431 | { |
| 432 | return mask & (1 << bit) ? flag : ' '; |
| 433 | } |
| 434 | |
| 435 | /* Takes NULL-terminated lists of names, assumes max. 5 chars per name. */ |
| 436 | static void prettyprint_pch100_masters( |
| 437 | const struct ich_descriptors *const desc, |
| 438 | const unsigned int number_masters, const char *const masters[], |
| 439 | const unsigned int number_regions, const char *const regions[]) |
| 440 | { |
| 441 | unsigned int m, r; |
| 442 | |
| 443 | msg_pdbg2(" "); |
| 444 | for (r = 0; r < number_regions && regions[r] != NULL; ++r) |
| 445 | msg_pdbg2(" %-5s", regions[r]); |
| 446 | msg_pdbg2("\n"); |
| 447 | |
| 448 | for (m = 0; m < number_masters; ++m) { |
| 449 | const unsigned int ext_start = 12; |
| 450 | |
| 451 | if (masters[m] == NULL) |
| 452 | break; |
| 453 | |
| 454 | const struct ich_desc_master_region_access master = desc->master.mstr[m]; |
| 455 | |
| 456 | msg_pdbg2("%-5s", masters[m]); |
| 457 | for (r = 0; r < ext_start && r < number_regions && regions[r] != NULL; ++r) |
| 458 | msg_pdbg2(" %c%c ", |
| 459 | prettify_flag(master.read, r, 'r'), |
| 460 | prettify_flag(master.write, r, 'w')); |
| 461 | for (; r < number_regions && regions[r] != NULL; ++r) |
| 462 | msg_pdbg2(" %c%c ", |
| 463 | prettify_flag(master.ext_read, r - ext_start, 'r'), |
| 464 | prettify_flag(master.ext_write, r - ext_start, 'w')); |
| 465 | msg_pdbg2("\n"); |
| 466 | } |
| 467 | } |
| 468 | |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 469 | void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct ich_descriptors *const desc) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 470 | { |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 471 | ssize_t i; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 472 | const ssize_t nm = ich_number_of_masters(cs, &desc->content); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 473 | msg_pdbg2("=== Master Section ===\n"); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 474 | if (nm < 0) { |
| 475 | msg_pdbg2("%s: number of masters too high (%d).\n", __func__, |
| 476 | desc->content.NM + 1); |
| 477 | return; |
| 478 | } |
| 479 | for (i = 0; i < nm; i++) |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 480 | msg_pdbg2("FLMSTR%zd 0x%08x\n", i + 1, desc->master.FLMSTRs[i]); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 481 | msg_pdbg2("\n"); |
| 482 | |
| 483 | msg_pdbg2("--- Details ---\n"); |
Nico Huber | b3cc2c6 | 2024-07-15 00:45:17 +0200 | [diff] [blame] | 484 | if (cs >= SPI_ENGINE_PCH100) { |
| 485 | const ssize_t nr = ich_number_of_regions(cs, &desc->content); |
| 486 | if (nr < 0) |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 487 | return; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 488 | |
Nico Huber | b3cc2c6 | 2024-07-15 00:45:17 +0200 | [diff] [blame] | 489 | if (cs == CHIPSET_APOLLO_LAKE || |
| 490 | cs == CHIPSET_GEMINI_LAKE || |
| 491 | cs == CHIPSET_ELKHART_LAKE) { |
| 492 | const char *const masters[] = { |
| 493 | "BIOS", "TXE", NULL |
| 494 | }; |
| 495 | const char *const regions[] = { |
| 496 | " FD", "IFWI", " TXE", " n/a", "Pltf.", "DevExp", NULL |
| 497 | }; |
| 498 | prettyprint_pch100_masters(desc, nm, masters, nr, regions); |
| 499 | } else if (cs == CHIPSET_C620_SERIES_LEWISBURG) { |
| 500 | const char *const masters[] = { |
| 501 | "BIOS", "ME", "GbE", "DE", "BMC", "IE", NULL |
| 502 | }; |
| 503 | const char *const regions[] = { |
| 504 | " FD ", " BIOS", " ME ", " GbE ", "Pltf.", |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 505 | " DE ", "BIOS2", " Reg7", " BMC ", " DE2 ", |
| 506 | " IE ", "10GbE", "OpROM", "Reg13", "Reg14", |
Nico Huber | b3cc2c6 | 2024-07-15 00:45:17 +0200 | [diff] [blame] | 507 | "Reg15", NULL |
| 508 | }; |
| 509 | prettyprint_pch100_masters(desc, nm, masters, nr, regions); |
| 510 | } else { |
| 511 | const char *const masters[] = { |
| 512 | "BIOS", "ME", "GbE", "unkn.", "EC", NULL |
| 513 | }; |
| 514 | const char *const regions[] = { |
| 515 | " FD ", "BIOS ", " ME ", " GbE ", "Pltf.", |
| 516 | "Reg5 ", "Reg6 ", "Reg7 ", " EC ", "Reg9 ", |
| 517 | "Reg10", "Reg11", "Reg12", "Reg13", "Reg14", |
| 518 | "Reg15", NULL |
| 519 | }; |
| 520 | prettyprint_pch100_masters(desc, nm, masters, nr, regions); |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 521 | } |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 522 | } else { |
| 523 | const struct ich_desc_master *const mstr = &desc->master; |
| 524 | msg_pdbg2(" Descr. BIOS ME GbE Platf.\n"); |
| 525 | msg_pdbg2("BIOS %c%c %c%c %c%c %c%c %c%c\n", |
| 526 | (mstr->BIOS_descr_r) ?'r':' ', (mstr->BIOS_descr_w) ?'w':' ', |
| 527 | (mstr->BIOS_BIOS_r) ?'r':' ', (mstr->BIOS_BIOS_w) ?'w':' ', |
| 528 | (mstr->BIOS_ME_r) ?'r':' ', (mstr->BIOS_ME_w) ?'w':' ', |
| 529 | (mstr->BIOS_GbE_r) ?'r':' ', (mstr->BIOS_GbE_w) ?'w':' ', |
| 530 | (mstr->BIOS_plat_r) ?'r':' ', (mstr->BIOS_plat_w) ?'w':' '); |
| 531 | msg_pdbg2("ME %c%c %c%c %c%c %c%c %c%c\n", |
| 532 | (mstr->ME_descr_r) ?'r':' ', (mstr->ME_descr_w) ?'w':' ', |
| 533 | (mstr->ME_BIOS_r) ?'r':' ', (mstr->ME_BIOS_w) ?'w':' ', |
| 534 | (mstr->ME_ME_r) ?'r':' ', (mstr->ME_ME_w) ?'w':' ', |
| 535 | (mstr->ME_GbE_r) ?'r':' ', (mstr->ME_GbE_w) ?'w':' ', |
| 536 | (mstr->ME_plat_r) ?'r':' ', (mstr->ME_plat_w) ?'w':' '); |
| 537 | msg_pdbg2("GbE %c%c %c%c %c%c %c%c %c%c\n", |
| 538 | (mstr->GbE_descr_r) ?'r':' ', (mstr->GbE_descr_w) ?'w':' ', |
| 539 | (mstr->GbE_BIOS_r) ?'r':' ', (mstr->GbE_BIOS_w) ?'w':' ', |
| 540 | (mstr->GbE_ME_r) ?'r':' ', (mstr->GbE_ME_w) ?'w':' ', |
| 541 | (mstr->GbE_GbE_r) ?'r':' ', (mstr->GbE_GbE_w) ?'w':' ', |
| 542 | (mstr->GbE_plat_r) ?'r':' ', (mstr->GbE_plat_w) ?'w':' '); |
| 543 | } |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 544 | msg_pdbg2("\n"); |
| 545 | } |
| 546 | |
Jacob Garber | beeb8bc | 2019-06-21 15:24:17 -0600 | [diff] [blame] | 547 | static void prettyprint_ich_descriptor_straps_ich8(const struct ich_descriptors *desc) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 548 | { |
| 549 | static const char * const str_GPIO12[4] = { |
| 550 | "GPIO12", |
| 551 | "LAN PHY Power Control Function (Native Output)", |
| 552 | "GLAN_DOCK# (Native Input)", |
| 553 | "invalid configuration", |
| 554 | }; |
| 555 | |
| 556 | msg_pdbg2("--- MCH details ---\n"); |
| 557 | msg_pdbg2("ME B is %sabled.\n", desc->north.ich8.MDB ? "dis" : "en"); |
| 558 | msg_pdbg2("\n"); |
| 559 | |
| 560 | msg_pdbg2("--- ICH details ---\n"); |
| 561 | msg_pdbg2("ME SMBus Address 1: 0x%02x\n", desc->south.ich8.ASD); |
| 562 | msg_pdbg2("ME SMBus Address 2: 0x%02x\n", desc->south.ich8.ASD2); |
| 563 | msg_pdbg2("ME SMBus Controller is connected to the %s.\n", |
| 564 | desc->south.ich8.MESM2SEL ? "SMLink pins" : "SMBus pins"); |
| 565 | msg_pdbg2("SPI CS1 is used for %s.\n", |
| 566 | desc->south.ich8.SPICS1_LANPHYPC_SEL ? |
| 567 | "LAN PHY Power Control Function" : |
| 568 | "SPI Chip Select"); |
| 569 | msg_pdbg2("GPIO12 is used as %s.\n", |
| 570 | str_GPIO12[desc->south.ich8.GPIO12_SEL]); |
| 571 | msg_pdbg2("PCIe Port 6 is used for %s.\n", |
| 572 | desc->south.ich8.GLAN_PCIE_SEL ? "integrated LAN" : "PCI Express"); |
| 573 | msg_pdbg2("%sn BMC Mode: " |
| 574 | "Intel AMT SMBus Controller 1 is connected to %s.\n", |
| 575 | desc->south.ich8.BMCMODE ? "I" : "Not i", |
| 576 | desc->south.ich8.BMCMODE ? "SMLink" : "SMBus"); |
| 577 | msg_pdbg2("TCO is in %s Mode.\n", |
| 578 | desc->south.ich8.TCOMODE ? "Advanced TCO" : "Legacy/Compatible"); |
| 579 | msg_pdbg2("ME A is %sabled.\n", |
| 580 | desc->south.ich8.ME_DISABLE ? "dis" : "en"); |
| 581 | msg_pdbg2("\n"); |
| 582 | } |
| 583 | |
| 584 | static void prettyprint_ich_descriptor_straps_56_pciecs(uint8_t conf, uint8_t off) |
| 585 | { |
| 586 | msg_pdbg2("PCI Express Port Configuration Strap %d: ", off+1); |
| 587 | |
| 588 | off *= 4; |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 589 | switch (conf){ |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 590 | case 0: |
| 591 | msg_pdbg2("4x1 Ports %d-%d (x1)", 1+off, 4+off); |
| 592 | break; |
| 593 | case 1: |
| 594 | msg_pdbg2("1x2, 2x1 Port %d (x2), Port %d (disabled), " |
| 595 | "Ports %d, %d (x1)", 1+off, 2+off, 3+off, 4+off); |
| 596 | break; |
| 597 | case 2: |
| 598 | msg_pdbg2("2x2 Port %d (x2), Port %d (x2), Ports " |
| 599 | "%d, %d (disabled)", 1+off, 3+off, 2+off, 4+off); |
| 600 | break; |
| 601 | case 3: |
| 602 | msg_pdbg2("1x4 Port %d (x4), Ports %d-%d (disabled)", |
| 603 | 1+off, 2+off, 4+off); |
| 604 | break; |
| 605 | } |
| 606 | msg_pdbg2("\n"); |
| 607 | } |
| 608 | |
Jacob Garber | beeb8bc | 2019-06-21 15:24:17 -0600 | [diff] [blame] | 609 | static void prettyprint_ich_descriptor_pchstraps45678_56(const struct ich_desc_south_strap *s) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 610 | { |
| 611 | /* PCHSTRP4 */ |
| 612 | msg_pdbg2("Intel PHY is %s.\n", |
| 613 | (s->ibex.PHYCON == 2) ? "connected" : |
| 614 | (s->ibex.PHYCON == 0) ? "disconnected" : "reserved"); |
| 615 | msg_pdbg2("GbE MAC SMBus address is %sabled.\n", |
| 616 | s->ibex.GBEMAC_SMBUS_ADDR_EN ? "en" : "dis"); |
| 617 | msg_pdbg2("GbE MAC SMBus address: 0x%02x\n", |
| 618 | s->ibex.GBEMAC_SMBUS_ADDR); |
| 619 | msg_pdbg2("GbE PHY SMBus address: 0x%02x\n", |
| 620 | s->ibex.GBEPHY_SMBUS_ADDR); |
| 621 | |
| 622 | /* PCHSTRP5 */ |
| 623 | /* PCHSTRP6 */ |
| 624 | /* PCHSTRP7 */ |
| 625 | msg_pdbg2("Intel ME SMBus Subsystem Vendor ID: 0x%04x\n", |
| 626 | s->ibex.MESMA2UDID_VENDOR); |
| 627 | msg_pdbg2("Intel ME SMBus Subsystem Device ID: 0x%04x\n", |
| 628 | s->ibex.MESMA2UDID_VENDOR); |
| 629 | |
| 630 | /* PCHSTRP8 */ |
| 631 | } |
| 632 | |
Jacob Garber | beeb8bc | 2019-06-21 15:24:17 -0600 | [diff] [blame] | 633 | static void prettyprint_ich_descriptor_pchstraps111213_56(const struct ich_desc_south_strap *s) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 634 | { |
| 635 | /* PCHSTRP11 */ |
| 636 | msg_pdbg2("SMLink1 GP Address is %sabled.\n", |
| 637 | s->ibex.SML1GPAEN ? "en" : "dis"); |
| 638 | msg_pdbg2("SMLink1 controller General Purpose Target address: 0x%02x\n", |
| 639 | s->ibex.SML1GPA); |
| 640 | msg_pdbg2("SMLink1 I2C Target address is %sabled.\n", |
| 641 | s->ibex.SML1I2CAEN ? "en" : "dis"); |
| 642 | msg_pdbg2("SMLink1 I2C Target address: 0x%02x\n", |
| 643 | s->ibex.SML1I2CA); |
| 644 | |
| 645 | /* PCHSTRP12 */ |
| 646 | /* PCHSTRP13 */ |
| 647 | } |
| 648 | |
Jacob Garber | beeb8bc | 2019-06-21 15:24:17 -0600 | [diff] [blame] | 649 | static void prettyprint_ich_descriptor_straps_ibex(const struct ich_desc_south_strap *s) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 650 | { |
Stefan Tauner | 67d163d | 2013-01-15 17:37:48 +0000 | [diff] [blame] | 651 | static const uint8_t dec_t209min[4] = { |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 652 | 100, |
| 653 | 50, |
| 654 | 5, |
| 655 | 1 |
| 656 | }; |
| 657 | |
| 658 | msg_pdbg2("--- PCH ---\n"); |
| 659 | |
| 660 | /* PCHSTRP0 */ |
| 661 | msg_pdbg2("Chipset configuration Softstrap 2: %d\n", s->ibex.cs_ss2); |
| 662 | msg_pdbg2("Intel ME SMBus Select is %sabled.\n", |
| 663 | s->ibex.SMB_EN ? "en" : "dis"); |
| 664 | msg_pdbg2("SMLink0 segment is %sabled.\n", |
| 665 | s->ibex.SML0_EN ? "en" : "dis"); |
| 666 | msg_pdbg2("SMLink1 segment is %sabled.\n", |
| 667 | s->ibex.SML1_EN ? "en" : "dis"); |
| 668 | msg_pdbg2("SMLink1 Frequency: %s\n", |
| 669 | (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved"); |
| 670 | msg_pdbg2("Intel ME SMBus Frequency: %s\n", |
| 671 | (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved"); |
| 672 | msg_pdbg2("SMLink0 Frequency: %s\n", |
| 673 | (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved"); |
| 674 | msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ? |
| 675 | "LAN_PHY_PWR_CTRL" : "general purpose output"); |
| 676 | msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->ibex.cs_ss1); |
| 677 | msg_pdbg2("DMI RequesterID Checks are %sabled.\n", |
| 678 | s->ibex.DMI_REQID_DIS ? "en" : "dis"); |
| 679 | msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n", |
| 680 | 1 << (6 + s->ibex.BBBS)); |
| 681 | |
| 682 | /* PCHSTRP1 */ |
| 683 | msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3); |
| 684 | |
| 685 | /* PCHSTRP2 */ |
| 686 | msg_pdbg2("ME SMBus ASD address is %sabled.\n", |
| 687 | s->ibex.MESMASDEN ? "en" : "dis"); |
| 688 | msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n", |
| 689 | s->ibex.MESMASDA); |
| 690 | msg_pdbg2("ME SMBus I2C address is %sabled.\n", |
| 691 | s->ibex.MESMI2CEN ? "en" : "dis"); |
| 692 | msg_pdbg2("ME SMBus I2C target address: 0x%02x\n", |
| 693 | s->ibex.MESMI2CA); |
| 694 | |
| 695 | /* PCHSTRP3 */ |
| 696 | prettyprint_ich_descriptor_pchstraps45678_56(s); |
| 697 | /* PCHSTRP9 */ |
| 698 | prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0); |
| 699 | prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1); |
| 700 | msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n", |
| 701 | s->ibex.PCIELR1 ? "" : "not "); |
| 702 | msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n", |
| 703 | s->ibex.PCIELR2 ? "" : "not "); |
| 704 | msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n", |
| 705 | s->ibex.DMILR ? "" : "not "); |
| 706 | msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1); |
| 707 | msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n", |
| 708 | s->ibex.PHY_PCIE_EN ? "en" : "dis"); |
| 709 | |
| 710 | /* PCHSTRP10 */ |
| 711 | msg_pdbg2("Management Engine will boot from %sflash.\n", |
| 712 | s->ibex.ME_BOOT_FLASH ? "" : "ROM, then "); |
| 713 | msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->ibex.cs_ss5); |
| 714 | msg_pdbg2("Virtualization Engine Enable 1 is %sabled.\n", |
| 715 | s->ibex.VE_EN ? "en" : "dis"); |
| 716 | msg_pdbg2("ME Memory-attached Debug Display Device is %sabled.\n", |
| 717 | s->ibex.MMDDE ? "en" : "dis"); |
| 718 | msg_pdbg2("ME Memory-attached Debug Display Device address: 0x%02x\n", |
| 719 | s->ibex.MMADDR); |
| 720 | msg_pdbg2("Chipset configuration Softstrap 7: %d\n", s->ibex.cs_ss7); |
| 721 | msg_pdbg2("Integrated Clocking Configuration is %d.\n", |
| 722 | (s->ibex.ICC_SEL == 7) ? 0 : s->ibex.ICC_SEL); |
| 723 | msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a " |
| 724 | "reset.\n", s->ibex.MER_CL1 ? "" : "not "); |
| 725 | |
| 726 | prettyprint_ich_descriptor_pchstraps111213_56(s); |
| 727 | |
| 728 | /* PCHSTRP14 */ |
| 729 | msg_pdbg2("Virtualization Engine Enable 2 is %sabled.\n", |
| 730 | s->ibex.VE_EN2 ? "en" : "dis"); |
| 731 | msg_pdbg2("Virtualization Engine will boot from %sflash.\n", |
| 732 | s->ibex.VE_BOOT_FLASH ? "" : "ROM, then "); |
| 733 | msg_pdbg2("Braidwood SSD functionality is %sabled.\n", |
| 734 | s->ibex.BW_SSD ? "en" : "dis"); |
| 735 | msg_pdbg2("Braidwood NVMHCI functionality is %sabled.\n", |
| 736 | s->ibex.NVMHCI_EN ? "en" : "dis"); |
| 737 | |
| 738 | /* PCHSTRP15 */ |
| 739 | msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->ibex.cs_ss6); |
| 740 | msg_pdbg2("Integrated wired LAN Solution is %sabled.\n", |
| 741 | s->ibex.IWL_EN ? "en" : "dis"); |
| 742 | msg_pdbg2("t209 min Timing: %d ms\n", |
| 743 | dec_t209min[s->ibex.t209min]); |
| 744 | msg_pdbg2("\n"); |
| 745 | } |
| 746 | |
Jacob Garber | beeb8bc | 2019-06-21 15:24:17 -0600 | [diff] [blame] | 747 | static void prettyprint_ich_descriptor_straps_cougar(const struct ich_desc_south_strap *s) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 748 | { |
| 749 | msg_pdbg2("--- PCH ---\n"); |
| 750 | |
| 751 | /* PCHSTRP0 */ |
| 752 | msg_pdbg2("Chipset configuration Softstrap 1: %d\n", s->cougar.cs_ss1); |
| 753 | msg_pdbg2("Intel ME SMBus Select is %sabled.\n", |
| 754 | s->ibex.SMB_EN ? "en" : "dis"); |
| 755 | msg_pdbg2("SMLink0 segment is %sabled.\n", |
| 756 | s->ibex.SML0_EN ? "en" : "dis"); |
| 757 | msg_pdbg2("SMLink1 segment is %sabled.\n", |
| 758 | s->ibex.SML1_EN ? "en" : "dis"); |
| 759 | msg_pdbg2("SMLink1 Frequency: %s\n", |
| 760 | (s->ibex.SML1FRQ == 1) ? "100 kHz" : "reserved"); |
| 761 | msg_pdbg2("Intel ME SMBus Frequency: %s\n", |
| 762 | (s->ibex.SMB0FRQ == 1) ? "100 kHz" : "reserved"); |
| 763 | msg_pdbg2("SMLink0 Frequency: %s\n", |
| 764 | (s->ibex.SML0FRQ == 1) ? "100 kHz" : "reserved"); |
| 765 | msg_pdbg2("GPIO12 is used as %s.\n", s->ibex.LANPHYPC_GP12_SEL ? |
| 766 | "LAN_PHY_PWR_CTRL" : "general purpose output"); |
| 767 | msg_pdbg2("LinkSec is %sabled.\n", |
| 768 | s->cougar.LINKSEC_DIS ? "en" : "dis"); |
| 769 | msg_pdbg2("DMI RequesterID Checks are %sabled.\n", |
| 770 | s->ibex.DMI_REQID_DIS ? "en" : "dis"); |
| 771 | msg_pdbg2("BIOS Boot-Block size (BBBS): %d kB.\n", |
| 772 | 1 << (6 + s->ibex.BBBS)); |
| 773 | |
| 774 | /* PCHSTRP1 */ |
| 775 | msg_pdbg2("Chipset configuration Softstrap 3: 0x%x\n", s->ibex.cs_ss3); |
| 776 | msg_pdbg2("Chipset configuration Softstrap 2: 0x%x\n", s->ibex.cs_ss2); |
| 777 | |
| 778 | /* PCHSTRP2 */ |
| 779 | msg_pdbg2("ME SMBus ASD address is %sabled.\n", |
| 780 | s->ibex.MESMASDEN ? "en" : "dis"); |
| 781 | msg_pdbg2("ME SMBus Controller ASD Target address: 0x%02x\n", |
| 782 | s->ibex.MESMASDA); |
| 783 | msg_pdbg2("ME SMBus MCTP Address is %sabled.\n", |
| 784 | s->cougar.MESMMCTPAEN ? "en" : "dis"); |
| 785 | msg_pdbg2("ME SMBus MCTP target address: 0x%02x\n", |
| 786 | s->cougar.MESMMCTPA); |
| 787 | msg_pdbg2("ME SMBus I2C address is %sabled.\n", |
| 788 | s->ibex.MESMI2CEN ? "en" : "dis"); |
| 789 | msg_pdbg2("ME SMBus I2C target address: 0x%02x\n", |
| 790 | s->ibex.MESMI2CA); |
| 791 | |
| 792 | /* PCHSTRP3 */ |
| 793 | prettyprint_ich_descriptor_pchstraps45678_56(s); |
| 794 | /* PCHSTRP9 */ |
| 795 | prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 0); |
| 796 | prettyprint_ich_descriptor_straps_56_pciecs(s->ibex.PCIEPCS1, 1); |
| 797 | msg_pdbg2("PCIe Lane Reversal 1: PCIe Lanes 0-3 are %sreserved.\n", |
| 798 | s->ibex.PCIELR1 ? "" : "not "); |
| 799 | msg_pdbg2("PCIe Lane Reversal 2: PCIe Lanes 4-7 are %sreserved.\n", |
| 800 | s->ibex.PCIELR2 ? "" : "not "); |
| 801 | msg_pdbg2("DMI Lane Reversal: DMI Lanes 0-3 are %sreserved.\n", |
| 802 | s->ibex.DMILR ? "" : "not "); |
| 803 | msg_pdbg2("ME Debug status writes over SMBUS are %sabled.\n", |
| 804 | s->cougar.MDSMBE_EN ? "en" : "dis"); |
| 805 | msg_pdbg2("ME Debug SMBus Emergency Mode address: 0x%02x (raw)\n", |
| 806 | s->cougar.MDSMBE_ADD); |
| 807 | msg_pdbg2("Default PHY PCIe Port is %d.\n", s->ibex.PHY_PCIEPORTSEL+1); |
| 808 | msg_pdbg2("Integrated MAC/PHY communication over PCIe is %sabled.\n", |
| 809 | s->ibex.PHY_PCIE_EN ? "en" : "dis"); |
| 810 | msg_pdbg2("PCIe ports Subtractive Decode Agent is %sabled.\n", |
| 811 | s->cougar.SUB_DECODE_EN ? "en" : "dis"); |
| 812 | msg_pdbg2("GPIO74 is used as %s.\n", s->cougar.PCHHOT_SML1ALERT_SEL ? |
| 813 | "PCHHOT#" : "SML1ALERT#"); |
| 814 | |
| 815 | /* PCHSTRP10 */ |
| 816 | msg_pdbg2("Management Engine will boot from %sflash.\n", |
| 817 | s->ibex.ME_BOOT_FLASH ? "" : "ROM, then "); |
| 818 | |
| 819 | msg_pdbg2("ME Debug SMBus Emergency Mode is %sabled.\n", |
| 820 | s->cougar.MDSMBE_EN ? "en" : "dis"); |
| 821 | msg_pdbg2("ME Debug SMBus Emergency Mode Address: 0x%02x\n", |
| 822 | s->cougar.MDSMBE_ADD); |
| 823 | |
| 824 | msg_pdbg2("Integrated Clocking Configuration used: %d\n", |
| 825 | s->cougar.ICC_SEL); |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 826 | msg_pdbg2("PCH Signal CL_RST1# does %sassert when Intel ME performs a reset.\n", |
| 827 | s->ibex.MER_CL1 ? "" : "not "); |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 828 | msg_pdbg2("ICC Profile is selected by %s.\n", |
| 829 | s->cougar.ICC_PRO_SEL ? "Softstraps" : "BIOS"); |
| 830 | msg_pdbg2("Deep SX is %ssupported on the platform.\n", |
| 831 | s->cougar.Deep_SX_EN ? "not " : ""); |
| 832 | msg_pdbg2("ME Debug LAN Emergency Mode is %sabled.\n", |
| 833 | s->cougar.ME_DBG_LAN ? "en" : "dis"); |
| 834 | |
| 835 | prettyprint_ich_descriptor_pchstraps111213_56(s); |
| 836 | |
| 837 | /* PCHSTRP14 */ |
| 838 | /* PCHSTRP15 */ |
| 839 | msg_pdbg2("Chipset configuration Softstrap 6: %d\n", s->cougar.cs_ss6); |
| 840 | msg_pdbg2("Integrated wired LAN is %sabled.\n", |
| 841 | s->cougar.IWL_EN ? "en" : "dis"); |
| 842 | msg_pdbg2("Chipset configuration Softstrap 5: %d\n", s->cougar.cs_ss5); |
| 843 | msg_pdbg2("SMLink1 provides temperature from %s.\n", |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 844 | s->cougar.SMLINK1_THERM_SEL ? "PCH only" : "the CPU, PCH and DIMMs"); |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 845 | msg_pdbg2("GPIO29 is used as %s.\n", s->cougar.SLP_LAN_GP29_SEL ? |
| 846 | "general purpose output" : "SLP_LAN#"); |
| 847 | |
| 848 | /* PCHSTRP16 */ |
| 849 | /* PCHSTRP17 */ |
| 850 | msg_pdbg2("Integrated Clock: %s Clock Mode\n", |
| 851 | s->cougar.ICML ? "Buffered Through" : "Full Integrated"); |
| 852 | msg_pdbg2("\n"); |
| 853 | } |
| 854 | |
| 855 | void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc) |
| 856 | { |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 857 | unsigned int i, max_count; |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 858 | msg_pdbg2("=== Softstraps ===\n"); |
| 859 | |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 860 | max_count = MIN(ARRAY_SIZE(desc->north.STRPs), desc->content.MSL); |
Nico Huber | d7c7552 | 2017-03-29 16:31:49 +0200 | [diff] [blame] | 861 | if (max_count < desc->content.MSL) { |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 862 | msg_pdbg2("MSL (%u) is greater than the current maximum of %u entries.\n", |
Nico Huber | d7c7552 | 2017-03-29 16:31:49 +0200 | [diff] [blame] | 863 | desc->content.MSL, max_count); |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 864 | msg_pdbg2("Only the first %u entries will be printed.\n", max_count); |
Nico Huber | d7c7552 | 2017-03-29 16:31:49 +0200 | [diff] [blame] | 865 | } |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 866 | |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 867 | msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max_count); |
| 868 | for (i = 0; i < max_count; i++) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 869 | msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]); |
| 870 | msg_pdbg2("\n"); |
| 871 | |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 872 | max_count = MIN(ARRAY_SIZE(desc->south.STRPs), desc->content.ISL); |
Nico Huber | d7c7552 | 2017-03-29 16:31:49 +0200 | [diff] [blame] | 873 | if (max_count < desc->content.ISL) { |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 874 | msg_pdbg2("ISL (%u) is greater than the current maximum of %u entries.\n", |
| 875 | desc->content.ISL, max_count); |
| 876 | msg_pdbg2("Only the first %u entries will be printed.\n", max_count); |
Nico Huber | d7c7552 | 2017-03-29 16:31:49 +0200 | [diff] [blame] | 877 | } |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 878 | |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 879 | msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max_count); |
| 880 | for (i = 0; i < max_count; i++) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 881 | msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->south.STRPs[i]); |
| 882 | msg_pdbg2("\n"); |
| 883 | |
| 884 | switch (cs) { |
| 885 | case CHIPSET_ICH8: |
| 886 | if (sizeof(desc->north.ich8) / 4 != desc->content.MSL) |
| 887 | msg_pdbg2("Detailed North/MCH/PROC information is " |
| 888 | "probably not reliable, printing anyway.\n"); |
| 889 | if (sizeof(desc->south.ich8) / 4 != desc->content.ISL) |
| 890 | msg_pdbg2("Detailed South/ICH/PCH information is " |
| 891 | "probably not reliable, printing anyway.\n"); |
| 892 | prettyprint_ich_descriptor_straps_ich8(desc); |
| 893 | break; |
| 894 | case CHIPSET_5_SERIES_IBEX_PEAK: |
| 895 | /* PCH straps only. PROCSTRPs are unknown. */ |
| 896 | if (sizeof(desc->south.ibex) / 4 != desc->content.ISL) |
| 897 | msg_pdbg2("Detailed South/ICH/PCH information is " |
| 898 | "probably not reliable, printing anyway.\n"); |
| 899 | prettyprint_ich_descriptor_straps_ibex(&desc->south); |
| 900 | break; |
| 901 | case CHIPSET_6_SERIES_COUGAR_POINT: |
| 902 | /* PCH straps only. PROCSTRP0 is "reserved". */ |
| 903 | if (sizeof(desc->south.cougar) / 4 != desc->content.ISL) |
| 904 | msg_pdbg2("Detailed South/ICH/PCH information is " |
| 905 | "probably not reliable, printing anyway.\n"); |
| 906 | prettyprint_ich_descriptor_straps_cougar(&desc->south); |
| 907 | break; |
| 908 | case CHIPSET_ICH_UNKNOWN: |
| 909 | break; |
| 910 | default: |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 911 | msg_pdbg2("The meaning of the descriptor straps are unknown yet.\n\n"); |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 912 | break; |
| 913 | } |
| 914 | } |
| 915 | |
Jacob Garber | beeb8bc | 2019-06-21 15:24:17 -0600 | [diff] [blame] | 916 | static void prettyprint_rdid(uint32_t reg_val) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 917 | { |
| 918 | uint8_t mid = reg_val & 0xFF; |
| 919 | uint16_t did = ((reg_val >> 16) & 0xFF) | (reg_val & 0xFF00); |
| 920 | msg_pdbg2("Manufacturer ID 0x%02x, Device ID 0x%04x\n", mid, did); |
| 921 | } |
| 922 | |
| 923 | void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap) |
| 924 | { |
| 925 | int i; |
| 926 | msg_pdbg2("=== Upper Map Section ===\n"); |
| 927 | msg_pdbg2("FLUMAP1 0x%08x\n", umap->FLUMAP1); |
| 928 | msg_pdbg2("\n"); |
| 929 | |
| 930 | msg_pdbg2("--- Details ---\n"); |
| 931 | msg_pdbg2("VTL (length in DWORDS) = %d\n", umap->VTL); |
| 932 | msg_pdbg2("VTBA (base address) = 0x%6.6x\n", getVTBA(umap)); |
| 933 | msg_pdbg2("\n"); |
| 934 | |
| 935 | msg_pdbg2("VSCC Table: %d entries\n", umap->VTL/2); |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 936 | for (i = 0; i < umap->VTL/2; i++) { |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 937 | uint32_t jid = umap->vscc_table[i].JID; |
| 938 | uint32_t vscc = umap->vscc_table[i].VSCC; |
| 939 | msg_pdbg2(" JID%d = 0x%08x\n", i, jid); |
| 940 | msg_pdbg2(" VSCC%d = 0x%08x\n", i, vscc); |
Martin Roth | f6c1cb1 | 2022-03-15 10:55:25 -0600 | [diff] [blame] | 941 | msg_pdbg2(" "); /* indentation */ |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 942 | prettyprint_rdid(jid); |
Martin Roth | f6c1cb1 | 2022-03-15 10:55:25 -0600 | [diff] [blame] | 943 | msg_pdbg2(" "); /* indentation */ |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 944 | prettyprint_ich_reg_vscc(vscc, 0, false); |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 945 | } |
| 946 | msg_pdbg2("\n"); |
| 947 | } |
| 948 | |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 949 | static inline void warn_peculiar_desc(const char *const name) |
Nico Huber | 964007a | 2021-06-17 21:12:47 +0200 | [diff] [blame] | 950 | { |
Nico Huber | 964007a | 2021-06-17 21:12:47 +0200 | [diff] [blame] | 951 | msg_pwarn("Peculiar flash descriptor, assuming %s compatibility.\n", name); |
| 952 | } |
| 953 | |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 954 | /* |
| 955 | * Guesses a minimum chipset version based on the maximum number of |
Nico Huber | 3ad9aad | 2021-06-17 22:05:00 +0200 | [diff] [blame] | 956 | * soft straps per generation and presence of the MIP base (MDTBA). |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 957 | */ |
Nico Huber | db878fb | 2024-07-19 17:37:09 +0200 | [diff] [blame^] | 958 | static enum ich_chipset guess_ich_chipset(const struct ich_desc_content *const content, |
| 959 | const struct ich_desc_upper_map *const upper) |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 960 | { |
| 961 | if (content->ICCRIBA == 0x00) { |
| 962 | if (content->MSL == 0 && content->ISL <= 2) |
| 963 | return CHIPSET_ICH8; |
Nico Huber | 83b01c8 | 2021-06-17 21:20:09 +0200 | [diff] [blame] | 964 | if (content->ISL <= 2) |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 965 | return CHIPSET_ICH9; |
Nico Huber | 83b01c8 | 2021-06-17 21:20:09 +0200 | [diff] [blame] | 966 | if (content->ISL <= 10) |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 967 | return CHIPSET_ICH10; |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 968 | if (content->ISL <= 16) |
| 969 | return CHIPSET_5_SERIES_IBEX_PEAK; |
Nico Huber | 83b01c8 | 2021-06-17 21:20:09 +0200 | [diff] [blame] | 970 | if (content->FLMAP2 == 0) { |
Nico Huber | 81965f3 | 2021-06-17 23:25:35 +0200 | [diff] [blame] | 971 | if (content->ISL == 19) |
| 972 | return CHIPSET_APOLLO_LAKE; |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 973 | if (content->ISL == 23) |
| 974 | return CHIPSET_GEMINI_LAKE; |
| 975 | warn_peculiar_desc("Gemini Lake"); |
Nico Huber | 81965f3 | 2021-06-17 23:25:35 +0200 | [diff] [blame] | 976 | return CHIPSET_GEMINI_LAKE; |
Nico Huber | d2d3993 | 2019-01-18 16:49:37 +0100 | [diff] [blame] | 977 | } |
Jonathan Zhang | 3bf7cfb | 2021-08-30 23:25:06 -0700 | [diff] [blame] | 978 | if (content->ISL <= 80) |
| 979 | return CHIPSET_C620_SERIES_LEWISBURG; |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 980 | warn_peculiar_desc("Ibex Peak"); |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 981 | return CHIPSET_5_SERIES_IBEX_PEAK; |
Nico Huber | 3ad9aad | 2021-06-17 22:05:00 +0200 | [diff] [blame] | 982 | } else if (upper->MDTBA == 0x00) { |
| 983 | if (content->ICCRIBA < 0x31 && content->FMSBA < 0x30) { |
| 984 | if (content->MSL == 0 && content->ISL <= 17) |
| 985 | return CHIPSET_BAYTRAIL; |
| 986 | if (content->MSL <= 1 && content->ISL <= 18) |
| 987 | return CHIPSET_6_SERIES_COUGAR_POINT; |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 988 | if (content->MSL <= 1 && content->ISL <= 21) |
| 989 | return CHIPSET_8_SERIES_LYNX_POINT; |
| 990 | warn_peculiar_desc("Lynx Point"); |
Nico Huber | 81965f3 | 2021-06-17 23:25:35 +0200 | [diff] [blame] | 991 | return CHIPSET_8_SERIES_LYNX_POINT; |
Nico Huber | 3ad9aad | 2021-06-17 22:05:00 +0200 | [diff] [blame] | 992 | } |
| 993 | if (content->NM == 6) { |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 994 | if (content->ICCRIBA <= 0x34) |
| 995 | return CHIPSET_C620_SERIES_LEWISBURG; |
| 996 | warn_peculiar_desc("C620 series"); |
Nico Huber | 2a5dfaf | 2019-07-04 16:01:51 +0200 | [diff] [blame] | 997 | return CHIPSET_C620_SERIES_LEWISBURG; |
Nico Huber | 3ad9aad | 2021-06-17 22:05:00 +0200 | [diff] [blame] | 998 | } |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 999 | if (content->ICCRIBA == 0x31) |
| 1000 | return CHIPSET_100_SERIES_SUNRISE_POINT; |
| 1001 | warn_peculiar_desc("100 series"); |
Nico Huber | 83b01c8 | 2021-06-17 21:20:09 +0200 | [diff] [blame] | 1002 | return CHIPSET_100_SERIES_SUNRISE_POINT; |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 1003 | } else { |
David Hendricks | 66565a7 | 2021-09-20 21:56:40 -0700 | [diff] [blame] | 1004 | if (content->ICCRIBA == 0x34) |
| 1005 | return CHIPSET_300_SERIES_CANNON_POINT; |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 1006 | if (content->CSSL == 0x11) |
| 1007 | return CHIPSET_500_SERIES_TIGER_POINT; |
Nico Huber | 29c23dd | 2022-12-21 15:25:09 +0000 | [diff] [blame] | 1008 | if (content->CSSL == 0x14) /* backwards compatible Alder Point */ |
| 1009 | return CHIPSET_500_SERIES_TIGER_POINT; |
Nico Huber | 756b6b3 | 2022-12-21 17:15:13 +0000 | [diff] [blame] | 1010 | if (content->CSSL == 0x03) { |
| 1011 | if (content->CSSO == 0x58) |
| 1012 | return CHIPSET_ELKHART_LAKE; |
| 1013 | else if (content->CSSO == 0x6c) /* backwards compatible Jasper Lake */ |
| 1014 | return CHIPSET_300_SERIES_CANNON_POINT; |
| 1015 | } |
Michał Żygowski | 5c9f542 | 2021-06-16 15:13:54 +0200 | [diff] [blame] | 1016 | msg_pwarn("Unknown flash descriptor, assuming 500 series compatibility.\n"); |
| 1017 | return CHIPSET_500_SERIES_TIGER_POINT; |
Nico Huber | 1dc3d42 | 2017-06-17 00:09:31 +0200 | [diff] [blame] | 1018 | } |
| 1019 | } |
| 1020 | |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1021 | /* len is the length of dump in bytes */ |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1022 | int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len, |
| 1023 | enum ich_chipset *const cs, struct ich_descriptors *const desc) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1024 | { |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 1025 | ssize_t i, max_count; |
| 1026 | size_t pch_bug_offset = 0; |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1027 | |
| 1028 | if (dump == NULL || desc == NULL) |
| 1029 | return ICH_RET_PARAM; |
| 1030 | |
| 1031 | if (dump[0] != DESCRIPTOR_MODE_SIGNATURE) { |
| 1032 | if (dump[4] == DESCRIPTOR_MODE_SIGNATURE) |
| 1033 | pch_bug_offset = 4; |
| 1034 | else |
| 1035 | return ICH_RET_ERR; |
| 1036 | } |
| 1037 | |
| 1038 | /* map */ |
Nico Huber | 9e14aed | 2017-03-28 17:08:46 +0200 | [diff] [blame] | 1039 | if (len < (4 + pch_bug_offset) * 4) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1040 | return ICH_RET_OOB; |
| 1041 | desc->content.FLVALSIG = dump[0 + pch_bug_offset]; |
| 1042 | desc->content.FLMAP0 = dump[1 + pch_bug_offset]; |
| 1043 | desc->content.FLMAP1 = dump[2 + pch_bug_offset]; |
| 1044 | desc->content.FLMAP2 = dump[3 + pch_bug_offset]; |
| 1045 | |
| 1046 | /* component */ |
Nico Huber | 9e14aed | 2017-03-28 17:08:46 +0200 | [diff] [blame] | 1047 | if (len < getFCBA(&desc->content) + 3 * 4) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1048 | return ICH_RET_OOB; |
| 1049 | desc->component.FLCOMP = dump[(getFCBA(&desc->content) >> 2) + 0]; |
| 1050 | desc->component.FLILL = dump[(getFCBA(&desc->content) >> 2) + 1]; |
| 1051 | desc->component.FLPB = dump[(getFCBA(&desc->content) >> 2) + 2]; |
| 1052 | |
Nico Huber | 8a03c90 | 2021-06-17 21:23:29 +0200 | [diff] [blame] | 1053 | /* upper map */ |
| 1054 | desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0]; |
| 1055 | |
| 1056 | /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide: |
| 1057 | * "Identifies the 1s based number of DWORDS contained in the VSCC |
| 1058 | * Table. Each SPI component entry in the table is 2 DWORDS long." So |
| 1059 | * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A |
| 1060 | * check ensures that the maximum offset actually accessed is available. |
| 1061 | */ |
| 1062 | if (len < getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8)) |
| 1063 | return ICH_RET_OOB; |
| 1064 | |
| 1065 | for (i = 0; i < desc->upper.VTL/2; i++) { |
| 1066 | desc->upper.vscc_table[i].JID = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0]; |
| 1067 | desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1]; |
| 1068 | } |
| 1069 | |
Nico Huber | 67d7179 | 2017-06-17 03:10:15 +0200 | [diff] [blame] | 1070 | if (*cs == CHIPSET_ICH_UNKNOWN) { |
Nico Huber | db878fb | 2024-07-19 17:37:09 +0200 | [diff] [blame^] | 1071 | *cs = guess_ich_chipset(&desc->content, &desc->upper); |
Nico Huber | 67d7179 | 2017-06-17 03:10:15 +0200 | [diff] [blame] | 1072 | prettyprint_ich_chipset(*cs); |
| 1073 | } |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1074 | |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1075 | /* region */ |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1076 | const ssize_t nr = ich_number_of_regions(*cs, &desc->content); |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 1077 | if (nr < 0 || len < getFRBA(&desc->content) + (size_t)nr * 4) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1078 | return ICH_RET_OOB; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1079 | for (i = 0; i < nr; i++) |
| 1080 | desc->region.FLREGs[i] = dump[(getFRBA(&desc->content) >> 2) + i]; |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1081 | |
| 1082 | /* master */ |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1083 | const ssize_t nm = ich_number_of_masters(*cs, &desc->content); |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 1084 | if (nm < 0 || len < getFMBA(&desc->content) + (size_t)nm * 4) |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1085 | return ICH_RET_OOB; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1086 | for (i = 0; i < nm; i++) |
| 1087 | desc->master.FLMSTRs[i] = dump[(getFMBA(&desc->content) >> 2) + i]; |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1088 | |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1089 | /* MCH/PROC (aka. North) straps */ |
| 1090 | if (len < getFMSBA(&desc->content) + desc->content.MSL * 4) |
| 1091 | return ICH_RET_OOB; |
| 1092 | |
| 1093 | /* limit the range to be written */ |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 1094 | max_count = MIN(sizeof(desc->north.STRPs) / 4, desc->content.MSL); |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 1095 | for (i = 0; i < max_count; i++) |
| 1096 | desc->north.STRPs[i] = dump[(getFMSBA(&desc->content) >> 2) + i]; |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1097 | |
| 1098 | /* ICH/PCH (aka. South) straps */ |
| 1099 | if (len < getFISBA(&desc->content) + desc->content.ISL * 4) |
| 1100 | return ICH_RET_OOB; |
| 1101 | |
| 1102 | /* limit the range to be written */ |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 1103 | max_count = MIN(sizeof(desc->south.STRPs) / 4, desc->content.ISL); |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 1104 | for (i = 0; i < max_count; i++) |
| 1105 | desc->south.STRPs[i] = dump[(getFISBA(&desc->content) >> 2) + i]; |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1106 | |
| 1107 | return ICH_RET_OK; |
| 1108 | } |
| 1109 | |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 1110 | #ifndef ICH_DESCRIPTORS_FROM_DUMP_ONLY |
Stefan Tauner | b385096 | 2011-12-24 00:00:32 +0000 | [diff] [blame] | 1111 | |
Stefan Tauner | d0c5dc2 | 2011-10-20 12:57:14 +0000 | [diff] [blame] | 1112 | /** Returns the integer representation of the component density with index |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 1113 | \em idx in bytes or -1 if the correct size can not be determined. */ |
| 1114 | int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx) |
Stefan Tauner | d0c5dc2 | 2011-10-20 12:57:14 +0000 | [diff] [blame] | 1115 | { |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 1116 | if (idx > 1) { |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 1117 | msg_perr("Only ICH SPI component index 0 or 1 are supported yet.\n"); |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 1118 | return -1; |
Stefan Tauner | d0c5dc2 | 2011-10-20 12:57:14 +0000 | [diff] [blame] | 1119 | } |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 1120 | if (cs == CHIPSET_ICH_UNKNOWN) { |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 1121 | msg_pwarn("Density encoding is unknown on this chipset.\n"); |
| 1122 | return -1; |
Stefan Tauner | d0c5dc2 | 2011-10-20 12:57:14 +0000 | [diff] [blame] | 1123 | } |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 1124 | |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 1125 | if (desc->content.NC == 0 && idx > 0) |
| 1126 | return 0; |
| 1127 | |
| 1128 | const unsigned int max_idx = cs < CHIPSET_HAS_NEW_COMPONENT_DENSITY ? 5 : 7; |
| 1129 | const unsigned int size_idx = get_density_index(cs, desc, idx); |
| 1130 | |
| 1131 | if (size_idx > max_idx) { |
Tai-Hong Wu | 60dead4 | 2015-01-05 23:00:14 +0000 | [diff] [blame] | 1132 | msg_perr("Density of ICH SPI component with index %d is invalid.\n" |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 1133 | "Encoded density is 0x%x while maximum allowed is 0x%x.\n", |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 1134 | idx, size_idx, max_idx); |
Stefan Tauner | 2ba9f6e | 2014-08-20 15:39:19 +0000 | [diff] [blame] | 1135 | return -1; |
| 1136 | } |
| 1137 | |
Nico Huber | dfd0647 | 2024-07-14 23:45:05 +0200 | [diff] [blame] | 1138 | return 1 << (19 + size_idx); |
Stefan Tauner | d0c5dc2 | 2011-10-20 12:57:14 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
Nico Huber | 8d49499 | 2017-06-19 12:18:33 +0200 | [diff] [blame] | 1141 | /* Only used by ichspi.c */ |
| 1142 | #if CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__)) |
Nico Huber | d54e4f4 | 2017-03-23 23:45:47 +0100 | [diff] [blame] | 1143 | static uint32_t read_descriptor_reg(enum ich_chipset cs, uint8_t section, uint16_t offset, void *spibar) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1144 | { |
| 1145 | uint32_t control = 0; |
| 1146 | control |= (section << FDOC_FDSS_OFF) & FDOC_FDSS; |
| 1147 | control |= (offset << FDOC_FDSI_OFF) & FDOC_FDSI; |
Nico Huber | b2ad9fd | 2024-07-14 23:18:53 +0200 | [diff] [blame] | 1148 | |
| 1149 | if (cs >= SPI_ENGINE_PCH100) { |
Nico Huber | d54e4f4 | 2017-03-23 23:45:47 +0100 | [diff] [blame] | 1150 | mmio_le_writel(control, spibar + PCH100_REG_FDOC); |
| 1151 | return mmio_le_readl(spibar + PCH100_REG_FDOD); |
Nico Huber | b2ad9fd | 2024-07-14 23:18:53 +0200 | [diff] [blame] | 1152 | } else { |
Nico Huber | d54e4f4 | 2017-03-23 23:45:47 +0100 | [diff] [blame] | 1153 | mmio_le_writel(control, spibar + ICH9_REG_FDOC); |
| 1154 | return mmio_le_readl(spibar + ICH9_REG_FDOD); |
| 1155 | } |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1156 | } |
| 1157 | |
Nico Huber | d54e4f4 | 2017-03-23 23:45:47 +0100 | [diff] [blame] | 1158 | int read_ich_descriptors_via_fdo(enum ich_chipset cs, void *spibar, struct ich_descriptors *desc) |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1159 | { |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 1160 | ssize_t i; |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1161 | struct ich_desc_region *r = &desc->region; |
| 1162 | |
| 1163 | /* Test if bit-fields are working as expected. |
| 1164 | * FIXME: Replace this with dynamic bitfield fixup |
| 1165 | */ |
| 1166 | for (i = 0; i < 4; i++) |
| 1167 | desc->region.FLREGs[i] = 0x5A << (i * 8); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1168 | if (r->old_reg[0].base != 0x005A || r->old_reg[0].limit != 0x0000 || |
| 1169 | r->old_reg[1].base != 0x1A00 || r->old_reg[1].limit != 0x0000 || |
| 1170 | r->old_reg[2].base != 0x0000 || r->old_reg[2].limit != 0x005A || |
| 1171 | r->old_reg[3].base != 0x0000 || r->old_reg[3].limit != 0x1A00) { |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1172 | msg_pdbg("The combination of compiler and CPU architecture used" |
| 1173 | "does not lay out bit-fields as expected, sorry.\n"); |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1174 | msg_pspew("r->old_reg[0].base = 0x%04X (0x005A)\n", r->old_reg[0].base); |
| 1175 | msg_pspew("r->old_reg[0].limit = 0x%04X (0x0000)\n", r->old_reg[0].limit); |
| 1176 | msg_pspew("r->old_reg[1].base = 0x%04X (0x1A00)\n", r->old_reg[1].base); |
| 1177 | msg_pspew("r->old_reg[1].limit = 0x%04X (0x0000)\n", r->old_reg[1].limit); |
| 1178 | msg_pspew("r->old_reg[2].base = 0x%04X (0x0000)\n", r->old_reg[2].base); |
| 1179 | msg_pspew("r->old_reg[2].limit = 0x%04X (0x005A)\n", r->old_reg[2].limit); |
| 1180 | msg_pspew("r->old_reg[3].base = 0x%04X (0x0000)\n", r->old_reg[3].base); |
| 1181 | msg_pspew("r->old_reg[3].limit = 0x%04X (0x1A00)\n", r->old_reg[3].limit); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1182 | return ICH_RET_ERR; |
| 1183 | } |
| 1184 | |
Stefan Tauner | a1a14ec | 2012-08-13 08:45:13 +0000 | [diff] [blame] | 1185 | msg_pdbg2("Reading flash descriptors mapped by the chipset via FDOC/FDOD..."); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1186 | /* content section */ |
Nico Huber | d54e4f4 | 2017-03-23 23:45:47 +0100 | [diff] [blame] | 1187 | desc->content.FLVALSIG = read_descriptor_reg(cs, 0, 0, spibar); |
| 1188 | desc->content.FLMAP0 = read_descriptor_reg(cs, 0, 1, spibar); |
| 1189 | desc->content.FLMAP1 = read_descriptor_reg(cs, 0, 2, spibar); |
| 1190 | desc->content.FLMAP2 = read_descriptor_reg(cs, 0, 3, spibar); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1191 | |
| 1192 | /* component section */ |
Nico Huber | d54e4f4 | 2017-03-23 23:45:47 +0100 | [diff] [blame] | 1193 | desc->component.FLCOMP = read_descriptor_reg(cs, 1, 0, spibar); |
| 1194 | desc->component.FLILL = read_descriptor_reg(cs, 1, 1, spibar); |
| 1195 | desc->component.FLPB = read_descriptor_reg(cs, 1, 2, spibar); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1196 | |
| 1197 | /* region section */ |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1198 | const ssize_t nr = ich_number_of_regions(cs, &desc->content); |
| 1199 | if (nr < 0) { |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1200 | msg_pdbg2("%s: number of regions too high (%d) - failed\n", |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1201 | __func__, desc->content.NR + 1); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1202 | return ICH_RET_ERR; |
| 1203 | } |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1204 | for (i = 0; i < nr; i++) |
Nico Huber | d54e4f4 | 2017-03-23 23:45:47 +0100 | [diff] [blame] | 1205 | desc->region.FLREGs[i] = read_descriptor_reg(cs, 2, i, spibar); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1206 | |
| 1207 | /* master section */ |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1208 | const ssize_t nm = ich_number_of_masters(cs, &desc->content); |
| 1209 | if (nm < 0) { |
| 1210 | msg_pdbg2("%s: number of masters too high (%d) - failed\n", |
| 1211 | __func__, desc->content.NM + 1); |
| 1212 | return ICH_RET_ERR; |
| 1213 | } |
| 1214 | for (i = 0; i < nm; i++) |
| 1215 | desc->master.FLMSTRs[i] = read_descriptor_reg(cs, 3, i, spibar); |
Stefan Tauner | 1e14639 | 2011-09-15 23:52:55 +0000 | [diff] [blame] | 1216 | |
| 1217 | /* Accessing the strap section via FDOC/D is only possible on ICH8 and |
| 1218 | * reading the upper map is impossible on all chipsets, so don't bother. |
| 1219 | */ |
| 1220 | |
| 1221 | msg_pdbg2(" done.\n"); |
| 1222 | return ICH_RET_OK; |
| 1223 | } |
Nico Huber | 8d49499 | 2017-06-19 12:18:33 +0200 | [diff] [blame] | 1224 | #endif |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1225 | |
| 1226 | /** |
| 1227 | * @brief Read a layout from the dump of an Intel ICH descriptor. |
| 1228 | * |
| 1229 | * @param layout Pointer where to store the layout. |
| 1230 | * @param dump The descriptor dump to read from. |
| 1231 | * @param len The length of the descriptor dump. |
| 1232 | * |
| 1233 | * @return 0 on success, |
Nico Huber | 70461a9 | 2019-06-15 14:56:19 +0200 | [diff] [blame] | 1234 | * 1 if the descriptor couldn't be parsed, |
| 1235 | * 2 when out of memory. |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1236 | */ |
Nico Huber | 5bd990c | 2019-06-16 19:46:46 +0200 | [diff] [blame] | 1237 | int layout_from_ich_descriptors( |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 1238 | struct flashprog_layout **const layout, |
Nico Huber | 5bd990c | 2019-06-16 19:46:46 +0200 | [diff] [blame] | 1239 | const void *const dump, const size_t len) |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1240 | { |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1241 | static const char *const regions[] = { |
David Hendricks | a521636 | 2017-08-08 20:02:22 -0700 | [diff] [blame] | 1242 | "fd", "bios", "me", "gbe", "pd", "reg5", "bios2", "reg7", "ec", "reg9", "ie", |
| 1243 | "10gbe", "reg12", "reg13", "reg14", "reg15" |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1244 | }; |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1245 | |
| 1246 | struct ich_descriptors desc; |
Nico Huber | fa62294 | 2017-03-24 17:25:37 +0100 | [diff] [blame] | 1247 | enum ich_chipset cs = CHIPSET_ICH_UNKNOWN; |
| 1248 | if (read_ich_descriptors_from_dump(dump, len, &cs, &desc)) |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1249 | return 1; |
| 1250 | |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 1251 | if (flashprog_layout_new(layout)) |
Nico Huber | 5bd990c | 2019-06-16 19:46:46 +0200 | [diff] [blame] | 1252 | return 2; |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1253 | |
Nico Huber | 92e0b62 | 2019-06-15 15:55:11 +0200 | [diff] [blame] | 1254 | ssize_t i; |
Nico Huber | 519be66 | 2018-12-23 20:03:35 +0100 | [diff] [blame] | 1255 | const ssize_t nr = MIN(ich_number_of_regions(cs, &desc.content), (ssize_t)ARRAY_SIZE(regions)); |
Nico Huber | 92e0b62 | 2019-06-15 15:55:11 +0200 | [diff] [blame] | 1256 | for (i = 0; i < nr; ++i) { |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1257 | const chipoff_t base = ICH_FREG_BASE(desc.region.FLREGs[i]); |
Nico Huber | 0bb3f71 | 2017-03-29 16:44:33 +0200 | [diff] [blame] | 1258 | const chipoff_t limit = ICH_FREG_LIMIT(desc.region.FLREGs[i]); |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1259 | if (limit <= base) |
| 1260 | continue; |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 1261 | if (flashprog_layout_add_region(*layout, base, limit, regions[i])) { |
| 1262 | flashprog_layout_release(*layout); |
Nico Huber | 5bd990c | 2019-06-16 19:46:46 +0200 | [diff] [blame] | 1263 | *layout = NULL; |
Nico Huber | 70461a9 | 2019-06-15 14:56:19 +0200 | [diff] [blame] | 1264 | return 2; |
Nico Huber | 5bd990c | 2019-06-16 19:46:46 +0200 | [diff] [blame] | 1265 | } |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1266 | } |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 1267 | return 0; |
| 1268 | } |
| 1269 | |
Nico Huber | ad18631 | 2016-05-02 15:15:29 +0200 | [diff] [blame] | 1270 | #endif /* ICH_DESCRIPTORS_FROM_DUMP_ONLY */ |