cpu.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. */
  17. struct cpu_platdata {
  18. int cpu_id;
  19. };
  20. /* CPU features - mostly just a placeholder for now */
  21. enum {
  22. CPU_FEAT_L1_CACHE = 0, /* Supports level 1 cache */
  23. CPU_FEAT_MMU = 1, /* Supports virtual memory */
  24. CPU_FEAT_COUNT,
  25. };
  26. /**
  27. * struct cpu_info - Information about a CPU
  28. *
  29. * @cpu_freq: Current CPU frequency in Hz
  30. * @features: Flags for supported CPU features
  31. */
  32. struct cpu_info {
  33. ulong cpu_freq;
  34. ulong features;
  35. };
  36. struct cpu_ops {
  37. /**
  38. * get_desc() - Get a description string for a CPU
  39. *
  40. * @dev: Device to check (UCLASS_CPU)
  41. * @buf: Buffer to place string
  42. * @size: Size of string space
  43. * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
  44. */
  45. int (*get_desc)(struct udevice *dev, char *buf, int size);
  46. /**
  47. * get_info() - Get information about a CPU
  48. *
  49. * @dev: Device to check (UCLASS_CPU)
  50. * @info: Returns CPU info
  51. * @return 0 if OK, -ve on error
  52. */
  53. int (*get_info)(struct udevice *dev, struct cpu_info *info);
  54. /**
  55. * get_count() - Get number of CPUs
  56. *
  57. * @dev: Device to check (UCLASS_CPU)
  58. * @return CPU count if OK, -ve on error
  59. */
  60. int (*get_count)(struct udevice *dev);
  61. };
  62. #define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops)
  63. /**
  64. * cpu_get_desc() - Get a description string for a CPU
  65. *
  66. * @dev: Device to check (UCLASS_CPU)
  67. * @buf: Buffer to place string
  68. * @size: Size of string space
  69. * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
  70. */
  71. int cpu_get_desc(struct udevice *dev, char *buf, int size);
  72. /**
  73. * cpu_get_info() - Get information about a CPU
  74. *
  75. * @dev: Device to check (UCLASS_CPU)
  76. * @info: Returns CPU info
  77. * @return 0 if OK, -ve on error
  78. */
  79. int cpu_get_info(struct udevice *dev, struct cpu_info *info);
  80. /**
  81. * cpu_get_count() - Get number of CPUs
  82. *
  83. * @dev: Device to check (UCLASS_CPU)
  84. * @return CPU count if OK, -ve on error
  85. */
  86. int cpu_get_count(struct udevice *dev);
  87. #endif