blob: 4f76981bb22309989378c834b53d0b192c8afa49 [file] [log] [blame]
Rudolf Marek113c3492011-10-27 20:42:11 +02001/*
2 * This file is part of the superiotool project.
3 *
4 * Copyright (C) 2011 Rudolf Marek <r.marek@assembler.cz>
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
Paul Menzela46a7122013-02-23 18:37:27 +010018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Rudolf Marek113c3492011-10-27 20:42:11 +020019 */
20
21#include "superiotool.h"
22
23#define DEVICE_ID_REG 0x20
24#define DEVICE_REV_REG 0x21
25
26static const struct superio_registers reg_table[] = {
27 {0xb7, "SB7xx", {
28 {NOLDN, NULL,
29 {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x28,0x29,0x2a,
30 0x2b,0x2c,0x2e, 0x2f, EOT},
31 {NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
32 {0x3, "EC channel 0",
33 {0x30,0x60,0x61, EOT},
34 {NANA,NANA,NANA,EOT}},
35 {0x5, "Irda",
36 {0x30,0x60,0x61,0x70, EOT},
37 {NANA,NANA,NANA,NANA,EOT}},
38 {0x7, "Keyboard Controller",
39 {0x30, EOT},
40 {NANA,EOT}},
41 {0x9, "Mailbox",
42 {0x30,0x60,0x61, EOT},
43 {NANA,NANA,NANA,EOT}},
44 {EOT}}},
45 {0xb8, "SB8xx", {
46 {NOLDN, NULL,
47 {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x28,0x29,0x2a,
48 0x2b,0x2c,0x2e, 0x2f, EOT},
49 {NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
50 {0x3, "EC channel 0",
51 {0x30,0x60,0x61, EOT},
52 {NANA,NANA,NANA,EOT}},
53 {0x5, "Irda",
54 {0x30,0x60,0x61,0x70, EOT},
55 {NANA,NANA,NANA,NANA,EOT}},
56 {0x7, "Keyboard Controller",
57 {0x30, EOT},
58 {NANA,EOT}},
59 {0x9, "Mailbox",
60 {0x30,0x60,0x61, EOT},
61 {NANA,NANA,NANA,EOT}},
62 {EOT}}},
63 {EOT}
64};
65
66/* same as serverengines */
67static void enter_conf_mode_ec(uint16_t port)
68{
69 OUTB(0x5a, port);
70}
71
72static void exit_conf_mode_ec(uint16_t port)
73{
74 OUTB(0xa5, port);
75}
76
77uint16_t detect_ec(void)
78{
79 uint16_t ec_port;
80 struct pci_dev *dev;
81
82 dev = pci_dev_find(0x1002, 0x439d);
83
84 if (!dev) {
85 return 0;
86 }
87
88 /* is EC disabled ? */
89 if (!(pci_read_byte(dev, 0x40) & (1 << 7)))
90 return 0;
91
92 ec_port = pci_read_word(dev, 0xa4);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070093
Rudolf Marek113c3492011-10-27 20:42:11 +020094 if (!(ec_port & 0x1))
95 return 0;
96
97 ec_port &= ~0x1;
98
99 return ec_port;
100}
101
102void probe_idregs_amd(uint16_t port)
103{
104 uint8_t rev, devid;
105
106 probing_for("AMD EC", "", port);
107
108 if (!(port = detect_ec()))
109 return;
110
111 enter_conf_mode_ec(port);
112
113 devid = regval(port, DEVICE_ID_REG);
114 rev = regval(port, DEVICE_REV_REG);
115
116 if (superio_unknown(reg_table, devid)) {
117 if (verbose)
118 printf(NOTFOUND "id=0x%02x, rev=0x%02x\n", devid, rev);
119 exit_conf_mode_ec(port);
120 return;
121 }
122
123 printf("Found AMD EC %s (id=0x%02x, rev=0x%02x) at 0x%x\n",
124 get_superio_name(reg_table, devid), devid, rev, port);
125 chip_found = 1;
126
127 dump_superio("AMD EC", reg_table, port, devid, LDN_SEL);
128
129 exit_conf_mode_ec(port);
130}
131
132void print_amd_chips(void)
133{
134 print_vendor_chips("AMD EC", reg_table);
135}