18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2011 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci#include <linux/mm.h> 68c2ecf20Sopenharmony_ci#include <linux/delay.h> 78c2ecf20Sopenharmony_ci#include <linux/clk.h> 88c2ecf20Sopenharmony_ci#include <linux/io.h> 98c2ecf20Sopenharmony_ci#include <linux/clkdev.h> 108c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 118c2ecf20Sopenharmony_ci#include <linux/err.h> 128c2ecf20Sopenharmony_ci#include <linux/of.h> 138c2ecf20Sopenharmony_ci#include <linux/of_address.h> 148c2ecf20Sopenharmony_ci#include <linux/of_irq.h> 158c2ecf20Sopenharmony_ci#include <linux/sizes.h> 168c2ecf20Sopenharmony_ci#include <soc/imx/revision.h> 178c2ecf20Sopenharmony_ci#include <dt-bindings/clock/imx5-clock.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include "clk.h" 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define MX51_DPLL1_BASE 0x83f80000 228c2ecf20Sopenharmony_ci#define MX51_DPLL2_BASE 0x83f84000 238c2ecf20Sopenharmony_ci#define MX51_DPLL3_BASE 0x83f88000 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define MX53_DPLL1_BASE 0x63f80000 268c2ecf20Sopenharmony_ci#define MX53_DPLL2_BASE 0x63f84000 278c2ecf20Sopenharmony_ci#define MX53_DPLL3_BASE 0x63f88000 288c2ecf20Sopenharmony_ci#define MX53_DPLL4_BASE 0x63f8c000 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define MXC_CCM_CCR (ccm_base + 0x00) 318c2ecf20Sopenharmony_ci#define MXC_CCM_CCDR (ccm_base + 0x04) 328c2ecf20Sopenharmony_ci#define MXC_CCM_CSR (ccm_base + 0x08) 338c2ecf20Sopenharmony_ci#define MXC_CCM_CCSR (ccm_base + 0x0c) 348c2ecf20Sopenharmony_ci#define MXC_CCM_CACRR (ccm_base + 0x10) 358c2ecf20Sopenharmony_ci#define MXC_CCM_CBCDR (ccm_base + 0x14) 368c2ecf20Sopenharmony_ci#define MXC_CCM_CBCMR (ccm_base + 0x18) 378c2ecf20Sopenharmony_ci#define MXC_CCM_CSCMR1 (ccm_base + 0x1c) 388c2ecf20Sopenharmony_ci#define MXC_CCM_CSCMR2 (ccm_base + 0x20) 398c2ecf20Sopenharmony_ci#define MXC_CCM_CSCDR1 (ccm_base + 0x24) 408c2ecf20Sopenharmony_ci#define MXC_CCM_CS1CDR (ccm_base + 0x28) 418c2ecf20Sopenharmony_ci#define MXC_CCM_CS2CDR (ccm_base + 0x2c) 428c2ecf20Sopenharmony_ci#define MXC_CCM_CDCDR (ccm_base + 0x30) 438c2ecf20Sopenharmony_ci#define MXC_CCM_CHSCDR (ccm_base + 0x34) 448c2ecf20Sopenharmony_ci#define MXC_CCM_CSCDR2 (ccm_base + 0x38) 458c2ecf20Sopenharmony_ci#define MXC_CCM_CSCDR3 (ccm_base + 0x3c) 468c2ecf20Sopenharmony_ci#define MXC_CCM_CSCDR4 (ccm_base + 0x40) 478c2ecf20Sopenharmony_ci#define MXC_CCM_CWDR (ccm_base + 0x44) 488c2ecf20Sopenharmony_ci#define MXC_CCM_CDHIPR (ccm_base + 0x48) 498c2ecf20Sopenharmony_ci#define MXC_CCM_CDCR (ccm_base + 0x4c) 508c2ecf20Sopenharmony_ci#define MXC_CCM_CTOR (ccm_base + 0x50) 518c2ecf20Sopenharmony_ci#define MXC_CCM_CLPCR (ccm_base + 0x54) 528c2ecf20Sopenharmony_ci#define MXC_CCM_CISR (ccm_base + 0x58) 538c2ecf20Sopenharmony_ci#define MXC_CCM_CIMR (ccm_base + 0x5c) 548c2ecf20Sopenharmony_ci#define MXC_CCM_CCOSR (ccm_base + 0x60) 558c2ecf20Sopenharmony_ci#define MXC_CCM_CGPR (ccm_base + 0x64) 568c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR0 (ccm_base + 0x68) 578c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR1 (ccm_base + 0x6c) 588c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR2 (ccm_base + 0x70) 598c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR3 (ccm_base + 0x74) 608c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR4 (ccm_base + 0x78) 618c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR5 (ccm_base + 0x7c) 628c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR6 (ccm_base + 0x80) 638c2ecf20Sopenharmony_ci#define MXC_CCM_CCGR7 (ccm_base + 0x84) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Low-power Audio Playback Mode clock */ 668c2ecf20Sopenharmony_cistatic const char *lp_apm_sel[] = { "osc", }; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* This is used multiple times */ 698c2ecf20Sopenharmony_cistatic const char *standard_pll_sel[] = { "pll1_sw", "pll2_sw", "pll3_sw", "lp_apm", }; 708c2ecf20Sopenharmony_cistatic const char *periph_apm_sel[] = { "pll1_sw", "pll3_sw", "lp_apm", }; 718c2ecf20Sopenharmony_cistatic const char *main_bus_sel[] = { "pll2_sw", "periph_apm", }; 728c2ecf20Sopenharmony_cistatic const char *per_lp_apm_sel[] = { "main_bus", "lp_apm", }; 738c2ecf20Sopenharmony_cistatic const char *per_root_sel[] = { "per_podf", "ipg", }; 748c2ecf20Sopenharmony_cistatic const char *esdhc_c_sel[] = { "esdhc_a_podf", "esdhc_b_podf", }; 758c2ecf20Sopenharmony_cistatic const char *esdhc_d_sel[] = { "esdhc_a_podf", "esdhc_b_podf", }; 768c2ecf20Sopenharmony_cistatic const char *ssi_apm_sels[] = { "ckih1", "lp_amp", "ckih2", }; 778c2ecf20Sopenharmony_cistatic const char *ssi_clk_sels[] = { "pll1_sw", "pll2_sw", "pll3_sw", "ssi_apm", }; 788c2ecf20Sopenharmony_cistatic const char *ssi3_clk_sels[] = { "ssi1_root_gate", "ssi2_root_gate", }; 798c2ecf20Sopenharmony_cistatic const char *ssi_ext1_com_sels[] = { "ssi_ext1_podf", "ssi1_root_gate", }; 808c2ecf20Sopenharmony_cistatic const char *ssi_ext2_com_sels[] = { "ssi_ext2_podf", "ssi2_root_gate", }; 818c2ecf20Sopenharmony_cistatic const char *emi_slow_sel[] = { "main_bus", "ahb", }; 828c2ecf20Sopenharmony_cistatic const char *usb_phy_sel_str[] = { "osc", "usb_phy_podf", }; 838c2ecf20Sopenharmony_cistatic const char *mx51_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "tve_di", }; 848c2ecf20Sopenharmony_cistatic const char *mx53_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "di_pll4_podf", "dummy", "ldb_di0_gate", }; 858c2ecf20Sopenharmony_cistatic const char *mx53_ldb_di0_sel[] = { "pll3_sw", "pll4_sw", }; 868c2ecf20Sopenharmony_cistatic const char *mx51_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", }; 878c2ecf20Sopenharmony_cistatic const char *mx53_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", "ldb_di1_gate", }; 888c2ecf20Sopenharmony_cistatic const char *mx53_ldb_di1_sel[] = { "pll3_sw", "pll4_sw", }; 898c2ecf20Sopenharmony_cistatic const char *mx51_tve_ext_sel[] = { "osc", "ckih1", }; 908c2ecf20Sopenharmony_cistatic const char *mx53_tve_ext_sel[] = { "pll4_sw", "ckih1", }; 918c2ecf20Sopenharmony_cistatic const char *mx51_tve_sel[] = { "tve_pred", "tve_ext_sel", }; 928c2ecf20Sopenharmony_cistatic const char *ipu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", }; 938c2ecf20Sopenharmony_cistatic const char *gpu3d_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb" }; 948c2ecf20Sopenharmony_cistatic const char *gpu2d_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb" }; 958c2ecf20Sopenharmony_cistatic const char *vpu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", }; 968c2ecf20Sopenharmony_cistatic const char *mx53_can_sel[] = { "ipg", "ckih1", "ckih2", "lp_apm", }; 978c2ecf20Sopenharmony_cistatic const char *mx53_cko1_sel[] = { 988c2ecf20Sopenharmony_ci "cpu_podf", "pll1_sw", "pll2_sw", "pll3_sw", 998c2ecf20Sopenharmony_ci "emi_slow_podf", "pll4_sw", "nfc_podf", "dummy", 1008c2ecf20Sopenharmony_ci "di_pred", "dummy", "dummy", "ahb", 1018c2ecf20Sopenharmony_ci "ipg", "per_root", "ckil", "dummy",}; 1028c2ecf20Sopenharmony_cistatic const char *mx53_cko2_sel[] = { 1038c2ecf20Sopenharmony_ci "dummy"/* dptc_core */, "dummy"/* dptc_perich */, 1048c2ecf20Sopenharmony_ci "dummy", "esdhc_a_podf", 1058c2ecf20Sopenharmony_ci "usboh3_podf", "dummy"/* wrck_clk_root */, 1068c2ecf20Sopenharmony_ci "ecspi_podf", "dummy"/* pll1_ref_clk */, 1078c2ecf20Sopenharmony_ci "esdhc_b_podf", "dummy"/* ddr_clk_root */, 1088c2ecf20Sopenharmony_ci "dummy"/* arm_axi_clk_root */, "dummy"/* usb_phy_out */, 1098c2ecf20Sopenharmony_ci "vpu_sel", "ipu_sel", 1108c2ecf20Sopenharmony_ci "osc", "ckih1", 1118c2ecf20Sopenharmony_ci "dummy", "esdhc_c_sel", 1128c2ecf20Sopenharmony_ci "ssi1_root_podf", "ssi2_root_podf", 1138c2ecf20Sopenharmony_ci "dummy", "dummy", 1148c2ecf20Sopenharmony_ci "dummy"/* lpsr_clk_root */, "dummy"/* pgc_clk_root */, 1158c2ecf20Sopenharmony_ci "dummy"/* tve_out */, "usb_phy_sel", 1168c2ecf20Sopenharmony_ci "tve_sel", "lp_apm", 1178c2ecf20Sopenharmony_ci "uart_root", "dummy"/* spdif0_clk_root */, 1188c2ecf20Sopenharmony_ci "dummy", "dummy", }; 1198c2ecf20Sopenharmony_cistatic const char *mx51_spdif_xtal_sel[] = { "osc", "ckih", "ckih2", }; 1208c2ecf20Sopenharmony_cistatic const char *mx53_spdif_xtal_sel[] = { "osc", "ckih", "ckih2", "pll4_sw", }; 1218c2ecf20Sopenharmony_cistatic const char *spdif_sel[] = { "pll1_sw", "pll2_sw", "pll3_sw", "spdif_xtal_sel", }; 1228c2ecf20Sopenharmony_cistatic const char *spdif0_com_sel[] = { "spdif0_podf", "ssi1_root_gate", }; 1238c2ecf20Sopenharmony_cistatic const char *mx51_spdif1_com_sel[] = { "spdif1_podf", "ssi2_root_gate", }; 1248c2ecf20Sopenharmony_cistatic const char *step_sels[] = { "lp_apm", }; 1258c2ecf20Sopenharmony_cistatic const char *cpu_podf_sels[] = { "pll1_sw", "step_sel" }; 1268c2ecf20Sopenharmony_cistatic const char *ieee1588_sels[] = { "pll3_sw", "pll4_sw", "dummy" /* usbphy2_clk */, "dummy" /* fec_phy_clk */ }; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cistatic struct clk *clk[IMX5_CLK_END]; 1298c2ecf20Sopenharmony_cistatic struct clk_onecell_data clk_data; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistatic void __init mx5_clocks_common_init(void __iomem *ccm_base) 1328c2ecf20Sopenharmony_ci{ 1338c2ecf20Sopenharmony_ci clk[IMX5_CLK_DUMMY] = imx_clk_fixed("dummy", 0); 1348c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKIL] = imx_obtain_fixed_clock("ckil", 0); 1358c2ecf20Sopenharmony_ci clk[IMX5_CLK_OSC] = imx_obtain_fixed_clock("osc", 0); 1368c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKIH1] = imx_obtain_fixed_clock("ckih1", 0); 1378c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKIH2] = imx_obtain_fixed_clock("ckih2", 0); 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci clk[IMX5_CLK_PER_LP_APM] = imx_clk_mux("per_lp_apm", MXC_CCM_CBCMR, 1, 1, 1408c2ecf20Sopenharmony_ci per_lp_apm_sel, ARRAY_SIZE(per_lp_apm_sel)); 1418c2ecf20Sopenharmony_ci clk[IMX5_CLK_PER_PRED1] = imx_clk_divider("per_pred1", "per_lp_apm", MXC_CCM_CBCDR, 6, 2); 1428c2ecf20Sopenharmony_ci clk[IMX5_CLK_PER_PRED2] = imx_clk_divider("per_pred2", "per_pred1", MXC_CCM_CBCDR, 3, 3); 1438c2ecf20Sopenharmony_ci clk[IMX5_CLK_PER_PODF] = imx_clk_divider("per_podf", "per_pred2", MXC_CCM_CBCDR, 0, 3); 1448c2ecf20Sopenharmony_ci clk[IMX5_CLK_PER_ROOT] = imx_clk_mux("per_root", MXC_CCM_CBCMR, 0, 1, 1458c2ecf20Sopenharmony_ci per_root_sel, ARRAY_SIZE(per_root_sel)); 1468c2ecf20Sopenharmony_ci clk[IMX5_CLK_AHB] = imx_clk_divider("ahb", "main_bus", MXC_CCM_CBCDR, 10, 3); 1478c2ecf20Sopenharmony_ci clk[IMX5_CLK_AHB_MAX] = imx_clk_gate2_flags("ahb_max", "ahb", MXC_CCM_CCGR0, 28, CLK_IS_CRITICAL); 1488c2ecf20Sopenharmony_ci clk[IMX5_CLK_AIPS_TZ1] = imx_clk_gate2_flags("aips_tz1", "ahb", MXC_CCM_CCGR0, 24, CLK_IS_CRITICAL); 1498c2ecf20Sopenharmony_ci clk[IMX5_CLK_AIPS_TZ2] = imx_clk_gate2_flags("aips_tz2", "ahb", MXC_CCM_CCGR0, 26, CLK_IS_CRITICAL); 1508c2ecf20Sopenharmony_ci clk[IMX5_CLK_TMAX1] = imx_clk_gate2_flags("tmax1", "ahb", MXC_CCM_CCGR1, 0, CLK_IS_CRITICAL); 1518c2ecf20Sopenharmony_ci clk[IMX5_CLK_TMAX2] = imx_clk_gate2_flags("tmax2", "ahb", MXC_CCM_CCGR1, 2, CLK_IS_CRITICAL); 1528c2ecf20Sopenharmony_ci clk[IMX5_CLK_TMAX3] = imx_clk_gate2_flags("tmax3", "ahb", MXC_CCM_CCGR1, 4, CLK_IS_CRITICAL); 1538c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPBA] = imx_clk_gate2_flags("spba", "ipg", MXC_CCM_CCGR5, 0, CLK_IS_CRITICAL); 1548c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPG] = imx_clk_divider("ipg", "ahb", MXC_CCM_CBCDR, 8, 2); 1558c2ecf20Sopenharmony_ci clk[IMX5_CLK_AXI_A] = imx_clk_divider("axi_a", "main_bus", MXC_CCM_CBCDR, 16, 3); 1568c2ecf20Sopenharmony_ci clk[IMX5_CLK_AXI_B] = imx_clk_divider("axi_b", "main_bus", MXC_CCM_CBCDR, 19, 3); 1578c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART_SEL] = imx_clk_mux("uart_sel", MXC_CCM_CSCMR1, 24, 2, 1588c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 1598c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART_PRED] = imx_clk_divider("uart_pred", "uart_sel", MXC_CCM_CSCDR1, 3, 3); 1608c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART_ROOT] = imx_clk_divider("uart_root", "uart_pred", MXC_CCM_CSCDR1, 0, 3); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_A_PRED] = imx_clk_divider("esdhc_a_pred", "esdhc_a_sel", MXC_CCM_CSCDR1, 16, 3); 1638c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_A_PODF] = imx_clk_divider("esdhc_a_podf", "esdhc_a_pred", MXC_CCM_CSCDR1, 11, 3); 1648c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_B_PRED] = imx_clk_divider("esdhc_b_pred", "esdhc_b_sel", MXC_CCM_CSCDR1, 22, 3); 1658c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_B_PODF] = imx_clk_divider("esdhc_b_podf", "esdhc_b_pred", MXC_CCM_CSCDR1, 19, 3); 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci clk[IMX5_CLK_EMI_SEL] = imx_clk_mux("emi_sel", MXC_CCM_CBCDR, 26, 1, 1688c2ecf20Sopenharmony_ci emi_slow_sel, ARRAY_SIZE(emi_slow_sel)); 1698c2ecf20Sopenharmony_ci clk[IMX5_CLK_EMI_SLOW_PODF] = imx_clk_divider("emi_slow_podf", "emi_sel", MXC_CCM_CBCDR, 22, 3); 1708c2ecf20Sopenharmony_ci clk[IMX5_CLK_NFC_PODF] = imx_clk_divider("nfc_podf", "emi_slow_podf", MXC_CCM_CBCDR, 13, 3); 1718c2ecf20Sopenharmony_ci clk[IMX5_CLK_ECSPI_SEL] = imx_clk_mux("ecspi_sel", MXC_CCM_CSCMR1, 4, 2, 1728c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 1738c2ecf20Sopenharmony_ci clk[IMX5_CLK_ECSPI_PRED] = imx_clk_divider("ecspi_pred", "ecspi_sel", MXC_CCM_CSCDR2, 25, 3); 1748c2ecf20Sopenharmony_ci clk[IMX5_CLK_ECSPI_PODF] = imx_clk_divider("ecspi_podf", "ecspi_pred", MXC_CCM_CSCDR2, 19, 6); 1758c2ecf20Sopenharmony_ci clk[IMX5_CLK_USBOH3_SEL] = imx_clk_mux("usboh3_sel", MXC_CCM_CSCMR1, 22, 2, 1768c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 1778c2ecf20Sopenharmony_ci clk[IMX5_CLK_USBOH3_PRED] = imx_clk_divider("usboh3_pred", "usboh3_sel", MXC_CCM_CSCDR1, 8, 3); 1788c2ecf20Sopenharmony_ci clk[IMX5_CLK_USBOH3_PODF] = imx_clk_divider("usboh3_podf", "usboh3_pred", MXC_CCM_CSCDR1, 6, 2); 1798c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY_PRED] = imx_clk_divider("usb_phy_pred", "pll3_sw", MXC_CCM_CDCDR, 3, 3); 1808c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY_PODF] = imx_clk_divider("usb_phy_podf", "usb_phy_pred", MXC_CCM_CDCDR, 0, 3); 1818c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY_SEL] = imx_clk_mux("usb_phy_sel", MXC_CCM_CSCMR1, 26, 1, 1828c2ecf20Sopenharmony_ci usb_phy_sel_str, ARRAY_SIZE(usb_phy_sel_str)); 1838c2ecf20Sopenharmony_ci clk[IMX5_CLK_STEP_SEL] = imx_clk_mux("step_sel", MXC_CCM_CCSR, 7, 2, step_sels, ARRAY_SIZE(step_sels)); 1848c2ecf20Sopenharmony_ci clk[IMX5_CLK_CPU_PODF_SEL] = imx_clk_mux("cpu_podf_sel", MXC_CCM_CCSR, 2, 1, cpu_podf_sels, ARRAY_SIZE(cpu_podf_sels)); 1858c2ecf20Sopenharmony_ci clk[IMX5_CLK_CPU_PODF] = imx_clk_divider("cpu_podf", "cpu_podf_sel", MXC_CCM_CACRR, 0, 3); 1868c2ecf20Sopenharmony_ci clk[IMX5_CLK_DI_PRED] = imx_clk_divider("di_pred", "pll3_sw", MXC_CCM_CDCDR, 6, 3); 1878c2ecf20Sopenharmony_ci clk[IMX5_CLK_IIM_GATE] = imx_clk_gate2("iim_gate", "ipg", MXC_CCM_CCGR0, 30); 1888c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART1_IPG_GATE] = imx_clk_gate2("uart1_ipg_gate", "ipg", MXC_CCM_CCGR1, 6); 1898c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART1_PER_GATE] = imx_clk_gate2("uart1_per_gate", "uart_root", MXC_CCM_CCGR1, 8); 1908c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART2_IPG_GATE] = imx_clk_gate2("uart2_ipg_gate", "ipg", MXC_CCM_CCGR1, 10); 1918c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART2_PER_GATE] = imx_clk_gate2("uart2_per_gate", "uart_root", MXC_CCM_CCGR1, 12); 1928c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART3_IPG_GATE] = imx_clk_gate2("uart3_ipg_gate", "ipg", MXC_CCM_CCGR1, 14); 1938c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART3_PER_GATE] = imx_clk_gate2("uart3_per_gate", "uart_root", MXC_CCM_CCGR1, 16); 1948c2ecf20Sopenharmony_ci clk[IMX5_CLK_I2C1_GATE] = imx_clk_gate2("i2c1_gate", "per_root", MXC_CCM_CCGR1, 18); 1958c2ecf20Sopenharmony_ci clk[IMX5_CLK_I2C2_GATE] = imx_clk_gate2("i2c2_gate", "per_root", MXC_CCM_CCGR1, 20); 1968c2ecf20Sopenharmony_ci clk[IMX5_CLK_PWM1_IPG_GATE] = imx_clk_gate2("pwm1_ipg_gate", "ipg", MXC_CCM_CCGR2, 10); 1978c2ecf20Sopenharmony_ci clk[IMX5_CLK_PWM1_HF_GATE] = imx_clk_gate2("pwm1_hf_gate", "per_root", MXC_CCM_CCGR2, 12); 1988c2ecf20Sopenharmony_ci clk[IMX5_CLK_PWM2_IPG_GATE] = imx_clk_gate2("pwm2_ipg_gate", "ipg", MXC_CCM_CCGR2, 14); 1998c2ecf20Sopenharmony_ci clk[IMX5_CLK_PWM2_HF_GATE] = imx_clk_gate2("pwm2_hf_gate", "per_root", MXC_CCM_CCGR2, 16); 2008c2ecf20Sopenharmony_ci clk[IMX5_CLK_GPT_IPG_GATE] = imx_clk_gate2("gpt_ipg_gate", "ipg", MXC_CCM_CCGR2, 18); 2018c2ecf20Sopenharmony_ci clk[IMX5_CLK_GPT_HF_GATE] = imx_clk_gate2("gpt_hf_gate", "per_root", MXC_CCM_CCGR2, 20); 2028c2ecf20Sopenharmony_ci clk[IMX5_CLK_FEC_GATE] = imx_clk_gate2("fec_gate", "ipg", MXC_CCM_CCGR2, 24); 2038c2ecf20Sopenharmony_ci clk[IMX5_CLK_USBOH3_GATE] = imx_clk_gate2("usboh3_gate", "ipg", MXC_CCM_CCGR2, 26); 2048c2ecf20Sopenharmony_ci clk[IMX5_CLK_USBOH3_PER_GATE] = imx_clk_gate2("usboh3_per_gate", "usboh3_podf", MXC_CCM_CCGR2, 28); 2058c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC1_IPG_GATE] = imx_clk_gate2("esdhc1_ipg_gate", "ipg", MXC_CCM_CCGR3, 0); 2068c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC2_IPG_GATE] = imx_clk_gate2("esdhc2_ipg_gate", "ipg", MXC_CCM_CCGR3, 4); 2078c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC3_IPG_GATE] = imx_clk_gate2("esdhc3_ipg_gate", "ipg", MXC_CCM_CCGR3, 8); 2088c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC4_IPG_GATE] = imx_clk_gate2("esdhc4_ipg_gate", "ipg", MXC_CCM_CCGR3, 12); 2098c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI1_IPG_GATE] = imx_clk_gate2("ssi1_ipg_gate", "ipg", MXC_CCM_CCGR3, 16); 2108c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI2_IPG_GATE] = imx_clk_gate2("ssi2_ipg_gate", "ipg", MXC_CCM_CCGR3, 20); 2118c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI3_IPG_GATE] = imx_clk_gate2("ssi3_ipg_gate", "ipg", MXC_CCM_CCGR3, 24); 2128c2ecf20Sopenharmony_ci clk[IMX5_CLK_ECSPI1_IPG_GATE] = imx_clk_gate2("ecspi1_ipg_gate", "ipg", MXC_CCM_CCGR4, 18); 2138c2ecf20Sopenharmony_ci clk[IMX5_CLK_ECSPI1_PER_GATE] = imx_clk_gate2("ecspi1_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 20); 2148c2ecf20Sopenharmony_ci clk[IMX5_CLK_ECSPI2_IPG_GATE] = imx_clk_gate2("ecspi2_ipg_gate", "ipg", MXC_CCM_CCGR4, 22); 2158c2ecf20Sopenharmony_ci clk[IMX5_CLK_ECSPI2_PER_GATE] = imx_clk_gate2("ecspi2_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 24); 2168c2ecf20Sopenharmony_ci clk[IMX5_CLK_CSPI_IPG_GATE] = imx_clk_gate2("cspi_ipg_gate", "ipg", MXC_CCM_CCGR4, 26); 2178c2ecf20Sopenharmony_ci clk[IMX5_CLK_SDMA_GATE] = imx_clk_gate2("sdma_gate", "ipg", MXC_CCM_CCGR4, 30); 2188c2ecf20Sopenharmony_ci clk[IMX5_CLK_EMI_FAST_GATE] = imx_clk_gate2_flags("emi_fast_gate", "dummy", MXC_CCM_CCGR5, 14, CLK_IS_CRITICAL); 2198c2ecf20Sopenharmony_ci clk[IMX5_CLK_EMI_SLOW_GATE] = imx_clk_gate2_flags("emi_slow_gate", "emi_slow_podf", MXC_CCM_CCGR5, 16, CLK_IS_CRITICAL); 2208c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_SEL] = imx_clk_mux("ipu_sel", MXC_CCM_CBCMR, 6, 2, ipu_sel, ARRAY_SIZE(ipu_sel)); 2218c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_GATE] = imx_clk_gate2("ipu_gate", "ipu_sel", MXC_CCM_CCGR5, 10); 2228c2ecf20Sopenharmony_ci clk[IMX5_CLK_NFC_GATE] = imx_clk_gate2("nfc_gate", "nfc_podf", MXC_CCM_CCGR5, 20); 2238c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_DI0_GATE] = imx_clk_gate2("ipu_di0_gate", "ipu_di0_sel", MXC_CCM_CCGR6, 10); 2248c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_DI1_GATE] = imx_clk_gate2("ipu_di1_gate", "ipu_di1_sel", MXC_CCM_CCGR6, 12); 2258c2ecf20Sopenharmony_ci clk[IMX5_CLK_GPU3D_SEL] = imx_clk_mux("gpu3d_sel", MXC_CCM_CBCMR, 4, 2, gpu3d_sel, ARRAY_SIZE(gpu3d_sel)); 2268c2ecf20Sopenharmony_ci clk[IMX5_CLK_GPU2D_SEL] = imx_clk_mux("gpu2d_sel", MXC_CCM_CBCMR, 16, 2, gpu2d_sel, ARRAY_SIZE(gpu2d_sel)); 2278c2ecf20Sopenharmony_ci clk[IMX5_CLK_GPU3D_GATE] = imx_clk_gate2("gpu3d_gate", "gpu3d_sel", MXC_CCM_CCGR5, 2); 2288c2ecf20Sopenharmony_ci clk[IMX5_CLK_GARB_GATE] = imx_clk_gate2("garb_gate", "axi_a", MXC_CCM_CCGR5, 4); 2298c2ecf20Sopenharmony_ci clk[IMX5_CLK_GPU2D_GATE] = imx_clk_gate2("gpu2d_gate", "gpu2d_sel", MXC_CCM_CCGR6, 14); 2308c2ecf20Sopenharmony_ci clk[IMX5_CLK_VPU_SEL] = imx_clk_mux("vpu_sel", MXC_CCM_CBCMR, 14, 2, vpu_sel, ARRAY_SIZE(vpu_sel)); 2318c2ecf20Sopenharmony_ci clk[IMX5_CLK_VPU_GATE] = imx_clk_gate2("vpu_gate", "vpu_sel", MXC_CCM_CCGR5, 6); 2328c2ecf20Sopenharmony_ci clk[IMX5_CLK_VPU_REFERENCE_GATE] = imx_clk_gate2("vpu_reference_gate", "osc", MXC_CCM_CCGR5, 8); 2338c2ecf20Sopenharmony_ci clk[IMX5_CLK_GPC_DVFS] = imx_clk_gate2_flags("gpc_dvfs", "dummy", MXC_CCM_CCGR5, 24, CLK_IS_CRITICAL); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_APM] = imx_clk_mux("ssi_apm", MXC_CCM_CSCMR1, 8, 2, ssi_apm_sels, ARRAY_SIZE(ssi_apm_sels)); 2368c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI1_ROOT_SEL] = imx_clk_mux("ssi1_root_sel", MXC_CCM_CSCMR1, 14, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels)); 2378c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI2_ROOT_SEL] = imx_clk_mux("ssi2_root_sel", MXC_CCM_CSCMR1, 12, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels)); 2388c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI3_ROOT_SEL] = imx_clk_mux("ssi3_root_sel", MXC_CCM_CSCMR1, 11, 1, ssi3_clk_sels, ARRAY_SIZE(ssi3_clk_sels)); 2398c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT1_SEL] = imx_clk_mux("ssi_ext1_sel", MXC_CCM_CSCMR1, 28, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels)); 2408c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT2_SEL] = imx_clk_mux("ssi_ext2_sel", MXC_CCM_CSCMR1, 30, 2, ssi_clk_sels, ARRAY_SIZE(ssi_clk_sels)); 2418c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT1_COM_SEL] = imx_clk_mux("ssi_ext1_com_sel", MXC_CCM_CSCMR1, 0, 1, ssi_ext1_com_sels, ARRAY_SIZE(ssi_ext1_com_sels)); 2428c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT2_COM_SEL] = imx_clk_mux("ssi_ext2_com_sel", MXC_CCM_CSCMR1, 1, 1, ssi_ext2_com_sels, ARRAY_SIZE(ssi_ext2_com_sels)); 2438c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI1_ROOT_PRED] = imx_clk_divider("ssi1_root_pred", "ssi1_root_sel", MXC_CCM_CS1CDR, 6, 3); 2448c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI1_ROOT_PODF] = imx_clk_divider("ssi1_root_podf", "ssi1_root_pred", MXC_CCM_CS1CDR, 0, 6); 2458c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI2_ROOT_PRED] = imx_clk_divider("ssi2_root_pred", "ssi2_root_sel", MXC_CCM_CS2CDR, 6, 3); 2468c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI2_ROOT_PODF] = imx_clk_divider("ssi2_root_podf", "ssi2_root_pred", MXC_CCM_CS2CDR, 0, 6); 2478c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT1_PRED] = imx_clk_divider("ssi_ext1_pred", "ssi_ext1_sel", MXC_CCM_CS1CDR, 22, 3); 2488c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT1_PODF] = imx_clk_divider("ssi_ext1_podf", "ssi_ext1_pred", MXC_CCM_CS1CDR, 16, 6); 2498c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT2_PRED] = imx_clk_divider("ssi_ext2_pred", "ssi_ext2_sel", MXC_CCM_CS2CDR, 22, 3); 2508c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT2_PODF] = imx_clk_divider("ssi_ext2_podf", "ssi_ext2_pred", MXC_CCM_CS2CDR, 16, 6); 2518c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI1_ROOT_GATE] = imx_clk_gate2("ssi1_root_gate", "ssi1_root_podf", MXC_CCM_CCGR3, 18); 2528c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI2_ROOT_GATE] = imx_clk_gate2("ssi2_root_gate", "ssi2_root_podf", MXC_CCM_CCGR3, 22); 2538c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI3_ROOT_GATE] = imx_clk_gate2("ssi3_root_gate", "ssi3_root_sel", MXC_CCM_CCGR3, 26); 2548c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT1_GATE] = imx_clk_gate2("ssi_ext1_gate", "ssi_ext1_com_sel", MXC_CCM_CCGR3, 28); 2558c2ecf20Sopenharmony_ci clk[IMX5_CLK_SSI_EXT2_GATE] = imx_clk_gate2("ssi_ext2_gate", "ssi_ext2_com_sel", MXC_CCM_CCGR3, 30); 2568c2ecf20Sopenharmony_ci clk[IMX5_CLK_EPIT1_IPG_GATE] = imx_clk_gate2("epit1_ipg_gate", "ipg", MXC_CCM_CCGR2, 2); 2578c2ecf20Sopenharmony_ci clk[IMX5_CLK_EPIT1_HF_GATE] = imx_clk_gate2("epit1_hf_gate", "per_root", MXC_CCM_CCGR2, 4); 2588c2ecf20Sopenharmony_ci clk[IMX5_CLK_EPIT2_IPG_GATE] = imx_clk_gate2("epit2_ipg_gate", "ipg", MXC_CCM_CCGR2, 6); 2598c2ecf20Sopenharmony_ci clk[IMX5_CLK_EPIT2_HF_GATE] = imx_clk_gate2("epit2_hf_gate", "per_root", MXC_CCM_CCGR2, 8); 2608c2ecf20Sopenharmony_ci clk[IMX5_CLK_OWIRE_GATE] = imx_clk_gate2("owire_gate", "per_root", MXC_CCM_CCGR2, 22); 2618c2ecf20Sopenharmony_ci clk[IMX5_CLK_SRTC_GATE] = imx_clk_gate2("srtc_gate", "per_root", MXC_CCM_CCGR4, 28); 2628c2ecf20Sopenharmony_ci clk[IMX5_CLK_PATA_GATE] = imx_clk_gate2("pata_gate", "ipg", MXC_CCM_CCGR4, 0); 2638c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF0_SEL] = imx_clk_mux("spdif0_sel", MXC_CCM_CSCMR2, 0, 2, spdif_sel, ARRAY_SIZE(spdif_sel)); 2648c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF0_PRED] = imx_clk_divider("spdif0_pred", "spdif0_sel", MXC_CCM_CDCDR, 25, 3); 2658c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF0_PODF] = imx_clk_divider("spdif0_podf", "spdif0_pred", MXC_CCM_CDCDR, 19, 6); 2668c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF0_COM_SEL] = imx_clk_mux_flags("spdif0_com_sel", MXC_CCM_CSCMR2, 4, 1, 2678c2ecf20Sopenharmony_ci spdif0_com_sel, ARRAY_SIZE(spdif0_com_sel), CLK_SET_RATE_PARENT); 2688c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF0_GATE] = imx_clk_gate2("spdif0_gate", "spdif0_com_sel", MXC_CCM_CCGR5, 26); 2698c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF_IPG_GATE] = imx_clk_gate2("spdif_ipg_gate", "ipg", MXC_CCM_CCGR5, 30); 2708c2ecf20Sopenharmony_ci clk[IMX5_CLK_SAHARA_IPG_GATE] = imx_clk_gate2("sahara_ipg_gate", "ipg", MXC_CCM_CCGR4, 14); 2718c2ecf20Sopenharmony_ci clk[IMX5_CLK_SATA_REF] = imx_clk_fixed_factor("sata_ref", "usb_phy1_gate", 1, 1); 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci clk_register_clkdev(clk[IMX5_CLK_CPU_PODF], NULL, "cpu0"); 2748c2ecf20Sopenharmony_ci clk_register_clkdev(clk[IMX5_CLK_GPC_DVFS], "gpc_dvfs", NULL); 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci /* move usb phy clk to 24MHz */ 2778c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_USB_PHY_SEL], clk[IMX5_CLK_OSC]); 2788c2ecf20Sopenharmony_ci} 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistatic void __init mx50_clocks_init(struct device_node *np) 2818c2ecf20Sopenharmony_ci{ 2828c2ecf20Sopenharmony_ci void __iomem *ccm_base; 2838c2ecf20Sopenharmony_ci void __iomem *pll_base; 2848c2ecf20Sopenharmony_ci unsigned long r; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci pll_base = ioremap(MX53_DPLL1_BASE, SZ_16K); 2878c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 2888c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL1_SW] = imx_clk_pllv2("pll1_sw", "osc", pll_base); 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci pll_base = ioremap(MX53_DPLL2_BASE, SZ_16K); 2918c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 2928c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL2_SW] = imx_clk_pllv2("pll2_sw", "osc", pll_base); 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci pll_base = ioremap(MX53_DPLL3_BASE, SZ_16K); 2958c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 2968c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL3_SW] = imx_clk_pllv2("pll3_sw", "osc", pll_base); 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci ccm_base = of_iomap(np, 0); 2998c2ecf20Sopenharmony_ci WARN_ON(!ccm_base); 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci mx5_clocks_common_init(ccm_base); 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci /* 3048c2ecf20Sopenharmony_ci * This clock is called periph_clk in the i.MX50 Reference Manual, but 3058c2ecf20Sopenharmony_ci * it comes closest in scope to the main_bus_clk of i.MX51 and i.MX53 3068c2ecf20Sopenharmony_ci */ 3078c2ecf20Sopenharmony_ci clk[IMX5_CLK_MAIN_BUS] = imx_clk_mux("main_bus", MXC_CCM_CBCDR, 25, 2, 3088c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci clk[IMX5_CLK_LP_APM] = imx_clk_mux("lp_apm", MXC_CCM_CCSR, 10, 1, 3118c2ecf20Sopenharmony_ci lp_apm_sel, ARRAY_SIZE(lp_apm_sel)); 3128c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_A_SEL] = imx_clk_mux("esdhc_a_sel", MXC_CCM_CSCMR1, 21, 2, 3138c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 3148c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_B_SEL] = imx_clk_mux("esdhc_b_sel", MXC_CCM_CSCMR1, 16, 2, 3158c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 3168c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_C_SEL] = imx_clk_mux("esdhc_c_sel", MXC_CCM_CSCMR1, 20, 1, esdhc_c_sel, ARRAY_SIZE(esdhc_c_sel)); 3178c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_D_SEL] = imx_clk_mux("esdhc_d_sel", MXC_CCM_CSCMR1, 19, 1, esdhc_d_sel, ARRAY_SIZE(esdhc_d_sel)); 3188c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC1_PER_GATE] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2); 3198c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC2_PER_GATE] = imx_clk_gate2("esdhc2_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 6); 3208c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC3_PER_GATE] = imx_clk_gate2("esdhc3_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 10); 3218c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC4_PER_GATE] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14); 3228c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY1_GATE] = imx_clk_gate2("usb_phy1_gate", "usb_phy_sel", MXC_CCM_CCGR4, 10); 3238c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY2_GATE] = imx_clk_gate2("usb_phy2_gate", "usb_phy_sel", MXC_CCM_CCGR4, 12); 3248c2ecf20Sopenharmony_ci clk[IMX5_CLK_I2C3_GATE] = imx_clk_gate2("i2c3_gate", "per_root", MXC_CCM_CCGR1, 22); 3258c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART4_IPG_GATE] = imx_clk_gate2("uart4_ipg_gate", "ipg", MXC_CCM_CCGR7, 8); 3268c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART4_PER_GATE] = imx_clk_gate2("uart4_per_gate", "uart_root", MXC_CCM_CCGR7, 10); 3278c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART5_IPG_GATE] = imx_clk_gate2("uart5_ipg_gate", "ipg", MXC_CCM_CCGR7, 12); 3288c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART5_PER_GATE] = imx_clk_gate2("uart5_per_gate", "uart_root", MXC_CCM_CCGR7, 14); 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO1_SEL] = imx_clk_mux("cko1_sel", MXC_CCM_CCOSR, 0, 4, 3318c2ecf20Sopenharmony_ci mx53_cko1_sel, ARRAY_SIZE(mx53_cko1_sel)); 3328c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO1_PODF] = imx_clk_divider("cko1_podf", "cko1_sel", MXC_CCM_CCOSR, 4, 3); 3338c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO1] = imx_clk_gate2("cko1", "cko1_podf", MXC_CCM_CCOSR, 7); 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO2_SEL] = imx_clk_mux("cko2_sel", MXC_CCM_CCOSR, 16, 5, 3368c2ecf20Sopenharmony_ci mx53_cko2_sel, ARRAY_SIZE(mx53_cko2_sel)); 3378c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO2_PODF] = imx_clk_divider("cko2_podf", "cko2_sel", MXC_CCM_CCOSR, 21, 3); 3388c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO2] = imx_clk_gate2("cko2", "cko2_podf", MXC_CCM_CCOSR, 24); 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci imx_check_clocks(clk, ARRAY_SIZE(clk)); 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci clk_data.clks = clk; 3438c2ecf20Sopenharmony_ci clk_data.clk_num = ARRAY_SIZE(clk); 3448c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci /* Set SDHC parents to be PLL2 */ 3478c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_ESDHC_A_SEL], clk[IMX5_CLK_PLL2_SW]); 3488c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_ESDHC_B_SEL], clk[IMX5_CLK_PLL2_SW]); 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci /* set SDHC root clock to 200MHZ*/ 3518c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_ESDHC_A_PODF], 200000000); 3528c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_ESDHC_B_PODF], 200000000); 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci clk_prepare_enable(clk[IMX5_CLK_IIM_GATE]); 3558c2ecf20Sopenharmony_ci imx_print_silicon_rev("i.MX50", IMX_CHIP_REVISION_1_1); 3568c2ecf20Sopenharmony_ci clk_disable_unprepare(clk[IMX5_CLK_IIM_GATE]); 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000); 3598c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r); 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci imx_register_uart_clocks(5); 3628c2ecf20Sopenharmony_ci} 3638c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx50_ccm, "fsl,imx50-ccm", mx50_clocks_init); 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_cistatic void __init mx51_clocks_init(struct device_node *np) 3668c2ecf20Sopenharmony_ci{ 3678c2ecf20Sopenharmony_ci void __iomem *ccm_base; 3688c2ecf20Sopenharmony_ci void __iomem *pll_base; 3698c2ecf20Sopenharmony_ci u32 val; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci pll_base = ioremap(MX51_DPLL1_BASE, SZ_16K); 3728c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 3738c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL1_SW] = imx_clk_pllv2("pll1_sw", "osc", pll_base); 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci pll_base = ioremap(MX51_DPLL2_BASE, SZ_16K); 3768c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 3778c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL2_SW] = imx_clk_pllv2("pll2_sw", "osc", pll_base); 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci pll_base = ioremap(MX51_DPLL3_BASE, SZ_16K); 3808c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 3818c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL3_SW] = imx_clk_pllv2("pll3_sw", "osc", pll_base); 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci ccm_base = of_iomap(np, 0); 3848c2ecf20Sopenharmony_ci WARN_ON(!ccm_base); 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci mx5_clocks_common_init(ccm_base); 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci clk[IMX5_CLK_PERIPH_APM] = imx_clk_mux("periph_apm", MXC_CCM_CBCMR, 12, 2, 3898c2ecf20Sopenharmony_ci periph_apm_sel, ARRAY_SIZE(periph_apm_sel)); 3908c2ecf20Sopenharmony_ci clk[IMX5_CLK_MAIN_BUS] = imx_clk_mux("main_bus", MXC_CCM_CBCDR, 25, 1, 3918c2ecf20Sopenharmony_ci main_bus_sel, ARRAY_SIZE(main_bus_sel)); 3928c2ecf20Sopenharmony_ci clk[IMX5_CLK_LP_APM] = imx_clk_mux("lp_apm", MXC_CCM_CCSR, 9, 1, 3938c2ecf20Sopenharmony_ci lp_apm_sel, ARRAY_SIZE(lp_apm_sel)); 3948c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_DI0_SEL] = imx_clk_mux_flags("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3, 3958c2ecf20Sopenharmony_ci mx51_ipu_di0_sel, ARRAY_SIZE(mx51_ipu_di0_sel), CLK_SET_RATE_PARENT); 3968c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_DI1_SEL] = imx_clk_mux_flags("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3, 3978c2ecf20Sopenharmony_ci mx51_ipu_di1_sel, ARRAY_SIZE(mx51_ipu_di1_sel), CLK_SET_RATE_PARENT); 3988c2ecf20Sopenharmony_ci clk[IMX5_CLK_TVE_EXT_SEL] = imx_clk_mux_flags("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1, 3998c2ecf20Sopenharmony_ci mx51_tve_ext_sel, ARRAY_SIZE(mx51_tve_ext_sel), CLK_SET_RATE_PARENT); 4008c2ecf20Sopenharmony_ci clk[IMX5_CLK_TVE_SEL] = imx_clk_mux("tve_sel", MXC_CCM_CSCMR1, 7, 1, 4018c2ecf20Sopenharmony_ci mx51_tve_sel, ARRAY_SIZE(mx51_tve_sel)); 4028c2ecf20Sopenharmony_ci clk[IMX5_CLK_TVE_GATE] = imx_clk_gate2("tve_gate", "tve_sel", MXC_CCM_CCGR2, 30); 4038c2ecf20Sopenharmony_ci clk[IMX5_CLK_TVE_PRED] = imx_clk_divider("tve_pred", "pll3_sw", MXC_CCM_CDCDR, 28, 3); 4048c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_A_SEL] = imx_clk_mux("esdhc_a_sel", MXC_CCM_CSCMR1, 20, 2, 4058c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 4068c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_B_SEL] = imx_clk_mux("esdhc_b_sel", MXC_CCM_CSCMR1, 16, 2, 4078c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 4088c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_C_SEL] = imx_clk_mux("esdhc_c_sel", MXC_CCM_CSCMR1, 19, 1, esdhc_c_sel, ARRAY_SIZE(esdhc_c_sel)); 4098c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_D_SEL] = imx_clk_mux("esdhc_d_sel", MXC_CCM_CSCMR1, 18, 1, esdhc_d_sel, ARRAY_SIZE(esdhc_d_sel)); 4108c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC1_PER_GATE] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2); 4118c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC2_PER_GATE] = imx_clk_gate2("esdhc2_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 6); 4128c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC3_PER_GATE] = imx_clk_gate2("esdhc3_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 10); 4138c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC4_PER_GATE] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14); 4148c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY_GATE] = imx_clk_gate2("usb_phy_gate", "usb_phy_sel", MXC_CCM_CCGR2, 0); 4158c2ecf20Sopenharmony_ci clk[IMX5_CLK_HSI2C_GATE] = imx_clk_gate2("hsi2c_gate", "ipg", MXC_CCM_CCGR1, 22); 4168c2ecf20Sopenharmony_ci clk[IMX5_CLK_SCC2_IPG_GATE] = imx_clk_gate2("scc2_gate", "ipg", MXC_CCM_CCGR1, 30); 4178c2ecf20Sopenharmony_ci clk[IMX5_CLK_MIPI_HSC1_GATE] = imx_clk_gate2_flags("mipi_hsc1_gate", "ipg", MXC_CCM_CCGR4, 6, CLK_IS_CRITICAL); 4188c2ecf20Sopenharmony_ci clk[IMX5_CLK_MIPI_HSC2_GATE] = imx_clk_gate2_flags("mipi_hsc2_gate", "ipg", MXC_CCM_CCGR4, 8, CLK_IS_CRITICAL); 4198c2ecf20Sopenharmony_ci clk[IMX5_CLK_MIPI_ESC_GATE] = imx_clk_gate2_flags("mipi_esc_gate", "ipg", MXC_CCM_CCGR4, 10, CLK_IS_CRITICAL); 4208c2ecf20Sopenharmony_ci clk[IMX5_CLK_MIPI_HSP_GATE] = imx_clk_gate2_flags("mipi_hsp_gate", "ipg", MXC_CCM_CCGR4, 12, CLK_IS_CRITICAL); 4218c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF_XTAL_SEL] = imx_clk_mux("spdif_xtal_sel", MXC_CCM_CSCMR1, 2, 2, 4228c2ecf20Sopenharmony_ci mx51_spdif_xtal_sel, ARRAY_SIZE(mx51_spdif_xtal_sel)); 4238c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF1_SEL] = imx_clk_mux("spdif1_sel", MXC_CCM_CSCMR2, 2, 2, 4248c2ecf20Sopenharmony_ci spdif_sel, ARRAY_SIZE(spdif_sel)); 4258c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF1_PRED] = imx_clk_divider("spdif1_pred", "spdif1_sel", MXC_CCM_CDCDR, 16, 3); 4268c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF1_PODF] = imx_clk_divider("spdif1_podf", "spdif1_pred", MXC_CCM_CDCDR, 9, 6); 4278c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF1_COM_SEL] = imx_clk_mux("spdif1_com_sel", MXC_CCM_CSCMR2, 5, 1, 4288c2ecf20Sopenharmony_ci mx51_spdif1_com_sel, ARRAY_SIZE(mx51_spdif1_com_sel)); 4298c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF1_GATE] = imx_clk_gate2("spdif1_gate", "spdif1_com_sel", MXC_CCM_CCGR5, 28); 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci imx_check_clocks(clk, ARRAY_SIZE(clk)); 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci clk_data.clks = clk; 4348c2ecf20Sopenharmony_ci clk_data.clk_num = ARRAY_SIZE(clk); 4358c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci /* set the usboh3 parent to pll2_sw */ 4388c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_USBOH3_SEL], clk[IMX5_CLK_PLL2_SW]); 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci /* Set SDHC parents to be PLL2 */ 4418c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_ESDHC_A_SEL], clk[IMX5_CLK_PLL2_SW]); 4428c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_ESDHC_B_SEL], clk[IMX5_CLK_PLL2_SW]); 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_ci /* set SDHC root clock to 166.25MHZ*/ 4458c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_ESDHC_A_PODF], 166250000); 4468c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_ESDHC_B_PODF], 166250000); 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci clk_prepare_enable(clk[IMX5_CLK_IIM_GATE]); 4498c2ecf20Sopenharmony_ci imx_print_silicon_rev("i.MX51", mx51_revision()); 4508c2ecf20Sopenharmony_ci clk_disable_unprepare(clk[IMX5_CLK_IIM_GATE]); 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci /* 4538c2ecf20Sopenharmony_ci * Reference Manual says: Functionality of CCDR[18] and CLPCR[23] is no 4548c2ecf20Sopenharmony_ci * longer supported. Set to one for better power saving. 4558c2ecf20Sopenharmony_ci * 4568c2ecf20Sopenharmony_ci * The effect of not setting these bits is that MIPI clocks can't be 4578c2ecf20Sopenharmony_ci * enabled without the IPU clock being enabled aswell. 4588c2ecf20Sopenharmony_ci */ 4598c2ecf20Sopenharmony_ci val = readl(MXC_CCM_CCDR); 4608c2ecf20Sopenharmony_ci val |= 1 << 18; 4618c2ecf20Sopenharmony_ci writel(val, MXC_CCM_CCDR); 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci val = readl(MXC_CCM_CLPCR); 4648c2ecf20Sopenharmony_ci val |= 1 << 23; 4658c2ecf20Sopenharmony_ci writel(val, MXC_CCM_CLPCR); 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci imx_register_uart_clocks(3); 4688c2ecf20Sopenharmony_ci} 4698c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx51_ccm, "fsl,imx51-ccm", mx51_clocks_init); 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_cistatic void __init mx53_clocks_init(struct device_node *np) 4728c2ecf20Sopenharmony_ci{ 4738c2ecf20Sopenharmony_ci void __iomem *ccm_base; 4748c2ecf20Sopenharmony_ci void __iomem *pll_base; 4758c2ecf20Sopenharmony_ci unsigned long r; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci pll_base = ioremap(MX53_DPLL1_BASE, SZ_16K); 4788c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 4798c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL1_SW] = imx_clk_pllv2("pll1_sw", "osc", pll_base); 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_ci pll_base = ioremap(MX53_DPLL2_BASE, SZ_16K); 4828c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 4838c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL2_SW] = imx_clk_pllv2("pll2_sw", "osc", pll_base); 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ci pll_base = ioremap(MX53_DPLL3_BASE, SZ_16K); 4868c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 4878c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL3_SW] = imx_clk_pllv2("pll3_sw", "osc", pll_base); 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci pll_base = ioremap(MX53_DPLL4_BASE, SZ_16K); 4908c2ecf20Sopenharmony_ci WARN_ON(!pll_base); 4918c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL4_SW] = imx_clk_pllv2("pll4_sw", "osc", pll_base); 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci ccm_base = of_iomap(np, 0); 4948c2ecf20Sopenharmony_ci WARN_ON(!ccm_base); 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci mx5_clocks_common_init(ccm_base); 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci clk[IMX5_CLK_PERIPH_APM] = imx_clk_mux("periph_apm", MXC_CCM_CBCMR, 12, 2, 4998c2ecf20Sopenharmony_ci periph_apm_sel, ARRAY_SIZE(periph_apm_sel)); 5008c2ecf20Sopenharmony_ci clk[IMX5_CLK_MAIN_BUS] = imx_clk_mux("main_bus", MXC_CCM_CBCDR, 25, 1, 5018c2ecf20Sopenharmony_ci main_bus_sel, ARRAY_SIZE(main_bus_sel)); 5028c2ecf20Sopenharmony_ci clk[IMX5_CLK_LP_APM] = imx_clk_mux("lp_apm", MXC_CCM_CCSR, 10, 1, 5038c2ecf20Sopenharmony_ci lp_apm_sel, ARRAY_SIZE(lp_apm_sel)); 5048c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI1_DIV_3_5] = imx_clk_fixed_factor("ldb_di1_div_3_5", "ldb_di1_sel", 2, 7); 5058c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI1_DIV] = imx_clk_divider_flags("ldb_di1_div", "ldb_di1_div_3_5", MXC_CCM_CSCMR2, 11, 1, 0); 5068c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI1_SEL] = imx_clk_mux_flags("ldb_di1_sel", MXC_CCM_CSCMR2, 9, 1, 5078c2ecf20Sopenharmony_ci mx53_ldb_di1_sel, ARRAY_SIZE(mx53_ldb_di1_sel), CLK_SET_RATE_PARENT); 5088c2ecf20Sopenharmony_ci clk[IMX5_CLK_DI_PLL4_PODF] = imx_clk_divider("di_pll4_podf", "pll4_sw", MXC_CCM_CDCDR, 16, 3); 5098c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI0_DIV_3_5] = imx_clk_fixed_factor("ldb_di0_div_3_5", "ldb_di0_sel", 2, 7); 5108c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI0_DIV] = imx_clk_divider_flags("ldb_di0_div", "ldb_di0_div_3_5", MXC_CCM_CSCMR2, 10, 1, 0); 5118c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI0_SEL] = imx_clk_mux_flags("ldb_di0_sel", MXC_CCM_CSCMR2, 8, 1, 5128c2ecf20Sopenharmony_ci mx53_ldb_di0_sel, ARRAY_SIZE(mx53_ldb_di0_sel), CLK_SET_RATE_PARENT); 5138c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI0_GATE] = imx_clk_gate2("ldb_di0_gate", "ldb_di0_div", MXC_CCM_CCGR6, 28); 5148c2ecf20Sopenharmony_ci clk[IMX5_CLK_LDB_DI1_GATE] = imx_clk_gate2("ldb_di1_gate", "ldb_di1_div", MXC_CCM_CCGR6, 30); 5158c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_DI0_SEL] = imx_clk_mux_flags("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3, 5168c2ecf20Sopenharmony_ci mx53_ipu_di0_sel, ARRAY_SIZE(mx53_ipu_di0_sel), CLK_SET_RATE_PARENT); 5178c2ecf20Sopenharmony_ci clk[IMX5_CLK_IPU_DI1_SEL] = imx_clk_mux_flags("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3, 5188c2ecf20Sopenharmony_ci mx53_ipu_di1_sel, ARRAY_SIZE(mx53_ipu_di1_sel), CLK_SET_RATE_PARENT); 5198c2ecf20Sopenharmony_ci clk[IMX5_CLK_TVE_EXT_SEL] = imx_clk_mux_flags("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1, 5208c2ecf20Sopenharmony_ci mx53_tve_ext_sel, ARRAY_SIZE(mx53_tve_ext_sel), CLK_SET_RATE_PARENT); 5218c2ecf20Sopenharmony_ci clk[IMX5_CLK_TVE_GATE] = imx_clk_gate2("tve_gate", "tve_pred", MXC_CCM_CCGR2, 30); 5228c2ecf20Sopenharmony_ci clk[IMX5_CLK_TVE_PRED] = imx_clk_divider("tve_pred", "tve_ext_sel", MXC_CCM_CDCDR, 28, 3); 5238c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_A_SEL] = imx_clk_mux("esdhc_a_sel", MXC_CCM_CSCMR1, 20, 2, 5248c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 5258c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_B_SEL] = imx_clk_mux("esdhc_b_sel", MXC_CCM_CSCMR1, 16, 2, 5268c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 5278c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_C_SEL] = imx_clk_mux("esdhc_c_sel", MXC_CCM_CSCMR1, 19, 1, esdhc_c_sel, ARRAY_SIZE(esdhc_c_sel)); 5288c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC_D_SEL] = imx_clk_mux("esdhc_d_sel", MXC_CCM_CSCMR1, 18, 1, esdhc_d_sel, ARRAY_SIZE(esdhc_d_sel)); 5298c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC1_PER_GATE] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2); 5308c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC2_PER_GATE] = imx_clk_gate2("esdhc2_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 6); 5318c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC3_PER_GATE] = imx_clk_gate2("esdhc3_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 10); 5328c2ecf20Sopenharmony_ci clk[IMX5_CLK_ESDHC4_PER_GATE] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14); 5338c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY1_GATE] = imx_clk_gate2("usb_phy1_gate", "usb_phy_sel", MXC_CCM_CCGR4, 10); 5348c2ecf20Sopenharmony_ci clk[IMX5_CLK_USB_PHY2_GATE] = imx_clk_gate2("usb_phy2_gate", "usb_phy_sel", MXC_CCM_CCGR4, 12); 5358c2ecf20Sopenharmony_ci clk[IMX5_CLK_CAN_SEL] = imx_clk_mux("can_sel", MXC_CCM_CSCMR2, 6, 2, 5368c2ecf20Sopenharmony_ci mx53_can_sel, ARRAY_SIZE(mx53_can_sel)); 5378c2ecf20Sopenharmony_ci clk[IMX5_CLK_CAN1_SERIAL_GATE] = imx_clk_gate2("can1_serial_gate", "can_sel", MXC_CCM_CCGR6, 22); 5388c2ecf20Sopenharmony_ci clk[IMX5_CLK_CAN1_IPG_GATE] = imx_clk_gate2("can1_ipg_gate", "ipg", MXC_CCM_CCGR6, 20); 5398c2ecf20Sopenharmony_ci clk[IMX5_CLK_OCRAM] = imx_clk_gate2("ocram", "ahb", MXC_CCM_CCGR6, 2); 5408c2ecf20Sopenharmony_ci clk[IMX5_CLK_CAN2_SERIAL_GATE] = imx_clk_gate2("can2_serial_gate", "can_sel", MXC_CCM_CCGR4, 8); 5418c2ecf20Sopenharmony_ci clk[IMX5_CLK_CAN2_IPG_GATE] = imx_clk_gate2("can2_ipg_gate", "ipg", MXC_CCM_CCGR4, 6); 5428c2ecf20Sopenharmony_ci clk[IMX5_CLK_I2C3_GATE] = imx_clk_gate2("i2c3_gate", "per_root", MXC_CCM_CCGR1, 22); 5438c2ecf20Sopenharmony_ci clk[IMX5_CLK_SATA_GATE] = imx_clk_gate2("sata_gate", "ipg", MXC_CCM_CCGR4, 2); 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci clk[IMX5_CLK_FIRI_SEL] = imx_clk_mux("firi_sel", MXC_CCM_CSCMR2, 12, 2, 5468c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 5478c2ecf20Sopenharmony_ci clk[IMX5_CLK_FIRI_PRED] = imx_clk_divider("firi_pred", "firi_sel", MXC_CCM_CSCDR3, 6, 3); 5488c2ecf20Sopenharmony_ci clk[IMX5_CLK_FIRI_PODF] = imx_clk_divider("firi_podf", "firi_pred", MXC_CCM_CSCDR3, 0, 6); 5498c2ecf20Sopenharmony_ci clk[IMX5_CLK_FIRI_SERIAL_GATE] = imx_clk_gate2("firi_serial_gate", "firi_podf", MXC_CCM_CCGR1, 28); 5508c2ecf20Sopenharmony_ci clk[IMX5_CLK_FIRI_IPG_GATE] = imx_clk_gate2("firi_ipg_gate", "ipg", MXC_CCM_CCGR1, 26); 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci clk[IMX5_CLK_CSI0_MCLK1_SEL] = imx_clk_mux("csi0_mclk1_sel", MXC_CCM_CSCMR2, 22, 2, 5538c2ecf20Sopenharmony_ci standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); 5548c2ecf20Sopenharmony_ci clk[IMX5_CLK_CSI0_MCLK1_PRED] = imx_clk_divider("csi0_mclk1_pred", "csi0_mclk1_sel", MXC_CCM_CSCDR4, 6, 3); 5558c2ecf20Sopenharmony_ci clk[IMX5_CLK_CSI0_MCLK1_PODF] = imx_clk_divider("csi0_mclk1_podf", "csi0_mclk1_pred", MXC_CCM_CSCDR4, 0, 6); 5568c2ecf20Sopenharmony_ci clk[IMX5_CLK_CSI0_MCLK1_GATE] = imx_clk_gate2("csi0_mclk1_serial_gate", "csi0_mclk1_podf", MXC_CCM_CCGR6, 4); 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci clk[IMX5_CLK_IEEE1588_SEL] = imx_clk_mux("ieee1588_sel", MXC_CCM_CSCMR2, 14, 2, 5598c2ecf20Sopenharmony_ci ieee1588_sels, ARRAY_SIZE(ieee1588_sels)); 5608c2ecf20Sopenharmony_ci clk[IMX5_CLK_IEEE1588_PRED] = imx_clk_divider("ieee1588_pred", "ieee1588_sel", MXC_CCM_CSCDR2, 6, 3); 5618c2ecf20Sopenharmony_ci clk[IMX5_CLK_IEEE1588_PODF] = imx_clk_divider("ieee1588_podf", "ieee1588_pred", MXC_CCM_CSCDR2, 0, 6); 5628c2ecf20Sopenharmony_ci clk[IMX5_CLK_IEEE1588_GATE] = imx_clk_gate2("ieee1588_serial_gate", "ieee1588_podf", MXC_CCM_CCGR7, 6); 5638c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART4_IPG_GATE] = imx_clk_gate2("uart4_ipg_gate", "ipg", MXC_CCM_CCGR7, 8); 5648c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART4_PER_GATE] = imx_clk_gate2("uart4_per_gate", "uart_root", MXC_CCM_CCGR7, 10); 5658c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART5_IPG_GATE] = imx_clk_gate2("uart5_ipg_gate", "ipg", MXC_CCM_CCGR7, 12); 5668c2ecf20Sopenharmony_ci clk[IMX5_CLK_UART5_PER_GATE] = imx_clk_gate2("uart5_per_gate", "uart_root", MXC_CCM_CCGR7, 14); 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO1_SEL] = imx_clk_mux("cko1_sel", MXC_CCM_CCOSR, 0, 4, 5698c2ecf20Sopenharmony_ci mx53_cko1_sel, ARRAY_SIZE(mx53_cko1_sel)); 5708c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO1_PODF] = imx_clk_divider("cko1_podf", "cko1_sel", MXC_CCM_CCOSR, 4, 3); 5718c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO1] = imx_clk_gate2("cko1", "cko1_podf", MXC_CCM_CCOSR, 7); 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO2_SEL] = imx_clk_mux("cko2_sel", MXC_CCM_CCOSR, 16, 5, 5748c2ecf20Sopenharmony_ci mx53_cko2_sel, ARRAY_SIZE(mx53_cko2_sel)); 5758c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO2_PODF] = imx_clk_divider("cko2_podf", "cko2_sel", MXC_CCM_CCOSR, 21, 3); 5768c2ecf20Sopenharmony_ci clk[IMX5_CLK_CKO2] = imx_clk_gate2("cko2", "cko2_podf", MXC_CCM_CCOSR, 24); 5778c2ecf20Sopenharmony_ci clk[IMX5_CLK_SPDIF_XTAL_SEL] = imx_clk_mux("spdif_xtal_sel", MXC_CCM_CSCMR1, 2, 2, 5788c2ecf20Sopenharmony_ci mx53_spdif_xtal_sel, ARRAY_SIZE(mx53_spdif_xtal_sel)); 5798c2ecf20Sopenharmony_ci clk[IMX5_CLK_ARM] = imx_clk_cpu("arm", "cpu_podf", 5808c2ecf20Sopenharmony_ci clk[IMX5_CLK_CPU_PODF], 5818c2ecf20Sopenharmony_ci clk[IMX5_CLK_CPU_PODF_SEL], 5828c2ecf20Sopenharmony_ci clk[IMX5_CLK_PLL1_SW], 5838c2ecf20Sopenharmony_ci clk[IMX5_CLK_STEP_SEL]); 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci imx_check_clocks(clk, ARRAY_SIZE(clk)); 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci clk_data.clks = clk; 5888c2ecf20Sopenharmony_ci clk_data.clk_num = ARRAY_SIZE(clk); 5898c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci /* Set SDHC parents to be PLL2 */ 5928c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_ESDHC_A_SEL], clk[IMX5_CLK_PLL2_SW]); 5938c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_ESDHC_B_SEL], clk[IMX5_CLK_PLL2_SW]); 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci /* set SDHC root clock to 200MHZ*/ 5968c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_ESDHC_A_PODF], 200000000); 5978c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_ESDHC_B_PODF], 200000000); 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci /* move can bus clk to 24MHz */ 6008c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_CAN_SEL], clk[IMX5_CLK_LP_APM]); 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci /* make sure step clock is running from 24MHz */ 6038c2ecf20Sopenharmony_ci clk_set_parent(clk[IMX5_CLK_STEP_SEL], clk[IMX5_CLK_LP_APM]); 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci clk_prepare_enable(clk[IMX5_CLK_IIM_GATE]); 6068c2ecf20Sopenharmony_ci imx_print_silicon_rev("i.MX53", mx53_revision()); 6078c2ecf20Sopenharmony_ci clk_disable_unprepare(clk[IMX5_CLK_IIM_GATE]); 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000); 6108c2ecf20Sopenharmony_ci clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r); 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci imx_register_uart_clocks(5); 6138c2ecf20Sopenharmony_ci} 6148c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx53_ccm, "fsl,imx53-ccm", mx53_clocks_init); 615