blob: 62d72177b027b765ced0583494498023427bec25 [file] [log] [blame]
Stefan Reinauer23190272008-08-20 13:41:24 +00001/*
2 * inteltool - dump all registers on an Intel CPU + chipset based system.
3 *
Stefan Reinauer14e22772010-04-27 06:56:47 +00004 * Copyright (C) 2008-2010 by coresystems GmbH
5 *
Stefan Reinauer23190272008-08-20 13:41:24 +00006 * 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 Reinauera7b296d2011-11-14 12:40:34 -080023#include <inttypes.h>
Stefan Reinauer23190272008-08-20 13:41:24 +000024#include "inteltool.h"
25
Anton Kochkovc7fc4422012-07-21 06:36:47 +040026static 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 Reinauer23190272008-08-20 13:41:24 +000067/*
68 * (G)MCH MMIO Config Space
69 */
Idwer Vollering312fc962010-12-17 22:34:58 +000070int print_mchbar(struct pci_dev *nb, struct pci_access *pacc)
Stefan Reinauer23190272008-08-20 13:41:24 +000071{
72 int i, size = (16 * 1024);
73 volatile uint8_t *mchbar;
Idwer Vollering312fc962010-12-17 22:34:58 +000074 uint64_t mchbar_phys;
Anton Kochkovc7fc4422012-07-21 06:36:47 +040075 const io_register_t *mch_registers = NULL;
Idwer Vollering312fc962010-12-17 22:34:58 +000076 struct pci_dev *nb_device6; /* "overflow device" on i865 */
77 uint16_t pcicmd6;
Stefan Reinauer23190272008-08-20 13:41:24 +000078
79 printf("\n============= MCHBAR ============\n\n");
80
81 switch (nb->device_id) {
Idwer Vollering312fc962010-12-17 22:34:58 +000082 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 Erleyca3548e2010-04-21 06:23:19 +0000107 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +0000108 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +0000109 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +0000110 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Tauner04c06002012-10-13 02:19:30 +0200111 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +0000112 mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe;
113 break;
Stefan Tauner04c06002012-10-13 02:19:30 +0200114 case PCI_DEVICE_ID_INTEL_82965PM:
115 case PCI_DEVICE_ID_INTEL_82Q35:
116 case PCI_DEVICE_ID_INTEL_82G33:
117 case PCI_DEVICE_ID_INTEL_82Q33:
118 mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe;
119 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
120 break;
121 case PCI_DEVICE_ID_INTEL_82Q965:
Corey Osgood23d98c72010-07-29 19:25:31 +0000122 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
123 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Stefan Tauner04c06002012-10-13 02:19:30 +0200124 mchbar_phys = pci_read_long(nb, 0x48);
Corey Osgood23d98c72010-07-29 19:25:31 +0000125
126 /* Test if bit 0 of the MCHBAR reg is 1 to enable memory reads.
Idwer Vollering312fc962010-12-17 22:34:58 +0000127 * 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 Osgood23d98c72010-07-29 19:25:31 +0000129 * datasheets.
130 */
131
132 if(!(mchbar_phys & 1))
133 {
Stefan Tauner04c06002012-10-13 02:19:30 +0200134 printf("Access to the MCHBAR is currently disabled, "
135 "attempting to enable.\n");
Corey Osgood23d98c72010-07-29 19:25:31 +0000136 mchbar_phys |= 0x1;
137 pci_write_long(nb, 0x48, mchbar_phys);
Stefan Tauner04c06002012-10-13 02:19:30 +0200138 if(pci_read_long(nb, 0x48) & 1)
Corey Osgood23d98c72010-07-29 19:25:31 +0000139 printf("Enabled successfully.\n");
140 else
141 printf("Enable FAILED!\n");
142 }
143 mchbar_phys &= 0xfffffffe;
Stefan Tauner04c06002012-10-13 02:19:30 +0200144 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
145 break;
Maciej Pijanka90d17402009-09-30 17:05:46 +0000146 case PCI_DEVICE_ID_INTEL_82443LX:
147 case PCI_DEVICE_ID_INTEL_82443BX:
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000148 case PCI_DEVICE_ID_INTEL_82810:
Stefan Tauner04c06002012-10-13 02:19:30 +0200149 case PCI_DEVICE_ID_INTEL_82810E_DC:
150 case PCI_DEVICE_ID_INTEL_82810_DC:
Stefan Reinauer04844812010-02-22 11:26:06 +0000151 case PCI_DEVICE_ID_INTEL_82830M:
Idwer Vollering312fc962010-12-17 22:34:58 +0000152 printf("This northbridge does not have MCHBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000153 return 1;
Stefan Tauner04c06002012-10-13 02:19:30 +0200154 case PCI_DEVICE_ID_INTEL_82X4X:
155 case PCI_DEVICE_ID_INTEL_82X38:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200156 case PCI_DEVICE_ID_INTEL_32X0:
Anton Kochkovda0b4562010-05-30 12:33:12 +0000157 mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe;
158 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
Stefan Tauner04c06002012-10-13 02:19:30 +0200159 break;
160 case PCI_DEVICE_ID_INTEL_CORE_1ST_GEN:
161 mchbar_phys = pci_read_long(nb, 0x48);
162 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
163 mchbar_phys &= 0x0000000fffffc000UL; /* 35:14 */
164 mch_registers = NULL; /* No public documentation */
165 break;
166 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN:
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400167 mch_registers = sandybridge_mch_registers;
168 size = ARRAY_SIZE(sandybridge_mch_registers);
Stefan Tauner04c06002012-10-13 02:19:30 +0200169 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN: /* pretty printing not implemented yet */
170 mchbar_phys = pci_read_long(nb, 0x48);
171 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
172 mchbar_phys &= 0x0000007fffff8000UL; /* 38:15 */
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400173 break;
Stefan Reinauer23190272008-08-20 13:41:24 +0000174 default:
175 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
176 return 1;
177 }
178
Stefan Reinauer1162f252008-12-04 15:18:20 +0000179 mchbar = map_physical(mchbar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000180
Stefan Reinauer1162f252008-12-04 15:18:20 +0000181 if (mchbar == NULL) {
Idwer Vollering312fc962010-12-17 22:34:58 +0000182 if (nb->device_id == PCI_DEVICE_ID_INTEL_82865)
183 perror("Error mapping BAR6");
184 else
185 perror("Error mapping MCHBAR");
Stefan Reinauer23190272008-08-20 13:41:24 +0000186 exit(1);
187 }
188
Idwer Vollering312fc962010-12-17 22:34:58 +0000189 if (nb->device_id == PCI_DEVICE_ID_INTEL_82865)
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800190 printf("BAR6 = 0x%08" PRIx64 " (MEM)\n\n", mchbar_phys);
Idwer Vollering312fc962010-12-17 22:34:58 +0000191 else
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800192 printf("MCHBAR = 0x%08" PRIx64 " (MEM)\n\n", mchbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000193
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400194 if (mch_registers != NULL) {
Stefan Tauner04c06002012-10-13 02:19:30 +0200195 printf("%d registers:\n", size);
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400196 for (i = 0; i < size; i++) {
197 switch (mch_registers[i].size) {
198 case 8:
Stefan Tauner04c06002012-10-13 02:19:30 +0200199 printf("mchbase+0x%04x: 0x%016lx (%s)\n",
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400200 mch_registers[i].addr,
201 *(uint64_t *)(mchbar+mch_registers[i].addr),
202 mch_registers[i].name);
203 break;
204 case 4:
Stefan Tauner04c06002012-10-13 02:19:30 +0200205 printf("mchbase+0x%04x: 0x%08x (%s)\n",
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400206 mch_registers[i].addr,
207 *(uint32_t *)(mchbar+mch_registers[i].addr),
208 mch_registers[i].name);
209 break;
210 case 2:
Stefan Tauner04c06002012-10-13 02:19:30 +0200211 printf("mchbase+0x%04x: 0x%04x (%s)\n",
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400212 mch_registers[i].addr,
213 *(uint16_t *)(mchbar+mch_registers[i].addr),
214 mch_registers[i].name);
215 break;
216 case 1:
Stefan Tauner04c06002012-10-13 02:19:30 +0200217 printf("mchbase+0x%04x: 0x%02x (%s)\n",
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400218 mch_registers[i].addr,
219 *(uint8_t *)(mchbar+mch_registers[i].addr),
220 mch_registers[i].name);
221 break;
222 }
223 }
224 } else {
225 for (i = 0; i < size; i += 4) {
226 if (*(uint32_t *)(mchbar + i))
227 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i));
228 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000229 }
230
Stefan Reinauer1162f252008-12-04 15:18:20 +0000231 unmap_physical((void *)mchbar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000232 return 0;
233}
234
235