1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2022 MediaTek Inc. All rights reserved.
8 #include <linux/types.h>
13 #include <asm/global_data.h>
14 #include <linux/err.h>
17 DECLARE_GLOBAL_DATA_PTR;
23 static int mtk_cpu_get_desc(const struct udevice *dev, char *buf, int size)
25 struct mtk_cpu_plat *plat = dev_get_plat(dev);
28 regmap_read(plat->hwver, 0, &val);
30 snprintf(buf, size, "MediaTek MT%04X", val);
35 static int mtk_cpu_get_count(const struct udevice *dev)
40 static int mtk_cpu_get_vendor(const struct udevice *dev, char *buf, int size)
42 snprintf(buf, size, "MediaTek");
47 static int mtk_cpu_probe(struct udevice *dev)
49 struct mtk_cpu_plat *plat = dev_get_plat(dev);
50 struct ofnode_phandle_args args;
53 ret = dev_read_phandle_with_args(dev, "mediatek,hwver", NULL, 0, 0,
58 plat->hwver = syscon_node_to_regmap(args.node);
59 if (IS_ERR(plat->hwver))
60 return PTR_ERR(plat->hwver);
65 static const struct cpu_ops mtk_cpu_ops = {
66 .get_desc = mtk_cpu_get_desc,
67 .get_count = mtk_cpu_get_count,
68 .get_vendor = mtk_cpu_get_vendor,
71 static const struct udevice_id mtk_cpu_ids[] = {
72 { .compatible = "arm,cortex-a7" },
73 { .compatible = "arm,cortex-a53" },
74 { .compatible = "arm,cortex-a73" },
78 U_BOOT_DRIVER(cpu_mtk) = {
81 .of_match = mtk_cpu_ids,
83 .probe = mtk_cpu_probe,
84 .plat_auto = sizeof(struct mtk_cpu_plat),
85 .flags = DM_FLAG_PRE_RELOC,