Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Coresight system configuration driver.
0004  */
0005 
0006 #ifndef CORESIGHT_SYSCFG_H
0007 #define CORESIGHT_SYSCFG_H
0008 
0009 #include <linux/configfs.h>
0010 #include <linux/coresight.h>
0011 #include <linux/device.h>
0012 
0013 #include "coresight-config.h"
0014 
0015 /*
0016  * Load operation types.
0017  * When loading or unloading, another load operation cannot be run.
0018  * When unloading configurations cannot be activated.
0019  */
0020 enum cscfg_load_ops {
0021     CSCFG_NONE,
0022     CSCFG_LOAD,
0023     CSCFG_UNLOAD
0024 };
0025 
0026 /**
0027  * System configuration manager device.
0028  *
0029  * Contains lists of the loaded configurations and features, plus a list of CoreSight devices
0030  * registered with the system as supporting configuration management.
0031  *
0032  * Need a device to 'own' some coresight system wide sysfs entries in
0033  * perf events, configfs etc.
0034  *
0035  * @dev:        The device.
0036  * @csdev_desc_list:    List of coresight devices registered with the configuration manager.
0037  * @feat_desc_list: List of feature descriptors to load into registered devices.
0038  * @config_desc_list:   List of system configuration descriptors to load into registered devices.
0039  * @load_order_list:    Ordered list of owners for dynamically loaded configurations.
0040  * @sys_active_cnt: Total number of active config descriptor references.
0041  * @cfgfs_subsys:   configfs subsystem used to manage configurations.
0042  * @sysfs_active_config:Active config hash used if CoreSight controlled from sysfs.
0043  * @sysfs_active_preset:Active preset index used if CoreSight controlled from sysfs.
0044  * @load_state:     A multi-stage load/unload operation is in progress.
0045  */
0046 struct cscfg_manager {
0047     struct device dev;
0048     struct list_head csdev_desc_list;
0049     struct list_head feat_desc_list;
0050     struct list_head config_desc_list;
0051     struct list_head load_order_list;
0052     atomic_t sys_active_cnt;
0053     struct configfs_subsystem cfgfs_subsys;
0054     u32 sysfs_active_config;
0055     int sysfs_active_preset;
0056     enum cscfg_load_ops load_state;
0057 };
0058 
0059 /* get reference to dev in cscfg_manager */
0060 struct device *cscfg_device(void);
0061 
0062 /**
0063  * List entry for Coresight devices that are registered as supporting complex
0064  * config operations.
0065  *
0066  * @csdev:   The registered device.
0067  * @match_flags: The matching type information for adding features.
0068  * @ops:     Operations supported by the registered device.
0069  * @item:    list entry.
0070  */
0071 struct cscfg_registered_csdev {
0072     struct coresight_device *csdev;
0073     u32 match_flags;
0074     struct cscfg_csdev_feat_ops ops;
0075     struct list_head item;
0076 };
0077 
0078 /* owner types for loading and unloading of config and feature sets */
0079 enum cscfg_load_owner_type {
0080     CSCFG_OWNER_PRELOAD,
0081     CSCFG_OWNER_MODULE,
0082 };
0083 
0084 /**
0085  * Load item - item to add to the load order list allowing dynamic load and
0086  *             unload of configurations and features. Caller loading a config
0087  *         set provides a context handle for unload. API ensures that
0088  *         items unloaded strictly in reverse order from load to ensure
0089  *         dependencies are respected.
0090  *
0091  * @item:       list entry for load order list.
0092  * @type:       type of owner - allows interpretation of owner_handle.
0093  * @owner_handle:   load context - handle for owner of loaded configs.
0094  */
0095 struct cscfg_load_owner_info {
0096     struct list_head item;
0097     int type;
0098     void *owner_handle;
0099 };
0100 
0101 /* internal core operations for cscfg */
0102 int __init cscfg_init(void);
0103 void cscfg_exit(void);
0104 int cscfg_preload(void *owner_handle);
0105 const struct cscfg_feature_desc *cscfg_get_named_feat_desc(const char *name);
0106 int cscfg_update_feat_param_val(struct cscfg_feature_desc *feat_desc,
0107                 int param_idx, u64 value);
0108 int cscfg_config_sysfs_activate(struct cscfg_config_desc *cfg_desc, bool activate);
0109 void cscfg_config_sysfs_set_preset(int preset);
0110 
0111 /* syscfg manager external API */
0112 int cscfg_load_config_sets(struct cscfg_config_desc **cfg_descs,
0113                struct cscfg_feature_desc **feat_descs,
0114                struct cscfg_load_owner_info *owner_info);
0115 int cscfg_unload_config_sets(struct cscfg_load_owner_info *owner_info);
0116 int cscfg_register_csdev(struct coresight_device *csdev, u32 match_flags,
0117              struct cscfg_csdev_feat_ops *ops);
0118 void cscfg_unregister_csdev(struct coresight_device *csdev);
0119 int cscfg_activate_config(unsigned long cfg_hash);
0120 void cscfg_deactivate_config(unsigned long cfg_hash);
0121 void cscfg_csdev_reset_feats(struct coresight_device *csdev);
0122 int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
0123                      unsigned long cfg_hash, int preset);
0124 void cscfg_csdev_disable_active_config(struct coresight_device *csdev);
0125 void cscfg_config_sysfs_get_active_cfg(unsigned long *cfg_hash, int *preset);
0126 
0127 #endif /* CORESIGHT_SYSCFG_H */