18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * AM43xx Clock domains framework
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2013 Texas Instruments, Inc.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/kernel.h>
98c2ecf20Sopenharmony_ci#include <linux/io.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "clockdomain.h"
128c2ecf20Sopenharmony_ci#include "prcm44xx.h"
138c2ecf20Sopenharmony_ci#include "prcm43xx.h"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistatic struct clockdomain l4_cefuse_43xx_clkdm = {
168c2ecf20Sopenharmony_ci	.name		  = "l4_cefuse_clkdm",
178c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "cefuse_pwrdm" },
188c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
198c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_CEFUSE_INST,
208c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_CEFUSE_CEFUSE_CDOFFS,
218c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic struct clockdomain mpu_43xx_clkdm = {
258c2ecf20Sopenharmony_ci	.name		  = "mpu_clkdm",
268c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "mpu_pwrdm" },
278c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
288c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_MPU_INST,
298c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_MPU_MPU_CDOFFS,
308c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_HWSUP_SWSUP,
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistatic struct clockdomain l4ls_43xx_clkdm = {
348c2ecf20Sopenharmony_ci	.name		  = "l4ls_clkdm",
358c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
368c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
378c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
388c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_L4LS_CDOFFS,
398c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistatic struct clockdomain tamper_43xx_clkdm = {
438c2ecf20Sopenharmony_ci	.name		  = "tamper_clkdm",
448c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "tamper_pwrdm" },
458c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
468c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_TAMPER_INST,
478c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_TAMPER_TAMPER_CDOFFS,
488c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistatic struct clockdomain l4_rtc_43xx_clkdm = {
528c2ecf20Sopenharmony_ci	.name		  = "l4_rtc_clkdm",
538c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "rtc_pwrdm" },
548c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
558c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_RTC_INST,
568c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_RTC_RTC_CDOFFS,
578c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistatic struct clockdomain pruss_ocp_43xx_clkdm = {
618c2ecf20Sopenharmony_ci	.name		  = "pruss_ocp_clkdm",
628c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
638c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
648c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
658c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_ICSS_CDOFFS,
668c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic struct clockdomain ocpwp_l3_43xx_clkdm = {
708c2ecf20Sopenharmony_ci	.name		  = "ocpwp_l3_clkdm",
718c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
728c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
738c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
748c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_OCPWP_L3_CDOFFS,
758c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistatic struct clockdomain l3s_tsc_43xx_clkdm = {
798c2ecf20Sopenharmony_ci	.name		  = "l3s_tsc_clkdm",
808c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "wkup_pwrdm" },
818c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
828c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_WKUP_INST,
838c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_WKUP_L3S_TSC_CDOFFS,
848c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistatic struct clockdomain lcdc_43xx_clkdm = {
888c2ecf20Sopenharmony_ci	.name		  = "lcdc_clkdm",
898c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
908c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
918c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
928c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_LCDC_CDOFFS,
938c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistatic struct clockdomain dss_43xx_clkdm = {
978c2ecf20Sopenharmony_ci	.name		  = "dss_clkdm",
988c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
998c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1008c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
1018c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_DSS_CDOFFS,
1028c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1038c2ecf20Sopenharmony_ci};
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cistatic struct clockdomain l3_aon_43xx_clkdm = {
1068c2ecf20Sopenharmony_ci	.name		  = "l3_aon_clkdm",
1078c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "wkup_pwrdm" },
1088c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1098c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_WKUP_INST,
1108c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_WKUP_L3_AON_CDOFFS,
1118c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cistatic struct clockdomain emif_43xx_clkdm = {
1158c2ecf20Sopenharmony_ci	.name		  = "emif_clkdm",
1168c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
1178c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1188c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
1198c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_EMIF_CDOFFS,
1208c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1218c2ecf20Sopenharmony_ci};
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_cistatic struct clockdomain l4_wkup_aon_43xx_clkdm = {
1248c2ecf20Sopenharmony_ci	.name		  = "l4_wkup_aon_clkdm",
1258c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "wkup_pwrdm" },
1268c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1278c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_WKUP_INST,
1288c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_WKUP_L4_WKUP_AON_CDOFFS,
1298c2ecf20Sopenharmony_ci};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cistatic struct clockdomain l3_43xx_clkdm = {
1328c2ecf20Sopenharmony_ci	.name		  = "l3_clkdm",
1338c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
1348c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1358c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
1368c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_L3_CDOFFS,
1378c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1388c2ecf20Sopenharmony_ci};
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_cistatic struct clockdomain l4_wkup_43xx_clkdm = {
1418c2ecf20Sopenharmony_ci	.name		  = "l4_wkup_clkdm",
1428c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "wkup_pwrdm" },
1438c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1448c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_WKUP_INST,
1458c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_WKUP_WKUP_CDOFFS,
1468c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1478c2ecf20Sopenharmony_ci};
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_cistatic struct clockdomain cpsw_125mhz_43xx_clkdm = {
1508c2ecf20Sopenharmony_ci	.name		  = "cpsw_125mhz_clkdm",
1518c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
1528c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1538c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
1548c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_CPSW_CDOFFS,
1558c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistatic struct clockdomain gfx_l3_43xx_clkdm = {
1598c2ecf20Sopenharmony_ci	.name		  = "gfx_l3_clkdm",
1608c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "gfx_pwrdm" },
1618c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1628c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_GFX_INST,
1638c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_GFX_GFX_L3_CDOFFS,
1648c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1658c2ecf20Sopenharmony_ci};
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_cistatic struct clockdomain l3s_43xx_clkdm = {
1688c2ecf20Sopenharmony_ci	.name		  = "l3s_clkdm",
1698c2ecf20Sopenharmony_ci	.pwrdm		  = { .name = "per_pwrdm" },
1708c2ecf20Sopenharmony_ci	.prcm_partition	  = AM43XX_CM_PARTITION,
1718c2ecf20Sopenharmony_ci	.cm_inst	  = AM43XX_CM_PER_INST,
1728c2ecf20Sopenharmony_ci	.clkdm_offs	  = AM43XX_CM_PER_L3S_CDOFFS,
1738c2ecf20Sopenharmony_ci	.flags		  = CLKDM_CAN_SWSUP,
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_cistatic struct clockdomain *clockdomains_am43xx[] __initdata = {
1778c2ecf20Sopenharmony_ci	&l4_cefuse_43xx_clkdm,
1788c2ecf20Sopenharmony_ci	&mpu_43xx_clkdm,
1798c2ecf20Sopenharmony_ci	&l4ls_43xx_clkdm,
1808c2ecf20Sopenharmony_ci	&tamper_43xx_clkdm,
1818c2ecf20Sopenharmony_ci	&l4_rtc_43xx_clkdm,
1828c2ecf20Sopenharmony_ci	&pruss_ocp_43xx_clkdm,
1838c2ecf20Sopenharmony_ci	&ocpwp_l3_43xx_clkdm,
1848c2ecf20Sopenharmony_ci	&l3s_tsc_43xx_clkdm,
1858c2ecf20Sopenharmony_ci	&lcdc_43xx_clkdm,
1868c2ecf20Sopenharmony_ci	&dss_43xx_clkdm,
1878c2ecf20Sopenharmony_ci	&l3_aon_43xx_clkdm,
1888c2ecf20Sopenharmony_ci	&emif_43xx_clkdm,
1898c2ecf20Sopenharmony_ci	&l4_wkup_aon_43xx_clkdm,
1908c2ecf20Sopenharmony_ci	&l3_43xx_clkdm,
1918c2ecf20Sopenharmony_ci	&l4_wkup_43xx_clkdm,
1928c2ecf20Sopenharmony_ci	&cpsw_125mhz_43xx_clkdm,
1938c2ecf20Sopenharmony_ci	&gfx_l3_43xx_clkdm,
1948c2ecf20Sopenharmony_ci	&l3s_43xx_clkdm,
1958c2ecf20Sopenharmony_ci	NULL
1968c2ecf20Sopenharmony_ci};
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_civoid __init am43xx_clockdomains_init(void)
1998c2ecf20Sopenharmony_ci{
2008c2ecf20Sopenharmony_ci	clkdm_register_platform_funcs(&am43xx_clkdm_operations);
2018c2ecf20Sopenharmony_ci	clkdm_register_clkdms(clockdomains_am43xx);
2028c2ecf20Sopenharmony_ci	clkdm_complete_init();
2038c2ecf20Sopenharmony_ci}
204