Add detection/dump support for ServerEngines SE-SM 4210-P01.
[coreboot.git] / util / superiotool / serverengines.c
1 /*
2  * This file is part of the superiotool project.
3  *
4  * Copyright (C) 2011 Ruud Schramp <schramp@holmes.nl>
5  *
6  * 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; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include "superiotool.h"
22
23 #define DEVICE_ID_BYTE1_REG     0x20
24 #define DEVICE_ID_BYTE2_REG     0x21
25
26 #define DEVICE_REV_REG          0x1f
27
28 static const struct superio_registers reg_table[] = {
29         /*
30          * Note: These register defaults are based on educated guessing,
31          *       take them with a grain of salt.
32          *
33          * TODO: Don't know the ID registers yet: 0x21 probably is not an ID
34          * register as it is being set in the BIOS. For now still use as there
35          * is no known alternative.
36          */
37         {0x02c0, "SE-SM 4210-P01", {
38                 {NOLDN, NULL,
39                         {0x1f,0x20,0x21,0x22,0x23,0x2c,0x2d,0x2e,EOT},
40                         {NANA,0x02,0xc0,0x00,0x00,RSVD,RSVD,RSVD,EOT}},
41                 {0x0, "UNKNOWN",
42                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
43                         {NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
44                 {0x1, "COM2",
45                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
46                         {0x00,0x02,0xf8,0x03,0x00,0x00,0x0c,EOT}},
47                 {0x2, "COM1",
48                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
49                         {0x00,0x03,0xf8,0x04,0x00,0x00,0x0c,EOT}},
50                 {0x3, "UNKNOWN",
51                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
52                         {NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
53                 {0x4, "UNKNOWN",
54                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
55                         {NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
56                 {0x5, "UNKNOWN",
57                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
58                         {NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
59                 {0x6, "UNKNOWN",
60                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
61                         {NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
62                 {0x7, "UNKNOWN",
63                         {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,EOT},
64                         {NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
65                 {EOT}}},
66         {EOT}
67 };
68
69 static void enter_conf_mode_serverengines(uint16_t port)
70 {
71         OUTB(0x5a, port);
72 }
73
74 static void exit_conf_mode_serverengines(uint16_t port)
75 {
76         OUTB(0xa5, port);
77 }
78
79 void probe_idregs_serverengines(uint16_t port)
80 {
81         uint16_t id;
82         uint8_t rev;
83
84         probing_for("Server Engines", "", port);
85
86         enter_conf_mode_serverengines(port);
87
88         id = regval(port, DEVICE_ID_BYTE1_REG) << 8;
89         id |= regval(port, DEVICE_ID_BYTE2_REG);
90
91         /* TODO: Not documented/available on ServerEngines. */
92         rev = regval(port, DEVICE_REV_REG);
93
94         if (superio_unknown(reg_table, id)) {
95                 if (verbose)
96                         printf(NOTFOUND "id=0x%04x, rev=0x%02x\n", id, rev);
97                 exit_conf_mode_serverengines(port);
98                 return;
99         }
100
101         printf("Found Server Engines %s (id=0x%04x, rev=0x%02x) at 0x%x\n",
102                get_superio_name(reg_table, id), id, rev, port);
103         chip_found = 1;
104
105         dump_superio("Server Engines", reg_table, port, id, LDN_SEL);
106
107         exit_conf_mode_serverengines(port);
108 }
109
110 void print_serverengines_chips(void)
111 {
112         print_vendor_chips("Server Engines", reg_table);
113 }