summaryrefstree
path: root/kernel/drivers/vision/npu/interface/loopback/npu-mailbox.h
blob: 93f1ea21522ceb774be4579efed9c00e0d409bb2 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Samsung Exynos SoC series NPU driver
 *
 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
 *	http://www.samsung.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef PERI_MAILBOX_H_
#define PERI_MAILBOX_H_

//#include <mtasker.h>
//#include <base/type.h>

#define MAILBOX_VERSION

struct int_group {
	u32 g;
	u32 c;
	u32 m;
	u32 s;
	u32 ms;
};

struct mailbox {
	u32			mcuctl;
	u32			pad0;
	struct int_group	g0;
	struct int_group	g1;
	struct int_group	g2;
	struct int_group	g3;
	struct int_group	g4;
	u32			pad1;
	u32			version;
	u32			pad2[3];
	u32			shared[64];
};

struct mailbox_h2f_hdr {
	u32			data_ofs;
	u32			data_len;
	u32			wptr_ofs;
	u32			rptr_ofs;
};

struct mailbox_f2h_hdr {
	u32			data_ofs;
	u32			data_len;
	u32			wptr_ofs;
	u32			rptr_ofs;
};

struct mailbox_hdr {
	u32			signature;
	u32			stack_ofs;
	u32			version;
	u32			totsize;
	u32			reserved[10];
	struct mailbox_h2f_hdr	h2fbox[2];
	struct mailbox_f2h_hdr	f2hbox[2];
};

enum npu_mailbox_h2f_type {
	NPU_H2F_LOW,
	NPU_H2F_NORMAL,
	NPU_H2F_HIGH,
};

enum npu_mailbox_f2h_type {
	NPU_F2H_LOW,
	NPU_F2H_NORMAL,
	NPU_F2H_HIGH,
	NPU_F2H_REPORT,
	NPU_F2H_DEBUG,
	NPU_F2H_ERROR,
};

struct mailbox_ctrl {
	struct mailbox_hdr		*hdr;
	struct mailbox_stack	*stack;
};

void mailbox_s_interrupt(void);

int npu_mailbox_init(struct mailbox_ctrl *mBox);
int npu_mailbox_ready(struct mailbox_ctrl *mBox);
int npu_mailbox_read(struct mailbox_ctrl *mBox);
int npu_mailbox_write(struct mailbox_ctrl *mBox);

#endif