Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Hou Zhiqiang | a1124da | 2024-08-01 11:59:50 +0800 | [diff] [blame] | 3 | * Copyright 2019, 2024 NXP |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 6 | #include <cpu.h> |
| 7 | #include <dm.h> |
| 8 | #include <thermal.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Hou Zhiqiang | 863a154 | 2024-08-01 11:59:54 +0800 | [diff] [blame] | 10 | #include <asm/ptrace.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 11 | #include <asm/system.h> |
Peng Fan | 2e0644a | 2023-04-28 12:08:09 +0800 | [diff] [blame] | 12 | #include <firmware/imx/sci/sci.h> |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 13 | #include <asm/arch/sys_proto.h> |
| 14 | #include <asm/arch-imx/cpu.h> |
| 15 | #include <asm/armv8/cpu.h> |
Peng Fan | 81c694a | 2023-04-28 12:08:14 +0800 | [diff] [blame] | 16 | #include <imx_thermal.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 17 | #include <linux/bitops.h> |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 18 | #include <linux/clk-provider.h> |
Hou Zhiqiang | 863a154 | 2024-08-01 11:59:54 +0800 | [diff] [blame] | 19 | #include <linux/psci.h> |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 23 | struct cpu_imx_plat { |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 24 | const char *name; |
| 25 | const char *rev; |
| 26 | const char *type; |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 27 | u32 cpu_rsrc; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 28 | u32 cpurev; |
| 29 | u32 freq_mhz; |
Peng Fan | e2ded33 | 2020-05-03 21:58:52 +0800 | [diff] [blame] | 30 | u32 mpidr; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 33 | static const char *get_imx_type_str(u32 imxtype) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 34 | { |
| 35 | switch (imxtype) { |
Hou Zhiqiang | 78ff9db | 2024-08-01 11:59:53 +0800 | [diff] [blame] | 36 | case MXC_CPU_IMX8MM: |
| 37 | return "8MM"; |
| 38 | case MXC_CPU_IMX8MN: |
| 39 | return "8MN"; |
| 40 | case MXC_CPU_IMX8MP: |
| 41 | return "8MP"; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 42 | case MXC_CPU_IMX8QXP: |
| 43 | case MXC_CPU_IMX8QXP_A0: |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 44 | return "8QXP"; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 45 | case MXC_CPU_IMX8QM: |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 46 | return "8QM"; |
| 47 | case MXC_CPU_IMX93: |
| 48 | return "93(52)";/* iMX93 Dual core with NPU */ |
Peng Fan | c3db3ad | 2023-04-28 12:08:32 +0800 | [diff] [blame] | 49 | case MXC_CPU_IMX9351: |
| 50 | return "93(51)";/* iMX93 Single core with NPU */ |
| 51 | case MXC_CPU_IMX9332: |
| 52 | return "93(32)";/* iMX93 Dual core without NPU */ |
| 53 | case MXC_CPU_IMX9331: |
| 54 | return "93(31)";/* iMX93 Single core without NPU */ |
| 55 | case MXC_CPU_IMX9322: |
| 56 | return "93(22)";/* iMX93 9x9 Dual core */ |
| 57 | case MXC_CPU_IMX9321: |
| 58 | return "93(21)";/* iMX93 9x9 Single core */ |
| 59 | case MXC_CPU_IMX9312: |
| 60 | return "93(12)";/* iMX93 9x9 Dual core without NPU */ |
| 61 | case MXC_CPU_IMX9311: |
| 62 | return "93(11)";/* iMX93 9x9 Single core without NPU */ |
Ye Li | 57b2ac4 | 2024-09-19 12:01:33 +0800 | [diff] [blame] | 63 | case MXC_CPU_IMX9302: |
| 64 | return "93(02)";/* iMX93 900Mhz Low performance Dual core without NPU */ |
| 65 | case MXC_CPU_IMX9301: |
| 66 | return "93(01)";/* iMX93 900Mhz Low performance Single core without NPU */ |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 67 | default: |
| 68 | return "??"; |
| 69 | } |
| 70 | } |
| 71 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 72 | static const char *get_imx_rev_str(u32 rev) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 73 | { |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 74 | static char revision[4]; |
| 75 | |
| 76 | if (IS_ENABLED(CONFIG_IMX8)) { |
| 77 | switch (rev) { |
| 78 | case CHIP_REV_A: |
| 79 | return "A"; |
| 80 | case CHIP_REV_B: |
| 81 | return "B"; |
| 82 | case CHIP_REV_C: |
| 83 | return "C"; |
| 84 | default: |
| 85 | return "?"; |
| 86 | } |
| 87 | } else { |
| 88 | revision[0] = '1' + (((rev & 0xf0) - CHIP_REV_1_0) >> 4); |
| 89 | revision[1] = '.'; |
| 90 | revision[2] = '0' + (rev & 0xf); |
| 91 | revision[3] = '\0'; |
| 92 | |
| 93 | return revision; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 97 | static void set_core_data(struct udevice *dev) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 98 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 99 | struct cpu_imx_plat *plat = dev_get_plat(dev); |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 100 | |
| 101 | if (device_is_compatible(dev, "arm,cortex-a35")) { |
| 102 | plat->cpu_rsrc = SC_R_A35; |
| 103 | plat->name = "A35"; |
| 104 | } else if (device_is_compatible(dev, "arm,cortex-a53")) { |
| 105 | plat->cpu_rsrc = SC_R_A53; |
| 106 | plat->name = "A53"; |
| 107 | } else if (device_is_compatible(dev, "arm,cortex-a72")) { |
| 108 | plat->cpu_rsrc = SC_R_A72; |
| 109 | plat->name = "A72"; |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 110 | } else if (device_is_compatible(dev, "arm,cortex-a55")) { |
| 111 | plat->name = "A55"; |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 112 | } else { |
| 113 | plat->cpu_rsrc = SC_R_A53; |
| 114 | plat->name = "?"; |
| 115 | } |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Peng Fan | 32eaf67 | 2023-04-28 12:08:13 +0800 | [diff] [blame] | 118 | #if IS_ENABLED(CONFIG_DM_THERMAL) |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 119 | static int cpu_imx_get_temp(struct cpu_imx_plat *plat) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 120 | { |
| 121 | struct udevice *thermal_dev; |
| 122 | int cpu_tmp, ret; |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 123 | int idx = 1; /* use "cpu-thermal0" device */ |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 124 | |
Peng Fan | 32eaf67 | 2023-04-28 12:08:13 +0800 | [diff] [blame] | 125 | if (IS_ENABLED(CONFIG_IMX8)) { |
| 126 | if (plat->cpu_rsrc == SC_R_A72) |
| 127 | idx = 2; /* use "cpu-thermal1" device */ |
| 128 | } else { |
| 129 | idx = 1; |
| 130 | } |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 131 | |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 132 | ret = uclass_get_device(UCLASS_THERMAL, idx, &thermal_dev); |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 133 | if (!ret) { |
| 134 | ret = thermal_get_temp(thermal_dev, &cpu_tmp); |
| 135 | if (ret) |
| 136 | return 0xdeadbeef; |
| 137 | } else { |
| 138 | return 0xdeadbeef; |
| 139 | } |
| 140 | |
| 141 | return cpu_tmp; |
| 142 | } |
| 143 | #else |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 144 | static int cpu_imx_get_temp(struct cpu_imx_plat *plat) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 145 | { |
| 146 | return 0; |
| 147 | } |
| 148 | #endif |
| 149 | |
Peng Fan | 81c694a | 2023-04-28 12:08:14 +0800 | [diff] [blame] | 150 | __weak u32 get_cpu_temp_grade(int *minc, int *maxc) |
| 151 | { |
| 152 | return 0; |
| 153 | } |
| 154 | |
Peng Fan | d3ee4de | 2023-04-28 12:08:11 +0800 | [diff] [blame] | 155 | static int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 156 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 157 | struct cpu_imx_plat *plat = dev_get_plat(dev); |
Peng Fan | 81c694a | 2023-04-28 12:08:14 +0800 | [diff] [blame] | 158 | const char *grade; |
Ye Li | cd8d1c5 | 2020-05-03 21:58:54 +0800 | [diff] [blame] | 159 | int ret, temp; |
Peng Fan | 81c694a | 2023-04-28 12:08:14 +0800 | [diff] [blame] | 160 | int minc, maxc; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 161 | |
| 162 | if (size < 100) |
| 163 | return -ENOSPC; |
| 164 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 165 | ret = snprintf(buf, size, "NXP i.MX%s Rev%s %s at %u MHz", |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 166 | plat->type, plat->rev, plat->name, plat->freq_mhz); |
| 167 | |
Peng Fan | 81c694a | 2023-04-28 12:08:14 +0800 | [diff] [blame] | 168 | if (IS_ENABLED(CONFIG_IMX9)) { |
| 169 | switch (get_cpu_temp_grade(&minc, &maxc)) { |
| 170 | case TEMP_AUTOMOTIVE: |
| 171 | grade = "Automotive temperature grade "; |
| 172 | break; |
| 173 | case TEMP_INDUSTRIAL: |
| 174 | grade = "Industrial temperature grade "; |
| 175 | break; |
| 176 | case TEMP_EXTCOMMERCIAL: |
| 177 | grade = "Extended Consumer temperature grade "; |
| 178 | break; |
| 179 | default: |
| 180 | grade = "Consumer temperature grade "; |
| 181 | break; |
| 182 | } |
| 183 | |
| 184 | buf = buf + ret; |
| 185 | size = size - ret; |
| 186 | ret = snprintf(buf, size, "\nCPU: %s (%dC to %dC)", grade, minc, maxc); |
| 187 | } |
| 188 | |
Peng Fan | 32eaf67 | 2023-04-28 12:08:13 +0800 | [diff] [blame] | 189 | if (IS_ENABLED(CONFIG_DM_THERMAL)) { |
Ye Li | cd8d1c5 | 2020-05-03 21:58:54 +0800 | [diff] [blame] | 190 | temp = cpu_imx_get_temp(plat); |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 191 | buf = buf + ret; |
| 192 | size = size - ret; |
Ye Li | cd8d1c5 | 2020-05-03 21:58:54 +0800 | [diff] [blame] | 193 | if (temp != 0xdeadbeef) |
| 194 | ret = snprintf(buf, size, " at %dC", temp); |
| 195 | else |
| 196 | ret = snprintf(buf, size, " - invalid sensor data"); |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 199 | return 0; |
| 200 | } |
| 201 | |
Simon Glass | 791fa45 | 2020-01-26 22:06:27 -0700 | [diff] [blame] | 202 | static int cpu_imx_get_info(const struct udevice *dev, struct cpu_info *info) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 203 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 204 | struct cpu_imx_plat *plat = dev_get_plat(dev); |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 205 | |
Hou Zhiqiang | a1124da | 2024-08-01 11:59:50 +0800 | [diff] [blame] | 206 | info->cpu_freq = plat->freq_mhz * 1000000; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 207 | info->features = BIT(CPU_FEAT_L1_CACHE) | BIT(CPU_FEAT_MMU); |
| 208 | return 0; |
| 209 | } |
| 210 | |
Simon Glass | 791fa45 | 2020-01-26 22:06:27 -0700 | [diff] [blame] | 211 | static int cpu_imx_get_count(const struct udevice *dev) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 212 | { |
Peng Fan | 8296b74 | 2020-05-03 21:58:51 +0800 | [diff] [blame] | 213 | ofnode node; |
| 214 | int num = 0; |
| 215 | |
| 216 | ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) { |
| 217 | const char *device_type; |
| 218 | |
Simon Glass | 2e4938b | 2022-09-06 20:27:17 -0600 | [diff] [blame] | 219 | if (!ofnode_is_enabled(node)) |
Peng Fan | 8296b74 | 2020-05-03 21:58:51 +0800 | [diff] [blame] | 220 | continue; |
| 221 | |
| 222 | device_type = ofnode_read_string(node, "device_type"); |
| 223 | if (!device_type) |
| 224 | continue; |
| 225 | |
| 226 | if (!strcmp(device_type, "cpu")) |
| 227 | num++; |
| 228 | } |
| 229 | |
| 230 | return num; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 231 | } |
| 232 | |
Simon Glass | 791fa45 | 2020-01-26 22:06:27 -0700 | [diff] [blame] | 233 | static int cpu_imx_get_vendor(const struct udevice *dev, char *buf, int size) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 234 | { |
| 235 | snprintf(buf, size, "NXP"); |
| 236 | return 0; |
| 237 | } |
| 238 | |
Peng Fan | e2ded33 | 2020-05-03 21:58:52 +0800 | [diff] [blame] | 239 | static int cpu_imx_is_current(struct udevice *dev) |
| 240 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 241 | struct cpu_imx_plat *plat = dev_get_plat(dev); |
Peng Fan | e2ded33 | 2020-05-03 21:58:52 +0800 | [diff] [blame] | 242 | |
| 243 | if (plat->mpidr == (read_mpidr() & 0xffff)) |
| 244 | return 1; |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
Hou Zhiqiang | 863a154 | 2024-08-01 11:59:54 +0800 | [diff] [blame] | 249 | static int cpu_imx_release_core(const struct udevice *dev, phys_addr_t addr) |
| 250 | { |
| 251 | struct cpu_imx_plat *plat = dev_get_plat(dev); |
| 252 | struct pt_regs regs; |
| 253 | |
| 254 | regs.regs[0] = PSCI_0_2_FN64_CPU_ON; |
| 255 | regs.regs[1] = plat->mpidr; |
| 256 | regs.regs[2] = addr; |
| 257 | regs.regs[3] = 0; |
| 258 | |
| 259 | smc_call(®s); |
| 260 | if (regs.regs[0]) { |
| 261 | printf("Failed to release CPU core (mpidr: 0x%x)\n", plat->mpidr); |
| 262 | return -1; |
| 263 | } |
| 264 | |
| 265 | printf("Released CPU core (mpidr: 0x%x) to address 0x%llx\n", plat->mpidr, addr); |
| 266 | |
| 267 | return 0; |
| 268 | } |
| 269 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 270 | static const struct cpu_ops cpu_imx_ops = { |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 271 | .get_desc = cpu_imx_get_desc, |
| 272 | .get_info = cpu_imx_get_info, |
| 273 | .get_count = cpu_imx_get_count, |
| 274 | .get_vendor = cpu_imx_get_vendor, |
Peng Fan | e2ded33 | 2020-05-03 21:58:52 +0800 | [diff] [blame] | 275 | .is_current = cpu_imx_is_current, |
Hou Zhiqiang | 863a154 | 2024-08-01 11:59:54 +0800 | [diff] [blame] | 276 | .release_core = cpu_imx_release_core, |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 277 | }; |
| 278 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 279 | static const struct udevice_id cpu_imx_ids[] = { |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 280 | { .compatible = "arm,cortex-a35" }, |
| 281 | { .compatible = "arm,cortex-a53" }, |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 282 | { .compatible = "arm,cortex-a55" }, |
Peng Fan | e2ded33 | 2020-05-03 21:58:52 +0800 | [diff] [blame] | 283 | { .compatible = "arm,cortex-a72" }, |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 284 | { } |
| 285 | }; |
| 286 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 287 | static ulong imx_get_cpu_rate(struct udevice *dev) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 288 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 289 | struct cpu_imx_plat *plat = dev_get_plat(dev); |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 290 | struct clk clk; |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 291 | ulong rate; |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 292 | int ret; |
Peng Fan | 4b1fbb7 | 2020-05-03 21:58:53 +0800 | [diff] [blame] | 293 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 294 | if (IS_ENABLED(CONFIG_IMX8)) { |
| 295 | ret = sc_pm_get_clock_rate(-1, plat->cpu_rsrc, SC_PM_CLK_CPU, |
| 296 | (sc_pm_clock_rate_t *)&rate); |
| 297 | } else { |
| 298 | ret = clk_get_by_index(dev, 0, &clk); |
| 299 | if (!ret) { |
| 300 | rate = clk_get_rate(&clk); |
| 301 | if (!rate) |
| 302 | ret = -EOPNOTSUPP; |
| 303 | } |
| 304 | } |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 305 | if (ret) { |
| 306 | printf("Could not read CPU frequency: %d\n", ret); |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | return rate; |
| 311 | } |
| 312 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 313 | static int imx_cpu_probe(struct udevice *dev) |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 314 | { |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 315 | struct cpu_imx_plat *plat = dev_get_plat(dev); |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 316 | u32 cpurev; |
| 317 | |
Anatolij Gustschin | 50ca4a0 | 2020-05-20 01:31:44 +0200 | [diff] [blame] | 318 | set_core_data(dev); |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 319 | cpurev = get_cpu_rev(); |
| 320 | plat->cpurev = cpurev; |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 321 | plat->rev = get_imx_rev_str(cpurev & 0xFFF); |
Hou Zhiqiang | c5e1a11 | 2024-08-01 11:59:51 +0800 | [diff] [blame] | 322 | plat->type = get_imx_type_str((cpurev & 0x1FF000) >> 12); |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 323 | plat->freq_mhz = imx_get_cpu_rate(dev) / 1000000; |
Peng Fan | e2ded33 | 2020-05-03 21:58:52 +0800 | [diff] [blame] | 324 | plat->mpidr = dev_read_addr(dev); |
| 325 | if (plat->mpidr == FDT_ADDR_T_NONE) { |
| 326 | printf("%s: Failed to get CPU reg property\n", __func__); |
| 327 | return -EINVAL; |
| 328 | } |
| 329 | |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 330 | return 0; |
| 331 | } |
| 332 | |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 333 | U_BOOT_DRIVER(cpu_imx_drv) = { |
| 334 | .name = "imx_cpu", |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 335 | .id = UCLASS_CPU, |
Peng Fan | 146cce9 | 2023-04-28 12:08:12 +0800 | [diff] [blame] | 336 | .of_match = cpu_imx_ids, |
| 337 | .ops = &cpu_imx_ops, |
| 338 | .probe = imx_cpu_probe, |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 339 | .plat_auto = sizeof(struct cpu_imx_plat), |
Peng Fan | 21981d2 | 2019-08-26 08:12:19 +0000 | [diff] [blame] | 340 | .flags = DM_FLAG_PRE_RELOC, |
| 341 | }; |