blob: bfb0db2e2c6dd96c5c52fa65edeb3a1bb9cfeb49 [file] [log] [blame]
Simon Glass11f4dc12015-04-28 20:25:09 -06001/*
2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#ifndef __CPU_H
9#define __CPU_H
10
11/**
12 * struct cpu_platdata - platform data for a CPU
13 *
14 * This can be accessed with dev_get_parent_platdata() for any UCLASS_CPU
15 * device.
16 *
17 * @cpu_id: Platform-specific way of identifying the CPU.
18 */
19struct cpu_platdata {
20 int cpu_id;
21};
22
23/* CPU features - mostly just a placeholder for now */
24enum {
25 CPU_FEAT_L1_CACHE = 0, /* Supports level 1 cache */
26 CPU_FEAT_MMU = 1, /* Supports virtual memory */
27
28 CPU_FEAT_COUNT,
29};
30
31/**
32 * struct cpu_info - Information about a CPU
33 *
34 * @cpu_freq: Current CPU frequency in Hz
35 * @features: Flags for supported CPU features
36 */
37struct cpu_info {
38 ulong cpu_freq;
39 ulong features;
40};
41
42struct cpu_ops {
43 /**
44 * get_desc() - Get a description string for a CPU
45 *
46 * @dev: Device to check (UCLASS_CPU)
47 * @buf: Buffer to place string
48 * @size: Size of string space
49 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
50 */
51 int (*get_desc)(struct udevice *dev, char *buf, int size);
52
53 /**
54 * get_info() - Get information about a CPU
55 *
56 * @dev: Device to check (UCLASS_CPU)
57 * @info: Returns CPU info
58 * @return 0 if OK, -ve on error
59 */
60 int (*get_info)(struct udevice *dev, struct cpu_info *info);
Bin Meng780bfdd2015-06-17 11:15:34 +080061
62 /**
63 * get_count() - Get number of CPUs
64 *
65 * @dev: Device to check (UCLASS_CPU)
66 * @return CPU count if OK, -ve on error
67 */
68 int (*get_count)(struct udevice *dev);
Simon Glass11f4dc12015-04-28 20:25:09 -060069};
70
71#define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops)
72
73/**
74 * cpu_get_desc() - Get a description string for a CPU
75 *
76 * @dev: Device to check (UCLASS_CPU)
77 * @buf: Buffer to place string
78 * @size: Size of string space
79 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
80 */
81int cpu_get_desc(struct udevice *dev, char *buf, int size);
82
83/**
84 * cpu_get_info() - Get information about a CPU
85 *
86 * @dev: Device to check (UCLASS_CPU)
87 * @info: Returns CPU info
88 * @return 0 if OK, -ve on error
89 */
90int cpu_get_info(struct udevice *dev, struct cpu_info *info);
91
Bin Meng780bfdd2015-06-17 11:15:34 +080092/**
93 * cpu_get_count() - Get number of CPUs
94 *
95 * @dev: Device to check (UCLASS_CPU)
96 * @return CPU count if OK, -ve on error
97 */
98int cpu_get_count(struct udevice *dev);
99
Simon Glass11f4dc12015-04-28 20:25:09 -0600100#endif