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 * @name: Sysfs entry name for this instance 25 * @uncore_attr_group: Attribute group storage 26 * @max_freq_khz_dev_attr: Storage for device attribute max_freq_khz 27 * @mix_freq_khz_dev_attr: Storage for device attribute min_freq_khz 28 * @initial_max_freq_khz_dev_attr: Storage for device attribute initial_max_freq_khz 29 * @initial_min_freq_khz_dev_attr: Storage for device attribute initial_min_freq_khz 30 * @current_freq_khz_dev_attr: Storage for device attribute current_freq_khz 31 * @uncore_attrs: Attribute storage for group creation 32 * 33 * This structure is used to encapsulate all data related to uncore sysfs 34 * settings for a die/package. 35 */ 36 struct uncore_data { 37 u64 stored_uncore_data; 38 u32 initial_min_freq_khz; 39 u32 initial_max_freq_khz; 40 int control_cpu; 41 bool valid; 42 int package_id; 43 int die_id; 44 char name[32]; 45 46 struct attribute_group uncore_attr_group; 47 struct device_attribute max_freq_khz_dev_attr; 48 struct device_attribute min_freq_khz_dev_attr; 49 struct device_attribute initial_max_freq_khz_dev_attr; 50 struct device_attribute initial_min_freq_khz_dev_attr; 51 struct device_attribute current_freq_khz_dev_attr; 52 struct attribute *uncore_attrs[6]; 53 }; 54 55 int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, unsigned int *min, unsigned int *max), 56 int (*write_control_freq)(struct uncore_data *data, unsigned int input, unsigned int min_max), 57 int (*uncore_read_freq)(struct uncore_data *data, unsigned int *freq)); 58 void uncore_freq_common_exit(void); 59 int uncore_freq_add_entry(struct uncore_data *data, int cpu); 60 void uncore_freq_remove_die_entry(struct uncore_data *data); 61 62 #endif 63