Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Intel Speed Select Interface: Drivers Internal defines
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_COMMON_H
0011 #define __ISST_IF_COMMON_H
0012 
0013 #define PCI_DEVICE_ID_INTEL_RAPL_PRIO_DEVID_0   0x3451
0014 #define PCI_DEVICE_ID_INTEL_CFG_MBOX_DEVID_0    0x3459
0015 
0016 #define PCI_DEVICE_ID_INTEL_RAPL_PRIO_DEVID_1   0x3251
0017 #define PCI_DEVICE_ID_INTEL_CFG_MBOX_DEVID_1    0x3259
0018 
0019 /*
0020  * Validate maximum commands in a single request.
0021  * This is enough to handle command to every core in one ioctl, or all
0022  * possible message id to one CPU. Limit is also helpful for resonse time
0023  * per IOCTL request, as PUNIT may take different times to process each
0024  * request and may hold for long for too many commands.
0025  */
0026 #define ISST_IF_CMD_LIMIT   64
0027 
0028 #define ISST_IF_API_VERSION 0x01
0029 #define ISST_IF_DRIVER_VERSION  0x01
0030 
0031 #define ISST_IF_DEV_MBOX    0
0032 #define ISST_IF_DEV_MMIO    1
0033 #define ISST_IF_DEV_MAX     2
0034 
0035 /**
0036  * struct isst_if_cmd_cb - Used to register a IOCTL handler
0037  * @registered: Used by the common code to store registry. Caller don't
0038  *      to touch this field
0039  * @cmd_size:   The command size of the individual command in IOCTL
0040  * @offset: Offset to the first valid member in command structure.
0041  *      This will be the offset of the start of the command
0042  *      after command count field
0043  * @cmd_callback: Callback function to handle IOCTL. The callback has the
0044  *      command pointer with data for command. There is a pointer
0045  *      called write_only, which when set, will not copy the
0046  *      response to user ioctl buffer. The "resume" argument
0047  *      can be used to avoid storing the command for replay
0048  *      during system resume
0049  *
0050  * This structure is used to register an handler for IOCTL. To avoid
0051  * code duplication common code handles all the IOCTL command read/write
0052  * including handling multiple command in single IOCTL. The caller just
0053  * need to execute a command via the registered callback.
0054  */
0055 struct isst_if_cmd_cb {
0056     int registered;
0057     int cmd_size;
0058     int offset;
0059     struct module *owner;
0060     long (*cmd_callback)(u8 *ptr, int *write_only, int resume);
0061 };
0062 
0063 /* Internal interface functions */
0064 int isst_if_cdev_register(int type, struct isst_if_cmd_cb *cb);
0065 void isst_if_cdev_unregister(int type);
0066 struct pci_dev *isst_if_get_pci_dev(int cpu, int bus, int dev, int fn);
0067 bool isst_if_mbox_cmd_set_req(struct isst_if_mbox_cmd *mbox_cmd);
0068 bool isst_if_mbox_cmd_invalid(struct isst_if_mbox_cmd *cmd);
0069 int isst_store_cmd(int cmd, int sub_command, u32 cpu, int mbox_cmd,
0070            u32 param, u64 data);
0071 void isst_resume_common(void);
0072 #endif