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) | |
Micah C
2011/03/28 02:08:22
This function is complex enough to justify a comme
Louis
2011/03/30 10:15:39
Done. Good point.
On 2011/03/28 02:08:22, Micah C
| |
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) | |
Micah C
2011/03/28 02:08:22
The appearance of the constant string "CPU part" 3
Louis
2011/03/30 10:15:39
Good idea. Done.
| |
105 ptr += sizeof("CPU part") - 1; | |
106 while (*ptr && isspace((unsigned char)*ptr)) | |
107 ptr++; | |
108 if (*ptr != ':') | |
109 continue; | |
110 | |
111 fclose(cpuinfo); | |
Micah C
2011/03/28 02:08:22
This seems like a surprising place to close the fi
Louis
2011/03/30 10:15:39
Done.
| |
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"); | |
Micah C
2011/03/28 02:08:22
Is this a temporary debugging message, or somethin
dhendrix
2011/03/28 05:06:05
Nice catch. We should suppress this for normal usa
Louis
2011/03/30 10:15:39
Done.
Louis
2011/03/30 10:15:39
Done.
| |
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 |