2 * Freescale i.MXS Register Accessors
4 * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
5 * on behalf of DENX Software Engineering GmbH
7 * SPDX-License-Identifier: GPL-2.0+
10 #ifndef __MXS_REGS_COMMON_H__
11 #define __MXS_REGS_COMMON_H__
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:
17 * 1) Common read/write access. To use this mode, just write to the address of
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.
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.
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).
37 #define __mxs_reg_8(name) \
39 uint8_t name##_set[4]; \
40 uint8_t name##_clr[4]; \
41 uint8_t name##_tog[4]; \
43 #define __mxs_reg_32(name) \
45 uint32_t name##_set; \
46 uint32_t name##_clr; \
49 struct mxs_register_8 {
53 struct mxs_register_32 {
57 #define mxs_reg_8(name) \
59 struct { __mxs_reg_8(name) }; \
60 struct mxs_register_8 name##_reg; \
63 #define mxs_reg_32(name) \
65 struct { __mxs_reg_32(name) }; \
66 struct mxs_register_32 name##_reg; \
69 #endif /* __MXS_REGS_COMMON_H__ */