Magnus Damm | e47bb51 | 2010-05-12 14:21:24 +0000 | [diff] [blame] | 1 | /* |
Magnus Damm | 3572b33 | 2010-08-16 10:40:49 +0000 | [diff] [blame] | 2 | * SH-Mobile Clock Framework |
Magnus Damm | e47bb51 | 2010-05-12 14:21:24 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2010 Magnus Damm |
| 5 | * |
Magnus Damm | 3572b33 | 2010-08-16 10:40:49 +0000 | [diff] [blame] | 6 | * Used together with arch/arm/common/clkdev.c and drivers/sh/clk.c. |
| 7 | * |
Magnus Damm | e47bb51 | 2010-05-12 14:21:24 +0000 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | * |
| 21 | */ |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/init.h> |
Magnus Damm | 25f5550 | 2014-03-13 08:36:17 +0900 | [diff] [blame] | 24 | |
| 25 | #ifdef CONFIG_COMMON_CLK |
| 26 | #include <linux/clk.h> |
| 27 | #include <linux/clkdev.h> |
Magnus Damm | ad6ffa0 | 2014-06-17 16:47:21 +0900 | [diff] [blame] | 28 | #include "clock.h" |
Magnus Damm | 25f5550 | 2014-03-13 08:36:17 +0900 | [diff] [blame] | 29 | |
| 30 | void __init shmobile_clk_workaround(const struct clk_name *clks, |
| 31 | int nr_clks, bool enable) |
| 32 | { |
| 33 | const struct clk_name *clkn; |
| 34 | struct clk *clk; |
| 35 | unsigned int i; |
| 36 | |
| 37 | for (i = 0; i < nr_clks; ++i) { |
| 38 | clkn = clks + i; |
| 39 | clk = clk_get(NULL, clkn->clk); |
| 40 | if (!IS_ERR(clk)) { |
| 41 | clk_register_clkdev(clk, clkn->con_id, clkn->dev_id); |
| 42 | if (enable) |
| 43 | clk_prepare_enable(clk); |
| 44 | clk_put(clk); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | #else /* CONFIG_COMMON_CLK */ |
Magnus Damm | e47bb51 | 2010-05-12 14:21:24 +0000 | [diff] [blame] | 50 | #include <linux/sh_clk.h> |
Paul Gortmaker | dc28094 | 2011-07-31 16:17:29 -0400 | [diff] [blame] | 51 | #include <linux/export.h> |
Magnus Damm | ad6ffa0 | 2014-06-17 16:47:21 +0900 | [diff] [blame] | 52 | #include "clock.h" |
Magnus Damm | fd44aa5 | 2014-06-17 16:47:37 +0900 | [diff] [blame] | 53 | #include "common.h" |
Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 54 | |
| 55 | unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk) |
| 56 | { |
| 57 | struct clk_ratio *p = clk->priv; |
| 58 | |
| 59 | return clk->parent->rate / p->div * p->mul; |
| 60 | }; |
| 61 | |
| 62 | struct sh_clk_ops shmobile_fixed_ratio_clk_ops = { |
| 63 | .recalc = shmobile_fixed_ratio_clk_recalc, |
| 64 | }; |
Magnus Damm | e47bb51 | 2010-05-12 14:21:24 +0000 | [diff] [blame] | 65 | |
Magnus Damm | 6b6a4c0 | 2012-02-29 21:41:30 +0900 | [diff] [blame] | 66 | int __init shmobile_clk_init(void) |
Magnus Damm | e47bb51 | 2010-05-12 14:21:24 +0000 | [diff] [blame] | 67 | { |
| 68 | /* Kick the child clocks.. */ |
| 69 | recalculate_root_clocks(); |
| 70 | |
| 71 | /* Enable the necessary init clocks */ |
| 72 | clk_enable_init_clocks(); |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | int __clk_get(struct clk *clk) |
| 78 | { |
| 79 | return 1; |
| 80 | } |
| 81 | EXPORT_SYMBOL(__clk_get); |
| 82 | |
| 83 | void __clk_put(struct clk *clk) |
| 84 | { |
| 85 | } |
| 86 | EXPORT_SYMBOL(__clk_put); |
Magnus Damm | 25f5550 | 2014-03-13 08:36:17 +0900 | [diff] [blame] | 87 | |
| 88 | #endif /* CONFIG_COMMON_CLK */ |