mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-27 23:35:10 +00:00
feat(nxp-clk): add get_rate for s32cc_dfs
Add the option to obtain the rate of an s32cc_dfs object. The DFS rate depends on the module to which it's connected. Therefore, it will always return the rate of its parent. Change-Id: Ie3becd36721f541d0fab11b2fb57aacd66d48220 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
This commit is contained in:
parent
fbebafa518
commit
2fb25509b8
1 changed files with 34 additions and 8 deletions
|
@ -33,6 +33,14 @@ struct s32cc_clk_drv {
|
||||||
uintptr_t rdc;
|
uintptr_t rdc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int set_module_rate(const struct s32cc_clk_obj *module,
|
||||||
|
unsigned long rate, unsigned long *orate,
|
||||||
|
unsigned int *depth);
|
||||||
|
static int get_module_rate(const struct s32cc_clk_obj *module,
|
||||||
|
const struct s32cc_clk_drv *drv,
|
||||||
|
unsigned long *rate,
|
||||||
|
unsigned int depth);
|
||||||
|
|
||||||
static int update_stack_depth(unsigned int *depth)
|
static int update_stack_depth(unsigned int *depth)
|
||||||
{
|
{
|
||||||
if (*depth == 0U) {
|
if (*depth == 0U) {
|
||||||
|
@ -651,6 +659,29 @@ static int enable_dfs(struct s32cc_clk_obj *module,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_dfs_freq(const struct s32cc_clk_obj *module,
|
||||||
|
const struct s32cc_clk_drv *drv,
|
||||||
|
unsigned long *rate, unsigned int depth)
|
||||||
|
{
|
||||||
|
const struct s32cc_dfs *dfs = s32cc_obj2dfs(module);
|
||||||
|
unsigned int ldepth = depth;
|
||||||
|
uintptr_t dfs_addr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = update_stack_depth(&ldepth);
|
||||||
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = get_base_addr(dfs->instance, drv, &dfs_addr);
|
||||||
|
if (ret != 0) {
|
||||||
|
ERROR("Failed to detect the DFS instance\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return get_module_rate(dfs->parent, drv, rate, ldepth);
|
||||||
|
}
|
||||||
|
|
||||||
static struct s32cc_dfs *get_div_dfs(const struct s32cc_dfs_div *dfs_div)
|
static struct s32cc_dfs *get_div_dfs(const struct s32cc_dfs_div *dfs_div)
|
||||||
{
|
{
|
||||||
const struct s32cc_clk_obj *parent = dfs_div->parent;
|
const struct s32cc_clk_obj *parent = dfs_div->parent;
|
||||||
|
@ -1059,14 +1090,6 @@ static bool s32cc_clk_is_enabled(unsigned long id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_module_rate(const struct s32cc_clk_obj *module,
|
|
||||||
unsigned long rate, unsigned long *orate,
|
|
||||||
unsigned int *depth);
|
|
||||||
static int get_module_rate(const struct s32cc_clk_obj *module,
|
|
||||||
const struct s32cc_clk_drv *drv,
|
|
||||||
unsigned long *rate,
|
|
||||||
unsigned int depth);
|
|
||||||
|
|
||||||
static int set_osc_freq(const struct s32cc_clk_obj *module, unsigned long rate,
|
static int set_osc_freq(const struct s32cc_clk_obj *module, unsigned long rate,
|
||||||
unsigned long *orate, unsigned int *depth)
|
unsigned long *orate, unsigned int *depth)
|
||||||
{
|
{
|
||||||
|
@ -1470,6 +1493,9 @@ static int get_module_rate(const struct s32cc_clk_obj *module,
|
||||||
case s32cc_pll_t:
|
case s32cc_pll_t:
|
||||||
ret = get_pll_freq(module, drv, rate, ldepth);
|
ret = get_pll_freq(module, drv, rate, ldepth);
|
||||||
break;
|
break;
|
||||||
|
case s32cc_dfs_t:
|
||||||
|
ret = get_dfs_freq(module, drv, rate, ldepth);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue