Prashant Gaikwad | 8f8f484 | 2013-01-11 13:16:20 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/clk.h> |
| 18 | #include <linux/clk-provider.h> |
| 19 | |
| 20 | #include "clk.h" |
| 21 | |
| 22 | void __init tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list, |
| 23 | struct clk *clks[], int clk_max) |
| 24 | { |
| 25 | struct clk *clk; |
| 26 | |
| 27 | for (; dup_list->clk_id < clk_max; dup_list++) { |
| 28 | clk = clks[dup_list->clk_id]; |
| 29 | dup_list->lookup.clk = clk; |
| 30 | clkdev_add(&dup_list->lookup); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | void __init tegra_init_from_table(struct tegra_clk_init_table *tbl, |
| 35 | struct clk *clks[], int clk_max) |
| 36 | { |
| 37 | struct clk *clk; |
| 38 | |
| 39 | for (; tbl->clk_id < clk_max; tbl++) { |
| 40 | clk = clks[tbl->clk_id]; |
| 41 | if (IS_ERR_OR_NULL(clk)) |
| 42 | return; |
| 43 | |
| 44 | if (tbl->parent_id < clk_max) { |
| 45 | struct clk *parent = clks[tbl->parent_id]; |
| 46 | if (clk_set_parent(clk, parent)) { |
| 47 | pr_err("%s: Failed to set parent %s of %s\n", |
| 48 | __func__, __clk_get_name(parent), |
| 49 | __clk_get_name(clk)); |
| 50 | WARN_ON(1); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | if (tbl->rate) |
| 55 | if (clk_set_rate(clk, tbl->rate)) { |
| 56 | pr_err("%s: Failed to set rate %lu of %s\n", |
| 57 | __func__, tbl->rate, |
| 58 | __clk_get_name(clk)); |
| 59 | WARN_ON(1); |
| 60 | } |
| 61 | |
| 62 | if (tbl->state) |
| 63 | if (clk_prepare_enable(clk)) { |
| 64 | pr_err("%s: Failed to enable %s\n", __func__, |
| 65 | __clk_get_name(clk)); |
| 66 | WARN_ON(1); |
| 67 | } |
| 68 | } |
| 69 | } |