]> git.sur5r.net Git - u-boot/blob - arch/arm/include/asm/mach-imx/regs-common.h
imx: reorganize IMX code as other SOCs
[u-boot] / arch / arm / include / asm / mach-imx / 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 #include <linux/types.h>
14
15 /*
16  * The i.MXS has interesting feature when it comes to register access. There
17  * are four kinds of access to one particular register. Those are:
18  *
19  * 1) Common read/write access. To use this mode, just write to the address of
20  *    the register.
21  * 2) Set bits only access. To set bits, write which bits you want to set to the
22  *    address of the register + 0x4.
23  * 3) Clear bits only access. To clear bits, write which bits you want to clear
24  *    to the address of the register + 0x8.
25  * 4) Toggle bits only access. To toggle bits, write which bits you want to
26  *    toggle to the address of the register + 0xc.
27  *
28  * IMPORTANT NOTE: Not all registers support accesses 2-4! Also, not all bits
29  * can be set/cleared by pure write as in access type 1, some need to be
30  * explicitly set/cleared by using access type 2-3.
31  *
32  * The following macros and structures allow the user to either access the
33  * register in all aforementioned modes (by accessing reg_name, reg_name_set,
34  * reg_name_clr, reg_name_tog) or pass the register structure further into
35  * various functions with correct type information (by accessing reg_name_reg).
36  *
37  */
38
39 #define __mxs_reg_8(name)               \
40         uint8_t name[4];                \
41         uint8_t name##_set[4];          \
42         uint8_t name##_clr[4];          \
43         uint8_t name##_tog[4];          \
44
45 #define __mxs_reg_32(name)              \
46         uint32_t name;                  \
47         uint32_t name##_set;            \
48         uint32_t name##_clr;            \
49         uint32_t name##_tog;
50
51 struct mxs_register_8 {
52         __mxs_reg_8(reg)
53 };
54
55 struct mxs_register_32 {
56         __mxs_reg_32(reg)
57 };
58
59 #define mxs_reg_8(name)                         \
60         union {                                         \
61                 struct { __mxs_reg_8(name) };           \
62                 struct mxs_register_8 name##_reg;       \
63         };
64
65 #define mxs_reg_32(name)                                \
66         union {                                         \
67                 struct { __mxs_reg_32(name) };          \
68                 struct mxs_register_32 name##_reg;      \
69         };
70
71 #endif  /* __MXS_REGS_COMMON_H__ */