Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Kelvin Cheung | a8e3ced | 2016-09-19 12:38:54 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> |
Kelvin Cheung | a8e3ced | 2016-09-19 12:38:54 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <linux/clk-provider.h> |
| 7 | #include <linux/slab.h> |
| 8 | |
Stephen Boyd | 0f51659 | 2018-11-30 12:59:38 -0800 | [diff] [blame] | 9 | #include "clk.h" |
| 10 | |
Kelvin Cheung | a8e3ced | 2016-09-19 12:38:54 +0800 | [diff] [blame] | 11 | struct clk_hw *__init clk_hw_register_pll(struct device *dev, |
| 12 | const char *name, |
| 13 | const char *parent_name, |
| 14 | const struct clk_ops *ops, |
| 15 | unsigned long flags) |
| 16 | { |
| 17 | int ret; |
| 18 | struct clk_hw *hw; |
| 19 | struct clk_init_data init; |
| 20 | |
| 21 | /* allocate the divider */ |
| 22 | hw = kzalloc(sizeof(*hw), GFP_KERNEL); |
| 23 | if (!hw) |
| 24 | return ERR_PTR(-ENOMEM); |
| 25 | |
| 26 | init.name = name; |
| 27 | init.ops = ops; |
Stephen Boyd | 0f51659 | 2018-11-30 12:59:38 -0800 | [diff] [blame] | 28 | init.flags = flags; |
| 29 | init.parent_names = parent_name ? &parent_name : NULL; |
| 30 | init.num_parents = parent_name ? 1 : 0; |
Kelvin Cheung | a8e3ced | 2016-09-19 12:38:54 +0800 | [diff] [blame] | 31 | hw->init = &init; |
| 32 | |
| 33 | /* register the clock */ |
| 34 | ret = clk_hw_register(dev, hw); |
| 35 | if (ret) { |
| 36 | kfree(hw); |
| 37 | hw = ERR_PTR(ret); |
| 38 | } |
| 39 | |
| 40 | return hw; |
| 41 | } |