]> git.sur5r.net Git - u-boot/blob - include/cpu.h
spi: zynqmp_gqspi: Add support for ZynqMP qspi driver
[u-boot] / include / cpu.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2015 Google, Inc
4  * Written by Simon Glass <sjg@chromium.org>
5  */
6
7 #ifndef __CPU_H
8 #define __CPU_H
9
10 /**
11  * struct cpu_platdata - platform data for a CPU
12  *
13  * This can be accessed with dev_get_parent_platdata() for any UCLASS_CPU
14  * device.
15  *
16  * @cpu_id:     Platform-specific way of identifying the CPU.
17  * @ucode_version: Microcode version, if CPU_FEAT_UCODE is set
18  */
19 struct cpu_platdata {
20         int cpu_id;
21         int ucode_version;
22         ulong device_id;
23         u16 family;             /* DMTF CPU Family */
24         u32 id[2];              /* DMTF CPU Processor IDs */
25 };
26
27 /* CPU features - mostly just a placeholder for now */
28 enum {
29         CPU_FEAT_L1_CACHE       = 0,    /* Supports level 1 cache */
30         CPU_FEAT_MMU            = 1,    /* Supports virtual memory */
31         CPU_FEAT_UCODE          = 2,    /* Requires/uses microcode */
32         CPU_FEAT_DEVICE_ID      = 3,    /* Provides a device ID */
33
34         CPU_FEAT_COUNT,
35 };
36
37 /**
38  * struct cpu_info - Information about a CPU
39  *
40  * @cpu_freq:   Current CPU frequency in Hz
41  * @features:   Flags for supported CPU features
42  */
43 struct cpu_info {
44         ulong cpu_freq;
45         ulong features;
46 };
47
48 struct cpu_ops {
49         /**
50          * get_desc() - Get a description string for a CPU
51          *
52          * @dev:        Device to check (UCLASS_CPU)
53          * @buf:        Buffer to place string
54          * @size:       Size of string space
55          * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
56          */
57         int (*get_desc)(struct udevice *dev, char *buf, int size);
58
59         /**
60          * get_info() - Get information about a CPU
61          *
62          * @dev:        Device to check (UCLASS_CPU)
63          * @info:       Returns CPU info
64          * @return 0 if OK, -ve on error
65          */
66         int (*get_info)(struct udevice *dev, struct cpu_info *info);
67
68         /**
69          * get_count() - Get number of CPUs
70          *
71          * @dev:        Device to check (UCLASS_CPU)
72          * @return CPU count if OK, -ve on error
73          */
74         int (*get_count)(struct udevice *dev);
75
76         /**
77          * get_vendor() - Get vendor name of a CPU
78          *
79          * @dev:        Device to check (UCLASS_CPU)
80          * @buf:        Buffer to place string
81          * @size:       Size of string space
82          * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
83          */
84         int (*get_vendor)(struct udevice *dev, char *buf, int size);
85 };
86
87 #define cpu_get_ops(dev)        ((struct cpu_ops *)(dev)->driver->ops)
88
89 /**
90  * cpu_get_desc() - Get a description string for a CPU
91  *
92  * @dev:        Device to check (UCLASS_CPU)
93  * @buf:        Buffer to place string
94  * @size:       Size of string space
95  * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
96  */
97 int cpu_get_desc(struct udevice *dev, char *buf, int size);
98
99 /**
100  * cpu_get_info() - Get information about a CPU
101  *
102  * @dev:        Device to check (UCLASS_CPU)
103  * @info:       Returns CPU info
104  * @return 0 if OK, -ve on error
105  */
106 int cpu_get_info(struct udevice *dev, struct cpu_info *info);
107
108 /**
109  * cpu_get_count() - Get number of CPUs
110  *
111  * @dev:        Device to check (UCLASS_CPU)
112  * @return CPU count if OK, -ve on error
113  */
114 int cpu_get_count(struct udevice *dev);
115
116 /**
117  * cpu_get_vendor() - Get vendor name of a CPU
118  *
119  * @dev:        Device to check (UCLASS_CPU)
120  * @buf:        Buffer to place string
121  * @size:       Size of string space
122  * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
123  */
124 int cpu_get_vendor(struct udevice *dev, char *buf, int size);
125
126 #endif