1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Intel Uncore Frequency Control: Common defines and prototypes 4 * Copyright (c) 2022, Intel Corporation. 5 * All rights reserved. 6 * 7 */ 8 9 #ifndef __INTEL_UNCORE_FREQ_COMMON_H 10 #define __INTEL_UNCORE_FREQ_COMMON_H 11 12 #include <linux/device.h> 13 14 /** 15 * struct uncore_data - Encapsulate all uncore data 16 * @stored_uncore_data: Last user changed MSR 620 value, which will be restored 17 * on system resume. 18 * @initial_min_freq_khz: Sampled minimum uncore frequency at driver init 19 * @initial_max_freq_khz: Sampled maximum uncore frequency at driver init 20 * @control_cpu: Designated CPU for a die to read/write 21 * @valid: Mark the data valid/invalid 22 * @package_id: Package id for this instance 23 * @die_id: Die id for this instance 24 * @domain_id: Power domain id for this instance 25 * @cluster_id: cluster id in a domain 26 * @instance_id: Unique instance id to append to directory name 27 * @name: Sysfs entry name for this instance 28 * @uncore_attr_group: Attribute group storage 29 * @max_freq_khz_kobj_attr: Storage for kobject attribute max_freq_khz 30 * @mix_freq_khz_kobj_attr: Storage for kobject attribute min_freq_khz 31 * @initial_max_freq_khz_kobj_attr: Storage for kobject attribute initial_max_freq_khz 32 * @initial_min_freq_khz_kobj_attr: Storage for kobject attribute initial_min_freq_khz 33 * @current_freq_khz_kobj_attr: Storage for kobject attribute current_freq_khz 34 * @domain_id_kobj_attr: Storage for kobject attribute domain_id 35 * @fabric_cluster_id_kobj_attr: Storage for kobject attribute fabric_cluster_id 36 * @package_id_kobj_attr: Storage for kobject attribute package_id 37 * @elc_low_threshold_percent_kobj_attr: 38 Storage for kobject attribute elc_low_threshold_percent 39 * @elc_high_threshold_percent_kobj_attr: 40 Storage for kobject attribute elc_high_threshold_percent 41 * @elc_high_threshold_enable_kobj_attr: 42 Storage for kobject attribute elc_high_threshold_enable 43 * @elc_floor_freq_khz_kobj_attr: Storage for kobject attribute elc_floor_freq_khz 44 * @uncore_attrs: Attribute storage for group creation 45 * 46 * This structure is used to encapsulate all data related to uncore sysfs 47 * settings for a die/package. 48 */ 49 struct uncore_data { 50 u64 stored_uncore_data; 51 u32 initial_min_freq_khz; 52 u32 initial_max_freq_khz; 53 int control_cpu; 54 bool valid; 55 int package_id; 56 int die_id; 57 int domain_id; 58 int cluster_id; 59 int instance_id; 60 char name[32]; 61 62 struct attribute_group uncore_attr_group; 63 struct kobj_attribute max_freq_khz_kobj_attr; 64 struct kobj_attribute min_freq_khz_kobj_attr; 65 struct kobj_attribute initial_max_freq_khz_kobj_attr; 66 struct kobj_attribute initial_min_freq_khz_kobj_attr; 67 struct kobj_attribute current_freq_khz_kobj_attr; 68 struct kobj_attribute domain_id_kobj_attr; 69 struct kobj_attribute fabric_cluster_id_kobj_attr; 70 struct kobj_attribute package_id_kobj_attr; 71 struct kobj_attribute elc_low_threshold_percent_kobj_attr; 72 struct kobj_attribute elc_high_threshold_percent_kobj_attr; 73 struct kobj_attribute elc_high_threshold_enable_kobj_attr; 74 struct kobj_attribute elc_floor_freq_khz_kobj_attr; 75 struct attribute *uncore_attrs[13]; 76 }; 77 78 #define UNCORE_DOMAIN_ID_INVALID -1 79 80 enum uncore_index { 81 UNCORE_INDEX_MIN_FREQ, 82 UNCORE_INDEX_MAX_FREQ, 83 UNCORE_INDEX_CURRENT_FREQ, 84 UNCORE_INDEX_EFF_LAT_CTRL_LOW_THRESHOLD, 85 UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD, 86 UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD_ENABLE, 87 UNCORE_INDEX_EFF_LAT_CTRL_FREQ, 88 }; 89 90 int uncore_freq_common_init(int (*read)(struct uncore_data *data, unsigned int *value, 91 enum uncore_index index), 92 int (*write)(struct uncore_data *data, unsigned int input, 93 enum uncore_index index)); 94 void uncore_freq_common_exit(void); 95 int uncore_freq_add_entry(struct uncore_data *data, int cpu); 96 void uncore_freq_remove_die_entry(struct uncore_data *data); 97 98 #endif 99