]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/include/asm/imx-common/regs-common.h
merged tx6dl-devel into denx master branch
[karo-tx-uboot.git] / arch / arm / include / asm / imx-common / regs-common.h
1 /*
2  * Freescale i.MXS Register Accessors
3  *
4  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
5  * on behalf of DENX Software Engineering GmbH
6  *
7  * SPDX-License-Identifier:     GPL-2.0+
8  */
9
10 #ifndef __MXS_REGS_COMMON_H__
11 #define __MXS_REGS_COMMON_H__
12
13 /*
14  * The i.MXS has interesting feature when it comes to register access. There
15  * are four kinds of access to one particular register. Those are:
16  *
17  * 1) Common read/write access. To use this mode, just write to the address of
18  *    the register.
19  * 2) Set bits only access. To set bits, write which bits you want to set to the
20  *    address of the register + 0x4.
21  * 3) Clear bits only access. To clear bits, write which bits you want to clear
22  *    to the address of the register + 0x8.
23  * 4) Toggle bits only access. To toggle bits, write which bits you want to
24  *    toggle to the address of the register + 0xc.
25  *
26  * IMPORTANT NOTE: Not all registers support accesses 2-4! Also, not all bits
27  * can be set/cleared by pure write as in access type 1, some need to be
28  * explicitly set/cleared by using access type 2-3.
29  *
30  * The following macros and structures allow the user to either access the
31  * register in all aforementioned modes (by accessing reg_name, reg_name_set,
32  * reg_name_clr, reg_name_tog) or pass the register structure further into
33  * various functions with correct type information (by accessing reg_name_reg).
34  *
35  */
36
37 #ifndef __ASSEMBLY__
38
39 #include <linux/types.h>
40
41 #define __mxs_reg_8(name)               \
42         uint8_t name[4];                \
43         uint8_t name##_set[4];          \
44         uint8_t name##_clr[4];          \
45         uint8_t name##_tog[4]
46
47 #define __mxs_reg_32(name)              \
48         uint32_t name;                  \
49         uint32_t name##_set;            \
50         uint32_t name##_clr;            \
51         uint32_t name##_tog
52
53 #define __reg_32(name)                  \
54         uint32_t name;                  \
55         uint32_t reserved_##name[3]
56
57 struct mxs_register_8 {
58         __mxs_reg_8(reg);
59 };
60
61 struct mxs_register_32 {
62         __mxs_reg_32(reg);
63 };
64
65 #define mxs_reg_8(name)                                 \
66         union {                                         \
67                 struct { __mxs_reg_8(name); };          \
68                 struct mxs_register_8 name##_reg;       \
69         }
70
71 #define mxs_reg_32(name);                               \
72         union {                                         \
73                 struct { __mxs_reg_32(name); };         \
74                 struct mxs_register_32 name##_reg;      \
75         }
76
77 #define reg_32(name)                                    \
78         struct { __reg_32(name); }
79 #endif
80
81 #endif  /* __MXS_REGS_COMMON_H__ */