superiotool: add detection and dump of Infineon SLB9635 TPM
[coreboot.git] / util / superiotool / infineon.c
1 /*
2  * This file is part of the superiotool project.
3  *
4  * Copyright (C) 2011 Jonathan A. Kollasch <jakllsch@kollasch.net>
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_REG           0x20
24 #define DEVICE_REV_REG          0x21
25
26 static const struct superio_registers reg_table[] = {
27         {0x0b, "SLB9635TT12", {
28                 {NOLDN, NULL,
29                         {0x20,0x21,0x26,0x27,EOT},
30                         {0x0b,0x00,NANA,NANA,EOT}},
31                 {0, NULL,
32                         {0x30,0x38,0x60,0x61,0x70,0x71,0xf1,0xf2,0xf3,0xf4,0xf5,EOT},
33                         {0x00,0x00,NANA,NANA,0x00,0x02,0xd1,0x15,0x0b,0x00,NANA,EOT}},
34                 {EOT}}},
35         {EOT}
36 };
37
38 /* same as some SMSC */
39 static void enter_conf_mode_infineon(uint16_t port)
40 {
41         OUTB(0x55, port);
42 }
43
44 static void exit_conf_mode_infineon(uint16_t port)
45 {
46         OUTB(0xaa, port);
47 }
48
49 void probe_idregs_infineon(uint16_t port)
50 {
51         uint8_t rev, devid;
52
53         probing_for("Infineon", "", port);
54
55         enter_conf_mode_infineon(port);
56
57         devid = regval(port, DEVICE_ID_REG);
58         rev = regval(port, DEVICE_REV_REG);
59
60         if (superio_unknown(reg_table, devid)) {
61                 if (verbose)
62                         printf(NOTFOUND "id=0x%02x, rev=0x%02x\n", devid, rev);
63                 exit_conf_mode_infineon(port);
64                 return;
65         }
66
67         /* Attempt to prevent false matches on SMSC FDC37N972, see smsc.c */
68         if (((regval(port, 0x27)<<8)|regval(port, 0x26)) != port) {
69                 if (verbose)
70                         printf(NOTFOUND "id=0x%02x, rev=0x%02x\n", devid, rev);
71                 exit_conf_mode_infineon(port);
72                 return;
73         }
74
75         printf("Found Infineon %s (id=0x%02x, rev=0x%02x) at 0x%x\n",
76                get_superio_name(reg_table, devid), devid, rev, port);
77         chip_found = 1;
78
79         dump_superio("Infineon", reg_table, port, devid, LDN_SEL);
80
81         exit_conf_mode_infineon(port);
82 }
83
84 void print_infineon_chips(void)
85 {
86         print_vendor_chips("Infineon", reg_table);
87 }