1 /*****************************************************************************
2 * Copyright 2003 - 2008 Broadcom Corporation. All rights reserved.
4 * Unless you and Broadcom execute a separate written software license
5 * agreement governing use of this software, this software is licensed to you
6 * under the terms of the GNU General Public License version 2, available at
7 * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
9 * Notwithstanding the above, under no circumstances may you combine this
10 * software in any way with any other Broadcom software provided under a
11 * license other than the GPL, without Broadcom's express prior written
13 *****************************************************************************/
15 /****************************************************************************/
19 * @brief Generic register definitions used in CSP
21 /****************************************************************************/
26 /* ---- Include Files ---------------------------------------------------- */
28 #include <linux/types.h>
31 /* ---- Public Constants and Types --------------------------------------- */
33 #define __REG32(x) (*((volatile uint32_t __iomem *)(x)))
34 #define __REG16(x) (*((volatile uint16_t __iomem *)(x)))
35 #define __REG8(x) (*((volatile uint8_t __iomem *) (x)))
37 /* Macros used to define a sequence of reserved registers. The start / end */
38 /* are byte offsets in the particular register definition, with the "end" */
39 /* being the offset of the next un-reserved register. E.g. if offsets */
40 /* 0x10 through to 0x1f are reserved, then this reserved area could be */
41 /* specified as follows. */
44 /* uint32_t reg1; offset 0x00 */
45 /* uint32_t reg2; offset 0x04 */
46 /* uint32_t reg3; offset 0x08 */
47 /* uint32_t reg4; offset 0x0c */
48 /* REG32_RSVD(0x10, 0x20); */
49 /* uint32_t reg5; offset 0x20 */
51 /* } EXAMPLE_REG_t; */
52 #define REG8_RSVD(start, end) uint8_t rsvd_##start[(end - start) / sizeof(uint8_t)]
53 #define REG16_RSVD(start, end) uint16_t rsvd_##start[(end - start) / sizeof(uint16_t)]
54 #define REG32_RSVD(start, end) uint32_t rsvd_##start[(end - start) / sizeof(uint32_t)]
56 /* ---- Public Variable Externs ------------------------------------------ */
57 /* ---- Public Function Prototypes --------------------------------------- */
59 /* Note: When protecting multiple statements, the REG_LOCAL_IRQ_SAVE and */
60 /* REG_LOCAL_IRQ_RESTORE must be enclosed in { } to allow the */
61 /* flags variable to be declared locally. */
65 /* REG_LOCAL_IRQ_SAVE; */
66 /* <multiple statements here> */
67 /* REG_LOCAL_IRQ_RESTORE; */
72 #if defined(__KERNEL__) && !defined(STANDALONE)
73 #include <mach/hardware.h>
74 #include <linux/interrupt.h>
76 #define REG_LOCAL_IRQ_SAVE HW_DECLARE_SPINLOCK(reg32) \
77 unsigned long flags; HW_IRQ_SAVE(reg32, flags)
79 #define REG_LOCAL_IRQ_RESTORE HW_IRQ_RESTORE(reg32, flags)
83 #define REG_LOCAL_IRQ_SAVE
84 #define REG_LOCAL_IRQ_RESTORE
88 static inline void reg32_modify_and(volatile uint32_t __iomem
*reg
, uint32_t value
)
91 __raw_writel(__raw_readl(reg
) & value
, reg
);
92 REG_LOCAL_IRQ_RESTORE
;
95 static inline void reg32_modify_or(volatile uint32_t __iomem
*reg
, uint32_t value
)
98 __raw_writel(__raw_readl(reg
) | value
, reg
);
99 REG_LOCAL_IRQ_RESTORE
;
102 static inline void reg32_modify_mask(volatile uint32_t __iomem
*reg
, uint32_t mask
,
106 __raw_writel((__raw_readl(reg
) & mask
) | value
, reg
);
107 REG_LOCAL_IRQ_RESTORE
;
110 static inline void reg32_write(volatile uint32_t __iomem
*reg
, uint32_t value
)
112 __raw_writel(value
, reg
);
115 #endif /* CSP_REG_H */
This page took 0.033412 seconds and 5 git commands to generate.