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