cpu.h 3.4 KB

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