18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2012 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/of.h>
118c2ecf20Sopenharmony_ci#include <linux/err.h>
128c2ecf20Sopenharmony_ci#include <soc/imx/revision.h>
138c2ecf20Sopenharmony_ci#include <soc/imx/timer.h>
148c2ecf20Sopenharmony_ci#include <asm/irq.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include "clk.h"
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define MX35_CCM_BASE_ADDR	0x53f80000
198c2ecf20Sopenharmony_ci#define MX35_GPT1_BASE_ADDR	0x53f90000
208c2ecf20Sopenharmony_ci#define MX35_INT_GPT		(NR_IRQS_LEGACY + 29)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define MXC_CCM_PDR0		0x04
238c2ecf20Sopenharmony_ci#define MX35_CCM_PDR2		0x0c
248c2ecf20Sopenharmony_ci#define MX35_CCM_PDR3		0x10
258c2ecf20Sopenharmony_ci#define MX35_CCM_PDR4		0x14
268c2ecf20Sopenharmony_ci#define MX35_CCM_MPCTL		0x1c
278c2ecf20Sopenharmony_ci#define MX35_CCM_PPCTL		0x20
288c2ecf20Sopenharmony_ci#define MX35_CCM_CGR0		0x2c
298c2ecf20Sopenharmony_ci#define MX35_CCM_CGR1		0x30
308c2ecf20Sopenharmony_ci#define MX35_CCM_CGR2		0x34
318c2ecf20Sopenharmony_ci#define MX35_CCM_CGR3		0x38
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistruct arm_ahb_div {
348c2ecf20Sopenharmony_ci	unsigned char arm, ahb, sel;
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cistatic struct arm_ahb_div clk_consumer[] = {
388c2ecf20Sopenharmony_ci	{ .arm = 1, .ahb = 4, .sel = 0},
398c2ecf20Sopenharmony_ci	{ .arm = 1, .ahb = 3, .sel = 1},
408c2ecf20Sopenharmony_ci	{ .arm = 2, .ahb = 2, .sel = 0},
418c2ecf20Sopenharmony_ci	{ .arm = 0, .ahb = 0, .sel = 0},
428c2ecf20Sopenharmony_ci	{ .arm = 0, .ahb = 0, .sel = 0},
438c2ecf20Sopenharmony_ci	{ .arm = 0, .ahb = 0, .sel = 0},
448c2ecf20Sopenharmony_ci	{ .arm = 4, .ahb = 1, .sel = 0},
458c2ecf20Sopenharmony_ci	{ .arm = 1, .ahb = 5, .sel = 0},
468c2ecf20Sopenharmony_ci	{ .arm = 1, .ahb = 8, .sel = 0},
478c2ecf20Sopenharmony_ci	{ .arm = 1, .ahb = 6, .sel = 1},
488c2ecf20Sopenharmony_ci	{ .arm = 2, .ahb = 4, .sel = 0},
498c2ecf20Sopenharmony_ci	{ .arm = 0, .ahb = 0, .sel = 0},
508c2ecf20Sopenharmony_ci	{ .arm = 0, .ahb = 0, .sel = 0},
518c2ecf20Sopenharmony_ci	{ .arm = 0, .ahb = 0, .sel = 0},
528c2ecf20Sopenharmony_ci	{ .arm = 4, .ahb = 2, .sel = 0},
538c2ecf20Sopenharmony_ci	{ .arm = 0, .ahb = 0, .sel = 0},
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic char hsp_div_532[] = { 4, 8, 3, 0 };
578c2ecf20Sopenharmony_cistatic char hsp_div_400[] = { 3, 6, 3, 0 };
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistatic struct clk_onecell_data clk_data;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic const char *std_sel[] = {"ppll", "arm"};
628c2ecf20Sopenharmony_cistatic const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cienum mx35_clks {
658c2ecf20Sopenharmony_ci	/*  0 */ ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb,
668c2ecf20Sopenharmony_ci	/*  9 */ ipg, arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div,
678c2ecf20Sopenharmony_ci	/* 15 */ esdhc_sel, esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel,
688c2ecf20Sopenharmony_ci	/* 20 */ spdif_div_pre, spdif_div_post, ssi_sel, ssi1_div_pre,
698c2ecf20Sopenharmony_ci	/* 24 */ ssi1_div_post, ssi2_div_pre, ssi2_div_post, usb_sel, usb_div,
708c2ecf20Sopenharmony_ci	/* 29 */ nfc_div, asrc_gate, pata_gate, audmux_gate, can1_gate,
718c2ecf20Sopenharmony_ci	/* 34 */ can2_gate, cspi1_gate, cspi2_gate, ect_gate, edio_gate,
728c2ecf20Sopenharmony_ci	/* 39 */ emi_gate, epit1_gate, epit2_gate, esai_gate, esdhc1_gate,
738c2ecf20Sopenharmony_ci	/* 44 */ esdhc2_gate, esdhc3_gate, fec_gate, gpio1_gate, gpio2_gate,
748c2ecf20Sopenharmony_ci	/* 49 */ gpio3_gate, gpt_gate, i2c1_gate, i2c2_gate, i2c3_gate,
758c2ecf20Sopenharmony_ci	/* 54 */ iomuxc_gate, ipu_gate, kpp_gate, mlb_gate, mshc_gate,
768c2ecf20Sopenharmony_ci	/* 59 */ owire_gate, pwm_gate, rngc_gate, rtc_gate, rtic_gate, scc_gate,
778c2ecf20Sopenharmony_ci	/* 65 */ sdma_gate, spba_gate, spdif_gate, ssi1_gate, ssi2_gate,
788c2ecf20Sopenharmony_ci	/* 70 */ uart1_gate, uart2_gate, uart3_gate, usbotg_gate, wdog_gate,
798c2ecf20Sopenharmony_ci	/* 75 */ max_gate, admux_gate, csi_gate, csi_div, csi_sel, iim_gate,
808c2ecf20Sopenharmony_ci	/* 81 */ gpu2d_gate, ckil, clk_max
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic struct clk *clk[clk_max];
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_cistatic void __init _mx35_clocks_init(void)
868c2ecf20Sopenharmony_ci{
878c2ecf20Sopenharmony_ci	void __iomem *base;
888c2ecf20Sopenharmony_ci	u32 pdr0, consumer_sel, hsp_sel;
898c2ecf20Sopenharmony_ci	struct arm_ahb_div *aad;
908c2ecf20Sopenharmony_ci	unsigned char *hsp_div;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	base = ioremap(MX35_CCM_BASE_ADDR, SZ_4K);
938c2ecf20Sopenharmony_ci	BUG_ON(!base);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	pdr0 = __raw_readl(base + MXC_CCM_PDR0);
968c2ecf20Sopenharmony_ci	consumer_sel = (pdr0 >> 16) & 0xf;
978c2ecf20Sopenharmony_ci	aad = &clk_consumer[consumer_sel];
988c2ecf20Sopenharmony_ci	if (!aad->arm) {
998c2ecf20Sopenharmony_ci		pr_err("i.MX35 clk: illegal consumer mux selection 0x%x\n", consumer_sel);
1008c2ecf20Sopenharmony_ci		/*
1018c2ecf20Sopenharmony_ci		 * We are basically stuck. Continue with a default entry and hope we
1028c2ecf20Sopenharmony_ci		 * get far enough to actually show the above message
1038c2ecf20Sopenharmony_ci		 */
1048c2ecf20Sopenharmony_ci		aad = &clk_consumer[0];
1058c2ecf20Sopenharmony_ci	}
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci	clk[ckih] = imx_clk_fixed("ckih", 24000000);
1088c2ecf20Sopenharmony_ci	clk[ckil] = imx_clk_fixed("ckil", 32768);
1098c2ecf20Sopenharmony_ci	clk[mpll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "mpll", "ckih", base + MX35_CCM_MPCTL);
1108c2ecf20Sopenharmony_ci	clk[ppll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "ppll", "ckih", base + MX35_CCM_PPCTL);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	clk[mpll] = imx_clk_fixed_factor("mpll_075", "mpll", 3, 4);
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	if (aad->sel)
1158c2ecf20Sopenharmony_ci		clk[arm] = imx_clk_fixed_factor("arm", "mpll_075", 1, aad->arm);
1168c2ecf20Sopenharmony_ci	else
1178c2ecf20Sopenharmony_ci		clk[arm] = imx_clk_fixed_factor("arm", "mpll", 1, aad->arm);
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	if (clk_get_rate(clk[arm]) > 400000000)
1208c2ecf20Sopenharmony_ci		hsp_div = hsp_div_532;
1218c2ecf20Sopenharmony_ci	else
1228c2ecf20Sopenharmony_ci		hsp_div = hsp_div_400;
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci	hsp_sel = (pdr0 >> 20) & 0x3;
1258c2ecf20Sopenharmony_ci	if (!hsp_div[hsp_sel]) {
1268c2ecf20Sopenharmony_ci		pr_err("i.MX35 clk: illegal hsp clk selection 0x%x\n", hsp_sel);
1278c2ecf20Sopenharmony_ci		hsp_sel = 0;
1288c2ecf20Sopenharmony_ci	}
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	clk[hsp] = imx_clk_fixed_factor("hsp", "arm", 1, hsp_div[hsp_sel]);
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	clk[ahb] = imx_clk_fixed_factor("ahb", "arm", 1, aad->ahb);
1338c2ecf20Sopenharmony_ci	clk[ipg] = imx_clk_fixed_factor("ipg", "ahb", 1, 2);
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci	clk[arm_per_div] = imx_clk_divider("arm_per_div", "arm", base + MX35_CCM_PDR4, 16, 6);
1368c2ecf20Sopenharmony_ci	clk[ahb_per_div] = imx_clk_divider("ahb_per_div", "ahb", base + MXC_CCM_PDR0, 12, 3);
1378c2ecf20Sopenharmony_ci	clk[ipg_per] = imx_clk_mux("ipg_per", base + MXC_CCM_PDR0, 26, 1, ipg_per_sel, ARRAY_SIZE(ipg_per_sel));
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci	clk[uart_sel] = imx_clk_mux("uart_sel", base + MX35_CCM_PDR3, 14, 1, std_sel, ARRAY_SIZE(std_sel));
1408c2ecf20Sopenharmony_ci	clk[uart_div] = imx_clk_divider("uart_div", "uart_sel", base + MX35_CCM_PDR4, 10, 6);
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci	clk[esdhc_sel] = imx_clk_mux("esdhc_sel", base + MX35_CCM_PDR4, 9, 1, std_sel, ARRAY_SIZE(std_sel));
1438c2ecf20Sopenharmony_ci	clk[esdhc1_div] = imx_clk_divider("esdhc1_div", "esdhc_sel", base + MX35_CCM_PDR3, 0, 6);
1448c2ecf20Sopenharmony_ci	clk[esdhc2_div] = imx_clk_divider("esdhc2_div", "esdhc_sel", base + MX35_CCM_PDR3, 8, 6);
1458c2ecf20Sopenharmony_ci	clk[esdhc3_div] = imx_clk_divider("esdhc3_div", "esdhc_sel", base + MX35_CCM_PDR3, 16, 6);
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	clk[spdif_sel] = imx_clk_mux("spdif_sel", base + MX35_CCM_PDR3, 22, 1, std_sel, ARRAY_SIZE(std_sel));
1488c2ecf20Sopenharmony_ci	clk[spdif_div_pre] = imx_clk_divider("spdif_div_pre", "spdif_sel", base + MX35_CCM_PDR3, 29, 3); /* divide by 1 not allowed */
1498c2ecf20Sopenharmony_ci	clk[spdif_div_post] = imx_clk_divider("spdif_div_post", "spdif_div_pre", base + MX35_CCM_PDR3, 23, 6);
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	clk[ssi_sel] = imx_clk_mux("ssi_sel", base + MX35_CCM_PDR2, 6, 1, std_sel, ARRAY_SIZE(std_sel));
1528c2ecf20Sopenharmony_ci	clk[ssi1_div_pre] = imx_clk_divider("ssi1_div_pre", "ssi_sel", base + MX35_CCM_PDR2, 24, 3);
1538c2ecf20Sopenharmony_ci	clk[ssi1_div_post] = imx_clk_divider("ssi1_div_post", "ssi1_div_pre", base + MX35_CCM_PDR2, 0, 6);
1548c2ecf20Sopenharmony_ci	clk[ssi2_div_pre] = imx_clk_divider("ssi2_div_pre", "ssi_sel", base + MX35_CCM_PDR2, 27, 3);
1558c2ecf20Sopenharmony_ci	clk[ssi2_div_post] = imx_clk_divider("ssi2_div_post", "ssi2_div_pre", base + MX35_CCM_PDR2, 8, 6);
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	clk[usb_sel] = imx_clk_mux("usb_sel", base + MX35_CCM_PDR4, 9, 1, std_sel, ARRAY_SIZE(std_sel));
1588c2ecf20Sopenharmony_ci	clk[usb_div] = imx_clk_divider("usb_div", "usb_sel", base + MX35_CCM_PDR4, 22, 6);
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	clk[nfc_div] = imx_clk_divider("nfc_div", "ahb", base + MX35_CCM_PDR4, 28, 4);
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	clk[csi_sel] = imx_clk_mux("csi_sel", base + MX35_CCM_PDR2, 7, 1, std_sel, ARRAY_SIZE(std_sel));
1638c2ecf20Sopenharmony_ci	clk[csi_div] = imx_clk_divider("csi_div", "csi_sel", base + MX35_CCM_PDR2, 16, 6);
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	clk[asrc_gate] = imx_clk_gate2("asrc_gate", "ipg", base + MX35_CCM_CGR0,  0);
1668c2ecf20Sopenharmony_ci	clk[pata_gate] = imx_clk_gate2("pata_gate", "ipg", base + MX35_CCM_CGR0,  2);
1678c2ecf20Sopenharmony_ci	clk[audmux_gate] = imx_clk_gate2("audmux_gate", "ipg", base + MX35_CCM_CGR0,  4);
1688c2ecf20Sopenharmony_ci	clk[can1_gate] = imx_clk_gate2("can1_gate", "ipg", base + MX35_CCM_CGR0,  6);
1698c2ecf20Sopenharmony_ci	clk[can2_gate] = imx_clk_gate2("can2_gate", "ipg", base + MX35_CCM_CGR0,  8);
1708c2ecf20Sopenharmony_ci	clk[cspi1_gate] = imx_clk_gate2("cspi1_gate", "ipg", base + MX35_CCM_CGR0, 10);
1718c2ecf20Sopenharmony_ci	clk[cspi2_gate] = imx_clk_gate2("cspi2_gate", "ipg", base + MX35_CCM_CGR0, 12);
1728c2ecf20Sopenharmony_ci	clk[ect_gate] = imx_clk_gate2("ect_gate", "ipg", base + MX35_CCM_CGR0, 14);
1738c2ecf20Sopenharmony_ci	clk[edio_gate] = imx_clk_gate2("edio_gate",   "ipg", base + MX35_CCM_CGR0, 16);
1748c2ecf20Sopenharmony_ci	clk[emi_gate] = imx_clk_gate2("emi_gate", "ipg", base + MX35_CCM_CGR0, 18);
1758c2ecf20Sopenharmony_ci	clk[epit1_gate] = imx_clk_gate2("epit1_gate", "ipg", base + MX35_CCM_CGR0, 20);
1768c2ecf20Sopenharmony_ci	clk[epit2_gate] = imx_clk_gate2("epit2_gate", "ipg", base + MX35_CCM_CGR0, 22);
1778c2ecf20Sopenharmony_ci	clk[esai_gate] = imx_clk_gate2("esai_gate",   "ipg", base + MX35_CCM_CGR0, 24);
1788c2ecf20Sopenharmony_ci	clk[esdhc1_gate] = imx_clk_gate2("esdhc1_gate", "esdhc1_div", base + MX35_CCM_CGR0, 26);
1798c2ecf20Sopenharmony_ci	clk[esdhc2_gate] = imx_clk_gate2("esdhc2_gate", "esdhc2_div", base + MX35_CCM_CGR0, 28);
1808c2ecf20Sopenharmony_ci	clk[esdhc3_gate] = imx_clk_gate2("esdhc3_gate", "esdhc3_div", base + MX35_CCM_CGR0, 30);
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", base + MX35_CCM_CGR1,  0);
1838c2ecf20Sopenharmony_ci	clk[gpio1_gate] = imx_clk_gate2("gpio1_gate", "ipg", base + MX35_CCM_CGR1,  2);
1848c2ecf20Sopenharmony_ci	clk[gpio2_gate] = imx_clk_gate2("gpio2_gate", "ipg", base + MX35_CCM_CGR1,  4);
1858c2ecf20Sopenharmony_ci	clk[gpio3_gate] = imx_clk_gate2("gpio3_gate", "ipg", base + MX35_CCM_CGR1,  6);
1868c2ecf20Sopenharmony_ci	clk[gpt_gate] = imx_clk_gate2("gpt_gate", "ipg", base + MX35_CCM_CGR1,  8);
1878c2ecf20Sopenharmony_ci	clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "ipg_per", base + MX35_CCM_CGR1, 10);
1888c2ecf20Sopenharmony_ci	clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "ipg_per", base + MX35_CCM_CGR1, 12);
1898c2ecf20Sopenharmony_ci	clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "ipg_per", base + MX35_CCM_CGR1, 14);
1908c2ecf20Sopenharmony_ci	clk[iomuxc_gate] = imx_clk_gate2("iomuxc_gate", "ipg", base + MX35_CCM_CGR1, 16);
1918c2ecf20Sopenharmony_ci	clk[ipu_gate] = imx_clk_gate2("ipu_gate", "hsp", base + MX35_CCM_CGR1, 18);
1928c2ecf20Sopenharmony_ci	clk[kpp_gate] = imx_clk_gate2("kpp_gate", "ipg", base + MX35_CCM_CGR1, 20);
1938c2ecf20Sopenharmony_ci	clk[mlb_gate] = imx_clk_gate2("mlb_gate", "ahb", base + MX35_CCM_CGR1, 22);
1948c2ecf20Sopenharmony_ci	clk[mshc_gate] = imx_clk_gate2("mshc_gate", "dummy", base + MX35_CCM_CGR1, 24);
1958c2ecf20Sopenharmony_ci	clk[owire_gate] = imx_clk_gate2("owire_gate", "ipg_per", base + MX35_CCM_CGR1, 26);
1968c2ecf20Sopenharmony_ci	clk[pwm_gate] = imx_clk_gate2("pwm_gate", "ipg_per", base + MX35_CCM_CGR1, 28);
1978c2ecf20Sopenharmony_ci	clk[rngc_gate] = imx_clk_gate2("rngc_gate", "ipg", base + MX35_CCM_CGR1, 30);
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	clk[rtc_gate] = imx_clk_gate2("rtc_gate", "ipg", base + MX35_CCM_CGR2,  0);
2008c2ecf20Sopenharmony_ci	clk[rtic_gate] = imx_clk_gate2("rtic_gate", "ahb", base + MX35_CCM_CGR2,  2);
2018c2ecf20Sopenharmony_ci	clk[scc_gate] = imx_clk_gate2("scc_gate", "ipg", base + MX35_CCM_CGR2,  4);
2028c2ecf20Sopenharmony_ci	clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ahb", base + MX35_CCM_CGR2,  6);
2038c2ecf20Sopenharmony_ci	clk[spba_gate] = imx_clk_gate2("spba_gate", "ipg", base + MX35_CCM_CGR2,  8);
2048c2ecf20Sopenharmony_ci	clk[spdif_gate] = imx_clk_gate2("spdif_gate", "spdif_div_post", base + MX35_CCM_CGR2, 10);
2058c2ecf20Sopenharmony_ci	clk[ssi1_gate] = imx_clk_gate2("ssi1_gate", "ssi1_div_post", base + MX35_CCM_CGR2, 12);
2068c2ecf20Sopenharmony_ci	clk[ssi2_gate] = imx_clk_gate2("ssi2_gate", "ssi2_div_post", base + MX35_CCM_CGR2, 14);
2078c2ecf20Sopenharmony_ci	clk[uart1_gate] = imx_clk_gate2("uart1_gate", "uart_div", base + MX35_CCM_CGR2, 16);
2088c2ecf20Sopenharmony_ci	clk[uart2_gate] = imx_clk_gate2("uart2_gate", "uart_div", base + MX35_CCM_CGR2, 18);
2098c2ecf20Sopenharmony_ci	clk[uart3_gate] = imx_clk_gate2("uart3_gate", "uart_div", base + MX35_CCM_CGR2, 20);
2108c2ecf20Sopenharmony_ci	clk[usbotg_gate] = imx_clk_gate2("usbotg_gate", "ahb", base + MX35_CCM_CGR2, 22);
2118c2ecf20Sopenharmony_ci	clk[wdog_gate] = imx_clk_gate2("wdog_gate", "ipg", base + MX35_CCM_CGR2, 24);
2128c2ecf20Sopenharmony_ci	clk[max_gate] = imx_clk_gate2("max_gate", "dummy", base + MX35_CCM_CGR2, 26);
2138c2ecf20Sopenharmony_ci	clk[admux_gate] = imx_clk_gate2("admux_gate", "ipg", base + MX35_CCM_CGR2, 30);
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	clk[csi_gate] = imx_clk_gate2("csi_gate", "csi_div", base + MX35_CCM_CGR3,  0);
2168c2ecf20Sopenharmony_ci	clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", base + MX35_CCM_CGR3,  2);
2178c2ecf20Sopenharmony_ci	clk[gpu2d_gate] = imx_clk_gate2("gpu2d_gate", "ahb", base + MX35_CCM_CGR3,  4);
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	imx_check_clocks(clk, ARRAY_SIZE(clk));
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[spba_gate]);
2228c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[gpio1_gate]);
2238c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[gpio2_gate]);
2248c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[gpio3_gate]);
2258c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[iim_gate]);
2268c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[emi_gate]);
2278c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[max_gate]);
2288c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[iomuxc_gate]);
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	/*
2318c2ecf20Sopenharmony_ci	 * SCC is needed to boot via mmc after a watchdog reset. The clock code
2328c2ecf20Sopenharmony_ci	 * before conversion to common clk also enabled UART1 (which isn't
2338c2ecf20Sopenharmony_ci	 * handled here and not needed for mmc) and IIM (which is enabled
2348c2ecf20Sopenharmony_ci	 * unconditionally above).
2358c2ecf20Sopenharmony_ci	 */
2368c2ecf20Sopenharmony_ci	clk_prepare_enable(clk[scc_gate]);
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	imx_register_uart_clocks(4);
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci	imx_print_silicon_rev("i.MX35", mx35_revision());
2418c2ecf20Sopenharmony_ci}
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic void __init mx35_clocks_init_dt(struct device_node *ccm_node)
2448c2ecf20Sopenharmony_ci{
2458c2ecf20Sopenharmony_ci	_mx35_clocks_init();
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	clk_data.clks = clk;
2488c2ecf20Sopenharmony_ci	clk_data.clk_num = ARRAY_SIZE(clk);
2498c2ecf20Sopenharmony_ci	of_clk_add_provider(ccm_node, of_clk_src_onecell_get, &clk_data);
2508c2ecf20Sopenharmony_ci}
2518c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx35, "fsl,imx35-ccm", mx35_clocks_init_dt);
252