Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Copyright (C) 2016 Socionext Inc.
0004  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
0005  */
0006 
0007 #include <linux/clk-provider.h>
0008 #include <linux/device.h>
0009 
0010 #include "clk-uniphier.h"
0011 
0012 struct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
0013                         const char *name,
0014                 const struct uniphier_clk_fixed_rate_data *data)
0015 {
0016     struct clk_fixed_rate *fixed;
0017     struct clk_init_data init;
0018     int ret;
0019 
0020     /* allocate fixed-rate clock */
0021     fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
0022     if (!fixed)
0023         return ERR_PTR(-ENOMEM);
0024 
0025     init.name = name;
0026     init.ops = &clk_fixed_rate_ops;
0027     init.flags = 0;
0028     init.parent_names = NULL;
0029     init.num_parents = 0;
0030 
0031     fixed->fixed_rate = data->fixed_rate;
0032     fixed->hw.init = &init;
0033 
0034     ret = devm_clk_hw_register(dev, &fixed->hw);
0035     if (ret)
0036         return ERR_PTR(ret);
0037 
0038     return &fixed->hw;
0039 }