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.flags = 0; 28 init.parent_names = NULL; 29 init.num_parents = 0; 30 31 fixed->fixed_rate = data->fixed_rate; 32 fixed->hw.init = &init; 33 34 ret = devm_clk_hw_register(dev, &fixed->hw); 35 if (ret) 36 return ERR_PTR(ret); 37 38 return &fixed->hw; 39 } 40