18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2016 Freescale Semiconductor, Inc. 48c2ecf20Sopenharmony_ci * Copyright 2017~2018 NXP 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Author: Dong Aisheng <aisheng.dong@nxp.com> 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <dt-bindings/clock/imx7ulp-clock.h> 118c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 128c2ecf20Sopenharmony_ci#include <linux/err.h> 138c2ecf20Sopenharmony_ci#include <linux/init.h> 148c2ecf20Sopenharmony_ci#include <linux/io.h> 158c2ecf20Sopenharmony_ci#include <linux/of.h> 168c2ecf20Sopenharmony_ci#include <linux/of_address.h> 178c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 188c2ecf20Sopenharmony_ci#include <linux/slab.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include "clk.h" 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic const char * const pll_pre_sels[] = { "sosc", "firc", }; 238c2ecf20Sopenharmony_cistatic const char * const spll_pfd_sels[] = { "spll_pfd0", "spll_pfd1", "spll_pfd2", "spll_pfd3", }; 248c2ecf20Sopenharmony_cistatic const char * const spll_sels[] = { "spll", "spll_pfd_sel", }; 258c2ecf20Sopenharmony_cistatic const char * const apll_pfd_sels[] = { "apll_pfd0", "apll_pfd1", "apll_pfd2", "apll_pfd3", }; 268c2ecf20Sopenharmony_cistatic const char * const apll_sels[] = { "apll", "apll_pfd_sel", }; 278c2ecf20Sopenharmony_cistatic const char * const scs_sels[] = { "dummy", "sosc", "sirc", "firc", "dummy", "apll_sel", "spll_sel", "dummy", }; 288c2ecf20Sopenharmony_cistatic const char * const ddr_sels[] = { "apll_pfd_sel", "dummy", "dummy", "dummy", }; 298c2ecf20Sopenharmony_cistatic const char * const nic_sels[] = { "firc", "ddr_clk", }; 308c2ecf20Sopenharmony_cistatic const char * const periph_plat_sels[] = { "dummy", "nic1_bus_clk", "nic1_clk", "ddr_clk", "apll_pfd2", "apll_pfd1", "apll_pfd0", "upll", }; 318c2ecf20Sopenharmony_cistatic const char * const periph_bus_sels[] = { "dummy", "sosc_bus_clk", "dummy", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", "spll_bus_clk", }; 328c2ecf20Sopenharmony_cistatic const char * const arm_sels[] = { "core", "dummy", "dummy", "hsrun_core", }; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* used by sosc/sirc/firc/ddr/spll/apll dividers */ 358c2ecf20Sopenharmony_cistatic const struct clk_div_table ulp_div_table[] = { 368c2ecf20Sopenharmony_ci { .val = 1, .div = 1, }, 378c2ecf20Sopenharmony_ci { .val = 2, .div = 2, }, 388c2ecf20Sopenharmony_ci { .val = 3, .div = 4, }, 398c2ecf20Sopenharmony_ci { .val = 4, .div = 8, }, 408c2ecf20Sopenharmony_ci { .val = 5, .div = 16, }, 418c2ecf20Sopenharmony_ci { .val = 6, .div = 32, }, 428c2ecf20Sopenharmony_ci { .val = 7, .div = 64, }, 438c2ecf20Sopenharmony_ci { /* sentinel */ }, 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic void __init imx7ulp_clk_scg1_init(struct device_node *np) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 498c2ecf20Sopenharmony_ci struct clk_hw **hws; 508c2ecf20Sopenharmony_ci void __iomem *base; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci clk_data = kzalloc(struct_size(clk_data, hws, IMX7ULP_CLK_SCG1_END), 538c2ecf20Sopenharmony_ci GFP_KERNEL); 548c2ecf20Sopenharmony_ci if (!clk_data) 558c2ecf20Sopenharmony_ci return; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci clk_data->num = IMX7ULP_CLK_SCG1_END; 588c2ecf20Sopenharmony_ci hws = clk_data->hws; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_DUMMY] = imx_clk_hw_fixed("dummy", 0); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_ROSC] = imx_obtain_fixed_clk_hw(np, "rosc"); 638c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SOSC] = imx_obtain_fixed_clk_hw(np, "sosc"); 648c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SIRC] = imx_obtain_fixed_clk_hw(np, "sirc"); 658c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_FIRC] = imx_obtain_fixed_clk_hw(np, "firc"); 668c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_UPLL] = imx_obtain_fixed_clk_hw(np, "upll"); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci /* SCG1 */ 698c2ecf20Sopenharmony_ci base = of_iomap(np, 0); 708c2ecf20Sopenharmony_ci WARN_ON(!base); 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci /* NOTE: xPLL config can't be changed when xPLL is enabled */ 738c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_PRE_SEL] = imx_clk_hw_mux_flags("apll_pre_sel", base + 0x508, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); 748c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_PRE_SEL] = imx_clk_hw_mux_flags("spll_pre_sel", base + 0x608, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci /* name parent_name reg shift width flags */ 778c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_PRE_DIV] = imx_clk_hw_divider_flags("apll_pre_div", "apll_pre_sel", base + 0x508, 8, 3, CLK_SET_RATE_GATE); 788c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_PRE_DIV] = imx_clk_hw_divider_flags("spll_pre_div", "spll_pre_sel", base + 0x608, 8, 3, CLK_SET_RATE_GATE); 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci /* name parent_name base */ 818c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL] = imx_clk_hw_pllv4("apll", "apll_pre_div", base + 0x500); 828c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL] = imx_clk_hw_pllv4("spll", "spll_pre_div", base + 0x600); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci /* APLL PFDs */ 858c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_PFD0] = imx_clk_hw_pfdv2("apll_pfd0", "apll", base + 0x50c, 0); 868c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_PFD1] = imx_clk_hw_pfdv2("apll_pfd1", "apll", base + 0x50c, 1); 878c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_PFD2] = imx_clk_hw_pfdv2("apll_pfd2", "apll", base + 0x50c, 2); 888c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_PFD3] = imx_clk_hw_pfdv2("apll_pfd3", "apll", base + 0x50c, 3); 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci /* SPLL PFDs */ 918c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_PFD0] = imx_clk_hw_pfdv2("spll_pfd0", "spll", base + 0x60C, 0); 928c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_PFD1] = imx_clk_hw_pfdv2("spll_pfd1", "spll", base + 0x60C, 1); 938c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_PFD2] = imx_clk_hw_pfdv2("spll_pfd2", "spll", base + 0x60C, 2); 948c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_PFD3] = imx_clk_hw_pfdv2("spll_pfd3", "spll", base + 0x60C, 3); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci /* PLL Mux */ 978c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_PFD_SEL] = imx_clk_hw_mux_flags("apll_pfd_sel", base + 0x508, 14, 2, apll_pfd_sels, ARRAY_SIZE(apll_pfd_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); 988c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_PFD_SEL] = imx_clk_hw_mux_flags("spll_pfd_sel", base + 0x608, 14, 2, spll_pfd_sels, ARRAY_SIZE(spll_pfd_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); 998c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_APLL_SEL] = imx_clk_hw_mux_flags("apll_sel", base + 0x508, 1, 1, apll_sels, ARRAY_SIZE(apll_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); 1008c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_SEL] = imx_clk_hw_mux_flags("spll_sel", base + 0x608, 1, 1, spll_sels, ARRAY_SIZE(spll_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SPLL_BUS_CLK] = imx_clk_hw_divider_gate("spll_bus_clk", "spll_sel", CLK_SET_RATE_GATE, base + 0x604, 8, 3, 0, ulp_div_table, &imx_ccm_lock); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci /* scs/ddr/nic select different clock source requires that clock to be enabled first */ 1058c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SYS_SEL] = imx_clk_hw_mux2("scs_sel", base + 0x14, 24, 4, scs_sels, ARRAY_SIZE(scs_sels)); 1068c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_HSRUN_SYS_SEL] = imx_clk_hw_mux2("hsrun_scs_sel", base + 0x1c, 24, 4, scs_sels, ARRAY_SIZE(scs_sels)); 1078c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_NIC_SEL] = imx_clk_hw_mux2("nic_sel", base + 0x40, 28, 1, nic_sels, ARRAY_SIZE(nic_sels)); 1088c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_DDR_SEL] = imx_clk_hw_mux_flags("ddr_sel", base + 0x30, 24, 2, ddr_sels, ARRAY_SIZE(ddr_sels), CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_CORE_DIV] = imx_clk_hw_divider_flags("divcore", "scs_sel", base + 0x14, 16, 4, CLK_SET_RATE_PARENT); 1118c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_CORE] = imx_clk_hw_cpu("core", "divcore", hws[IMX7ULP_CLK_CORE_DIV]->clk, hws[IMX7ULP_CLK_SYS_SEL]->clk, hws[IMX7ULP_CLK_SPLL_SEL]->clk, hws[IMX7ULP_CLK_FIRC]->clk); 1128c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_HSRUN_CORE_DIV] = imx_clk_hw_divider_flags("hsrun_divcore", "hsrun_scs_sel", base + 0x1c, 16, 4, CLK_SET_RATE_PARENT); 1138c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_HSRUN_CORE] = imx_clk_hw_cpu("hsrun_core", "hsrun_divcore", hws[IMX7ULP_CLK_HSRUN_CORE_DIV]->clk, hws[IMX7ULP_CLK_HSRUN_SYS_SEL]->clk, hws[IMX7ULP_CLK_SPLL_SEL]->clk, hws[IMX7ULP_CLK_FIRC]->clk); 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_DDR_DIV] = imx_clk_hw_divider_gate("ddr_clk", "ddr_sel", CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, base + 0x30, 0, 3, 1168c2ecf20Sopenharmony_ci 0, ulp_div_table, &imx_ccm_lock); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_NIC0_DIV] = imx_clk_hw_divider_flags("nic0_clk", "nic_sel", base + 0x40, 24, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 1198c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_NIC1_DIV] = imx_clk_hw_divider_flags("nic1_clk", "nic0_clk", base + 0x40, 16, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 1208c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_NIC1_BUS_DIV] = imx_clk_hw_divider_flags("nic1_bus_clk", "nic0_clk", base + 0x40, 4, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_GPU_DIV] = imx_clk_hw_divider("gpu_clk", "nic0_clk", base + 0x40, 20, 4); 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_SOSC_BUS_CLK] = imx_clk_hw_divider_gate("sosc_bus_clk", "sosc", 0, base + 0x104, 8, 3, 1258c2ecf20Sopenharmony_ci CLK_DIVIDER_READ_ONLY, ulp_div_table, &imx_ccm_lock); 1268c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_FIRC_BUS_CLK] = imx_clk_hw_divider_gate("firc_bus_clk", "firc", 0, base + 0x304, 8, 3, 1278c2ecf20Sopenharmony_ci CLK_DIVIDER_READ_ONLY, ulp_div_table, &imx_ccm_lock); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci imx_check_clk_hws(hws, clk_data->num); 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); 1328c2ecf20Sopenharmony_ci} 1338c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx7ulp_clk_scg1, "fsl,imx7ulp-scg1", imx7ulp_clk_scg1_init); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cistatic void __init imx7ulp_clk_pcc2_init(struct device_node *np) 1368c2ecf20Sopenharmony_ci{ 1378c2ecf20Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 1388c2ecf20Sopenharmony_ci struct clk_hw **hws; 1398c2ecf20Sopenharmony_ci void __iomem *base; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci clk_data = kzalloc(struct_size(clk_data, hws, IMX7ULP_CLK_PCC2_END), 1428c2ecf20Sopenharmony_ci GFP_KERNEL); 1438c2ecf20Sopenharmony_ci if (!clk_data) 1448c2ecf20Sopenharmony_ci return; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci clk_data->num = IMX7ULP_CLK_PCC2_END; 1478c2ecf20Sopenharmony_ci hws = clk_data->hws; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci /* PCC2 */ 1508c2ecf20Sopenharmony_ci base = of_iomap(np, 0); 1518c2ecf20Sopenharmony_ci WARN_ON(!base); 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_DMA1] = imx_clk_hw_gate("dma1", "nic1_clk", base + 0x20, 30); 1548c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_RGPIO2P1] = imx_clk_hw_gate("rgpio2p1", "nic1_bus_clk", base + 0x3c, 30); 1558c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_DMA_MUX1] = imx_clk_hw_gate("dma_mux1", "nic1_bus_clk", base + 0x84, 30); 1568c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_CAAM] = imx_clk_hw_gate("caam", "nic1_clk", base + 0x90, 30); 1578c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPTPM4] = imx7ulp_clk_hw_composite("lptpm4", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x94); 1588c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPTPM5] = imx7ulp_clk_hw_composite("lptpm5", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x98); 1598c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPIT1] = imx7ulp_clk_hw_composite("lpit1", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x9c); 1608c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPSPI2] = imx7ulp_clk_hw_composite("lpspi2", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xa4); 1618c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPSPI3] = imx7ulp_clk_hw_composite("lpspi3", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xa8); 1628c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPI2C4] = imx7ulp_clk_hw_composite("lpi2c4", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xac); 1638c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPI2C5] = imx7ulp_clk_hw_composite("lpi2c5", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xb0); 1648c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPUART4] = imx7ulp_clk_hw_composite("lpuart4", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xb4); 1658c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPUART5] = imx7ulp_clk_hw_composite("lpuart5", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xb8); 1668c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_FLEXIO1] = imx7ulp_clk_hw_composite("flexio1", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xc4); 1678c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_USB0] = imx7ulp_clk_hw_composite("usb0", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xcc); 1688c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_USB1] = imx7ulp_clk_hw_composite("usb1", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xd0); 1698c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_USB_PHY] = imx_clk_hw_gate("usb_phy", "nic1_bus_clk", base + 0xd4, 30); 1708c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_USDHC0] = imx7ulp_clk_hw_composite("usdhc0", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xdc); 1718c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_USDHC1] = imx7ulp_clk_hw_composite("usdhc1", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xe0); 1728c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_WDG1] = imx7ulp_clk_hw_composite("wdg1", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, true, true, base + 0xf4); 1738c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_WDG2] = imx7ulp_clk_hw_composite("wdg2", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, true, true, base + 0x10c); 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci imx_check_clk_hws(hws, clk_data->num); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci imx_register_uart_clocks(2); 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx7ulp_clk_pcc2, "fsl,imx7ulp-pcc2", imx7ulp_clk_pcc2_init); 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_cistatic void __init imx7ulp_clk_pcc3_init(struct device_node *np) 1848c2ecf20Sopenharmony_ci{ 1858c2ecf20Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 1868c2ecf20Sopenharmony_ci struct clk_hw **hws; 1878c2ecf20Sopenharmony_ci void __iomem *base; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci clk_data = kzalloc(struct_size(clk_data, hws, IMX7ULP_CLK_PCC3_END), 1908c2ecf20Sopenharmony_ci GFP_KERNEL); 1918c2ecf20Sopenharmony_ci if (!clk_data) 1928c2ecf20Sopenharmony_ci return; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci clk_data->num = IMX7ULP_CLK_PCC3_END; 1958c2ecf20Sopenharmony_ci hws = clk_data->hws; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci /* PCC3 */ 1988c2ecf20Sopenharmony_ci base = of_iomap(np, 0); 1998c2ecf20Sopenharmony_ci WARN_ON(!base); 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPTPM6] = imx7ulp_clk_hw_composite("lptpm6", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x84); 2028c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPTPM7] = imx7ulp_clk_hw_composite("lptpm7", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x88); 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_MMDC] = clk_hw_register_gate(NULL, "mmdc", "nic1_clk", CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, 2058c2ecf20Sopenharmony_ci base + 0xac, 30, 0, &imx_ccm_lock); 2068c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPI2C6] = imx7ulp_clk_hw_composite("lpi2c6", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x90); 2078c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPI2C7] = imx7ulp_clk_hw_composite("lpi2c7", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x94); 2088c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPUART6] = imx7ulp_clk_hw_composite("lpuart6", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x98); 2098c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LPUART7] = imx7ulp_clk_hw_composite("lpuart7", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x9c); 2108c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_DSI] = imx7ulp_clk_hw_composite("dsi", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, true, true, base + 0xa4); 2118c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_LCDIF] = imx7ulp_clk_hw_composite("lcdif", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xa8); 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_VIU] = imx_clk_hw_gate("viu", "nic1_clk", base + 0xa0, 30); 2148c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_PCTLC] = imx_clk_hw_gate("pctlc", "nic1_bus_clk", base + 0xb8, 30); 2158c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_PCTLD] = imx_clk_hw_gate("pctld", "nic1_bus_clk", base + 0xbc, 30); 2168c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_PCTLE] = imx_clk_hw_gate("pctle", "nic1_bus_clk", base + 0xc0, 30); 2178c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_PCTLF] = imx_clk_hw_gate("pctlf", "nic1_bus_clk", base + 0xc4, 30); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_GPU3D] = imx7ulp_clk_hw_composite("gpu3d", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, false, true, base + 0x140); 2208c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_GPU2D] = imx7ulp_clk_hw_composite("gpu2d", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, false, true, base + 0x144); 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci imx_check_clk_hws(hws, clk_data->num); 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci imx_register_uart_clocks(7); 2278c2ecf20Sopenharmony_ci} 2288c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx7ulp_clk_pcc3, "fsl,imx7ulp-pcc3", imx7ulp_clk_pcc3_init); 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_cistatic void __init imx7ulp_clk_smc1_init(struct device_node *np) 2318c2ecf20Sopenharmony_ci{ 2328c2ecf20Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 2338c2ecf20Sopenharmony_ci struct clk_hw **hws; 2348c2ecf20Sopenharmony_ci void __iomem *base; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci clk_data = kzalloc(struct_size(clk_data, hws, IMX7ULP_CLK_SMC1_END), 2378c2ecf20Sopenharmony_ci GFP_KERNEL); 2388c2ecf20Sopenharmony_ci if (!clk_data) 2398c2ecf20Sopenharmony_ci return; 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci clk_data->num = IMX7ULP_CLK_SMC1_END; 2428c2ecf20Sopenharmony_ci hws = clk_data->hws; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci /* SMC1 */ 2458c2ecf20Sopenharmony_ci base = of_iomap(np, 0); 2468c2ecf20Sopenharmony_ci WARN_ON(!base); 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci hws[IMX7ULP_CLK_ARM] = imx_clk_hw_mux_flags("arm", base + 0x10, 8, 2, arm_sels, ARRAY_SIZE(arm_sels), CLK_SET_RATE_PARENT); 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci imx_check_clk_hws(hws, clk_data->num); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); 2538c2ecf20Sopenharmony_ci} 2548c2ecf20Sopenharmony_ciCLK_OF_DECLARE(imx7ulp_clk_smc1, "fsl,imx7ulp-smc1", imx7ulp_clk_smc1_init); 255