0001 ==========================================================================
0002 Interface for registering and calling firmware-specific operations for ARM
0003 ==========================================================================
0004
0005 Written by Tomasz Figa <t.figa@samsung.com>
0006
0007 Some boards are running with secure firmware running in TrustZone secure
0008 world, which changes the way some things have to be initialized. This makes
0009 a need to provide an interface for such platforms to specify available firmware
0010 operations and call them when needed.
0011
0012 Firmware operations can be specified by filling in a struct firmware_ops
0013 with appropriate callbacks and then registering it with register_firmware_ops()
0014 function::
0015
0016 void register_firmware_ops(const struct firmware_ops *ops)
0017
0018 The ops pointer must be non-NULL. More information about struct firmware_ops
0019 and its members can be found in arch/arm/include/asm/firmware.h header.
0020
0021 There is a default, empty set of operations provided, so there is no need to
0022 set anything if platform does not require firmware operations.
0023
0024 To call a firmware operation, a helper macro is provided::
0025
0026 #define call_firmware_op(op, ...) \
0027 ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))
0028
0029 the macro checks if the operation is provided and calls it or otherwise returns
0030 -ENOSYS to signal that given operation is not available (for example, to allow
0031 fallback to legacy operation).
0032
0033 Example of registering firmware operations::
0034
0035 /* board file */
0036
0037 static int platformX_do_idle(void)
0038 {
0039 /* tell platformX firmware to enter idle */
0040 return 0;
0041 }
0042
0043 static int platformX_cpu_boot(int i)
0044 {
0045 /* tell platformX firmware to boot CPU i */
0046 return 0;
0047 }
0048
0049 static const struct firmware_ops platformX_firmware_ops = {
0050 .do_idle = exynos_do_idle,
0051 .cpu_boot = exynos_cpu_boot,
0052 /* other operations not available on platformX */
0053 };
0054
0055 /* init_early callback of machine descriptor */
0056 static void __init board_init_early(void)
0057 {
0058 register_firmware_ops(&platformX_firmware_ops);
0059 }
0060
0061 Example of using a firmware operation::
0062
0063 /* some platform code, e.g. SMP initialization */
0064
0065 __raw_writel(__pa_symbol(exynos4_secondary_startup),
0066 CPU1_BOOT_REG);
0067
0068 /* Call Exynos specific smc call */
0069 if (call_firmware_op(cpu_boot, cpu) == -ENOSYS)
0070 cpu_boot_legacy(...); /* Try legacy way */
0071
0072 gic_raise_softirq(cpumask_of(cpu), 1);