linux/drivers/hid/intel-ish-hid/ishtp/loader.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * ISHTP firmware loader header
 *
 * Copyright (c) 2024, Intel Corporation.
 */

#ifndef _ISHTP_LOADER_H_
#define _ISHTP_LOADER_H_

#include <linux/bits.h>
#include <linux/jiffies.h>
#include <linux/types.h>

#include "ishtp-dev.h"

struct work_struct;

#define LOADER_MSG_SIZE

/*
 * ISHTP firmware loader protocol definition
 */
#define LOADER_CMD_XFER_QUERY
#define LOADER_CMD_XFER_FRAGMENT
#define LOADER_CMD_START

/* Only support DMA mode */
#define LOADER_XFER_MODE_DMA

/**
 * union loader_msg_header - ISHTP firmware loader message header
 * @command: Command type
 * @is_response: Indicates if the message is a response
 * @has_next: Indicates if there is a next message
 * @reserved: Reserved for future use
 * @status: Status of the message
 * @val32: entire header as a 32-bit value
 */
loader_msg_header;

/**
 * struct loader_xfer_query - ISHTP firmware loader transfer query packet
 * @header: Header of the message
 * @image_size: Size of the image
 */
struct loader_xfer_query {};

/**
 * struct loader_version - ISHTP firmware loader version
 * @value: Value of the version
 * @major: Major version
 * @minor: Minor version
 * @hotfix: Hotfix version
 * @build: Build version
 */
struct loader_version {};

/**
 * struct loader_capability - ISHTP firmware loader capability
 * @max_fw_image_size: Maximum firmware image size
 * @support_mode: Support mode
 * @reserved: Reserved for future use
 * @platform: Platform
 * @max_dma_buf_size: Maximum DMA buffer size, multiples of 4096
 */
struct loader_capability {};

/**
 * struct loader_xfer_query_ack - ISHTP firmware loader transfer query acknowledgment
 * @header: Header of the message
 * @version_major: ISH Major version
 * @version_minor: ISH Minor version
 * @version_hotfix: ISH Hotfix version
 * @version_build: ISH Build version
 * @protocol_version: Protocol version
 * @loader_version: Loader version
 * @capability: Loader capability
 */
struct loader_xfer_query_ack {};

/**
 * struct loader_xfer_fragment - ISHTP firmware loader transfer fragment
 * @header: Header of the message
 * @xfer_mode: Transfer mode
 * @offset: Offset
 * @size: Size
 * @is_last: Is last
 */
struct loader_xfer_fragment {};

/**
 * struct loader_xfer_fragment_ack - ISHTP firmware loader transfer fragment acknowledgment
 * @header: Header of the message
 */
struct loader_xfer_fragment_ack {};

/**
 * struct fragment_dscrpt - ISHTP firmware loader fragment descriptor
 * @ddr_adrs: The address in host DDR
 * @fw_off: The offset of the fragment in the fw image
 * @length: The length of the fragment
 */
struct fragment_dscrpt {};

#define FRAGMENT_MAX_NUM

/**
 * struct loader_xfer_dma_fragment - ISHTP firmware loader transfer DMA fragment
 * @fragment: Fragment
 * @fragment_cnt: How many descriptors in the fragment_tbl
 * @fragment_tbl: Fragment table
 */
struct loader_xfer_dma_fragment {};

/**
 * struct loader_start - ISHTP firmware loader start
 * @header: Header of the message
 */
struct loader_start {};

/**
 * struct loader_start_ack - ISHTP firmware loader start acknowledgment
 * @header: Header of the message
 */
struct loader_start_ack {};

loader_recv_message;

/*
 * ISHTP firmware loader internal use
 */
/* ISHTP firmware loader command timeout */
#define ISHTP_LOADER_TIMEOUT

/* ISHTP firmware loader retry times */
#define ISHTP_LOADER_RETRY_TIMES

/**
 * struct ish_firmware_variant - ISH firmware variant
 * @device: PCI Device ID
 * @filename: The firmware file name
 */
struct ish_firmware_variant {};

/*
 * ISHTP firmware loader API for ISHTP hbm
 */

/* ISHTP capability bit for firmware loader */
#define ISHTP_SUPPORT_CAP_LOADER

/* Firmware loader address */
#define ISHTP_LOADER_CLIENT_ADDR

/**
 * ishtp_loader_work - The work function to start the firmware loading process
 * @work: The work structure
 */
void ishtp_loader_work(struct work_struct *work);

#endif /* _ISHTP_LOADER_H_ */