Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2012 Samsung Electronics.
0004  * Kyungmin Park <kyungmin.park@samsung.com>
0005  * Tomasz Figa <t.figa@samsung.com>
0006  */
0007 
0008 #ifndef __ASM_ARM_FIRMWARE_H
0009 #define __ASM_ARM_FIRMWARE_H
0010 
0011 #include <linux/bug.h>
0012 
0013 /*
0014  * struct firmware_ops
0015  *
0016  * A structure to specify available firmware operations.
0017  *
0018  * A filled up structure can be registered with register_firmware_ops().
0019  */
0020 struct firmware_ops {
0021     /*
0022      * Inform the firmware we intend to enter CPU idle mode
0023      */
0024     int (*prepare_idle)(unsigned long mode);
0025     /*
0026      * Enters CPU idle mode
0027      */
0028     int (*do_idle)(unsigned long mode);
0029     /*
0030      * Sets boot address of specified physical CPU
0031      */
0032     int (*set_cpu_boot_addr)(int cpu, unsigned long boot_addr);
0033     /*
0034      * Gets boot address of specified physical CPU
0035      */
0036     int (*get_cpu_boot_addr)(int cpu, unsigned long *boot_addr);
0037     /*
0038      * Boots specified physical CPU
0039      */
0040     int (*cpu_boot)(int cpu);
0041     /*
0042      * Initializes L2 cache
0043      */
0044     int (*l2x0_init)(void);
0045     /*
0046      * Enter system-wide suspend.
0047      */
0048     int (*suspend)(void);
0049     /*
0050      * Restore state of privileged hardware after system-wide suspend.
0051      */
0052     int (*resume)(void);
0053 };
0054 
0055 /* Global pointer for current firmware_ops structure, can't be NULL. */
0056 extern const struct firmware_ops *firmware_ops;
0057 
0058 /*
0059  * call_firmware_op(op, ...)
0060  *
0061  * Checks if firmware operation is present and calls it,
0062  * otherwise returns -ENOSYS
0063  */
0064 #define call_firmware_op(op, ...)                   \
0065     ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS))
0066 
0067 /*
0068  * register_firmware_ops(ops)
0069  *
0070  * A function to register platform firmware_ops struct.
0071  */
0072 static inline void register_firmware_ops(const struct firmware_ops *ops)
0073 {
0074     BUG_ON(!ops);
0075 
0076     firmware_ops = ops;
0077 }
0078 
0079 #endif