/* SPDX-License-Identifier: GPL-2.0 */


#include <linux/bits.h>

#ifndef _HID_OVER_I2C_H_
#define _HID_OVER_I2C_H_

#define HIDI2C_REG_LEN		sizeof(__le16)


enum hidi2c_report_type {
	HIDI2C_RESERVED = 0,
	HIDI2C_INPUT,
	HIDI2C_OUTPUT,
	HIDI2C_FEATURE,
};


enum hidi2c_power_state {
	HIDI2C_ON,
	HIDI2C_SLEEP,
};


enum hidi2c_opcode {
	HIDI2C_RESET = 1,
	HIDI2C_GET_REPORT,
	HIDI2C_SET_REPORT,
	HIDI2C_GET_IDLE,
	HIDI2C_SET_IDLE,
	HIDI2C_GET_PROTOCOL,
	HIDI2C_SET_PROTOCOL,
	HIDI2C_SET_POWER,
};


struct hidi2c_report_packet {
	__le16 len;
	u8 data[];
} __packed;

#define HIDI2C_LENGTH_LEN	sizeof(__le16)

#define HIDI2C_PACKET_LEN(data_len)	((data_len) + HIDI2C_LENGTH_LEN)
#define HIDI2C_DATA_LEN(pkt_len)	((pkt_len) - HIDI2C_LENGTH_LEN)

#define HIDI2C_CMD_MAX_RI	0x0F



#define HIDI2C_CMD_LEN			sizeof(__le16)
#define HIDI2C_CMD_LEN_OPT		(sizeof(__le16) + 1)
#define HIDI2C_CMD_REPORT_ID		GENMASK(3, 0)
#define HIDI2C_CMD_REPORT_TYPE		GENMASK(5, 4)
#define HIDI2C_CMD_OPCODE		GENMASK(11, 8)
#define HIDI2C_CMD_OPCODE		GENMASK(11, 8)
#define HIDI2C_CMD_3RD_BYTE		GENMASK(23, 16)

#define HIDI2C_HID_DESC_BCDVERSION	0x100


struct hidi2c_dev_descriptor {
	__le16 dev_desc_len;
	__le16 bcd_ver;
	__le16 report_desc_len;
	__le16 report_desc_reg;
	__le16 input_reg;
	__le16 max_input_len;
	__le16 output_reg;
	__le16 max_output_len;
	__le16 cmd_reg;
	__le16 data_reg;
	__le16 vendor_id;
	__le16 product_id;
	__le16 version_id;
	__le16 reserved0;
	__le16 reserved1;
} __packed;

#define HIDI2C_DEV_DESC_LEN		sizeof(struct hidi2c_dev_descriptor)

#endif 
