18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * AM33XX Clock init
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2013 Texas Instruments, Inc
58c2ecf20Sopenharmony_ci *     Tero Kristo (t-kristo@ti.com)
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
88c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License as
98c2ecf20Sopenharmony_ci * published by the Free Software Foundation version 2.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * This program is distributed "as is" WITHOUT ANY WARRANTY of any
128c2ecf20Sopenharmony_ci * kind, whether express or implied; without even the implied warranty
138c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
148c2ecf20Sopenharmony_ci * GNU General Public License for more details.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <linux/kernel.h>
188c2ecf20Sopenharmony_ci#include <linux/list.h>
198c2ecf20Sopenharmony_ci#include <linux/clk.h>
208c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
218c2ecf20Sopenharmony_ci#include <linux/clk/ti.h>
228c2ecf20Sopenharmony_ci#include <dt-bindings/clock/am3.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include "clock.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic const char * const am3_gpio1_dbclk_parents[] __initconst = {
278c2ecf20Sopenharmony_ci	"clk-24mhz-clkctrl:0000:0",
288c2ecf20Sopenharmony_ci	NULL,
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am3_gpio2_bit_data[] __initconst = {
328c2ecf20Sopenharmony_ci	{ 18, TI_CLK_GATE, am3_gpio1_dbclk_parents, NULL },
338c2ecf20Sopenharmony_ci	{ 0 },
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am3_gpio3_bit_data[] __initconst = {
378c2ecf20Sopenharmony_ci	{ 18, TI_CLK_GATE, am3_gpio1_dbclk_parents, NULL },
388c2ecf20Sopenharmony_ci	{ 0 },
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am3_gpio4_bit_data[] __initconst = {
428c2ecf20Sopenharmony_ci	{ 18, TI_CLK_GATE, am3_gpio1_dbclk_parents, NULL },
438c2ecf20Sopenharmony_ci	{ 0 },
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l4ls_clkctrl_regs[] __initconst = {
478c2ecf20Sopenharmony_ci	{ AM3_L4LS_UART6_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
488c2ecf20Sopenharmony_ci	{ AM3_L4LS_MMC1_CLKCTRL, NULL, CLKF_SW_SUP, "mmc_clk" },
498c2ecf20Sopenharmony_ci	{ AM3_L4LS_ELM_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
508c2ecf20Sopenharmony_ci	{ AM3_L4LS_I2C3_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
518c2ecf20Sopenharmony_ci	{ AM3_L4LS_I2C2_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
528c2ecf20Sopenharmony_ci	{ AM3_L4LS_SPI0_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
538c2ecf20Sopenharmony_ci	{ AM3_L4LS_SPI1_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
548c2ecf20Sopenharmony_ci	{ AM3_L4LS_L4_LS_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
558c2ecf20Sopenharmony_ci	{ AM3_L4LS_UART2_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
568c2ecf20Sopenharmony_ci	{ AM3_L4LS_UART3_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
578c2ecf20Sopenharmony_ci	{ AM3_L4LS_UART4_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
588c2ecf20Sopenharmony_ci	{ AM3_L4LS_UART5_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
598c2ecf20Sopenharmony_ci	{ AM3_L4LS_TIMER7_CLKCTRL, NULL, CLKF_SW_SUP, "timer7_fck" },
608c2ecf20Sopenharmony_ci	{ AM3_L4LS_TIMER2_CLKCTRL, NULL, CLKF_SW_SUP, "timer2_fck" },
618c2ecf20Sopenharmony_ci	{ AM3_L4LS_TIMER3_CLKCTRL, NULL, CLKF_SW_SUP, "timer3_fck" },
628c2ecf20Sopenharmony_ci	{ AM3_L4LS_TIMER4_CLKCTRL, NULL, CLKF_SW_SUP, "timer4_fck" },
638c2ecf20Sopenharmony_ci	{ AM3_L4LS_RNG_CLKCTRL, NULL, CLKF_SW_SUP, "rng_fck" },
648c2ecf20Sopenharmony_ci	{ AM3_L4LS_GPIO2_CLKCTRL, am3_gpio2_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
658c2ecf20Sopenharmony_ci	{ AM3_L4LS_GPIO3_CLKCTRL, am3_gpio3_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
668c2ecf20Sopenharmony_ci	{ AM3_L4LS_GPIO4_CLKCTRL, am3_gpio4_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
678c2ecf20Sopenharmony_ci	{ AM3_L4LS_D_CAN0_CLKCTRL, NULL, CLKF_SW_SUP, "dcan0_fck" },
688c2ecf20Sopenharmony_ci	{ AM3_L4LS_D_CAN1_CLKCTRL, NULL, CLKF_SW_SUP, "dcan1_fck" },
698c2ecf20Sopenharmony_ci	{ AM3_L4LS_EPWMSS1_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
708c2ecf20Sopenharmony_ci	{ AM3_L4LS_EPWMSS0_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
718c2ecf20Sopenharmony_ci	{ AM3_L4LS_EPWMSS2_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
728c2ecf20Sopenharmony_ci	{ AM3_L4LS_TIMER5_CLKCTRL, NULL, CLKF_SW_SUP, "timer5_fck" },
738c2ecf20Sopenharmony_ci	{ AM3_L4LS_TIMER6_CLKCTRL, NULL, CLKF_SW_SUP, "timer6_fck" },
748c2ecf20Sopenharmony_ci	{ AM3_L4LS_MMC2_CLKCTRL, NULL, CLKF_SW_SUP, "mmc_clk" },
758c2ecf20Sopenharmony_ci	{ AM3_L4LS_SPINLOCK_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
768c2ecf20Sopenharmony_ci	{ AM3_L4LS_MAILBOX_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
778c2ecf20Sopenharmony_ci	{ AM3_L4LS_OCPWP_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
788c2ecf20Sopenharmony_ci	{ 0 },
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l3s_clkctrl_regs[] __initconst = {
828c2ecf20Sopenharmony_ci	{ AM3_L3S_USB_OTG_HS_CLKCTRL, NULL, CLKF_SW_SUP, "usbotg_fck" },
838c2ecf20Sopenharmony_ci	{ AM3_L3S_GPMC_CLKCTRL, NULL, CLKF_SW_SUP, "l3s_gclk" },
848c2ecf20Sopenharmony_ci	{ AM3_L3S_MCASP0_CLKCTRL, NULL, CLKF_SW_SUP, "mcasp0_fck" },
858c2ecf20Sopenharmony_ci	{ AM3_L3S_MCASP1_CLKCTRL, NULL, CLKF_SW_SUP, "mcasp1_fck" },
868c2ecf20Sopenharmony_ci	{ AM3_L3S_MMC3_CLKCTRL, NULL, CLKF_SW_SUP, "mmc_clk" },
878c2ecf20Sopenharmony_ci	{ 0 },
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l3_clkctrl_regs[] __initconst = {
918c2ecf20Sopenharmony_ci	{ AM3_L3_TPTC0_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
928c2ecf20Sopenharmony_ci	{ AM3_L3_EMIF_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_ddr_m2_div2_ck" },
938c2ecf20Sopenharmony_ci	{ AM3_L3_OCMCRAM_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
948c2ecf20Sopenharmony_ci	{ AM3_L3_AES_CLKCTRL, NULL, CLKF_SW_SUP, "aes0_fck" },
958c2ecf20Sopenharmony_ci	{ AM3_L3_SHAM_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
968c2ecf20Sopenharmony_ci	{ AM3_L3_TPCC_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
978c2ecf20Sopenharmony_ci	{ AM3_L3_L3_INSTR_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
988c2ecf20Sopenharmony_ci	{ AM3_L3_L3_MAIN_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
998c2ecf20Sopenharmony_ci	{ AM3_L3_TPTC1_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
1008c2ecf20Sopenharmony_ci	{ AM3_L3_TPTC2_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
1018c2ecf20Sopenharmony_ci	{ 0 },
1028c2ecf20Sopenharmony_ci};
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l4hs_clkctrl_regs[] __initconst = {
1058c2ecf20Sopenharmony_ci	{ AM3_L4HS_L4_HS_CLKCTRL, NULL, CLKF_SW_SUP, "l4hs_gclk" },
1068c2ecf20Sopenharmony_ci	{ 0 },
1078c2ecf20Sopenharmony_ci};
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_pruss_ocp_clkctrl_regs[] __initconst = {
1108c2ecf20Sopenharmony_ci	{ AM3_PRUSS_OCP_PRUSS_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_NO_IDLEST, "pruss_ocp_gclk" },
1118c2ecf20Sopenharmony_ci	{ 0 },
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_cpsw_125mhz_clkctrl_regs[] __initconst = {
1158c2ecf20Sopenharmony_ci	{ AM3_CPSW_125MHZ_CPGMAC0_CLKCTRL, NULL, CLKF_SW_SUP, "cpsw_125mhz_gclk" },
1168c2ecf20Sopenharmony_ci	{ 0 },
1178c2ecf20Sopenharmony_ci};
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_lcdc_clkctrl_regs[] __initconst = {
1208c2ecf20Sopenharmony_ci	{ AM3_LCDC_LCDC_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_SET_RATE_PARENT, "lcd_gclk" },
1218c2ecf20Sopenharmony_ci	{ 0 },
1228c2ecf20Sopenharmony_ci};
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_clk_24mhz_clkctrl_regs[] __initconst = {
1258c2ecf20Sopenharmony_ci	{ AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL, NULL, CLKF_SW_SUP, "clkdiv32k_ck" },
1268c2ecf20Sopenharmony_ci	{ 0 },
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistatic const char * const am3_gpio0_dbclk_parents[] __initconst = {
1308c2ecf20Sopenharmony_ci	"gpio0_dbclk_mux_ck",
1318c2ecf20Sopenharmony_ci	NULL,
1328c2ecf20Sopenharmony_ci};
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am3_gpio1_bit_data[] __initconst = {
1358c2ecf20Sopenharmony_ci	{ 18, TI_CLK_GATE, am3_gpio0_dbclk_parents, NULL },
1368c2ecf20Sopenharmony_ci	{ 0 },
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l4_wkup_clkctrl_regs[] __initconst = {
1408c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_CONTROL_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_core_m4_div2_ck" },
1418c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_GPIO1_CLKCTRL, am3_gpio1_bit_data, CLKF_SW_SUP, "dpll_core_m4_div2_ck" },
1428c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_L4_WKUP_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_core_m4_div2_ck" },
1438c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_UART1_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_wkupdm_ck" },
1448c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_I2C1_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_wkupdm_ck" },
1458c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_ADC_TSC_CLKCTRL, NULL, CLKF_SW_SUP, "adc_tsc_fck" },
1468c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_SMARTREFLEX0_CLKCTRL, NULL, CLKF_SW_SUP, "smartreflex0_fck" },
1478c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_TIMER1_CLKCTRL, NULL, CLKF_SW_SUP, "timer1_fck" },
1488c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_SMARTREFLEX1_CLKCTRL, NULL, CLKF_SW_SUP, "smartreflex1_fck" },
1498c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_WD_TIMER2_CLKCTRL, NULL, CLKF_SW_SUP, "wdt1_fck" },
1508c2ecf20Sopenharmony_ci	{ 0 },
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistatic const char * const am3_dbg_sysclk_ck_parents[] __initconst = {
1548c2ecf20Sopenharmony_ci	"sys_clkin_ck",
1558c2ecf20Sopenharmony_ci	NULL,
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistatic const char * const am3_trace_pmd_clk_mux_ck_parents[] __initconst = {
1598c2ecf20Sopenharmony_ci	"l3-aon-clkctrl:0000:19",
1608c2ecf20Sopenharmony_ci	"l3-aon-clkctrl:0000:30",
1618c2ecf20Sopenharmony_ci	NULL,
1628c2ecf20Sopenharmony_ci};
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_cistatic const char * const am3_trace_clk_div_ck_parents[] __initconst = {
1658c2ecf20Sopenharmony_ci	"l3-aon-clkctrl:0000:20",
1668c2ecf20Sopenharmony_ci	NULL,
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_div_data am3_trace_clk_div_ck_data __initconst = {
1708c2ecf20Sopenharmony_ci	.max_div = 64,
1718c2ecf20Sopenharmony_ci	.flags = CLK_DIVIDER_POWER_OF_TWO,
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cistatic const char * const am3_stm_clk_div_ck_parents[] __initconst = {
1758c2ecf20Sopenharmony_ci	"l3-aon-clkctrl:0000:22",
1768c2ecf20Sopenharmony_ci	NULL,
1778c2ecf20Sopenharmony_ci};
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_div_data am3_stm_clk_div_ck_data __initconst = {
1808c2ecf20Sopenharmony_ci	.max_div = 64,
1818c2ecf20Sopenharmony_ci	.flags = CLK_DIVIDER_POWER_OF_TWO,
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_cistatic const char * const am3_dbg_clka_ck_parents[] __initconst = {
1858c2ecf20Sopenharmony_ci	"dpll_core_m4_ck",
1868c2ecf20Sopenharmony_ci	NULL,
1878c2ecf20Sopenharmony_ci};
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am3_debugss_bit_data[] __initconst = {
1908c2ecf20Sopenharmony_ci	{ 19, TI_CLK_GATE, am3_dbg_sysclk_ck_parents, NULL },
1918c2ecf20Sopenharmony_ci	{ 20, TI_CLK_MUX, am3_trace_pmd_clk_mux_ck_parents, NULL },
1928c2ecf20Sopenharmony_ci	{ 22, TI_CLK_MUX, am3_trace_pmd_clk_mux_ck_parents, NULL },
1938c2ecf20Sopenharmony_ci	{ 24, TI_CLK_DIVIDER, am3_trace_clk_div_ck_parents, &am3_trace_clk_div_ck_data },
1948c2ecf20Sopenharmony_ci	{ 27, TI_CLK_DIVIDER, am3_stm_clk_div_ck_parents, &am3_stm_clk_div_ck_data },
1958c2ecf20Sopenharmony_ci	{ 30, TI_CLK_GATE, am3_dbg_clka_ck_parents, NULL },
1968c2ecf20Sopenharmony_ci	{ 0 },
1978c2ecf20Sopenharmony_ci};
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l3_aon_clkctrl_regs[] __initconst = {
2008c2ecf20Sopenharmony_ci	{ AM3_L3_AON_DEBUGSS_CLKCTRL, am3_debugss_bit_data, CLKF_SW_SUP, "l3-aon-clkctrl:0000:24" },
2018c2ecf20Sopenharmony_ci	{ 0 },
2028c2ecf20Sopenharmony_ci};
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l4_wkup_aon_clkctrl_regs[] __initconst = {
2058c2ecf20Sopenharmony_ci	{ AM3_L4_WKUP_AON_WKUP_M3_CLKCTRL, NULL, CLKF_NO_IDLEST, "dpll_core_m4_div2_ck" },
2068c2ecf20Sopenharmony_ci	{ 0 },
2078c2ecf20Sopenharmony_ci};
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_mpu_clkctrl_regs[] __initconst = {
2108c2ecf20Sopenharmony_ci	{ AM3_MPU_MPU_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_mpu_m2_ck" },
2118c2ecf20Sopenharmony_ci	{ 0 },
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l4_rtc_clkctrl_regs[] __initconst = {
2158c2ecf20Sopenharmony_ci	{ AM3_L4_RTC_RTC_CLKCTRL, NULL, CLKF_SW_SUP, "clk-24mhz-clkctrl:0000:0" },
2168c2ecf20Sopenharmony_ci	{ 0 },
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_gfx_l3_clkctrl_regs[] __initconst = {
2208c2ecf20Sopenharmony_ci	{ AM3_GFX_L3_GFX_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_NO_IDLEST, "gfx_fck_div_ck" },
2218c2ecf20Sopenharmony_ci	{ 0 },
2228c2ecf20Sopenharmony_ci};
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am3_l4_cefuse_clkctrl_regs[] __initconst = {
2258c2ecf20Sopenharmony_ci	{ AM3_L4_CEFUSE_CEFUSE_CLKCTRL, NULL, CLKF_SW_SUP, "sys_clkin_ck" },
2268c2ecf20Sopenharmony_ci	{ 0 },
2278c2ecf20Sopenharmony_ci};
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ciconst struct omap_clkctrl_data am3_clkctrl_data[] __initconst = {
2308c2ecf20Sopenharmony_ci	{ 0x44e00038, am3_l4ls_clkctrl_regs },
2318c2ecf20Sopenharmony_ci	{ 0x44e0001c, am3_l3s_clkctrl_regs },
2328c2ecf20Sopenharmony_ci	{ 0x44e00024, am3_l3_clkctrl_regs },
2338c2ecf20Sopenharmony_ci	{ 0x44e00120, am3_l4hs_clkctrl_regs },
2348c2ecf20Sopenharmony_ci	{ 0x44e000e8, am3_pruss_ocp_clkctrl_regs },
2358c2ecf20Sopenharmony_ci	{ 0x44e00000, am3_cpsw_125mhz_clkctrl_regs },
2368c2ecf20Sopenharmony_ci	{ 0x44e00018, am3_lcdc_clkctrl_regs },
2378c2ecf20Sopenharmony_ci	{ 0x44e0014c, am3_clk_24mhz_clkctrl_regs },
2388c2ecf20Sopenharmony_ci	{ 0x44e00400, am3_l4_wkup_clkctrl_regs },
2398c2ecf20Sopenharmony_ci	{ 0x44e00414, am3_l3_aon_clkctrl_regs },
2408c2ecf20Sopenharmony_ci	{ 0x44e004b0, am3_l4_wkup_aon_clkctrl_regs },
2418c2ecf20Sopenharmony_ci	{ 0x44e00600, am3_mpu_clkctrl_regs },
2428c2ecf20Sopenharmony_ci	{ 0x44e00800, am3_l4_rtc_clkctrl_regs },
2438c2ecf20Sopenharmony_ci	{ 0x44e00900, am3_gfx_l3_clkctrl_regs },
2448c2ecf20Sopenharmony_ci	{ 0x44e00a00, am3_l4_cefuse_clkctrl_regs },
2458c2ecf20Sopenharmony_ci	{ 0 },
2468c2ecf20Sopenharmony_ci};
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cistatic struct ti_dt_clk am33xx_clks[] = {
2498c2ecf20Sopenharmony_ci	DT_CLK(NULL, "timer_32k_ck", "clk-24mhz-clkctrl:0000:0"),
2508c2ecf20Sopenharmony_ci	DT_CLK(NULL, "timer_sys_ck", "sys_clkin_ck"),
2518c2ecf20Sopenharmony_ci	DT_CLK(NULL, "clkdiv32k_ick", "clk-24mhz-clkctrl:0000:0"),
2528c2ecf20Sopenharmony_ci	DT_CLK(NULL, "dbg_clka_ck", "l3-aon-clkctrl:0000:30"),
2538c2ecf20Sopenharmony_ci	DT_CLK(NULL, "dbg_sysclk_ck", "l3-aon-clkctrl:0000:19"),
2548c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio0_dbclk", "l4-wkup-clkctrl:0008:18"),
2558c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio1_dbclk", "l4ls-clkctrl:0074:18"),
2568c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio2_dbclk", "l4ls-clkctrl:0078:18"),
2578c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio3_dbclk", "l4ls-clkctrl:007c:18"),
2588c2ecf20Sopenharmony_ci	DT_CLK(NULL, "stm_clk_div_ck", "l3-aon-clkctrl:0000:27"),
2598c2ecf20Sopenharmony_ci	DT_CLK(NULL, "stm_pmd_clock_mux_ck", "l3-aon-clkctrl:0000:22"),
2608c2ecf20Sopenharmony_ci	DT_CLK(NULL, "trace_clk_div_ck", "l3-aon-clkctrl:0000:24"),
2618c2ecf20Sopenharmony_ci	DT_CLK(NULL, "trace_pmd_clk_mux_ck", "l3-aon-clkctrl:0000:20"),
2628c2ecf20Sopenharmony_ci	{ .node_name = NULL },
2638c2ecf20Sopenharmony_ci};
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistatic const char *enable_init_clks[] = {
2668c2ecf20Sopenharmony_ci	"dpll_ddr_m2_ck",
2678c2ecf20Sopenharmony_ci	"dpll_mpu_m2_ck",
2688c2ecf20Sopenharmony_ci	"l3_gclk",
2698c2ecf20Sopenharmony_ci	"l4hs_gclk",
2708c2ecf20Sopenharmony_ci	"l4fw_gclk",
2718c2ecf20Sopenharmony_ci	"l4ls_gclk",
2728c2ecf20Sopenharmony_ci	/* Required for external peripherals like, Audio codecs */
2738c2ecf20Sopenharmony_ci	"clkout2_ck",
2748c2ecf20Sopenharmony_ci};
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ciint __init am33xx_dt_clk_init(void)
2778c2ecf20Sopenharmony_ci{
2788c2ecf20Sopenharmony_ci	struct clk *clk1, *clk2;
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	if (ti_clk_get_features()->flags & TI_CLK_CLKCTRL_COMPAT)
2818c2ecf20Sopenharmony_ci		ti_dt_clocks_register(am33xx_compat_clks);
2828c2ecf20Sopenharmony_ci	else
2838c2ecf20Sopenharmony_ci		ti_dt_clocks_register(am33xx_clks);
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	omap2_clk_disable_autoidle_all();
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	ti_clk_add_aliases();
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	omap2_clk_enable_init_clocks(enable_init_clks,
2908c2ecf20Sopenharmony_ci				     ARRAY_SIZE(enable_init_clks));
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	/* TRM ERRATA: Timer 3 & 6 default parent (TCLKIN) may not be always
2938c2ecf20Sopenharmony_ci	 *    physically present, in such a case HWMOD enabling of
2948c2ecf20Sopenharmony_ci	 *    clock would be failure with default parent. And timer
2958c2ecf20Sopenharmony_ci	 *    probe thinks clock is already enabled, this leads to
2968c2ecf20Sopenharmony_ci	 *    crash upon accessing timer 3 & 6 registers in probe.
2978c2ecf20Sopenharmony_ci	 *    Fix by setting parent of both these timers to master
2988c2ecf20Sopenharmony_ci	 *    oscillator clock.
2998c2ecf20Sopenharmony_ci	 */
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	clk1 = clk_get_sys(NULL, "sys_clkin_ck");
3028c2ecf20Sopenharmony_ci	clk2 = clk_get_sys(NULL, "timer3_fck");
3038c2ecf20Sopenharmony_ci	clk_set_parent(clk2, clk1);
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	clk2 = clk_get_sys(NULL, "timer6_fck");
3068c2ecf20Sopenharmony_ci	clk_set_parent(clk2, clk1);
3078c2ecf20Sopenharmony_ci	/*
3088c2ecf20Sopenharmony_ci	 * The On-Chip 32K RC Osc clock is not an accurate clock-source as per
3098c2ecf20Sopenharmony_ci	 * the design/spec, so as a result, for example, timer which supposed
3108c2ecf20Sopenharmony_ci	 * to get expired @60Sec, but will expire somewhere ~@40Sec, which is
3118c2ecf20Sopenharmony_ci	 * not expected by any use-case, so change WDT1 clock source to PRCM
3128c2ecf20Sopenharmony_ci	 * 32KHz clock.
3138c2ecf20Sopenharmony_ci	 */
3148c2ecf20Sopenharmony_ci	clk1 = clk_get_sys(NULL, "wdt1_fck");
3158c2ecf20Sopenharmony_ci	clk2 = clk_get_sys(NULL, "clkdiv32k_ick");
3168c2ecf20Sopenharmony_ci	clk_set_parent(clk1, clk2);
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci	return 0;
3198c2ecf20Sopenharmony_ci}
320