1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Coresight system configuration driver. 4 */ 5 6 #ifndef CORESIGHT_SYSCFG_H 7 #define CORESIGHT_SYSCFG_H 8 9 #include <linux/configfs.h> 10 #include <linux/coresight.h> 11 #include <linux/device.h> 12 13 #include "coresight-config.h" 14 15 /** 16 * System configuration manager device. 17 * 18 * Contains lists of the loaded configurations and features, plus a list of CoreSight devices 19 * registered with the system as supporting configuration management. 20 * 21 * Need a device to 'own' some coresight system wide sysfs entries in 22 * perf events, configfs etc. 23 * 24 * @dev: The device. 25 * @csdev_desc_list: List of coresight devices registered with the configuration manager. 26 * @feat_desc_list: List of feature descriptors to load into registered devices. 27 * @config_desc_list: List of system configuration descriptors to load into registered devices. 28 * @sys_active_cnt: Total number of active config descriptor references. 29 * @cfgfs_subsys: configfs subsystem used to manage configurations. 30 */ 31 struct cscfg_manager { 32 struct device dev; 33 struct list_head csdev_desc_list; 34 struct list_head feat_desc_list; 35 struct list_head config_desc_list; 36 atomic_t sys_active_cnt; 37 struct configfs_subsystem cfgfs_subsys; 38 }; 39 40 /* get reference to dev in cscfg_manager */ 41 struct device *cscfg_device(void); 42 43 /** 44 * List entry for Coresight devices that are registered as supporting complex 45 * config operations. 46 * 47 * @csdev: The registered device. 48 * @match_flags: The matching type information for adding features. 49 * @ops: Operations supported by the registered device. 50 * @item: list entry. 51 */ 52 struct cscfg_registered_csdev { 53 struct coresight_device *csdev; 54 u32 match_flags; 55 struct cscfg_csdev_feat_ops ops; 56 struct list_head item; 57 }; 58 59 /* internal core operations for cscfg */ 60 int __init cscfg_init(void); 61 void cscfg_exit(void); 62 int cscfg_preload(void); 63 const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name); 64 int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc, 65 int param_idx, u64 value); 66 67 68 /* syscfg manager external API */ 69 int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs, 70 struct cscfg_feature_desc **feat_descs); 71 int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags, 72 struct cscfg_csdev_feat_ops *ops); 73 void cscfg_unregister_csdev(struct coresight_device *csdev); 74 int cscfg_activate_config(unsigned long cfg_hash); 75 void cscfg_deactivate_config(unsigned long cfg_hash); 76 void cscfg_csdev_reset_feats(struct coresight_device *csdev); 77 int cscfg_csdev_enable_active_config(struct coresight_device *csdev, 78 unsigned long cfg_hash, int preset); 79 void cscfg_csdev_disable_active_config(struct coresight_device *csdev); 80 81 #endif /* CORESIGHT_SYSCFG_H */ 82