[flashrom] [PATCH] Asus P3B-F support

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Mon Oct 4 15:45:10 CEST 2010


Unfinished, posting to get some discussion about i2c infrastructure going.

TODO:
- Write i2c code
- Use correct data for board enable table

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: flashrom-asus_p3b_f/Makefile
===================================================================
--- flashrom-asus_p3b_f/Makefile	(Revision 1184)
+++ flashrom-asus_p3b_f/Makefile	(Arbeitskopie)
@@ -171,7 +171,7 @@
 
 ifeq ($(CONFIG_INTERNAL), yes)
 FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
-PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
+PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o i2c.o internal.o
 # FIXME: The PROGRAMMER_OBJS below should only be included on x86.
 PROGRAMMER_OBJS += it87spi.o ichspi.o sb600spi.o wbsio_spi.o mcp6x_spi.o
 NEED_PCI := yes
Index: flashrom-asus_p3b_f/i2c.c
===================================================================
--- flashrom-asus_p3b_f/i2c.c	(Revision 0)
+++ flashrom-asus_p3b_f/i2c.c	(Revision 0)
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2000 Silicon Integrated System Corporation
+ * Copyright (C) 2005-2009 coresystems GmbH
+ * Copyright (C) 2006 Uwe Hermann <uwe at hermann-uwe.de>
+ * Copyright (C) 2007,2008,2009 Carl-Daniel Hailfinger
+ * Copyright (C) 2009 Kontron Modular Computers GmbH
+ *
+ * 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; version 2 of the License.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/*
+ * Contains the I2C support code. Linux-only hack for now.
+ */
+
+#include "flash.h"
+
+int i2c_init(int bus, int devaddr)
+{
+	//"i2cdetect -l";
+	return 0;
+}
+
+uint8_t i2c_read_byte(int bus, int devaddr, int dataaddr)
+{
+	//"i2cget -y";
+	return 0xff;
+}
+
+uint8_t i2c_write_byte(int bus, int devaddr, int dataaddr, uint8_t val)
+{
+	//"i2cset -y";
+	return 0;
+}
+
+int i2c_shutdown(int bus)
+{
+	return 0;
+}
Index: flashrom-asus_p3b_f/programmer.h
===================================================================
--- flashrom-asus_p3b_f/programmer.h	(Revision 1184)
+++ flashrom-asus_p3b_f/programmer.h	(Arbeitskopie)
@@ -252,6 +252,12 @@
 void dmi_init(void);
 int dmi_match(const char *pattern);
 
+/* i2c.c */
+int i2c_init(int bus, int devaddr);
+uint8_t i2c_read_byte(int bus, int devaddr, int dataaddr);
+uint8_t i2c_write_byte(int bus, int devaddr, int dataaddr, uint8_t val);
+int i2c_shutdown(int bus);
+
 /* internal.c */
 #if NEED_PCI == 1
 struct superio {
Index: flashrom-asus_p3b_f/board_enable.c
===================================================================
--- flashrom-asus_p3b_f/board_enable.c	(Revision 1184)
+++ flashrom-asus_p3b_f/board_enable.c	(Arbeitskopie)
@@ -762,6 +762,41 @@
 }
 
 /*
+ * Suited for:
+ *  - ASUS P3B-F
+ *
+ * This is a gross hack until we have a cross-platform i2c infrastructure.
+ */
+static int board_asus_p3b_f(void)
+{
+	uint8_t bus = 0, devaddr = 0x48, dataaddr = 0x80;
+	uint8_t reg;
+
+	if (i2c_init(bus, devaddr)) {
+		msg_perr("i2c init failed. Aborting board enable.\n");
+		return 1;
+	}
+
+	reg = i2c_read_byte(bus, devaddr, dataaddr);
+	if ((reg & ~0x08) != 0x80) {
+		msg_perr("Yeargh! Unexpected value at i2c bus 0x%x, dev 0x%x, "
+			 "addr 0x%x: 0x%x\n", bus, devaddr, dataaddr, reg);
+		i2c_shutdown(bus);
+		return 1;
+	}
+	if (!(reg & 0x08)) {
+		msg_pdbg("Flash writes already enabled. Nothing to do.\n");
+		i2c_shutdown(bus);
+		return 0;
+	}
+	reg &= ~0x08;
+	i2c_write_byte(bus, devaddr, dataaddr, reg);
+
+	i2c_shutdown(bus);
+	return 0;
+}
+
+/*
  * Set GPIO lines in the Broadcom HT-1000 southbridge.
  *
  * It's not a Super I/O but it uses the same index/data port method.
@@ -1889,6 +1924,7 @@
 	{0x10DE, 0x0264, 0x1043, 0x81C0,  0x10DE, 0x0260, 0x1043, 0x81C0, NULL,          NULL,         NULL,          "ASUS",        "M2NBP-VM CSM",          0,   OK, nvidia_mcp_gpio0_raise},
 	{0x1106, 0x1336, 0x1043, 0x80ed,  0x1106, 0x3288, 0x1043, 0x8249, NULL,          NULL,         NULL,          "ASUS",        "M2V-MX",                0,   OK, via_vt823x_gpio5_raise},
 	{0x8086, 0x7190,      0,      0,  0x8086, 0x7110,      0,      0, "^P2B-N$",     NULL,         NULL,          "ASUS",        "P2B-N",                 0,   OK, intel_piix4_gpo18_lower},
+	{     0,      0,      0,      0,       0,      0,      0,      0, "^P3B-F$",     NULL,         NULL,          "ASUS",        "P3B-F",                 0,   OK, board_asus_p3b_f},
 	{0x8086, 0x1A30, 0x1043, 0x8025,  0x8086, 0x244B, 0x104D, 0x80F0, NULL,          NULL,         NULL,          "ASUS",        "P4B266-LM",             0,   OK, intel_ich_gpio21_raise},
 	{0x8086, 0x1a30, 0x1043, 0x8070,  0x8086, 0x244b, 0x1043, 0x8028, NULL,          NULL,         NULL,          "ASUS",        "P4B266",                0,   OK, intel_ich_gpio22_raise},
 	{0x8086, 0x1A30, 0x1043, 0x8088,  0x8086, 0x24C3, 0x1043, 0x8089, NULL,          NULL,         NULL,          "ASUS",        "P4B533-E",              0,   NT, intel_ich_gpio22_raise},


-- 
http://www.hailfinger.org/





More information about the flashrom mailing list