Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * inteltool - dump all registers on an Intel CPU + chipset based system. |
| 3 | * |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008-2010 by coresystems GmbH |
| 5 | * |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 23 | #include <inttypes.h> |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 24 | #include "inteltool.h" |
| 25 | |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 26 | static const io_register_t sandybridge_mch_registers[] = { |
| 27 | /* Channel 0 */ |
| 28 | { 0x4000, 4, "TC_DBP_C0" }, // Timing of DDR Bin Parameters |
| 29 | { 0x4004, 4, "TC_RAP_C0" }, // Timing of DDR Regular Access Parameters |
| 30 | { 0x4028, 4, "SC_IO_LATENCY_C0" }, // IO Latency Configuration |
| 31 | { 0x42A4, 4, "TC_SRFTP_C0" }, // Self-Refresh Timing Parameters |
| 32 | { 0x40B0, 4, "PM_PDWN_config_C0" }, // Power-down Configuration |
| 33 | { 0x4294, 4, "TC_RFP_C0" }, // Refresh Parameters |
| 34 | { 0x4298, 4, "TC_RFTP_C0" }, // Refresh Timing Parameters |
| 35 | /* Channel 1 */ |
| 36 | { 0x4400, 4, "TC_DBP_C1" }, // Timing of DDR Bin Parameters |
| 37 | { 0x4404, 4, "TC_RAP_C1" }, // Timing of DDR Regular Access Parameters |
| 38 | { 0x4428, 4, "SC_IO_LATENCY_C1" }, // IO Latency Configuration |
| 39 | { 0x46A4, 4, "TC_SRFTP_C1" }, // Self-Refresh Timing Parameters |
| 40 | { 0x44B0, 4, "PM_PDWN_config_C1" }, // Power-down Configuration |
| 41 | { 0x4694, 4, "TC_RFP_C1" }, // Refresh Parameters |
| 42 | { 0x4698, 4, "TC_RFTP_C1" }, // Refresh Timing Parameters |
| 43 | /* Integrated Memory Peripheral Hub (IMPH) */ |
| 44 | { 0x740C, 4, "CRDTCTL3" }, // Credit Control 3 |
| 45 | /* Common Registers */ |
| 46 | { 0x5000, 4, "MAD_CHNL" }, // Address decoder Channel Configuration |
| 47 | { 0x5004, 4, "MAD_DIMM_ch0" }, // Address Decode Channel 0 |
| 48 | { 0x5008, 4, "MAD_DIMM_ch1" }, // Address Decode Channel 1 |
| 49 | { 0x5060, 4, "PM_SREF_config" }, // Self Refresh Configuration |
| 50 | /* MMIO Registers Broadcast Group */ |
| 51 | { 0x4CB0, 4, "PM_PDWN_config" }, // Power-down Configuration |
| 52 | { 0x4F84, 4, "PM_CMD_PWR" }, // Power Management Command Power |
| 53 | { 0x4F88, 4, "PM_BW_LIMIT_config" }, // BW Limit Configuration |
| 54 | { 0x4F8C, 4, "RESERVED" }, // Reserved, default value - 0xFF1D1519 |
| 55 | /* PCU MCHBAR Registers */ |
| 56 | { 0x5880, 4, "MEM_TRML_ESTIMATION_CONFIG" }, // Memory Thermal Estimation Configuration |
| 57 | { 0x5884, 4, "RESERVED" }, // Reserved |
| 58 | { 0x5888, 4, "MEM_TRML_THRESHOLDS_CONFIG" }, // Memory Thermal Thresholds Configuration |
| 59 | { 0x58A0, 4, "MEM_TRML_STATUS_REPORT" }, // Memory Thermal Status Report |
| 60 | { 0x58A4, 4, "MEM_TRML_TEMPERATURE_REPORT" }, // Memory Thermal Temperature Report |
| 61 | { 0x58A8, 4, "MEM_TRML_INTERRUPT" }, // Memory Thermal Interrupt |
| 62 | { 0x5948, 4, "GT_PERF_STATUS" }, // GT Performance Status |
| 63 | { 0x5998, 4, "RP_STATE_CAP" }, // RP State Capability |
| 64 | { 0x5D10, 8, "SSKPD" }, // Sticky Scratchpad Data |
| 65 | }; |
| 66 | |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 67 | /* |
| 68 | * (G)MCH MMIO Config Space |
| 69 | */ |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 70 | int print_mchbar(struct pci_dev *nb, struct pci_access *pacc) |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 71 | { |
| 72 | int i, size = (16 * 1024); |
| 73 | volatile uint8_t *mchbar; |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 74 | uint64_t mchbar_phys; |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 75 | const io_register_t *mch_registers = NULL; |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 76 | struct pci_dev *nb_device6; /* "overflow device" on i865 */ |
| 77 | uint16_t pcicmd6; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 78 | |
| 79 | printf("\n============= MCHBAR ============\n\n"); |
| 80 | |
| 81 | switch (nb->device_id) { |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 82 | case PCI_DEVICE_ID_INTEL_82865: |
| 83 | /* |
| 84 | * On i865, the memory access enable/disable bit (MCHBAREN on |
| 85 | * i945/i965) is not in the MCHBAR (i945/i965) register but in |
| 86 | * the PCICMD6 register. BAR6 and PCICMD6 reside on device 6. |
| 87 | * |
| 88 | * The actual base address is in BAR6 on i865 where on |
| 89 | * i945/i965 the base address is in MCHBAR. |
| 90 | */ |
| 91 | nb_device6 = pci_get_dev(pacc, 0, 0, 0x06, 0); /* Device 6 */ |
| 92 | mchbar_phys = pci_read_long(nb_device6, 0x10); /* BAR6 */ |
| 93 | pcicmd6 = pci_read_long(nb_device6, 0x04); /* PCICMD6 */ |
| 94 | |
| 95 | /* Try to enable Memory Access Enable (MAE). */ |
| 96 | if (!(pcicmd6 & (1 << 1))) { |
| 97 | printf("Access to BAR6 is currently disabled, " |
| 98 | "attempting to enable.\n"); |
| 99 | pci_write_long(nb_device6, 0x04, pcicmd6 | (1 << 1)); |
| 100 | if (pci_read_long(nb_device6, 0x04) & (1 << 1)) |
| 101 | printf("Enabled successfully.\n"); |
| 102 | else |
| 103 | printf("Enable FAILED!\n"); |
| 104 | } |
| 105 | mchbar_phys &= 0xfffff000; /* Bits 31:12 from BAR6 */ |
| 106 | break; |
Pat Erley | ca3548e | 2010-04-21 06:23:19 +0000 | [diff] [blame] | 107 | case PCI_DEVICE_ID_INTEL_82915: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 108 | case PCI_DEVICE_ID_INTEL_82945GM: |
Björn Busse | 2d33dc4 | 2010-08-01 15:33:30 +0000 | [diff] [blame] | 109 | case PCI_DEVICE_ID_INTEL_82945GSE: |
Stefan Reinauer | 3d9a12f | 2008-11-02 11:11:40 +0000 | [diff] [blame] | 110 | case PCI_DEVICE_ID_INTEL_82945P: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 111 | case PCI_DEVICE_ID_INTEL_82975X: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 112 | mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe; |
| 113 | break; |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 114 | case PCI_DEVICE_ID_INTEL_PM965: |
Loïc Grenié | 8429de7 | 2009-11-02 15:01:49 +0000 | [diff] [blame] | 115 | case PCI_DEVICE_ID_INTEL_82Q35: |
| 116 | case PCI_DEVICE_ID_INTEL_82G33: |
| 117 | case PCI_DEVICE_ID_INTEL_82Q33: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 118 | mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe; |
| 119 | mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32; |
| 120 | break; |
Corey Osgood | 23d98c7 | 2010-07-29 19:25:31 +0000 | [diff] [blame] | 121 | case PCI_DEVICE_ID_INTEL_Q965: |
| 122 | case PCI_DEVICE_ID_INTEL_ATOM_DXXX: |
| 123 | case PCI_DEVICE_ID_INTEL_ATOM_NXXX: |
| 124 | mchbar_phys = pci_read_long(nb, 0x48); |
| 125 | |
| 126 | /* Test if bit 0 of the MCHBAR reg is 1 to enable memory reads. |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 127 | * If it isn't, try to set it. This may fail, because there is |
| 128 | * some bit that locks that bit, and isn't in the public |
Corey Osgood | 23d98c7 | 2010-07-29 19:25:31 +0000 | [diff] [blame] | 129 | * datasheets. |
| 130 | */ |
| 131 | |
| 132 | if(!(mchbar_phys & 1)) |
| 133 | { |
| 134 | printf("Access to the MCHBAR is currently disabled, "\ |
| 135 | "attempting to enable.\n"); |
| 136 | mchbar_phys |= 0x1; |
| 137 | pci_write_long(nb, 0x48, mchbar_phys); |
| 138 | if(pci_read_long(nb, 0x48) & 1) |
| 139 | printf("Enabled successfully.\n"); |
| 140 | else |
| 141 | printf("Enable FAILED!\n"); |
| 142 | } |
| 143 | mchbar_phys &= 0xfffffffe; |
| 144 | mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32; |
| 145 | break; |
Maciej Pijanka | 90d1740 | 2009-09-30 17:05:46 +0000 | [diff] [blame] | 146 | case PCI_DEVICE_ID_INTEL_82443LX: |
| 147 | case PCI_DEVICE_ID_INTEL_82443BX: |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 148 | case PCI_DEVICE_ID_INTEL_82810: |
Joseph Smith | e10757e | 2010-06-16 22:21:19 +0000 | [diff] [blame] | 149 | case PCI_DEVICE_ID_INTEL_82810E_MC: |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 150 | case PCI_DEVICE_ID_INTEL_82810DC: |
Stefan Reinauer | 0484481 | 2010-02-22 11:26:06 +0000 | [diff] [blame] | 151 | case PCI_DEVICE_ID_INTEL_82830M: |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 152 | printf("This northbridge does not have MCHBAR.\n"); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 153 | return 1; |
Anton Kochkov | da0b456 | 2010-05-30 12:33:12 +0000 | [diff] [blame] | 154 | case PCI_DEVICE_ID_INTEL_GS45: |
Ruud Schramp | bb41f50 | 2011-04-04 07:53:19 +0200 | [diff] [blame] | 155 | case PCI_DEVICE_ID_INTEL_X44: |
| 156 | case PCI_DEVICE_ID_INTEL_32X0: |
Anton Kochkov | da0b456 | 2010-05-30 12:33:12 +0000 | [diff] [blame] | 157 | mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe; |
| 158 | mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32; |
| 159 | break; |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 160 | case PCI_DEVICE_ID_INTEL_HM65E: |
| 161 | mchbar_phys = pci_read_long(nb, 0x48) & 0xffff8000; |
| 162 | mch_registers = sandybridge_mch_registers; |
| 163 | size = ARRAY_SIZE(sandybridge_mch_registers); |
| 164 | break; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 165 | default: |
| 166 | printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n"); |
| 167 | return 1; |
| 168 | } |
| 169 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 170 | mchbar = map_physical(mchbar_phys, size); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 171 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 172 | if (mchbar == NULL) { |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 173 | if (nb->device_id == PCI_DEVICE_ID_INTEL_82865) |
| 174 | perror("Error mapping BAR6"); |
| 175 | else |
| 176 | perror("Error mapping MCHBAR"); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 177 | exit(1); |
| 178 | } |
| 179 | |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 180 | if (nb->device_id == PCI_DEVICE_ID_INTEL_82865) |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 181 | printf("BAR6 = 0x%08" PRIx64 " (MEM)\n\n", mchbar_phys); |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 182 | else |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 183 | printf("MCHBAR = 0x%08" PRIx64 " (MEM)\n\n", mchbar_phys); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 184 | |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 185 | if (mch_registers != NULL) { |
| 186 | for (i = 0; i < size; i++) { |
| 187 | switch (mch_registers[i].size) { |
| 188 | case 8: |
| 189 | printf("mchbase+0x%04x: 0x%08lx (%s)\n", |
| 190 | mch_registers[i].addr, |
| 191 | *(uint64_t *)(mchbar+mch_registers[i].addr), |
| 192 | mch_registers[i].name); |
| 193 | break; |
| 194 | case 4: |
| 195 | printf("mchbase+0x%04x: 0x%08x (%s)\n", |
| 196 | mch_registers[i].addr, |
| 197 | *(uint32_t *)(mchbar+mch_registers[i].addr), |
| 198 | mch_registers[i].name); |
| 199 | break; |
| 200 | case 2: |
| 201 | printf("mchbase+0x%04x: 0x%04x (%s)\n", |
| 202 | mch_registers[i].addr, |
| 203 | *(uint16_t *)(mchbar+mch_registers[i].addr), |
| 204 | mch_registers[i].name); |
| 205 | break; |
| 206 | case 1: |
| 207 | printf("mchbase+0x%04x: 0x%02x (%s)\n", |
| 208 | mch_registers[i].addr, |
| 209 | *(uint8_t *)(mchbar+mch_registers[i].addr), |
| 210 | mch_registers[i].name); |
| 211 | break; |
| 212 | } |
| 213 | } |
| 214 | } else { |
| 215 | for (i = 0; i < size; i += 4) { |
| 216 | if (*(uint32_t *)(mchbar + i)) |
| 217 | printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i)); |
| 218 | } |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 221 | unmap_physical((void *)mchbar, size); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | |