xref: /btstack/port/samv71-xplained-atwilc3000/ASF/common/services/clock/pll.h (revision 1b2596b5303dd8caeea8565532c93cca8dab8cc4)
1*1b2596b5SMatthias Ringwald /**
2*1b2596b5SMatthias Ringwald  * \file
3*1b2596b5SMatthias Ringwald  *
4*1b2596b5SMatthias Ringwald  * \brief PLL management
5*1b2596b5SMatthias Ringwald  *
6*1b2596b5SMatthias Ringwald  * Copyright (c) 2010-2015 Atmel Corporation. All rights reserved.
7*1b2596b5SMatthias Ringwald  *
8*1b2596b5SMatthias Ringwald  * \asf_license_start
9*1b2596b5SMatthias Ringwald  *
10*1b2596b5SMatthias Ringwald  * \page License
11*1b2596b5SMatthias Ringwald  *
12*1b2596b5SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
13*1b2596b5SMatthias Ringwald  * modification, are permitted provided that the following conditions are met:
14*1b2596b5SMatthias Ringwald  *
15*1b2596b5SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright notice,
16*1b2596b5SMatthias Ringwald  *    this list of conditions and the following disclaimer.
17*1b2596b5SMatthias Ringwald  *
18*1b2596b5SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright notice,
19*1b2596b5SMatthias Ringwald  *    this list of conditions and the following disclaimer in the documentation
20*1b2596b5SMatthias Ringwald  *    and/or other materials provided with the distribution.
21*1b2596b5SMatthias Ringwald  *
22*1b2596b5SMatthias Ringwald  * 3. The name of Atmel may not be used to endorse or promote products derived
23*1b2596b5SMatthias Ringwald  *    from this software without specific prior written permission.
24*1b2596b5SMatthias Ringwald  *
25*1b2596b5SMatthias Ringwald  * 4. This software may only be redistributed and used in connection with an
26*1b2596b5SMatthias Ringwald  *    Atmel microcontroller product.
27*1b2596b5SMatthias Ringwald  *
28*1b2596b5SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29*1b2596b5SMatthias Ringwald  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30*1b2596b5SMatthias Ringwald  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31*1b2596b5SMatthias Ringwald  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32*1b2596b5SMatthias Ringwald  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33*1b2596b5SMatthias Ringwald  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34*1b2596b5SMatthias Ringwald  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35*1b2596b5SMatthias Ringwald  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36*1b2596b5SMatthias Ringwald  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37*1b2596b5SMatthias Ringwald  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38*1b2596b5SMatthias Ringwald  * POSSIBILITY OF SUCH DAMAGE.
39*1b2596b5SMatthias Ringwald  *
40*1b2596b5SMatthias Ringwald  * \asf_license_stop
41*1b2596b5SMatthias Ringwald  *
42*1b2596b5SMatthias Ringwald  */
43*1b2596b5SMatthias Ringwald /*
44*1b2596b5SMatthias Ringwald  * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45*1b2596b5SMatthias Ringwald  */
46*1b2596b5SMatthias Ringwald #ifndef CLK_PLL_H_INCLUDED
47*1b2596b5SMatthias Ringwald #define CLK_PLL_H_INCLUDED
48*1b2596b5SMatthias Ringwald 
49*1b2596b5SMatthias Ringwald #include "parts.h"
50*1b2596b5SMatthias Ringwald #include "conf_clock.h"
51*1b2596b5SMatthias Ringwald 
52*1b2596b5SMatthias Ringwald #if SAM3S
53*1b2596b5SMatthias Ringwald # include "sam3s/pll.h"
54*1b2596b5SMatthias Ringwald #elif SAM3XA
55*1b2596b5SMatthias Ringwald # include "sam3x/pll.h"
56*1b2596b5SMatthias Ringwald #elif SAM3U
57*1b2596b5SMatthias Ringwald # include "sam3u/pll.h"
58*1b2596b5SMatthias Ringwald #elif SAM3N
59*1b2596b5SMatthias Ringwald # include "sam3n/pll.h"
60*1b2596b5SMatthias Ringwald #elif SAM4S
61*1b2596b5SMatthias Ringwald # include "sam4s/pll.h"
62*1b2596b5SMatthias Ringwald #elif SAM4E
63*1b2596b5SMatthias Ringwald # include "sam4e/pll.h"
64*1b2596b5SMatthias Ringwald #elif SAM4C
65*1b2596b5SMatthias Ringwald # include "sam4c/pll.h"
66*1b2596b5SMatthias Ringwald #elif SAM4CM
67*1b2596b5SMatthias Ringwald # include "sam4cm/pll.h"
68*1b2596b5SMatthias Ringwald #elif SAM4CP
69*1b2596b5SMatthias Ringwald # include "sam4cp/pll.h"
70*1b2596b5SMatthias Ringwald #elif SAM4L
71*1b2596b5SMatthias Ringwald # include "sam4l/pll.h"
72*1b2596b5SMatthias Ringwald #elif SAM4N
73*1b2596b5SMatthias Ringwald # include "sam4n/pll.h"
74*1b2596b5SMatthias Ringwald #elif SAMG
75*1b2596b5SMatthias Ringwald # include "samg/pll.h"
76*1b2596b5SMatthias Ringwald #elif SAMV71
77*1b2596b5SMatthias Ringwald # include "samv71/pll.h"
78*1b2596b5SMatthias Ringwald #elif SAMV70
79*1b2596b5SMatthias Ringwald # include "samv70/pll.h"
80*1b2596b5SMatthias Ringwald #elif SAME70
81*1b2596b5SMatthias Ringwald # include "same70/pll.h"
82*1b2596b5SMatthias Ringwald #elif SAMS70
83*1b2596b5SMatthias Ringwald # include "sams70/pll.h"
84*1b2596b5SMatthias Ringwald #elif (UC3A0 || UC3A1)
85*1b2596b5SMatthias Ringwald # include "uc3a0_a1/pll.h"
86*1b2596b5SMatthias Ringwald #elif UC3A3
87*1b2596b5SMatthias Ringwald # include "uc3a3_a4/pll.h"
88*1b2596b5SMatthias Ringwald #elif UC3B
89*1b2596b5SMatthias Ringwald # include "uc3b0_b1/pll.h"
90*1b2596b5SMatthias Ringwald #elif UC3C
91*1b2596b5SMatthias Ringwald # include "uc3c/pll.h"
92*1b2596b5SMatthias Ringwald #elif UC3D
93*1b2596b5SMatthias Ringwald # include "uc3d/pll.h"
94*1b2596b5SMatthias Ringwald #elif (UC3L0128 || UC3L0256 || UC3L3_L4)
95*1b2596b5SMatthias Ringwald # include "uc3l/pll.h"
96*1b2596b5SMatthias Ringwald #elif XMEGA
97*1b2596b5SMatthias Ringwald # include "xmega/pll.h"
98*1b2596b5SMatthias Ringwald #else
99*1b2596b5SMatthias Ringwald # error Unsupported chip type
100*1b2596b5SMatthias Ringwald #endif
101*1b2596b5SMatthias Ringwald 
102*1b2596b5SMatthias Ringwald /**
103*1b2596b5SMatthias Ringwald  * \ingroup clk_group
104*1b2596b5SMatthias Ringwald  * \defgroup pll_group PLL Management
105*1b2596b5SMatthias Ringwald  *
106*1b2596b5SMatthias Ringwald  * This group contains functions and definitions related to configuring
107*1b2596b5SMatthias Ringwald  * and enabling/disabling on-chip PLLs. A PLL will take an input signal
108*1b2596b5SMatthias Ringwald  * (the \em source), optionally divide the frequency by a configurable
109*1b2596b5SMatthias Ringwald  * \em divider, and then multiply the frequency by a configurable \em
110*1b2596b5SMatthias Ringwald  * multiplier.
111*1b2596b5SMatthias Ringwald  *
112*1b2596b5SMatthias Ringwald  * Some devices don't support input dividers; specifying any other
113*1b2596b5SMatthias Ringwald  * divisor than 1 on these devices will result in an assertion failure.
114*1b2596b5SMatthias Ringwald  * Other devices may have various restrictions to the frequency range of
115*1b2596b5SMatthias Ringwald  * the input and output signals.
116*1b2596b5SMatthias Ringwald  *
117*1b2596b5SMatthias Ringwald  * \par Example: Setting up PLL0 with default parameters
118*1b2596b5SMatthias Ringwald  *
119*1b2596b5SMatthias Ringwald  * The following example shows how to configure and enable PLL0 using
120*1b2596b5SMatthias Ringwald  * the default parameters specified using the configuration symbols
121*1b2596b5SMatthias Ringwald  * listed above.
122*1b2596b5SMatthias Ringwald  * \code
123*1b2596b5SMatthias Ringwald 	pll_enable_config_defaults(0); \endcode
124*1b2596b5SMatthias Ringwald  *
125*1b2596b5SMatthias Ringwald  * To configure, enable PLL0 using the default parameters and to disable
126*1b2596b5SMatthias Ringwald  * a specific feature like Wide Bandwidth Mode (a UC3A3-specific
127*1b2596b5SMatthias Ringwald  * PLL option.), you can use this initialization process.
128*1b2596b5SMatthias Ringwald  * \code
129*1b2596b5SMatthias Ringwald 	struct pll_config pllcfg;
130*1b2596b5SMatthias Ringwald 	if (pll_is_locked(pll_id)) {
131*1b2596b5SMatthias Ringwald 		return; // Pll already running
132*1b2596b5SMatthias Ringwald 	}
133*1b2596b5SMatthias Ringwald 	pll_enable_source(CONFIG_PLL0_SOURCE);
134*1b2596b5SMatthias Ringwald 	pll_config_defaults(&pllcfg, 0);
135*1b2596b5SMatthias Ringwald 	pll_config_set_option(&pllcfg, PLL_OPT_WBM_DISABLE);
136*1b2596b5SMatthias Ringwald 	pll_enable(&pllcfg, 0);
137*1b2596b5SMatthias Ringwald 	pll_wait_for_lock(0); \endcode
138*1b2596b5SMatthias Ringwald  *
139*1b2596b5SMatthias Ringwald  * When the last function call returns, PLL0 is ready to be used as the
140*1b2596b5SMatthias Ringwald  * main system clock source.
141*1b2596b5SMatthias Ringwald  *
142*1b2596b5SMatthias Ringwald  * \section pll_group_config Configuration Symbols
143*1b2596b5SMatthias Ringwald  *
144*1b2596b5SMatthias Ringwald  * Each PLL has a set of default parameters determined by the following
145*1b2596b5SMatthias Ringwald  * configuration symbols in the application's configuration file:
146*1b2596b5SMatthias Ringwald  *   - \b CONFIG_PLLn_SOURCE: The default clock source connected to the
147*1b2596b5SMatthias Ringwald  *     input of PLL \a n. Must be one of the values defined by the
148*1b2596b5SMatthias Ringwald  *     #pll_source enum.
149*1b2596b5SMatthias Ringwald  *   - \b CONFIG_PLLn_MUL: The default multiplier (loop divider) of PLL
150*1b2596b5SMatthias Ringwald  *     \a n.
151*1b2596b5SMatthias Ringwald  *   - \b CONFIG_PLLn_DIV: The default input divider of PLL \a n.
152*1b2596b5SMatthias Ringwald  *
153*1b2596b5SMatthias Ringwald  * These configuration symbols determine the result of calling
154*1b2596b5SMatthias Ringwald  * pll_config_defaults() and pll_get_default_rate().
155*1b2596b5SMatthias Ringwald  *
156*1b2596b5SMatthias Ringwald  * @{
157*1b2596b5SMatthias Ringwald  */
158*1b2596b5SMatthias Ringwald 
159*1b2596b5SMatthias Ringwald //! \name Chip-specific PLL characteristics
160*1b2596b5SMatthias Ringwald //@{
161*1b2596b5SMatthias Ringwald /**
162*1b2596b5SMatthias Ringwald  * \def PLL_MAX_STARTUP_CYCLES
163*1b2596b5SMatthias Ringwald  * \brief Maximum PLL startup time in number of slow clock cycles
164*1b2596b5SMatthias Ringwald  */
165*1b2596b5SMatthias Ringwald /**
166*1b2596b5SMatthias Ringwald  * \def NR_PLLS
167*1b2596b5SMatthias Ringwald  * \brief Number of on-chip PLLs
168*1b2596b5SMatthias Ringwald  */
169*1b2596b5SMatthias Ringwald 
170*1b2596b5SMatthias Ringwald /**
171*1b2596b5SMatthias Ringwald  * \def PLL_MIN_HZ
172*1b2596b5SMatthias Ringwald  * \brief Minimum frequency that the PLL can generate
173*1b2596b5SMatthias Ringwald  */
174*1b2596b5SMatthias Ringwald /**
175*1b2596b5SMatthias Ringwald  * \def PLL_MAX_HZ
176*1b2596b5SMatthias Ringwald  * \brief Maximum frequency that the PLL can generate
177*1b2596b5SMatthias Ringwald  */
178*1b2596b5SMatthias Ringwald /**
179*1b2596b5SMatthias Ringwald  * \def PLL_NR_OPTIONS
180*1b2596b5SMatthias Ringwald  * \brief Number of PLL option bits
181*1b2596b5SMatthias Ringwald  */
182*1b2596b5SMatthias Ringwald //@}
183*1b2596b5SMatthias Ringwald 
184*1b2596b5SMatthias Ringwald /**
185*1b2596b5SMatthias Ringwald  * \enum pll_source
186*1b2596b5SMatthias Ringwald  * \brief PLL clock source
187*1b2596b5SMatthias Ringwald  */
188*1b2596b5SMatthias Ringwald 
189*1b2596b5SMatthias Ringwald //! \name PLL configuration
190*1b2596b5SMatthias Ringwald //@{
191*1b2596b5SMatthias Ringwald 
192*1b2596b5SMatthias Ringwald /**
193*1b2596b5SMatthias Ringwald  * \struct pll_config
194*1b2596b5SMatthias Ringwald  * \brief Hardware-specific representation of PLL configuration.
195*1b2596b5SMatthias Ringwald  *
196*1b2596b5SMatthias Ringwald  * This structure contains one or more device-specific values
197*1b2596b5SMatthias Ringwald  * representing the current PLL configuration. The contents of this
198*1b2596b5SMatthias Ringwald  * structure is typically different from platform to platform, and the
199*1b2596b5SMatthias Ringwald  * user should not access any fields except through the PLL
200*1b2596b5SMatthias Ringwald  * configuration API.
201*1b2596b5SMatthias Ringwald  */
202*1b2596b5SMatthias Ringwald 
203*1b2596b5SMatthias Ringwald /**
204*1b2596b5SMatthias Ringwald  * \fn void pll_config_init(struct pll_config *cfg,
205*1b2596b5SMatthias Ringwald  *              enum pll_source src, unsigned int div, unsigned int mul)
206*1b2596b5SMatthias Ringwald  * \brief Initialize PLL configuration from standard parameters.
207*1b2596b5SMatthias Ringwald  *
208*1b2596b5SMatthias Ringwald  * \note This function may be defined inline because it is assumed to be
209*1b2596b5SMatthias Ringwald  * called very few times, and usually with constant parameters. Inlining
210*1b2596b5SMatthias Ringwald  * it will in such cases reduce the code size significantly.
211*1b2596b5SMatthias Ringwald  *
212*1b2596b5SMatthias Ringwald  * \param cfg The PLL configuration to be initialized.
213*1b2596b5SMatthias Ringwald  * \param src The oscillator to be used as input to the PLL.
214*1b2596b5SMatthias Ringwald  * \param div PLL input divider.
215*1b2596b5SMatthias Ringwald  * \param mul PLL loop divider (i.e. multiplier).
216*1b2596b5SMatthias Ringwald  *
217*1b2596b5SMatthias Ringwald  * \return A configuration which will make the PLL run at
218*1b2596b5SMatthias Ringwald  * (\a mul / \a div) times the frequency of \a src
219*1b2596b5SMatthias Ringwald  */
220*1b2596b5SMatthias Ringwald /**
221*1b2596b5SMatthias Ringwald  * \def pll_config_defaults(cfg, pll_id)
222*1b2596b5SMatthias Ringwald  * \brief Initialize PLL configuration using default parameters.
223*1b2596b5SMatthias Ringwald  *
224*1b2596b5SMatthias Ringwald  * After this function returns, \a cfg will contain a configuration
225*1b2596b5SMatthias Ringwald  * which will make the PLL run at (CONFIG_PLLx_MUL / CONFIG_PLLx_DIV)
226*1b2596b5SMatthias Ringwald  * times the frequency of CONFIG_PLLx_SOURCE.
227*1b2596b5SMatthias Ringwald  *
228*1b2596b5SMatthias Ringwald  * \param cfg The PLL configuration to be initialized.
229*1b2596b5SMatthias Ringwald  * \param pll_id Use defaults for this PLL.
230*1b2596b5SMatthias Ringwald  */
231*1b2596b5SMatthias Ringwald /**
232*1b2596b5SMatthias Ringwald  * \def pll_get_default_rate(pll_id)
233*1b2596b5SMatthias Ringwald  * \brief Get the default rate in Hz of \a pll_id
234*1b2596b5SMatthias Ringwald  */
235*1b2596b5SMatthias Ringwald /**
236*1b2596b5SMatthias Ringwald  * \fn void pll_config_set_option(struct pll_config *cfg,
237*1b2596b5SMatthias Ringwald  *              unsigned int option)
238*1b2596b5SMatthias Ringwald  * \brief Set the PLL option bit \a option in the configuration \a cfg.
239*1b2596b5SMatthias Ringwald  *
240*1b2596b5SMatthias Ringwald  * \param cfg The PLL configuration to be changed.
241*1b2596b5SMatthias Ringwald  * \param option The PLL option bit to be set.
242*1b2596b5SMatthias Ringwald  */
243*1b2596b5SMatthias Ringwald /**
244*1b2596b5SMatthias Ringwald  * \fn void pll_config_clear_option(struct pll_config *cfg,
245*1b2596b5SMatthias Ringwald  *              unsigned int option)
246*1b2596b5SMatthias Ringwald  * \brief Clear the PLL option bit \a option in the configuration \a cfg.
247*1b2596b5SMatthias Ringwald  *
248*1b2596b5SMatthias Ringwald  * \param cfg The PLL configuration to be changed.
249*1b2596b5SMatthias Ringwald  * \param option The PLL option bit to be cleared.
250*1b2596b5SMatthias Ringwald  */
251*1b2596b5SMatthias Ringwald /**
252*1b2596b5SMatthias Ringwald  * \fn void pll_config_read(struct pll_config *cfg, unsigned int pll_id)
253*1b2596b5SMatthias Ringwald  * \brief Read the currently active configuration of \a pll_id.
254*1b2596b5SMatthias Ringwald  *
255*1b2596b5SMatthias Ringwald  * \param cfg The configuration object into which to store the currently
256*1b2596b5SMatthias Ringwald  * active configuration.
257*1b2596b5SMatthias Ringwald  * \param pll_id The ID of the PLL to be accessed.
258*1b2596b5SMatthias Ringwald  */
259*1b2596b5SMatthias Ringwald /**
260*1b2596b5SMatthias Ringwald  * \fn void pll_config_write(const struct pll_config *cfg,
261*1b2596b5SMatthias Ringwald  *              unsigned int pll_id)
262*1b2596b5SMatthias Ringwald  * \brief Activate the configuration \a cfg on \a pll_id
263*1b2596b5SMatthias Ringwald  *
264*1b2596b5SMatthias Ringwald  * \param cfg The configuration object representing the PLL
265*1b2596b5SMatthias Ringwald  * configuration to be activated.
266*1b2596b5SMatthias Ringwald  * \param pll_id The ID of the PLL to be updated.
267*1b2596b5SMatthias Ringwald  */
268*1b2596b5SMatthias Ringwald 
269*1b2596b5SMatthias Ringwald //@}
270*1b2596b5SMatthias Ringwald 
271*1b2596b5SMatthias Ringwald //! \name Interaction with the PLL hardware
272*1b2596b5SMatthias Ringwald //@{
273*1b2596b5SMatthias Ringwald /**
274*1b2596b5SMatthias Ringwald  * \fn void pll_enable(const struct pll_config *cfg,
275*1b2596b5SMatthias Ringwald  *              unsigned int pll_id)
276*1b2596b5SMatthias Ringwald  * \brief Activate the configuration \a cfg and enable PLL \a pll_id.
277*1b2596b5SMatthias Ringwald  *
278*1b2596b5SMatthias Ringwald  * \param cfg The PLL configuration to be activated.
279*1b2596b5SMatthias Ringwald  * \param pll_id The ID of the PLL to be enabled.
280*1b2596b5SMatthias Ringwald  */
281*1b2596b5SMatthias Ringwald /**
282*1b2596b5SMatthias Ringwald  * \fn void pll_disable(unsigned int pll_id)
283*1b2596b5SMatthias Ringwald  * \brief Disable the PLL identified by \a pll_id.
284*1b2596b5SMatthias Ringwald  *
285*1b2596b5SMatthias Ringwald  * After this function is called, the PLL identified by \a pll_id will
286*1b2596b5SMatthias Ringwald  * be disabled. The PLL configuration stored in hardware may be affected
287*1b2596b5SMatthias Ringwald  * by this, so if the caller needs to restore the same configuration
288*1b2596b5SMatthias Ringwald  * later, it should either do a pll_config_read() before disabling the
289*1b2596b5SMatthias Ringwald  * PLL, or remember the last configuration written to the PLL.
290*1b2596b5SMatthias Ringwald  *
291*1b2596b5SMatthias Ringwald  * \param pll_id The ID of the PLL to be disabled.
292*1b2596b5SMatthias Ringwald  */
293*1b2596b5SMatthias Ringwald /**
294*1b2596b5SMatthias Ringwald  * \fn bool pll_is_locked(unsigned int pll_id)
295*1b2596b5SMatthias Ringwald  * \brief Determine whether the PLL is locked or not.
296*1b2596b5SMatthias Ringwald  *
297*1b2596b5SMatthias Ringwald  * \param pll_id The ID of the PLL to check.
298*1b2596b5SMatthias Ringwald  *
299*1b2596b5SMatthias Ringwald  * \retval true The PLL is locked and ready to use as a clock source
300*1b2596b5SMatthias Ringwald  * \retval false The PLL is not yet locked, or has not been enabled.
301*1b2596b5SMatthias Ringwald  */
302*1b2596b5SMatthias Ringwald /**
303*1b2596b5SMatthias Ringwald  * \fn void pll_enable_source(enum pll_source src)
304*1b2596b5SMatthias Ringwald  * \brief Enable the source of the pll.
305*1b2596b5SMatthias Ringwald  * The source is enabled, if the source is not already running.
306*1b2596b5SMatthias Ringwald  *
307*1b2596b5SMatthias Ringwald  * \param src The ID of the PLL source to enable.
308*1b2596b5SMatthias Ringwald  */
309*1b2596b5SMatthias Ringwald /**
310*1b2596b5SMatthias Ringwald  * \fn void pll_enable_config_defaults(unsigned int pll_id)
311*1b2596b5SMatthias Ringwald  * \brief Enable the pll with the default configuration.
312*1b2596b5SMatthias Ringwald  * PLL is enabled, if the PLL is not already locked.
313*1b2596b5SMatthias Ringwald  *
314*1b2596b5SMatthias Ringwald  * \param pll_id The ID of the PLL to enable.
315*1b2596b5SMatthias Ringwald  */
316*1b2596b5SMatthias Ringwald 
317*1b2596b5SMatthias Ringwald /**
318*1b2596b5SMatthias Ringwald  * \brief Wait for PLL \a pll_id to become locked
319*1b2596b5SMatthias Ringwald  *
320*1b2596b5SMatthias Ringwald  * \todo Use a timeout to avoid waiting forever and hanging the system
321*1b2596b5SMatthias Ringwald  *
322*1b2596b5SMatthias Ringwald  * \param pll_id The ID of the PLL to wait for.
323*1b2596b5SMatthias Ringwald  *
324*1b2596b5SMatthias Ringwald  * \retval STATUS_OK The PLL is now locked.
325*1b2596b5SMatthias Ringwald  * \retval ERR_TIMEOUT Timed out waiting for PLL to become locked.
326*1b2596b5SMatthias Ringwald  */
pll_wait_for_lock(unsigned int pll_id)327*1b2596b5SMatthias Ringwald static inline int pll_wait_for_lock(unsigned int pll_id)
328*1b2596b5SMatthias Ringwald {
329*1b2596b5SMatthias Ringwald 	Assert(pll_id < NR_PLLS);
330*1b2596b5SMatthias Ringwald 
331*1b2596b5SMatthias Ringwald 	while (!pll_is_locked(pll_id)) {
332*1b2596b5SMatthias Ringwald 		/* Do nothing */
333*1b2596b5SMatthias Ringwald 	}
334*1b2596b5SMatthias Ringwald 
335*1b2596b5SMatthias Ringwald 	return 0;
336*1b2596b5SMatthias Ringwald }
337*1b2596b5SMatthias Ringwald 
338*1b2596b5SMatthias Ringwald //@}
339*1b2596b5SMatthias Ringwald //! @}
340*1b2596b5SMatthias Ringwald 
341*1b2596b5SMatthias Ringwald #endif /* CLK_PLL_H_INCLUDED */
342