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__
13 #include <linux/types.h>
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:
19 * 1) Common read/write access. To use this mode, just write to the address of
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.
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.
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).
39 #define __mxs_reg_8(name) \
41 uint8_t name##_set[4]; \
42 uint8_t name##_clr[4]; \
43 uint8_t name##_tog[4]; \
45 #define __mxs_reg_32(name) \
47 uint32_t name##_set; \
48 uint32_t name##_clr; \
51 struct mxs_register_8 {
55 struct mxs_register_32 {
59 #define mxs_reg_8(name) \
61 struct { __mxs_reg_8(name) }; \
62 struct mxs_register_8 name##_reg; \
65 #define mxs_reg_32(name) \
67 struct { __mxs_reg_32(name) }; \
68 struct mxs_register_32 name##_reg; \
71 #endif /* __MXS_REGS_COMMON_H__ */