xref: /linux/drivers/clk/meson/meson-clkc-utils.c (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2023 Neil Armstrong <neil.armstrong@linaro.org>
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_NS_GPL(meson_clk_hw_get, CLK_MESON);
24 
25 MODULE_DESCRIPTION("Amlogic Clock Controller Utilities");
26 MODULE_LICENSE("GPL");
27 MODULE_IMPORT_NS(CLK_MESON);
28