• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * include/linux/amlogic/media/rdma/rdma_mgr.h
3  *
4  * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  */
17 
18 #ifndef RDMA_MGR_H_
19 #define RDMA_MGR_H_
20 
21 struct rdma_op_s {
22 	void (*irq_cb)(void *arg);
23 	void *arg;
24 };
25 
26 #define RDMA_TRIGGER_VSYNC_INPUT 0x1
27 #define RDMA_TRIGGER_LINE_INPUT (1 << 5)
28 #define RDMA_TRIGGER_MANUAL	0x100
29 #define RDMA_TRIGGER_DEBUG1 0x101
30 #define RDMA_TRIGGER_DEBUG2 0x102
31 #define RDMA_AUTO_START_MASK 0x80000
32 
33 /* rdma write: bit[20] = 0
34  * rdma read:  bit[20] = 1
35  */
36 #define RDMA_READ_MASK 0x100000
37 
38 enum rdma_ver_e {
39 	RDMA_VER_1,
40 	RDMA_VER_2,
41 };
42 
43 enum cpu_ver_e {
44 	CPU_G12B,
45 	CPU_NORMAL,
46 };
47 
48 struct rdma_device_data_s {
49 	enum cpu_ver_e cpu_type;
50 	enum rdma_ver_e rdma_ver;
51 	u32 trigger_mask_len;
52 };
53 
54 struct reg_handle {
55 	u32 offset;   /* read-only, offset in register table */
56 	u32 reg_addr; /* VCBus register address offset */
57 	struct list_head list;
58 };
59 
60 u32 is_meson_g12b_revb(void);
61 /*
62  *	rdma_read_reg(), rdma_write_reg(), rdma_clear() can only be called
63  *	after rdma_register() is called and
64  *	before rdma_unregister() is called
65  */
66 int rdma_register(struct rdma_op_s *rdma_op, void *op_arg, int table_size);
67 
68 /*
69  *	if keep_buf is 0, rdma_unregister can only be called in its irq_cb.
70  *	in normal case, keep_buf is 1, so rdma_unregister can be called anywhere
71  */
72 void rdma_unregister(int i);
73 
74 int rdma_config(int handle, int trigger_type);
75 
76 u32 rdma_read_reg(int handle, u32 adr);
77 
78 int rdma_write_reg(int handle, u32 adr, u32 val);
79 
80 int rdma_write_reg_bits(int handle, u32 adr, u32 val, u32 start, u32 len);
81 
82 int rdma_clear(int handle);
83 
84 s32 rdma_add_read_reg(int handle, struct reg_handle *reg_hnd);
85 
86 s32 rdma_remove_read_reg(int handle, struct reg_handle *reg_hnd, u32 count);
87 
88 u32 *rdma_get_read_back_addr(int handle, struct reg_handle *reg_hnd);
89 
90 struct reg_handle *rdma_query_read_handle(int handle, u32 index);
91 
92 #endif
93