Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: processor_enable.c

Issue 6731011: Add Tegra2 SPI controller. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flashrom.git@master
Patch Set: remove an empty line. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Makefile ('k') | programmer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 /* Returns true if the /proc/cpuinfo contains a line: "CPU part *: *0xc09".
90 * TODO: need to extend in future for same SPI controller in chip family.
91 */
92 static int is_tegra2(void)
93 {
94 FILE *cpuinfo;
95 uint32_t impl = 0, architecture = 0, variant = 0, part = 0;
96 const char *name = "CPU part";
97 const char *value = "0xc09";
98 int ret = 0;
99
100 cpuinfo = fopen("/proc/cpuinfo", "rb");
101 if (!cpuinfo)
102 return 0;
103 while (!feof(cpuinfo)) {
104 char line[512], *ptr;
105 if (fgets(line, sizeof(line), cpuinfo) == NULL)
106 break;
107 ptr = line;
108 while (*ptr && isspace((unsigned char)*ptr))
109 ptr++;
110 if (strncmp(ptr, name, strlen(name)) == 0)
111 ptr += strlen(name);
112 while (*ptr && isspace((unsigned char)*ptr))
113 ptr++;
114 if (*ptr != ':')
115 continue;
116 ptr++;
117 while (*ptr && isspace((unsigned char)*ptr))
118 ptr++;
119 ret = (strncmp(ptr, value, strlen(value)) == 0);
120 }
121 fclose(cpuinfo);
122 return ret;
123 }
124 #endif
125
84 int processor_flash_enable(void) 126 int processor_flash_enable(void)
85 { 127 {
86 /* FIXME: detect loongson on FreeBSD and OpenBSD as well. */ 128 /* FIXME: detect loongson on FreeBSD and OpenBSD as well. */
87 #if defined (__MIPSEL__) && defined (__linux) 129 #if defined (__MIPSEL__) && defined (__linux)
88 if (is_loongson()) { 130 if (is_loongson()) {
89 flashbase = 0x1fc00000; 131 flashbase = 0x1fc00000;
90 return 0; 132 return 0;
91 } 133 }
92 #endif 134 #endif
135 #if defined (__arm__)
136 if (is_tegra2()) {
137 msg_pdbg("Detected NVIDIA Tegra 2.\n");
138 return tegra2_spi_init();
139 }
140 #endif
93 /* Not implemented yet. Oh well. */ 141 /* Not implemented yet. Oh well. */
94 return 1; 142 return 1;
95 } 143 }
96 144
97 #endif 145 #endif
OLDNEW
« no previous file with comments | « Makefile ('k') | programmer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698