1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Intel Speed Select Interface: Drivers Internal defines 4 * Copyright (c) 2019, Intel Corporation. 5 * All rights reserved. 6 * 7 * Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> 8 */ 9 10 #ifndef __ISST_IF_COMMON_H 11 #define __ISST_IF_COMMON_H 12 13 #define INTEL_RAPL_PRIO_DEVID_0 0x3451 14 #define INTEL_CFG_MBOX_DEVID_0 0x3459 15 16 /* 17 * Validate maximum commands in a single request. 18 * This is enough to handle command to every core in one ioctl, or all 19 * possible message id to one CPU. Limit is also helpful for resonse time 20 * per IOCTL request, as PUNIT may take different times to process each 21 * request and may hold for long for too many commands. 22 */ 23 #define ISST_IF_CMD_LIMIT 64 24 25 #define ISST_IF_API_VERSION 0x01 26 #define ISST_IF_DRIVER_VERSION 0x01 27 28 #define ISST_IF_DEV_MBOX 0 29 #define ISST_IF_DEV_MMIO 1 30 #define ISST_IF_DEV_MAX 2 31 32 /** 33 * struct isst_if_cmd_cb - Used to register a IOCTL handler 34 * @registered: Used by the common code to store registry. Caller don't 35 * to touch this field 36 * @cmd_size: The command size of the individual command in IOCTL 37 * @offset: Offset to the first valid member in command structure. 38 * This will be the offset of the start of the command 39 * after command count field 40 * @cmd_callback: Callback function to handle IOCTL. The callback has the 41 * command pointer with data for command. There is a pointer 42 * called write_only, which when set, will not copy the 43 * response to user ioctl buffer. The "resume" argument 44 * can be used to avoid storing the command for replay 45 * during system resume 46 * 47 * This structure is used to register an handler for IOCTL. To avoid 48 * code duplication common code handles all the IOCTL command read/write 49 * including handling multiple command in single IOCTL. The caller just 50 * need to execute a command via the registered callback. 51 */ 52 struct isst_if_cmd_cb { 53 int registered; 54 int cmd_size; 55 int offset; 56 struct module *owner; 57 long (*cmd_callback)(u8 *ptr, int *write_only, int resume); 58 }; 59 60 /* Internal interface functions */ 61 int isst_if_cdev_register(int type, struct isst_if_cmd_cb *cb); 62 void isst_if_cdev_unregister(int type); 63 struct pci_dev *isst_if_get_pci_dev(int cpu, int bus, int dev, int fn); 64 bool isst_if_mbox_cmd_set_req(struct isst_if_mbox_cmd *mbox_cmd); 65 bool isst_if_mbox_cmd_invalid(struct isst_if_mbox_cmd *cmd); 66 int isst_store_cmd(int cmd, int sub_command, u32 cpu, int mbox_cmd, 67 u32 param, u64 data); 68 void isst_resume_common(void); 69 #endif