Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Hisilicon clock driver |
| 3 | * |
| 4 | * Copyright (c) 2012-2013 Hisilicon Limited. |
| 5 | * Copyright (c) 2012-2013 Linaro Limited. |
| 6 | * |
| 7 | * Author: Haojian Zhuang <haojian.zhuang@linaro.org> |
| 8 | * Xin Li <li.xin@linaro.org> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License along |
| 21 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include <linux/kernel.h> |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 27 | #include <linux/clkdev.h> |
Stephen Boyd | 593438e | 2015-06-19 15:00:46 -0700 | [diff] [blame] | 28 | #include <linux/clk-provider.h> |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 29 | #include <linux/delay.h> |
| 30 | #include <linux/io.h> |
| 31 | #include <linux/of.h> |
| 32 | #include <linux/of_address.h> |
| 33 | #include <linux/of_device.h> |
| 34 | #include <linux/slab.h> |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 35 | |
| 36 | #include "clk.h" |
| 37 | |
| 38 | static DEFINE_SPINLOCK(hisi_clk_lock); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 39 | |
Jiancheng Xue | 32226916 | 2016-06-15 14:26:35 +0800 | [diff] [blame] | 40 | struct hisi_clock_data *hisi_clk_alloc(struct platform_device *pdev, |
| 41 | int nr_clks) |
| 42 | { |
| 43 | struct hisi_clock_data *clk_data; |
| 44 | struct resource *res; |
| 45 | struct clk **clk_table; |
| 46 | |
| 47 | clk_data = devm_kmalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL); |
| 48 | if (!clk_data) |
| 49 | return NULL; |
| 50 | |
| 51 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Wei Yongjun | c744b63 | 2018-03-20 14:19:34 +0000 | [diff] [blame] | 52 | if (!res) |
| 53 | return NULL; |
Jiancheng Xue | 32226916 | 2016-06-15 14:26:35 +0800 | [diff] [blame] | 54 | clk_data->base = devm_ioremap(&pdev->dev, |
| 55 | res->start, resource_size(res)); |
| 56 | if (!clk_data->base) |
| 57 | return NULL; |
| 58 | |
Markus Elfring | 8d9bdc4 | 2017-04-18 10:15:19 +0200 | [diff] [blame] | 59 | clk_table = devm_kmalloc_array(&pdev->dev, nr_clks, |
| 60 | sizeof(*clk_table), |
| 61 | GFP_KERNEL); |
Jiancheng Xue | 32226916 | 2016-06-15 14:26:35 +0800 | [diff] [blame] | 62 | if (!clk_table) |
| 63 | return NULL; |
| 64 | |
| 65 | clk_data->clk_data.clks = clk_table; |
| 66 | clk_data->clk_data.clk_num = nr_clks; |
| 67 | |
| 68 | return clk_data; |
| 69 | } |
| 70 | EXPORT_SYMBOL_GPL(hisi_clk_alloc); |
| 71 | |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 72 | struct hisi_clock_data *hisi_clk_init(struct device_node *np, |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 73 | int nr_clks) |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 74 | { |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 75 | struct hisi_clock_data *clk_data; |
| 76 | struct clk **clk_table; |
| 77 | void __iomem *base; |
| 78 | |
Leo Yan | 1fb6dd9 | 2015-08-03 09:13:34 +0800 | [diff] [blame] | 79 | base = of_iomap(np, 0); |
| 80 | if (!base) { |
| 81 | pr_err("%s: failed to map clock registers\n", __func__); |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 82 | goto err; |
| 83 | } |
| 84 | |
| 85 | clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); |
Markus Elfring | 840e563 | 2017-04-18 10:12:32 +0200 | [diff] [blame] | 86 | if (!clk_data) |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 87 | goto err; |
Markus Elfring | 840e563 | 2017-04-18 10:12:32 +0200 | [diff] [blame] | 88 | |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 89 | clk_data->base = base; |
Markus Elfring | 7b9bae1 | 2017-04-18 09:25:47 +0200 | [diff] [blame] | 90 | clk_table = kcalloc(nr_clks, sizeof(*clk_table), GFP_KERNEL); |
Markus Elfring | 840e563 | 2017-04-18 10:12:32 +0200 | [diff] [blame] | 91 | if (!clk_table) |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 92 | goto err_data; |
Markus Elfring | 840e563 | 2017-04-18 10:12:32 +0200 | [diff] [blame] | 93 | |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 94 | clk_data->clk_data.clks = clk_table; |
| 95 | clk_data->clk_data.clk_num = nr_clks; |
| 96 | of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data->clk_data); |
| 97 | return clk_data; |
| 98 | err_data: |
| 99 | kfree(clk_data); |
| 100 | err: |
| 101 | return NULL; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 102 | } |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 103 | EXPORT_SYMBOL_GPL(hisi_clk_init); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 104 | |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 105 | int hisi_clk_register_fixed_rate(const struct hisi_fixed_rate_clock *clks, |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 106 | int nums, struct hisi_clock_data *data) |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 107 | { |
| 108 | struct clk *clk; |
| 109 | int i; |
| 110 | |
| 111 | for (i = 0; i < nums; i++) { |
| 112 | clk = clk_register_fixed_rate(NULL, clks[i].name, |
| 113 | clks[i].parent_name, |
| 114 | clks[i].flags, |
| 115 | clks[i].fixed_rate); |
| 116 | if (IS_ERR(clk)) { |
| 117 | pr_err("%s: failed to register clock %s\n", |
| 118 | __func__, clks[i].name); |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 119 | goto err; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 120 | } |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 121 | data->clk_data.clks[clks[i].id] = clk; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 122 | } |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 123 | |
| 124 | return 0; |
| 125 | |
| 126 | err: |
| 127 | while (i--) |
| 128 | clk_unregister_fixed_rate(data->clk_data.clks[clks[i].id]); |
| 129 | |
| 130 | return PTR_ERR(clk); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 131 | } |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 132 | EXPORT_SYMBOL_GPL(hisi_clk_register_fixed_rate); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 133 | |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 134 | int hisi_clk_register_fixed_factor(const struct hisi_fixed_factor_clock *clks, |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 135 | int nums, |
| 136 | struct hisi_clock_data *data) |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 137 | { |
| 138 | struct clk *clk; |
| 139 | int i; |
| 140 | |
| 141 | for (i = 0; i < nums; i++) { |
| 142 | clk = clk_register_fixed_factor(NULL, clks[i].name, |
| 143 | clks[i].parent_name, |
| 144 | clks[i].flags, clks[i].mult, |
| 145 | clks[i].div); |
| 146 | if (IS_ERR(clk)) { |
| 147 | pr_err("%s: failed to register clock %s\n", |
| 148 | __func__, clks[i].name); |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 149 | goto err; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 150 | } |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 151 | data->clk_data.clks[clks[i].id] = clk; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 152 | } |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 153 | |
| 154 | return 0; |
| 155 | |
| 156 | err: |
| 157 | while (i--) |
| 158 | clk_unregister_fixed_factor(data->clk_data.clks[clks[i].id]); |
| 159 | |
| 160 | return PTR_ERR(clk); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 161 | } |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 162 | EXPORT_SYMBOL_GPL(hisi_clk_register_fixed_factor); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 163 | |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 164 | int hisi_clk_register_mux(const struct hisi_mux_clock *clks, |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 165 | int nums, struct hisi_clock_data *data) |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 166 | { |
| 167 | struct clk *clk; |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 168 | void __iomem *base = data->base; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 169 | int i; |
| 170 | |
| 171 | for (i = 0; i < nums; i++) { |
Zhangfei Gao | 156342a | 2014-04-21 11:35:21 +0800 | [diff] [blame] | 172 | u32 mask = BIT(clks[i].width) - 1; |
| 173 | |
| 174 | clk = clk_register_mux_table(NULL, clks[i].name, |
| 175 | clks[i].parent_names, |
| 176 | clks[i].num_parents, clks[i].flags, |
| 177 | base + clks[i].offset, clks[i].shift, |
| 178 | mask, clks[i].mux_flags, |
| 179 | clks[i].table, &hisi_clk_lock); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 180 | if (IS_ERR(clk)) { |
| 181 | pr_err("%s: failed to register clock %s\n", |
| 182 | __func__, clks[i].name); |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 183 | goto err; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | if (clks[i].alias) |
| 187 | clk_register_clkdev(clk, clks[i].alias, NULL); |
| 188 | |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 189 | data->clk_data.clks[clks[i].id] = clk; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 190 | } |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 191 | |
| 192 | return 0; |
| 193 | |
| 194 | err: |
| 195 | while (i--) |
| 196 | clk_unregister_mux(data->clk_data.clks[clks[i].id]); |
| 197 | |
| 198 | return PTR_ERR(clk); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 199 | } |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 200 | EXPORT_SYMBOL_GPL(hisi_clk_register_mux); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 201 | |
tianshuliang | 811f67c | 2018-03-05 15:01:31 +0800 | [diff] [blame] | 202 | int hisi_clk_register_phase(struct device *dev, |
| 203 | const struct hisi_phase_clock *clks, |
| 204 | int nums, struct hisi_clock_data *data) |
| 205 | { |
| 206 | void __iomem *base = data->base; |
| 207 | struct clk *clk; |
| 208 | int i; |
| 209 | |
| 210 | for (i = 0; i < nums; i++) { |
| 211 | clk = clk_register_hisi_phase(dev, &clks[i], base, |
| 212 | &hisi_clk_lock); |
| 213 | if (IS_ERR(clk)) { |
| 214 | pr_err("%s: failed to register clock %s\n", __func__, |
| 215 | clks[i].name); |
| 216 | return PTR_ERR(clk); |
| 217 | } |
| 218 | |
| 219 | data->clk_data.clks[clks[i].id] = clk; |
| 220 | } |
| 221 | |
| 222 | return 0; |
| 223 | } |
| 224 | EXPORT_SYMBOL_GPL(hisi_clk_register_phase); |
| 225 | |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 226 | int hisi_clk_register_divider(const struct hisi_divider_clock *clks, |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 227 | int nums, struct hisi_clock_data *data) |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 228 | { |
| 229 | struct clk *clk; |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 230 | void __iomem *base = data->base; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 231 | int i; |
| 232 | |
| 233 | for (i = 0; i < nums; i++) { |
| 234 | clk = clk_register_divider_table(NULL, clks[i].name, |
| 235 | clks[i].parent_name, |
| 236 | clks[i].flags, |
| 237 | base + clks[i].offset, |
| 238 | clks[i].shift, clks[i].width, |
| 239 | clks[i].div_flags, |
| 240 | clks[i].table, |
| 241 | &hisi_clk_lock); |
| 242 | if (IS_ERR(clk)) { |
| 243 | pr_err("%s: failed to register clock %s\n", |
| 244 | __func__, clks[i].name); |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 245 | goto err; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | if (clks[i].alias) |
| 249 | clk_register_clkdev(clk, clks[i].alias, NULL); |
| 250 | |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 251 | data->clk_data.clks[clks[i].id] = clk; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 252 | } |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 253 | |
| 254 | return 0; |
| 255 | |
| 256 | err: |
| 257 | while (i--) |
| 258 | clk_unregister_divider(data->clk_data.clks[clks[i].id]); |
| 259 | |
| 260 | return PTR_ERR(clk); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 261 | } |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 262 | EXPORT_SYMBOL_GPL(hisi_clk_register_divider); |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 263 | |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 264 | int hisi_clk_register_gate(const struct hisi_gate_clock *clks, |
Zhangfei Gao | 8b9dcb6c | 2014-04-22 15:42:47 +0800 | [diff] [blame] | 265 | int nums, struct hisi_clock_data *data) |
| 266 | { |
| 267 | struct clk *clk; |
| 268 | void __iomem *base = data->base; |
| 269 | int i; |
| 270 | |
| 271 | for (i = 0; i < nums; i++) { |
| 272 | clk = clk_register_gate(NULL, clks[i].name, |
| 273 | clks[i].parent_name, |
| 274 | clks[i].flags, |
| 275 | base + clks[i].offset, |
| 276 | clks[i].bit_idx, |
| 277 | clks[i].gate_flags, |
| 278 | &hisi_clk_lock); |
| 279 | if (IS_ERR(clk)) { |
| 280 | pr_err("%s: failed to register clock %s\n", |
| 281 | __func__, clks[i].name); |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 282 | goto err; |
Zhangfei Gao | 8b9dcb6c | 2014-04-22 15:42:47 +0800 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | if (clks[i].alias) |
| 286 | clk_register_clkdev(clk, clks[i].alias, NULL); |
| 287 | |
| 288 | data->clk_data.clks[clks[i].id] = clk; |
| 289 | } |
Jiancheng Xue | 5497f66 | 2016-06-15 14:26:36 +0800 | [diff] [blame] | 290 | |
| 291 | return 0; |
| 292 | |
| 293 | err: |
| 294 | while (i--) |
| 295 | clk_unregister_gate(data->clk_data.clks[clks[i].id]); |
| 296 | |
| 297 | return PTR_ERR(clk); |
Zhangfei Gao | 8b9dcb6c | 2014-04-22 15:42:47 +0800 | [diff] [blame] | 298 | } |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 299 | EXPORT_SYMBOL_GPL(hisi_clk_register_gate); |
Zhangfei Gao | 8b9dcb6c | 2014-04-22 15:42:47 +0800 | [diff] [blame] | 300 | |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 301 | void hisi_clk_register_gate_sep(const struct hisi_gate_clock *clks, |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 302 | int nums, struct hisi_clock_data *data) |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 303 | { |
| 304 | struct clk *clk; |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 305 | void __iomem *base = data->base; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 306 | int i; |
| 307 | |
| 308 | for (i = 0; i < nums; i++) { |
| 309 | clk = hisi_register_clkgate_sep(NULL, clks[i].name, |
| 310 | clks[i].parent_name, |
| 311 | clks[i].flags, |
| 312 | base + clks[i].offset, |
| 313 | clks[i].bit_idx, |
| 314 | clks[i].gate_flags, |
| 315 | &hisi_clk_lock); |
| 316 | if (IS_ERR(clk)) { |
| 317 | pr_err("%s: failed to register clock %s\n", |
| 318 | __func__, clks[i].name); |
| 319 | continue; |
| 320 | } |
| 321 | |
| 322 | if (clks[i].alias) |
| 323 | clk_register_clkdev(clk, clks[i].alias, NULL); |
| 324 | |
Haojian Zhuang | 75af25f | 2013-12-24 21:38:26 +0800 | [diff] [blame] | 325 | data->clk_data.clks[clks[i].id] = clk; |
Haojian Zhuang | 0aa0c95 | 2013-11-13 08:51:23 +0800 | [diff] [blame] | 326 | } |
| 327 | } |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 328 | EXPORT_SYMBOL_GPL(hisi_clk_register_gate_sep); |
Bintian Wang | 72ea486 | 2015-05-29 10:08:38 +0800 | [diff] [blame] | 329 | |
Jiancheng Xue | f6ff57c | 2016-04-23 15:40:29 +0800 | [diff] [blame] | 330 | void __init hi6220_clk_register_divider(const struct hi6220_divider_clock *clks, |
Bintian Wang | 72ea486 | 2015-05-29 10:08:38 +0800 | [diff] [blame] | 331 | int nums, struct hisi_clock_data *data) |
| 332 | { |
| 333 | struct clk *clk; |
| 334 | void __iomem *base = data->base; |
| 335 | int i; |
| 336 | |
| 337 | for (i = 0; i < nums; i++) { |
| 338 | clk = hi6220_register_clkdiv(NULL, clks[i].name, |
| 339 | clks[i].parent_name, |
| 340 | clks[i].flags, |
| 341 | base + clks[i].offset, |
| 342 | clks[i].shift, |
| 343 | clks[i].width, |
| 344 | clks[i].mask_bit, |
| 345 | &hisi_clk_lock); |
| 346 | if (IS_ERR(clk)) { |
| 347 | pr_err("%s: failed to register clock %s\n", |
| 348 | __func__, clks[i].name); |
| 349 | continue; |
| 350 | } |
| 351 | |
| 352 | if (clks[i].alias) |
| 353 | clk_register_clkdev(clk, clks[i].alias, NULL); |
| 354 | |
| 355 | data->clk_data.clks[clks[i].id] = clk; |
| 356 | } |
| 357 | } |