1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
10 #include <linux/types.h>
15 * struct cpu_plat - platform data for a CPU
16 * @cpu_id: Platform-specific way of identifying the CPU.
17 * @ucode_version: Microcode version, if CPU_FEAT_UCODE is set
18 * @device_id: Driver-defined device identifier
19 * @family: DMTF CPU Family identifier
20 * @id: DMTF CPU Processor identifier
21 * @timebase_freq: the current frequency at which the cpu timer timebase
22 * registers are updated (in Hz)
24 * This can be accessed with dev_get_parent_plat() for any UCLASS_CPU
36 /* CPU features - mostly just a placeholder for now */
38 CPU_FEAT_L1_CACHE = 0, /* Supports level 1 cache */
39 CPU_FEAT_MMU = 1, /* Supports virtual memory */
40 CPU_FEAT_UCODE = 2, /* Requires/uses microcode */
41 CPU_FEAT_DEVICE_ID = 3, /* Provides a device ID */
47 * struct cpu_info - Information about a CPU
49 * @cpu_freq: Current CPU frequency in Hz
50 * @features: Flags for supported CPU features
51 * @address_width: Width of the CPU address space in bits (e.g. 32)
61 * get_desc() - Get a description string for a CPU
63 * @dev: Device to check (UCLASS_CPU)
64 * @buf: Buffer to place string
65 * @size: Size of string space
66 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
68 int (*get_desc)(const struct udevice *dev, char *buf, int size);
71 * get_info() - Get information about a CPU
73 * @dev: Device to check (UCLASS_CPU)
74 * @info: Returns CPU info
75 * @return 0 if OK, -ve on error
77 int (*get_info)(const struct udevice *dev, struct cpu_info *info);
80 * get_count() - Get number of CPUs
82 * @dev: Device to check (UCLASS_CPU)
83 * @return CPU count if OK, -ve on error
85 int (*get_count)(const struct udevice *dev);
88 * get_vendor() - Get vendor name of a CPU
90 * @dev: Device to check (UCLASS_CPU)
91 * @buf: Buffer to place string
92 * @size: Size of string space
93 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
95 int (*get_vendor)(const struct udevice *dev, char *buf, int size);
98 * is_current() - Check if the CPU that U-Boot is currently running from
100 * @dev: Device to check (UCLASS_CPU)
101 * @return 1 if the CPU that U-Boot is currently running from, 0
104 int (*is_current)(struct udevice *dev);
107 * release_core() - Relase a CPU core to the given address to run application
109 * @dev: Device to check (UCLASS_CPU)
110 * @addr: Address to relese the CPU core
111 * @return 0 if OK, -ve on error
113 int (*release_core)(const struct udevice *dev, phys_addr_t addr);
116 #define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops)
119 * cpu_get_desc() - Get a description string for a CPU
120 * @dev: Device to check (UCLASS_CPU)
121 * @buf: Buffer to place string
122 * @size: Size of string space
124 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
126 int cpu_get_desc(const struct udevice *dev, char *buf, int size);
129 * cpu_get_info() - Get information about a CPU
130 * @dev: Device to check (UCLASS_CPU)
131 * @info: Returns CPU info
133 * Return: 0 if OK, -ve on error
135 int cpu_get_info(const struct udevice *dev, struct cpu_info *info);
138 * cpu_get_count() - Get number of CPUs
139 * @dev: Device to check (UCLASS_CPU)
141 * Return: CPU count if OK, -ve on error
143 int cpu_get_count(const struct udevice *dev);
146 * cpu_get_vendor() - Get vendor name of a CPU
147 * @dev: Device to check (UCLASS_CPU)
148 * @buf: Buffer to place string
149 * @size: Size of string space
151 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
153 int cpu_get_vendor(const struct udevice *dev, char *buf, int size);
156 * cpu_probe_all() - Probe all available CPUs
158 * Return: 0 if OK, -ve on error
160 int cpu_probe_all(void);
163 * cpu_is_current() - Check if the CPU that U-Boot is currently running from
165 * Return: 1 if yes, - 0 if not
167 int cpu_is_current(struct udevice *cpu);
170 * cpu_get_current_dev() - Get CPU udevice for current CPU
172 * Return: udevice if OK, - NULL on error
174 struct udevice *cpu_get_current_dev(void);
177 * cpu_release_core() - Relase a CPU core to the given address to run application
179 * @return 0 if OK, -ve on error
181 int cpu_release_core(const struct udevice *dev, phys_addr_t addr);