soc: Remove copyright notices
[coreboot.git] / src / soc / intel / quark / spi_debug.c
blobcadd9fb741a957c7ba7ca6b9ba8fa576daba0b29
1 /*
2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; version 2 of
8 * the License.
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.
16 #include <console/console.h>
17 #include <soc/spi.h>
19 const char *spi_opcode_name(int opcode)
21 const char *op_name;
23 switch (opcode) {
24 default:
25 op_name = "Unknown";
26 break;
27 case 1:
28 op_name = "Write Status";
29 break;
30 case 2:
31 op_name = "Page Program";
32 break;
33 case 3:
34 op_name = "Read Data";
35 break;
36 case 5:
37 op_name = "Read Status";
38 break;
39 case 6:
40 op_name = "Write Data Enable";
41 break;
42 case 0x0b:
43 op_name = "Fast Read";
44 break;
45 case 0x20:
46 op_name = "Erase 4 KiB";
47 break;
48 case 0x50:
49 op_name = "Write Status Enable";
50 break;
51 case 0x9f:
52 op_name = "Read ID";
53 break;
54 case 0xd8:
55 op_name = "Erase 64 KiB";
56 break;
58 return op_name;
61 void spi_display(volatile struct flash_ctrlr *ctrlr)
63 int index;
64 int opcode;
65 const char *op_name;
66 int prefix;
67 int status;
68 int type;
70 /* Display the prefixes */
71 printk(BIOS_DEBUG, "Prefix Table\n");
72 for (index = 0; index < 2; index++) {
73 prefix = ctrlr->prefix[index];
74 op_name = spi_opcode_name(prefix);
75 printk(BIOS_DEBUG, " %d: 0x%02x (%s)\n", index, prefix,
76 op_name);
79 /* Display the opcodes */
80 printk(BIOS_DEBUG, "Opcode Menu\n");
81 for (index = 0; index < 8; index++) {
82 opcode = ctrlr->opmenu[index];
83 type = (ctrlr->type >> (index << 1)) & 3;
84 op_name = spi_opcode_name(opcode);
85 printk(BIOS_DEBUG, " %d: 0x%02x (%s), %s%s\n", index, opcode,
86 op_name,
87 (type & SPITYPE_PREFIX) ? "Write" : "Read",
88 (type & SPITYPE_ADDRESS) ? ", w/3 byte address" : "");
91 /* Display the BIOS base address */
92 printk(BIOS_DEBUG, "0x%08x: BIOS Base Address\n", ctrlr->bbar);
94 /* Display the protection ranges */
95 printk(BIOS_DEBUG, "BIOS Protected Range Regsiters\n");
96 for (index = 0; index < ARRAY_SIZE(ctrlr->pbr); index++) {
97 status = ctrlr->pbr[index];
98 printk(BIOS_DEBUG, " %d: 0x%08x: 0x%08x - 0x%08x %s\n",
99 index, status,
100 0xff000000 | (0x1000000 - CONFIG_ROM_SIZE)
101 | ((status & SPIPBR_PRB) << SPIPBR_PRB_SHIFT),
102 0xff800fff | (0x1000000 - CONFIG_ROM_SIZE)
103 | (status & SPIPBR_PRL),
104 (status & SPIPBR_WPE) ? "Protected" : "Unprotected");
107 /* Display locked status */
108 status = ctrlr->status;
109 printk(BIOS_DEBUG, "0x%04x: SPISTS, Tables %s\n", status,
110 (status & SPISTS_CLD) ? "Locked" : "Unlocked");