From 8aa209c7cf29d256a18ed524bd2380ce7571a541 Mon Sep 17 00:00:00 2001 From: Shunzhou Jiang Date: Mon, 11 Jun 2018 12:08:22 +0800 Subject: [PATCH] clk: clock: compatible clk count for different platform [1/1] PD#165090: clock: fix clk count error Change-Id: I3b7c181e159b2a028ddc53e7c72066ec3633fd75 Signed-off-by: Shunzhou Jiang --- drivers/amlogic/clk/axg/axg.c | 1 + drivers/amlogic/clk/axg/axg_ao.c | 1 + drivers/amlogic/clk/clk_test.c | 5 +++-- drivers/amlogic/clk/clkc.h | 1 + drivers/amlogic/clk/g12a/g12a.c | 1 + drivers/amlogic/clk/g12a/g12a_ao.c | 1 + drivers/amlogic/clk/g12b/g12b.c | 1 + drivers/amlogic/clk/gxl/gxl.c | 2 ++ drivers/amlogic/clk/m8b/meson8b.c | 2 ++ drivers/amlogic/clk/txlx/txlx.c | 2 +- 10 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/amlogic/clk/axg/axg.c b/drivers/amlogic/clk/axg/axg.c index 25b1d94..d267eb6 100644 --- a/drivers/amlogic/clk/axg/axg.c +++ b/drivers/amlogic/clk/axg/axg.c @@ -871,6 +871,7 @@ static void __init axg_clkc_init(struct device_node *np) /* return -ENOMEM; */ return; } + clk_numbers = NR_CLKS; } if (NULL == clks) { diff --git a/drivers/amlogic/clk/axg/axg_ao.c b/drivers/amlogic/clk/axg/axg_ao.c index 8fa0c5e4..8ca22b8 100644 --- a/drivers/amlogic/clk/axg/axg_ao.c +++ b/drivers/amlogic/clk/axg/axg_ao.c @@ -125,6 +125,7 @@ static void __init axg_aoclkc_init(struct device_node *np) /* return -ENOMEM; */ return; } + clk_numbers = NR_CLKS; } for (clkid = CLKID_AO_BASE; clkid < NR_CLKS; clkid++) { diff --git a/drivers/amlogic/clk/clk_test.c b/drivers/amlogic/clk/clk_test.c index ae2df30..0bfab8b 100644 --- a/drivers/amlogic/clk/clk_test.c +++ b/drivers/amlogic/clk/clk_test.c @@ -29,7 +29,8 @@ #include "clkc.h" static struct dentry *debugfs_root; -#define NR_CLKS 221 +//#define NR_CLKS 221 + void usage(void) { pr_info("\nclk_test:\n"); @@ -44,7 +45,7 @@ struct clk *aml_get_clk_by_name(char *name) int idx; struct clk *cur_clk; - for (idx = 0; idx < NR_CLKS; idx++) { + for (idx = 0; idx < clk_numbers; idx++) { if (!clks[idx]) { pr_debug("no such clk clks[%d]\n", idx); continue; diff --git a/drivers/amlogic/clk/clkc.h b/drivers/amlogic/clk/clkc.h index f837065..5a90fdb 100644 --- a/drivers/amlogic/clk/clkc.h +++ b/drivers/amlogic/clk/clkc.h @@ -286,4 +286,5 @@ void meson_g12a_media_init(void); void meson_g12a_gpu_init(void); void meson_g12a_misc_init(void); +extern int clk_numbers; #endif /* __CLKC_H */ diff --git a/drivers/amlogic/clk/g12a/g12a.c b/drivers/amlogic/clk/g12a/g12a.c index dd13b0e..e2c7afd 100644 --- a/drivers/amlogic/clk/g12a/g12a.c +++ b/drivers/amlogic/clk/g12a/g12a.c @@ -871,6 +871,7 @@ static void __init g12a_clkc_init(struct device_node *np) /* return -ENOMEM; */ return; } + clk_numbers = NR_CLKS; } clk_data.clks = clks; diff --git a/drivers/amlogic/clk/g12a/g12a_ao.c b/drivers/amlogic/clk/g12a/g12a_ao.c index ccba986..92dc5f4 100644 --- a/drivers/amlogic/clk/g12a/g12a_ao.c +++ b/drivers/amlogic/clk/g12a/g12a_ao.c @@ -125,6 +125,7 @@ static void __init g12a_aoclkc_init(struct device_node *np) /* return -ENOMEM; */ return; } + clk_numbers = NR_CLKS; } for (clkid = CLKID_AO_BASE; clkid < NR_CLKS; clkid++) { diff --git a/drivers/amlogic/clk/g12b/g12b.c b/drivers/amlogic/clk/g12b/g12b.c index 9c7482c9..86e9c1f 100644 --- a/drivers/amlogic/clk/g12b/g12b.c +++ b/drivers/amlogic/clk/g12b/g12b.c @@ -552,6 +552,7 @@ static void __init g12b_clkc_init(struct device_node *np) pr_err("%s: alloc clks fail!", __func__); return; } + clk_numbers = NR_CLKS; } /* diff --git a/drivers/amlogic/clk/gxl/gxl.c b/drivers/amlogic/clk/gxl/gxl.c index 508e91d..8831de5 100644 --- a/drivers/amlogic/clk/gxl/gxl.c +++ b/drivers/amlogic/clk/gxl/gxl.c @@ -28,6 +28,7 @@ DEFINE_SPINLOCK(clk_lock); struct clk **clks; +int clk_numbers; static struct clk_onecell_data clk_data; void __iomem *clk_base; /* #undef pr_debug */ @@ -1071,6 +1072,7 @@ static void __init gxl_clkc_init(struct device_node *np) /* return -ENOMEM; */ return; } + clk_numbers = NR_CLKS; /* pr_debug("%s: kzalloc clks ok!", __func__); */ clk_data.clks = clks; clk_data.clk_num = NR_CLKS; diff --git a/drivers/amlogic/clk/m8b/meson8b.c b/drivers/amlogic/clk/m8b/meson8b.c index 45223cd..a930438 100644 --- a/drivers/amlogic/clk/m8b/meson8b.c +++ b/drivers/amlogic/clk/m8b/meson8b.c @@ -30,6 +30,7 @@ DEFINE_SPINLOCK(clk_lock); struct clk **clks; void __iomem *clk_base; static struct clk_onecell_data clk_data; +int clk_numbers; static const struct pll_rate_table sys_pll_rate_table[] = { PLL_RATE(312000000, 52, 1, 2), @@ -732,6 +733,7 @@ static void __init meson8b_clkc_init(struct device_node *np) /* return -ENOMEM; */ return; } + clk_numbers = NR_CLKS; clk_data.clks = clks; clk_data.clk_num = NR_CLKS; /* diff --git a/drivers/amlogic/clk/txlx/txlx.c b/drivers/amlogic/clk/txlx/txlx.c index 9ec1c6f..227ec77 100644 --- a/drivers/amlogic/clk/txlx/txlx.c +++ b/drivers/amlogic/clk/txlx/txlx.c @@ -975,7 +975,7 @@ static void __init txlx_clkc_init(struct device_node *np) pr_err("%s: error: not kzalloc clks in eeclk!", __func__); return; } - + clk_numbers = NR_CLKS; clk_data.clks = clks; clk_data.clk_num = NR_CLKS; -- 2.7.4