1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2 /* Copyright (c) 2023 Imagination Technologies Ltd. */
3 
4 #ifndef PVR_PARAMS_H
5 #define PVR_PARAMS_H
6 
7 #include "pvr_rogue_fwif.h"
8 
9 #include <linux/cache.h>
10 #include <linux/compiler_attributes.h>
11 
12 /*
13  * This is the definitive list of types allowed in the definition of
14  * %PVR_DEVICE_PARAMS.
15  */
16 #define PVR_PARAM_TYPE_X32_C u32
17 
18 /*
19  * This macro defines all device-specific parameters; that is parameters which
20  * are set independently per device.
21  *
22  * The X-macro accepts the following arguments. Arguments marked with [debugfs]
23  * are ignored when debugfs is disabled; values used for these arguments may
24  * safely be gated behind CONFIG_DEBUG_FS.
25  *
26  * @type_: The definitive list of allowed values is PVR_PARAM_TYPE_*_C.
27  * @name_: Name of the parameter. This is used both as the field name in C and
28  *         stringified as the parameter name.
29  * @value_: Initial/default value.
30  * @desc_: String literal used as help text to describe the usage of this
31  *         parameter.
32  * @mode_: [debugfs] One of {RO,RW}. The access mode of the debugfs entry for
33  *         this parameter.
34  * @update_: [debugfs] When debugfs support is enabled, parameters may be
35  *           updated at runtime. When this happens, this function will be
36  *           called to allow changes to propagate. The signature of this
37  *           function is:
38  *
39  *              void (*)(struct pvr_device *pvr_dev, T old_val, T new_val)
40  *
41  *           Where T is the C type associated with @type_.
42  *
43  *           If @mode_ does not allow write access, this function will never be
44  *           called. In this case, or if no update callback is required, you
45  *           should specify NULL for this argument.
46  */
47 #define PVR_DEVICE_PARAMS                                                    \
48 	X(X32, fw_trace_mask, ROGUE_FWIF_LOG_TYPE_NONE,                      \
49 	  "Enable FW trace for the specified groups. Specifying 0 disables " \
50 	  "all FW tracing.",                                                 \
51 	  RW, pvr_fw_trace_mask_update)
52 
53 struct pvr_device_params {
54 #define X(type_, name_, value_, desc_, ...) \
55 	PVR_PARAM_TYPE_##type_##_C name_;
56 	PVR_DEVICE_PARAMS
57 #undef X
58 };
59 
60 int pvr_device_params_init(struct pvr_device_params *params);
61 
62 #if defined(CONFIG_DEBUG_FS)
63 /* Forward declaration from "pvr_device.h". */
64 struct pvr_device;
65 
66 /* Forward declaration from <linux/dcache.h>. */
67 struct dentry;
68 
69 void pvr_params_debugfs_init(struct pvr_device *pvr_dev, struct dentry *dir);
70 #endif /* defined(CONFIG_DEBUG_FS) */
71 
72 #endif /* PVR_PARAMS_H */
73