chipid: read chipid fail [1/1]

PD#SWPL-152551

Problem:
read chipid fail

Solution:
the chipid can be read by reading registers, but the register address is
set in DTS, which is prone to setting errors. It can be read through a
unified command, so there will be no previous problems.

Verify:
s905x2

Change-Id: I69b9e3236a338655e2fbc2293baa917d2c04312c
Signed-off-by: Wanwei Jiang <wanwei.jiang@amlogic.com>
This commit is contained in:
Wanwei Jiang
2024-01-11 11:22:41 +08:00
parent 8e35d620c0
commit bd79bdd444
35 changed files with 40 additions and 284 deletions
-6
View File
@@ -285,12 +285,6 @@
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x5a20 0x140>;
amlogic,has-chip-id;
};
meson_clk_msr@3400 {
compatible = "amlogic,a1-clk-measure";
reg = <0x3400 0x10>;
-6
View File
@@ -386,12 +386,6 @@
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x5a20 0x140>;
amlogic,has-chip-id;
};
meson_clk_msr@3400 {
compatible = "amlogic,c2-clk-measure";
reg = <0x3400 0x10>;
-6
View File
@@ -397,12 +397,6 @@
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x10220 0x140>;
amlogic,has-chip-id;
};
meson_clk_msr@3400 {
compatible = "amlogic,c3-clk-measure";
reg = <0x48000 0x10>;
-5
View File
@@ -636,11 +636,6 @@
reg = <0x2000 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x10220 0x4>;
};
};
crg_phy_20: crgphy20@fe318000 {
-5
View File
@@ -1101,11 +1101,6 @@
reg = <0x2000 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x10220 0x4>;
};
};
usb2_phy_v2: usb2phy@fe03a000 {
-5
View File
@@ -1137,11 +1137,6 @@
reg = <0x2000 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x10220 0x4>;
};
};
usb2_phy_v2: usb2phy@fe03a000 {
-6
View File
@@ -1139,12 +1139,6 @@
reg = <0x2000 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x10220 0x140>;
amlogic,has-chip-id;
};
};
usb2_phy_v2: usb2phy@fe03a000 {
-5
View File
@@ -1199,11 +1199,6 @@
};
};
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x10220 0x140>;
};
};
ethmac: ethernet@fdc00000 {
-7
View File
@@ -1226,13 +1226,6 @@
clocks = <&xtal>;
clock-names = "xtal";
};
sec_AO: ao-secure@140 {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg = <0x140 0x140>;
amlogic,has-chip-id;
};
};
uart_AO: serial@3000 {
-7
View File
@@ -730,13 +730,6 @@
#size-cells = <1>;
ranges = <0x0 0x0 0x300>;
sec_AO: ao-secure@140 {
compatible = "amlogic,meson-gx-ao-secure",
"syscon";
reg = <0x140 0x140>;
amlogic,has-chip-id;
};
clkc_AO: clock-controller@2 {
compatible = "amlogic,t5w-aoclkc";
#clock-cells = <1>;
@@ -1476,12 +1476,6 @@
#size-cells = <1>;
ranges = <0x0 0xff800000 0xa000>;
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x140 0x4>;
amlogic,has-chip-id;
};
dcon_led: dcon_led@1000 {
compatible = "amlogic,led_unipolar_ctrl";
reg = <0x1000 0x88>;
@@ -1177,12 +1177,6 @@
#size-cells = <1>;
ranges = <0x0 0xff800000 0xa000>;
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x140 0x4>;
amlogic,has-chip-id;
};
dcon_led: dcon_led@1000 {
compatible = "amlogic,led_unipolar_ctrl";
reg = <0x1000 0x88>;
@@ -278,12 +278,6 @@
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x5a20 0x0 0x140>;
amlogic,has-chip-id;
};
meson_clk_msr@3400 {
compatible = "amlogic,a1-clk-measure";
reg = <0x0 0x3400 0x0 0x10>;
@@ -1017,11 +1017,6 @@
reg = <0x0 0x2000 0x0 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x4>;
};
};
aobus_pinctrl: pinctrl@fe08e700 {
@@ -981,11 +981,6 @@
reg = <0x0 0x2000 0x0 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x4>;
};
};
crg_phy_20: crgphy20@fe03c000 {
-11
View File
@@ -277,12 +277,6 @@
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x5a20 0x0 0x140>;
amlogic,has-chip-id;
};
meson_clk_msr@3400 {
compatible = "amlogic,meson-c1-clk-measure";
reg = <0x0 0x3400 0x0 0x10>;
@@ -1536,11 +1530,6 @@
};
};
sec_AO: ao-secure {
compatible = "amlogic,meson-gx-ao-secure";
amlogic,has-chip-id;
};
timestamp {
compatible = "amlogic, meson-soc-timestamp";
reg = <0x0 0xfe005904 0x0 0x8>;
@@ -387,12 +387,6 @@
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x5a20 0x0 0x140>;
amlogic,has-chip-id;
};
meson_clk_msr@3400 {
compatible = "amlogic,c2-clk-measure";
reg = <0x0 0x3400 0x0 0x10>;
@@ -1102,11 +1102,6 @@
reg = <0x0 0x2000 0x0 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x4>;
};
};
usb2_phy_v2: usb2phy@fe03a000 {
@@ -932,11 +932,6 @@
reg = <0x0 0x2000 0x0 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x4>;
};
};
usb2_phy_v2: usb2phy@fe03a000 {
@@ -1140,12 +1140,6 @@
reg = <0x0 0x2000 0x0 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x140>;
amlogic,has-chip-id;
};
};
usb2_phy_v2: usb2phy@fe03a000 {
@@ -740,12 +740,6 @@
#size-cells = <2>;
ranges = <0x0 0x0 0x0 0xff800000 0x0 0xb000>;
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x220 0x0 0x4>;
amlogic,has-chip-id;
};
rti: sys-ctrl@0 {
compatible = "amlogic,meson-gx-ao-sysctrl",
"simple-mfd", "syscon";
@@ -817,12 +817,6 @@
#size-cells = <2>;
ranges = <0x0 0x0 0x0 0xff800000 0x0 0xb000>;
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x140 0x0 0x4>;
amlogic,has-chip-id;
};
rti: sys-ctrl@0 {
compatible = "amlogic,meson-gx-ao-sysctrl",
"simple-mfd", "syscon";
-6
View File
@@ -1055,12 +1055,6 @@
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
status = "disable"
reg=<0x0 0x10220 0x0 0x140>;
};
gbl_timer_core: global-timer@8e000 {
compatible = "amlogic,meson-glb-timer-core";
reg = <0x0 0x8e000 0x0 0x28>;
@@ -905,12 +905,6 @@
#size-cells = <2>;
ranges = <0x0 0x0 0x0 0xff800000 0x0 0xb000>;
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x140 0x0 0x4>;
amlogic,has-chip-id;
};
rti: sys-ctrl@0 {
compatible = "amlogic,meson-gx-ao-sysctrl",
"simple-mfd", "syscon";
-5
View File
@@ -1206,11 +1206,6 @@
};
};
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x140>;
};
};
ethmac: ethernet@fdc00000 {
@@ -1133,12 +1133,6 @@
};
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
status = "disable"
reg=<0x0 0x10220 0x0 0x140>;
};
gbl_timer_core: global-timer@8e000 {
compatible = "amlogic,meson-glb-timer-core";
reg = <0x0 0x8e000 0x0 0x28>;
@@ -1045,12 +1045,6 @@
};
};
cpu_version {
status = "okay";
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x140>;
};
hwspinlock_regs: syscon@e2c0 {
compatible = "syscon";
reg = <0x0 0xe2c0 0x0 0x20>;
@@ -1063,12 +1063,6 @@
};
};
cpu_version {
status = "okay";
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x140>;
};
hwspinlock_regs: syscon@e2c0 {
compatible = "syscon";
reg = <0x0 0xe2c0 0x0 0x20>;
@@ -731,13 +731,6 @@
#size-cells = <2>;
ranges = <0x0 0x0 0x0 0x0 0x0 0x300>;
sec_AO: ao-secure@140 {
compatible = "amlogic,meson-gx-ao-secure",
"syscon";
reg = <0x0 0x140 0x0 0x140>;
amlogic,has-chip-id;
};
clkc_AO: clock-controller@2 {
compatible = "amlogic,t5w-aoclkc";
#clock-cells = <1>;
-6
View File
@@ -1689,12 +1689,6 @@
reg = <0x0 0x2000 0x0 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x140>;
amlogic,has-chip-id;
};
};
crg_phy_20: crgphy20@fe03c000 {
@@ -1611,12 +1611,6 @@
reg = <0x0 0x2000 0x0 0x98>;
#reset-cells = <1>;
};
cpu_version {
compatible = "amlogic,meson-gx-ao-secure", "syscon";
reg=<0x0 0x10220 0x0 0x140>;
amlogic,has-chip-id;
};
};
crg_phy_20: crgphy20@fe03c000 {
+1 -1
View File
@@ -2,7 +2,7 @@
MODULE_NAME = amlogic-cpuinfo
obj-$(CONFIG_AMLOGIC_CPU_INFO) = $(MODULE_NAME).o
$(MODULE_NAME)-y += cpu_info.o cpu_version.o
$(MODULE_NAME)-y += cpu_info.o
PR_FMT = $(subst amlogic-,,$(MODULE_NAME))
PR_FMT_DEFINE="-Dpr_fmt(fmt)= \"[$(PR_FMT)]: \" fmt"
+39 -2
View File
@@ -27,10 +27,48 @@
#endif
#include <linux/upstream_version.h>
static int init_done;
static unsigned char cpuinfo_chip_id[CHIPID_LEN];
static int cpu_id_from_media;
int get_cpu_type_from_media(void)
{
return cpu_id_from_media;
}
EXPORT_SYMBOL(get_cpu_type_from_media);
void set_cpu_type_from_media(int cpu_id)
{
if (cpu_id <= 0) {
pr_err("wrong cpu id from media driver 0x%x.\n", cpu_id);
return;
}
cpu_id_from_media = cpu_id;
}
EXPORT_SYMBOL(set_cpu_type_from_media);
unsigned char get_meson_cpu_version(int level)
{
if (!init_done) {
pr_err("too early call %s\n", __func__);
dump_stack();
return -1;
}
if (level >= 0 && level <= MESON_CPU_VERSION_LVL_MAX)
return cpuinfo_chip_id[level];
return 0;
}
EXPORT_SYMBOL(get_meson_cpu_version);
void cpuinfo_get_chipid(unsigned char *cid, unsigned int size)
{
if (!init_done) {
pr_err("too early call %s\n", __func__);
dump_stack();
return;
}
memcpy(&cid[0], cpuinfo_chip_id, size);
}
EXPORT_SYMBOL(cpuinfo_get_chipid);
@@ -114,6 +152,7 @@ static int cpuinfo_probe(struct platform_device *pdev)
meson_sm_mutex_unlock();
if (ret == 0) {
init_done = 1;
pr_info("serial = ");
for (i = 0; i < CHIPID_LEN; i++)
pr_cont("%02x", cpuinfo_chip_id[i]);
@@ -151,8 +190,6 @@ static int __init meson_cpuinfo_init(void)
pr_notice("kernel upgrade info: <%d> <%s> <%s-%s>\n",
AML_KERNEL_VERSION, MERGE_DATE, UPSTREAM_VERSION, AML_PATCH_VERSION);
meson_cpu_version_init();
return platform_driver_register(&cpuinfo_platform_driver);
}
-95
View File
@@ -1,95 +0,0 @@
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Copyright (c) 2019 Amlogic, Inc. All rights reserved.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/amlogic/cpu_version.h>
#include <linux/printk.h>
#include <linux/string.h>
#include <linux/of_address.h>
#include <linux/io.h>
#include <linux/regmap.h>
#include <linux/mfd/syscon.h>
#define AO_SEC_SD_CFG8 0xe0
#define AO_SEC_SOCINFO_OFFSET AO_SEC_SD_CFG8
static unsigned char cpu_version[MESON_CPU_VERSION_LVL_MAX + 1];
static int init_done;
static int cpu_id_from_media;
int get_cpu_type_from_media(void)
{
return cpu_id_from_media;
}
EXPORT_SYMBOL(get_cpu_type_from_media);
void set_cpu_type_from_media(int cpu_id)
{
if (cpu_id <= 0) {
pr_err("wrong cpu id from media driver 0x%x.\n", cpu_id);
return;
}
cpu_id_from_media = cpu_id;
}
EXPORT_SYMBOL(set_cpu_type_from_media);
unsigned char get_meson_cpu_version(int level)
{
if (!init_done) {
pr_err("too early call %s\n", __func__);
dump_stack();
return -1;
}
if (level >= 0 && level <= MESON_CPU_VERSION_LVL_MAX)
return cpu_version[level];
return 0;
}
EXPORT_SYMBOL(get_meson_cpu_version);
int __init meson_cpu_version_init(void)
{
struct device_node *np;
unsigned int socinfo;
struct regmap *regmap;
int ret;
/* look up for chipid node */
np = of_find_compatible_node(NULL, NULL, "amlogic,meson-gx-ao-secure");
if (!np)
return -ENODEV;
/* node should be a syscon */
regmap = syscon_node_to_regmap(np);
of_node_put(np);
if (IS_ERR(regmap)) {
pr_err("%s: failed to get regmap\n", __func__);
return -ENODEV;
}
ret = regmap_read(regmap, AO_SEC_SOCINFO_OFFSET, &socinfo);
if (ret < 0)
return ret;
if (!socinfo) {
pr_err("%s: invalid chipid value\n", __func__);
return -EINVAL;
}
cpu_version[MESON_CPU_VERSION_LVL_MAJOR] = (socinfo >> 24) & 0xff;
cpu_version[MESON_CPU_VERSION_LVL_MINOR] = (socinfo >> 8) & 0xff;
cpu_version[MESON_CPU_VERSION_LVL_PACK] = (socinfo >> 16) & 0xff;
cpu_version[MESON_CPU_VERSION_LVL_MISC] = socinfo & 0xff;
pr_info("chip version = %X:%X - %X:%X\n",
cpu_version[MESON_CPU_VERSION_LVL_MAJOR],
cpu_version[MESON_CPU_VERSION_LVL_MINOR],
cpu_version[MESON_CPU_VERSION_LVL_PACK],
cpu_version[MESON_CPU_VERSION_LVL_MISC]
);
init_done = 1;
return 0;
}
@@ -80,7 +80,6 @@ struct codecio_device_data_s {
enum meson_cpuid_type_e cpu_id;
};
int meson_cpu_version_init(void);
int get_cpu_type_from_media(void);
unsigned char get_meson_cpu_version(int level);