blob: 983ce9f6edbb7ce037d17f83d84c4eedbefa3fd7 [file] [log] [blame]
Kelvin Cheunga8e3ced2016-09-19 12:38:54 +08001/*
2 * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/clk-provider.h>
11#include <linux/slab.h>
12
Stephen Boyd0f516592018-11-30 12:59:38 -080013#include "clk.h"
14
Kelvin Cheunga8e3ced2016-09-19 12:38:54 +080015struct clk_hw *__init clk_hw_register_pll(struct device *dev,
16 const char *name,
17 const char *parent_name,
18 const struct clk_ops *ops,
19 unsigned long flags)
20{
21 int ret;
22 struct clk_hw *hw;
23 struct clk_init_data init;
24
25 /* allocate the divider */
26 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
27 if (!hw)
28 return ERR_PTR(-ENOMEM);
29
30 init.name = name;
31 init.ops = ops;
Stephen Boyd0f516592018-11-30 12:59:38 -080032 init.flags = flags;
33 init.parent_names = parent_name ? &parent_name : NULL;
34 init.num_parents = parent_name ? 1 : 0;
Kelvin Cheunga8e3ced2016-09-19 12:38:54 +080035 hw->init = &init;
36
37 /* register the clock */
38 ret = clk_hw_register(dev, hw);
39 if (ret) {
40 kfree(hw);
41 hw = ERR_PTR(ret);
42 }
43
44 return hw;
45}