mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
soc: rockchip: cpuinfo: Add support for cpu code parse
This patch add cpu code parse from otp or efuse. Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> Change-Id: I550eb01725ba265d5eb47caaf1d0e66656cfb4b0
This commit is contained in:
@@ -32,6 +32,16 @@ static int rockchip_cpuinfo_probe(struct platform_device *pdev)
|
||||
size_t len;
|
||||
int i;
|
||||
|
||||
cell = nvmem_cell_get(dev, "cpu-code");
|
||||
if (!IS_ERR(cell)) {
|
||||
efuse_buf = nvmem_cell_read(cell, &len);
|
||||
nvmem_cell_put(cell);
|
||||
|
||||
if (len == 2)
|
||||
rockchip_set_cpu((efuse_buf[0] << 8 | efuse_buf[1]));
|
||||
kfree(efuse_buf);
|
||||
}
|
||||
|
||||
cell = nvmem_cell_get(dev, "cpu-version");
|
||||
if (!IS_ERR(cell)) {
|
||||
efuse_buf = nvmem_cell_read(cell, &len);
|
||||
@@ -68,6 +78,7 @@ static int rockchip_cpuinfo_probe(struct platform_device *pdev)
|
||||
system_serial_low = crc32(0, buf, 8);
|
||||
system_serial_high = crc32(system_serial_low, buf + 8, 8);
|
||||
|
||||
dev_info(dev, "SoC\t\t: %lx\n", rockchip_soc_id);
|
||||
dev_info(dev, "Serial\t\t: %08x%08x\n",
|
||||
system_serial_high, system_serial_low);
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
|
||||
#include <linux/of.h>
|
||||
|
||||
#define ROCKCHIP_CPU_MASK 0xffff0000
|
||||
#define ROCKCHIP_CPU_SHIFT 16
|
||||
#define ROCKCHIP_CPU_RK312X 0x31260000
|
||||
#define ROCKCHIP_CPU_RK3288 0x32880000
|
||||
#define ROCKCHIP_CPU_RK3308 0x33080000
|
||||
|
||||
#ifdef CONFIG_ROCKCHIP_CPUINFO
|
||||
|
||||
extern unsigned long rockchip_soc_id;
|
||||
@@ -36,6 +42,14 @@ static inline void rockchip_set_cpu_version(unsigned long ver)
|
||||
(ver << ROCKCHIP_CPU_VERION_SHIFT) & ROCKCHIP_CPU_VERION_MASK;
|
||||
}
|
||||
|
||||
static inline void rockchip_set_cpu(unsigned long code)
|
||||
{
|
||||
if (!code)
|
||||
return;
|
||||
|
||||
rockchip_soc_id &= ~ROCKCHIP_CPU_MASK;
|
||||
rockchip_soc_id |= (code << ROCKCHIP_CPU_SHIFT) & ROCKCHIP_CPU_MASK;
|
||||
}
|
||||
#else
|
||||
|
||||
#define rockchip_soc_id 0
|
||||
@@ -49,13 +63,11 @@ static inline void rockchip_set_cpu_version(unsigned long ver)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void rockchip_set_cpu(unsigned long code)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ROCKCHIP_CPU_MASK 0xffff0000
|
||||
#define ROCKCHIP_CPU_RK312X 0x31260000
|
||||
#define ROCKCHIP_CPU_RK3288 0x32880000
|
||||
#define ROCKCHIP_CPU_RK3308 0x33080000
|
||||
|
||||
#ifdef CONFIG_CPU_RK312X
|
||||
static inline bool cpu_is_rk312x(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user