1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

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>
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-29 23:37:24 +00:00 committed by Carl-Daniel Hailfinger
parent cb3eb05172
commit 5cfc94a98b
2 changed files with 52 additions and 1 deletions

View File

@ -244,7 +244,7 @@ int internal_init(void)
* The error code might have been a warning only.
* Besides that, we don't check the board enable return code either.
*/
#if defined(__i386__) || defined(__x86_64__)
#if defined(__i386__) || defined(__x86_64__) || defined (__mips)
return 0;
#else
msg_perr("Your platform is not supported yet for the internal "

View File

@ -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;
}