cpu.h 3.1 KB

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