1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2016 Socionext Inc.
4  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5  */
6 
7 #include <linux/clk-provider.h>
8 #include <linux/device.h>
9 
10 #include "clk-uniphier.h"
11 
12 struct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
13 						const char *name,
14 				const struct uniphier_clk_fixed_rate_data *data)
15 {
16 	struct clk_fixed_rate *fixed;
17 	struct clk_init_data init;
18 	int ret;
19 
20 	/* allocate fixed-rate clock */
21 	fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
22 	if (!fixed)
23 		return ERR_PTR(-ENOMEM);
24 
25 	init.name = name;
26 	init.ops = &clk_fixed_rate_ops;
27 	init.parent_names = NULL;
28 	init.num_parents = 0;
29 
30 	fixed->fixed_rate = data->fixed_rate;
31 	fixed->hw.init = &init;
32 
33 	ret = devm_clk_hw_register(dev, &fixed->hw);
34 	if (ret)
35 		return ERR_PTR(ret);
36 
37 	return &fixed->hw;
38 }
39