blob: 0ad0d46173c0e50357f4ea73077a0a20991860d1 [file] [log] [blame]
Masahiro Yamada734d82f2016-09-16 16:40:03 +09001/*
2 * Copyright (C) 2016 Socionext Inc.
3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/clk-provider.h>
17#include <linux/device.h>
18
19#include "clk-uniphier.h"
20
21struct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
22 const char *name,
23 const struct uniphier_clk_fixed_rate_data *data)
24{
25 struct clk_fixed_rate *fixed;
26 struct clk_init_data init;
27 int ret;
28
29 /* allocate fixed-rate clock */
30 fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL);
31 if (!fixed)
32 return ERR_PTR(-ENOMEM);
33
34 init.name = name;
35 init.ops = &clk_fixed_rate_ops;
36 init.parent_names = NULL;
37 init.num_parents = 0;
38
39 fixed->fixed_rate = data->fixed_rate;
40 fixed->hw.init = &init;
41
42 ret = devm_clk_hw_register(dev, &fixed->hw);
43 if (ret)
44 return ERR_PTR(ret);
45
46 return &fixed->hw;
47}