嵌入式爱好者

imx6x无法查看cpuid

2024-9-27 10:45| 发布者: 十七十七| 查看: 74| 评论: 0

类目: 知识库  >  I.MX6系列产品     文档编号: 1531

1.用cat /proc/cpuinfo看cpuid是0000000000000000,是因为内核驱动没有加读cpuid的代码
2.kernel_imx/arch/arm/kernel/setup.c,添加下方补丁
--- a/kernel_imx/arch/arm/kernel/setup.c
+++ b/kernel_imx/arch/arm/kernel/setup.c
@@ -57,6 +57,11 @@
 #include <asm/unwind.h>
 #include <asm/memblock.h>
 #include <asm/virt.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/regmap.h>
+#include <asm/mach/map.h>
+#include <asm/io.h>
 
 #include "atags.h"
 
@@ -837,10 +842,34 @@ static int __init customize_machine(void)
 }
 arch_initcall(customize_machine);
 
+#define OCOTP_CFG0  0x410
+#define OCOTP_CFG1  0x420
+
 static int __init init_machine_late(void)
 {
+ struct device_node *np;
+ void __iomem *base;
+
  if (machine_desc->init_late)
  machine_desc->init_late();
+
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp");
+ if (!np) {
+ pr_warn("failed to find ocotp node\n");
+ return -ENODEV;
+ }
+
+ base = of_iomap(np, 0);
+ if (!base) {
+ pr_warn("failed to map ocotp\n");
+ goto put_node;
+ }
+
+ system_serial_low =  readl_relaxed(base + OCOTP_CFG0);
+ system_serial_high =  readl_relaxed(base + OCOTP_CFG1);
+put_node:
+ of_node_put(np);
+
  return 0;
 }
 late_initcall(init_machine_late);
-- 
2.17.1


已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2025-7-1 15:28

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部