19cf705deSTony Lindgren /* 29cf705deSTony Lindgren * This program is free software; you can redistribute it and/or 39cf705deSTony Lindgren * modify it under the terms of the GNU General Public License as 49cf705deSTony Lindgren * published by the Free Software Foundation version 2. 59cf705deSTony Lindgren */ 69cf705deSTony Lindgren 79cf705deSTony Lindgren #include <linux/kernel.h> 821330497STony Lindgren #include <linux/clk.h> 99cf705deSTony Lindgren #include <linux/clk-provider.h> 109cf705deSTony Lindgren #include <linux/clk/ti.h> 1121330497STony Lindgren #include <linux/of_platform.h> 129cf705deSTony Lindgren 13f9511a4fSStephen Rothwell #include "clock.h" 14f9511a4fSStephen Rothwell 159cf705deSTony Lindgren static struct ti_dt_clk dm814_clks[] = { 169cf705deSTony Lindgren DT_CLK(NULL, "timer_sys_ck", "devosc_ck"), 179cf705deSTony Lindgren { .node_name = NULL }, 189cf705deSTony Lindgren }; 199cf705deSTony Lindgren 2021330497STony Lindgren static bool timer_clocks_initialized; 2121330497STony Lindgren 228a8b6eb7SStephen Boyd static int __init dm814x_adpll_early_init(void) 2321330497STony Lindgren { 2421330497STony Lindgren struct device_node *np; 2521330497STony Lindgren 2621330497STony Lindgren if (!timer_clocks_initialized) 2721330497STony Lindgren return -ENODEV; 2821330497STony Lindgren 2921330497STony Lindgren np = of_find_node_by_name(NULL, "pllss"); 3021330497STony Lindgren if (!np) { 3121330497STony Lindgren pr_err("Could not find node for plls\n"); 3221330497STony Lindgren return -ENODEV; 3321330497STony Lindgren } 3421330497STony Lindgren 3521330497STony Lindgren of_platform_populate(np, NULL, NULL, NULL); 3621330497STony Lindgren 3721330497STony Lindgren return 0; 3821330497STony Lindgren } 3921330497STony Lindgren core_initcall(dm814x_adpll_early_init); 4021330497STony Lindgren 4121330497STony Lindgren static const char * const init_clocks[] = { 4221330497STony Lindgren "pll040clkout", /* MPU 481c5040.adpll.clkout */ 4321330497STony Lindgren "pll290clkout", /* DDR 481c5290.adpll.clkout */ 4421330497STony Lindgren }; 4521330497STony Lindgren 468a8b6eb7SStephen Boyd static int __init dm814x_adpll_enable_init_clocks(void) 4721330497STony Lindgren { 4821330497STony Lindgren int i, err; 4921330497STony Lindgren 5021330497STony Lindgren if (!timer_clocks_initialized) 5121330497STony Lindgren return -ENODEV; 5221330497STony Lindgren 5321330497STony Lindgren for (i = 0; i < ARRAY_SIZE(init_clocks); i++) { 5421330497STony Lindgren struct clk *clock; 5521330497STony Lindgren 5621330497STony Lindgren clock = clk_get(NULL, init_clocks[i]); 5721330497STony Lindgren if (WARN(IS_ERR(clock), "could not find init clock %s\n", 5821330497STony Lindgren init_clocks[i])) 5921330497STony Lindgren continue; 6021330497STony Lindgren err = clk_prepare_enable(clock); 6121330497STony Lindgren if (WARN(err, "could not enable init clock %s\n", 6221330497STony Lindgren init_clocks[i])) 6321330497STony Lindgren continue; 6421330497STony Lindgren } 6521330497STony Lindgren 6621330497STony Lindgren return 0; 6721330497STony Lindgren } 6821330497STony Lindgren postcore_initcall(dm814x_adpll_enable_init_clocks); 6921330497STony Lindgren 709cf705deSTony Lindgren int __init dm814x_dt_clk_init(void) 719cf705deSTony Lindgren { 729cf705deSTony Lindgren ti_dt_clocks_register(dm814_clks); 739cf705deSTony Lindgren omap2_clk_disable_autoidle_all(); 74*44d2b566STero Kristo ti_clk_add_aliases(); 759cf705deSTony Lindgren omap2_clk_enable_init_clocks(NULL, 0); 7621330497STony Lindgren timer_clocks_initialized = true; 779cf705deSTony Lindgren 789cf705deSTony Lindgren return 0; 799cf705deSTony Lindgren } 80