summaryrefslogtreecommitdiffstats
path: root/processor_enable.c
diff options
context:
space:
mode:
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>2010-09-29 23:37:24 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-09-29 23:37:24 +0000
commit5cfc94a98be9fa2317220c76367fe1792c328461 (patch)
tree75b4baeb1b33fe031ef74aaddd2529f1330aa994 /processor_enable.c
parentcb3eb051729118b3ac5acd67064ba519bb0cd88e (diff)
downloadast2050-flashrom-5cfc94a98be9fa2317220c76367fe1792c328461.zip
ast2050-flashrom-5cfc94a98be9fa2317220c76367fe1792c328461.tar.gz
Support for Loongson-2F (MIPS) flashing
Corresponding to flashrom svn r1183. Signed-off-by: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'processor_enable.c')
-rw-r--r--processor_enable.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/processor_enable.c b/processor_enable.c
index 245975e..74caedc 100644
--- a/processor_enable.c
+++ b/processor_enable.c
@@ -37,8 +37,59 @@ int processor_flash_enable(void)
#else
+#if defined (__MIPSEL__) && defined (__linux)
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+static int is_loongson(void)
+{
+ FILE *cpuinfo;
+ cpuinfo = fopen("/proc/cpuinfo", "rb");
+ if (!cpuinfo)
+ return 0;
+ while (!feof(cpuinfo)) {
+ char line[512], *ptr;
+ if (fgets(line, sizeof(line), cpuinfo) == NULL)
+ break;
+ ptr = line;
+ while (*ptr && isspace(*ptr))
+ ptr++;
+ /* "cpu" part appears only with some Linux versions. */
+ if (strncmp(ptr, "cpu", sizeof("cpu") - 1) == 0)
+ ptr += sizeof("cpu") - 1;
+ while (*ptr && isspace(*ptr))
+ ptr++;
+ if (strncmp(ptr, "model", sizeof("model") - 1) != 0)
+ continue;
+ ptr += sizeof("model") - 1;
+ while (*ptr && isspace(*ptr))
+ ptr++;
+ if (*ptr != ':')
+ continue;
+ ptr++;
+ while (*ptr && isspace(*ptr))
+ ptr++;
+ fclose(cpuinfo);
+ return (strncmp(ptr, "ICT Loongson-2 V0.3",
+ sizeof("ICT Loongson-2 V0.3") - 1) == 0)
+ || (strncmp(ptr, "Godson2 V0.3 FPU V0.1",
+ sizeof("Godson2 V0.3 FPU V0.1") - 1) == 0);
+ }
+ fclose(cpuinfo);
+ return 0;
+}
+#endif
+
int processor_flash_enable(void)
{
+ /* FIXME: detect loongson on FreeBSD and OpenBSD as well. */
+#if defined (__MIPSEL__) && defined (__linux)
+ if (is_loongson()) {
+ flashbase = 0x1fc00000;
+ return 0;
+ }
+#endif
/* Not implemented yet. Oh well. */
return 1;
}
OpenPOWER on IntegriCloud