xref: /OK3568_Linux_fs/kernel/include/uapi/linux/isst_if.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Intel Speed Select Interface: OS to hardware Interface
4*4882a593Smuzhiyun  * Copyright (c) 2019, Intel Corporation.
5*4882a593Smuzhiyun  * All rights reserved.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #ifndef __ISST_IF_H
11*4882a593Smuzhiyun #define __ISST_IF_H
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <linux/types.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /**
16*4882a593Smuzhiyun  * struct isst_if_platform_info - Define platform information
17*4882a593Smuzhiyun  * @api_version:	Version of the firmware document, which this driver
18*4882a593Smuzhiyun  *			can communicate
19*4882a593Smuzhiyun  * @driver_version:	Driver version, which will help user to send right
20*4882a593Smuzhiyun  *			commands. Even if the firmware is capable, driver may
21*4882a593Smuzhiyun  *			not be ready
22*4882a593Smuzhiyun  * @max_cmds_per_ioctl:	Returns the maximum number of commands driver will
23*4882a593Smuzhiyun  *			accept in a single ioctl
24*4882a593Smuzhiyun  * @mbox_supported:	Support of mail box interface
25*4882a593Smuzhiyun  * @mmio_supported:	Support of mmio interface for core-power feature
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * Used to return output of IOCTL ISST_IF_GET_PLATFORM_INFO. This
28*4882a593Smuzhiyun  * information can be used by the user space, to get the driver, firmware
29*4882a593Smuzhiyun  * support and also number of commands to send in a single IOCTL request.
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun struct isst_if_platform_info {
32*4882a593Smuzhiyun 	__u16 api_version;
33*4882a593Smuzhiyun 	__u16 driver_version;
34*4882a593Smuzhiyun 	__u16 max_cmds_per_ioctl;
35*4882a593Smuzhiyun 	__u8 mbox_supported;
36*4882a593Smuzhiyun 	__u8 mmio_supported;
37*4882a593Smuzhiyun };
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun /**
40*4882a593Smuzhiyun  * struct isst_if_cpu_map - CPU mapping between logical and physical CPU
41*4882a593Smuzhiyun  * @logical_cpu:	Linux logical CPU number
42*4882a593Smuzhiyun  * @physical_cpu:	PUNIT CPU number
43*4882a593Smuzhiyun  *
44*4882a593Smuzhiyun  * Used to convert from Linux logical CPU to PUNIT CPU numbering scheme.
45*4882a593Smuzhiyun  * The PUNIT CPU number is different than APIC ID based CPU numbering.
46*4882a593Smuzhiyun  */
47*4882a593Smuzhiyun struct isst_if_cpu_map {
48*4882a593Smuzhiyun 	__u32 logical_cpu;
49*4882a593Smuzhiyun 	__u32 physical_cpu;
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun /**
53*4882a593Smuzhiyun  * struct isst_if_cpu_maps - structure for CPU map IOCTL
54*4882a593Smuzhiyun  * @cmd_count:	Number of CPU mapping command in cpu_map[]
55*4882a593Smuzhiyun  * @cpu_map[]:	Holds one or more CPU map data structure
56*4882a593Smuzhiyun  *
57*4882a593Smuzhiyun  * This structure used with ioctl ISST_IF_GET_PHY_ID to send
58*4882a593Smuzhiyun  * one or more CPU mapping commands. Here IOCTL return value indicates
59*4882a593Smuzhiyun  * number of commands sent or error number if no commands have been sent.
60*4882a593Smuzhiyun  */
61*4882a593Smuzhiyun struct isst_if_cpu_maps {
62*4882a593Smuzhiyun 	__u32 cmd_count;
63*4882a593Smuzhiyun 	struct isst_if_cpu_map cpu_map[1];
64*4882a593Smuzhiyun };
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /**
67*4882a593Smuzhiyun  * struct isst_if_io_reg - Read write PUNIT IO register
68*4882a593Smuzhiyun  * @read_write:		Value 0: Read, 1: Write
69*4882a593Smuzhiyun  * @logical_cpu:	Logical CPU number to get target PCI device.
70*4882a593Smuzhiyun  * @reg:		PUNIT register offset
71*4882a593Smuzhiyun  * @value:		For write operation value to write and for
72*4882a593Smuzhiyun  *			read placeholder read value
73*4882a593Smuzhiyun  *
74*4882a593Smuzhiyun  * Structure to specify read/write data to PUNIT registers.
75*4882a593Smuzhiyun  */
76*4882a593Smuzhiyun struct isst_if_io_reg {
77*4882a593Smuzhiyun 	__u32 read_write; /* Read:0, Write:1 */
78*4882a593Smuzhiyun 	__u32 logical_cpu;
79*4882a593Smuzhiyun 	__u32 reg;
80*4882a593Smuzhiyun 	__u32 value;
81*4882a593Smuzhiyun };
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun /**
84*4882a593Smuzhiyun  * struct isst_if_io_regs - structure for IO register commands
85*4882a593Smuzhiyun  * @cmd_count:	Number of io reg commands in io_reg[]
86*4882a593Smuzhiyun  * @io_reg[]:	Holds one or more io_reg command structure
87*4882a593Smuzhiyun  *
88*4882a593Smuzhiyun  * This structure used with ioctl ISST_IF_IO_CMD to send
89*4882a593Smuzhiyun  * one or more read/write commands to PUNIT. Here IOCTL return value
90*4882a593Smuzhiyun  * indicates number of requests sent or error number if no requests have
91*4882a593Smuzhiyun  * been sent.
92*4882a593Smuzhiyun  */
93*4882a593Smuzhiyun struct isst_if_io_regs {
94*4882a593Smuzhiyun 	__u32 req_count;
95*4882a593Smuzhiyun 	struct isst_if_io_reg io_reg[1];
96*4882a593Smuzhiyun };
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun /**
99*4882a593Smuzhiyun  * struct isst_if_mbox_cmd - Structure to define mail box command
100*4882a593Smuzhiyun  * @logical_cpu:	Logical CPU number to get target PCI device
101*4882a593Smuzhiyun  * @parameter:		Mailbox parameter value
102*4882a593Smuzhiyun  * @req_data:		Request data for the mailbox
103*4882a593Smuzhiyun  * @resp_data:		Response data for mailbox command response
104*4882a593Smuzhiyun  * @command:		Mailbox command value
105*4882a593Smuzhiyun  * @sub_command:	Mailbox sub command value
106*4882a593Smuzhiyun  * @reserved:		Unused, set to 0
107*4882a593Smuzhiyun  *
108*4882a593Smuzhiyun  * Structure to specify mailbox command to be sent to PUNIT.
109*4882a593Smuzhiyun  */
110*4882a593Smuzhiyun struct isst_if_mbox_cmd {
111*4882a593Smuzhiyun 	__u32 logical_cpu;
112*4882a593Smuzhiyun 	__u32 parameter;
113*4882a593Smuzhiyun 	__u32 req_data;
114*4882a593Smuzhiyun 	__u32 resp_data;
115*4882a593Smuzhiyun 	__u16 command;
116*4882a593Smuzhiyun 	__u16 sub_command;
117*4882a593Smuzhiyun 	__u32 reserved;
118*4882a593Smuzhiyun };
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun /**
121*4882a593Smuzhiyun  * struct isst_if_mbox_cmds - structure for mailbox commands
122*4882a593Smuzhiyun  * @cmd_count:	Number of mailbox commands in mbox_cmd[]
123*4882a593Smuzhiyun  * @mbox_cmd[]:	Holds one or more mbox commands
124*4882a593Smuzhiyun  *
125*4882a593Smuzhiyun  * This structure used with ioctl ISST_IF_MBOX_COMMAND to send
126*4882a593Smuzhiyun  * one or more mailbox commands to PUNIT. Here IOCTL return value
127*4882a593Smuzhiyun  * indicates number of commands sent or error number if no commands have
128*4882a593Smuzhiyun  * been sent.
129*4882a593Smuzhiyun  */
130*4882a593Smuzhiyun struct isst_if_mbox_cmds {
131*4882a593Smuzhiyun 	__u32 cmd_count;
132*4882a593Smuzhiyun 	struct isst_if_mbox_cmd mbox_cmd[1];
133*4882a593Smuzhiyun };
134*4882a593Smuzhiyun 
135*4882a593Smuzhiyun /**
136*4882a593Smuzhiyun  * struct isst_if_msr_cmd - Structure to define msr command
137*4882a593Smuzhiyun  * @read_write:		Value 0: Read, 1: Write
138*4882a593Smuzhiyun  * @logical_cpu:	Logical CPU number
139*4882a593Smuzhiyun  * @msr:		MSR number
140*4882a593Smuzhiyun  * @data:		For write operation, data to write, for read
141*4882a593Smuzhiyun  *			place holder
142*4882a593Smuzhiyun  *
143*4882a593Smuzhiyun  * Structure to specify MSR command related to PUNIT.
144*4882a593Smuzhiyun  */
145*4882a593Smuzhiyun struct isst_if_msr_cmd {
146*4882a593Smuzhiyun 	__u32 read_write; /* Read:0, Write:1 */
147*4882a593Smuzhiyun 	__u32 logical_cpu;
148*4882a593Smuzhiyun 	__u64 msr;
149*4882a593Smuzhiyun 	__u64 data;
150*4882a593Smuzhiyun };
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun /**
153*4882a593Smuzhiyun  * struct isst_if_msr_cmds - structure for msr commands
154*4882a593Smuzhiyun  * @cmd_count:	Number of mailbox commands in msr_cmd[]
155*4882a593Smuzhiyun  * @msr_cmd[]:	Holds one or more msr commands
156*4882a593Smuzhiyun  *
157*4882a593Smuzhiyun  * This structure used with ioctl ISST_IF_MSR_COMMAND to send
158*4882a593Smuzhiyun  * one or more MSR commands. IOCTL return value indicates number of
159*4882a593Smuzhiyun  * commands sent or error number if no commands have been sent.
160*4882a593Smuzhiyun  */
161*4882a593Smuzhiyun struct isst_if_msr_cmds {
162*4882a593Smuzhiyun 	__u32 cmd_count;
163*4882a593Smuzhiyun 	struct isst_if_msr_cmd msr_cmd[1];
164*4882a593Smuzhiyun };
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun #define ISST_IF_MAGIC			0xFE
167*4882a593Smuzhiyun #define ISST_IF_GET_PLATFORM_INFO	_IOR(ISST_IF_MAGIC, 0, struct isst_if_platform_info *)
168*4882a593Smuzhiyun #define ISST_IF_GET_PHY_ID		_IOWR(ISST_IF_MAGIC, 1, struct isst_if_cpu_map *)
169*4882a593Smuzhiyun #define ISST_IF_IO_CMD		_IOW(ISST_IF_MAGIC, 2, struct isst_if_io_regs *)
170*4882a593Smuzhiyun #define ISST_IF_MBOX_COMMAND	_IOWR(ISST_IF_MAGIC, 3, struct isst_if_mbox_cmds *)
171*4882a593Smuzhiyun #define ISST_IF_MSR_COMMAND	_IOWR(ISST_IF_MAGIC, 4, struct isst_if_msr_cmds *)
172*4882a593Smuzhiyun #endif
173