4 * This file is part of BeRTOS.
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.
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.
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
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.
29 * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
34 * \author Francesco Sacchi <batt@develer.com>
36 * AT91 power management controller.
37 * This file is based on NUT/OS implementation. See license below.
41 * Copyright (C) 2005-2006 by egnite Software GmbH. All rights reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. Neither the name of the copyright holders nor the names of
53 * contributors may be used to endorse or promote products derived
54 * from this software without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
57 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
58 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
59 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
60 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
61 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
62 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
63 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
64 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
65 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
66 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * For additional information see http://www.ethernut.de/
75 /** System Clock Enable, Disable and Status Register */
77 #define PMC_SCER_OFF 0x00000000 ///< System clock enable register offset.
78 #define PMC_SCER (*((reg32_t *)(PMC_BASE + PMC_SCER_OFF))) ///< System clock enable register address.
79 #define PMC_SCDR_OFF 0x00000004 ///< System clock disable register offset.
80 #define PMC_SCDR (*((reg32_t *)(PMC_BASE + PMC_SCDR_OFF))) ///< System clock disable register address.
81 #define PMC_SCSR_OFF 0x00000008 ///< System clock status register offset.
82 #define PMC_SCSR (*((reg32_t *)(PMC_BASE + PMC_SCSR_OFF))) ///< System clock status register address.
84 #define PMC_PCK 0 ///< Processor clock.
85 #define PMC_UDP 7 ///< USB device port clock.
86 #define PMC_PCK0 8 ///< Programmable clock 0 output.
87 #define PMC_PCK1 9 ///< Programmable clock 1 output.
88 #define PMC_PCK2 10 ///< Programmable clock 2 output.
91 /** Peripheral Clock Enable, Disable and Status Register */
93 #define PMC_PCER_OFF 0x00000010 ///< Peripheral clock enable register offset.
94 #define PMC_PCER (*((reg32_t *)(PMC_BASE + PMC_PCER_OFF))) ///< Peripheral clock enable register address.
95 #define PMC_PCDR_OFF 0x00000014 ///< Peripheral clock disable register offset.
96 #define PMC_PCDR (*((reg32_t *)(PMC_BASE + PMC_PCDR_OFF))) ///< Peripheral clock disable register address.
97 #define PMC_PCSR_OFF 0x00000018 ///< Peripheral clock status register offset.
98 #define PMC_PCSR (*((reg32_t *)(PMC_BASE + PMC_PCSR_OFF))) ///< Peripheral clock status register address.
101 /** Clock Generator Main Oscillator Register */
103 #define CKGR_MOR_OFF 0x00000020 ///< Main oscillator register offset.
104 #define CKGR_MOR (*((reg32_t *)(PMC_BASE + CKGR_MOR_OFF))) ///< Main oscillator register address.
106 #define CKGR_MOSCEN 0 ///< Main oscillator enable.
107 #define CKGR_OSCBYPASS 1 ///< Main oscillator bypass.
108 #define CKGR_OSCOUNT_MASK 0x0000FF00 ///< Main oscillator start-up time mask.
109 #define CKGR_OSCOUNT_SHIFT 8 ///< Main oscillator start-up time LSB.
112 /** Clock Generator Main Clock Frequency Register */
114 #define CKGR_MCFR_OFF 0x00000024 ///< Main clock frequency register offset.
115 #define CKGR_MCFR (*((reg32_t *)(PMC_BASE + CKGR_MCFR_OFF))) ///< Main clock frequency register address.
117 #define CKGR_MAINF_MASK 0x0000FFFF ///< Main clock frequency mask mask.
118 #define CKGR_MAINRDY 16 ///< Main clock ready.
123 #define CKGR_PLLR_OFF 0x0000002C ///< Clock generator PLL register offset.
124 #define CKGR_PLLR (*((reg32_t *)(PMC_BASE + CKGR_PLLR_OFF))) ///< Clock generator PLL register address.
126 #define CKGR_DIV_MASK 0x000000FF ///< Divider.
127 #define CKGR_DIV_SHIFT 0 ///< Least significant bit of the divider.
128 #define CKGR_DIV_0 0x00000000 ///< Divider output is 0.
129 #define CKGR_DIV_BYPASS 0x00000001 ///< Divider is bypassed.
130 #define CKGR_PLLCOUNT_MASK 0x00003F00 ///< PLL counter mask.
131 #define CKGR_PLLCOUNT_SHIFT 8 ///< PLL counter LSB.
133 #define CKGR_OUT_MASK 0x0000C000 ///< PLL output frequency range.
134 #define CKGR_OUT_0 0x00000000 ///< Please refer to the PLL datasheet.
135 #define CKGR_OUT_1 0x00004000 ///< Please refer to the PLL datasheet.
136 #define CKGR_OUT_2 0x00008000 ///< Please refer to the PLL datasheet.
137 #define CKGR_OUT_3 0x0000C000 ///< Please refer to the PLL datasheet.
138 #define CKGR_MUL_MASK 0x07FF0000 ///< PLL multiplier.
139 #define CKGR_MUL_SHIFT 16 ///< Least significant bit of the PLL multiplier.
141 #define CKGR_USBDIV_MASK 0x30000000 ///< Divider for USB clocks.
142 #define CKGR_USBDIV_1 0x00000000 ///< Divider output is PLL clock output.
143 #define CKGR_USBDIV_2 0x10000000 ///< Divider output is PLL clock output divided by 2.
144 #define CKGR_USBDIV_4 0x20000000 ///< Divider output is PLL clock output divided by 4.
147 /** Master Clock Register */
149 #define PMC_MCKR_OFF 0x00000030 ///< Master clock register offset.
150 #define PMC_MCKR (*((reg32_t *)(PMC_BASE + PMC_MCKR_OFF))) ///< Master clock register address.
152 #define PMC_PCKR0_OFF 0x00000040 ///< Programmable clock 0 register offset.
153 #define PMC_PCKR0 (*((reg32_t *)(PMC_BASE + PMC_PCKR0_OFF))) ///< Programmable clock 0 register address.
154 #define PMC_PCKR1_OFF 0x00000044 ///< Programmable clock 1 register offset.
155 #define PMC_PCKR1 (*((reg32_t *)(PMC_BASE + PMC_PCKR1_OFF))) ///< Programmable clock 1 register address.
156 #define PMC_PCKR2_OFF 0x00000048 ///< Programmable clock 2 register offset.
157 #define PMC_PCKR2 (*((reg32_t *)(PMC_BASE + PMC_PCKR2_OFF))) ///< Programmable clock 2 register address.
159 #define PMC_CSS_MASK 0x00000003 ///< Clock selection mask.
160 #define PMC_CSS_SLOW_CLK 0x00000000 ///< Slow clock selected.
161 #define PMC_CSS_MAIN_CLK 0x00000001 ///< Main clock selected.
162 #define PMC_CSS_PLL_CLK 0x00000003 ///< PLL clock selected.
164 #define PMC_PRES_MASK 0x0000001C ///< Clock prescaler mask.
165 #define PMC_PRES_SHIFT 2 ///< Clock prescaler LSB.
166 #define PMC_PRES_CLK 0x00000000 ///< Selected clock, not divided.
167 #define PMC_PRES_CLK_2 0x00000004 ///< Selected clock divided by 2.
168 #define PMC_PRES_CLK_4 0x00000008 ///< Selected clock divided by 4.
169 #define PMC_PRES_CLK_8 0x0000000C ///< Selected clock divided by 8.
170 #define PMC_PRES_CLK_16 0x00000010 ///< Selected clock divided by 16.
171 #define PMC_PRES_CLK_32 0x00000014 ///< Selected clock divided by 32.
172 #define PMC_PRES_CLK_64 0x00000018 ///< Selected clock divided by 64.
175 /** Power Management Status and Interrupt Registers */
177 #define PMC_IER_OFF 0x00000060 ///< Interrupt enable register offset.
178 #define PMC_IER (*((reg32_t *)(PMC_BASE + PMC_IER_OFF))) ///< Interrupt enable register address.
179 #define PMC_IDR_OFF 0x00000064 ///< Interrupt disable register offset.
180 #define PMC_IDR (*((reg32_t *)(PMC_BASE + PMC_IDR_OFF))) ///< Interrupt disable register address.
181 #define PMC_SR_OFF 0x00000068 ///< Status register offset.
182 #define PMC_SR (*((reg32_t *)(PMC_BASE + PMC_SR_OFF))) ///< Status register address.
183 #define PMC_IMR_OFF 0x0000006C ///< Interrupt mask register offset.
184 #define PMC_IMR (*((reg32_t *)(PMC_BASE + PMC_IMR_OFF))) ///< Interrupt mask register address.
186 #define PMC_MOSCS 0 ///< Main oscillator.
187 #define PMC_LOCK 2 ///< PLL lock.
188 #define PMC_MCKRDY 3 ///< Master clock ready.
189 #define PMC_PCKRDY0 8 ///< Programmable clock 0 ready.
190 #define PMC_PCKRDY1 9 ///< Programmable clock 1 ready.
191 #define PMC_PCKRDY2 10 ///< Programmable clock 2 ready.
194 #endif /* AT91_PMC_H */