cpu.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. *
  11. * This can be accessed with dev_get_parent_platdata() for any UCLASS_CPU
  12. * device.
  13. *
  14. * @cpu_id: Platform-specific way of identifying the CPU.
  15. * @ucode_version: Microcode version, if CPU_FEAT_UCODE is set
  16. */
  17. struct cpu_platdata {
  18. int cpu_id;
  19. int ucode_version;
  20. ulong device_id;
  21. u16 family; /* DMTF CPU Family */
  22. u32 id[2]; /* DMTF CPU Processor IDs */
  23. };
  24. /* CPU features - mostly just a placeholder for now */
  25. enum {
  26. CPU_FEAT_L1_CACHE = 0, /* Supports level 1 cache */
  27. CPU_FEAT_MMU = 1, /* Supports virtual memory */
  28. CPU_FEAT_UCODE = 2, /* Requires/uses microcode */
  29. CPU_FEAT_DEVICE_ID = 3, /* Provides a device ID */
  30. CPU_FEAT_COUNT,
  31. };
  32. /**
  33. * struct cpu_info - Information about a CPU
  34. *
  35. * @cpu_freq: Current CPU frequency in Hz
  36. * @features: Flags for supported CPU features
  37. */
  38. struct cpu_info {
  39. ulong cpu_freq;
  40. ulong features;
  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. * get_info() - Get information about a CPU
  54. *
  55. * @dev: Device to check (UCLASS_CPU)
  56. * @info: Returns CPU info
  57. * @return 0 if OK, -ve on error
  58. */
  59. int (*get_info)(struct udevice *dev, struct cpu_info *info);
  60. /**
  61. * get_count() - Get number of CPUs
  62. *
  63. * @dev: Device to check (UCLASS_CPU)
  64. * @return CPU count if OK, -ve on error
  65. */
  66. int (*get_count)(struct udevice *dev);
  67. /**
  68. * get_vendor() - Get vendor name of a CPU
  69. *
  70. * @dev: Device to check (UCLASS_CPU)
  71. * @buf: Buffer to place string
  72. * @size: Size of string space
  73. * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
  74. */
  75. int (*get_vendor)(struct udevice *dev, char *buf, int size);
  76. };
  77. #define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops)
  78. /**
  79. * cpu_get_desc() - Get a description string for 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 cpu_get_desc(struct udevice *dev, char *buf, int size);
  87. /**
  88. * cpu_get_info() - Get information about a CPU
  89. *
  90. * @dev: Device to check (UCLASS_CPU)
  91. * @info: Returns CPU info
  92. * @return 0 if OK, -ve on error
  93. */
  94. int cpu_get_info(struct udevice *dev, struct cpu_info *info);
  95. /**
  96. * cpu_get_count() - Get number of CPUs
  97. *
  98. * @dev: Device to check (UCLASS_CPU)
  99. * @return CPU count if OK, -ve on error
  100. */
  101. int cpu_get_count(struct udevice *dev);
  102. /**
  103. * cpu_get_vendor() - Get vendor name of a CPU
  104. *
  105. * @dev: Device to check (UCLASS_CPU)
  106. * @buf: Buffer to place string
  107. * @size: Size of string space
  108. * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
  109. */
  110. int cpu_get_vendor(struct udevice *dev, char *buf, int size);
  111. #endif