blob: d66ee4884daeac8b7c9022d22f2b05046850071e [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 Reinauer1162f252008-12-04 15:18:20 +0000111 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 Reinauer1162f252008-12-04 15:18:20 +0000114 case PCI_DEVICE_ID_INTEL_PM965:
Loïc Grenié8429de72009-11-02 15:01:49 +0000115 case PCI_DEVICE_ID_INTEL_82Q35:
116 case PCI_DEVICE_ID_INTEL_82G33:
117 case PCI_DEVICE_ID_INTEL_82Q33:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000118 mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe;
119 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
120 break;
Corey Osgood23d98c72010-07-29 19:25:31 +0000121 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 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 {
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 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:
Joseph Smithe10757e2010-06-16 22:21:19 +0000149 case PCI_DEVICE_ID_INTEL_82810E_MC:
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000150 case PCI_DEVICE_ID_INTEL_82810DC:
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;
Anton Kochkovda0b4562010-05-30 12:33:12 +0000154 case PCI_DEVICE_ID_INTEL_GS45:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200155 case PCI_DEVICE_ID_INTEL_X44:
156 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;
159 break;
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400160 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 Reinauer23190272008-08-20 13:41:24 +0000165 default:
166 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
167 return 1;
168 }
169
Stefan Reinauer1162f252008-12-04 15:18:20 +0000170 mchbar = map_physical(mchbar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000171
Stefan Reinauer1162f252008-12-04 15:18:20 +0000172 if (mchbar == NULL) {
Idwer Vollering312fc962010-12-17 22:34:58 +0000173 if (nb->device_id == PCI_DEVICE_ID_INTEL_82865)
174 perror("Error mapping BAR6");
175 else
176 perror("Error mapping MCHBAR");
Stefan Reinauer23190272008-08-20 13:41:24 +0000177 exit(1);
178 }
179
Idwer Vollering312fc962010-12-17 22:34:58 +0000180 if (nb->device_id == PCI_DEVICE_ID_INTEL_82865)
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800181 printf("BAR6 = 0x%08" PRIx64 " (MEM)\n\n", mchbar_phys);
Idwer Vollering312fc962010-12-17 22:34:58 +0000182 else
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800183 printf("MCHBAR = 0x%08" PRIx64 " (MEM)\n\n", mchbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000184
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400185 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 Reinauer23190272008-08-20 13:41:24 +0000219 }
220
Stefan Reinauer1162f252008-12-04 15:18:20 +0000221 unmap_physical((void *)mchbar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000222 return 0;
223}
224
225