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> 8 #include <linux/clk.h> 9 #include <linux/clk-provider.h> 10 #include <linux/clk/ti.h> 11 #include <linux/of_platform.h> 12 13 #include "clock.h" 14 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"), 19 DT_CLK(NULL, "sysclk5_ck", "sysclk5_ck"), 20 DT_CLK(NULL, "sysclk6_ck", "sysclk6_ck"), 21 DT_CLK(NULL, "sysclk8_ck", "sysclk8_ck"), 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"), 25 DT_CLK(NULL, "timer1_fck", "timer1_fck"), 26 DT_CLK(NULL, "timer2_fck", "timer2_fck"), 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 32 static bool timer_clocks_initialized; 33 34 static int __init dm814x_adpll_early_init(void) 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 58 static int __init dm814x_adpll_enable_init_clocks(void) 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 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); 87 timer_clocks_initialized = true; 88 89 return 0; 90 } 91