clk.c (a245fecbb8064641d9cc317b347b5bdb2b7a4bb6) | clk.c (90c590254051f511299538c158e12fdad41ce163) |
---|---|
1/* 2 * Copyright (c) 2014 MundoReader S.L. 3 * Author: Heiko Stuebner <heiko@sntech.de> 4 * 5 * based on 6 * 7 * samsung/clk.c 8 * Copyright (c) 2013 Samsung Electronics Co., Ltd. --- 9 unchanged lines hidden (view full) --- 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 */ 22 23#include <linux/slab.h> 24#include <linux/clk.h> 25#include <linux/clk-provider.h> | 1/* 2 * Copyright (c) 2014 MundoReader S.L. 3 * Author: Heiko Stuebner <heiko@sntech.de> 4 * 5 * based on 6 * 7 * samsung/clk.c 8 * Copyright (c) 2013 Samsung Electronics Co., Ltd. --- 9 unchanged lines hidden (view full) --- 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 */ 22 23#include <linux/slab.h> 24#include <linux/clk.h> 25#include <linux/clk-provider.h> |
26#include <linux/mfd/syscon.h> 27#include <linux/regmap.h> |
|
26#include "clk.h" 27 28/** 29 * Register a clock branch. 30 * Most clock branches have a form like 31 * 32 * src1 --|--\ 33 * |M |--[GATE]-[DIV]- --- 66 unchanged lines hidden (view full) --- 100 101 return clk; 102} 103 104static DEFINE_SPINLOCK(clk_lock); 105static struct clk **clk_table; 106static void __iomem *reg_base; 107static struct clk_onecell_data clk_data; | 28#include "clk.h" 29 30/** 31 * Register a clock branch. 32 * Most clock branches have a form like 33 * 34 * src1 --|--\ 35 * |M |--[GATE]-[DIV]- --- 66 unchanged lines hidden (view full) --- 102 103 return clk; 104} 105 106static DEFINE_SPINLOCK(clk_lock); 107static struct clk **clk_table; 108static void __iomem *reg_base; 109static struct clk_onecell_data clk_data; |
110static struct device_node *cru_node; 111static struct regmap *grf; |
|
108 109void __init rockchip_clk_init(struct device_node *np, void __iomem *base, 110 unsigned long nr_clks) 111{ 112 reg_base = base; | 112 113void __init rockchip_clk_init(struct device_node *np, void __iomem *base, 114 unsigned long nr_clks) 115{ 116 reg_base = base; |
117 cru_node = np; 118 grf = ERR_PTR(-EPROBE_DEFER); |
|
113 114 clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL); 115 if (!clk_table) 116 pr_err("%s: could not allocate clock lookup table\n", __func__); 117 118 clk_data.clks = clk_table; 119 clk_data.clk_num = nr_clks; 120 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 121} 122 | 119 120 clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL); 121 if (!clk_table) 122 pr_err("%s: could not allocate clock lookup table\n", __func__); 123 124 clk_data.clks = clk_table; 125 clk_data.clk_num = nr_clks; 126 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 127} 128 |
129struct regmap *rockchip_clk_get_grf(void) 130{ 131 if (IS_ERR(grf)) 132 grf = syscon_regmap_lookup_by_phandle(cru_node, "rockchip,grf"); 133 return grf; 134} 135 |
|
123void rockchip_clk_add_lookup(struct clk *clk, unsigned int id) 124{ 125 if (clk_table && id) 126 clk_table[id] = clk; 127} 128 | 136void rockchip_clk_add_lookup(struct clk *clk, unsigned int id) 137{ 138 if (clk_table && id) 139 clk_table[id] = clk; 140} 141 |
142void __init rockchip_clk_register_plls(struct rockchip_pll_clock *list, 143 unsigned int nr_pll, int grf_lock_offset) 144{ 145 struct clk *clk; 146 int idx; 147 148 for (idx = 0; idx < nr_pll; idx++, list++) { 149 clk = rockchip_clk_register_pll(list->type, list->name, 150 list->parent_names, list->num_parents, 151 reg_base, list->con_offset, grf_lock_offset, 152 list->lock_shift, list->mode_offset, 153 list->mode_shift, list->rate_table, &clk_lock); 154 if (IS_ERR(clk)) { 155 pr_err("%s: failed to register clock %s\n", __func__, 156 list->name); 157 continue; 158 } 159 160 rockchip_clk_add_lookup(clk, list->id); 161 } 162} 163 |
|
129void __init rockchip_clk_register_branches( 130 struct rockchip_clk_branch *list, 131 unsigned int nr_clk) 132{ 133 struct clk *clk = NULL; 134 unsigned int idx; 135 unsigned long flags; 136 --- 73 unchanged lines hidden --- | 164void __init rockchip_clk_register_branches( 165 struct rockchip_clk_branch *list, 166 unsigned int nr_clk) 167{ 168 struct clk *clk = NULL; 169 unsigned int idx; 170 unsigned long flags; 171 --- 73 unchanged lines hidden --- |