void cpuinfo_arm_fixup_chipset()

in src/arm/linux/chipset.c [3166:3395]


void cpuinfo_arm_fixup_chipset(
	struct cpuinfo_arm_chipset chipset[restrict static 1], uint32_t cores, uint32_t max_cpu_freq_max)
{
	switch (chipset->series) {
		case cpuinfo_arm_chipset_series_qualcomm_msm:
			/* Check if there is suffix */
			if (chipset->suffix[0] == 0) {
				/* No suffix, but the model may be misreported */
				switch (chipset->model) {
					case 8216:
						/* MSM8216 was renamed to MSM8916 */
						cpuinfo_log_info("reinterpreted MSM8216 chipset as MSM8916");
						chipset->model = 8916;
						break;
					case 8916:
						/* Common bug: MSM8939 (Octa-core) reported as MSM8916 (Quad-core) */
						switch (cores) {
							case 4:
								break;
							case 8:
								cpuinfo_log_info("reinterpreted MSM8916 chipset with 8 cores as MSM8939");
								chipset->model = 8939;
								break;
							default:
								cpuinfo_log_warning("system reported invalid %"PRIu32"-core MSM%"PRIu32" chipset",
									cores, chipset->model);
								chipset->model = 0;
						}
						break;
					case 8937:
						/* Common bug: MSM8917 (Quad-core) reported as MSM8937 (Octa-core) */
						switch (cores) {
							case 4:
								cpuinfo_log_info("reinterpreted MSM8937 chipset with 4 cores as MSM8917");
								chipset->model = 8917;
								break;
							case 8:
								break;
							default:
								cpuinfo_log_warning("system reported invalid %"PRIu32"-core MSM%"PRIu32" chipset",
									cores, chipset->model);
								chipset->model = 0;
						}
						break;
					case 8960:
						/* Common bug: APQ8064 (Quad-core) reported as MSM8960 (Dual-core) */
						switch (cores) {
							case 2:
								break;
							case 4:
								cpuinfo_log_info("reinterpreted MSM8960 chipset with 4 cores as APQ8064");
								chipset->series = cpuinfo_arm_chipset_series_qualcomm_apq;
								chipset->model = 8064;
								break;
							default:
								cpuinfo_log_warning("system reported invalid %"PRIu32"-core MSM%"PRIu32" chipset",
									cores, chipset->model);
								chipset->model = 0;
						}
						break;
					case 8996:
						/* Common bug: MSM8994 (Octa-core) reported as MSM8996 (Quad-core) */
						switch (cores) {
							case 4:
								break;
							case 8:
								cpuinfo_log_info("reinterpreted MSM8996 chipset with 8 cores as MSM8994");
								chipset->model = 8994;
								break;
							default:
								cpuinfo_log_warning("system reported invalid %"PRIu32"-core MSM%"PRIu32" chipset",
									cores, chipset->model);
								chipset->model = 0;
						}
						break;
#if CPUINFO_ARCH_ARM
					case 8610:
						/* Common bug: MSM8612 (Quad-core) reported as MSM8610 (Dual-core) */
						switch (cores) {
							case 2:
								break;
							case 4:
								cpuinfo_log_info("reinterpreted MSM8610 chipset with 4 cores as MSM8612");
								chipset->model = 8612;
								break;
							default:
								cpuinfo_log_warning("system reported invalid %"PRIu32"-core MSM%"PRIu32" chipset",
									cores, chipset->model);
								chipset->model = 0;
						}
						break;
#endif /* CPUINFO_ARCH_ARM */
				}
			} else {
				/* Suffix may need correction */
				const uint32_t suffix_word = load_u32le(chipset->suffix);
				if (suffix_word == UINT32_C(0x004D534D) /* "\0MSM" = reverse("MSM\0") */) {
					/*
					 * Common bug: model name repeated twice, e.g. "MSM8916MSM8916"
					 * In this case, model matching code parses the second "MSM" as a suffix
					 */
					chipset->suffix[0] = 0;
					chipset->suffix[1] = 0;
					chipset->suffix[2] = 0;
				} else {
					switch (chipset->model) {
						case 8976:
							/* MSM8976SG -> MSM8976PRO */
							if (suffix_word == UINT32_C(0x00004753) /* "\0\0GS" = reverse("SG\0\0") */ ) {
								chipset->suffix[0] = 'P';
								chipset->suffix[1] = 'R';
								chipset->suffix[2] = 'O';
							}
							break;
						case 8996:
							/* MSM8996PRO -> MSM8996PRO-AB or MSM8996PRO-AC */
							if (suffix_word == UINT32_C(0x004F5250) /* "\0ORP" = reverse("PRO\0") */ ) {
								chipset->suffix[3] = '-';
								chipset->suffix[4] = 'A';
								chipset->suffix[5] = 'B' + (char) (max_cpu_freq_max >= 2188800);
							}
							break;
					}
				}
			}
			break;
		case cpuinfo_arm_chipset_series_qualcomm_apq:
		{
			/* Suffix may need correction */
			const uint32_t expected_apq = load_u32le(chipset->suffix);
			if (expected_apq == UINT32_C(0x00515041) /* "\0QPA" = reverse("APQ\0") */) {
				/*
				 * Common bug: model name repeated twice, e.g. "APQ8016APQ8016"
				 * In this case, model matching code parses the second "APQ" as a suffix
				 */
				chipset->suffix[0] = 0;
				chipset->suffix[1] = 0;
				chipset->suffix[2] = 0;
			}
			break;
		}
		case cpuinfo_arm_chipset_series_samsung_exynos:
			switch (chipset->model) {
#if CPUINFO_ARCH_ARM
				case 4410:
					/* Exynos 4410 was renamed to Exynos 4412 */
					chipset->model = 4412;
					break;
				case 5420:
					/* Common bug: Exynos 5260 (Hexa-core) reported as Exynos 5420 (Quad-core) */
					switch (cores) {
						case 4:
							break;
						case 6:
							cpuinfo_log_info("reinterpreted Exynos 5420 chipset with 6 cores as Exynos 5260");
							chipset->model = 5260;
							break;
						default:
							cpuinfo_log_warning("system reported invalid %"PRIu32"-core Exynos 5420 chipset", cores);
							chipset->model = 0;
					}
					break;
#endif /* CPUINFO_ARCH_ARM */
				case 7580:
					/* Common bug: Exynos 7578 (Quad-core) reported as Exynos 7580 (Octa-core) */
					switch (cores) {
						case 4:
							cpuinfo_log_info("reinterpreted Exynos 7580 chipset with 4 cores as Exynos 7578");
							chipset->model = 7578;
							break;
						case 8:
							break;
						default:
							cpuinfo_log_warning("system reported invalid %"PRIu32"-core Exynos 7580 chipset", cores);
							chipset->model = 0;
					}
					break;
			}
			break;
		case cpuinfo_arm_chipset_series_mediatek_mt:
			if (chipset->model == 6752) {
				/* Common bug: MT6732 (Quad-core) reported as MT6752 (Octa-core) */
				switch (cores) {
					case 4:
						cpuinfo_log_info("reinterpreted MT6752 chipset with 4 cores as MT6732");
						chipset->model = 6732;
						break;
					case 8:
						break;
					default:
						cpuinfo_log_warning("system reported invalid %"PRIu32"-core MT6752 chipset", cores);
						chipset->model = 0;
				}
			}
			if (chipset->suffix[0] == 'T') {
				/* Normalization: "TURBO" and "TRUBO" (apparently a typo) -> "T" */
				const uint32_t suffix_word = load_u32le(chipset->suffix + 1);
				switch (suffix_word) {
					case UINT32_C(0x4F425255): /* "OBRU" = reverse("URBO") */
					case UINT32_C(0x4F425552): /* "OBUR" = reverse("RUBO") */
						if (chipset->suffix[5] == 0) {
							chipset->suffix[1] = 0;
							chipset->suffix[2] = 0;
							chipset->suffix[3] = 0;
							chipset->suffix[4] = 0;
						}
						break;
				}
			}
			break;
		case cpuinfo_arm_chipset_series_rockchip_rk:
			if (chipset->model == 3288) {
				/* Common bug: Rockchip RK3399 (Hexa-core) always reported as RK3288 (Quad-core) */
				switch (cores) {
					case 4:
						break;
					case 6:
						cpuinfo_log_info("reinterpreted RK3288 chipset with 6 cores as RK3399");
						chipset->model = 3399;
						break;
					default:
						cpuinfo_log_warning("system reported invalid %"PRIu32"-core RK3288 chipset", cores);
						chipset->model = 0;
				}
			}
			break;
		default:
			break;
	}
}