clk-cpumux.c (1ed7d32763857fbdc8e406352404538e41050d22) | clk-cpumux.c (1667393126d7c51fad8b3cb9d3798e8e0367e2ec) |
---|---|
1/* 2 * Copyright (c) 2015 Linaro Ltd. 3 * Author: Pi-Cheng Chen <pi-cheng.chen@linaro.org> 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 version 2 as 7 * published by the Free Software Foundation. 8 * --- 13 unchanged lines hidden (view full) --- 22static inline struct mtk_clk_cpumux *to_mtk_clk_cpumux(struct clk_hw *_hw) 23{ 24 return container_of(_hw, struct mtk_clk_cpumux, hw); 25} 26 27static u8 clk_cpumux_get_parent(struct clk_hw *hw) 28{ 29 struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw); | 1/* 2 * Copyright (c) 2015 Linaro Ltd. 3 * Author: Pi-Cheng Chen <pi-cheng.chen@linaro.org> 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 version 2 as 7 * published by the Free Software Foundation. 8 * --- 13 unchanged lines hidden (view full) --- 22static inline struct mtk_clk_cpumux *to_mtk_clk_cpumux(struct clk_hw *_hw) 23{ 24 return container_of(_hw, struct mtk_clk_cpumux, hw); 25} 26 27static u8 clk_cpumux_get_parent(struct clk_hw *hw) 28{ 29 struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw); |
30 int num_parents = clk_hw_get_num_parents(hw); | |
31 unsigned int val; 32 33 regmap_read(mux->regmap, mux->reg, &val); 34 35 val >>= mux->shift; 36 val &= mux->mask; 37 | 30 unsigned int val; 31 32 regmap_read(mux->regmap, mux->reg, &val); 33 34 val >>= mux->shift; 35 val &= mux->mask; 36 |
38 if (val >= num_parents) 39 return -EINVAL; 40 | |
41 return val; 42} 43 44static int clk_cpumux_set_parent(struct clk_hw *hw, u8 index) 45{ 46 struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw); 47 u32 mask, val; 48 --- 44 unchanged lines hidden (view full) --- 93 struct clk_onecell_data *clk_data) 94{ 95 int i; 96 struct clk *clk; 97 struct regmap *regmap; 98 99 regmap = syscon_node_to_regmap(node); 100 if (IS_ERR(regmap)) { | 37 return val; 38} 39 40static int clk_cpumux_set_parent(struct clk_hw *hw, u8 index) 41{ 42 struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw); 43 u32 mask, val; 44 --- 44 unchanged lines hidden (view full) --- 89 struct clk_onecell_data *clk_data) 90{ 91 int i; 92 struct clk *clk; 93 struct regmap *regmap; 94 95 regmap = syscon_node_to_regmap(node); 96 if (IS_ERR(regmap)) { |
101 pr_err("Cannot find regmap for %s: %ld\n", node->full_name, | 97 pr_err("Cannot find regmap for %pOF: %ld\n", node, |
102 PTR_ERR(regmap)); 103 return PTR_ERR(regmap); 104 } 105 106 for (i = 0; i < num; i++) { 107 const struct mtk_composite *mux = &clks[i]; 108 109 clk = mtk_clk_register_cpumux(mux, regmap); 110 if (IS_ERR(clk)) { 111 pr_err("Failed to register clk %s: %ld\n", 112 mux->name, PTR_ERR(clk)); 113 continue; 114 } 115 116 clk_data->clks[mux->id] = clk; 117 } 118 119 return 0; 120} | 98 PTR_ERR(regmap)); 99 return PTR_ERR(regmap); 100 } 101 102 for (i = 0; i < num; i++) { 103 const struct mtk_composite *mux = &clks[i]; 104 105 clk = mtk_clk_register_cpumux(mux, regmap); 106 if (IS_ERR(clk)) { 107 pr_err("Failed to register clk %s: %ld\n", 108 mux->name, PTR_ERR(clk)); 109 continue; 110 } 111 112 clk_data->clks[mux->id] = clk; 113 } 114 115 return 0; 116} |