2015-08-30 22:55:28 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2015 Google, Inc
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_ARCH_CLOCK_H
|
|
|
|
#define _ASM_ARCH_CLOCK_H
|
|
|
|
|
|
|
|
/* define pll mode */
|
|
|
|
#define RKCLK_PLL_MODE_SLOW 0
|
|
|
|
#define RKCLK_PLL_MODE_NORMAL 1
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ROCKCHIP_SYSCON_NOC,
|
|
|
|
ROCKCHIP_SYSCON_GRF,
|
|
|
|
ROCKCHIP_SYSCON_SGRF,
|
|
|
|
ROCKCHIP_SYSCON_PMU,
|
2016-08-16 09:58:10 +00:00
|
|
|
ROCKCHIP_SYSCON_PMUGRF,
|
2017-02-13 09:38:59 +00:00
|
|
|
ROCKCHIP_SYSCON_PMUSGRF,
|
|
|
|
ROCKCHIP_SYSCON_CIC,
|
2015-08-30 22:55:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Standard Rockchip clock numbers */
|
|
|
|
enum rk_clk_id {
|
|
|
|
CLK_OSC,
|
|
|
|
CLK_ARM,
|
|
|
|
CLK_DDR,
|
|
|
|
CLK_CODEC,
|
|
|
|
CLK_GENERAL,
|
|
|
|
CLK_NEW,
|
|
|
|
|
|
|
|
CLK_COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int rk_pll_id(enum rk_clk_id clk_id)
|
|
|
|
{
|
|
|
|
return clk_id - 1;
|
|
|
|
}
|
|
|
|
|
2015-09-02 01:19:37 +00:00
|
|
|
/**
|
|
|
|
* clk_get_divisor() - Calculate the required clock divisior
|
|
|
|
*
|
|
|
|
* Given an input rate and a required output_rate, calculate the Rockchip
|
|
|
|
* divisor needed to achieve this.
|
|
|
|
*
|
|
|
|
* @input_rate: Input clock rate in Hz
|
|
|
|
* @output_rate: Output clock rate in Hz
|
|
|
|
* @return divisor register value to use
|
|
|
|
*/
|
|
|
|
static inline u32 clk_get_divisor(ulong input_rate, uint output_rate)
|
|
|
|
{
|
|
|
|
uint clk_div;
|
|
|
|
|
|
|
|
clk_div = input_rate / output_rate;
|
|
|
|
clk_div = (clk_div + 1) & 0xfffe;
|
|
|
|
|
|
|
|
return clk_div;
|
|
|
|
}
|
|
|
|
|
2015-08-30 22:55:28 +00:00
|
|
|
/**
|
|
|
|
* rockchip_get_cru() - get a pointer to the clock/reset unit registers
|
|
|
|
*
|
|
|
|
* @return pointer to registers, or -ve error on error
|
|
|
|
*/
|
|
|
|
void *rockchip_get_cru(void);
|
|
|
|
|
2017-02-13 09:38:56 +00:00
|
|
|
/**
|
|
|
|
* rockchip_get_pmucru() - get a pointer to the clock/reset unit registers
|
|
|
|
*
|
|
|
|
* @return pointer to registers, or -ve error on error
|
|
|
|
*/
|
|
|
|
void *rockchip_get_pmucru(void);
|
|
|
|
|
2016-01-22 02:45:17 +00:00
|
|
|
struct rk3288_cru;
|
|
|
|
struct rk3288_grf;
|
|
|
|
|
2016-07-15 22:17:16 +00:00
|
|
|
void rk3288_clk_configure_cpu(struct rk3288_cru *cru, struct rk3288_grf *grf);
|
2016-01-22 02:45:17 +00:00
|
|
|
|
2016-07-17 21:23:16 +00:00
|
|
|
int rockchip_get_clk(struct udevice **devp);
|
|
|
|
|
2015-08-30 22:55:28 +00:00
|
|
|
#endif
|