summaryrefslogtreecommitdiffstats
path: root/include/linux/mfd/rave-sp.h
blob: 92315c6e1296af4ea017d70c40dd0712c5963844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* SPDX-License-Identifier: GPL-2.0+ */

/*
 * Core definitions for RAVE SP MFD driver.
 *
 * Copyright (C) 2017 Zodiac Inflight Innovations
 */

#ifndef _LINUX_RAVE_SP_H_
#define _LINUX_RAVE_SP_H_

/* #include <linux/notifier.h> */

enum rave_sp_command {
	RAVE_SP_CMD_GET_FIRMWARE_VERSION	= 0x20,
	RAVE_SP_CMD_GET_BOOTLOADER_VERSION	= 0x21,
	RAVE_SP_CMD_GET_OPERATIONAL_MODE	= 0x25,
	RAVE_SP_CMD_BOOT_SOURCE			= 0x26,
	RAVE_SP_CMD_GET_BOARD_COPPER_REV	= 0x2B,
	RAVE_SP_CMD_GET_GPIO_STATE		= 0x2F,

	RAVE_SP_CMD_STATUS			= 0xA0,
	RAVE_SP_CMD_SW_WDT			= 0xA1,
	RAVE_SP_CMD_PET_WDT			= 0xA2,
	RAVE_SP_CMD_RMB_EEPROM			= 0xA4,
	RAVE_SP_CMD_SET_BACKLIGHT		= 0xA6,
	RAVE_SP_CMD_RESET			= 0xA7,
	RAVE_SP_CMD_RESET_REASON		= 0xA8,
	RAVE_SP_CMD_RESET_ETH_SWITCH		= 0xAF,

	RAVE_SP_CMD_JUMP_TO_BOOTLOADER		= 0xB0,
	RAVE_SP_CMD_BOOTLOADER			= 0xB1,
	RAVE_SP_CMD_REQ_IP_ADDR			= 0xB2,
	RAVE_SP_CMD_REQ_COPPER_REV		= 0xB6,
	RAVE_SP_CMD_GET_I2C_DEVICE_STATUS	= 0xBA,
	RAVE_SP_CMD_GET_SP_SILICON_REV		= 0xB9,
	RAVE_SP_CMD_CONTROL_EVENTS		= 0xBB,

	RAVE_SP_EVNT_BASE			= 0xE0,
};

enum rave_sp_bootloader_command {
	RAVE_SP_BOOTLOADER_CMD_QUERY_DEVICE	= 0xA1,
	RAVE_SP_BOOTLOADER_CMD_ERASE_APP	= 0xA3,
	RAVE_SP_BOOTLOADER_CMD_PROGRAM_DEVICE	= 0xA4,
	RAVE_SP_BOOTLOADER_CMD_PROGRAM_COMPLETE = 0xA5,
	RAVE_SP_BOOTLOADER_CMD_READ_APP		= 0xA6,
	RAVE_SP_BOOTLOADER_CMD_RESET_DEVICE	= 0xA7,
	RAVE_SP_BOOTLOADER_CMD_LAUNCH_APP	= 0xA8,
};

struct rave_sp;

static inline unsigned long rave_sp_action_pack(u8 event, u8 value)
{
	return ((unsigned long)value << 8) | event;
}

static inline u8 rave_sp_action_unpack_event(unsigned long action)
{
	return action;
}

static inline u8 rave_sp_action_unpack_value(unsigned long action)
{
	return action >> 8;
}

int rave_sp_exec(struct rave_sp *sp,
		 void *__data,  size_t data_size,
		 void *reply_data, size_t reply_data_size);

struct device;
/* int devm_rave_sp_register_event_notifier(struct device *dev, */
/* 					 struct notifier_block *nb); */

bool rave_sp_is_in_bootloader_mode(struct rave_sp *sp);
const struct firmware *rave_sp_get_firmware(struct rave_sp *sp);
void rave_sp_release_firmware(struct rave_sp *sp);
void rave_sp_set_update_fw_status(struct rave_sp *sp, int status);

#endif /* _LINUX_RAVE_SP_H_ */