xref: /openbmc/linux/drivers/clk/ti/clk-43xx.c (revision f9786f41)
1ffab2399STero Kristo /*
2ffab2399STero Kristo  * AM43XX Clock init
3ffab2399STero Kristo  *
4ffab2399STero Kristo  * Copyright (C) 2013 Texas Instruments, Inc
5ffab2399STero Kristo  *     Tero Kristo (t-kristo@ti.com)
6ffab2399STero Kristo  *
7ffab2399STero Kristo  * This program is free software; you can redistribute it and/or
8ffab2399STero Kristo  * modify it under the terms of the GNU General Public License as
9ffab2399STero Kristo  * published by the Free Software Foundation version 2.
10ffab2399STero Kristo  *
11ffab2399STero Kristo  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12ffab2399STero Kristo  * kind, whether express or implied; without even the implied warranty
13ffab2399STero Kristo  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14ffab2399STero Kristo  * GNU General Public License for more details.
15ffab2399STero Kristo  */
16ffab2399STero Kristo 
17ffab2399STero Kristo #include <linux/kernel.h>
18ffab2399STero Kristo #include <linux/list.h>
19ffab2399STero Kristo #include <linux/clk-provider.h>
20ffab2399STero Kristo #include <linux/clk/ti.h>
21ffab2399STero Kristo 
22ffab2399STero Kristo static struct ti_dt_clk am43xx_clks[] = {
23ffab2399STero Kristo 	DT_CLK(NULL, "clk_32768_ck", "clk_32768_ck"),
24ffab2399STero Kristo 	DT_CLK(NULL, "clk_rc32k_ck", "clk_rc32k_ck"),
25ffab2399STero Kristo 	DT_CLK(NULL, "virt_19200000_ck", "virt_19200000_ck"),
26ffab2399STero Kristo 	DT_CLK(NULL, "virt_24000000_ck", "virt_24000000_ck"),
27ffab2399STero Kristo 	DT_CLK(NULL, "virt_25000000_ck", "virt_25000000_ck"),
28ffab2399STero Kristo 	DT_CLK(NULL, "virt_26000000_ck", "virt_26000000_ck"),
29ffab2399STero Kristo 	DT_CLK(NULL, "sys_clkin_ck", "sys_clkin_ck"),
30ffab2399STero Kristo 	DT_CLK(NULL, "tclkin_ck", "tclkin_ck"),
31ffab2399STero Kristo 	DT_CLK(NULL, "dpll_core_ck", "dpll_core_ck"),
32ffab2399STero Kristo 	DT_CLK(NULL, "dpll_core_x2_ck", "dpll_core_x2_ck"),
33ffab2399STero Kristo 	DT_CLK(NULL, "dpll_core_m4_ck", "dpll_core_m4_ck"),
34ffab2399STero Kristo 	DT_CLK(NULL, "dpll_core_m5_ck", "dpll_core_m5_ck"),
35ffab2399STero Kristo 	DT_CLK(NULL, "dpll_core_m6_ck", "dpll_core_m6_ck"),
36ffab2399STero Kristo 	DT_CLK(NULL, "dpll_mpu_ck", "dpll_mpu_ck"),
37ffab2399STero Kristo 	DT_CLK(NULL, "dpll_mpu_m2_ck", "dpll_mpu_m2_ck"),
38ffab2399STero Kristo 	DT_CLK(NULL, "dpll_ddr_ck", "dpll_ddr_ck"),
39ffab2399STero Kristo 	DT_CLK(NULL, "dpll_ddr_m2_ck", "dpll_ddr_m2_ck"),
40ffab2399STero Kristo 	DT_CLK(NULL, "dpll_disp_ck", "dpll_disp_ck"),
41ffab2399STero Kristo 	DT_CLK(NULL, "dpll_disp_m2_ck", "dpll_disp_m2_ck"),
42ffab2399STero Kristo 	DT_CLK(NULL, "dpll_per_ck", "dpll_per_ck"),
43ffab2399STero Kristo 	DT_CLK(NULL, "dpll_per_m2_ck", "dpll_per_m2_ck"),
44ffab2399STero Kristo 	DT_CLK(NULL, "dpll_per_m2_div4_wkupdm_ck", "dpll_per_m2_div4_wkupdm_ck"),
45ffab2399STero Kristo 	DT_CLK(NULL, "dpll_per_m2_div4_ck", "dpll_per_m2_div4_ck"),
46ffab2399STero Kristo 	DT_CLK(NULL, "adc_tsc_fck", "adc_tsc_fck"),
47ffab2399STero Kristo 	DT_CLK(NULL, "clkdiv32k_ck", "clkdiv32k_ck"),
48ffab2399STero Kristo 	DT_CLK(NULL, "clkdiv32k_ick", "clkdiv32k_ick"),
49ffab2399STero Kristo 	DT_CLK(NULL, "dcan0_fck", "dcan0_fck"),
50ffab2399STero Kristo 	DT_CLK(NULL, "dcan1_fck", "dcan1_fck"),
51ffab2399STero Kristo 	DT_CLK(NULL, "pruss_ocp_gclk", "pruss_ocp_gclk"),
52ffab2399STero Kristo 	DT_CLK(NULL, "mcasp0_fck", "mcasp0_fck"),
53ffab2399STero Kristo 	DT_CLK(NULL, "mcasp1_fck", "mcasp1_fck"),
54ffab2399STero Kristo 	DT_CLK(NULL, "smartreflex0_fck", "smartreflex0_fck"),
55ffab2399STero Kristo 	DT_CLK(NULL, "smartreflex1_fck", "smartreflex1_fck"),
56ffab2399STero Kristo 	DT_CLK(NULL, "sha0_fck", "sha0_fck"),
57ffab2399STero Kristo 	DT_CLK(NULL, "aes0_fck", "aes0_fck"),
58ffab2399STero Kristo 	DT_CLK(NULL, "timer1_fck", "timer1_fck"),
59ffab2399STero Kristo 	DT_CLK(NULL, "timer2_fck", "timer2_fck"),
60ffab2399STero Kristo 	DT_CLK(NULL, "timer3_fck", "timer3_fck"),
61ffab2399STero Kristo 	DT_CLK(NULL, "timer4_fck", "timer4_fck"),
62ffab2399STero Kristo 	DT_CLK(NULL, "timer5_fck", "timer5_fck"),
63ffab2399STero Kristo 	DT_CLK(NULL, "timer6_fck", "timer6_fck"),
64ffab2399STero Kristo 	DT_CLK(NULL, "timer7_fck", "timer7_fck"),
65ffab2399STero Kristo 	DT_CLK(NULL, "wdt1_fck", "wdt1_fck"),
66ffab2399STero Kristo 	DT_CLK(NULL, "l3_gclk", "l3_gclk"),
67ffab2399STero Kristo 	DT_CLK(NULL, "dpll_core_m4_div2_ck", "dpll_core_m4_div2_ck"),
68ffab2399STero Kristo 	DT_CLK(NULL, "l4hs_gclk", "l4hs_gclk"),
69ffab2399STero Kristo 	DT_CLK(NULL, "l3s_gclk", "l3s_gclk"),
70ffab2399STero Kristo 	DT_CLK(NULL, "l4ls_gclk", "l4ls_gclk"),
71ffab2399STero Kristo 	DT_CLK(NULL, "clk_24mhz", "clk_24mhz"),
72ffab2399STero Kristo 	DT_CLK(NULL, "cpsw_125mhz_gclk", "cpsw_125mhz_gclk"),
73ffab2399STero Kristo 	DT_CLK(NULL, "cpsw_cpts_rft_clk", "cpsw_cpts_rft_clk"),
74ffab2399STero Kristo 	DT_CLK(NULL, "gpio0_dbclk_mux_ck", "gpio0_dbclk_mux_ck"),
75ffab2399STero Kristo 	DT_CLK(NULL, "gpio0_dbclk", "gpio0_dbclk"),
76ffab2399STero Kristo 	DT_CLK(NULL, "gpio1_dbclk", "gpio1_dbclk"),
77ffab2399STero Kristo 	DT_CLK(NULL, "gpio2_dbclk", "gpio2_dbclk"),
78ffab2399STero Kristo 	DT_CLK(NULL, "gpio3_dbclk", "gpio3_dbclk"),
79ffab2399STero Kristo 	DT_CLK(NULL, "gpio4_dbclk", "gpio4_dbclk"),
80ffab2399STero Kristo 	DT_CLK(NULL, "gpio5_dbclk", "gpio5_dbclk"),
81ffab2399STero Kristo 	DT_CLK(NULL, "mmc_clk", "mmc_clk"),
82ffab2399STero Kristo 	DT_CLK(NULL, "gfx_fclk_clksel_ck", "gfx_fclk_clksel_ck"),
83ffab2399STero Kristo 	DT_CLK(NULL, "gfx_fck_div_ck", "gfx_fck_div_ck"),
84ffab2399STero Kristo 	DT_CLK(NULL, "timer_32k_ck", "clkdiv32k_ick"),
85ffab2399STero Kristo 	DT_CLK(NULL, "timer_sys_ck", "sys_clkin_ck"),
86ffab2399STero Kristo 	DT_CLK(NULL, "sysclk_div", "sysclk_div"),
87ffab2399STero Kristo 	DT_CLK(NULL, "disp_clk", "disp_clk"),
88ffab2399STero Kristo 	DT_CLK(NULL, "clk_32k_mosc_ck", "clk_32k_mosc_ck"),
89ffab2399STero Kristo 	DT_CLK(NULL, "clk_32k_tpm_ck", "clk_32k_tpm_ck"),
90ffab2399STero Kristo 	DT_CLK(NULL, "dpll_extdev_ck", "dpll_extdev_ck"),
91ffab2399STero Kristo 	DT_CLK(NULL, "dpll_extdev_m2_ck", "dpll_extdev_m2_ck"),
92ffab2399STero Kristo 	DT_CLK(NULL, "mux_synctimer32k_ck", "mux_synctimer32k_ck"),
93ffab2399STero Kristo 	DT_CLK(NULL, "synctimer_32kclk", "synctimer_32kclk"),
94ffab2399STero Kristo 	DT_CLK(NULL, "timer8_fck", "timer8_fck"),
95ffab2399STero Kristo 	DT_CLK(NULL, "timer9_fck", "timer9_fck"),
96ffab2399STero Kristo 	DT_CLK(NULL, "timer10_fck", "timer10_fck"),
97ffab2399STero Kristo 	DT_CLK(NULL, "timer11_fck", "timer11_fck"),
98ffab2399STero Kristo 	DT_CLK(NULL, "cpsw_50m_clkdiv", "cpsw_50m_clkdiv"),
99ffab2399STero Kristo 	DT_CLK(NULL, "cpsw_5m_clkdiv", "cpsw_5m_clkdiv"),
100ffab2399STero Kristo 	DT_CLK(NULL, "dpll_ddr_x2_ck", "dpll_ddr_x2_ck"),
101ffab2399STero Kristo 	DT_CLK(NULL, "dpll_ddr_m4_ck", "dpll_ddr_m4_ck"),
102ffab2399STero Kristo 	DT_CLK(NULL, "dpll_per_clkdcoldo", "dpll_per_clkdcoldo"),
103ffab2399STero Kristo 	DT_CLK(NULL, "dll_aging_clk_div", "dll_aging_clk_div"),
104ffab2399STero Kristo 	DT_CLK(NULL, "div_core_25m_ck", "div_core_25m_ck"),
105ffab2399STero Kristo 	DT_CLK(NULL, "func_12m_clk", "func_12m_clk"),
106ffab2399STero Kristo 	DT_CLK(NULL, "vtp_clk_div", "vtp_clk_div"),
107ffab2399STero Kristo 	DT_CLK(NULL, "usbphy_32khz_clkmux", "usbphy_32khz_clkmux"),
108ffab2399STero Kristo 	{ .node_name = NULL },
109ffab2399STero Kristo };
110ffab2399STero Kristo 
111ffab2399STero Kristo int __init am43xx_dt_clk_init(void)
112ffab2399STero Kristo {
113f9786f41SGeorge Cherian 	struct clk *clk1, *clk2;
114f9786f41SGeorge Cherian 
115ffab2399STero Kristo 	ti_dt_clocks_register(am43xx_clks);
116ffab2399STero Kristo 
117ffab2399STero Kristo 	omap2_clk_disable_autoidle_all();
118ffab2399STero Kristo 
119f9786f41SGeorge Cherian 	/*
120f9786f41SGeorge Cherian 	 * cpsw_cpts_rft_clk  has got the choice of 3 clocksources
121f9786f41SGeorge Cherian 	 * dpll_core_m4_ck, dpll_core_m5_ck and dpll_disp_m2_ck.
122f9786f41SGeorge Cherian 	 * By default dpll_core_m4_ck is selected, witn this as clock
123f9786f41SGeorge Cherian 	 * source the CPTS doesnot work properly. It gives clockcheck errors
124f9786f41SGeorge Cherian 	 * while running PTP.
125f9786f41SGeorge Cherian 	 * clockcheck: clock jumped backward or running slower than expected!
126f9786f41SGeorge Cherian 	 * By selecting dpll_core_m5_ck as the clocksource fixes this issue.
127f9786f41SGeorge Cherian 	 * In AM335x dpll_core_m5_ck is the default clocksource.
128f9786f41SGeorge Cherian 	 */
129f9786f41SGeorge Cherian 	clk1 = clk_get_sys(NULL, "cpsw_cpts_rft_clk");
130f9786f41SGeorge Cherian 	clk2 = clk_get_sys(NULL, "dpll_core_m5_ck");
131f9786f41SGeorge Cherian 	clk_set_parent(clk1, clk2);
132f9786f41SGeorge Cherian 
133ffab2399STero Kristo 	return 0;
134ffab2399STero Kristo }
135