1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * Intel Speed Select Interface: OS to hardware Interface
4 * Copyright (c) 2019, Intel Corporation.
7 * Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
13 #include <linux/types.h>
16 * struct isst_if_platform_info - Define platform information
17 * @api_version: Version of the firmware document, which this driver
19 * @driver_version: Driver version, which will help user to send right
20 * commands. Even if the firmware is capable, driver may
22 * @max_cmds_per_ioctl: Returns the maximum number of commands driver will
23 * accept in a single ioctl
24 * @mbox_supported: Support of mail box interface
25 * @mmio_supported: Support of mmio interface for core-power feature
27 * Used to return output of IOCTL ISST_IF_GET_PLATFORM_INFO. This
28 * information can be used by the user space, to get the driver, firmware
29 * support and also number of commands to send in a single IOCTL request.
31 struct isst_if_platform_info {
34 __u16 max_cmds_per_ioctl;
40 * struct isst_if_cpu_map - CPU mapping between logical and physical CPU
41 * @logical_cpu: Linux logical CPU number
42 * @physical_cpu: PUNIT CPU number
44 * Used to convert from Linux logical CPU to PUNIT CPU numbering scheme.
45 * The PUNIT CPU number is different than APIC ID based CPU numbering.
47 struct isst_if_cpu_map {
53 * struct isst_if_cpu_maps - structure for CPU map IOCTL
54 * @cmd_count: Number of CPU mapping command in cpu_map[]
55 * @cpu_map[]: Holds one or more CPU map data structure
57 * This structure used with ioctl ISST_IF_GET_PHY_ID to send
58 * one or more CPU mapping commands. Here IOCTL return value indicates
59 * number of commands sent or error number if no commands have been sent.
61 struct isst_if_cpu_maps {
63 struct isst_if_cpu_map cpu_map[1];
67 * struct isst_if_io_reg - Read write PUNIT IO register
68 * @read_write: Value 0: Read, 1: Write
69 * @logical_cpu: Logical CPU number to get target PCI device.
70 * @reg: PUNIT register offset
71 * @value: For write operation value to write and for
72 * read placeholder read value
74 * Structure to specify read/write data to PUNIT registers.
76 struct isst_if_io_reg {
77 __u32 read_write; /* Read:0, Write:1 */
84 * struct isst_if_io_regs - structure for IO register commands
85 * @cmd_count: Number of io reg commands in io_reg[]
86 * @io_reg[]: Holds one or more io_reg command structure
88 * This structure used with ioctl ISST_IF_IO_CMD to send
89 * one or more read/write commands to PUNIT. Here IOCTL return value
90 * indicates number of requests sent or error number if no requests have
93 struct isst_if_io_regs {
95 struct isst_if_io_reg io_reg[1];
99 * struct isst_if_mbox_cmd - Structure to define mail box command
100 * @logical_cpu: Logical CPU number to get target PCI device
101 * @parameter: Mailbox parameter value
102 * @req_data: Request data for the mailbox
103 * @resp_data: Response data for mailbox command response
104 * @command: Mailbox command value
105 * @sub_command: Mailbox sub command value
106 * @reserved: Unused, set to 0
108 * Structure to specify mailbox command to be sent to PUNIT.
110 struct isst_if_mbox_cmd {
121 * struct isst_if_mbox_cmds - structure for mailbox commands
122 * @cmd_count: Number of mailbox commands in mbox_cmd[]
123 * @mbox_cmd[]: Holds one or more mbox commands
125 * This structure used with ioctl ISST_IF_MBOX_COMMAND to send
126 * one or more mailbox commands to PUNIT. Here IOCTL return value
127 * indicates number of commands sent or error number if no commands have
130 struct isst_if_mbox_cmds {
132 struct isst_if_mbox_cmd mbox_cmd[1];
136 * struct isst_if_msr_cmd - Structure to define msr command
137 * @read_write: Value 0: Read, 1: Write
138 * @logical_cpu: Logical CPU number
140 * @data: For write operation, data to write, for read
143 * Structure to specify MSR command related to PUNIT.
145 struct isst_if_msr_cmd {
146 __u32 read_write; /* Read:0, Write:1 */
153 * struct isst_if_msr_cmds - structure for msr commands
154 * @cmd_count: Number of mailbox commands in msr_cmd[]
155 * @msr_cmd[]: Holds one or more msr commands
157 * This structure used with ioctl ISST_IF_MSR_COMMAND to send
158 * one or more MSR commands. IOCTL return value indicates number of
159 * commands sent or error number if no commands have been sent.
161 struct isst_if_msr_cmds {
163 struct isst_if_msr_cmd msr_cmd[1];
167 * struct isst_core_power - Structure to get/set core_power feature
168 * @get_set: 0: Get, 1: Set
169 * @socket_id: Socket/package id
170 * @power_domain: Power Domain id
171 * @enable: Feature enable status
172 * @priority_type: Priority type for the feature (ordered/proportional)
174 * Structure to get/set core_power feature state using IOCTL
175 * ISST_IF_CORE_POWER_STATE.
177 struct isst_core_power {
180 __u8 power_domain_id;
187 * struct isst_clos_param - Structure to get/set clos praram
188 * @get_set: 0: Get, 1: Set
189 * @socket_id: Socket/package id
190 * @power_domain: Power Domain id
191 * clos: Clos ID for the parameters
192 * min_freq_mhz: Minimum frequency in MHz
193 * max_freq_mhz: Maximum frequency in MHz
194 * prop_prio: Proportional priority from 0-15
196 * Structure to get/set per clos property using IOCTL
197 * ISST_IF_CLOS_PARAM.
199 struct isst_clos_param {
202 __u8 power_domain_id;
210 * struct isst_if_clos_assoc - Structure to assign clos to a CPU
211 * @socket_id: Socket/package id
212 * @power_domain: Power Domain id
213 * @logical_cpu: CPU number
214 * @clos: Clos ID to assign to the logical CPU
216 * Structure to get/set core_power feature.
218 struct isst_if_clos_assoc {
220 __u8 power_domain_id;
226 * struct isst_if_clos_assoc_cmds - Structure to assign clos to CPUs
227 * @cmd_count: Number of cmds (cpus) in this request
228 * @get_set: Request is for get or set
229 * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not
232 * Structure used to get/set associate CPUs to clos using IOCTL
233 * ISST_IF_CLOS_ASSOC.
235 struct isst_if_clos_assoc_cmds {
239 struct isst_if_clos_assoc assoc_info[1];
243 * struct isst_tpmi_instance_count - Get number of TPMI instances per socket
244 * @socket_id: Socket/package id
245 * @count: Number of instances
246 * @valid_mask: Mask of instances as there can be holes
248 * Structure used to get TPMI instances information using
249 * IOCTL ISST_IF_COUNT_TPMI_INSTANCES.
251 struct isst_tpmi_instance_count {
258 * struct isst_perf_level_info - Structure to get information on SST-PP levels
259 * @socket_id: Socket/package id
260 * @power_domain: Power Domain id
261 * @logical_cpu: CPU number
262 * @clos: Clos ID to assign to the logical CPU
263 * @max_level: Maximum performance level supported by the platform
264 * @feature_rev: The feature revision for SST-PP supported by the platform
265 * @level_mask: Mask of supported performance levels
266 * @current_level: Current performance level
267 * @feature_state: SST-BF and SST-TF (enabled/disabled) status at current level
268 * @locked: SST-PP performance level change is locked/unlocked
269 * @enabled: SST-PP feature is enabled or not
270 * @sst-tf_support: SST-TF support status at this level
271 * @sst-bf_support: SST-BF support status at this level
273 * Structure to get SST-PP details using IOCTL ISST_IF_PERF_LEVELS.
275 struct isst_perf_level_info {
277 __u8 power_domain_id;
290 * struct isst_perf_level_control - Structure to set SST-PP level
291 * @socket_id: Socket/package id
292 * @power_domain: Power Domain id
293 * @level: level to set
295 * Structure used change SST-PP level using IOCTL ISST_IF_PERF_SET_LEVEL.
297 struct isst_perf_level_control {
299 __u8 power_domain_id;
304 * struct isst_perf_feature_control - Structure to activate SST-BF/SST-TF
305 * @socket_id: Socket/package id
306 * @power_domain: Power Domain id
307 * @feature: bit 0 = SST-BF state, bit 1 = SST-TF state
309 * Structure used to enable SST-BF/SST-TF using IOCTL ISST_IF_PERF_SET_FEATURE.
311 struct isst_perf_feature_control {
313 __u8 power_domain_id;
317 #define TRL_MAX_BUCKETS 8
318 #define TRL_MAX_LEVELS 6
321 * struct isst_perf_level_data_info - Structure to get SST-PP level details
322 * @socket_id: Socket/package id
323 * @power_domain: Power Domain id
324 * @level: SST-PP level for which caller wants to get information
325 * @tdp_ratio: TDP Ratio
326 * @base_freq_mhz: Base frequency in MHz
327 * @base_freq_avx2_mhz: AVX2 Base frequency in MHz
328 * @base_freq_avx512_mhz: AVX512 base frequency in MHz
329 * @base_freq_amx_mhz: AMX base frequency in MHz
330 * @thermal_design_power_w: Thermal design (TDP) power
331 * @tjunction_max_c: Max junction temperature
332 * @max_memory_freq_mhz: Max memory frequency in MHz
333 * @cooling_type: Type of cooling is used
334 * @p0_freq_mhz: core maximum frequency
335 * @p1_freq_mhz: Core TDP frequency
336 * @pn_freq_mhz: Core maximum efficiency frequency
337 * @pm_freq_mhz: Core minimum frequency
338 * @p0_fabric_freq_mhz: Fabric (Uncore) maximum frequency
339 * @p1_fabric_freq_mhz: Fabric (Uncore) TDP frequency
340 * @pn_fabric_freq_mhz: Fabric (Uncore) minimum efficiency frequency
341 * @pm_fabric_freq_mhz: Fabric (Uncore) minimum frequency
342 * @max_buckets: Maximum trl buckets
343 * @max_trl_levels: Maximum trl levels
344 * @bucket_core_counts[TRL_MAX_BUCKETS]: Number of cores per bucket
345 * @trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS]: maximum frequency
346 * for a bucket and trl level
348 * Structure used to get information on frequencies and TDP for a SST-PP
349 * level using ISST_IF_GET_PERF_LEVEL_INFO.
351 struct isst_perf_level_data_info {
353 __u8 power_domain_id;
357 __u16 base_freq_avx2_mhz;
358 __u16 base_freq_avx512_mhz;
359 __u16 base_freq_amx_mhz;
360 __u16 thermal_design_power_w;
361 __u16 tjunction_max_c;
362 __u16 max_memory_freq_mhz;
368 __u16 p0_fabric_freq_mhz;
369 __u16 p1_fabric_freq_mhz;
370 __u16 pn_fabric_freq_mhz;
371 __u16 pm_fabric_freq_mhz;
373 __u16 max_trl_levels;
374 __u16 bucket_core_counts[TRL_MAX_BUCKETS];
375 __u16 trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS];
379 * struct isst_perf_level_cpu_mask - Structure to get SST-PP level CPU mask
380 * @socket_id: Socket/package id
381 * @power_domain: Power Domain id
382 * @level: SST-PP level for which caller wants to get information
383 * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not
384 * Linux CPU number. If 0 CPU buffer is copied to user space
385 * supplied cpu_buffer of size cpu_buffer_size. Punit
386 * cpu mask is copied to "mask" field.
387 * @mask: cpu mask for this PP level (punit CPU numbering)
388 * @cpu_buffer_size: size of cpu_buffer also used to return the copied CPU
390 * @cpu_buffer: Buffer to copy CPU mask when punit_cpu_map is 0
392 * Structure used to get cpumask for a SST-PP level using
393 * IOCTL ISST_IF_GET_PERF_LEVEL_CPU_MASK. Also used to get CPU mask for
394 * IOCTL ISST_IF_GET_BASE_FREQ_CPU_MASK for SST-BF.
396 struct isst_perf_level_cpu_mask {
398 __u8 power_domain_id;
402 __u16 cpu_buffer_size;
407 * struct isst_base_freq_info - Structure to get SST-BF frequencies
408 * @socket_id: Socket/package id
409 * @power_domain: Power Domain id
410 * @level: SST-PP level for which caller wants to get information
411 * @high_base_freq_mhz: High priority CPU base frequency
412 * @low_base_freq_mhz: Low priority CPU base frequency
413 * @tjunction_max_c: Max junction temperature
414 * @thermal_design_power_w: Thermal design power in watts
416 * Structure used to get SST-BF information using
417 * IOCTL ISST_IF_GET_BASE_FREQ_INFO.
419 struct isst_base_freq_info {
421 __u8 power_domain_id;
423 __u16 high_base_freq_mhz;
424 __u16 low_base_freq_mhz;
425 __u16 tjunction_max_c;
426 __u16 thermal_design_power_w;
430 * struct isst_turbo_freq_info - Structure to get SST-TF frequencies
431 * @socket_id: Socket/package id
432 * @power_domain: Power Domain id
433 * @level: SST-PP level for which caller wants to get information
434 * @max_clip_freqs: Maximum number of low priority core clipping frequencies
435 * @lp_clip_freq_mhz: Clip frequencies per trl level
436 * @bucket_core_counts: Maximum number of cores for a bucket
437 * @trl_freq_mhz: Frequencies per trl level for each bucket
439 * Structure used to get SST-TF information using
440 * IOCTL ISST_IF_GET_TURBO_FREQ_INFO.
442 struct isst_turbo_freq_info {
444 __u8 power_domain_id;
446 __u16 max_clip_freqs;
448 __u16 max_trl_levels;
449 __u16 lp_clip_freq_mhz[TRL_MAX_LEVELS];
450 __u16 bucket_core_counts[TRL_MAX_BUCKETS];
451 __u16 trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS];
454 #define ISST_IF_MAGIC 0xFE
455 #define ISST_IF_GET_PLATFORM_INFO _IOR(ISST_IF_MAGIC, 0, struct isst_if_platform_info *)
456 #define ISST_IF_GET_PHY_ID _IOWR(ISST_IF_MAGIC, 1, struct isst_if_cpu_map *)
457 #define ISST_IF_IO_CMD _IOW(ISST_IF_MAGIC, 2, struct isst_if_io_regs *)
458 #define ISST_IF_MBOX_COMMAND _IOWR(ISST_IF_MAGIC, 3, struct isst_if_mbox_cmds *)
459 #define ISST_IF_MSR_COMMAND _IOWR(ISST_IF_MAGIC, 4, struct isst_if_msr_cmds *)
461 #define ISST_IF_COUNT_TPMI_INSTANCES _IOR(ISST_IF_MAGIC, 5, struct isst_tpmi_instance_count *)
462 #define ISST_IF_CORE_POWER_STATE _IOWR(ISST_IF_MAGIC, 6, struct isst_core_power *)
463 #define ISST_IF_CLOS_PARAM _IOWR(ISST_IF_MAGIC, 7, struct isst_clos_param *)
464 #define ISST_IF_CLOS_ASSOC _IOWR(ISST_IF_MAGIC, 8, struct isst_if_clos_assoc_cmds *)
466 #define ISST_IF_PERF_LEVELS _IOWR(ISST_IF_MAGIC, 9, struct isst_perf_level_info *)
467 #define ISST_IF_PERF_SET_LEVEL _IOW(ISST_IF_MAGIC, 10, struct isst_perf_level_control *)
468 #define ISST_IF_PERF_SET_FEATURE _IOW(ISST_IF_MAGIC, 11, struct isst_perf_feature_control *)
469 #define ISST_IF_GET_PERF_LEVEL_INFO _IOR(ISST_IF_MAGIC, 12, struct isst_perf_level_data_info *)
470 #define ISST_IF_GET_PERF_LEVEL_CPU_MASK _IOR(ISST_IF_MAGIC, 13, struct isst_perf_level_cpu_mask *)
471 #define ISST_IF_GET_BASE_FREQ_INFO _IOR(ISST_IF_MAGIC, 14, struct isst_base_freq_info *)
472 #define ISST_IF_GET_BASE_FREQ_CPU_MASK _IOR(ISST_IF_MAGIC, 15, struct isst_perf_level_cpu_mask *)
473 #define ISST_IF_GET_TURBO_FREQ_INFO _IOR(ISST_IF_MAGIC, 16, struct isst_turbo_freq_info *)