Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Intel Uncore Frequency Control: Common defines and prototypes
0004  * Copyright (c) 2022, Intel Corporation.
0005  * All rights reserved.
0006  *
0007  */
0008 
0009 #ifndef __INTEL_UNCORE_FREQ_COMMON_H
0010 #define __INTEL_UNCORE_FREQ_COMMON_H
0011 
0012 #include <linux/device.h>
0013 
0014 /**
0015  * struct uncore_data - Encapsulate all uncore data
0016  * @stored_uncore_data: Last user changed MSR 620 value, which will be restored
0017  *          on system resume.
0018  * @initial_min_freq_khz: Sampled minimum uncore frequency at driver init
0019  * @initial_max_freq_khz: Sampled maximum uncore frequency at driver init
0020  * @control_cpu:    Designated CPU for a die to read/write
0021  * @valid:      Mark the data valid/invalid
0022  * @package_id: Package id for this instance
0023  * @die_id:     Die id for this instance
0024  * @name:       Sysfs entry name for this instance
0025  * @uncore_attr_group:  Attribute group storage
0026  * @max_freq_khz_dev_attr: Storage for device attribute max_freq_khz
0027  * @mix_freq_khz_dev_attr: Storage for device attribute min_freq_khz
0028  * @initial_max_freq_khz_dev_attr: Storage for device attribute initial_max_freq_khz
0029  * @initial_min_freq_khz_dev_attr: Storage for device attribute initial_min_freq_khz
0030  * @current_freq_khz_dev_attr: Storage for device attribute current_freq_khz
0031  * @uncore_attrs:   Attribute storage for group creation
0032  *
0033  * This structure is used to encapsulate all data related to uncore sysfs
0034  * settings for a die/package.
0035  */
0036 struct uncore_data {
0037     u64 stored_uncore_data;
0038     u32 initial_min_freq_khz;
0039     u32 initial_max_freq_khz;
0040     int control_cpu;
0041     bool valid;
0042     int package_id;
0043     int die_id;
0044     char name[32];
0045 
0046     struct attribute_group uncore_attr_group;
0047     struct device_attribute max_freq_khz_dev_attr;
0048     struct device_attribute min_freq_khz_dev_attr;
0049     struct device_attribute initial_max_freq_khz_dev_attr;
0050     struct device_attribute initial_min_freq_khz_dev_attr;
0051     struct device_attribute current_freq_khz_dev_attr;
0052     struct attribute *uncore_attrs[6];
0053 };
0054 
0055 int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, unsigned int *min, unsigned int *max),
0056                  int (*write_control_freq)(struct uncore_data *data, unsigned int input, unsigned int min_max),
0057                  int (*uncore_read_freq)(struct uncore_data *data, unsigned int *freq));
0058 void uncore_freq_common_exit(void);
0059 int uncore_freq_add_entry(struct uncore_data *data, int cpu);
0060 void uncore_freq_remove_die_entry(struct uncore_data *data);
0061 
0062 #endif