blob: a076876526c2c84b07e92038192d1000f6338280 [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 Reinauer23190272008-08-20 13:41:24 +000023#include "inteltool.h"
24
25/*
26 * (G)MCH MMIO Config Space
27 */
28int print_mchbar(struct pci_dev *nb)
29{
30 int i, size = (16 * 1024);
31 volatile uint8_t *mchbar;
Stefan Reinauer1162f252008-12-04 15:18:20 +000032 uint64_t mchbar_phys;
Stefan Reinauer23190272008-08-20 13:41:24 +000033
34 printf("\n============= MCHBAR ============\n\n");
35
36 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +000037 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +000038 case PCI_DEVICE_ID_INTEL_82945GM:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +000039 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +000040 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +000041 mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe;
42 break;
Stefan Reinauer1162f252008-12-04 15:18:20 +000043 case PCI_DEVICE_ID_INTEL_PM965:
Loïc Grenié8429de72009-11-02 15:01:49 +000044 case PCI_DEVICE_ID_INTEL_82Q35:
45 case PCI_DEVICE_ID_INTEL_82G33:
46 case PCI_DEVICE_ID_INTEL_82Q33:
Stefan Reinauer1162f252008-12-04 15:18:20 +000047 mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe;
48 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
49 break;
Corey Osgood23d98c72010-07-29 19:25:31 +000050 case PCI_DEVICE_ID_INTEL_Q965:
51 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
52 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
53 mchbar_phys = pci_read_long(nb, 0x48);
54
55 /* Test if bit 0 of the MCHBAR reg is 1 to enable memory reads.
56 * If it isn't, try to set it. This may fail, because there is
57 * some bit that locks that bit, and isn't in the public
58 * datasheets.
59 */
60
61 if(!(mchbar_phys & 1))
62 {
63 printf("Access to the MCHBAR is currently disabled, "\
64 "attempting to enable.\n");
65 mchbar_phys |= 0x1;
66 pci_write_long(nb, 0x48, mchbar_phys);
67 if(pci_read_long(nb, 0x48) & 1)
68 printf("Enabled successfully.\n");
69 else
70 printf("Enable FAILED!\n");
71 }
72 mchbar_phys &= 0xfffffffe;
73 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
74 break;
Maciej Pijanka90d17402009-09-30 17:05:46 +000075 case PCI_DEVICE_ID_INTEL_82443LX:
76 case PCI_DEVICE_ID_INTEL_82443BX:
Stefan Reinauerb2aedb12009-08-29 15:45:43 +000077 case PCI_DEVICE_ID_INTEL_82810:
Joseph Smithe10757e2010-06-16 22:21:19 +000078 case PCI_DEVICE_ID_INTEL_82810E_MC:
Stefan Reinauerb2aedb12009-08-29 15:45:43 +000079 case PCI_DEVICE_ID_INTEL_82810DC:
Stefan Reinauer04844812010-02-22 11:26:06 +000080 case PCI_DEVICE_ID_INTEL_82830M:
Stefan Reinauer23190272008-08-20 13:41:24 +000081 printf("This northbrigde does not have MCHBAR.\n");
82 return 1;
Anton Kochkovda0b4562010-05-30 12:33:12 +000083 case PCI_DEVICE_ID_INTEL_GS45:
84 mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe;
85 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
86 break;
Stefan Reinauer23190272008-08-20 13:41:24 +000087 default:
88 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
89 return 1;
90 }
91
Stefan Reinauer1162f252008-12-04 15:18:20 +000092 mchbar = map_physical(mchbar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +000093
Stefan Reinauer1162f252008-12-04 15:18:20 +000094 if (mchbar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +000095 perror("Error mapping MCHBAR");
96 exit(1);
97 }
98
Stefan Reinauer1162f252008-12-04 15:18:20 +000099 printf("MCHBAR = 0x%08llx (MEM)\n\n", mchbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000100
101 for (i = 0; i < size; i += 4) {
102 if (*(uint32_t *)(mchbar + i))
103 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i));
104 }
105
Stefan Reinauer1162f252008-12-04 15:18:20 +0000106 unmap_physical((void *)mchbar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000107 return 0;
108}
109
110