RTEMS 6.1-rc1
alt_clock_manager.h
Go to the documentation of this file.
1
12/******************************************************************************
13*
14* Copyright 2013 Altera Corporation. All Rights Reserved.
15*
16* Redistribution and use in source and binary forms, with or without
17* modification, are permitted provided that the following conditions are met:
18*
19* 1. Redistributions of source code must retain the above copyright notice,
20* this list of conditions and the following disclaimer.
21*
22* 2. Redistributions in binary form must reproduce the above copyright notice,
23* this list of conditions and the following disclaimer in the documentation
24* and/or other materials provided with the distribution.
25*
26* 3. The name of the author may not be used to endorse or promote products
27* derived from this software without specific prior written permission.
28*
29* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
30* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO
32* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
34* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
37* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
38* OF SUCH DAMAGE.
39*
40******************************************************************************/
41
42#ifndef __ALT_CLK_MGR_H__
43#define __ALT_CLK_MGR_H__
44
45#include "hwlib.h"
46#include "alt_clock_group.h"
47
48#ifdef __cplusplus
49extern "C"
50{
51#endif /* __cplusplus */
52
61/******************************************************************************/
66typedef uint32_t alt_freq_t;
67
68/******************************************************************************/
73typedef enum ALT_CLK_e
74{
75 /* Clock Input Pins */
98 /* FPGA Clock Sources External to HPS */
99 ALT_CLK_F2H_PERIPH_REF,
100 /*<! Alternate clock source from FPGA
101 * for HPS Peripheral PLL. */
102
103 ALT_CLK_F2H_SDRAM_REF,
104 /*<! Alternate clock source from FPGA
105 * for HPS SDRAM PLL. */
106
107
108 /* Other Clock Sources External to HPS */
142 /* PLLs */
165 /* OSC1 Clock Group - The OSC1 clock group contains those clocks which are derived
166 * directly from the osc_clk_1_HPS pin */
177 /* Main Clock Group - The following clocks are derived from the Main PLL. */
305 /* Peripherals Clock Group - The following clocks are derived from the Peripheral PLL */
396 /* SDRAM Clock Group - The following clocks are derived from the SDRAM PLL */
442 /* Clock Output Pins */
503 ALT_CLK_UNKNOWN
505
506/******************************************************************************/
514/******************************************************************************/
521{
522 ALT_MAIN_PLL_LOCK_ACHV = 0x00000001,
527 ALT_PERIPH_PLL_LOCK_ACHV = 0x00000002,
532 ALT_SDR_PLL_LOCK_ACHV = 0x00000004,
537 ALT_MAIN_PLL_LOCK_LOST = 0x00000008,
542 ALT_PERIPH_PLL_LOCK_LOST = 0x00000010,
547 ALT_SDR_PLL_LOCK_LOST = 0x00000020
553
554/******************************************************************************/
574
575/******************************************************************************/
585uint32_t alt_clk_lock_status_get(void);
586
587/******************************************************************************/
609
612/******************************************************************************/
650/******************************************************************************/
656{
668
669/******************************************************************************/
680
681/******************************************************************************/
692
695/******************************************************************************/
719/******************************************************************************/
733
734/******************************************************************************/
754 bool use_input_mux);
755
756/******************************************************************************/
775
778/******************************************************************************/
823/******************************************************************************/
837
838/******************************************************************************/
852
853/******************************************************************************/
866
869/******************************************************************************/
916/******************************************************************************/
934
935/******************************************************************************/
956 ALT_CLK_t ref_clk);
957
960/******************************************************************************/
969/******************************************************************************/
997 alt_freq_t freq);
998
999/******************************************************************************/
1018
1019/******************************************************************************/
1024typedef struct ALT_CLK_PLL_CFG_s
1025{
1027 uint32_t mult;
1030 uint32_t div;
1033 uint32_t cntrs[6];
1036 uint32_t pshift[6];
1041
1042/******************************************************************************/
1057 ALT_CLK_PLL_CFG_t* pll_cfg);
1058
1059/******************************************************************************/
1075 const ALT_CLK_PLL_CFG_t* pll_cfg);
1076
1077/******************************************************************************/
1096 uint32_t* mult,
1097 uint32_t* div);
1098
1099/******************************************************************************/
1117 uint32_t mult,
1118 uint32_t div);
1119
1120/******************************************************************************/
1139 alt_freq_t* freq);
1140
1141/******************************************************************************/
1151
1152/******************************************************************************/
1183 uint32_t guard_band);
1184
1185/******************************************************************************/
1209 uint32_t* div);
1210
1211/******************************************************************************/
1237 uint32_t div);
1238
1239/******************************************************************************/
1258 alt_freq_t* freq);
1259
1262/******************************************************************************/
1307/******************************************************************************/
1330
1331/******************************************************************************/
1354
1357/******************************************************************************/
1388/******************************************************************************/
1408 ALT_CLK_GROUP_RAW_CFG_t* clk_group_raw_cfg);
1409
1410/******************************************************************************/
1430
1431ALT_STATUS_CODE alt_clk_clkmgr_init(void);
1432
1436#ifdef __cplusplus
1437}
1438
1439#endif /* __cplusplus */
1440#endif /* __ALT_CLK_MGR_H__ */
enum ALT_CLK_GRP_e ALT_CLK_GRP_t
ALT_STATUS_CODE alt_clk_pll_is_bypassed(ALT_CLK_t pll)
Definition: alt_clock_manager.c:778
ALT_STATUS_CODE alt_clk_pll_bypass_enable(ALT_CLK_t pll, bool use_input_mux)
Definition: alt_clock_manager.c:660
ALT_STATUS_CODE alt_clk_pll_bypass_disable(ALT_CLK_t pll)
Definition: alt_clock_manager.c:530
ALT_STATUS_CODE alt_clk_source_set(ALT_CLK_t clk, ALT_CLK_t ref_clk)
Definition: alt_clock_manager.c:1514
ALT_CLK_t alt_clk_source_get(ALT_CLK_t clk)
Definition: alt_clock_manager.c:1253
ALT_STATUS_CODE alt_clk_divider_get(ALT_CLK_t clk, uint32_t *div)
Definition: alt_clock_manager.c:2658
ALT_STATUS_CODE alt_clk_pll_cfg_get(ALT_CLK_t pll, ALT_CLK_PLL_CFG_t *pll_cfg)
Definition: alt_clock_manager.c:1789
struct ALT_CLK_PLL_CFG_s ALT_CLK_PLL_CFG_t
ALT_STATUS_CODE alt_clk_pll_cfg_set(ALT_CLK_t pll, const ALT_CLK_PLL_CFG_t *pll_cfg)
Definition: alt_clock_manager.c:1931
ALT_STATUS_CODE alt_clk_ext_clk_freq_set(ALT_CLK_t clk, alt_freq_t freq)
Definition: alt_clock_manager.c:1697
ALT_STATUS_CODE alt_clk_pll_vco_cfg_set(ALT_CLK_t pll, uint32_t mult, uint32_t div)
Definition: alt_clock_manager.c:2354
uint32_t alt_clk_pll_guard_band_get(ALT_CLK_t pll)
Definition: alt_clock_manager.c:2596
ALT_STATUS_CODE alt_clk_freq_get(ALT_CLK_t clk, alt_freq_t *freq)
Definition: alt_clock_manager.c:4154
ALT_STATUS_CODE alt_clk_divider_set(ALT_CLK_t clk, uint32_t div)
Definition: alt_clock_manager.c:3082
ALT_STATUS_CODE alt_clk_pll_vco_cfg_get(ALT_CLK_t pll, uint32_t *mult, uint32_t *div)
Definition: alt_clock_manager.c:2084
alt_freq_t alt_clk_ext_clk_freq_get(ALT_CLK_t clk)
Definition: alt_clock_manager.c:1762
ALT_STATUS_CODE alt_clk_pll_guard_band_set(ALT_CLK_t pll, uint32_t guard_band)
Definition: alt_clock_manager.c:2620
ALT_STATUS_CODE alt_clk_pll_vco_freq_get(ALT_CLK_t pll, alt_freq_t *freq)
Definition: alt_clock_manager.c:2477
ALT_STATUS_CODE alt_clk_clock_disable(ALT_CLK_t clk)
Definition: alt_clock_manager.c:859
ALT_STATUS_CODE alt_clk_clock_enable(ALT_CLK_t clk)
Definition: alt_clock_manager.c:972
ALT_STATUS_CODE alt_clk_is_enabled(ALT_CLK_t clk)
Definition: alt_clock_manager.c:1087
ALT_STATUS_CODE alt_clk_group_cfg_raw_set(const ALT_CLK_GROUP_RAW_CFG_t *clk_group_raw_cfg)
Definition: alt_clock_manager.c:4999
ALT_STATUS_CODE alt_clk_group_cfg_raw_get(ALT_CLK_GRP_t clk_group, ALT_CLK_GROUP_RAW_CFG_t *clk_group_raw_cfg)
Definition: alt_clock_manager.c:4875
ALT_STATUS_CODE alt_clk_irq_enable(ALT_CLK_PLL_LOCK_STATUS_t lock_stat_mask)
Definition: alt_clock_manager.c:4856
ALT_STATUS_CODE alt_clk_irq_disable(ALT_CLK_PLL_LOCK_STATUS_t lock_stat_mask)
Definition: alt_clock_manager.c:4839
enum ALT_CLK_SAFE_DOMAIN_e ALT_CLK_SAFE_DOMAIN_t
ALT_STATUS_CODE alt_clk_safe_mode_clear(void)
Definition: alt_clock_manager.c:463
ALT_CLK_SAFE_DOMAIN_e
Definition: alt_clock_manager.h:656
bool alt_clk_is_in_safe_mode(ALT_CLK_SAFE_DOMAIN_t clk_domain)
Definition: alt_clock_manager.c:497
@ ALT_CLK_DOMAIN_DEBUG
Definition: alt_clock_manager.h:666
@ ALT_CLK_DOMAIN_NORMAL
Definition: alt_clock_manager.h:661
enum ALT_CLK_PLL_LOCK_STATUS_e ALT_CLK_PLL_LOCK_STATUS_t
ALT_STATUS_CODE alt_clk_lock_status_clear(ALT_CLK_PLL_LOCK_STATUS_t lock_stat_mask)
Definition: alt_clock_manager.c:392
ALT_STATUS_CODE alt_clk_pll_is_locked(ALT_CLK_t pll)
Definition: alt_clock_manager.c:435
uint32_t alt_clk_lock_status_get(void)
Definition: alt_clock_manager.c:416
ALT_CLK_PLL_LOCK_STATUS_e
Definition: alt_clock_manager.h:521
@ ALT_SDR_PLL_LOCK_LOST
Definition: alt_clock_manager.h:547
@ ALT_PERIPH_PLL_LOCK_LOST
Definition: alt_clock_manager.h:542
@ ALT_MAIN_PLL_LOCK_ACHV
Definition: alt_clock_manager.h:522
@ ALT_SDR_PLL_LOCK_ACHV
Definition: alt_clock_manager.h:532
@ ALT_PERIPH_PLL_LOCK_ACHV
Definition: alt_clock_manager.h:527
@ ALT_MAIN_PLL_LOCK_LOST
Definition: alt_clock_manager.h:537
enum ALT_CLK_e ALT_CLK_t
ALT_CLK_e
Definition: alt_clock_manager.h:74
uint32_t alt_freq_t
Definition: alt_clock_manager.h:66
@ ALT_CLK_IN_PIN_EMAC0_RX
Definition: alt_clock_manager.h:129
@ ALT_CLK_NAND_X
Definition: alt_clock_manager.h:339
@ ALT_CLK_CAN0
Definition: alt_clock_manager.h:370
@ ALT_CLK_OSC1
Definition: alt_clock_manager.h:167
@ ALT_CLK_SPI_M
Definition: alt_clock_manager.h:329
@ ALT_CLK_MAIN_PLL_C5
Definition: alt_clock_manager.h:193
@ ALT_CLK_OUT_PIN_SDMMC
Definition: alt_clock_manager.h:455
@ ALT_CLK_OUT_PIN_I2C1_SCL
Definition: alt_clock_manager.h:467
@ ALT_CLK_DDR_2X_DQS
Definition: alt_clock_manager.h:423
@ ALT_CLK_OUT_PIN_EMAC1_TX
Definition: alt_clock_manager.h:449
@ ALT_CLK_DBG_AT
Definition: alt_clock_manager.h:254
@ ALT_CLK_DBG_TIMER
Definition: alt_clock_manager.h:267
@ ALT_CLK_MPU_PERIPH
Definition: alt_clock_manager.h:208
@ ALT_CLK_PERIPHERAL_PLL_C1
Definition: alt_clock_manager.h:309
@ ALT_CLK_SDRAM_PLL_C3
Definition: alt_clock_manager.h:406
@ ALT_CLK_PERIPHERAL_PLL_C2
Definition: alt_clock_manager.h:312
@ ALT_CLK_MAIN_PLL_C3
Definition: alt_clock_manager.h:187
@ ALT_CLK_DBG
Definition: alt_clock_manager.h:273
@ ALT_CLK_MAIN_PLL_C4
Definition: alt_clock_manager.h:190
@ ALT_CLK_IN_PIN_JTAG
Definition: alt_clock_manager.h:109
@ ALT_CLK_OUT_PIN_SPIM0
Definition: alt_clock_manager.h:485
@ ALT_CLK_PERIPHERAL_PLL_C4
Definition: alt_clock_manager.h:318
@ ALT_CLK_CFG
Definition: alt_clock_manager.h:294
@ ALT_CLK_L3_MP
Definition: alt_clock_manager.h:221
@ ALT_CLK_MPU_L2_RAM
Definition: alt_clock_manager.h:203
@ ALT_CLK_SDRAM_PLL_C5
Definition: alt_clock_manager.h:412
@ ALT_CLK_PERIPHERAL_PLL
Definition: alt_clock_manager.h:150
@ ALT_CLK_QSPI
Definition: alt_clock_manager.h:334
@ ALT_CLK_SDRAM_PLL_C1
Definition: alt_clock_manager.h:400
@ ALT_CLK_EMAC1
Definition: alt_clock_manager.h:363
@ ALT_CLK_MAIN_PLL_C0
Definition: alt_clock_manager.h:178
@ ALT_CLK_GPIO_DB
Definition: alt_clock_manager.h:382
@ ALT_CLK_SDRAM_PLL_C2
Definition: alt_clock_manager.h:403
@ ALT_CLK_L3_SP
Definition: alt_clock_manager.h:226
@ ALT_CLK_H2F_USER0
Definition: alt_clock_manager.h:299
@ ALT_CLK_L3_MAIN
Definition: alt_clock_manager.h:215
@ ALT_CLK_IN_PIN_ULPI1
Definition: alt_clock_manager.h:122
@ ALT_CLK_MAIN_PLL
Definition: alt_clock_manager.h:143
@ ALT_CLK_OUT_PIN_QSPI
Definition: alt_clock_manager.h:497
@ ALT_CLK_H2F_USER2
Definition: alt_clock_manager.h:435
@ ALT_CLK_SDMMC
Definition: alt_clock_manager.h:351
@ ALT_CLK_MAIN_PLL_C2
Definition: alt_clock_manager.h:184
@ ALT_CLK_DBG_TRACE
Definition: alt_clock_manager.h:261
@ ALT_CLK_IN_PIN_OSC1
Definition: alt_clock_manager.h:76
@ ALT_CLK_OUT_PIN_EMAC0_TX
Definition: alt_clock_manager.h:443
@ ALT_CLK_SDRAM_PLL_C4
Definition: alt_clock_manager.h:409
@ ALT_CLK_OUT_PIN_I2C2_SCL
Definition: alt_clock_manager.h:473
@ ALT_CLK_DBG_BASE
Definition: alt_clock_manager.h:248
@ ALT_CLK_PERIPHERAL_PLL_C3
Definition: alt_clock_manager.h:315
@ ALT_CLK_OUT_PIN_SPIM1
Definition: alt_clock_manager.h:491
@ ALT_CLK_EMAC0
Definition: alt_clock_manager.h:356
@ ALT_CLK_SDRAM_PLL
Definition: alt_clock_manager.h:158
@ ALT_CLK_MAIN_NAND_SDMMC
Definition: alt_clock_manager.h:287
@ ALT_CLK_MPU
Definition: alt_clock_manager.h:196
@ ALT_CLK_OUT_PIN_I2C3_SCL
Definition: alt_clock_manager.h:479
@ ALT_CLK_SDRAM_PLL_C0
Definition: alt_clock_manager.h:397
@ ALT_CLK_H2F_USER1
Definition: alt_clock_manager.h:388
@ ALT_CLK_L4_MP
Definition: alt_clock_manager.h:238
@ ALT_CLK_MAIN_QSPI
Definition: alt_clock_manager.h:280
@ ALT_CLK_CAN1
Definition: alt_clock_manager.h:376
@ ALT_CLK_NAND
Definition: alt_clock_manager.h:345
@ ALT_CLK_OUT_PIN_I2C0_SCL
Definition: alt_clock_manager.h:461
@ ALT_CLK_L4_MAIN
Definition: alt_clock_manager.h:231
@ ALT_CLK_IN_PIN_OSC2
Definition: alt_clock_manager.h:87
@ ALT_CLK_IN_PIN_EMAC1_RX
Definition: alt_clock_manager.h:135
@ ALT_CLK_L4_SP
Definition: alt_clock_manager.h:243
@ ALT_CLK_USB_MP
Definition: alt_clock_manager.h:324
@ ALT_CLK_MAIN_PLL_C1
Definition: alt_clock_manager.h:181
@ ALT_CLK_PERIPHERAL_PLL_C5
Definition: alt_clock_manager.h:321
@ ALT_CLK_DDR_DQS
Definition: alt_clock_manager.h:415
@ ALT_CLK_DDR_DQ
Definition: alt_clock_manager.h:429
@ ALT_CLK_PERIPHERAL_PLL_C0
Definition: alt_clock_manager.h:306
@ ALT_CLK_IN_PIN_ULPI0
Definition: alt_clock_manager.h:115
int32_t ALT_STATUS_CODE
Definition: hwlib.h:60
Definition: alt_clock_group.h:73
Definition: alt_clock_manager.h:1025
uint32_t cntrs[6]
Definition: alt_clock_manager.h:1033
uint32_t pshift[6]
Definition: alt_clock_manager.h:1036
uint32_t mult
Definition: alt_clock_manager.h:1027
uint32_t div
Definition: alt_clock_manager.h:1030
ALT_CLK_t ref_clk
Definition: alt_clock_manager.h:1026