Linux 4.18.10
[linux/fpc-iii.git] / drivers / clk / sprd / composite.c
blobebb644820b1eb776d0b487fadf0753a56cde5d05
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Spreadtrum composite clock driver
4 //
5 // Copyright (C) 2017 Spreadtrum, Inc.
6 // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
8 #include <linux/clk-provider.h>
10 #include "composite.h"
12 static long sprd_comp_round_rate(struct clk_hw *hw, unsigned long rate,
13 unsigned long *parent_rate)
15 struct sprd_comp *cc = hw_to_sprd_comp(hw);
17 return sprd_div_helper_round_rate(&cc->common, &cc->div,
18 rate, parent_rate);
21 static unsigned long sprd_comp_recalc_rate(struct clk_hw *hw,
22 unsigned long parent_rate)
24 struct sprd_comp *cc = hw_to_sprd_comp(hw);
26 return sprd_div_helper_recalc_rate(&cc->common, &cc->div, parent_rate);
29 static int sprd_comp_set_rate(struct clk_hw *hw, unsigned long rate,
30 unsigned long parent_rate)
32 struct sprd_comp *cc = hw_to_sprd_comp(hw);
34 return sprd_div_helper_set_rate(&cc->common, &cc->div,
35 rate, parent_rate);
38 static u8 sprd_comp_get_parent(struct clk_hw *hw)
40 struct sprd_comp *cc = hw_to_sprd_comp(hw);
42 return sprd_mux_helper_get_parent(&cc->common, &cc->mux);
45 static int sprd_comp_set_parent(struct clk_hw *hw, u8 index)
47 struct sprd_comp *cc = hw_to_sprd_comp(hw);
49 return sprd_mux_helper_set_parent(&cc->common, &cc->mux, index);
52 const struct clk_ops sprd_comp_ops = {
53 .get_parent = sprd_comp_get_parent,
54 .set_parent = sprd_comp_set_parent,
56 .round_rate = sprd_comp_round_rate,
57 .recalc_rate = sprd_comp_recalc_rate,
58 .set_rate = sprd_comp_set_rate,
60 EXPORT_SYMBOL_GPL(sprd_comp_ops);