2 * Copyright (c) 2012, 2013, NVIDIA CORPORATION. All rights reserved.
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.
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
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/>.
18 #include <linux/clk-provider.h>
20 #include <linux/of_address.h>
21 #include <linux/delay.h>
22 #include <linux/export.h>
23 #include <linux/clk/tegra.h>
29 #define OSC_CTRL_OSC_FREQ_SHIFT 28
30 #define OSC_CTRL_PLL_REF_DIV_SHIFT 26
32 int __init tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *clks,
33 unsigned long *input_freqs, unsigned int num,
34 unsigned int clk_m_div, unsigned long *osc_freq,
35 unsigned long *pll_ref_freq)
37 struct clk *clk, *osc;
42 val = readl_relaxed(clk_base + OSC_CTRL);
43 osc_idx = val >> OSC_CTRL_OSC_FREQ_SHIFT;
46 *osc_freq = input_freqs[osc_idx];
55 osc = clk_register_fixed_rate(NULL, "osc", NULL, 0, *osc_freq);
57 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_m, clks);
61 clk = clk_register_fixed_factor(NULL, "clk_m", "osc",
66 val = (val >> OSC_CTRL_PLL_REF_DIV_SHIFT) & 3;
67 pll_ref_div = 1 << val;
68 dt_clk = tegra_lookup_dt_id(tegra_clk_pll_ref, clks);
72 clk = clk_register_fixed_factor(NULL, "pll_ref", "osc",
77 *pll_ref_freq = *osc_freq / pll_ref_div;
82 void __init tegra_fixed_clk_init(struct tegra_clk *tegra_clks)
88 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_32k, tegra_clks);
90 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, 0, 32768);
95 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_m_div2, tegra_clks);
97 clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m",
98 CLK_SET_RATE_PARENT, 1, 2);
103 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_m_div4, tegra_clks);
105 clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m",
106 CLK_SET_RATE_PARENT, 1, 4);