Simon Glass | 131a645 | 2015-04-28 20:25:09 -0600 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 19 | struct cpu_platdata { |
| 20 | int cpu_id; |
| 21 | }; |
| 22 | |
| 23 | /* CPU features - mostly just a placeholder for now */ |
| 24 | enum { |
| 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 | */ |
| 37 | struct cpu_info { |
| 38 | ulong cpu_freq; |
| 39 | ulong features; |
| 40 | }; |
| 41 | |
| 42 | struct 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); |
| 61 | }; |
| 62 | |
| 63 | #define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops) |
| 64 | |
| 65 | /** |
| 66 | * cpu_get_desc() - Get a description string for a CPU |
| 67 | * |
| 68 | * @dev: Device to check (UCLASS_CPU) |
| 69 | * @buf: Buffer to place string |
| 70 | * @size: Size of string space |
| 71 | * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error |
| 72 | */ |
| 73 | int cpu_get_desc(struct udevice *dev, char *buf, int size); |
| 74 | |
| 75 | /** |
| 76 | * cpu_get_info() - Get information about a CPU |
| 77 | * |
| 78 | * @dev: Device to check (UCLASS_CPU) |
| 79 | * @info: Returns CPU info |
| 80 | * @return 0 if OK, -ve on error |
| 81 | */ |
| 82 | int cpu_get_info(struct udevice *dev, struct cpu_info *info); |
| 83 | |
| 84 | #endif |