| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the flashrom project. | 2 * This file is part of the flashrom project. |
| 3 * | 3 * |
| 4 * Copyright (C) 2010 Carl-Daniel Hailfinger | 4 * Copyright (C) 2010 Carl-Daniel Hailfinger |
| 5 * | 5 * |
| 6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
| 8 * the Free Software Foundation; version 2 of the License. | 8 * the Free Software Foundation; version 2 of the License. |
| 9 * | 9 * |
| 10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return (strncmp(ptr, "ICT Loongson-2 V0.3", | 74 return (strncmp(ptr, "ICT Loongson-2 V0.3", |
| 75 sizeof("ICT Loongson-2 V0.3") - 1) == 0) | 75 sizeof("ICT Loongson-2 V0.3") - 1) == 0) |
| 76 || (strncmp(ptr, "Godson2 V0.3 FPU V0.1", | 76 || (strncmp(ptr, "Godson2 V0.3 FPU V0.1", |
| 77 sizeof("Godson2 V0.3 FPU V0.1") - 1) == 0); | 77 sizeof("Godson2 V0.3 FPU V0.1") - 1) == 0); |
| 78 } | 78 } |
| 79 fclose(cpuinfo); | 79 fclose(cpuinfo); |
| 80 return 0; | 80 return 0; |
| 81 } | 81 } |
| 82 #endif | 82 #endif |
| 83 | 83 |
| 84 #if defined(__arm__) |
| 85 #include <stdio.h> |
| 86 #include <string.h> |
| 87 #include <ctype.h> |
| 88 |
| 89 static int is_tegra2(void) |
| 90 { |
| 91 FILE *cpuinfo; |
| 92 uint32_t impl = 0, architecture = 0, variant = 0, part = 0; |
| 93 |
| 94 cpuinfo = fopen("/proc/cpuinfo", "rb"); |
| 95 if (!cpuinfo) |
| 96 return 0; |
| 97 while (!feof(cpuinfo)) { |
| 98 char line[512], *ptr; |
| 99 if (fgets(line, sizeof(line), cpuinfo) == NULL) |
| 100 break; |
| 101 ptr = line; |
| 102 while (*ptr && isspace((unsigned char)*ptr)) |
| 103 ptr++; |
| 104 if (strncmp(ptr, "CPU part", sizeof("CPU part") - 1) == 0) |
| 105 ptr += sizeof("CPU part") - 1; |
| 106 while (*ptr && isspace((unsigned char)*ptr)) |
| 107 ptr++; |
| 108 if (*ptr != ':') |
| 109 continue; |
| 110 |
| 111 fclose(cpuinfo); |
| 112 ptr++; |
| 113 while (*ptr && isspace((unsigned char)*ptr)) |
| 114 ptr++; |
| 115 return (strncmp(ptr, "0xc09", |
| 116 sizeof("0xc09") - 1) == 0); |
| 117 } |
| 118 fclose(cpuinfo); |
| 119 return 0; |
| 120 } |
| 121 #endif |
| 122 |
| 84 int processor_flash_enable(void) | 123 int processor_flash_enable(void) |
| 85 { | 124 { |
| 86 /* FIXME: detect loongson on FreeBSD and OpenBSD as well. */ | 125 /* FIXME: detect loongson on FreeBSD and OpenBSD as well. */ |
| 87 #if defined (__MIPSEL__) && defined (__linux) | 126 #if defined (__MIPSEL__) && defined (__linux) |
| 88 if (is_loongson()) { | 127 if (is_loongson()) { |
| 89 flashbase = 0x1fc00000; | 128 flashbase = 0x1fc00000; |
| 90 return 0; | 129 return 0; |
| 91 } | 130 } |
| 92 #endif | 131 #endif |
| 132 #if defined (__arm__) |
| 133 if (is_tegra2()) { |
| 134 msg_pinfo("Detected NVIDIA Tegra 2.\n"); |
| 135 return tegra2_spi_init(); |
| 136 } |
| 137 #endif |
| 93 /* Not implemented yet. Oh well. */ | 138 /* Not implemented yet. Oh well. */ |
| 94 return 1; | 139 return 1; |
| 95 } | 140 } |
| 96 | 141 |
| 97 #endif | 142 #endif |
| OLD | NEW |