soc: rockchip: cpuinfo: read cpu version from eFuse
Change-Id: Ia18ff4e745f09fa04690bb7bc6d95169c389b9d2 Signed-off-by: Liang Chen <cl@rock-chips.com>
This commit is contained in:
parent
f54c22b859
commit
06b2370417
3 changed files with 44 additions and 4 deletions
|
|
@ -4,8 +4,9 @@ if ARCH_ROCKCHIP || COMPILE_TEST
|
|||
# Rockchip Soc drivers
|
||||
#
|
||||
config ROCKCHIP_CPUINFO
|
||||
tristate "Rockchip cpuinfo support"
|
||||
bool "Rockchip cpuinfo support"
|
||||
depends on ROCKCHIP_EFUSE && (ARM64 || ARM)
|
||||
default y
|
||||
help
|
||||
Say y here to enable Rockchip cpuinfo support.
|
||||
Set system_serial_low/high from eFuse ID.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <asm/system_info.h>
|
||||
#include <linux/rockchip/cpu.h>
|
||||
|
||||
unsigned long rockchip_soc_id;
|
||||
EXPORT_SYMBOL(rockchip_soc_id);
|
||||
|
||||
static int rockchip_cpuinfo_probe(struct platform_device *pdev)
|
||||
{
|
||||
|
|
@ -27,6 +31,16 @@ static int rockchip_cpuinfo_probe(struct platform_device *pdev)
|
|||
size_t len;
|
||||
int i;
|
||||
|
||||
cell = nvmem_cell_get(dev, "cpu-version");
|
||||
if (!IS_ERR(cell)) {
|
||||
efuse_buf = nvmem_cell_read(cell, &len);
|
||||
nvmem_cell_put(cell);
|
||||
|
||||
if (len == 1)
|
||||
rockchip_set_cpu_version(efuse_buf[0]);
|
||||
kfree(efuse_buf);
|
||||
}
|
||||
|
||||
cell = nvmem_cell_get(dev, "id");
|
||||
if (IS_ERR(cell)) {
|
||||
dev_err(dev, "failed to get id cell: %ld\n", PTR_ERR(cell));
|
||||
|
|
@ -72,4 +86,9 @@ static struct platform_driver rockchip_cpuinfo_driver = {
|
|||
.of_match_table = rockchip_cpuinfo_of_match,
|
||||
},
|
||||
};
|
||||
module_platform_driver(rockchip_cpuinfo_driver);
|
||||
|
||||
static int __init rockchip_cpuinfo_init(void)
|
||||
{
|
||||
return platform_driver_register(&rockchip_cpuinfo_driver);
|
||||
}
|
||||
subsys_initcall_sync(rockchip_cpuinfo_init);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __MACH_ROCKCHIP_CPU_H
|
||||
#define __MACH_ROCKCHIP_CPU_H
|
||||
|
||||
#ifdef CONFIG_ROCKCHIP_CPUINFO
|
||||
|
||||
extern unsigned long rockchip_soc_id;
|
||||
|
||||
static inline bool cpu_is_rockchip(void)
|
||||
|
|
@ -24,6 +26,24 @@ static inline void rockchip_set_cpu_version(unsigned long ver)
|
|||
(ver << ROCKCHIP_CPU_VERION_SHIFT) & ROCKCHIP_CPU_VERION_MASK;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline bool cpu_is_rockchip(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline unsigned long rockchip_get_cpu_version(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void rockchip_set_cpu_version(unsigned long ver)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define ROCKCHIP_CPU_MASK 0xffff0000
|
||||
#define ROCKCHIP_CPU_RK2928 0x29280000
|
||||
#define ROCKCHIP_CPU_RK3026 0x30260000
|
||||
|
|
@ -36,7 +56,7 @@ static inline void rockchip_set_cpu_version(unsigned long ver)
|
|||
#define ROCKCHIP_CPU_RK3288 0x32880000
|
||||
#define ROCKCHIP_CPU_RK3228 0x32280000
|
||||
|
||||
#ifdef CONFIG_ARM
|
||||
#ifdef CONFIG_ROCKCHIP_CPUINFO
|
||||
#define ROCKCHIP_CPU(id, ID) \
|
||||
static inline bool cpu_is_rk##id(void) \
|
||||
{ \
|
||||
|
|
@ -80,7 +100,7 @@ ROCKCHIP_CPU(3228, 3228)
|
|||
#define ROCKCHIP_SOC_RK3288 (ROCKCHIP_CPU_RK3288 | 0x00)
|
||||
#define ROCKCHIP_SOC_RK3228 (ROCKCHIP_CPU_RK3228 | 0x00)
|
||||
|
||||
#ifdef CONFIG_ARM
|
||||
#ifdef CONFIG_ROCKCHIP_CPUINFO
|
||||
#define ROCKCHIP_SOC(id, ID) \
|
||||
static inline bool soc_is_rk##id(void) \
|
||||
{ \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue