blob: 52c6efc53731881b8ddbc3686e2227594697d841 [file] [log] [blame]
Tony Lindgren9cf705d2015-07-16 01:55:57 -07001/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation version 2.
5 */
6
7#include <linux/kernel.h>
Tony Lindgren21330492016-02-26 09:35:05 -08008#include <linux/clk.h>
Tony Lindgren9cf705d2015-07-16 01:55:57 -07009#include <linux/clk-provider.h>
10#include <linux/clk/ti.h>
Tony Lindgren21330492016-02-26 09:35:05 -080011#include <linux/of_platform.h>
Tony Lindgren9cf705d2015-07-16 01:55:57 -070012
Stephen Rothwellf9511a42015-07-27 14:11:17 +100013#include "clock.h"
14
Tony Lindgren9cf705d2015-07-16 01:55:57 -070015static struct ti_dt_clk dm814_clks[] = {
16 DT_CLK(NULL, "devosc_ck", "devosc_ck"),
17 DT_CLK(NULL, "mpu_ck", "mpu_ck"),
18 DT_CLK(NULL, "sysclk4_ck", "sysclk4_ck"),
Tony Lindgren5fbeef52015-12-03 12:02:31 -080019 DT_CLK(NULL, "sysclk5_ck", "sysclk5_ck"),
Tony Lindgren9cf705d2015-07-16 01:55:57 -070020 DT_CLK(NULL, "sysclk6_ck", "sysclk6_ck"),
Tony Lindgren5fbeef52015-12-03 12:02:31 -080021 DT_CLK(NULL, "sysclk8_ck", "sysclk8_ck"),
Tony Lindgren9cf705d2015-07-16 01:55:57 -070022 DT_CLK(NULL, "sysclk10_ck", "sysclk10_ck"),
23 DT_CLK(NULL, "sysclk18_ck", "sysclk18_ck"),
24 DT_CLK(NULL, "timer_sys_ck", "devosc_ck"),
Tony Lindgren5fbeef52015-12-03 12:02:31 -080025 DT_CLK(NULL, "timer1_fck", "timer1_fck"),
26 DT_CLK(NULL, "timer2_fck", "timer2_fck"),
Tony Lindgren9cf705d2015-07-16 01:55:57 -070027 DT_CLK(NULL, "cpsw_125mhz_gclk", "cpsw_125mhz_gclk"),
28 DT_CLK(NULL, "cpsw_cpts_rft_clk", "cpsw_cpts_rft_clk"),
29 { .node_name = NULL },
30};
31
Tony Lindgren21330492016-02-26 09:35:05 -080032static bool timer_clocks_initialized;
33
Stephen Boyd8a8b6eb2016-03-01 10:51:42 -080034static int __init dm814x_adpll_early_init(void)
Tony Lindgren21330492016-02-26 09:35:05 -080035{
36 struct device_node *np;
37
38 if (!timer_clocks_initialized)
39 return -ENODEV;
40
41 np = of_find_node_by_name(NULL, "pllss");
42 if (!np) {
43 pr_err("Could not find node for plls\n");
44 return -ENODEV;
45 }
46
47 of_platform_populate(np, NULL, NULL, NULL);
48
49 return 0;
50}
51core_initcall(dm814x_adpll_early_init);
52
53static const char * const init_clocks[] = {
54 "pll040clkout", /* MPU 481c5040.adpll.clkout */
55 "pll290clkout", /* DDR 481c5290.adpll.clkout */
56};
57
Stephen Boyd8a8b6eb2016-03-01 10:51:42 -080058static int __init dm814x_adpll_enable_init_clocks(void)
Tony Lindgren21330492016-02-26 09:35:05 -080059{
60 int i, err;
61
62 if (!timer_clocks_initialized)
63 return -ENODEV;
64
65 for (i = 0; i < ARRAY_SIZE(init_clocks); i++) {
66 struct clk *clock;
67
68 clock = clk_get(NULL, init_clocks[i]);
69 if (WARN(IS_ERR(clock), "could not find init clock %s\n",
70 init_clocks[i]))
71 continue;
72 err = clk_prepare_enable(clock);
73 if (WARN(err, "could not enable init clock %s\n",
74 init_clocks[i]))
75 continue;
76 }
77
78 return 0;
79}
80postcore_initcall(dm814x_adpll_enable_init_clocks);
81
Tony Lindgren9cf705d2015-07-16 01:55:57 -070082int __init dm814x_dt_clk_init(void)
83{
84 ti_dt_clocks_register(dm814_clks);
85 omap2_clk_disable_autoidle_all();
86 omap2_clk_enable_init_clocks(NULL, 0);
Tony Lindgren21330492016-02-26 09:35:05 -080087 timer_clocks_initialized = true;
Tony Lindgren9cf705d2015-07-16 01:55:57 -070088
89 return 0;
90}