Merge branch 'kirkwood/boards' of git://git.infradead.org/users/jcooper/linux into...
[deliverable/linux.git] / arch / arm / mach-bcmring / include / mach / csp / reg.h
1 /*****************************************************************************
2 * Copyright 2003 - 2008 Broadcom Corporation. All rights reserved.
3 *
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").
8 *
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
12 * consent.
13 *****************************************************************************/
14
15 /****************************************************************************/
16 /**
17 * @file reg.h
18 *
19 * @brief Generic register definitions used in CSP
20 */
21 /****************************************************************************/
22
23 #ifndef CSP_REG_H
24 #define CSP_REG_H
25
26 /* ---- Include Files ---------------------------------------------------- */
27
28 #include <linux/types.h>
29 #include <linux/io.h>
30
31 /* ---- Public Constants and Types --------------------------------------- */
32
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)))
36
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. */
42 /* typedef struct */
43 /* { */
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 */
50 /* ... */
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)]
55
56 /* ---- Public Variable Externs ------------------------------------------ */
57 /* ---- Public Function Prototypes --------------------------------------- */
58
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. */
62 /* e.g. */
63 /* statement1; */
64 /* { */
65 /* REG_LOCAL_IRQ_SAVE; */
66 /* <multiple statements here> */
67 /* REG_LOCAL_IRQ_RESTORE; */
68 /* } */
69 /* statement2; */
70 /* */
71
72 #if defined(__KERNEL__) && !defined(STANDALONE)
73 #include <mach/hardware.h>
74 #include <linux/interrupt.h>
75
76 #define REG_LOCAL_IRQ_SAVE HW_DECLARE_SPINLOCK(reg32) \
77 unsigned long flags; HW_IRQ_SAVE(reg32, flags)
78
79 #define REG_LOCAL_IRQ_RESTORE HW_IRQ_RESTORE(reg32, flags)
80
81 #else
82
83 #define REG_LOCAL_IRQ_SAVE
84 #define REG_LOCAL_IRQ_RESTORE
85
86 #endif
87
88 static inline void reg32_modify_and(volatile uint32_t __iomem *reg, uint32_t value)
89 {
90 REG_LOCAL_IRQ_SAVE;
91 __raw_writel(__raw_readl(reg) & value, reg);
92 REG_LOCAL_IRQ_RESTORE;
93 }
94
95 static inline void reg32_modify_or(volatile uint32_t __iomem *reg, uint32_t value)
96 {
97 REG_LOCAL_IRQ_SAVE;
98 __raw_writel(__raw_readl(reg) | value, reg);
99 REG_LOCAL_IRQ_RESTORE;
100 }
101
102 static inline void reg32_modify_mask(volatile uint32_t __iomem *reg, uint32_t mask,
103 uint32_t value)
104 {
105 REG_LOCAL_IRQ_SAVE;
106 __raw_writel((__raw_readl(reg) & mask) | value, reg);
107 REG_LOCAL_IRQ_RESTORE;
108 }
109
110 static inline void reg32_write(volatile uint32_t __iomem *reg, uint32_t value)
111 {
112 __raw_writel(value, reg);
113 }
114
115 #endif /* CSP_REG_H */
This page took 0.033412 seconds and 5 git commands to generate.