1 Interface for registering and calling firmware-specific operations for ARM.
3 Written by Tomasz Figa <t.figa@samsung.com>
5 Some boards are running with secure firmware running in TrustZone secure
6 world, which changes the way some things have to be initialized. This makes
7 a need to provide an interface for such platforms to specify available firmware
8 operations and call them when needed.
10 Firmware operations can be specified using struct firmware_ops
14 * Enters CPU idle mode
18 * Sets boot address of specified physical CPU
20 int (*set_cpu_boot_addr)(int cpu, unsigned long boot_addr);
22 * Boots specified physical CPU
24 int (*cpu_boot)(int cpu);
26 * Initializes L2 cache
28 int (*l2x0_init)(void);
31 and then registered with register_firmware_ops function
33 void register_firmware_ops(const struct firmware_ops *ops)
35 the ops pointer must be non-NULL.
37 There is a default, empty set of operations provided, so there is no need to
38 set anything if platform does not require firmware operations.
40 To call a firmware operation, a helper macro is provided
42 #define call_firmware_op(op, ...) \
43 ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))
45 the macro checks if the operation is provided and calls it or otherwise returns
46 -ENOSYS to signal that given operation is not available (for example, to allow
47 fallback to legacy operation).
49 Example of registering firmware operations:
53 static int platformX_do_idle(void)
55 /* tell platformX firmware to enter idle */
59 static int platformX_cpu_boot(int i)
61 /* tell platformX firmware to boot CPU i */
65 static const struct firmware_ops platformX_firmware_ops = {
66 .do_idle = exynos_do_idle,
67 .cpu_boot = exynos_cpu_boot,
68 /* other operations not available on platformX */
71 /* init_early callback of machine descriptor */
72 static void __init board_init_early(void)
74 register_firmware_ops(&platformX_firmware_ops);
77 Example of using a firmware operation:
79 /* some platform code, e.g. SMP initialization */
81 __raw_writel(virt_to_phys(exynos4_secondary_startup),
84 /* Call Exynos specific smc call */
85 if (call_firmware_op(cpu_boot, cpu) == -ENOSYS)
86 cpu_boot_legacy(...); /* Try legacy way */
88 gic_raise_softirq(cpumask_of(cpu), 1);