![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 /* 0003 * Copyright (c) 2020 Linaro Limited, All rights reserved. 0004 * Author: Mike Leach <mike.leach@linaro.org> 0005 */ 0006 0007 #ifndef _CORESIGHT_CORESIGHT_CONFIG_H 0008 #define _CORESIGHT_CORESIGHT_CONFIG_H 0009 0010 #include <linux/coresight.h> 0011 #include <linux/types.h> 0012 0013 /* CoreSight Configuration Management - component and system wide configuration */ 0014 0015 /* 0016 * Register type flags for register value descriptor: 0017 * describe how the value is interpreted, and handled. 0018 */ 0019 #define CS_CFG_REG_TYPE_STD 0x80 /* reg is standard reg */ 0020 #define CS_CFG_REG_TYPE_RESOURCE 0x40 /* reg is a resource */ 0021 #define CS_CFG_REG_TYPE_VAL_PARAM 0x08 /* reg value uses param */ 0022 #define CS_CFG_REG_TYPE_VAL_MASK 0x04 /* reg value bit masked */ 0023 #define CS_CFG_REG_TYPE_VAL_64BIT 0x02 /* reg value 64 bit */ 0024 #define CS_CFG_REG_TYPE_VAL_SAVE 0x01 /* reg value save on disable */ 0025 0026 /* 0027 * flags defining what device class a feature will match to when processing a 0028 * system configuration - used by config data and devices. 0029 */ 0030 #define CS_CFG_MATCH_CLASS_SRC_ALL 0x0001 /* match any source */ 0031 #define CS_CFG_MATCH_CLASS_SRC_ETM4 0x0002 /* match any ETMv4 device */ 0032 0033 /* flags defining device instance matching - used in config match desc data. */ 0034 #define CS_CFG_MATCH_INST_ANY 0x80000000 /* any instance of a class */ 0035 0036 /* 0037 * Limit number of presets in a configuration 0038 * This is related to the number of bits (4) we use to select the preset on 0039 * the perf command line. Preset 0 is always none selected. 0040 * See PMU_FORMAT_ATTR(preset, "config:0-3") in coresight-etm-perf.c 0041 */ 0042 #define CS_CFG_CONFIG_PRESET_MAX 15 0043 0044 /** 0045 * Parameter descriptor for a device feature. 0046 * 0047 * @name: Name of parameter. 0048 * @value: Initial or default value. 0049 */ 0050 struct cscfg_parameter_desc { 0051 const char *name; 0052 u64 value; 0053 }; 0054 0055 /** 0056 * Representation of register value and a descriptor of register usage. 0057 * 0058 * Used as a descriptor in the feature descriptors. 0059 * Used as a value in when in a feature loading into a csdev. 0060 * 0061 * Supports full 64 bit register value, or 32 bit value with optional mask 0062 * value. 0063 * 0064 * @type: define register usage and interpretation. 0065 * @offset: the address offset for register in the hardware device (per device specification). 0066 * @hw_info: optional hardware device type specific information. (ETM / CTI specific etc) 0067 * @val64: 64 bit value. 0068 * @val32: 32 bit value. 0069 * @mask32: 32 bit mask when using 32 bit value to access device register - if mask type. 0070 * @param_idx: parameter index value into parameter array if param type. 0071 */ 0072 struct cscfg_regval_desc { 0073 struct { 0074 u32 type:8; 0075 u32 offset:12; 0076 u32 hw_info:12; 0077 }; 0078 union { 0079 u64 val64; 0080 struct { 0081 u32 val32; 0082 u32 mask32; 0083 }; 0084 u32 param_idx; 0085 }; 0086 }; 0087 0088 /** 0089 * Device feature descriptor - combination of registers and parameters to 0090 * program a device to implement a specific complex function. 0091 * 0092 * @name: feature name. 0093 * @description: brief description of the feature. 0094 * @item: List entry. 0095 * @match_flags: matching information if loading into a device 0096 * @nr_params: number of parameters used. 0097 * @params_desc: array of parameters used. 0098 * @nr_regs: number of registers used. 0099 * @regs_desc: array of registers used. 0100 * @load_owner: handle to load owner for dynamic load and unload of features. 0101 * @fs_group: reference to configfs group for dynamic unload. 0102 */ 0103 struct cscfg_feature_desc { 0104 const char *name; 0105 const char *description; 0106 struct list_head item; 0107 u32 match_flags; 0108 int nr_params; 0109 struct cscfg_parameter_desc *params_desc; 0110 int nr_regs; 0111 struct cscfg_regval_desc *regs_desc; 0112 void *load_owner; 0113 struct config_group *fs_group; 0114 }; 0115 0116 /** 0117 * Configuration descriptor - describes selectable system configuration. 0118 * 0119 * A configuration describes device features in use, and may provide preset 0120 * values for the parameters in those features. 0121 * 0122 * A single set of presets is the sum of the parameters declared by 0123 * all the features in use - this value is @nr_total_params. 0124 * 0125 * @name: name of the configuration - used for selection. 0126 * @description: description of the purpose of the configuration. 0127 * @item: list entry. 0128 * @nr_feat_refs: Number of features used in this configuration. 0129 * @feat_ref_names: references to features used in this configuration. 0130 * @nr_presets: Number of sets of presets supplied by this configuration. 0131 * @nr_total_params: Sum of all parameters declared by used features 0132 * @presets: Array of preset values. 0133 * @event_ea: Extended attribute for perf event value 0134 * @active_cnt: ref count for activate on this configuration. 0135 * @load_owner: handle to load owner for dynamic load and unload of configs. 0136 * @fs_group: reference to configfs group for dynamic unload. 0137 * @available: config can be activated - multi-stage load sets true on completion. 0138 */ 0139 struct cscfg_config_desc { 0140 const char *name; 0141 const char *description; 0142 struct list_head item; 0143 int nr_feat_refs; 0144 const char **feat_ref_names; 0145 int nr_presets; 0146 int nr_total_params; 0147 const u64 *presets; /* nr_presets * nr_total_params */ 0148 struct dev_ext_attribute *event_ea; 0149 atomic_t active_cnt; 0150 void *load_owner; 0151 struct config_group *fs_group; 0152 bool available; 0153 }; 0154 0155 /** 0156 * config register instance - part of a loaded feature. 0157 * maps register values to csdev driver structures 0158 * 0159 * @reg_desc: value to use when setting feature on device / store for 0160 * readback of volatile values. 0161 * @driver_regval: pointer to internal driver element used to set the value 0162 * in hardware. 0163 */ 0164 struct cscfg_regval_csdev { 0165 struct cscfg_regval_desc reg_desc; 0166 void *driver_regval; 0167 }; 0168 0169 /** 0170 * config parameter instance - part of a loaded feature. 0171 * 0172 * @feat_csdev: parent feature 0173 * @reg_csdev: register value updated by this parameter. 0174 * @current_value: current value of parameter - may be set by user via 0175 * sysfs, or modified during device operation. 0176 * @val64: true if 64 bit value 0177 */ 0178 struct cscfg_parameter_csdev { 0179 struct cscfg_feature_csdev *feat_csdev; 0180 struct cscfg_regval_csdev *reg_csdev; 0181 u64 current_value; 0182 bool val64; 0183 }; 0184 0185 /** 0186 * Feature instance loaded into a CoreSight device. 0187 * 0188 * When a feature is loaded into a specific device, then this structure holds 0189 * the connections between the register / parameter values used and the 0190 * internal data structures that are written when the feature is enabled. 0191 * 0192 * Since applying a feature modifies internal data structures in the device, 0193 * then we have a reference to the device spinlock to protect access to these 0194 * structures (@drv_spinlock). 0195 * 0196 * @feat_desc: pointer to the static descriptor for this feature. 0197 * @csdev: parent CoreSight device instance. 0198 * @node: list entry into feature list for this device. 0199 * @drv_spinlock: device spinlock for access to driver register data. 0200 * @nr_params: number of parameters. 0201 * @params_csdev: current parameter values on this device 0202 * @nr_regs: number of registers to be programmed. 0203 * @regs_csdev: Programming details for the registers 0204 */ 0205 struct cscfg_feature_csdev { 0206 const struct cscfg_feature_desc *feat_desc; 0207 struct coresight_device *csdev; 0208 struct list_head node; 0209 spinlock_t *drv_spinlock; 0210 int nr_params; 0211 struct cscfg_parameter_csdev *params_csdev; 0212 int nr_regs; 0213 struct cscfg_regval_csdev *regs_csdev; 0214 }; 0215 0216 /** 0217 * Configuration instance when loaded into a CoreSight device. 0218 * 0219 * The instance contains references to loaded features on this device that are 0220 * used by the configuration. 0221 * 0222 * @config_desc:reference to the descriptor for this configuration 0223 * @csdev: parent coresight device for this configuration instance. 0224 * @enabled: true if configuration is enabled on this device. 0225 * @node: list entry within the coresight device 0226 * @nr_feat: Number of features on this device that are used in the 0227 * configuration. 0228 * @feats_csdev:references to the device features to enable. 0229 */ 0230 struct cscfg_config_csdev { 0231 const struct cscfg_config_desc *config_desc; 0232 struct coresight_device *csdev; 0233 bool enabled; 0234 struct list_head node; 0235 int nr_feat; 0236 struct cscfg_feature_csdev *feats_csdev[]; 0237 }; 0238 0239 /** 0240 * Coresight device operations. 0241 * 0242 * Registered coresight devices provide these operations to manage feature 0243 * instances compatible with the device hardware and drivers 0244 * 0245 * @load_feat: Pass a feature descriptor into the device and create the 0246 * loaded feature instance (struct cscfg_feature_csdev). 0247 */ 0248 struct cscfg_csdev_feat_ops { 0249 int (*load_feat)(struct coresight_device *csdev, 0250 struct cscfg_feature_csdev *feat_csdev); 0251 }; 0252 0253 /* coresight config helper functions*/ 0254 0255 /* enable / disable config on a device - called with appropriate locks set.*/ 0256 int cscfg_csdev_enable_config(struct cscfg_config_csdev *config_csdev, int preset); 0257 void cscfg_csdev_disable_config(struct cscfg_config_csdev *config_csdev); 0258 0259 /* reset a feature to default values */ 0260 void cscfg_reset_feat(struct cscfg_feature_csdev *feat_csdev); 0261 0262 #endif /* _CORESIGHT_CORESIGHT_CONFIG_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |