Skip to content

Commit 230b6f3

Browse files
superna9999jbrun3t
authored andcommitted
clk: meson: introduce meson-clkc-utils
Let's introduce a new module called meson-clkc-utils that will contain shared utility functions for all Amlogic clock controller drivers. The first utility function is a replacement of of_clk_hw_onecell_get in order to get rid of the NR_CLKS define in all Amlogic clock drivers. The goal is to move all duplicate probe and init code in this module. [jbrunet: Fixed MODULE_LICENCE checkpatch warning] Signed-off-by: Neil Armstrong <[email protected]> Link: https://lore.kernel.org/r/20230607-topic-amlogic-upstream-clkid-public-migration-v2-1-38172d17c27a@linaro.org Signed-off-by: Jerome Brunet <[email protected]>
1 parent 06c2afb commit 230b6f3

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

drivers/clk/meson/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ config COMMON_CLK_MESON_VID_PLL_DIV
3030
tristate
3131
select COMMON_CLK_MESON_REGMAP
3232

33+
config COMMON_CLK_MESON_CLKC_UTILS
34+
tristate
35+
3336
config COMMON_CLK_MESON_AO_CLKC
3437
tristate
3538
select COMMON_CLK_MESON_REGMAP

drivers/clk/meson/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
# Amlogic clock drivers
33

4+
obj-$(CONFIG_COMMON_CLK_MESON_CLKC_UTILS) += meson-clkc-utils.o
45
obj-$(CONFIG_COMMON_CLK_MESON_AO_CLKC) += meson-aoclk.o
56
obj-$(CONFIG_COMMON_CLK_MESON_CPU_DYNDIV) += clk-cpu-dyndiv.o
67
obj-$(CONFIG_COMMON_CLK_MESON_DUALDIV) += clk-dualdiv.o

drivers/clk/meson/meson-clkc-utils.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/*
3+
* Copyright (c) 2023 Neil Armstrong <[email protected]>
4+
*/
5+
6+
#include <linux/of_device.h>
7+
#include <linux/clk-provider.h>
8+
#include <linux/module.h>
9+
#include "meson-clkc-utils.h"
10+
11+
struct clk_hw *meson_clk_hw_get(struct of_phandle_args *clkspec, void *clk_hw_data)
12+
{
13+
const struct meson_clk_hw_data *data = clk_hw_data;
14+
unsigned int idx = clkspec->args[0];
15+
16+
if (idx >= data->num) {
17+
pr_err("%s: invalid index %u\n", __func__, idx);
18+
return ERR_PTR(-EINVAL);
19+
}
20+
21+
return data->hws[idx];
22+
}
23+
EXPORT_SYMBOL_GPL(meson_clk_hw_get);
24+
25+
MODULE_LICENSE("GPL");

drivers/clk/meson/meson-clkc-utils.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
2+
/*
3+
* Copyright (c) 2023 Neil Armstrong <[email protected]>
4+
*/
5+
6+
#ifndef __MESON_CLKC_UTILS_H__
7+
#define __MESON_CLKC_UTILS_H__
8+
9+
#include <linux/of_device.h>
10+
#include <linux/clk-provider.h>
11+
12+
struct meson_clk_hw_data {
13+
struct clk_hw **hws;
14+
unsigned int num;
15+
};
16+
17+
struct clk_hw *meson_clk_hw_get(struct of_phandle_args *clkspec, void *clk_hw_data);
18+
19+
#endif

0 commit comments

Comments
 (0)