Skip to content

Commit 7357f7d

Browse files
hfutxqdxuqd
and
xuqd
authored
Add support for some special qualcomm SoCs. (#67)
Co-authored-by: xuqd <[email protected]>
1 parent 728f3e9 commit 7357f7d

File tree

2 files changed

+85
-7
lines changed

2 files changed

+85
-7
lines changed

Diff for: src/arm/cache.c

+1
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ void cpuinfo_arm_decode_cache(
535535
l2_size = 1024 * 1024;
536536
break;
537537
case 660:
538+
case 662:
538539
/* Snapdragon 660: 1 MB L2 (little cores only) */
539540
l2_size = 1024 * 1024;
540541
break;

Diff for: src/arm/linux/chipset.c

+84-7
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,82 @@ static bool match_sm(
281281
return true;
282282
}
283283

284+
285+
struct special_map_entry {
286+
const char* platform;
287+
uint16_t model;
288+
uint8_t series;
289+
char suffix;
290+
};
291+
292+
static const struct special_map_entry qualcomm_hardware_map_entries[] = {
293+
{
294+
/* "Kona" -> Qualcomm Kona */
295+
.platform = "Kona",
296+
.series = cpuinfo_arm_chipset_series_qualcomm_snapdragon,
297+
.model = 865,
298+
},
299+
{
300+
/* "Bengal" -> Qualcomm Bengal */
301+
.platform = "Bengal",
302+
.series = cpuinfo_arm_chipset_series_qualcomm_snapdragon,
303+
.model = 662,
304+
},
305+
{
306+
/* "Bengalp" -> Qualcomm Bengalp */
307+
.platform = "Bengalp",
308+
.series = cpuinfo_arm_chipset_series_qualcomm_snapdragon,
309+
.model = 662,
310+
},
311+
{
312+
/* "Lito" -> Qualcomm Lito */
313+
.platform = "Lito",
314+
.series = cpuinfo_arm_chipset_series_qualcomm_snapdragon,
315+
.model = 765,
316+
.suffix = 'G'
317+
},
318+
{
319+
/* "Lagoon" -> Qualcomm Lagoon */
320+
.platform = "Lagoon",
321+
.series = cpuinfo_arm_chipset_series_qualcomm_snapdragon,
322+
.model = 0,
323+
},
324+
};
325+
326+
327+
int strcicmp(char const *a, char const *b)
328+
{
329+
for (;; a++, b++) {
330+
int d = tolower((unsigned char)*a) - tolower((unsigned char)*b);
331+
if (d != 0 || !*a)
332+
return d;
333+
}
334+
}
335+
336+
static bool match_qualcomm_special(
337+
const char* start, const char* end,
338+
struct cpuinfo_arm_chipset chipset[restrict static 1])
339+
{
340+
for (size_t i = 0; i < CPUINFO_COUNT_OF(qualcomm_hardware_map_entries); i++) {
341+
int length = end - start;
342+
if (strcicmp(qualcomm_hardware_map_entries[i].platform, start) == 0 &&
343+
qualcomm_hardware_map_entries[i].platform[length] == 0)
344+
{
345+
*chipset = (struct cpuinfo_arm_chipset) {
346+
.vendor = chipset_series_vendor[qualcomm_hardware_map_entries[i].series],
347+
.series = (enum cpuinfo_arm_chipset_series) qualcomm_hardware_map_entries[i].series,
348+
.model = qualcomm_hardware_map_entries[i].model,
349+
.suffix = {
350+
[0] = qualcomm_hardware_map_entries[i].suffix,
351+
},
352+
};
353+
return true;
354+
}
355+
}
356+
return false;
357+
358+
}
359+
284360
/**
285361
* Tries to match /Samsung Exynos\d{4}$/ signature (case-insensitive) for Samsung Exynos chipsets.
286362
* If match successful, extracts model information into \p chipset argument.
@@ -1752,13 +1828,6 @@ static bool is_tegra(const char* start, const char* end) {
17521828
return (length == 5 || start[5] == '3');
17531829
}
17541830

1755-
struct special_map_entry {
1756-
const char* platform;
1757-
uint16_t model;
1758-
uint8_t series;
1759-
char suffix;
1760-
};
1761-
17621831
static const struct special_map_entry special_hardware_map_entries[] = {
17631832
#if CPUINFO_ARCH_ARM
17641833
{
@@ -2317,6 +2386,14 @@ struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_ha
23172386
(int) hardware_length, hardware);
23182387
return chipset;
23192388
}
2389+
2390+
if (match_qualcomm_special(pos, hardware_end, &chipset)) {
2391+
cpuinfo_log_debug(
2392+
"matched Qualcomm signature in /proc/cpuinfo Hardware string \"%.*s\"",
2393+
(int) hardware_length, hardware);
2394+
return chipset;
2395+
}
2396+
23202397
}
23212398
word_start = false;
23222399
break;

0 commit comments

Comments
 (0)