blob: 8c0492040eac30bd57d45a8c3ac7d59ec3dd01b1 [file] [log] [blame]
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*
* EXYNOS - mapping cpu onto physical core
* Author: Park Bumgyu <bumgyu.park@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/io.h>
#include <linux/smc.h>
#include <asm/cputype.h>
#ifndef CONFIG_SOC_EXYNOS7885
static char lot_id[6];
static u32 CHIPID_ReverseValue(u32 uValue, u32 nBitCnt)
{
u32 uTemp, uRetValue = 0;
u32 i;
for (i = 0; i < nBitCnt; i++) {
uTemp = (uValue >> i) & 0x1;
uRetValue += uTemp << ((nBitCnt - 1) - i);
}
return uRetValue;
}
static void CHIPID_DecTo36(u32 in, char *p)
{
u32 nMod;
u32 i;
for (i = 4; i >= 1; i--) {
nMod = in % 36;
in /= 36;
p[i] = (nMod < 10) ? (nMod + '0') : (nMod - 10 + 'A');
}
p[0] = 'N';
p[5] = 0;
}
void __init get_lot_id(void)
{
void __iomem *reg;
int value;
reg = early_ioremap(0x10000004, SZ_4K);
value = __raw_readl(reg);
early_iounmap(reg, SZ_4K);
value = CHIPID_ReverseValue(value, 32);
value = (value >> 11) & 0x1fffff;
CHIPID_DecTo36(value, lot_id);
pr_info("Lot ID = %s\n", lot_id);
}
#else
void __init get_lot_id(void) { }
#endif
u64 get_auto_cpu_hwid(u32 cpu)
{
int ret = exynos_smc(SMC_CMD_CPUMAP, cpu, 0, 0);
if (ret < 0)
return INVALID_HWID;
#ifndef CONFIG_SOC_EXYNOS7885
if (cpu >= 4) {
if (strcmp(lot_id, "NZNP4") == 0 ||
strcmp(lot_id, "NZNP5") == 0 ||
strcmp(lot_id, "NZNP7") == 0 ||
strcmp(lot_id, "NZNRH") == 0 ||
strcmp(lot_id, "NZNVK") == 0 ||
strcmp(lot_id, "NZNV2") == 0)
return INVALID_HWID;
}
#endif
return ret;
}