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
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>
19 const char *spi_opcode_name(int opcode
)
28 op_name
= "Write Status";
31 op_name
= "Page Program";
34 op_name
= "Read Data";
37 op_name
= "Read Status";
40 op_name
= "Write Data Enable";
43 op_name
= "Fast Read";
46 op_name
= "Erase 4 KiB";
49 op_name
= "Write Status Enable";
55 op_name
= "Erase 64 KiB";
61 void spi_display(volatile struct flash_ctrlr
*ctrlr
)
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
,
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
,
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",
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");