blob: b71d43cdbf09dc8c457f9b6d91f86ec7d2b0bc11 [file] [log] [blame]
Uwe Hermann622fb792010-01-24 01:47:58 +00001/*
2 * This file is part of the superiotool project.
3 *
4 * Copyright (C) 2009 Carl-Daniel Hailfinger
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.
Uwe Hermann622fb792010-01-24 01:47:58 +000015 */
16
17#include "superiotool.h"
18
19#define DEVICE_ID_VT82C686_REG 0xe0
20#define DEVICE_REV_VT82C686_REG 0xe1
21
22static const struct superio_registers reg_table[] = {
23 {0x3c, "VT82C686A/VT82C686B", {
24 {EOT}}},
25 {EOT}
26};
27
28static uint8_t vt82c686_conf = 0;
29
30static int enter_conf_mode_via_vt82c686(void)
31{
32 struct pci_dev *dev;
33
34 dev = pci_dev_find(0x1106, 0x0686);
35 if (!dev) {
36 if (verbose)
37 printf(" PCI device 1106:0686 not found.\n");
38 return 1;
39 }
40
41 vt82c686_conf = pci_read_byte(dev, 0x85);
42 if (verbose)
43 printf(" Super I/O %sabled, Super I/O configuration %sabled\n",
44 (vt82c686_conf & (1 << 0)) ? "en" : "dis",
45 (vt82c686_conf & (1 << 1)) ? "en" : "dis");
46
47 /* If the Super I/O is not enabled, skip it. */
48 if (!(vt82c686_conf & (1 << 0)))
49 return 1;
50
51 /* Enable Super I/O configuration mode. */
52 pci_write_byte(dev, 0x85, vt82c686_conf | (1 << 1));
53
54 return 0;
55}
56
57static void exit_conf_mode_via_vt82c686(void)
58{
59 struct pci_dev *dev;
60
61 dev = pci_dev_find(0x1106, 0x0686);
62 if (!dev) {
63 printf("Bug: PCI device 1106:0686 not found during shutdown.\n"
64 "Please report to coreboot@coreboot.org.\n");
65 return;
66 }
67
68 /* Restore (disable?) Super I/O configuration mode setting. */
69 pci_write_byte(dev, 0x85, vt82c686_conf);
70}
71
72void probe_idregs_via(uint16_t port)
73{
74 uint16_t id;
75 uint8_t rev;
76
77 probing_for("VIA", "", port);
78
79 if (enter_conf_mode_via_vt82c686())
80 return;
81
82 id = regval(port, DEVICE_ID_VT82C686_REG);
83 rev = regval(port, DEVICE_REV_VT82C686_REG);
84
85 if (superio_unknown(reg_table, id)) {
86 if (verbose)
87 printf(NOTFOUND "id=0x%04x, rev=0x%02x\n", id, rev);
88 exit_conf_mode_via_vt82c686();
89 return;
90 }
91
92 printf("Found VIA %s (id=0x%04x, rev=0x%02x) at 0x%x\n",
93 get_superio_name(reg_table, id), id, rev, port);
94 chip_found = 1;
95
96 exit_conf_mode_via_vt82c686();
97}
98
99void print_via_chips(void)
100{
101 print_vendor_chips("VIA", reg_table);
102}