1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries
12 #include <linux/clk-provider.h>
14 struct at91_cpu_plat {
21 extern char *get_cpu_name(void);
23 const char *at91_cpu_get_name(void)
25 return get_cpu_name();
28 int at91_cpu_get_desc(const struct udevice *dev, char *buf, int size)
30 struct at91_cpu_plat *plat = dev_get_plat(dev);
32 snprintf(buf, size, "%s\n"
33 "Crystal frequency: %8lu MHz\n"
34 "CPU clock : %8lu MHz\n"
35 "Master clock : %8lu MHz\n",
36 plat->name, plat->xtalfreq_mhz, plat->cpufreq_mhz,
42 static int at91_cpu_get_info(const struct udevice *dev, struct cpu_info *info)
44 struct at91_cpu_plat *plat = dev_get_plat(dev);
46 info->cpu_freq = plat->cpufreq_mhz * 1000000;
47 info->features = BIT(CPU_FEAT_L1_CACHE);
52 static int at91_cpu_get_count(const struct udevice *dev)
57 static int at91_cpu_get_vendor(const struct udevice *dev, char *buf, int size)
59 snprintf(buf, size, "Microchip Technology Inc.");
64 static const struct cpu_ops at91_cpu_ops = {
65 .get_desc = at91_cpu_get_desc,
66 .get_info = at91_cpu_get_info,
67 .get_count = at91_cpu_get_count,
68 .get_vendor = at91_cpu_get_vendor,
71 static const struct udevice_id at91_cpu_ids[] = {
72 { .compatible = "arm,cortex-a7" },
76 static int at91_cpu_probe(struct udevice *dev)
78 struct at91_cpu_plat *plat = dev_get_plat(dev);
83 ret = clk_get_by_index(dev, 0, &clk);
87 rate = clk_get_rate(&clk);
90 plat->cpufreq_mhz = DIV_ROUND_CLOSEST_ULL(rate, 1000000);
92 ret = clk_get_by_index(dev, 1, &clk);
96 rate = clk_get_rate(&clk);
99 plat->mckfreq_mhz = DIV_ROUND_CLOSEST_ULL(rate, 1000000);
101 ret = clk_get_by_index(dev, 2, &clk);
105 rate = clk_get_rate(&clk);
108 plat->xtalfreq_mhz = DIV_ROUND_CLOSEST_ULL(rate, 1000000);
110 plat->name = get_cpu_name();
115 U_BOOT_DRIVER(cpu_at91_drv) = {
118 .of_match = at91_cpu_ids,
119 .ops = &at91_cpu_ops,
120 .probe = at91_cpu_probe,
121 .plat_auto = sizeof(struct at91_cpu_plat),
122 .flags = DM_FLAG_PRE_RELOC,