blob: 608489b457c5bd27387b27ae88d2902ee290b4d1 [file] [log] [blame]
Thomas Jourdan1a692d82009-07-01 17:01:17 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2008 coresystems GmbH
5 * Copyright (C) 2009 Thomas Jourdan <thomas.jourdan@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
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.
Thomas Jourdan1a692d82009-07-01 17:01:17 +000016 */
17
Uwe Hermannd773fd32010-11-20 20:23:08 +000018#include <spd.h>
Thomas Jourdan1a692d82009-07-01 17:01:17 +000019
20static void print_reg(unsigned char index)
21{
22 unsigned char data;
23
24 outb(index, 0x2e);
25 data = inb(0x2f);
Stefan Reinauer069f4762015-01-05 13:02:32 -080026 printk(BIOS_DEBUG, "0x%02x: 0x%02x\n", index, data);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000027 return;
28}
29
Stefan Reinauer23836e22010-04-15 12:39:29 +000030static inline void xbus_en(void)
Thomas Jourdan1a692d82009-07-01 17:01:17 +000031{
32 /* select the XBUS function in the SIO */
33 outb(0x07, 0x2e);
34 outb(0x0f, 0x2f);
35 outb(0x30, 0x2e);
36 outb(0x01, 0x2f);
37 return;
38}
39
40static void setup_func(unsigned char func)
41{
42 /* select the function in the SIO */
43 outb(0x07, 0x2e);
44 outb(func, 0x2f);
45 /* print out the regs */
46 print_reg(0x30);
47 print_reg(0x60);
48 print_reg(0x61);
49 print_reg(0x62);
50 print_reg(0x63);
51 print_reg(0x70);
52 print_reg(0x71);
53 print_reg(0x74);
54 print_reg(0x75);
55 return;
56}
57
Stefan Reinauer23836e22010-04-15 12:39:29 +000058static inline void siodump(void)
Thomas Jourdan1a692d82009-07-01 17:01:17 +000059{
60 int i;
61 unsigned char data;
62
Stefan Reinauer069f4762015-01-05 13:02:32 -080063 printk(BIOS_DEBUG, "\n*** SERVER I/O REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +000064 for (i=0x10; i<=0x2d; i++) {
65 print_reg((unsigned char)i);
66 }
67#if 0
Stefan Reinauer069f4762015-01-05 13:02:32 -080068 printk(BIOS_DEBUG, "\n*** XBUS REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +000069 setup_func(0x0f);
70 for (i=0xf0; i<=0xff; i++) {
71 print_reg((unsigned char)i);
72 }
73
Stefan Reinauer069f4762015-01-05 13:02:32 -080074 printk(BIOS_DEBUG, "\n*** SERIAL 1 CONFIG REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +000075 setup_func(0x03);
76 print_reg(0xf0);
77
Stefan Reinauer069f4762015-01-05 13:02:32 -080078 printk(BIOS_DEBUG, "\n*** SERIAL 2 CONFIG REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +000079 setup_func(0x02);
80 print_reg(0xf0);
81
82#endif
Stefan Reinauer069f4762015-01-05 13:02:32 -080083 printk(BIOS_DEBUG, "\n*** GPIO REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +000084 setup_func(0x07);
85 for (i=0xf0; i<=0xf8; i++) {
86 print_reg((unsigned char)i);
87 }
Stefan Reinauer069f4762015-01-05 13:02:32 -080088 printk(BIOS_DEBUG, "\n*** GPIO VALUES ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +000089 data = inb(0x68a);
Stefan Reinauer069f4762015-01-05 13:02:32 -080090 printk(BIOS_DEBUG, "\nGPDO 4: 0x%02x", data);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000091 data = inb(0x68b);
Stefan Reinauer069f4762015-01-05 13:02:32 -080092 printk(BIOS_DEBUG, "\nGPDI 4: 0x%02x\n", data);
Thomas Jourdan1a692d82009-07-01 17:01:17 +000093
94#if 0
95
Stefan Reinauer069f4762015-01-05 13:02:32 -080096 printk(BIOS_DEBUG, "\n*** WATCHDOG TIMER REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +000097 setup_func(0x0a);
98 print_reg(0xf0);
99
Stefan Reinauer069f4762015-01-05 13:02:32 -0800100 printk(BIOS_DEBUG, "\n*** FAN CONTROL REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000101 setup_func(0x09);
102 print_reg(0xf0);
103 print_reg(0xf1);
104
Stefan Reinauer069f4762015-01-05 13:02:32 -0800105 printk(BIOS_DEBUG, "\n*** RTC REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000106 setup_func(0x10);
107 print_reg(0xf0);
108 print_reg(0xf1);
109 print_reg(0xf3);
110 print_reg(0xf6);
111 print_reg(0xf7);
112 print_reg(0xfe);
113 print_reg(0xff);
114
Stefan Reinauer069f4762015-01-05 13:02:32 -0800115 printk(BIOS_DEBUG, "\n*** HEALTH MONITORING & CONTROL REGISTERS ***\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000116 setup_func(0x14);
117 print_reg(0xf0);
118#endif
119 return;
120}
121
Stefan Reinauer23836e22010-04-15 12:39:29 +0000122static inline void dump_bar14(unsigned dev)
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000123{
124 int i;
125 unsigned long bar;
126
Stefan Reinauer069f4762015-01-05 13:02:32 -0800127 printk(BIOS_DEBUG, "BAR 14 Dump\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000128
129 bar = pci_read_config32(dev, 0x14);
130 for(i = 0; i <= 0x300; i+=4) {
131#if 0
132 unsigned char val;
Stefan Reinauer069f4762015-01-05 13:02:32 -0800133 if ((i & 0x0f) == 0)
134 printk(BIOS_DEBUG, "%02x:", i);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000135 val = pci_read_config8(dev, i);
136#endif
Stefan Reinauer069f4762015-01-05 13:02:32 -0800137 if((i%4)==0)
138 printk(BIOS_DEBUG, "\n%04x ", i);
139 printk(BIOS_DEBUG, "%08x ", read32(bar + i));
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000140 }
Stefan Reinauer069f4762015-01-05 13:02:32 -0800141 printk(BIOS_DEBUG, "\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000142}
143
Stefan Reinauer23836e22010-04-15 12:39:29 +0000144static inline void dump_spd_registers(void)
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000145{
146 unsigned device;
Uwe Hermannd773fd32010-11-20 20:23:08 +0000147 device = DIMM0;
148 while(device <= DIMM7) {
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000149 int status = 0;
150 int i;
Stefan Reinauer069f4762015-01-05 13:02:32 -0800151 printk(BIOS_DEBUG, "\ndimm %02x", device);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000152
153 for(i = 0; (i < 256) ; i++) {
Stefan Reinauer069f4762015-01-05 13:02:32 -0800154 if ((i % 16) == 0)
155 printk(BIOS_DEBUG, "\n%02x: ", i);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000156 status = smbus_read_byte(device, i);
157 if (status < 0) {
Stefan Reinauer069f4762015-01-05 13:02:32 -0800158 printk(BIOS_DEBUG, "bad device: %d\n", -status);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000159 break;
160 }
Stefan Reinauer069f4762015-01-05 13:02:32 -0800161 printk(BIOS_DEBUG, "%02x ", status);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000162 }
Uwe Hermannd773fd32010-11-20 20:23:08 +0000163 device++;
Stefan Reinauer069f4762015-01-05 13:02:32 -0800164 printk(BIOS_DEBUG, "\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000165 }
166}
167
Stefan Reinauer23836e22010-04-15 12:39:29 +0000168static inline void dump_ipmi_registers(void)
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000169{
170 unsigned device;
171 device = 0x42;
172 while(device <= 0x42) {
173 int status = 0;
174 int i;
Stefan Reinauer069f4762015-01-05 13:02:32 -0800175 printk(BIOS_DEBUG, "\nipmi %02x", device);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000176
177 for(i = 0; (i < 8) ; i++) {
178 status = smbus_read_byte(device, 2);
179 if (status < 0) {
Stefan Reinauer069f4762015-01-05 13:02:32 -0800180 printk(BIOS_DEBUG, "bad device: %d\n", -status);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000181 break;
182 }
Stefan Reinauer069f4762015-01-05 13:02:32 -0800183 printk(BIOS_DEBUG, "%02x ", status);
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000184 }
Uwe Hermannd773fd32010-11-20 20:23:08 +0000185 device++;
Stefan Reinauer069f4762015-01-05 13:02:32 -0800186 printk(BIOS_DEBUG, "\n");
Thomas Jourdan1a692d82009-07-01 17:01:17 +0000187 }
188}