xref: /freebsd/sys/contrib/alpine-hal/al_hal_udma_regs.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*-
2 *******************************************************************************
3 Copyright (C) 2015 Annapurna Labs Ltd.
4 
5 This file may be licensed under the terms of the Annapurna Labs Commercial
6 License Agreement.
7 
8 Alternatively, this file can be distributed under the terms of the GNU General
9 Public License V2 as published by the Free Software Foundation and can be
10 found at http://www.gnu.org/licenses/gpl-2.0.html
11 
12 Alternatively, redistribution and use in source and binary forms, with or
13 without modification, are permitted provided that the following conditions are
14 met:
15 
16     *     Redistributions of source code must retain the above copyright notice,
17 this list of conditions and the following disclaimer.
18 
19     *     Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in
21 the documentation and/or other materials provided with the
22 distribution.
23 
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
28 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 
35 *******************************************************************************/
36 
37 /**
38  *  @{
39  * @file   al_hal_udma_regs.h
40  *
41  * @brief  udma registers definition
42  *
43  *
44  */
45 #ifndef __AL_HAL_UDMA_REG_H
46 #define __AL_HAL_UDMA_REG_H
47 
48 #include "al_hal_udma_regs_m2s.h"
49 #include "al_hal_udma_regs_s2m.h"
50 #include "al_hal_udma_regs_gen.h"
51 
52 #define AL_UDMA_REV_ID_REV0   0
53 #define AL_UDMA_REV_ID_REV1   1
54 #define AL_UDMA_REV_ID_REV2   2
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 /** UDMA registers, either m2s or s2m */
61 union udma_regs {
62 	struct udma_m2s_regs m2s;
63 	struct udma_s2m_regs s2m;
64 };
65 
66 struct unit_regs {
67 	struct udma_m2s_regs m2s;
68 	uint32_t rsrvd0[(0x10000 - sizeof(struct udma_m2s_regs)) >> 2];
69 	struct udma_s2m_regs s2m;
70 	uint32_t rsrvd1[((0x1C000 - 0x10000) - sizeof(struct udma_s2m_regs)) >> 2];
71 	struct udma_gen_regs gen;
72 };
73 
74 /** UDMA submission and completion registers, M2S and S2M UDMAs have same stucture */
75 struct udma_rings_regs {
76 	uint32_t rsrvd0[8];
77 	uint32_t cfg;		/* Descriptor ring configuration */
78 	uint32_t status;	/* Descriptor ring status and information */
79 	uint32_t drbp_low;	/* Descriptor Ring Base Pointer [31:4] */
80 	uint32_t drbp_high;	/* Descriptor Ring Base Pointer [63:32] */
81 	uint32_t drl;		/* Descriptor Ring Length[23:2] */
82 	uint32_t drhp;		/* Descriptor Ring Head Pointer */
83 	uint32_t drtp_inc;	/* Descriptor Tail Pointer increment */
84 	uint32_t drtp;		/* Descriptor Tail Pointer */
85 	uint32_t dcp;		/* Descriptor Current Pointer */
86 	uint32_t crbp_low;	/* Completion Ring Base Pointer [31:4] */
87 	uint32_t crbp_high;	/* Completion Ring Base Pointer [63:32] */
88 	uint32_t crhp;		/* Completion Ring Head Pointer */
89 	uint32_t crhp_internal;	/* Completion Ring Head Pointer internal, before AX ... */
90 };
91 
92 /** M2S and S2M generic structure of Q registers */
93 union udma_q_regs {
94 	struct udma_rings_regs	rings;
95 	struct udma_m2s_q	m2s_q;
96 	struct udma_s2m_q	s2m_q;
97 };
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* __AL_HAL_UDMA_REG_H */
104 /** @} end of UDMA group */
105