87 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			87 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
							 | 
						||
| 
								 | 
							
								be copied by any method or incorporated into another program without
							 | 
						||
| 
								 | 
							
								the express written consent of Aerospace C.Power. This Information or any portion
							 | 
						||
| 
								 | 
							
								thereof remains the property of Aerospace C.Power. The Information contained herein
							 | 
						||
| 
								 | 
							
								is believed to be accurate and Aerospace C.Power assumes no responsibility or
							 | 
						||
| 
								 | 
							
								liability for its use in any way and conveys no license or title under
							 | 
						||
| 
								 | 
							
								any patent or copyright and makes no representation or warranty that this
							 | 
						||
| 
								 | 
							
								Information is free from patent or copyright infringement.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								#ifndef _CLK_H
							 | 
						||
| 
								 | 
							
								#define _CLK_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if HW_PLATFORM > HW_PLATFORM_SIMU
							 | 
						||
| 
								 | 
							
								#include "clk_hw.h"
							 | 
						||
| 
								 | 
							
								#else
							 | 
						||
| 
								 | 
							
								typedef enum {
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_25M = 0,
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_75M,
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_150M,
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_160M,
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_170M,
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_180M,
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_200M,
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    CPU_FREQ_MAX,
							 | 
						||
| 
								 | 
							
								} CPU_FREQ;
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								extern uint32_t g_cpu_freq;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								int clk_core_freq_set(uint32_t freq);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t clk_core_freq_get();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void clk_i2s_dev_set(uint32_t div, uint32_t m, uint32_t n);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void clk_core_freq_slip_25m_set();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void clk_core_freq_slip_150m_set();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								uint32_t clk_pwm_src_freq_get(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void clk_pwm_src_freq_set(uint32_t frq);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief clk_core_init() - set clock source and frequency division coefficient.
							 | 
						||
| 
								 | 
							
								 * @return none.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void clk_core_init(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* Clock source type */
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_XTL        1
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_APB        2
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_MPLL       3
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_WPHY_FCLK  4
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_PLC_ADC    5
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_PLC_DAC    6
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_TPID       7
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_METER      8
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_AHB        9
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_PLC_50     10
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_PLC_75     11
							 | 
						||
| 
								 | 
							
								#define CLK_TYPE_PLC_150    12
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* Frequency division coefficient */
							 | 
						||
| 
								 | 
							
								#define CLK_DIV1    0x0
							 | 
						||
| 
								 | 
							
								#define CLK_DIV2    0x1
							 | 
						||
| 
								 | 
							
								#define CLK_DIV4    0x3
							 | 
						||
| 
								 | 
							
								#define CLK_DIV8    0x7
							 | 
						||
| 
								 | 
							
								#define CLK_DIV16   0xF
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/*
							 | 
						||
| 
								 | 
							
								 * Type : 1-XTL, 2-APB, 3-MPLL, 4-WPHY_FCLK, 5-PLC_ADC, 6-PLC_DAC, 7-TPID,
							 | 
						||
| 
								 | 
							
								 *        8-METER, 9-AHB, 10-PLC_50, 11-PLC_75, 12-PLC_150.
							 | 
						||
| 
								 | 
							
								 * div : 0x0 - DIV1, 0x1 - DIV2, 0x3 - DIV4, 0x7 - DIV8, 0xF - DIV16.
							 | 
						||
| 
								 | 
							
								 * gpio : gpio to output the selected clock.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t clk_debug_output_set(uint32_t type, uint32_t div, uint32_t gpio);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif //_CLK_H
							 | 
						||
| 
								 | 
							
								
							 |