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