18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * AM43XX 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/am4.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include "clock.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_l3s_tsc_clkctrl_regs[] __initconst = {
278c2ecf20Sopenharmony_ci	{ AM4_L3S_TSC_ADC_TSC_CLKCTRL, NULL, CLKF_SW_SUP, "adc_tsc_fck" },
288c2ecf20Sopenharmony_ci	{ 0 },
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic const char * const am4_synctimer_32kclk_parents[] __initconst = {
328c2ecf20Sopenharmony_ci	"mux_synctimer32k_ck",
338c2ecf20Sopenharmony_ci	NULL,
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_counter_32k_bit_data[] __initconst = {
378c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_synctimer_32kclk_parents, NULL },
388c2ecf20Sopenharmony_ci	{ 0 },
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_l4_wkup_aon_clkctrl_regs[] __initconst = {
428c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_AON_WKUP_M3_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_NO_IDLEST, "sys_clkin_ck" },
438c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_AON_COUNTER_32K_CLKCTRL, am4_counter_32k_bit_data, CLKF_SW_SUP, "l4-wkup-aon-clkctrl:0008:8" },
448c2ecf20Sopenharmony_ci	{ 0 },
458c2ecf20Sopenharmony_ci};
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic const char * const am4_gpio0_dbclk_parents[] __initconst = {
488c2ecf20Sopenharmony_ci	"gpio0_dbclk_mux_ck",
498c2ecf20Sopenharmony_ci	NULL,
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_gpio1_bit_data[] __initconst = {
538c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_gpio0_dbclk_parents, NULL },
548c2ecf20Sopenharmony_ci	{ 0 },
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_l4_wkup_clkctrl_regs[] __initconst = {
588c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_L4_WKUP_CLKCTRL, NULL, CLKF_SW_SUP, "sys_clkin_ck" },
598c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_TIMER1_CLKCTRL, NULL, CLKF_SW_SUP, "timer1_fck" },
608c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_WD_TIMER2_CLKCTRL, NULL, CLKF_SW_SUP, "wdt1_fck" },
618c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_I2C1_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_wkupdm_ck" },
628c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_UART1_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_wkupdm_ck" },
638c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_SMARTREFLEX0_CLKCTRL, NULL, CLKF_SW_SUP, "smartreflex0_fck" },
648c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_SMARTREFLEX1_CLKCTRL, NULL, CLKF_SW_SUP, "smartreflex1_fck" },
658c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_CONTROL_CLKCTRL, NULL, CLKF_SW_SUP, "sys_clkin_ck" },
668c2ecf20Sopenharmony_ci	{ AM4_L4_WKUP_GPIO1_CLKCTRL, am4_gpio1_bit_data, CLKF_SW_SUP, "sys_clkin_ck" },
678c2ecf20Sopenharmony_ci	{ 0 },
688c2ecf20Sopenharmony_ci};
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_mpu_clkctrl_regs[] __initconst = {
718c2ecf20Sopenharmony_ci	{ AM4_MPU_MPU_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_mpu_m2_ck" },
728c2ecf20Sopenharmony_ci	{ 0 },
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_gfx_l3_clkctrl_regs[] __initconst = {
768c2ecf20Sopenharmony_ci	{ AM4_GFX_L3_GFX_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_NO_IDLEST, "gfx_fck_div_ck" },
778c2ecf20Sopenharmony_ci	{ 0 },
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_l4_rtc_clkctrl_regs[] __initconst = {
818c2ecf20Sopenharmony_ci	{ AM4_L4_RTC_RTC_CLKCTRL, NULL, CLKF_SW_SUP, "clkdiv32k_ick" },
828c2ecf20Sopenharmony_ci	{ 0 },
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_l3_clkctrl_regs[] __initconst = {
868c2ecf20Sopenharmony_ci	{ AM4_L3_L3_MAIN_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
878c2ecf20Sopenharmony_ci	{ AM4_L3_AES_CLKCTRL, NULL, CLKF_SW_SUP, "aes0_fck" },
888c2ecf20Sopenharmony_ci	{ AM4_L3_DES_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
898c2ecf20Sopenharmony_ci	{ AM4_L3_L3_INSTR_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
908c2ecf20Sopenharmony_ci	{ AM4_L3_OCMCRAM_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
918c2ecf20Sopenharmony_ci	{ AM4_L3_SHAM_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
928c2ecf20Sopenharmony_ci	{ AM4_L3_TPCC_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
938c2ecf20Sopenharmony_ci	{ AM4_L3_TPTC0_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
948c2ecf20Sopenharmony_ci	{ AM4_L3_TPTC1_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
958c2ecf20Sopenharmony_ci	{ AM4_L3_TPTC2_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
968c2ecf20Sopenharmony_ci	{ AM4_L3_L4_HS_CLKCTRL, NULL, CLKF_SW_SUP, "l4hs_gclk" },
978c2ecf20Sopenharmony_ci	{ 0 },
988c2ecf20Sopenharmony_ci};
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistatic const char * const am4_usb_otg_ss0_refclk960m_parents[] __initconst = {
1018c2ecf20Sopenharmony_ci	"dpll_per_clkdcoldo",
1028c2ecf20Sopenharmony_ci	NULL,
1038c2ecf20Sopenharmony_ci};
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_usb_otg_ss0_bit_data[] __initconst = {
1068c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_usb_otg_ss0_refclk960m_parents, NULL },
1078c2ecf20Sopenharmony_ci	{ 0 },
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_usb_otg_ss1_bit_data[] __initconst = {
1118c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_usb_otg_ss0_refclk960m_parents, NULL },
1128c2ecf20Sopenharmony_ci	{ 0 },
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_l3s_clkctrl_regs[] __initconst = {
1168c2ecf20Sopenharmony_ci	{ AM4_L3S_VPFE0_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
1178c2ecf20Sopenharmony_ci	{ AM4_L3S_VPFE1_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
1188c2ecf20Sopenharmony_ci	{ AM4_L3S_GPMC_CLKCTRL, NULL, CLKF_SW_SUP, "l3s_gclk" },
1198c2ecf20Sopenharmony_ci	{ AM4_L3S_MCASP0_CLKCTRL, NULL, CLKF_SW_SUP, "mcasp0_fck" },
1208c2ecf20Sopenharmony_ci	{ AM4_L3S_MCASP1_CLKCTRL, NULL, CLKF_SW_SUP, "mcasp1_fck" },
1218c2ecf20Sopenharmony_ci	{ AM4_L3S_MMC3_CLKCTRL, NULL, CLKF_SW_SUP, "mmc_clk" },
1228c2ecf20Sopenharmony_ci	{ AM4_L3S_QSPI_CLKCTRL, NULL, CLKF_SW_SUP, "l3s_gclk" },
1238c2ecf20Sopenharmony_ci	{ AM4_L3S_USB_OTG_SS0_CLKCTRL, am4_usb_otg_ss0_bit_data, CLKF_SW_SUP, "l3s_gclk" },
1248c2ecf20Sopenharmony_ci	{ AM4_L3S_USB_OTG_SS1_CLKCTRL, am4_usb_otg_ss1_bit_data, CLKF_SW_SUP, "l3s_gclk" },
1258c2ecf20Sopenharmony_ci	{ 0 },
1268c2ecf20Sopenharmony_ci};
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_pruss_ocp_clkctrl_regs[] __initconst = {
1298c2ecf20Sopenharmony_ci	{ AM4_PRUSS_OCP_PRUSS_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_NO_IDLEST, "pruss_ocp_gclk" },
1308c2ecf20Sopenharmony_ci	{ 0 },
1318c2ecf20Sopenharmony_ci};
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistatic const char * const am4_gpio1_dbclk_parents[] __initconst = {
1348c2ecf20Sopenharmony_ci	"clkdiv32k_ick",
1358c2ecf20Sopenharmony_ci	NULL,
1368c2ecf20Sopenharmony_ci};
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_gpio2_bit_data[] __initconst = {
1398c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_gpio1_dbclk_parents, NULL },
1408c2ecf20Sopenharmony_ci	{ 0 },
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_gpio3_bit_data[] __initconst = {
1448c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_gpio1_dbclk_parents, NULL },
1458c2ecf20Sopenharmony_ci	{ 0 },
1468c2ecf20Sopenharmony_ci};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_gpio4_bit_data[] __initconst = {
1498c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_gpio1_dbclk_parents, NULL },
1508c2ecf20Sopenharmony_ci	{ 0 },
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_gpio5_bit_data[] __initconst = {
1548c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_gpio1_dbclk_parents, NULL },
1558c2ecf20Sopenharmony_ci	{ 0 },
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_bit_data am4_gpio6_bit_data[] __initconst = {
1598c2ecf20Sopenharmony_ci	{ 8, TI_CLK_GATE, am4_gpio1_dbclk_parents, NULL },
1608c2ecf20Sopenharmony_ci	{ 0 },
1618c2ecf20Sopenharmony_ci};
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_l4ls_clkctrl_regs[] __initconst = {
1648c2ecf20Sopenharmony_ci	{ AM4_L4LS_L4_LS_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1658c2ecf20Sopenharmony_ci	{ AM4_L4LS_D_CAN0_CLKCTRL, NULL, CLKF_SW_SUP, "dcan0_fck" },
1668c2ecf20Sopenharmony_ci	{ AM4_L4LS_D_CAN1_CLKCTRL, NULL, CLKF_SW_SUP, "dcan1_fck" },
1678c2ecf20Sopenharmony_ci	{ AM4_L4LS_EPWMSS0_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1688c2ecf20Sopenharmony_ci	{ AM4_L4LS_EPWMSS1_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1698c2ecf20Sopenharmony_ci	{ AM4_L4LS_EPWMSS2_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1708c2ecf20Sopenharmony_ci	{ AM4_L4LS_EPWMSS3_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1718c2ecf20Sopenharmony_ci	{ AM4_L4LS_EPWMSS4_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1728c2ecf20Sopenharmony_ci	{ AM4_L4LS_EPWMSS5_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1738c2ecf20Sopenharmony_ci	{ AM4_L4LS_ELM_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1748c2ecf20Sopenharmony_ci	{ AM4_L4LS_GPIO2_CLKCTRL, am4_gpio2_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
1758c2ecf20Sopenharmony_ci	{ AM4_L4LS_GPIO3_CLKCTRL, am4_gpio3_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
1768c2ecf20Sopenharmony_ci	{ AM4_L4LS_GPIO4_CLKCTRL, am4_gpio4_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
1778c2ecf20Sopenharmony_ci	{ AM4_L4LS_GPIO5_CLKCTRL, am4_gpio5_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
1788c2ecf20Sopenharmony_ci	{ AM4_L4LS_GPIO6_CLKCTRL, am4_gpio6_bit_data, CLKF_SW_SUP, "l4ls_gclk" },
1798c2ecf20Sopenharmony_ci	{ AM4_L4LS_HDQ1W_CLKCTRL, NULL, CLKF_SW_SUP, "func_12m_clk" },
1808c2ecf20Sopenharmony_ci	{ AM4_L4LS_I2C2_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
1818c2ecf20Sopenharmony_ci	{ AM4_L4LS_I2C3_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
1828c2ecf20Sopenharmony_ci	{ AM4_L4LS_MAILBOX_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1838c2ecf20Sopenharmony_ci	{ AM4_L4LS_MMC1_CLKCTRL, NULL, CLKF_SW_SUP, "mmc_clk" },
1848c2ecf20Sopenharmony_ci	{ AM4_L4LS_MMC2_CLKCTRL, NULL, CLKF_SW_SUP, "mmc_clk" },
1858c2ecf20Sopenharmony_ci	{ AM4_L4LS_RNG_CLKCTRL, NULL, CLKF_SW_SUP, "rng_fck" },
1868c2ecf20Sopenharmony_ci	{ AM4_L4LS_SPI0_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
1878c2ecf20Sopenharmony_ci	{ AM4_L4LS_SPI1_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
1888c2ecf20Sopenharmony_ci	{ AM4_L4LS_SPI2_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
1898c2ecf20Sopenharmony_ci	{ AM4_L4LS_SPI3_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
1908c2ecf20Sopenharmony_ci	{ AM4_L4LS_SPI4_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
1918c2ecf20Sopenharmony_ci	{ AM4_L4LS_SPINLOCK_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
1928c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER2_CLKCTRL, NULL, CLKF_SW_SUP, "timer2_fck" },
1938c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER3_CLKCTRL, NULL, CLKF_SW_SUP, "timer3_fck" },
1948c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER4_CLKCTRL, NULL, CLKF_SW_SUP, "timer4_fck" },
1958c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER5_CLKCTRL, NULL, CLKF_SW_SUP, "timer5_fck" },
1968c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER6_CLKCTRL, NULL, CLKF_SW_SUP, "timer6_fck" },
1978c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER7_CLKCTRL, NULL, CLKF_SW_SUP, "timer7_fck" },
1988c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER8_CLKCTRL, NULL, CLKF_SW_SUP, "timer8_fck" },
1998c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER9_CLKCTRL, NULL, CLKF_SW_SUP, "timer9_fck" },
2008c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER10_CLKCTRL, NULL, CLKF_SW_SUP, "timer10_fck" },
2018c2ecf20Sopenharmony_ci	{ AM4_L4LS_TIMER11_CLKCTRL, NULL, CLKF_SW_SUP, "timer11_fck" },
2028c2ecf20Sopenharmony_ci	{ AM4_L4LS_UART2_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
2038c2ecf20Sopenharmony_ci	{ AM4_L4LS_UART3_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
2048c2ecf20Sopenharmony_ci	{ AM4_L4LS_UART4_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
2058c2ecf20Sopenharmony_ci	{ AM4_L4LS_UART5_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
2068c2ecf20Sopenharmony_ci	{ AM4_L4LS_UART6_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_per_m2_div4_ck" },
2078c2ecf20Sopenharmony_ci	{ AM4_L4LS_OCP2SCP0_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
2088c2ecf20Sopenharmony_ci	{ AM4_L4LS_OCP2SCP1_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" },
2098c2ecf20Sopenharmony_ci	{ 0 },
2108c2ecf20Sopenharmony_ci};
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_emif_clkctrl_regs[] __initconst = {
2138c2ecf20Sopenharmony_ci	{ AM4_EMIF_EMIF_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_ddr_m2_ck" },
2148c2ecf20Sopenharmony_ci	{ 0 },
2158c2ecf20Sopenharmony_ci};
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_dss_clkctrl_regs[] __initconst = {
2188c2ecf20Sopenharmony_ci	{ AM4_DSS_DSS_CORE_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_SET_RATE_PARENT, "disp_clk" },
2198c2ecf20Sopenharmony_ci	{ 0 },
2208c2ecf20Sopenharmony_ci};
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_cistatic const struct omap_clkctrl_reg_data am4_cpsw_125mhz_clkctrl_regs[] __initconst = {
2238c2ecf20Sopenharmony_ci	{ AM4_CPSW_125MHZ_CPGMAC0_CLKCTRL, NULL, CLKF_SW_SUP, "cpsw_125mhz_gclk" },
2248c2ecf20Sopenharmony_ci	{ 0 },
2258c2ecf20Sopenharmony_ci};
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ciconst struct omap_clkctrl_data am4_clkctrl_data[] __initconst = {
2288c2ecf20Sopenharmony_ci	{ 0x44df2920, am4_l3s_tsc_clkctrl_regs },
2298c2ecf20Sopenharmony_ci	{ 0x44df2a28, am4_l4_wkup_aon_clkctrl_regs },
2308c2ecf20Sopenharmony_ci	{ 0x44df2a20, am4_l4_wkup_clkctrl_regs },
2318c2ecf20Sopenharmony_ci	{ 0x44df8320, am4_mpu_clkctrl_regs },
2328c2ecf20Sopenharmony_ci	{ 0x44df8420, am4_gfx_l3_clkctrl_regs },
2338c2ecf20Sopenharmony_ci	{ 0x44df8520, am4_l4_rtc_clkctrl_regs },
2348c2ecf20Sopenharmony_ci	{ 0x44df8820, am4_l3_clkctrl_regs },
2358c2ecf20Sopenharmony_ci	{ 0x44df8868, am4_l3s_clkctrl_regs },
2368c2ecf20Sopenharmony_ci	{ 0x44df8b20, am4_pruss_ocp_clkctrl_regs },
2378c2ecf20Sopenharmony_ci	{ 0x44df8c20, am4_l4ls_clkctrl_regs },
2388c2ecf20Sopenharmony_ci	{ 0x44df8f20, am4_emif_clkctrl_regs },
2398c2ecf20Sopenharmony_ci	{ 0x44df9220, am4_dss_clkctrl_regs },
2408c2ecf20Sopenharmony_ci	{ 0x44df9320, am4_cpsw_125mhz_clkctrl_regs },
2418c2ecf20Sopenharmony_ci	{ 0 },
2428c2ecf20Sopenharmony_ci};
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ciconst struct omap_clkctrl_data am438x_clkctrl_data[] __initconst = {
2458c2ecf20Sopenharmony_ci	{ 0x44df2920, am4_l3s_tsc_clkctrl_regs },
2468c2ecf20Sopenharmony_ci	{ 0x44df2a28, am4_l4_wkup_aon_clkctrl_regs },
2478c2ecf20Sopenharmony_ci	{ 0x44df2a20, am4_l4_wkup_clkctrl_regs },
2488c2ecf20Sopenharmony_ci	{ 0x44df8320, am4_mpu_clkctrl_regs },
2498c2ecf20Sopenharmony_ci	{ 0x44df8420, am4_gfx_l3_clkctrl_regs },
2508c2ecf20Sopenharmony_ci	{ 0x44df8820, am4_l3_clkctrl_regs },
2518c2ecf20Sopenharmony_ci	{ 0x44df8868, am4_l3s_clkctrl_regs },
2528c2ecf20Sopenharmony_ci	{ 0x44df8b20, am4_pruss_ocp_clkctrl_regs },
2538c2ecf20Sopenharmony_ci	{ 0x44df8c20, am4_l4ls_clkctrl_regs },
2548c2ecf20Sopenharmony_ci	{ 0x44df8f20, am4_emif_clkctrl_regs },
2558c2ecf20Sopenharmony_ci	{ 0x44df9220, am4_dss_clkctrl_regs },
2568c2ecf20Sopenharmony_ci	{ 0x44df9320, am4_cpsw_125mhz_clkctrl_regs },
2578c2ecf20Sopenharmony_ci	{ 0 },
2588c2ecf20Sopenharmony_ci};
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_cistatic struct ti_dt_clk am43xx_clks[] = {
2618c2ecf20Sopenharmony_ci	DT_CLK(NULL, "timer_32k_ck", "clkdiv32k_ick"),
2628c2ecf20Sopenharmony_ci	DT_CLK(NULL, "timer_sys_ck", "sys_clkin_ck"),
2638c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio0_dbclk", "l4-wkup-clkctrl:0148:8"),
2648c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio1_dbclk", "l4ls-clkctrl:0058:8"),
2658c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio2_dbclk", "l4ls-clkctrl:0060:8"),
2668c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio3_dbclk", "l4ls-clkctrl:0068:8"),
2678c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio4_dbclk", "l4ls-clkctrl:0070:8"),
2688c2ecf20Sopenharmony_ci	DT_CLK(NULL, "gpio5_dbclk", "l4ls-clkctrl:0078:8"),
2698c2ecf20Sopenharmony_ci	DT_CLK(NULL, "synctimer_32kclk", "l4-wkup-aon-clkctrl:0008:8"),
2708c2ecf20Sopenharmony_ci	DT_CLK(NULL, "usb_otg_ss0_refclk960m", "l3s-clkctrl:01f8:8"),
2718c2ecf20Sopenharmony_ci	DT_CLK(NULL, "usb_otg_ss1_refclk960m", "l3s-clkctrl:0200:8"),
2728c2ecf20Sopenharmony_ci	{ .node_name = NULL },
2738c2ecf20Sopenharmony_ci};
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ciint __init am43xx_dt_clk_init(void)
2768c2ecf20Sopenharmony_ci{
2778c2ecf20Sopenharmony_ci	struct clk *clk1, *clk2;
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	if (ti_clk_get_features()->flags & TI_CLK_CLKCTRL_COMPAT)
2808c2ecf20Sopenharmony_ci		ti_dt_clocks_register(am43xx_compat_clks);
2818c2ecf20Sopenharmony_ci	else
2828c2ecf20Sopenharmony_ci		ti_dt_clocks_register(am43xx_clks);
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	omap2_clk_disable_autoidle_all();
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	ti_clk_add_aliases();
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	/*
2898c2ecf20Sopenharmony_ci	 * cpsw_cpts_rft_clk  has got the choice of 3 clocksources
2908c2ecf20Sopenharmony_ci	 * dpll_core_m4_ck, dpll_core_m5_ck and dpll_disp_m2_ck.
2918c2ecf20Sopenharmony_ci	 * By default dpll_core_m4_ck is selected, witn this as clock
2928c2ecf20Sopenharmony_ci	 * source the CPTS doesnot work properly. It gives clockcheck errors
2938c2ecf20Sopenharmony_ci	 * while running PTP.
2948c2ecf20Sopenharmony_ci	 * clockcheck: clock jumped backward or running slower than expected!
2958c2ecf20Sopenharmony_ci	 * By selecting dpll_core_m5_ck as the clocksource fixes this issue.
2968c2ecf20Sopenharmony_ci	 * In AM335x dpll_core_m5_ck is the default clocksource.
2978c2ecf20Sopenharmony_ci	 */
2988c2ecf20Sopenharmony_ci	clk1 = clk_get_sys(NULL, "cpsw_cpts_rft_clk");
2998c2ecf20Sopenharmony_ci	clk2 = clk_get_sys(NULL, "dpll_core_m5_ck");
3008c2ecf20Sopenharmony_ci	clk_set_parent(clk1, clk2);
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	return 0;
3038c2ecf20Sopenharmony_ci}
304