summaryrefslogtreecommitdiff
path: root/util/dump_mmcr/dumpmmcr.c
blob: de2bfec3493716660cfa93e16b44acaad6b3bb65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/*
 * dump mmcr of Elan520 uController (incomplete, see 22005b pg23+).
 *
 * Copyright 2006 coresystems GmbH
 *      Stefan Reinauer <stepan@coresystems.de>
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <getopt.h>
#include "../../src/include/cpu/amd/sc520.h"

#define val(x,y) (x->y)

int print_mmcr(struct mmcr *mmcr)
{
	int i;
	printf("revid is 0x%x\n\n", val(mmcr, revid));
	printf("cpucontrol is 0x%x\n\n", val(mmcr, cpucontrol));

	printf("\n");
	printf("drcctl is 0x%x\n", val(mmcr, memregs.drcctl));
	printf("drctmctl is 0x%x\n", val(mmcr, memregs.drctmctl));
	printf("drccfg is 0x%x\n", val(mmcr, memregs.drccfg));
	printf("bendaddr is 0x%02x%02x%02x%02x\n",
			val(mmcr, memregs.drcbendadr[3]),
			val(mmcr, memregs.drcbendadr[2]),
			val(mmcr, memregs.drcbendadr[1]),
			val(mmcr, memregs.drcbendadr[0]));
	printf("eccctl is 0x%x\n", val(mmcr, memregs.eccctl));
	printf("eccsta is 0x%x\n", val(mmcr, memregs.eccsta));
	printf("ckbpos is 0x%x\n", val(mmcr, memregs.eccckbpos));
	printf("cktest is 0x%x\n", val(mmcr, memregs.ecccktest));
	printf("sbadd is 0x%x\n", val(mmcr, memregs.eccsbadd));
	printf("mbadd is 0x%x\n", val(mmcr, memregs.eccmbadd));

	printf("\n");
	printf("dbctl is 0x%x\n", val(mmcr, dbctl.dbctl));

	printf("\n");
	printf("bootcs is 0x%x\n", val(mmcr, romregs.bootcs));
	printf("romcs1 is 0x%x\n", val(mmcr, romregs.romcs1));
	printf("romcs2 is 0x%x\n", val(mmcr, romregs.romcs2));

	printf("\n");
	printf("hbctl is 0x%x\n",  val(mmcr, hostbridge.ctl));
	printf("hbtgtirqctl is 0x%x\n",  val(mmcr, hostbridge.tgtirqctl));
	printf("hbtgtirqsta is 0x%x\n",  val(mmcr, hostbridge.tgtirqsta));
	printf("hbmstirqctl is 0x%x\n",  val(mmcr, hostbridge.mstirqctl));
	printf("hbmstirqsta is 0x%x\n",  val(mmcr, hostbridge.mstirqsta));
	printf("mstintadd is 0x%x\n",  val(mmcr, hostbridge.mstintadd));


	printf("\n");
	printf("sysarbctl is 0x%x\n", val(mmcr, sysarb.ctl));
	printf("pciarbsta is 0x%x\n", val(mmcr, sysarb.sta));
	printf("sysarbmenb is 0x%x\n", val(mmcr, sysarb.menb));
	printf("arbprictl is 0x%x\n", val(mmcr, sysarb.prictl));

	printf("\n");
	printf("adddecctl is 0x%x\n", val(mmcr, sysmap.adddecctl));
	printf("wpvsta is 0x%x\n", val(mmcr, sysmap.wpvsta));
	for (i=0; i<16; i++)
		printf("par %d is 0x%x\n", i, val(mmcr, sysmap.par[i]));

	printf("\n");
	printf("gpecho is 0x%x\n", val(mmcr, gpctl.gpecho));
	printf("gpcsdw is 0x%x\n", val(mmcr, gpctl.gpcsdw));
	printf("gpcsqual is 0x%x\n", val(mmcr, gpctl.gpcsqual));
	printf("gpcsrt is 0x%x\n", val(mmcr, gpctl.gpcsrt));
	printf("gpcspw is 0x%x\n", val(mmcr, gpctl.gpcspw));
	printf("gpcsoff is 0x%x\n", val(mmcr, gpctl.gpcsoff));
	printf("gprdw is 0x%x\n", val(mmcr, gpctl.gprdw));
	printf("gprdoff is 0x%x\n", val(mmcr, gpctl.gprdoff));
	printf("gpwrw is 0x%x\n", val(mmcr, gpctl.gpwrw));
	printf("gpwroff is 0x%x\n", val(mmcr, gpctl.gpwroff));
	printf("gpalew is 0x%x\n", val(mmcr, gpctl.gpalew));
	printf("gpaleoff is 0x%x\n", val(mmcr, gpctl.gpaleoff));

	printf("\n");

	printf("piopfs15_0 is 0x%x\n",  val(mmcr, pio.pfs15_0));
	printf("piopfs31_16 is 0x%x\n",  val(mmcr, pio.pfs31_16));
	printf("cspfs is 0x%x\n",  val(mmcr, pio.cspfs));
	printf("clksel is 0x%x\n",  val(mmcr, pio.clksel));
	printf("dsctl is 0x%x\n",  val(mmcr, pio.dsctl));
	printf("piodir15_0 is 0x%x\n",  val(mmcr, pio.dir15_0));
	printf("piodir31_16 is 0x%x\n",  val(mmcr, pio.dir31_16));
	printf("piodata15_0 is 0x%x\n",  val(mmcr, pio.data15_0));
	printf("piodata31_16 is 0x%x\n",  val(mmcr, pio.data31_16));
	printf("pioset15_0 is 0x%x\n",  val(mmcr, pio.set15_0));
	printf("pioset31_16 is 0x%x\n",  val(mmcr, pio.set31_16));
	printf("pioclr15_0 is 0x%x\n",  val(mmcr, pio.clr15_0));
	printf("pioclr31_16 is 0x%x\n",  val(mmcr, pio.clr31_16));

	printf("swtmrmilli is 0x%x\n", val(mmcr, swtmr.swtmrmilli));
	printf("swtmrmicro is 0x%x\n", val(mmcr, swtmr.swtmrmicro));
	printf("swtmrcfg is 0x%x\n", val(mmcr, swtmr.swtmrcfg));

	printf("status  is 0x%x\n", val(mmcr, gptimers.status));
	printf("pad  is 0x%x\n", val(mmcr, gptimers.pad));

	printf("timers[0].ctl is 0x%x\n",  val(mmcr, gptimers.timer[0].ctl));
	printf("timers[0].cnt is 0x%x\n",  val(mmcr, gptimers.timer[0].cnt));
	printf("timers[0].maxcmpa is 0x%x\n",  val(mmcr, gptimers.timer[0].maxcmpa));
	printf("timers[0].maxcmpb is 0x%x\n",  val(mmcr, gptimers.timer[0].maxcmpb));

	printf("timers[1].ctl is 0x%x\n",  val(mmcr, gptimers.timer[1].ctl));
	printf("timers[1].cnt is 0x%x\n",  val(mmcr, gptimers.timer[1].cnt));
	printf("timers[1].maxcmpa is 0x%x\n",  val(mmcr, gptimers.timer[1].maxcmpa));
	printf("timers[1].maxcmpb is 0x%x\n",  val(mmcr, gptimers.timer[1].maxcmpb));
	printf("timers[2].ctl is 0x%x\n",  val(mmcr, gptimers.ctl2));
	printf("timers[2].cnt is 0x%x\n",  val(mmcr, gptimers.cnt2));
	printf("timers[2].maxcmpa is 0x%x\n",  val(mmcr, gptimers.maxcmpa2));

	printf("ctl  is 0x%x\n",  val(mmcr, watchdog.ctl));
	printf("cntll  is 0x%x\n",  val(mmcr, watchdog.cntll));
	printf("cntlh  is 0x%x\n",  val(mmcr, watchdog.cntlh));

	printf("uart 1 ctl is 0x%x\n", val(mmcr, uarts.uart[0].ctl));
	printf("uart 1 sta is 0x%x\n", val(mmcr, uarts.uart[0].sta));
	printf("uart 1 fcrshad is 0x%x\n", val(mmcr, uarts.uart[0].fcrshad));
	printf("uart 2 ctl is 0x%x\n", val(mmcr, uarts.uart[1].ctl));
	printf("uart 2 sta is 0x%x\n", val(mmcr, uarts.uart[1].sta));
	printf("uart 2 fcrshad is 0x%x\n", val(mmcr, uarts.uart[1].fcrshad));

	printf("ssi ctl is 0x%x\n", val(mmcr, ssi.ctl));
	printf("ssi xmit is 0x%x\n", val(mmcr, ssi.xmit));
	printf("ssi cmd is 0x%x\n", val(mmcr, ssi.cmd));
	printf("ssi sta is 0x%x\n", val(mmcr, ssi.sta));
	printf("ssi rcv is 0x%x\n", val(mmcr, ssi.rcv));

	printf("pcicr is 0x%x\n", val(mmcr, pic.pcicr));
	printf("mpicmode is 0x%x\n", val(mmcr, pic.mpicmode));
	printf("sl1picmode is 0x%x\n", val(mmcr, pic.sl1picmode));
	printf("sl2picmode is 0x%x\n", val(mmcr, pic.sl2picmode));
	printf("swint16_1 is 0x%x\n", val(mmcr, pic.swint16_1));
	printf("swint22_17 is 0x%x\n", val(mmcr, pic.swint22_17));
	printf("intpinpol is 0x%x\n", val(mmcr, pic.intpinpol));
	printf("pichostmap is 0x%x\n", val(mmcr, pic.pichostmap));
	printf("eccmap is 0x%x\n", val(mmcr, pic.eccmap));
	printf("gptmr0map is 0x%x\n", val(mmcr, pic.gptmr0map));
	printf("gptmr1map is 0x%x\n", val(mmcr, pic.gptmr1map));
	printf("gptmr2map is 0x%x\n", val(mmcr, pic.gptmr2map));
	printf("pit0map is 0x%x\n", val(mmcr, pic.pit0map));
	printf("pit1map is 0x%x\n", val(mmcr, pic.pit1map));
	printf("pit2map is 0x%x\n", val(mmcr, pic.pit2map));
	printf("uart1map is 0x%x\n", val(mmcr, pic.uart1map));
	printf("uart2map is 0x%x\n", val(mmcr, pic.uart2map));
	printf("pciintamap is 0x%x\n", val(mmcr, pic.pciintamap));
	printf("pciintbmap is 0x%x\n", val(mmcr, pic.pciintbmap));
	printf("pciintcmap is 0x%x\n", val(mmcr, pic.pciintcmap));
	printf("pciintdmap is 0x%x\n", val(mmcr, pic.pciintdmap));
	printf("dmabcintmap is 0x%x\n", val(mmcr, pic.dmabcintmap));
	printf("ssimap is 0x%x\n", val(mmcr, pic.ssimap));
	printf("wdtmap is 0x%x\n", val(mmcr, pic.wdtmap));
	printf("rtcmap is 0x%x\n", val(mmcr, pic.rtcmap));
	printf("wpvmap is 0x%x\n", val(mmcr, pic.wpvmap));
	printf("icemap is 0x%x\n", val(mmcr, pic.icemap));
	printf("ferrmap is 0x%x\n", val(mmcr, pic.ferrmap));
	printf("gp0imap is 0x%x\n", val(mmcr, pic.gp0imap));
	printf("gp1imap is 0x%x\n", val(mmcr, pic.gp1imap));
	printf("gp2imap is 0x%x\n", val(mmcr, pic.gp2imap));
	printf("gp3imap is 0x%x\n", val(mmcr, pic.gp3imap));
	printf("gp4imap is 0x%x\n", val(mmcr, pic.gp4imap));
	printf("gp5imap is 0x%x\n", val(mmcr, pic.gp5imap));
	printf("gp6imap is 0x%x\n", val(mmcr, pic.gp6imap));
	printf("gp7imap is 0x%x\n", val(mmcr, pic.gp7imap));
	printf("gp8imap is 0x%x\n", val(mmcr, pic.gp8imap));
	printf("gp9imap is 0x%x\n", val(mmcr, pic.gp9imap));
	printf("gp10imap is 0x%x\n", val(mmcr, pic.gp10imap));

	printf("sysinfo is 0x%x\n", val(mmcr, reset.sysinfo));
	printf("rescfg is 0x%x\n", val(mmcr, reset.rescfg));
	printf("ressta is 0x%x\n", val(mmcr, reset.ressta));


	printf("ctl is 0x%x\n", val(mmcr, dmacontrol.ctl));
	printf("mmio is 0x%x\n", val(mmcr, dmacontrol.mmio));
	printf("extchanmapa is 0x%x\n", val(mmcr, dmacontrol.extchanmapa));
	printf("extchanmapb is 0x%x\n", val(mmcr, dmacontrol.extchanmapb));
	printf("extpg0 is 0x%x\n", val(mmcr, dmacontrol.extpg0));
	printf("extpg1 is 0x%x\n", val(mmcr, dmacontrol.extpg1));
	printf("extpg2 is 0x%x\n", val(mmcr, dmacontrol.extpg2));
	printf("extpg3 is 0x%x\n", val(mmcr, dmacontrol.extpg3));
	printf("extpg5 is 0x%x\n", val(mmcr, dmacontrol.extpg5));
	printf("extpg6 is 0x%x\n", val(mmcr, dmacontrol.extpg6));
	printf("extpg7 is 0x%x\n", val(mmcr, dmacontrol.extpg7));
	printf("exttc3 is 0x%x\n", val(mmcr, dmacontrol.exttc3));
	printf("exttc5 is 0x%x\n", val(mmcr, dmacontrol.exttc5));
	printf("exttc6 is 0x%x\n", val(mmcr, dmacontrol.exttc6));
	printf("exttc7 is 0x%x\n", val(mmcr, dmacontrol.exttc7));
	printf("bcctl is 0x%x\n", val(mmcr, dmacontrol.bcctl));
	printf("bcsta is 0x%x\n", val(mmcr, dmacontrol.bcsta));
	printf("bsintenb is 0x%x\n", val(mmcr, dmacontrol.bsintenb));
	printf("bcval is 0x%x\n", val(mmcr, dmacontrol.bcval));
	printf("nxtaddl3 is 0x%x\n", val(mmcr, dmacontrol.nxtaddl3));
	printf("nxtaddh3 is 0x%x\n", val(mmcr, dmacontrol.nxtaddh3));
	printf("nxtaddl5 is 0x%x\n", val(mmcr, dmacontrol.nxtaddl5));
	printf("nxtaddh5 is 0x%x\n", val(mmcr, dmacontrol.nxtaddh5));
	printf("nxtaddl6 is 0x%x\n", val(mmcr, dmacontrol.nxtaddl6));
	printf("nxtaddh6 is 0x%x\n", val(mmcr, dmacontrol.nxtaddh6));
	printf("nxtaddl7 is 0x%x\n", val(mmcr, dmacontrol.nxtaddl7));
	printf("nxtaddh7 is 0x%x\n", val(mmcr, dmacontrol.nxtaddh7));
	printf("nxtttcl3 is 0x%x\n", val(mmcr, dmacontrol.nxtttcl3));
	printf("nxtttch3 is 0x%x\n", val(mmcr, dmacontrol.nxtttch3));
	printf("nxtttcl5 is 0x%x\n", val(mmcr, dmacontrol.nxtttcl5));
	printf("nxtttch5 is 0x%x\n", val(mmcr, dmacontrol.nxtttch5));
	printf("nxtttcl6 is 0x%x\n", val(mmcr, dmacontrol.nxtttcl6));
	printf("nxtttch6 is 0x%x\n", val(mmcr, dmacontrol.nxtttch6));
	printf("nxtttcl7 is 0x%x\n", val(mmcr, dmacontrol.nxtttcl7));
	printf("nxtttch7 is 0x%x\n", val(mmcr, dmacontrol.nxtttch7));

	return 0;
}

int map_mmcr(void)
{
	int fd_mem;
	volatile uint8_t *mmcr;
	unsigned long size=4096;

	if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
		perror("Can not open /dev/mem");
		exit(1);
	}

	if (getpagesize() > size) {
		size = getpagesize();
	}

	mmcr = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
		    fd_mem, (off_t) (0xFFFEF000));

	if (mmcr == MAP_FAILED) {
		perror("Error MMAP /dev/mem");
		exit(1);
	}


	print_mmcr((struct mmcr *)mmcr);
#if 0

	printf("ElanSC520 uC Rev. ID  : %04x\n",*(uint16_t *)mmcr);
	printf("Am5x86 CPU Control    : %04x\n",*(uint16_t *)(mmcr+2));
	printf("\n");
	printf("SDRAM Control         : %04x\n",*(uint16_t *)(mmcr+0x10));
	printf("SDRAM Timing Control  : %04x\n",*(uint16_t *)(mmcr+0x12));
	printf("SDRAM Bank Config     : %04x\n",*(uint16_t *)(mmcr+0x14));
	printf("SDRAM Bank 0-3 Ending : %04x\n",*(uint16_t *)(mmcr+0x18));
	printf("ECC Control           : %04x\n",*(uint16_t *)(mmcr+0x20));
	printf("ECC Status            : %04x\n",*(uint16_t *)(mmcr+0x21));
	printf("ECC Check Bit Position: %04x\n",*(uint16_t *)(mmcr+0x22));
	printf("ECC Check Code Test   : %04x\n",*(uint16_t *)(mmcr+0x23));
	printf("ECC Single Bit ErrAddr: %04x\n",*(uint16_t *)(mmcr+0x24));
	printf("ECC Multi Bit ErrAddr : %04x\n",*(uint16_t *)(mmcr+0x28));
	printf("\n");
	printf("SDRAM Buffer Control  : %04x\n",*(uint16_t *)(mmcr+0x40));
	printf("\n");
	printf("BOOTCS Control        : %04x\n",*(uint16_t *)(mmcr+0x50));
	printf("BOOTCS1 Control       : %04x\n",*(uint16_t *)(mmcr+0x54));
	printf("BOOTCS2 Control       : %04x\n",*(uint16_t *)(mmcr+0x56));
	printf("\n");

	printf("Adr Decode Control    : %02x\n",*(uint8_t *)(mmcr+0x80));
	printf("WrProt Violation Stat.: %04x\n",*(uint16_t *)(mmcr+0x82));
	printf("PAR 0                 : %08x\n",*(uint32_t *)(mmcr+0x88));
	printf("PAR 1                 : %08x\n",*(uint32_t *)(mmcr+0x8C));
	printf("PAR 2                 : %08x\n",*(uint32_t *)(mmcr+0x90));
	printf("PAR 3                 : %08x\n",*(uint32_t *)(mmcr+0x94));
	printf("PAR 4                 : %08x\n",*(uint32_t *)(mmcr+0x98));
	printf("PAR 5                 : %08x\n",*(uint32_t *)(mmcr+0x9C));
	printf("PAR 6                 : %08x\n",*(uint32_t *)(mmcr+0xA0));
	printf("PAR 7                 : %08x\n",*(uint32_t *)(mmcr+0xA4));
	printf("PAR 8                 : %08x\n",*(uint32_t *)(mmcr+0xA8));
	printf("PAR 9                 : %08x\n",*(uint32_t *)(mmcr+0xAC));
	printf("PAR 10                : %08x\n",*(uint32_t *)(mmcr+0xB0));
	printf("PAR 11                : %08x\n",*(uint32_t *)(mmcr+0xB4));
	printf("PAR 12                : %08x\n",*(uint32_t *)(mmcr+0xB8));
	printf("PAR 13                : %08x\n",*(uint32_t *)(mmcr+0xBC));
	printf("PAR 14                : %08x\n",*(uint32_t *)(mmcr+0xC0));
	printf("PAR 15                : %08x\n",*(uint32_t *)(mmcr+0xC4));
#endif
	munmap((void *) mmcr, size);
	return 0;
}

int main(int argc, char *argv[])
{
	map_mmcr();
	return 0;
}