1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2017-2018, Intel Corporation
6 #ifndef __STRATIX10_SVC_CLIENT_H
7 #define __STRATIX10_SVC_CLIENT_H
10 * Service layer driver supports client names
12 * fpga: for FPGA configuration
13 * rsu: for remote status update
15 #define SVC_CLIENT_FPGA "fpga"
16 #define SVC_CLIENT_RSU "rsu"
19 * Status of the sent command, in bit number
21 * SVC_COMMAND_STATUS_RECONFIG_REQUEST_OK:
22 * Secure firmware accepts the request of FPGA reconfiguration.
24 * SVC_STATUS_RECONFIG_BUFFER_SUBMITTED:
25 * Service client successfully submits FPGA configuration
26 * data buffer to secure firmware.
28 * SVC_COMMAND_STATUS_RECONFIG_BUFFER_DONE:
29 * Secure firmware completes data process, ready to accept the
30 * next WRITE transaction.
32 * SVC_COMMAND_STATUS_RECONFIG_COMPLETED:
33 * Secure firmware completes FPGA configuration successfully, FPGA should
36 * SVC_COMMAND_STATUS_RECONFIG_BUSY:
37 * FPGA configuration is still in process.
39 * SVC_COMMAND_STATUS_RECONFIG_ERROR:
40 * Error encountered during FPGA configuration.
43 * Secure firmware accepts the request of remote status update (RSU).
45 * SVC_STATUS_RSU_ERROR:
46 * Error encountered during remote system update.
48 * SVC_STATUS_RSU_NO_SUPPORT:
49 * Secure firmware doesn't support RSU retry or notify feature.
51 #define SVC_STATUS_RECONFIG_REQUEST_OK 0
52 #define SVC_STATUS_RECONFIG_BUFFER_SUBMITTED 1
53 #define SVC_STATUS_RECONFIG_BUFFER_DONE 2
54 #define SVC_STATUS_RECONFIG_COMPLETED 3
55 #define SVC_STATUS_RECONFIG_BUSY 4
56 #define SVC_STATUS_RECONFIG_ERROR 5
57 #define SVC_STATUS_RSU_OK 6
58 #define SVC_STATUS_RSU_ERROR 7
59 #define SVC_STATUS_RSU_NO_SUPPORT 8
62 * Flag bit for COMMAND_RECONFIG
64 * COMMAND_RECONFIG_FLAG_PARTIAL:
65 * Set to FPGA configuration type (full or partial), the default
68 #define COMMAND_RECONFIG_FLAG_PARTIAL 0
71 * Timeout settings for service clients:
72 * timeout value used in Stratix10 FPGA manager driver.
73 * timeout value used in RSU driver
75 #define SVC_RECONFIG_REQUEST_TIMEOUT_MS 100
76 #define SVC_RECONFIG_BUFFER_TIMEOUT_MS 240
77 #define SVC_RSU_REQUEST_TIMEOUT_MS 300
79 struct stratix10_svc_chan;
82 * enum stratix10_svc_command_code - supported service commands
84 * @COMMAND_NOOP: do 'dummy' request for integration/debug/trouble-shooting
86 * @COMMAND_RECONFIG: ask for FPGA configuration preparation, return status
87 * is SVC_STATUS_RECONFIG_REQUEST_OK
89 * @COMMAND_RECONFIG_DATA_SUBMIT: submit buffer(s) of bit-stream data for the
90 * FPGA configuration, return status is SVC_STATUS_RECONFIG_BUFFER_SUBMITTED,
91 * or SVC_STATUS_RECONFIG_ERROR
93 * @COMMAND_RECONFIG_DATA_CLAIM: check the status of the configuration, return
94 * status is SVC_STATUS_RECONFIG_COMPLETED, or SVC_STATUS_RECONFIG_BUSY, or
95 * SVC_STATUS_RECONFIG_ERROR
97 * @COMMAND_RECONFIG_STATUS: check the status of the configuration, return
98 * status is SVC_STATUS_RECONFIG_COMPLETED, or SVC_STATUS_RECONFIG_BUSY, or
99 * SVC_STATUS_RECONFIG_ERROR
101 * @COMMAND_RSU_STATUS: request remote system update boot log, return status
102 * is log data or SVC_STATUS_RSU_ERROR
104 * @COMMAND_RSU_UPDATE: set the offset of the bitstream to boot after reboot,
105 * return status is SVC_STATUS_RSU_OK or SVC_STATUS_RSU_ERROR
107 * @COMMAND_RSU_NOTIFY: report the status of hard processor system
108 * software to firmware, return status is SVC_STATUS_RSU_OK or
109 * SVC_STATUS_RSU_ERROR
111 * @COMMAND_RSU_RETRY: query firmware for the current image's retry counter,
112 * return status is SVC_STATUS_RSU_OK or SVC_STATUS_RSU_ERROR
114 enum stratix10_svc_command_code {
117 COMMAND_RECONFIG_DATA_SUBMIT,
118 COMMAND_RECONFIG_DATA_CLAIM,
119 COMMAND_RECONFIG_STATUS,
127 * struct stratix10_svc_client_msg - message sent by client to service
128 * @payload: starting address of data need be processed
129 * @payload_length: data size in bytes
130 * @command: service command
131 * @arg: args to be passed via registers and not physically mapped buffers
133 struct stratix10_svc_client_msg {
135 size_t payload_length;
136 enum stratix10_svc_command_code command;
141 * struct stratix10_svc_command_config_type - config type
142 * @flags: flag bit for the type of FPGA configuration
144 struct stratix10_svc_command_config_type {
149 * struct stratix10_svc_cb_data - callback data structure from service layer
150 * @status: the status of sent command
151 * @kaddr1: address of 1st completed data block
152 * @kaddr2: address of 2nd completed data block
153 * @kaddr3: address of 3rd completed data block
155 struct stratix10_svc_cb_data {
163 * struct stratix10_svc_client - service client structure
164 * @dev: the client device
165 * @receive_cb: callback to provide service client the received data
166 * @priv: client private data
168 struct stratix10_svc_client {
170 void (*receive_cb)(struct stratix10_svc_client *client,
171 struct stratix10_svc_cb_data *cb_data);
176 * stratix10_svc_request_channel_byname() - request service channel
177 * @client: identity of the client requesting the channel
178 * @name: supporting client name defined above
180 * Return: a pointer to channel assigned to the client on success,
181 * or ERR_PTR() on error.
183 struct stratix10_svc_chan
184 *stratix10_svc_request_channel_byname(struct stratix10_svc_client *client,
188 * stratix10_svc_free_channel() - free service channel.
189 * @chan: service channel to be freed
191 void stratix10_svc_free_channel(struct stratix10_svc_chan *chan);
194 * stratix10_svc_allocate_memory() - allocate the momory
195 * @chan: service channel assigned to the client
196 * @size: number of bytes client requests
198 * Service layer allocates the requested number of bytes from the memory
199 * pool for the client.
201 * Return: the starting address of allocated memory on success, or
202 * ERR_PTR() on error.
204 void *stratix10_svc_allocate_memory(struct stratix10_svc_chan *chan,
208 * stratix10_svc_free_memory() - free allocated memory
209 * @chan: service channel assigned to the client
210 * @kaddr: starting address of memory to be free back to pool
212 void stratix10_svc_free_memory(struct stratix10_svc_chan *chan, void *kaddr);
215 * stratix10_svc_send() - send a message to the remote
216 * @chan: service channel assigned to the client
217 * @msg: message data to be sent, in the format of
218 * struct stratix10_svc_client_msg
220 * Return: 0 for success, -ENOMEM or -ENOBUFS on error.
222 int stratix10_svc_send(struct stratix10_svc_chan *chan, void *msg);
225 * intel_svc_done() - complete service request
226 * @chan: service channel assigned to the client
228 * This function is used by service client to inform service layer that
229 * client's service requests are completed, or there is an error in the
232 void stratix10_svc_done(struct stratix10_svc_chan *chan);