firmware.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 Samsung Electronics.
  4. * Kyungmin Park <[email protected]>
  5. * Tomasz Figa <[email protected]>
  6. */
  7. #ifndef __ASM_ARM_FIRMWARE_H
  8. #define __ASM_ARM_FIRMWARE_H
  9. #include <linux/bug.h>
  10. /*
  11. * struct firmware_ops
  12. *
  13. * A structure to specify available firmware operations.
  14. *
  15. * A filled up structure can be registered with register_firmware_ops().
  16. */
  17. struct firmware_ops {
  18. /*
  19. * Inform the firmware we intend to enter CPU idle mode
  20. */
  21. int (*prepare_idle)(unsigned long mode);
  22. /*
  23. * Enters CPU idle mode
  24. */
  25. int (*do_idle)(unsigned long mode);
  26. /*
  27. * Sets boot address of specified physical CPU
  28. */
  29. int (*set_cpu_boot_addr)(int cpu, unsigned long boot_addr);
  30. /*
  31. * Gets boot address of specified physical CPU
  32. */
  33. int (*get_cpu_boot_addr)(int cpu, unsigned long *boot_addr);
  34. /*
  35. * Boots specified physical CPU
  36. */
  37. int (*cpu_boot)(int cpu);
  38. /*
  39. * Initializes L2 cache
  40. */
  41. int (*l2x0_init)(void);
  42. /*
  43. * Enter system-wide suspend.
  44. */
  45. int (*suspend)(void);
  46. /*
  47. * Restore state of privileged hardware after system-wide suspend.
  48. */
  49. int (*resume)(void);
  50. };
  51. /* Global pointer for current firmware_ops structure, can't be NULL. */
  52. extern const struct firmware_ops *firmware_ops;
  53. /*
  54. * call_firmware_op(op, ...)
  55. *
  56. * Checks if firmware operation is present and calls it,
  57. * otherwise returns -ENOSYS
  58. */
  59. #define call_firmware_op(op, ...) \
  60. ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))
  61. /*
  62. * register_firmware_ops(ops)
  63. *
  64. * A function to register platform firmware_ops struct.
  65. */
  66. static inline void register_firmware_ops(const struct firmware_ops *ops)
  67. {
  68. BUG_ON(!ops);
  69. firmware_ops = ops;
  70. }
  71. #endif