Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * ISHTP bus layer messages handling
0004  *
0005  * Copyright (c) 2003-2016, Intel Corporation.
0006  */
0007 
0008 #ifndef _ISHTP_HBM_H_
0009 #define _ISHTP_HBM_H_
0010 
0011 #include <linux/uuid.h>
0012 
0013 struct ishtp_device;
0014 struct ishtp_msg_hdr;
0015 struct ishtp_cl;
0016 
0017 /*
0018  * Timeouts in Seconds
0019  */
0020 #define ISHTP_INTEROP_TIMEOUT       7 /* Timeout on ready message */
0021 
0022 #define ISHTP_CL_CONNECT_TIMEOUT    15 /* HPS: Client Connect Timeout */
0023 
0024 /*
0025  * ISHTP Version
0026  */
0027 #define HBM_MINOR_VERSION       0
0028 #define HBM_MAJOR_VERSION       1
0029 
0030 /* Host bus message command opcode */
0031 #define ISHTP_HBM_CMD_OP_MSK        0x7f
0032 /* Host bus message command RESPONSE */
0033 #define ISHTP_HBM_CMD_RES_MSK       0x80
0034 
0035 /*
0036  * ISHTP Bus Message Command IDs
0037  */
0038 #define HOST_START_REQ_CMD      0x01
0039 #define HOST_START_RES_CMD      0x81
0040 
0041 #define HOST_STOP_REQ_CMD       0x02
0042 #define HOST_STOP_RES_CMD       0x82
0043 
0044 #define FW_STOP_REQ_CMD         0x03
0045 
0046 #define HOST_ENUM_REQ_CMD       0x04
0047 #define HOST_ENUM_RES_CMD       0x84
0048 
0049 #define HOST_CLIENT_PROPERTIES_REQ_CMD  0x05
0050 #define HOST_CLIENT_PROPERTIES_RES_CMD  0x85
0051 
0052 #define CLIENT_CONNECT_REQ_CMD      0x06
0053 #define CLIENT_CONNECT_RES_CMD      0x86
0054 
0055 #define CLIENT_DISCONNECT_REQ_CMD   0x07
0056 #define CLIENT_DISCONNECT_RES_CMD   0x87
0057 
0058 #define ISHTP_FLOW_CONTROL_CMD      0x08
0059 
0060 #define DMA_BUFFER_ALLOC_NOTIFY     0x11
0061 #define DMA_BUFFER_ALLOC_RESPONSE   0x91
0062 
0063 #define DMA_XFER            0x12
0064 #define DMA_XFER_ACK            0x92
0065 
0066 /*
0067  * ISHTP Stop Reason
0068  * used by hbm_host_stop_request.reason
0069  */
0070 #define DRIVER_STOP_REQUEST     0x00
0071 
0072 /*
0073  * ISHTP BUS Interface Section
0074  */
0075 struct ishtp_msg_hdr {
0076     uint32_t fw_addr:8;
0077     uint32_t host_addr:8;
0078     uint32_t length:9;
0079     uint32_t reserved:6;
0080     uint32_t msg_complete:1;
0081 } __packed;
0082 
0083 struct ishtp_bus_message {
0084     uint8_t hbm_cmd;
0085     uint8_t data[];
0086 } __packed;
0087 
0088 /**
0089  * struct hbm_cl_cmd - client specific host bus command
0090  *  CONNECT, DISCONNECT, and FlOW CONTROL
0091  *
0092  * @hbm_cmd - bus message command header
0093  * @fw_addr - address of the fw client
0094  * @host_addr - address of the client in the driver
0095  * @data
0096  */
0097 struct ishtp_hbm_cl_cmd {
0098     uint8_t hbm_cmd;
0099     uint8_t fw_addr;
0100     uint8_t host_addr;
0101     uint8_t data;
0102 };
0103 
0104 struct hbm_version {
0105     uint8_t minor_version;
0106     uint8_t major_version;
0107 } __packed;
0108 
0109 struct hbm_host_version_request {
0110     uint8_t hbm_cmd;
0111     uint8_t reserved;
0112     struct hbm_version host_version;
0113 } __packed;
0114 
0115 struct hbm_host_version_response {
0116     uint8_t hbm_cmd;
0117     uint8_t host_version_supported;
0118     struct hbm_version fw_max_version;
0119 } __packed;
0120 
0121 struct hbm_host_stop_request {
0122     uint8_t hbm_cmd;
0123     uint8_t reason;
0124     uint8_t reserved[2];
0125 } __packed;
0126 
0127 struct hbm_host_stop_response {
0128     uint8_t hbm_cmd;
0129     uint8_t reserved[3];
0130 } __packed;
0131 
0132 struct hbm_host_enum_request {
0133     uint8_t hbm_cmd;
0134     uint8_t reserved[3];
0135 } __packed;
0136 
0137 struct hbm_host_enum_response {
0138     uint8_t hbm_cmd;
0139     uint8_t reserved[3];
0140     uint8_t valid_addresses[32];
0141 } __packed;
0142 
0143 struct ishtp_client_properties {
0144     guid_t protocol_name;
0145     uint8_t protocol_version;
0146     uint8_t max_number_of_connections;
0147     uint8_t fixed_address;
0148     uint8_t single_recv_buf;
0149     uint32_t max_msg_length;
0150     uint8_t dma_hdr_len;
0151 #define ISHTP_CLIENT_DMA_ENABLED    0x80
0152     uint8_t reserved4;
0153     uint8_t reserved5;
0154     uint8_t reserved6;
0155 } __packed;
0156 
0157 struct hbm_props_request {
0158     uint8_t hbm_cmd;
0159     uint8_t address;
0160     uint8_t reserved[2];
0161 } __packed;
0162 
0163 struct hbm_props_response {
0164     uint8_t hbm_cmd;
0165     uint8_t address;
0166     uint8_t status;
0167     uint8_t reserved[1];
0168     struct ishtp_client_properties client_properties;
0169 } __packed;
0170 
0171 /**
0172  * struct hbm_client_connect_request - connect/disconnect request
0173  *
0174  * @hbm_cmd - bus message command header
0175  * @fw_addr - address of the fw client
0176  * @host_addr - address of the client in the driver
0177  * @reserved
0178  */
0179 struct hbm_client_connect_request {
0180     uint8_t hbm_cmd;
0181     uint8_t fw_addr;
0182     uint8_t host_addr;
0183     uint8_t reserved;
0184 } __packed;
0185 
0186 /**
0187  * struct hbm_client_connect_response - connect/disconnect response
0188  *
0189  * @hbm_cmd - bus message command header
0190  * @fw_addr - address of the fw client
0191  * @host_addr - address of the client in the driver
0192  * @status - status of the request
0193  */
0194 struct hbm_client_connect_response {
0195     uint8_t hbm_cmd;
0196     uint8_t fw_addr;
0197     uint8_t host_addr;
0198     uint8_t status;
0199 } __packed;
0200 
0201 
0202 #define ISHTP_FC_MESSAGE_RESERVED_LENGTH        5
0203 
0204 struct hbm_flow_control {
0205     uint8_t hbm_cmd;
0206     uint8_t fw_addr;
0207     uint8_t host_addr;
0208     uint8_t reserved[ISHTP_FC_MESSAGE_RESERVED_LENGTH];
0209 } __packed;
0210 
0211 struct dma_alloc_notify {
0212     uint8_t hbm;
0213     uint8_t status;
0214     uint8_t reserved[2];
0215     uint32_t buf_size;
0216     uint64_t buf_address;
0217     /* [...] May come more size/address pairs */
0218 } __packed;
0219 
0220 struct dma_xfer_hbm {
0221     uint8_t hbm;
0222     uint8_t fw_client_id;
0223     uint8_t host_client_id;
0224     uint8_t reserved;
0225     uint64_t msg_addr;
0226     uint32_t msg_length;
0227     uint32_t reserved2;
0228 } __packed;
0229 
0230 /* System state */
0231 #define ISHTP_SYSTEM_STATE_CLIENT_ADDR      13
0232 
0233 #define SYSTEM_STATE_SUBSCRIBE          0x1
0234 #define SYSTEM_STATE_STATUS         0x2
0235 #define SYSTEM_STATE_QUERY_SUBSCRIBERS      0x3
0236 #define SYSTEM_STATE_STATE_CHANGE_REQ       0x4
0237 /*indicates suspend and resume states*/
0238 #define CONNECTED_STANDBY_STATE_BIT     (1<<0)
0239 #define SUSPEND_STATE_BIT           (1<<1)
0240 
0241 struct ish_system_states_header {
0242     uint32_t cmd;
0243     uint32_t cmd_status;    /*responses will have this set*/
0244 } __packed;
0245 
0246 struct ish_system_states_subscribe {
0247     struct ish_system_states_header hdr;
0248     uint32_t states;
0249 } __packed;
0250 
0251 struct ish_system_states_status {
0252     struct ish_system_states_header hdr;
0253     uint32_t supported_states;
0254     uint32_t states_status;
0255 } __packed;
0256 
0257 struct ish_system_states_query_subscribers {
0258     struct ish_system_states_header hdr;
0259 } __packed;
0260 
0261 struct ish_system_states_state_change_req {
0262     struct ish_system_states_header hdr;
0263     uint32_t requested_states;
0264     uint32_t states_status;
0265 } __packed;
0266 
0267 /**
0268  * enum ishtp_hbm_state - host bus message protocol state
0269  *
0270  * @ISHTP_HBM_IDLE : protocol not started
0271  * @ISHTP_HBM_START : start request message was sent
0272  * @ISHTP_HBM_ENUM_CLIENTS : enumeration request was sent
0273  * @ISHTP_HBM_CLIENT_PROPERTIES : acquiring clients properties
0274  */
0275 enum ishtp_hbm_state {
0276     ISHTP_HBM_IDLE = 0,
0277     ISHTP_HBM_START,
0278     ISHTP_HBM_STARTED,
0279     ISHTP_HBM_ENUM_CLIENTS,
0280     ISHTP_HBM_CLIENT_PROPERTIES,
0281     ISHTP_HBM_WORKING,
0282     ISHTP_HBM_STOPPED,
0283 };
0284 
0285 static inline void ishtp_hbm_hdr(struct ishtp_msg_hdr *hdr, size_t length)
0286 {
0287     hdr->host_addr = 0;
0288     hdr->fw_addr = 0;
0289     hdr->length = length;
0290     hdr->msg_complete = 1;
0291     hdr->reserved = 0;
0292 }
0293 
0294 int ishtp_hbm_start_req(struct ishtp_device *dev);
0295 int ishtp_hbm_start_wait(struct ishtp_device *dev);
0296 int ishtp_hbm_cl_flow_control_req(struct ishtp_device *dev,
0297                   struct ishtp_cl *cl);
0298 int ishtp_hbm_cl_disconnect_req(struct ishtp_device *dev, struct ishtp_cl *cl);
0299 int ishtp_hbm_cl_connect_req(struct ishtp_device *dev, struct ishtp_cl *cl);
0300 void ishtp_hbm_enum_clients_req(struct ishtp_device *dev);
0301 void bh_hbm_work_fn(struct work_struct *work);
0302 void recv_hbm(struct ishtp_device *dev, struct ishtp_msg_hdr *ishtp_hdr);
0303 void recv_fixed_cl_msg(struct ishtp_device *dev,
0304     struct ishtp_msg_hdr *ishtp_hdr);
0305 void ishtp_hbm_dispatch(struct ishtp_device *dev,
0306     struct ishtp_bus_message *hdr);
0307 
0308 void ishtp_query_subscribers(struct ishtp_device *dev);
0309 
0310 /* Exported I/F */
0311 void ishtp_send_suspend(struct ishtp_device *dev);
0312 void ishtp_send_resume(struct ishtp_device *dev);
0313 
0314 #endif /* _ISHTP_HBM_H_ */