isst_if.h 5.3 KB

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