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