18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2012 Freescale Semiconductor, Inc. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/clk/mxs.h> 78c2ecf20Sopenharmony_ci#include <linux/clkdev.h> 88c2ecf20Sopenharmony_ci#include <linux/clk.h> 98c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 108c2ecf20Sopenharmony_ci#include <linux/err.h> 118c2ecf20Sopenharmony_ci#include <linux/init.h> 128c2ecf20Sopenharmony_ci#include <linux/io.h> 138c2ecf20Sopenharmony_ci#include <linux/of.h> 148c2ecf20Sopenharmony_ci#include <linux/of_address.h> 158c2ecf20Sopenharmony_ci#include "clk.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistatic void __iomem *clkctrl; 188c2ecf20Sopenharmony_ci#define CLKCTRL clkctrl 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define PLL0CTRL0 (CLKCTRL + 0x0000) 218c2ecf20Sopenharmony_ci#define PLL1CTRL0 (CLKCTRL + 0x0020) 228c2ecf20Sopenharmony_ci#define PLL2CTRL0 (CLKCTRL + 0x0040) 238c2ecf20Sopenharmony_ci#define CPU (CLKCTRL + 0x0050) 248c2ecf20Sopenharmony_ci#define HBUS (CLKCTRL + 0x0060) 258c2ecf20Sopenharmony_ci#define XBUS (CLKCTRL + 0x0070) 268c2ecf20Sopenharmony_ci#define XTAL (CLKCTRL + 0x0080) 278c2ecf20Sopenharmony_ci#define SSP0 (CLKCTRL + 0x0090) 288c2ecf20Sopenharmony_ci#define SSP1 (CLKCTRL + 0x00a0) 298c2ecf20Sopenharmony_ci#define SSP2 (CLKCTRL + 0x00b0) 308c2ecf20Sopenharmony_ci#define SSP3 (CLKCTRL + 0x00c0) 318c2ecf20Sopenharmony_ci#define GPMI (CLKCTRL + 0x00d0) 328c2ecf20Sopenharmony_ci#define SPDIF (CLKCTRL + 0x00e0) 338c2ecf20Sopenharmony_ci#define EMI (CLKCTRL + 0x00f0) 348c2ecf20Sopenharmony_ci#define SAIF0 (CLKCTRL + 0x0100) 358c2ecf20Sopenharmony_ci#define SAIF1 (CLKCTRL + 0x0110) 368c2ecf20Sopenharmony_ci#define LCDIF (CLKCTRL + 0x0120) 378c2ecf20Sopenharmony_ci#define ETM (CLKCTRL + 0x0130) 388c2ecf20Sopenharmony_ci#define ENET (CLKCTRL + 0x0140) 398c2ecf20Sopenharmony_ci#define FLEXCAN (CLKCTRL + 0x0160) 408c2ecf20Sopenharmony_ci#define FRAC0 (CLKCTRL + 0x01b0) 418c2ecf20Sopenharmony_ci#define FRAC1 (CLKCTRL + 0x01c0) 428c2ecf20Sopenharmony_ci#define CLKSEQ (CLKCTRL + 0x01d0) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define BP_CPU_INTERRUPT_WAIT 12 458c2ecf20Sopenharmony_ci#define BP_SAIF_DIV_FRAC_EN 16 468c2ecf20Sopenharmony_ci#define BP_ENET_DIV_TIME 21 478c2ecf20Sopenharmony_ci#define BP_ENET_SLEEP 31 488c2ecf20Sopenharmony_ci#define BP_CLKSEQ_BYPASS_SAIF0 0 498c2ecf20Sopenharmony_ci#define BP_CLKSEQ_BYPASS_SSP0 3 508c2ecf20Sopenharmony_ci#define BP_FRAC0_IO1FRAC 16 518c2ecf20Sopenharmony_ci#define BP_FRAC0_IO0FRAC 24 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic void __iomem *digctrl; 548c2ecf20Sopenharmony_ci#define DIGCTRL digctrl 558c2ecf20Sopenharmony_ci#define BP_SAIF_CLKMUX 10 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* 588c2ecf20Sopenharmony_ci * HW_SAIF_CLKMUX_SEL: 598c2ecf20Sopenharmony_ci * DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and SAIF1 608c2ecf20Sopenharmony_ci * clock pins selected for SAIF1 input clocks. 618c2ecf20Sopenharmony_ci * CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input clocks, and 628c2ecf20Sopenharmony_ci * SAIF0 clock inputs selected for SAIF1 input clocks. 638c2ecf20Sopenharmony_ci * EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 input 648c2ecf20Sopenharmony_ci * clocks. 658c2ecf20Sopenharmony_ci * EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 input 668c2ecf20Sopenharmony_ci * clocks. 678c2ecf20Sopenharmony_ci */ 688c2ecf20Sopenharmony_ciint mxs_saif_clkmux_select(unsigned int clkmux) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci if (clkmux > 0x3) 718c2ecf20Sopenharmony_ci return -EINVAL; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci writel_relaxed(0x3 << BP_SAIF_CLKMUX, DIGCTRL + CLR); 748c2ecf20Sopenharmony_ci writel_relaxed(clkmux << BP_SAIF_CLKMUX, DIGCTRL + SET); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci return 0; 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistatic void __init clk_misc_init(void) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci u32 val; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci /* Gate off cpu clock in WFI for power saving */ 848c2ecf20Sopenharmony_ci writel_relaxed(1 << BP_CPU_INTERRUPT_WAIT, CPU + SET); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci /* 0 is a bad default value for a divider */ 878c2ecf20Sopenharmony_ci writel_relaxed(1 << BP_ENET_DIV_TIME, ENET + SET); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci /* Clear BYPASS for SAIF */ 908c2ecf20Sopenharmony_ci writel_relaxed(0x3 << BP_CLKSEQ_BYPASS_SAIF0, CLKSEQ + CLR); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci /* SAIF has to use frac div for functional operation */ 938c2ecf20Sopenharmony_ci val = readl_relaxed(SAIF0); 948c2ecf20Sopenharmony_ci val |= 1 << BP_SAIF_DIV_FRAC_EN; 958c2ecf20Sopenharmony_ci writel_relaxed(val, SAIF0); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci val = readl_relaxed(SAIF1); 988c2ecf20Sopenharmony_ci val |= 1 << BP_SAIF_DIV_FRAC_EN; 998c2ecf20Sopenharmony_ci writel_relaxed(val, SAIF1); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci /* Extra fec clock setting */ 1028c2ecf20Sopenharmony_ci val = readl_relaxed(ENET); 1038c2ecf20Sopenharmony_ci val &= ~(1 << BP_ENET_SLEEP); 1048c2ecf20Sopenharmony_ci writel_relaxed(val, ENET); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci /* 1078c2ecf20Sopenharmony_ci * Source ssp clock from ref_io than ref_xtal, 1088c2ecf20Sopenharmony_ci * as ref_xtal only provides 24 MHz as maximum. 1098c2ecf20Sopenharmony_ci */ 1108c2ecf20Sopenharmony_ci writel_relaxed(0xf << BP_CLKSEQ_BYPASS_SSP0, CLKSEQ + CLR); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci /* 1138c2ecf20Sopenharmony_ci * 480 MHz seems too high to be ssp clock source directly, 1148c2ecf20Sopenharmony_ci * so set frac0 to get a 288 MHz ref_io0 and ref_io1. 1158c2ecf20Sopenharmony_ci */ 1168c2ecf20Sopenharmony_ci val = readl_relaxed(FRAC0); 1178c2ecf20Sopenharmony_ci val &= ~((0x3f << BP_FRAC0_IO0FRAC) | (0x3f << BP_FRAC0_IO1FRAC)); 1188c2ecf20Sopenharmony_ci val |= (30 << BP_FRAC0_IO0FRAC) | (30 << BP_FRAC0_IO1FRAC); 1198c2ecf20Sopenharmony_ci writel_relaxed(val, FRAC0); 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistatic const char *const sel_cpu[] __initconst = { "ref_cpu", "ref_xtal", }; 1238c2ecf20Sopenharmony_cistatic const char *const sel_io0[] __initconst = { "ref_io0", "ref_xtal", }; 1248c2ecf20Sopenharmony_cistatic const char *const sel_io1[] __initconst = { "ref_io1", "ref_xtal", }; 1258c2ecf20Sopenharmony_cistatic const char *const sel_pix[] __initconst = { "ref_pix", "ref_xtal", }; 1268c2ecf20Sopenharmony_cistatic const char *const sel_gpmi[] __initconst = { "ref_gpmi", "ref_xtal", }; 1278c2ecf20Sopenharmony_cistatic const char *const sel_pll0[] __initconst = { "pll0", "ref_xtal", }; 1288c2ecf20Sopenharmony_cistatic const char *const cpu_sels[] __initconst = { "cpu_pll", "cpu_xtal", }; 1298c2ecf20Sopenharmony_cistatic const char *const emi_sels[] __initconst = { "emi_pll", "emi_xtal", }; 1308c2ecf20Sopenharmony_cistatic const char *const ptp_sels[] __initconst = { "ref_xtal", "pll0", }; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cienum imx28_clk { 1338c2ecf20Sopenharmony_ci ref_xtal, pll0, pll1, pll2, ref_cpu, ref_emi, ref_io0, ref_io1, 1348c2ecf20Sopenharmony_ci ref_pix, ref_hsadc, ref_gpmi, saif0_sel, saif1_sel, gpmi_sel, 1358c2ecf20Sopenharmony_ci ssp0_sel, ssp1_sel, ssp2_sel, ssp3_sel, emi_sel, etm_sel, 1368c2ecf20Sopenharmony_ci lcdif_sel, cpu, ptp_sel, cpu_pll, cpu_xtal, hbus, xbus, 1378c2ecf20Sopenharmony_ci ssp0_div, ssp1_div, ssp2_div, ssp3_div, gpmi_div, emi_pll, 1388c2ecf20Sopenharmony_ci emi_xtal, lcdif_div, etm_div, ptp, saif0_div, saif1_div, 1398c2ecf20Sopenharmony_ci clk32k_div, rtc, lradc, spdif_div, clk32k, pwm, uart, ssp0, 1408c2ecf20Sopenharmony_ci ssp1, ssp2, ssp3, gpmi, spdif, emi, saif0, saif1, lcdif, etm, 1418c2ecf20Sopenharmony_ci fec, can0, can1, usb0, usb1, usb0_phy, usb1_phy, enet_out, 1428c2ecf20Sopenharmony_ci clk_max 1438c2ecf20Sopenharmony_ci}; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cistatic struct clk *clks[clk_max]; 1468c2ecf20Sopenharmony_cistatic struct clk_onecell_data clk_data; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_cistatic enum imx28_clk clks_init_on[] __initdata = { 1498c2ecf20Sopenharmony_ci cpu, hbus, xbus, emi, uart, 1508c2ecf20Sopenharmony_ci}; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistatic void __init mx28_clocks_init(struct device_node *np) 1538c2ecf20Sopenharmony_ci{ 1548c2ecf20Sopenharmony_ci struct device_node *dcnp; 1558c2ecf20Sopenharmony_ci u32 i; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci dcnp = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl"); 1588c2ecf20Sopenharmony_ci digctrl = of_iomap(dcnp, 0); 1598c2ecf20Sopenharmony_ci WARN_ON(!digctrl); 1608c2ecf20Sopenharmony_ci of_node_put(dcnp); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci clkctrl = of_iomap(np, 0); 1638c2ecf20Sopenharmony_ci WARN_ON(!clkctrl); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci clk_misc_init(); 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000); 1688c2ecf20Sopenharmony_ci clks[pll0] = mxs_clk_pll("pll0", "ref_xtal", PLL0CTRL0, 17, 480000000); 1698c2ecf20Sopenharmony_ci clks[pll1] = mxs_clk_pll("pll1", "ref_xtal", PLL1CTRL0, 17, 480000000); 1708c2ecf20Sopenharmony_ci clks[pll2] = mxs_clk_pll("pll2", "ref_xtal", PLL2CTRL0, 23, 50000000); 1718c2ecf20Sopenharmony_ci clks[ref_cpu] = mxs_clk_ref("ref_cpu", "pll0", FRAC0, 0); 1728c2ecf20Sopenharmony_ci clks[ref_emi] = mxs_clk_ref("ref_emi", "pll0", FRAC0, 1); 1738c2ecf20Sopenharmony_ci clks[ref_io1] = mxs_clk_ref("ref_io1", "pll0", FRAC0, 2); 1748c2ecf20Sopenharmony_ci clks[ref_io0] = mxs_clk_ref("ref_io0", "pll0", FRAC0, 3); 1758c2ecf20Sopenharmony_ci clks[ref_pix] = mxs_clk_ref("ref_pix", "pll0", FRAC1, 0); 1768c2ecf20Sopenharmony_ci clks[ref_hsadc] = mxs_clk_ref("ref_hsadc", "pll0", FRAC1, 1); 1778c2ecf20Sopenharmony_ci clks[ref_gpmi] = mxs_clk_ref("ref_gpmi", "pll0", FRAC1, 2); 1788c2ecf20Sopenharmony_ci clks[saif0_sel] = mxs_clk_mux("saif0_sel", CLKSEQ, 0, 1, sel_pll0, ARRAY_SIZE(sel_pll0)); 1798c2ecf20Sopenharmony_ci clks[saif1_sel] = mxs_clk_mux("saif1_sel", CLKSEQ, 1, 1, sel_pll0, ARRAY_SIZE(sel_pll0)); 1808c2ecf20Sopenharmony_ci clks[gpmi_sel] = mxs_clk_mux("gpmi_sel", CLKSEQ, 2, 1, sel_gpmi, ARRAY_SIZE(sel_gpmi)); 1818c2ecf20Sopenharmony_ci clks[ssp0_sel] = mxs_clk_mux("ssp0_sel", CLKSEQ, 3, 1, sel_io0, ARRAY_SIZE(sel_io0)); 1828c2ecf20Sopenharmony_ci clks[ssp1_sel] = mxs_clk_mux("ssp1_sel", CLKSEQ, 4, 1, sel_io0, ARRAY_SIZE(sel_io0)); 1838c2ecf20Sopenharmony_ci clks[ssp2_sel] = mxs_clk_mux("ssp2_sel", CLKSEQ, 5, 1, sel_io1, ARRAY_SIZE(sel_io1)); 1848c2ecf20Sopenharmony_ci clks[ssp3_sel] = mxs_clk_mux("ssp3_sel", CLKSEQ, 6, 1, sel_io1, ARRAY_SIZE(sel_io1)); 1858c2ecf20Sopenharmony_ci clks[emi_sel] = mxs_clk_mux("emi_sel", CLKSEQ, 7, 1, emi_sels, ARRAY_SIZE(emi_sels)); 1868c2ecf20Sopenharmony_ci clks[etm_sel] = mxs_clk_mux("etm_sel", CLKSEQ, 8, 1, sel_cpu, ARRAY_SIZE(sel_cpu)); 1878c2ecf20Sopenharmony_ci clks[lcdif_sel] = mxs_clk_mux("lcdif_sel", CLKSEQ, 14, 1, sel_pix, ARRAY_SIZE(sel_pix)); 1888c2ecf20Sopenharmony_ci clks[cpu] = mxs_clk_mux("cpu", CLKSEQ, 18, 1, cpu_sels, ARRAY_SIZE(cpu_sels)); 1898c2ecf20Sopenharmony_ci clks[ptp_sel] = mxs_clk_mux("ptp_sel", ENET, 19, 1, ptp_sels, ARRAY_SIZE(ptp_sels)); 1908c2ecf20Sopenharmony_ci clks[cpu_pll] = mxs_clk_div("cpu_pll", "ref_cpu", CPU, 0, 6, 28); 1918c2ecf20Sopenharmony_ci clks[cpu_xtal] = mxs_clk_div("cpu_xtal", "ref_xtal", CPU, 16, 10, 29); 1928c2ecf20Sopenharmony_ci clks[hbus] = mxs_clk_div("hbus", "cpu", HBUS, 0, 5, 31); 1938c2ecf20Sopenharmony_ci clks[xbus] = mxs_clk_div("xbus", "ref_xtal", XBUS, 0, 10, 31); 1948c2ecf20Sopenharmony_ci clks[ssp0_div] = mxs_clk_div("ssp0_div", "ssp0_sel", SSP0, 0, 9, 29); 1958c2ecf20Sopenharmony_ci clks[ssp1_div] = mxs_clk_div("ssp1_div", "ssp1_sel", SSP1, 0, 9, 29); 1968c2ecf20Sopenharmony_ci clks[ssp2_div] = mxs_clk_div("ssp2_div", "ssp2_sel", SSP2, 0, 9, 29); 1978c2ecf20Sopenharmony_ci clks[ssp3_div] = mxs_clk_div("ssp3_div", "ssp3_sel", SSP3, 0, 9, 29); 1988c2ecf20Sopenharmony_ci clks[gpmi_div] = mxs_clk_div("gpmi_div", "gpmi_sel", GPMI, 0, 10, 29); 1998c2ecf20Sopenharmony_ci clks[emi_pll] = mxs_clk_div("emi_pll", "ref_emi", EMI, 0, 6, 28); 2008c2ecf20Sopenharmony_ci clks[emi_xtal] = mxs_clk_div("emi_xtal", "ref_xtal", EMI, 8, 4, 29); 2018c2ecf20Sopenharmony_ci clks[lcdif_div] = mxs_clk_div("lcdif_div", "lcdif_sel", LCDIF, 0, 13, 29); 2028c2ecf20Sopenharmony_ci clks[etm_div] = mxs_clk_div("etm_div", "etm_sel", ETM, 0, 7, 29); 2038c2ecf20Sopenharmony_ci clks[ptp] = mxs_clk_div("ptp", "ptp_sel", ENET, 21, 6, 27); 2048c2ecf20Sopenharmony_ci clks[saif0_div] = mxs_clk_frac("saif0_div", "saif0_sel", SAIF0, 0, 16, 29); 2058c2ecf20Sopenharmony_ci clks[saif1_div] = mxs_clk_frac("saif1_div", "saif1_sel", SAIF1, 0, 16, 29); 2068c2ecf20Sopenharmony_ci clks[clk32k_div] = mxs_clk_fixed_factor("clk32k_div", "ref_xtal", 1, 750); 2078c2ecf20Sopenharmony_ci clks[rtc] = mxs_clk_fixed_factor("rtc", "ref_xtal", 1, 768); 2088c2ecf20Sopenharmony_ci clks[lradc] = mxs_clk_fixed_factor("lradc", "clk32k", 1, 16); 2098c2ecf20Sopenharmony_ci clks[spdif_div] = mxs_clk_fixed_factor("spdif_div", "pll0", 1, 4); 2108c2ecf20Sopenharmony_ci clks[clk32k] = mxs_clk_gate("clk32k", "clk32k_div", XTAL, 26); 2118c2ecf20Sopenharmony_ci clks[pwm] = mxs_clk_gate("pwm", "ref_xtal", XTAL, 29); 2128c2ecf20Sopenharmony_ci clks[uart] = mxs_clk_gate("uart", "ref_xtal", XTAL, 31); 2138c2ecf20Sopenharmony_ci clks[ssp0] = mxs_clk_gate("ssp0", "ssp0_div", SSP0, 31); 2148c2ecf20Sopenharmony_ci clks[ssp1] = mxs_clk_gate("ssp1", "ssp1_div", SSP1, 31); 2158c2ecf20Sopenharmony_ci clks[ssp2] = mxs_clk_gate("ssp2", "ssp2_div", SSP2, 31); 2168c2ecf20Sopenharmony_ci clks[ssp3] = mxs_clk_gate("ssp3", "ssp3_div", SSP3, 31); 2178c2ecf20Sopenharmony_ci clks[gpmi] = mxs_clk_gate("gpmi", "gpmi_div", GPMI, 31); 2188c2ecf20Sopenharmony_ci clks[spdif] = mxs_clk_gate("spdif", "spdif_div", SPDIF, 31); 2198c2ecf20Sopenharmony_ci clks[emi] = mxs_clk_gate("emi", "emi_sel", EMI, 31); 2208c2ecf20Sopenharmony_ci clks[saif0] = mxs_clk_gate("saif0", "saif0_div", SAIF0, 31); 2218c2ecf20Sopenharmony_ci clks[saif1] = mxs_clk_gate("saif1", "saif1_div", SAIF1, 31); 2228c2ecf20Sopenharmony_ci clks[lcdif] = mxs_clk_gate("lcdif", "lcdif_div", LCDIF, 31); 2238c2ecf20Sopenharmony_ci clks[etm] = mxs_clk_gate("etm", "etm_div", ETM, 31); 2248c2ecf20Sopenharmony_ci clks[fec] = mxs_clk_gate("fec", "hbus", ENET, 30); 2258c2ecf20Sopenharmony_ci clks[can0] = mxs_clk_gate("can0", "ref_xtal", FLEXCAN, 30); 2268c2ecf20Sopenharmony_ci clks[can1] = mxs_clk_gate("can1", "ref_xtal", FLEXCAN, 28); 2278c2ecf20Sopenharmony_ci clks[usb0] = mxs_clk_gate("usb0", "usb0_phy", DIGCTRL, 2); 2288c2ecf20Sopenharmony_ci clks[usb1] = mxs_clk_gate("usb1", "usb1_phy", DIGCTRL, 16); 2298c2ecf20Sopenharmony_ci clks[usb0_phy] = clk_register_gate(NULL, "usb0_phy", "pll0", 0, PLL0CTRL0, 18, 0, &mxs_lock); 2308c2ecf20Sopenharmony_ci clks[usb1_phy] = clk_register_gate(NULL, "usb1_phy", "pll1", 0, PLL1CTRL0, 18, 0, &mxs_lock); 2318c2ecf20Sopenharmony_ci clks[enet_out] = clk_register_gate(NULL, "enet_out", "pll2", 0, ENET, 18, 0, &mxs_lock); 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(clks); i++) 2348c2ecf20Sopenharmony_ci if (IS_ERR(clks[i])) { 2358c2ecf20Sopenharmony_ci pr_err("i.MX28 clk %d: register failed with %ld\n", 2368c2ecf20Sopenharmony_ci i, PTR_ERR(clks[i])); 2378c2ecf20Sopenharmony_ci return; 2388c2ecf20Sopenharmony_ci } 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci clk_data.clks = clks; 2418c2ecf20Sopenharmony_ci clk_data.clk_num = ARRAY_SIZE(clks); 2428c2ecf20Sopenharmony_ci of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci clk_register_clkdev(clks[enet_out], NULL, "enet_out"); 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) 2478c2ecf20Sopenharmony_ci clk_prepare_enable(clks[clks_init_on[i]]); 2488c2ecf20Sopenharmony_ci} 2498c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx28_clkctrl, "fsl,imx28-clkctrl", mx28_clocks_init); 250