firmware.txt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. Interface for registering and calling firmware-specific operations for ARM.
  2. ----
  3. Written by Tomasz Figa <t.figa@samsung.com>
  4. Some boards are running with secure firmware running in TrustZone secure
  5. world, which changes the way some things have to be initialized. This makes
  6. a need to provide an interface for such platforms to specify available firmware
  7. operations and call them when needed.
  8. Firmware operations can be specified by filling in a struct firmware_ops
  9. with appropriate callbacks and then registering it with register_firmware_ops()
  10. function.
  11. void register_firmware_ops(const struct firmware_ops *ops)
  12. The ops pointer must be non-NULL. More information about struct firmware_ops
  13. and its members can be found in arch/arm/include/asm/firmware.h header.
  14. There is a default, empty set of operations provided, so there is no need to
  15. set anything if platform does not require firmware operations.
  16. To call a firmware operation, a helper macro is provided
  17. #define call_firmware_op(op, ...) \
  18. ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))
  19. the macro checks if the operation is provided and calls it or otherwise returns
  20. -ENOSYS to signal that given operation is not available (for example, to allow
  21. fallback to legacy operation).
  22. Example of registering firmware operations:
  23. /* board file */
  24. static int platformX_do_idle(void)
  25. {
  26. /* tell platformX firmware to enter idle */
  27. return 0;
  28. }
  29. static int platformX_cpu_boot(int i)
  30. {
  31. /* tell platformX firmware to boot CPU i */
  32. return 0;
  33. }
  34. static const struct firmware_ops platformX_firmware_ops = {
  35. .do_idle = exynos_do_idle,
  36. .cpu_boot = exynos_cpu_boot,
  37. /* other operations not available on platformX */
  38. };
  39. /* init_early callback of machine descriptor */
  40. static void __init board_init_early(void)
  41. {
  42. register_firmware_ops(&platformX_firmware_ops);
  43. }
  44. Example of using a firmware operation:
  45. /* some platform code, e.g. SMP initialization */
  46. __raw_writel(virt_to_phys(exynos4_secondary_startup),
  47. CPU1_BOOT_REG);
  48. /* Call Exynos specific smc call */
  49. if (call_firmware_op(cpu_boot, cpu) == -ENOSYS)
  50. cpu_boot_legacy(...); /* Try legacy way */
  51. gic_raise_softirq(cpumask_of(cpu), 1);