Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm
[linux-2.6] / arch / avr32 / mach-at32ap / pm.h
1 /*
2  * Register definitions for the Power Manager (PM)
3  */
4 #ifndef __ARCH_AVR32_MACH_AT32AP_PM_H__
5 #define __ARCH_AVR32_MACH_AT32AP_PM_H__
6
7 /*
8  * We can reduce the code size a bit by using a constant here. Since
9  * this file is only used on AVR32 AP CPUs with segmentation enabled,
10  * it's safe to not use ioremap. Generic drivers should of course
11  * never do this.
12  */
13 #define AT32_PM_BASE    0xfff00000
14
15 /* PM register offsets */
16 #define PM_MCCTRL                               0x0000
17 #define PM_CKSEL                                0x0004
18 #define PM_CPU_MASK                             0x0008
19 #define PM_HSB_MASK                             0x000c
20 #define PM_PBA_MASK                             0x0010
21 #define PM_PBB_MASK                             0x0014
22 #define PM_PLL0                                 0x0020
23 #define PM_PLL1                                 0x0024
24 #define PM_IER                                  0x0040
25 #define PM_IDR                                  0x0044
26 #define PM_IMR                                  0x0048
27 #define PM_ISR                                  0x004c
28 #define PM_ICR                                  0x0050
29 #define PM_GCCTRL(x)                            (0x0060 + 4 * (x))
30 #define PM_RCAUSE                               0x00c0
31
32 /* Bitfields in CKSEL */
33 #define PM_CPUSEL_OFFSET                        0
34 #define PM_CPUSEL_SIZE                          3
35 #define PM_CPUDIV_OFFSET                        7
36 #define PM_CPUDIV_SIZE                          1
37 #define PM_HSBSEL_OFFSET                        8
38 #define PM_HSBSEL_SIZE                          3
39 #define PM_HSBDIV_OFFSET                        15
40 #define PM_HSBDIV_SIZE                          1
41 #define PM_PBASEL_OFFSET                        16
42 #define PM_PBASEL_SIZE                          3
43 #define PM_PBADIV_OFFSET                        23
44 #define PM_PBADIV_SIZE                          1
45 #define PM_PBBSEL_OFFSET                        24
46 #define PM_PBBSEL_SIZE                          3
47 #define PM_PBBDIV_OFFSET                        31
48 #define PM_PBBDIV_SIZE                          1
49
50 /* Bitfields in PLL0 */
51 #define PM_PLLEN_OFFSET                         0
52 #define PM_PLLEN_SIZE                           1
53 #define PM_PLLOSC_OFFSET                        1
54 #define PM_PLLOSC_SIZE                          1
55 #define PM_PLLOPT_OFFSET                        2
56 #define PM_PLLOPT_SIZE                          3
57 #define PM_PLLDIV_OFFSET                        8
58 #define PM_PLLDIV_SIZE                          8
59 #define PM_PLLMUL_OFFSET                        16
60 #define PM_PLLMUL_SIZE                          8
61 #define PM_PLLCOUNT_OFFSET                      24
62 #define PM_PLLCOUNT_SIZE                        6
63 #define PM_PLLTEST_OFFSET                       31
64 #define PM_PLLTEST_SIZE                         1
65
66 /* Bitfields in ICR */
67 #define PM_LOCK0_OFFSET                         0
68 #define PM_LOCK0_SIZE                           1
69 #define PM_LOCK1_OFFSET                         1
70 #define PM_LOCK1_SIZE                           1
71 #define PM_WAKE_OFFSET                          2
72 #define PM_WAKE_SIZE                            1
73 #define PM_CKRDY_OFFSET                         5
74 #define PM_CKRDY_SIZE                           1
75 #define PM_MSKRDY_OFFSET                        6
76 #define PM_MSKRDY_SIZE                          1
77
78 /* Bitfields in GCCTRL0 */
79 #define PM_OSCSEL_OFFSET                        0
80 #define PM_OSCSEL_SIZE                          1
81 #define PM_PLLSEL_OFFSET                        1
82 #define PM_PLLSEL_SIZE                          1
83 #define PM_CEN_OFFSET                           2
84 #define PM_CEN_SIZE                             1
85 #define PM_DIVEN_OFFSET                         4
86 #define PM_DIVEN_SIZE                           1
87 #define PM_DIV_OFFSET                           8
88 #define PM_DIV_SIZE                             8
89
90 /* Bitfields in RCAUSE */
91 #define PM_POR_OFFSET                           0
92 #define PM_POR_SIZE                             1
93 #define PM_EXT_OFFSET                           2
94 #define PM_EXT_SIZE                             1
95 #define PM_WDT_OFFSET                           3
96 #define PM_WDT_SIZE                             1
97 #define PM_NTAE_OFFSET                          4
98 #define PM_NTAE_SIZE                            1
99
100 /* Bit manipulation macros */
101 #define PM_BIT(name)                                    \
102         (1 << PM_##name##_OFFSET)
103 #define PM_BF(name,value)                               \
104         (((value) & ((1 << PM_##name##_SIZE) - 1))      \
105          << PM_##name##_OFFSET)
106 #define PM_BFEXT(name,value)                            \
107         (((value) >> PM_##name##_OFFSET)                \
108          & ((1 << PM_##name##_SIZE) - 1))
109 #define PM_BFINS(name,value,old)\
110         (((old) & ~(((1 << PM_##name##_SIZE) - 1)       \
111                     << PM_##name##_OFFSET))             \
112          | PM_BF(name,value))
113
114 /* Register access macros */
115 #define pm_readl(reg)                                                   \
116         __raw_readl((void __iomem __force *)AT32_PM_BASE + PM_##reg)
117 #define pm_writel(reg,value)                                            \
118         __raw_writel((value), (void __iomem __force *)AT32_PM_BASE + PM_##reg)
119
120 #endif /* __ARCH_AVR32_MACH_AT32AP_PM_H__ */