summaryrefslogtreecommitdiff
path: root/include/ratp_bb.h
blob: b710f99bf9d0ca625cbe49a48e6d1ba7eaaeb76a (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
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __RATP_BB_H
#define __RATP_BB_H

#include <linux/stringify.h>

#define BB_RATP_TYPE_COMMAND		1
#define BB_RATP_TYPE_COMMAND_RETURN	2
#define BB_RATP_TYPE_CONSOLEMSG		3
#define BB_RATP_TYPE_PING		4
#define BB_RATP_TYPE_PONG		5
#define BB_RATP_TYPE_GETENV		6
#define BB_RATP_TYPE_GETENV_RETURN	7
#define BB_RATP_TYPE_FS			8
#define BB_RATP_TYPE_FS_RETURN		9
#define BB_RATP_TYPE_MD			10
#define BB_RATP_TYPE_MD_RETURN		11
#define BB_RATP_TYPE_MW			12
#define BB_RATP_TYPE_MW_RETURN		13
#define BB_RATP_TYPE_RESET		14
#define BB_RATP_TYPE_I2C_READ		15
#define BB_RATP_TYPE_I2C_READ_RETURN	16
#define BB_RATP_TYPE_I2C_WRITE		17
#define BB_RATP_TYPE_I2C_WRITE_RETURN	18
#define BB_RATP_TYPE_GPIO_GET_VALUE		19
#define BB_RATP_TYPE_GPIO_GET_VALUE_RETURN	20
#define BB_RATP_TYPE_GPIO_SET_VALUE		21
#define BB_RATP_TYPE_GPIO_SET_VALUE_RETURN	22
#define BB_RATP_TYPE_GPIO_SET_DIRECTION		23
#define BB_RATP_TYPE_GPIO_SET_DIRECTION_RETURN	24

struct ratp_bb {
	uint16_t type;
	uint16_t flags;
	uint8_t data[];
};

struct ratp_bb_pkt {
	unsigned int len;
	uint8_t data[];
};

int  barebox_ratp(struct console_device *cdev);
int  barebox_ratp_fs_call(struct ratp_bb_pkt *tx, struct ratp_bb_pkt **rx);
int  barebox_ratp_fs_mount(const char *path);

/*
 * RATP commands definition
 */

struct ratp_command {
	struct list_head  list;
	uint16_t          request_id;
	uint16_t          response_id;
	int		(*cmd)(const struct ratp_bb *req,
			       int req_len,
			       struct ratp_bb **rsp,
			       int *rsp_len);
}
#ifdef __x86_64__
/* This is required because the linker will put symbols on a 64 bit alignment */
__attribute__((aligned(64)))
#endif
;

#define BAREBOX_RATP_CMD_START(_name)							\
extern const struct ratp_command __barebox_ratp_cmd_##_name;				\
const struct ratp_command __barebox_ratp_cmd_##_name					\
	__attribute__ ((unused,section (".barebox_ratp_cmd_" __stringify(_name)))) = {

#define BAREBOX_RATP_CMD_END								\
};

int register_ratp_command(struct ratp_command *cmd);

#endif /* __RATP_BB_H */