Refactor BeRTOS to be in his own directory.
[bertos.git] / cpu / arm / io / at91_pmc.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \version $Id$
34  *
35  * \author Francesco Sacchi <batt@develer.com>
36  *
37  * AT91 power management controller.
38  * This file is based on NUT/OS implementation. See license below.
39  */
40
41 /*
42  * Copyright (C) 2005-2006 by egnite Software GmbH. All rights reserved.
43  *
44  * Redistribution and use in source and binary forms, with or without
45  * modification, are permitted provided that the following conditions
46  * are met:
47  *
48  * 1. Redistributions of source code must retain the above copyright
49  *    notice, this list of conditions and the following disclaimer.
50  * 2. Redistributions in binary form must reproduce the above copyright
51  *    notice, this list of conditions and the following disclaimer in the
52  *    documentation and/or other materials provided with the distribution.
53  * 3. Neither the name of the copyright holders nor the names of
54  *    contributors may be used to endorse or promote products derived
55  *    from this software without specific prior written permission.
56  *
57  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
58  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
59  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
60  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
61  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
62  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
63  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
64  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
65  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
66  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
67  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68  * SUCH DAMAGE.
69  *
70  * For additional information see http://www.ethernut.de/
71  */
72
73 #ifndef AT91_PMC_H
74 #define AT91_PMC_H
75
76 /** System Clock Enable, Disable and Status Register */
77 /*\{*/
78 #define PMC_SCER_OFF                0x00000000  ///< System clock enable register offset.
79 #define PMC_SCER    (*((reg32_t *)(PMC_BASE + PMC_SCER_OFF)))   ///< System clock enable register address.
80 #define PMC_SCDR_OFF                0x00000004  ///< System clock disable register offset.
81 #define PMC_SCDR    (*((reg32_t *)(PMC_BASE + PMC_SCDR_OFF)))   ///< System clock disable register address.
82 #define PMC_SCSR_OFF                0x00000008  ///< System clock status register offset.
83 #define PMC_SCSR    (*((reg32_t *)(PMC_BASE + PMC_SCSR_OFF)))   ///< System clock status register address.
84
85 #define PMC_PCK                              0  ///< Processor clock.
86 #define PMC_UDP                              7  ///< USB device port clock.
87 #define PMC_PCK0                             8  ///< Programmable clock 0 output.
88 #define PMC_PCK1                             9  ///< Programmable clock 1 output.
89 #define PMC_PCK2                            10  ///< Programmable clock 2 output.
90 /*\}*/
91
92 /** Peripheral Clock Enable, Disable and Status Register */
93 /*\{*/
94 #define PMC_PCER_OFF                0x00000010  ///< Peripheral clock enable register offset.
95 #define PMC_PCER    (*((reg32_t *)(PMC_BASE + PMC_PCER_OFF)))   ///< Peripheral clock enable register address.
96 #define PMC_PCDR_OFF                0x00000014  ///< Peripheral clock disable register offset.
97 #define PMC_PCDR    (*((reg32_t *)(PMC_BASE + PMC_PCDR_OFF)))   ///< Peripheral clock disable register address.
98 #define PMC_PCSR_OFF                0x00000018  ///< Peripheral clock status register offset.
99 #define PMC_PCSR    (*((reg32_t *)(PMC_BASE + PMC_PCSR_OFF)))   ///< Peripheral clock status register address.
100 /*\}*/
101
102 /** Clock Generator Main Oscillator Register */
103 /*\{*/
104 #define CKGR_MOR_OFF                0x00000020  ///< Main oscillator register offset.
105 #define CKGR_MOR    (*((reg32_t *)(PMC_BASE + CKGR_MOR_OFF)))   ///< Main oscillator register address.
106
107 #define CKGR_MOSCEN                          0  ///< Main oscillator enable.
108 #define CKGR_OSCBYPASS                       1  ///< Main oscillator bypass.
109 #define CKGR_OSCOUNT_MASK           0x0000FF00  ///< Main oscillator start-up time mask.
110 #define CKGR_OSCOUNT_SHIFT                   8  ///< Main oscillator start-up time LSB.
111 /*\}*/
112
113 /** Clock Generator Main Clock Frequency Register */
114 /*\{*/
115 #define CKGR_MCFR_OFF               0x00000024  ///< Main clock frequency register offset.
116 #define CKGR_MCFR   (*((reg32_t *)(PMC_BASE + CKGR_MCFR_OFF)))  ///< Main clock frequency register address.
117
118 #define CKGR_MAINF_MASK             0x0000FFFF  ///< Main clock frequency mask mask.
119 #define CKGR_MAINRDY                        16  ///< Main clock ready.
120 /*\}*/
121
122 /** PLL Registers */
123 /*\{*/
124 #define CKGR_PLLR_OFF               0x0000002C  ///< Clock generator PLL register offset.
125 #define CKGR_PLLR   (*((reg32_t *)(PMC_BASE + CKGR_PLLR_OFF)))  ///< Clock generator PLL register address.
126
127 #define CKGR_DIV_MASK               0x000000FF  ///< Divider.
128 #define CKGR_DIV_SHIFT                       0  ///< Least significant bit of the divider.
129 #define CKGR_DIV_0                  0x00000000  ///< Divider output is 0.
130 #define CKGR_DIV_BYPASS             0x00000001  ///< Divider is bypassed.
131 #define CKGR_PLLCOUNT_MASK          0x00003F00  ///< PLL counter mask.
132 #define CKGR_PLLCOUNT_SHIFT                  8  ///< PLL counter LSB.
133
134 #define CKGR_OUT_MASK               0x0000C000  ///< PLL output frequency range.
135 #define CKGR_OUT_0                  0x00000000  ///< Please refer to the PLL datasheet.
136 #define CKGR_OUT_1                  0x00004000  ///< Please refer to the PLL datasheet.
137 #define CKGR_OUT_2                  0x00008000  ///< Please refer to the PLL datasheet.
138 #define CKGR_OUT_3                  0x0000C000  ///< Please refer to the PLL datasheet.
139 #define CKGR_MUL_MASK               0x07FF0000  ///< PLL multiplier.
140 #define CKGR_MUL_SHIFT                      16  ///< Least significant bit of the PLL multiplier.
141
142 #define CKGR_USBDIV_MASK            0x30000000  ///< Divider for USB clocks.
143 #define CKGR_USBDIV_1               0x00000000  ///< Divider output is PLL clock output.
144 #define CKGR_USBDIV_2               0x10000000  ///< Divider output is PLL clock output divided by 2.
145 #define CKGR_USBDIV_4               0x20000000  ///< Divider output is PLL clock output divided by 4.
146 /*\}*/
147
148 /** Master Clock Register */
149 /*\{*/
150 #define PMC_MCKR_OFF                0x00000030  ///< Master clock register offset.
151 #define PMC_MCKR    (*((reg32_t *)(PMC_BASE + PMC_MCKR_OFF)))   ///< Master clock register address.
152
153 #define PMC_PCKR0_OFF               0x00000040  ///< Programmable clock 0 register offset.
154 #define PMC_PCKR0   (*((reg32_t *)(PMC_BASE + PMC_PCKR0_OFF)))  ///< Programmable clock 0 register address.
155 #define PMC_PCKR1_OFF               0x00000044  ///< Programmable clock 1 register offset.
156 #define PMC_PCKR1   (*((reg32_t *)(PMC_BASE + PMC_PCKR1_OFF)))  ///< Programmable clock 1 register address.
157 #define PMC_PCKR2_OFF               0x00000048  ///< Programmable clock 2 register offset.
158 #define PMC_PCKR2   (*((reg32_t *)(PMC_BASE + PMC_PCKR2_OFF)))  ///< Programmable clock 2 register address.
159
160 #define PMC_CSS_MASK                0x00000003  ///< Clock selection mask.
161 #define PMC_CSS_SLOW_CLK            0x00000000  ///< Slow clock selected.
162 #define PMC_CSS_MAIN_CLK            0x00000001  ///< Main clock selected.
163 #define PMC_CSS_PLL_CLK             0x00000003  ///< PLL clock selected.
164
165 #define PMC_PRES_MASK               0x0000001C  ///< Clock prescaler mask.
166 #define PMC_PRES_SHIFT                       2   ///< Clock prescaler LSB.
167 #define PMC_PRES_CLK                0x00000000  ///< Selected clock, not divided.
168 #define PMC_PRES_CLK_2              0x00000004  ///< Selected clock divided by 2.
169 #define PMC_PRES_CLK_4              0x00000008  ///< Selected clock divided by 4.
170 #define PMC_PRES_CLK_8              0x0000000C  ///< Selected clock divided by 8.
171 #define PMC_PRES_CLK_16             0x00000010  ///< Selected clock divided by 16.
172 #define PMC_PRES_CLK_32             0x00000014  ///< Selected clock divided by 32.
173 #define PMC_PRES_CLK_64             0x00000018  ///< Selected clock divided by 64.
174 /*\}*/
175
176 /** Power Management Status and Interrupt Registers */
177 /*\{*/
178 #define PMC_IER_OFF                 0x00000060  ///< Interrupt enable register offset.
179 #define PMC_IER     (*((reg32_t *)(PMC_BASE + PMC_IER_OFF)))    ///< Interrupt enable register address.
180 #define PMC_IDR_OFF                 0x00000064  ///< Interrupt disable register offset.
181 #define PMC_IDR     (*((reg32_t *)(PMC_BASE + PMC_IDR_OFF)))    ///< Interrupt disable register address.
182 #define PMC_SR_OFF                  0x00000068  ///< Status register offset.
183 #define PMC_SR      (*((reg32_t *)(PMC_BASE + PMC_SR_OFF)))     ///< Status register address.
184 #define PMC_IMR_OFF                 0x0000006C  ///< Interrupt mask register offset.
185 #define PMC_IMR     (*((reg32_t *)(PMC_BASE + PMC_IMR_OFF)))    ///< Interrupt mask register address.
186
187 #define PMC_MOSCS                            0  ///< Main oscillator.
188 #define PMC_LOCK                             2  ///< PLL lock.
189 #define PMC_MCKRDY                           3  ///< Master clock ready.
190 #define PMC_PCKRDY0                          8  ///< Programmable clock 0 ready.
191 #define PMC_PCKRDY1                          9  ///< Programmable clock 1 ready.
192 #define PMC_PCKRDY2                         10  ///< Programmable clock 2 ready.
193 /*\}*/
194
195 #endif /* AT91_PMC_H */