2 * Freescale i.MX28 Register Accessors
4 * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
5 * on behalf of DENX Software Engineering GmbH
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef __MX28_REGS_COMMON_H__
24 #define __MX28_REGS_COMMON_H__
27 * The i.MX28 has interesting feature when it comes to register access. There
28 * are four kinds of access to one particular register. Those are:
30 * 1) Common read/write access. To use this mode, just write to the address of
32 * 2) Set bits only access. To set bits, write which bits you want to set to the
33 * address of the register + 0x4.
34 * 3) Clear bits only access. To clear bits, write which bits you want to clear
35 * to the address of the register + 0x8.
36 * 4) Toggle bits only access. To toggle bits, write which bits you want to
37 * toggle to the address of the register + 0xc.
39 * IMPORTANT NOTE: Not all registers support accesses 2-4! Also, not all bits
40 * can be set/cleared by pure write as in access type 1, some need to be
41 * explicitly set/cleared by using access type 2-3.
43 * The following macros and structures allow the user to either access the
44 * register in all aforementioned modes (by accessing reg_name, reg_name_set,
45 * reg_name_clr, reg_name_tog) or pass the register structure further into
46 * various functions with correct type information (by accessing reg_name_reg).
50 #define __mx28_reg(name) \
52 uint32_t name##_set; \
53 uint32_t name##_clr; \
56 struct mx28_register {
60 #define mx28_reg(name) \
62 struct { __mx28_reg(name) }; \
63 struct mx28_register name##_reg; \
66 #endif /* __MX28_REGS_COMMON_H__ */