Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 1 | /* |
| 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 Lindgren | 2133049 | 2016-02-26 09:35:05 -0800 | [diff] [blame] | 8 | #include <linux/clk.h> |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 9 | #include <linux/clk-provider.h> |
| 10 | #include <linux/clk/ti.h> |
Tony Lindgren | 2133049 | 2016-02-26 09:35:05 -0800 | [diff] [blame] | 11 | #include <linux/of_platform.h> |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 12 | |
Stephen Rothwell | f9511a4 | 2015-07-27 14:11:17 +1000 | [diff] [blame] | 13 | #include "clock.h" |
| 14 | |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 15 | static 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 Lindgren | 5fbeef5 | 2015-12-03 12:02:31 -0800 | [diff] [blame] | 19 | DT_CLK(NULL, "sysclk5_ck", "sysclk5_ck"), |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 20 | DT_CLK(NULL, "sysclk6_ck", "sysclk6_ck"), |
Tony Lindgren | 5fbeef5 | 2015-12-03 12:02:31 -0800 | [diff] [blame] | 21 | DT_CLK(NULL, "sysclk8_ck", "sysclk8_ck"), |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 22 | 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 Lindgren | 5fbeef5 | 2015-12-03 12:02:31 -0800 | [diff] [blame] | 25 | DT_CLK(NULL, "timer1_fck", "timer1_fck"), |
| 26 | DT_CLK(NULL, "timer2_fck", "timer2_fck"), |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 27 | 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 Lindgren | 2133049 | 2016-02-26 09:35:05 -0800 | [diff] [blame] | 32 | static bool timer_clocks_initialized; |
| 33 | |
Stephen Boyd | 8a8b6eb | 2016-03-01 10:51:42 -0800 | [diff] [blame] | 34 | static int __init dm814x_adpll_early_init(void) |
Tony Lindgren | 2133049 | 2016-02-26 09:35:05 -0800 | [diff] [blame] | 35 | { |
| 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 | } |
| 51 | core_initcall(dm814x_adpll_early_init); |
| 52 | |
| 53 | static const char * const init_clocks[] = { |
| 54 | "pll040clkout", /* MPU 481c5040.adpll.clkout */ |
| 55 | "pll290clkout", /* DDR 481c5290.adpll.clkout */ |
| 56 | }; |
| 57 | |
Stephen Boyd | 8a8b6eb | 2016-03-01 10:51:42 -0800 | [diff] [blame] | 58 | static int __init dm814x_adpll_enable_init_clocks(void) |
Tony Lindgren | 2133049 | 2016-02-26 09:35:05 -0800 | [diff] [blame] | 59 | { |
| 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 | } |
| 80 | postcore_initcall(dm814x_adpll_enable_init_clocks); |
| 81 | |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 82 | int __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 Lindgren | 2133049 | 2016-02-26 09:35:05 -0800 | [diff] [blame] | 87 | timer_clocks_initialized = true; |
Tony Lindgren | 9cf705d | 2015-07-16 01:55:57 -0700 | [diff] [blame] | 88 | |
| 89 | return 0; |
| 90 | } |