tree: drop last paragraph of GPL copyright header
[coreboot.git] / util / superiotool / amd.c
blobf78a79ba86fa6994ec1e4451c6677b4a2ae6b46b
1 /*
2 * This file is part of the superiotool project.
4 * Copyright (C) 2011 Rudolf Marek <r.marek@assembler.cz>
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.
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.
17 #include "superiotool.h"
19 #define DEVICE_ID_REG 0x20
20 #define DEVICE_REV_REG 0x21
22 static const struct superio_registers reg_table[] = {
23 {0xb7, "SB7xx", {
24 {NOLDN, NULL,
25 {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x28,0x29,0x2a,
26 0x2b,0x2c,0x2e, 0x2f, EOT},
27 {NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
28 {0x3, "EC channel 0",
29 {0x30,0x60,0x61, EOT},
30 {NANA,NANA,NANA,EOT}},
31 {0x5, "Irda",
32 {0x30,0x60,0x61,0x70, EOT},
33 {NANA,NANA,NANA,NANA,EOT}},
34 {0x7, "Keyboard Controller",
35 {0x30, EOT},
36 {NANA,EOT}},
37 {0x9, "Mailbox",
38 {0x30,0x60,0x61, EOT},
39 {NANA,NANA,NANA,EOT}},
40 {EOT}}},
41 {0xb8, "SB8xx", {
42 {NOLDN, NULL,
43 {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x28,0x29,0x2a,
44 0x2b,0x2c,0x2e, 0x2f, EOT},
45 {NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,NANA,EOT}},
46 {0x3, "EC channel 0",
47 {0x30,0x60,0x61, EOT},
48 {NANA,NANA,NANA,EOT}},
49 {0x5, "Irda",
50 {0x30,0x60,0x61,0x70, EOT},
51 {NANA,NANA,NANA,NANA,EOT}},
52 {0x7, "Keyboard Controller",
53 {0x30, EOT},
54 {NANA,EOT}},
55 {0x9, "Mailbox",
56 {0x30,0x60,0x61, EOT},
57 {NANA,NANA,NANA,EOT}},
58 {EOT}}},
59 {EOT}
62 /* same as serverengines */
63 static void enter_conf_mode_ec(uint16_t port)
65 OUTB(0x5a, port);
68 static void exit_conf_mode_ec(uint16_t port)
70 OUTB(0xa5, port);
73 uint16_t detect_ec(void)
75 uint16_t ec_port;
76 struct pci_dev *dev;
78 dev = pci_dev_find(0x1002, 0x439d);
80 if (!dev) {
81 return 0;
84 /* is EC disabled ? */
85 if (!(pci_read_byte(dev, 0x40) & (1 << 7)))
86 return 0;
88 ec_port = pci_read_word(dev, 0xa4);
90 if (!(ec_port & 0x1))
91 return 0;
93 ec_port &= ~0x1;
95 return ec_port;
98 void probe_idregs_amd(uint16_t port)
100 uint8_t rev, devid;
102 probing_for("AMD EC", "", port);
104 if (!(port = detect_ec()))
105 return;
107 enter_conf_mode_ec(port);
109 devid = regval(port, DEVICE_ID_REG);
110 rev = regval(port, DEVICE_REV_REG);
112 if (superio_unknown(reg_table, devid)) {
113 if (verbose)
114 printf(NOTFOUND "id=0x%02x, rev=0x%02x\n", devid, rev);
115 exit_conf_mode_ec(port);
116 return;
119 printf("Found AMD EC %s (id=0x%02x, rev=0x%02x) at 0x%x\n",
120 get_superio_name(reg_table, devid), devid, rev, port);
121 chip_found = 1;
123 dump_superio("AMD EC", reg_table, port, devid, LDN_SEL);
125 exit_conf_mode_ec(port);
128 void print_amd_chips(void)
130 print_vendor_chips("AMD EC", reg_table);