Add support for AMD Geode LX / CS5536 to the flashrom utility.

Signed-off-by: Ingmar Schraub <[EMAIL PROTECTED]>

---

regards,

Ingmar
Index: chipset_enable.c
===================================================================
--- chipset_enable.c	(revision 2744)
+++ chipset_enable.c	(working copy)
@@ -11,9 +11,15 @@
  *
  */
 
+#define _LARGEFILE64_SOURCE
 #include <stdio.h>
 #include <pci/pci.h>
 #include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
 
 #include "flash.h"
 #include "debug.h"
@@ -414,6 +420,45 @@
 	return 0;
 }
 
+static int enable_flash_geodelx(struct pci_dev *dev, char *name)
+{
+	/* note: needs kernel support for /dev/cpu/0/msr. Compile support into
+	 * the kernel or create the msr kernel module and load it before
+	 * running flashrom !
+	 * note 2: make sure the device node /dev/cpu/0/msr c 202 0 exists!
+	 */
+
+	unsigned char buf[8];
+	int fd_msr;
+	unsigned long addr = 0x1808;
+	unsigned char wrbuf[] = { 0x00, 0xbf, 0xf7, 0x10, 0x02, 0x80, 0xff, 0x22};
+
+	fd_msr = open("/dev/cpu/0/msr", O_RDONLY);
+	if (fd_msr == -1)
+	{
+                fprintf(stderr, "ERROR: Cannot open /dev/cpu/0/msr. aborting\n");
+		exit(1);
+        }
+	lseek64(fd_msr, (off64_t)addr, SEEK_SET);
+	read(fd_msr, buf, 8);
+	close(fd_msr);
+
+	fd_msr = open("/dev/cpu/0/msr", O_WRONLY);
+	lseek64(fd_msr, (off64_t)addr, SEEK_SET);
+	write(fd_msr, wrbuf, 8);
+	close(fd_msr);
+
+	fd_msr = open("/dev/cpu/0/msr", O_RDONLY);
+	lseek64(fd_msr, (off64_t)addr, SEEK_SET);
+	read(fd_msr, buf, 8);
+	close(fd_msr);
+
+	if (memcmp(buf, wrbuf, 8))
+		return -1;
+
+	return 0;
+}
+
 typedef struct penable {
 	unsigned short vendor, device;
 	char *name;
@@ -473,6 +518,7 @@
 	{0x1002, 0x4377, "ATI SB400", enable_flash_sb400},	/* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */
 
 	{0x1166, 0x0205, "Broadcom HT-1000", enable_flash_ht1000},
+	{0x1022, 0x2090, "AMD Geode LX", enable_flash_geodelx},
 };
 
 /*
-- 
linuxbios mailing list
linuxbios@linuxbios.org
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to