]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/cpu.h
Merge branch 'master' of git://git.denx.de/u-boot-i2c
[thirdparty/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 <sjg@chromium.org>
11f4dc15
SG
5 */
6
7#ifndef __CPU_H
8#define __CPU_H
9
10/**
11 * struct cpu_platdata - platform data for a CPU
50d188b9
MS
12 * @cpu_id: Platform-specific way of identifying the CPU.
13 * @ucode_version: Microcode version, if CPU_FEAT_UCODE is set
14 * @device_id: Driver-defined device identifier
15 * @family: DMTF CPU Family identifier
16 * @id: DMTF CPU Processor identifier
11f4dc15
SG
17 *
18 * This can be accessed with dev_get_parent_platdata() for any UCLASS_CPU
19 * device.
11f4dc15
SG
20 */
21struct cpu_platdata {
22 int cpu_id;
740d5d34
SG
23 int ucode_version;
24 ulong device_id;
50d188b9
MS
25 u16 family;
26 u32 id[2];
11f4dc15
SG
27};
28
29/* CPU features - mostly just a placeholder for now */
30enum {
31 CPU_FEAT_L1_CACHE = 0, /* Supports level 1 cache */
32 CPU_FEAT_MMU = 1, /* Supports virtual memory */
740d5d34
SG
33 CPU_FEAT_UCODE = 2, /* Requires/uses microcode */
34 CPU_FEAT_DEVICE_ID = 3, /* Provides a device ID */
11f4dc15
SG
35
36 CPU_FEAT_COUNT,
37};
38
39/**
40 * struct cpu_info - Information about a CPU
41 *
42 * @cpu_freq: Current CPU frequency in Hz
43 * @features: Flags for supported CPU features
44 */
45struct cpu_info {
46 ulong cpu_freq;
47 ulong features;
48};
49
50struct cpu_ops {
51 /**
52 * get_desc() - Get a description string for a CPU
53 *
54 * @dev: Device to check (UCLASS_CPU)
55 * @buf: Buffer to place string
56 * @size: Size of string space
57 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
58 */
59 int (*get_desc)(struct udevice *dev, char *buf, int size);
60
61 /**
62 * get_info() - Get information about a CPU
63 *
64 * @dev: Device to check (UCLASS_CPU)
65 * @info: Returns CPU info
66 * @return 0 if OK, -ve on error
67 */
68 int (*get_info)(struct udevice *dev, struct cpu_info *info);
780bfdd3
BM
69
70 /**
71 * get_count() - Get number of CPUs
72 *
73 * @dev: Device to check (UCLASS_CPU)
74 * @return CPU count if OK, -ve on error
75 */
76 int (*get_count)(struct udevice *dev);
94eaa79c
AG
77
78 /**
79 * get_vendor() - Get vendor name of a CPU
80 *
81 * @dev: Device to check (UCLASS_CPU)
82 * @buf: Buffer to place string
83 * @size: Size of string space
84 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
85 */
86 int (*get_vendor)(struct udevice *dev, char *buf, int size);
11f4dc15
SG
87};
88
89#define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops)
90
91/**
92 * cpu_get_desc() - Get a description string for a CPU
11f4dc15
SG
93 * @dev: Device to check (UCLASS_CPU)
94 * @buf: Buffer to place string
95 * @size: Size of string space
50d188b9
MS
96 *
97 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
11f4dc15
SG
98 */
99int cpu_get_desc(struct udevice *dev, char *buf, int size);
100
101/**
102 * cpu_get_info() - Get information about a CPU
11f4dc15
SG
103 * @dev: Device to check (UCLASS_CPU)
104 * @info: Returns CPU info
50d188b9
MS
105 *
106 * Return: 0 if OK, -ve on error
11f4dc15
SG
107 */
108int cpu_get_info(struct udevice *dev, struct cpu_info *info);
109
780bfdd3
BM
110/**
111 * cpu_get_count() - Get number of CPUs
780bfdd3 112 * @dev: Device to check (UCLASS_CPU)
50d188b9
MS
113 *
114 * Return: CPU count if OK, -ve on error
780bfdd3
BM
115 */
116int cpu_get_count(struct udevice *dev);
117
94eaa79c
AG
118/**
119 * cpu_get_vendor() - Get vendor name of a CPU
94eaa79c
AG
120 * @dev: Device to check (UCLASS_CPU)
121 * @buf: Buffer to place string
122 * @size: Size of string space
50d188b9
MS
123 *
124 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
94eaa79c
AG
125 */
126int cpu_get_vendor(struct udevice *dev, char *buf, int size);
127
57370de3
MS
128/**
129 * cpu_probe_all() - Probe all available CPUs
130 *
131 * Return: 0 if OK, -ve on error
132 */
133int cpu_probe_all(void);
134
11f4dc15 135#endif