Add VIA VT82C686A/VT82C686B detection support to superiotool.
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Sun, 24 Jan 2010 01:40:46 +0000 (01:40 +0000)
committerUwe Hermann <uwe@hermann-uwe.de>
Sun, 24 Jan 2010 01:40:46 +0000 (01:40 +0000)
This adds an additional requirement to superiotool: libpci.
The PCI code is conditional on PCI_SUPPORT. You can set the
CONFIG_PCI variable in the Makefile to 'no' to disable it.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5047 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

util/superiotool/Makefile
util/superiotool/superiotool.c
util/superiotool/superiotool.h

index 6cb304273930a2882c7c1bb56507ebeae8c67d65..6a6b69762f01c7bf0a3cd1d2406494694cfe81fb 100644 (file)
@@ -1,7 +1,7 @@
 ##
 ## This file is part of the superiotool project.
 ##
-## Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2007-2010 Uwe Hermann <uwe@hermann-uwe.de>
 ##
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -39,6 +39,15 @@ ifeq ($(OS_ARCH), Darwin)
 LDFLAGS = -framework IOKit -framework DirectIO -lpci -lz
 endif
 
+# Support for PCI-attached "Super I/Os" (e.g. in VIA VT82686A/B).
+CONFIG_PCI = yes
+
+ifeq ($(CONFIG_PCI), yes)
+CFLAGS += -DPCI_SUPPORT
+LDFLAGS += -lpci
+OBJS += pci.o via.o
+endif
+
 all: $(PROGRAM)
 
 superiotool.o: *.c superiotool.h
index 6786b0a47f085fcc8516de83bb4c25d85bbcc57c..2afc2bfa62b6810956a69da7bd730f59b9f93722 100644 (file)
@@ -282,6 +282,13 @@ int main(int argc, char *argv[])
 
        print_version();
 
+#ifdef PCI_SUPPORT
+       /* Do some basic libpci init. */
+       pacc = pci_alloc();
+       pci_init(pacc);
+       pci_scan_bus(pacc);
+#endif
+
        for (i = 0; i < ARRAY_SIZE(superio_ports_table); i++) {
                for (j = 0; superio_ports_table[i].ports[j] != EOT; j++)
                        superio_ports_table[i].probe_idregs(
index f9a38a1d5ab59b3113b0af4bce78509379c71cc1..c953038528b4d35f2fcf334efe66f04455bde965 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the superiotool project.
  *
  * Copyright (C) 2007 Carl-Daniel Hailfinger
- * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2007-2010 Uwe Hermann <uwe@hermann-uwe.de>
  * Copyright (C) 2008 Robinson P. Tryon <bishop.robinson@gmail.com>
  * Copyright (C) 2008-2009 coresystems GmbH
  *
 #include <DirectIO/darwinio.h>
 #endif
 
+#ifdef PCI_SUPPORT
+#include <pci/pci.h>
+#endif
+
 #if defined(__FreeBSD__)
 #include <sys/types.h>
 #include <machine/cpufunc.h>
@@ -102,6 +106,12 @@ struct superio_registers {
        } ldn[LDNSIZE];
 };
 
+/* pci.c */
+#ifdef PCI_SUPPORT
+extern struct pci_access *pacc;
+struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
+#endif
+
 /* superiotool.c */
 uint8_t regval(uint16_t port, uint8_t reg);
 void regwrite(uint16_t port, uint8_t reg, uint8_t val);
@@ -141,6 +151,12 @@ void print_smsc_chips(void);
 void probe_idregs_winbond(uint16_t port);
 void print_winbond_chips(void);
 
+/* via.c */
+#ifdef PCI_SUPPORT
+void probe_idregs_via(uint16_t port);
+void print_via_chips(void);
+#endif
+
 /** Table of which config ports to probe for each Super I/O family. */
 static const struct {
        void (*probe_idregs) (uint16_t port);
@@ -153,6 +169,9 @@ static const struct {
        {probe_idregs_nsc,      {0x2e, 0x4e, 0x15c, EOT}},
        {probe_idregs_smsc,     {0x2e, 0x4e, 0x162e, 0x164e, 0x3f0, 0x370, EOT}},
        {probe_idregs_winbond,  {0x2e, 0x4e, 0x3f0, 0x370, 0x250, EOT}},
+#ifdef PCI_SUPPORT
+       {probe_idregs_via,      {0x3f0, EOT}},
+#endif
 };
 
 /** Table of functions to print out supported Super I/O chips. */
@@ -165,6 +184,9 @@ static const struct {
        {print_nsc_chips},
        {print_smsc_chips},
        {print_winbond_chips},
+#ifdef PCI_SUPPORT
+       {print_via_chips},
+#endif
 };
 
 #endif