Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * Intel Speed Select Interface: OS to hardware Interface
0004  * Copyright (c) 2019, Intel Corporation.
0005  * All rights reserved.
0006  *
0007  * Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
0008  */
0009 
0010 #ifndef __ISST_IF_H
0011 #define __ISST_IF_H
0012 
0013 #include <linux/types.h>
0014 
0015 /**
0016  * struct isst_if_platform_info - Define platform information
0017  * @api_version:    Version of the firmware document, which this driver
0018  *          can communicate
0019  * @driver_version: Driver version, which will help user to send right
0020  *          commands. Even if the firmware is capable, driver may
0021  *          not be ready
0022  * @max_cmds_per_ioctl: Returns the maximum number of commands driver will
0023  *          accept in a single ioctl
0024  * @mbox_supported: Support of mail box interface
0025  * @mmio_supported: Support of mmio interface for core-power feature
0026  *
0027  * Used to return output of IOCTL ISST_IF_GET_PLATFORM_INFO. This
0028  * information can be used by the user space, to get the driver, firmware
0029  * support and also number of commands to send in a single IOCTL request.
0030  */
0031 struct isst_if_platform_info {
0032     __u16 api_version;
0033     __u16 driver_version;
0034     __u16 max_cmds_per_ioctl;
0035     __u8 mbox_supported;
0036     __u8 mmio_supported;
0037 };
0038 
0039 /**
0040  * struct isst_if_cpu_map - CPU mapping between logical and physical CPU
0041  * @logical_cpu:    Linux logical CPU number
0042  * @physical_cpu:   PUNIT CPU number
0043  *
0044  * Used to convert from Linux logical CPU to PUNIT CPU numbering scheme.
0045  * The PUNIT CPU number is different than APIC ID based CPU numbering.
0046  */
0047 struct isst_if_cpu_map {
0048     __u32 logical_cpu;
0049     __u32 physical_cpu;
0050 };
0051 
0052 /**
0053  * struct isst_if_cpu_maps - structure for CPU map IOCTL
0054  * @cmd_count:  Number of CPU mapping command in cpu_map[]
0055  * @cpu_map[]:  Holds one or more CPU map data structure
0056  *
0057  * This structure used with ioctl ISST_IF_GET_PHY_ID to send
0058  * one or more CPU mapping commands. Here IOCTL return value indicates
0059  * number of commands sent or error number if no commands have been sent.
0060  */
0061 struct isst_if_cpu_maps {
0062     __u32 cmd_count;
0063     struct isst_if_cpu_map cpu_map[1];
0064 };
0065 
0066 /**
0067  * struct isst_if_io_reg - Read write PUNIT IO register
0068  * @read_write:     Value 0: Read, 1: Write
0069  * @logical_cpu:    Logical CPU number to get target PCI device.
0070  * @reg:        PUNIT register offset
0071  * @value:      For write operation value to write and for
0072  *          read placeholder read value
0073  *
0074  * Structure to specify read/write data to PUNIT registers.
0075  */
0076 struct isst_if_io_reg {
0077     __u32 read_write; /* Read:0, Write:1 */
0078     __u32 logical_cpu;
0079     __u32 reg;
0080     __u32 value;
0081 };
0082 
0083 /**
0084  * struct isst_if_io_regs - structure for IO register commands
0085  * @cmd_count:  Number of io reg commands in io_reg[]
0086  * @io_reg[]:   Holds one or more io_reg command structure
0087  *
0088  * This structure used with ioctl ISST_IF_IO_CMD to send
0089  * one or more read/write commands to PUNIT. Here IOCTL return value
0090  * indicates number of requests sent or error number if no requests have
0091  * been sent.
0092  */
0093 struct isst_if_io_regs {
0094     __u32 req_count;
0095     struct isst_if_io_reg io_reg[1];
0096 };
0097 
0098 /**
0099  * struct isst_if_mbox_cmd - Structure to define mail box command
0100  * @logical_cpu:    Logical CPU number to get target PCI device
0101  * @parameter:      Mailbox parameter value
0102  * @req_data:       Request data for the mailbox
0103  * @resp_data:      Response data for mailbox command response
0104  * @command:        Mailbox command value
0105  * @sub_command:    Mailbox sub command value
0106  * @reserved:       Unused, set to 0
0107  *
0108  * Structure to specify mailbox command to be sent to PUNIT.
0109  */
0110 struct isst_if_mbox_cmd {
0111     __u32 logical_cpu;
0112     __u32 parameter;
0113     __u32 req_data;
0114     __u32 resp_data;
0115     __u16 command;
0116     __u16 sub_command;
0117     __u32 reserved;
0118 };
0119 
0120 /**
0121  * struct isst_if_mbox_cmds - structure for mailbox commands
0122  * @cmd_count:  Number of mailbox commands in mbox_cmd[]
0123  * @mbox_cmd[]: Holds one or more mbox commands
0124  *
0125  * This structure used with ioctl ISST_IF_MBOX_COMMAND to send
0126  * one or more mailbox commands to PUNIT. Here IOCTL return value
0127  * indicates number of commands sent or error number if no commands have
0128  * been sent.
0129  */
0130 struct isst_if_mbox_cmds {
0131     __u32 cmd_count;
0132     struct isst_if_mbox_cmd mbox_cmd[1];
0133 };
0134 
0135 /**
0136  * struct isst_if_msr_cmd - Structure to define msr command
0137  * @read_write:     Value 0: Read, 1: Write
0138  * @logical_cpu:    Logical CPU number
0139  * @msr:        MSR number
0140  * @data:       For write operation, data to write, for read
0141  *          place holder
0142  *
0143  * Structure to specify MSR command related to PUNIT.
0144  */
0145 struct isst_if_msr_cmd {
0146     __u32 read_write; /* Read:0, Write:1 */
0147     __u32 logical_cpu;
0148     __u64 msr;
0149     __u64 data;
0150 };
0151 
0152 /**
0153  * struct isst_if_msr_cmds - structure for msr commands
0154  * @cmd_count:  Number of mailbox commands in msr_cmd[]
0155  * @msr_cmd[]:  Holds one or more msr commands
0156  *
0157  * This structure used with ioctl ISST_IF_MSR_COMMAND to send
0158  * one or more MSR commands. IOCTL return value indicates number of
0159  * commands sent or error number if no commands have been sent.
0160  */
0161 struct isst_if_msr_cmds {
0162     __u32 cmd_count;
0163     struct isst_if_msr_cmd msr_cmd[1];
0164 };
0165 
0166 #define ISST_IF_MAGIC           0xFE
0167 #define ISST_IF_GET_PLATFORM_INFO   _IOR(ISST_IF_MAGIC, 0, struct isst_if_platform_info *)
0168 #define ISST_IF_GET_PHY_ID      _IOWR(ISST_IF_MAGIC, 1, struct isst_if_cpu_map *)
0169 #define ISST_IF_IO_CMD      _IOW(ISST_IF_MAGIC, 2, struct isst_if_io_regs *)
0170 #define ISST_IF_MBOX_COMMAND    _IOWR(ISST_IF_MAGIC, 3, struct isst_if_mbox_cmds *)
0171 #define ISST_IF_MSR_COMMAND _IOWR(ISST_IF_MAGIC, 4, struct isst_if_msr_cmds *)
0172 #endif