Here you go, this work great, thanks again Stefan.

Signed-off-by: Joseph Smith <[EMAIL PROTECTED]>

Thanks - Joe
Index: intel-debugtools/ich_gpio_dump/ich_gpio.c
===================================================================
--- intel-debugtools/ich_gpio_dump/ich_gpio.c	(revision 0)
+++ intel-debugtools/ich_gpio_dump/ich_gpio.c	(revision 0)
@@ -0,0 +1,95 @@
+/*
+ * dump gpio on intel ICH series southbridges
+ *
+ * Copyright (C) 2008 by coresystems GmbH 
+ * written by Stefan Reinauer <[EMAIL PROTECTED]> 
+ * modded for all ICH's by Joseph Smith <[EMAIL PROTECTED]>
+ * 
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <getopt.h>
+
+#include <sys/io.h>
+#include <pci/pci.h>
+
+int map_gpio(uint16_t gpio)
+{
+	int i;
+	unsigned long size=0x40;
+
+	for (i=0; i<size; i+=4) {
+		printf("gpiobase+0x%04x: 0x%08x\n", i, inl(gpio+i));
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	struct pci_access *pacc;
+	struct pci_dev *sb;
+	uint16_t gpiobadd;
+	uint16_t device;
+
+	if (iopl(3)) { printf("You need to be root.\n"); exit(1); }
+
+	pacc = pci_alloc();
+	pci_init(pacc);
+	pci_scan_bus(pacc);
+
+	sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
+	if (!sb) {
+		printf("No southbridge found.\n");
+		pci_cleanup(pacc);
+		exit(1);
+	}
+
+	if (pci_read_word(sb, 0) != 0x8086) {
+		printf("Not an Intel southbridge.\n");
+		
+		pci_free_dev(sb);
+		pci_cleanup(pacc);
+		exit(1);
+	}
+
+	printf("Intel Southbridge: %04x:%04x\n", 
+		pci_read_word(sb, 0), pci_read_word(sb, 2));
+
+	device = pci_read_word(sb, 2);
+
+	if (device < 0x2640) {
+		gpiobadd = pci_read_word(sb, 0x58) & 0xfffc; 
+	} else if (device >= 0x2640) {
+		gpiobadd = pci_read_word(sb, 0x48) & 0xfffc;
+	}
+	printf("GPIOBASE = 0x%04x\n\n", gpiobadd);
+
+	pci_free_dev(sb);
+	pci_cleanup(pacc);
+
+	map_gpio(gpiobadd);
+
+
+	return 0;
+}
Index: intel-debugtools/ich_gpio_dump/Makefile
===================================================================
--- intel-debugtools/ich_gpio_dump/Makefile	(revision 0)
+++ intel-debugtools/ich_gpio_dump/Makefile	(revision 0)
@@ -0,0 +1,62 @@
+#
+# Makefile for ich_gpio utility
+# 
+# (C) 2008 by coresystems GmbH
+# written by Stefan Reinauer <[EMAIL PROTECTED]>
+# modded for all ICH's by Joseph Smith <[EMAIL PROTECTED]>
+#
+
+PROGRAM = ich_gpio
+
+CC      = gcc
+STRIP	= strip
+INSTALL = /usr/bin/install
+PREFIX  = /usr/local
+CFLAGS  = -O2 -g -Wall
+OS_ARCH	= $(shell uname)
+ifeq ($(OS_ARCH), SunOS)
+LDFLAGS = -lpci -lz
+else
+LDFLAGS = -lpci -lz -static 
+STRIP_ARGS = -s
+endif
+
+OBJS = ich_gpio.o
+
+all: pciutils dep $(PROGRAM)
+
+$(PROGRAM): $(OBJS)
+	$(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
+	$(STRIP) $(STRIP_ARGS) $(PROGRAM)
+
+clean:
+	rm -f *.o *~
+
+distclean: clean
+	rm -f $(PROGRAM) .dependencies
+	
+dep:
+	@$(CC) -MM *.c > .dependencies
+
+pciutils:
+	@echo; echo -n "Checking for pciutils and zlib... "
+	@$(shell ( echo "#include <pci/pci.h>";		   \
+		   echo "struct pci_access *pacc;";	   \
+		   echo "int main(int argc, char **argv)"; \
+		   echo "{ pacc = pci_alloc(); return 0; }"; ) > .test.c )
+	@$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) &>/dev/null &&	\
+		echo "found." || ( echo "not found."; echo;		\
+		echo "Please install pciutils-devel and zlib-devel.";	\
+		echo "See README for more information."; echo;		\
+		rm -f .test.c .test; exit 1)
+	@rm -f .test.c .test
+
+install: $(PROGRAM)
+	$(INSTALL) $(PROGRAM) $(PREFIX)/sbin
+	mkdir -p $(PREFIX)/share/man/man8
+	$(INSTALL) $(PROGRAM).8 $(PREFIX)/share/man/man8
+
+.PHONY: all clean distclean dep pciutils
+
+-include .dependencies
+
-- 
coreboot mailing list
[email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to