Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
  1/* SPDX-License-Identifier: GPL-2.0-only
  2 *
  3 * Copyright (C) 2020-2021 Intel Corporation.
  4 */
  5
  6#ifndef _IOSM_IPC_DEVLINK_H_
  7#define _IOSM_IPC_DEVLINK_H_
  8
  9#include <net/devlink.h>
 10
 11#include "iosm_ipc_imem.h"
 12#include "iosm_ipc_imem_ops.h"
 13#include "iosm_ipc_pcie.h"
 14
 15/* Image ext max len */
 16#define IOSM_DEVLINK_MAX_IMG_LEN 3
 17/* Magic Header */
 18#define IOSM_DEVLINK_MAGIC_HEADER "IOSM_DEVLINK_HEADER"
 19/* Magic Header len */
 20#define IOSM_DEVLINK_MAGIC_HEADER_LEN 20
 21/* Devlink image type */
 22#define IOSM_DEVLINK_IMG_TYPE 4
 23/* Reserve header size */
 24#define IOSM_DEVLINK_RESERVED 34
 25/* Devlink Image Header size */
 26#define IOSM_DEVLINK_HDR_SIZE sizeof(struct iosm_devlink_image)
 27/* MAX file name length */
 28#define IOSM_MAX_FILENAME_LEN 32
 29/* EBL response size */
 30#define IOSM_EBL_RSP_SIZE 76
 31/* MAX number of regions supported */
 32#define IOSM_NOF_CD_REGION 6
 33/* MAX number of SNAPSHOTS supported */
 34#define MAX_SNAPSHOTS 1
 35/* Default Coredump file size */
 36#define REPORT_JSON_SIZE 0x800
 37#define COREDUMP_FCD_SIZE 0x10E00000
 38#define CDD_LOG_SIZE 0x30000
 39#define EEPROM_BIN_SIZE 0x10000
 40#define BOOTCORE_TRC_BIN_SIZE 0x8000
 41#define BOOTCORE_PREV_TRC_BIN_SIZE 0x20000
 42
 43/**
 44 * enum iosm_devlink_param_id - Enum type to different devlink params
 45 * @IOSM_DEVLINK_PARAM_ID_BASE:			Devlink param base ID
 46 * @IOSM_DEVLINK_PARAM_ID_ERASE_FULL_FLASH:     Set if full erase required
 47 */
 48
 49enum iosm_devlink_param_id {
 50	IOSM_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
 51	IOSM_DEVLINK_PARAM_ID_ERASE_FULL_FLASH,
 52};
 53
 54/**
 55 * enum iosm_rpsi_cmd_code - Enum type for RPSI command list
 56 * @rpsi_cmd_code_ebl:		Command to load ebl
 57 * @rpsi_cmd_coredump_start:    Command to get list of files and
 58 *				file size info from PSI
 59 * @rpsi_cmd_coredump_get:      Command to get the coredump data
 60 * @rpsi_cmd_coredump_end:      Command to stop receiving the coredump
 61 */
 62enum iosm_rpsi_cmd_code {
 63	rpsi_cmd_code_ebl = 0x02,
 64	rpsi_cmd_coredump_start = 0x10,
 65	rpsi_cmd_coredump_get   = 0x11,
 66	rpsi_cmd_coredump_end   = 0x12,
 67};
 68
 69/**
 70 * enum iosm_flash_comp_type - Enum for different flash component types
 71 * @FLASH_COMP_TYPE_PSI:	PSI flash comp type
 72 * @FLASH_COMP_TYPE_EBL:	EBL flash comp type
 73 * @FLASH_COMP_TYPE_FLS:	FLS flash comp type
 74 * @FLASH_COMP_TYPE_INVAL:	Invalid flash comp type
 75 */
 76enum iosm_flash_comp_type {
 77	FLASH_COMP_TYPE_PSI,
 78	FLASH_COMP_TYPE_EBL,
 79	FLASH_COMP_TYPE_FLS,
 80	FLASH_COMP_TYPE_INVAL,
 81};
 82
 83/**
 84 * struct iosm_devlink_sio - SIO instance
 85 * @rx_list:	Downlink skbuf list received from CP
 86 * @read_sem:	Needed for the blocking read or downlink transfer
 87 * @channel_id: Reserved channel id for flashing/CD collection to RAM
 88 * @channel:	Channel instance for flashing and coredump
 89 * @devlink_read_pend: Check if read is pending
 90 */
 91struct iosm_devlink_sio {
 92	struct sk_buff_head rx_list;
 93	struct completion read_sem;
 94	int channel_id;
 95	struct ipc_mem_channel *channel;
 96	u32 devlink_read_pend;
 97};
 98
 99/**
100 * struct iosm_flash_params - List of flash params required for flashing
101 * @erase_full_flash:   To set the flashing mode
102 *                      erase_full_flash = 1; full erase
103 *                      erase_full_flash = 0; no erase
104 * @erase_full_flash_done: Flag to check if it is a full erase
105 */
106struct iosm_flash_params {
107	u8 erase_full_flash;
108	u8 erase_full_flash_done;
109};
110
111/**
112 * struct iosm_devlink_image - Structure with Fls file header info
113 * @magic_header:	Header of the firmware image
114 * @image_type:		Firmware image type
115 * @region_address:	Address of the region to be flashed
116 * @download_region:	Field to identify if it is a region
117 * @last_region:	Field to identify if it is last region
118 * @reserved:		Reserved field
119 */
120struct iosm_devlink_image {
121	char magic_header[IOSM_DEVLINK_MAGIC_HEADER_LEN];
122	char image_type[IOSM_DEVLINK_IMG_TYPE];
123	__le32 region_address;
124	u8 download_region;
125	u8 last_region;
126	u8 reserved[IOSM_DEVLINK_RESERVED];
127} __packed;
128
129/**
130 * struct iosm_ebl_ctx_data -  EBL ctx data used during flashing
131 * @ebl_sw_info_version: SWID version info obtained from EBL
132 * @m_ebl_resp:         Buffer used to read and write the ebl data
133 */
134struct iosm_ebl_ctx_data {
135	u8 ebl_sw_info_version;
136	u8 m_ebl_resp[IOSM_EBL_RSP_SIZE];
137};
138
139/**
140 * struct iosm_coredump_file_info -  Coredump file info
141 * @filename:		Name of coredump file
142 * @default_size:	Default size of coredump file
143 * @actual_size:	Actual size of coredump file
144 * @entry:		Index of the coredump file
145 */
146struct iosm_coredump_file_info {
147	char filename[IOSM_MAX_FILENAME_LEN];
148	u32 default_size;
149	u32 actual_size;
150	u32 entry;
151};
152
153/**
154 * struct iosm_devlink - IOSM Devlink structure
155 * @devlink_sio:        SIO instance for read/write functionality
156 * @pcie:               Pointer to PCIe component
157 * @dev:                Pointer to device struct
158 * @devlink_ctx:	Pointer to devlink context
159 * @param:		Params required for flashing
160 * @ebl_ctx:		Data to be read and written to Modem
161 * @cd_file_info:	coredump file info
162 * @iosm_devlink_mdm_coredump:	region ops for coredump collection
163 * @cd_regions:		coredump regions
164 */
165struct iosm_devlink {
166	struct iosm_devlink_sio devlink_sio;
167	struct iosm_pcie *pcie;
168	struct device *dev;
169	struct devlink *devlink_ctx;
170	struct iosm_flash_params param;
171	struct iosm_ebl_ctx_data ebl_ctx;
172	struct iosm_coredump_file_info *cd_file_info;
173	struct devlink_region_ops iosm_devlink_mdm_coredump[IOSM_NOF_CD_REGION];
174	struct devlink_region *cd_regions[IOSM_NOF_CD_REGION];
175};
176
177/**
178 * union iosm_rpsi_param_u - RPSI cmd param for CRC calculation
179 * @word:	Words member used in CRC calculation
180 * @dword:	Actual data
181 */
182union iosm_rpsi_param_u {
183	__le16 word[2];
184	__le32 dword;
185};
186
187/**
188 * struct iosm_rpsi_cmd - Structure for RPSI Command
189 * @param:      Used to calculate CRC
190 * @cmd:        Stores the RPSI command
191 * @crc:        Stores the CRC value
192 */
193struct iosm_rpsi_cmd {
194	union iosm_rpsi_param_u param;
195	__le16	cmd;
196	__le16	crc;
197};
198
199struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem);
200
201void ipc_devlink_deinit(struct iosm_devlink *ipc_devlink);
202
203int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry);
204
205#endif /* _IOSM_IPC_DEVLINK_H */