]> Git Repo - J-u-boot.git/blame - include/cpu.h
include: Add <linux/types.h> in a few places
[J-u-boot.git] / include / cpu.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
11f4dc15
SG
2/*
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <[email protected]>
11f4dc15
SG
5 */
6
7#ifndef __CPU_H
8#define __CPU_H
9
12c00f9e
TR
10#include <linux/types.h>
11
401d1c4f
SG
12struct udevice;
13
11f4dc15 14/**
8a8d24bd 15 * struct cpu_plat - platform data for a CPU
50d188b9
MS
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
b8596947
BM
21 * @timebase_freq: the current frequency at which the cpu timer timebase
22 * registers are updated (in Hz)
11f4dc15 23 *
caa4daa2 24 * This can be accessed with dev_get_parent_plat() for any UCLASS_CPU
11f4dc15 25 * device.
11f4dc15 26 */
8a8d24bd 27struct cpu_plat {
11f4dc15 28 int cpu_id;
740d5d34
SG
29 int ucode_version;
30 ulong device_id;
50d188b9
MS
31 u16 family;
32 u32 id[2];
b8596947 33 u32 timebase_freq;
11f4dc15
SG
34};
35
36/* CPU features - mostly just a placeholder for now */
37enum {
38 CPU_FEAT_L1_CACHE = 0, /* Supports level 1 cache */
39 CPU_FEAT_MMU = 1, /* Supports virtual memory */
740d5d34
SG
40 CPU_FEAT_UCODE = 2, /* Requires/uses microcode */
41 CPU_FEAT_DEVICE_ID = 3, /* Provides a device ID */
11f4dc15
SG
42
43 CPU_FEAT_COUNT,
44};
45
46/**
47 * struct cpu_info - Information about a CPU
48 *
49 * @cpu_freq: Current CPU frequency in Hz
50 * @features: Flags for supported CPU features
600f584d 51 * @address_width: Width of the CPU address space in bits (e.g. 32)
11f4dc15
SG
52 */
53struct cpu_info {
54 ulong cpu_freq;
55 ulong features;
600f584d 56 uint address_width;
11f4dc15
SG
57};
58
59struct cpu_ops {
60 /**
61 * get_desc() - Get a description string for a CPU
62 *
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
67 */
961420fa 68 int (*get_desc)(const struct udevice *dev, char *buf, int size);
11f4dc15
SG
69
70 /**
71 * get_info() - Get information about a CPU
72 *
73 * @dev: Device to check (UCLASS_CPU)
74 * @info: Returns CPU info
75 * @return 0 if OK, -ve on error
76 */
961420fa 77 int (*get_info)(const struct udevice *dev, struct cpu_info *info);
780bfdd3
BM
78
79 /**
80 * get_count() - Get number of CPUs
81 *
82 * @dev: Device to check (UCLASS_CPU)
83 * @return CPU count if OK, -ve on error
84 */
961420fa 85 int (*get_count)(const struct udevice *dev);
94eaa79c
AG
86
87 /**
88 * get_vendor() - Get vendor name of a CPU
89 *
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
94 */
961420fa 95 int (*get_vendor)(const struct udevice *dev, char *buf, int size);
4c809aee
PF
96
97 /**
98 * is_current() - Check if the CPU that U-Boot is currently running from
99 *
100 * @dev: Device to check (UCLASS_CPU)
101 * @return 1 if the CPU that U-Boot is currently running from, 0
102 * if not.
103 */
104 int (*is_current)(struct udevice *dev);
11f4dc15
SG
105};
106
107#define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops)
108
109/**
110 * cpu_get_desc() - Get a description string for a CPU
11f4dc15
SG
111 * @dev: Device to check (UCLASS_CPU)
112 * @buf: Buffer to place string
113 * @size: Size of string space
50d188b9
MS
114 *
115 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
11f4dc15 116 */
961420fa 117int cpu_get_desc(const struct udevice *dev, char *buf, int size);
11f4dc15
SG
118
119/**
120 * cpu_get_info() - Get information about a CPU
11f4dc15
SG
121 * @dev: Device to check (UCLASS_CPU)
122 * @info: Returns CPU info
50d188b9
MS
123 *
124 * Return: 0 if OK, -ve on error
11f4dc15 125 */
961420fa 126int cpu_get_info(const struct udevice *dev, struct cpu_info *info);
11f4dc15 127
780bfdd3
BM
128/**
129 * cpu_get_count() - Get number of CPUs
780bfdd3 130 * @dev: Device to check (UCLASS_CPU)
50d188b9
MS
131 *
132 * Return: CPU count if OK, -ve on error
780bfdd3 133 */
961420fa 134int cpu_get_count(const struct udevice *dev);
780bfdd3 135
94eaa79c
AG
136/**
137 * cpu_get_vendor() - Get vendor name of a CPU
94eaa79c
AG
138 * @dev: Device to check (UCLASS_CPU)
139 * @buf: Buffer to place string
140 * @size: Size of string space
50d188b9
MS
141 *
142 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
94eaa79c 143 */
961420fa 144int cpu_get_vendor(const struct udevice *dev, char *buf, int size);
94eaa79c 145
57370de3
MS
146/**
147 * cpu_probe_all() - Probe all available CPUs
148 *
149 * Return: 0 if OK, -ve on error
150 */
151int cpu_probe_all(void);
152
4c809aee
PF
153/**
154 * cpu_is_current() - Check if the CPU that U-Boot is currently running from
155 *
156 * Return: 1 if yes, - 0 if not
157 */
158int cpu_is_current(struct udevice *cpu);
159
160/**
161 * cpu_get_current_dev() - Get CPU udevice for current CPU
162 *
163 * Return: udevice if OK, - NULL on error
164 */
165struct udevice *cpu_get_current_dev(void);
166
11f4dc15 167#endif
This page took 0.462682 seconds and 4 git commands to generate.