162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2021 NXP 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <dt-bindings/clock/imx8ulp-clock.h> 762306a36Sopenharmony_ci#include <linux/err.h> 862306a36Sopenharmony_ci#include <linux/io.h> 962306a36Sopenharmony_ci#include <linux/module.h> 1062306a36Sopenharmony_ci#include <linux/of.h> 1162306a36Sopenharmony_ci#include <linux/platform_device.h> 1262306a36Sopenharmony_ci#include <linux/reset-controller.h> 1362306a36Sopenharmony_ci#include <linux/slab.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include "clk.h" 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistatic const char * const pll_pre_sels[] = { "sosc", "frosc", }; 1862306a36Sopenharmony_cistatic const char * const a35_sels[] = { "frosc", "spll2", "sosc", "lvds", }; 1962306a36Sopenharmony_cistatic const char * const nic_sels[] = { "frosc", "spll3_pfd0", "sosc", "lvds", }; 2062306a36Sopenharmony_cistatic const char * const pcc3_periph_bus_sels[] = { "dummy", "lposc", "sosc_div2", 2162306a36Sopenharmony_ci "frosc_div2", "xbar_divbus", "spll3_pfd1_div1", 2262306a36Sopenharmony_ci "spll3_pfd0_div2", "spll3_pfd0_div1", }; 2362306a36Sopenharmony_cistatic const char * const pcc4_periph_bus_sels[] = { "dummy", "dummy", "lposc", 2462306a36Sopenharmony_ci "sosc_div2", "frosc_div2", "xbar_divbus", 2562306a36Sopenharmony_ci "spll3_vcodiv", "spll3_pfd0_div1", }; 2662306a36Sopenharmony_cistatic const char * const pcc4_periph_plat_sels[] = { "dummy", "sosc_div1", "frosc_div1", 2762306a36Sopenharmony_ci "spll3_pfd3_div2", "spll3_pfd3_div1", 2862306a36Sopenharmony_ci "spll3_pfd2_div2", "spll3_pfd2_div1", 2962306a36Sopenharmony_ci "spll3_pfd1_div2", }; 3062306a36Sopenharmony_cistatic const char * const pcc5_periph_bus_sels[] = { "dummy", "dummy", "lposc", 3162306a36Sopenharmony_ci "sosc_div2", "frosc_div2", "lpav_bus_clk", 3262306a36Sopenharmony_ci "pll4_vcodiv", "pll4_pfd3_div1", }; 3362306a36Sopenharmony_cistatic const char * const pcc5_periph_plat_sels[] = { "dummy", "pll4_pfd3_div2", "pll4_pfd2_div2", 3462306a36Sopenharmony_ci "pll4_pfd2_div1", "pll4_pfd1_div2", 3562306a36Sopenharmony_ci "pll4_pfd1_div1", "pll4_pfd0_div2", 3662306a36Sopenharmony_ci "pll4_pfd0_div1", }; 3762306a36Sopenharmony_cistatic const char * const hifi_sels[] = { "frosc", "pll4", "pll4_pfd0", "sosc", 3862306a36Sopenharmony_ci "lvds", "dummy", "dummy", "dummy", }; 3962306a36Sopenharmony_cistatic const char * const ddr_sels[] = { "frosc", "pll4_pfd1", "sosc", "lvds", 4062306a36Sopenharmony_ci "pll4", "pll4", "pll4", "pll4", }; 4162306a36Sopenharmony_cistatic const char * const lpav_sels[] = { "frosc", "pll4_pfd1", "sosc", "lvds", }; 4262306a36Sopenharmony_cistatic const char * const sai45_sels[] = { "spll3_pfd1_div1", "aud_clk1", "aud_clk2", "sosc", }; 4362306a36Sopenharmony_cistatic const char * const sai67_sels[] = { "spll1_pfd2_div", "spll3_pfd1_div1", "aud_clk0", "aud_clk1", "aud_clk2", "sosc", "dummy", "dummy", }; 4462306a36Sopenharmony_cistatic const char * const aud_clk1_sels[] = { "ext_aud_mclk2", "sai4_rx_bclk", "sai4_tx_bclk", "sai5_rx_bclk", "sai5_tx_bclk", "dummy", "dummy", "dummy", }; 4562306a36Sopenharmony_cistatic const char * const aud_clk2_sels[] = { "ext_aud_mclk3", "sai6_rx_bclk", "sai6_tx_bclk", "sai7_rx_bclk", "sai7_tx_bclk", "spdif_rx", "dummy", "dummy", }; 4662306a36Sopenharmony_cistatic const char * const enet_ts_sels[] = { "ext_rmii_clk", "ext_ts_clk", "rosc", "ext_aud_mclk", "sosc", "dummy", "dummy", "dummy"}; 4762306a36Sopenharmony_cistatic const char * const xbar_divbus[] = { "xbar_divbus" }; 4862306a36Sopenharmony_cistatic const char * const nic_per_divplat[] = { "nic_per_divplat" }; 4962306a36Sopenharmony_cistatic const char * const lpav_axi_div[] = { "lpav_axi_div" }; 5062306a36Sopenharmony_cistatic const char * const lpav_bus_div[] = { "lpav_bus_div" }; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_cistruct pcc_reset_dev { 5362306a36Sopenharmony_ci void __iomem *base; 5462306a36Sopenharmony_ci struct reset_controller_dev rcdev; 5562306a36Sopenharmony_ci const u32 *resets; 5662306a36Sopenharmony_ci /* Set to imx_ccm_lock to protect register access shared with clock control */ 5762306a36Sopenharmony_ci spinlock_t *lock; 5862306a36Sopenharmony_ci}; 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define PCC_SW_RST BIT(28) 6162306a36Sopenharmony_ci#define to_pcc_reset_dev(_rcdev) container_of(_rcdev, struct pcc_reset_dev, rcdev) 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_cistatic const u32 pcc3_resets[] = { 6462306a36Sopenharmony_ci 0xa8, 0xac, 0xc8, 0xcc, 0xd0, 6562306a36Sopenharmony_ci 0xd4, 0xd8, 0xdc, 0xe0, 0xe4, 6662306a36Sopenharmony_ci 0xe8, 0xec, 0xf0 6762306a36Sopenharmony_ci}; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_cistatic const u32 pcc4_resets[] = { 7062306a36Sopenharmony_ci 0x4, 0x8, 0xc, 0x10, 0x14, 7162306a36Sopenharmony_ci 0x18, 0x1c, 0x20, 0x24, 0x34, 7262306a36Sopenharmony_ci 0x38, 0x3c, 0x40, 0x44, 0x48, 7362306a36Sopenharmony_ci 0x4c, 0x54 7462306a36Sopenharmony_ci}; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cistatic const u32 pcc5_resets[] = { 7762306a36Sopenharmony_ci 0xa0, 0xa4, 0xa8, 0xac, 0xb0, 7862306a36Sopenharmony_ci 0xb4, 0xbc, 0xc0, 0xc8, 0xcc, 7962306a36Sopenharmony_ci 0xd0, 0xf0, 0xf4, 0xf8 8062306a36Sopenharmony_ci}; 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_cistatic int imx8ulp_pcc_assert(struct reset_controller_dev *rcdev, unsigned long id) 8362306a36Sopenharmony_ci{ 8462306a36Sopenharmony_ci struct pcc_reset_dev *pcc_reset = to_pcc_reset_dev(rcdev); 8562306a36Sopenharmony_ci u32 offset = pcc_reset->resets[id]; 8662306a36Sopenharmony_ci unsigned long flags; 8762306a36Sopenharmony_ci u32 val; 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci spin_lock_irqsave(pcc_reset->lock, flags); 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci val = readl(pcc_reset->base + offset); 9262306a36Sopenharmony_ci val &= ~PCC_SW_RST; 9362306a36Sopenharmony_ci writel(val, pcc_reset->base + offset); 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci spin_unlock_irqrestore(pcc_reset->lock, flags); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci return 0; 9862306a36Sopenharmony_ci} 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_cistatic int imx8ulp_pcc_deassert(struct reset_controller_dev *rcdev, unsigned long id) 10162306a36Sopenharmony_ci{ 10262306a36Sopenharmony_ci struct pcc_reset_dev *pcc_reset = to_pcc_reset_dev(rcdev); 10362306a36Sopenharmony_ci u32 offset = pcc_reset->resets[id]; 10462306a36Sopenharmony_ci unsigned long flags; 10562306a36Sopenharmony_ci u32 val; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci spin_lock_irqsave(pcc_reset->lock, flags); 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci val = readl(pcc_reset->base + offset); 11062306a36Sopenharmony_ci val |= PCC_SW_RST; 11162306a36Sopenharmony_ci writel(val, pcc_reset->base + offset); 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci spin_unlock_irqrestore(pcc_reset->lock, flags); 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci return 0; 11662306a36Sopenharmony_ci} 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_cistatic const struct reset_control_ops imx8ulp_pcc_reset_ops = { 11962306a36Sopenharmony_ci .assert = imx8ulp_pcc_assert, 12062306a36Sopenharmony_ci .deassert = imx8ulp_pcc_deassert, 12162306a36Sopenharmony_ci}; 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_cistatic int imx8ulp_pcc_reset_init(struct platform_device *pdev, void __iomem *base, 12462306a36Sopenharmony_ci const u32 *resets, unsigned int nr_resets) 12562306a36Sopenharmony_ci{ 12662306a36Sopenharmony_ci struct device_node *np = pdev->dev.of_node; 12762306a36Sopenharmony_ci struct device *dev = &pdev->dev; 12862306a36Sopenharmony_ci struct pcc_reset_dev *pcc_reset; 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci pcc_reset = devm_kzalloc(dev, sizeof(*pcc_reset), GFP_KERNEL); 13162306a36Sopenharmony_ci if (!pcc_reset) 13262306a36Sopenharmony_ci return -ENOMEM; 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci pcc_reset->base = base; 13562306a36Sopenharmony_ci pcc_reset->lock = &imx_ccm_lock; 13662306a36Sopenharmony_ci pcc_reset->resets = resets; 13762306a36Sopenharmony_ci pcc_reset->rcdev.owner = THIS_MODULE; 13862306a36Sopenharmony_ci pcc_reset->rcdev.nr_resets = nr_resets; 13962306a36Sopenharmony_ci pcc_reset->rcdev.ops = &imx8ulp_pcc_reset_ops; 14062306a36Sopenharmony_ci pcc_reset->rcdev.of_node = np; 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci return devm_reset_controller_register(dev, &pcc_reset->rcdev); 14362306a36Sopenharmony_ci} 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cistatic int imx8ulp_clk_cgc1_init(struct platform_device *pdev) 14662306a36Sopenharmony_ci{ 14762306a36Sopenharmony_ci struct device *dev = &pdev->dev; 14862306a36Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 14962306a36Sopenharmony_ci struct clk_hw **clks; 15062306a36Sopenharmony_ci void __iomem *base; 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_CGC1_END), 15362306a36Sopenharmony_ci GFP_KERNEL); 15462306a36Sopenharmony_ci if (!clk_data) 15562306a36Sopenharmony_ci return -ENOMEM; 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci clk_data->num = IMX8ULP_CLK_CGC1_END; 15862306a36Sopenharmony_ci clks = clk_data->hws; 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DUMMY] = imx_clk_hw_fixed("dummy", 0); 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci /* CGC1 */ 16362306a36Sopenharmony_ci base = devm_platform_ioremap_resource(pdev, 0); 16462306a36Sopenharmony_ci if (WARN_ON(IS_ERR(base))) 16562306a36Sopenharmony_ci return PTR_ERR(base); 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL2_PRE_SEL] = imx_clk_hw_mux_flags("spll2_pre_sel", base + 0x510, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); 16862306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PRE_SEL] = imx_clk_hw_mux_flags("spll3_pre_sel", base + 0x610, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL2] = imx_clk_hw_pllv4(IMX_PLLV4_IMX8ULP_1GHZ, "spll2", "spll2_pre_sel", base + 0x500); 17162306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3] = imx_clk_hw_pllv4(IMX_PLLV4_IMX8ULP, "spll3", "spll3_pre_sel", base + 0x600); 17262306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_VCODIV] = imx_clk_hw_divider("spll3_vcodiv", "spll3", base + 0x604, 0, 6); 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD0] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd0", "spll3_vcodiv", base + 0x614, 0); 17562306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD1] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd1", "spll3_vcodiv", base + 0x614, 1); 17662306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD2] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd2", "spll3_vcodiv", base + 0x614, 2); 17762306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD3] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd3", "spll3_vcodiv", base + 0x614, 3); 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD0_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd0_div1_gate", "spll3_pfd0", base + 0x608, 7); 18062306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD0_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd0_div2_gate", "spll3_pfd0", base + 0x608, 15); 18162306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD1_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd1_div1_gate", "spll3_pfd1", base + 0x608, 23); 18262306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD1_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd1_div2_gate", "spll3_pfd1", base + 0x608, 31); 18362306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD2_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd2_div1_gate", "spll3_pfd2", base + 0x60c, 7); 18462306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD2_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd2_div2_gate", "spll3_pfd2", base + 0x60c, 15); 18562306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD3_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd3_div1_gate", "spll3_pfd3", base + 0x60c, 23); 18662306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD3_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd3_div2_gate", "spll3_pfd3", base + 0x60c, 31); 18762306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD0_DIV1] = imx_clk_hw_divider("spll3_pfd0_div1", "spll3_pfd0_div1_gate", base + 0x608, 0, 6); 18862306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD0_DIV2] = imx_clk_hw_divider("spll3_pfd0_div2", "spll3_pfd0_div2_gate", base + 0x608, 8, 6); 18962306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD1_DIV1] = imx_clk_hw_divider("spll3_pfd1_div1", "spll3_pfd1_div1_gate", base + 0x608, 16, 6); 19062306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD1_DIV2] = imx_clk_hw_divider("spll3_pfd1_div2", "spll3_pfd1_div2_gate", base + 0x608, 24, 6); 19162306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD2_DIV1] = imx_clk_hw_divider("spll3_pfd2_div1", "spll3_pfd2_div1_gate", base + 0x60c, 0, 6); 19262306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD2_DIV2] = imx_clk_hw_divider("spll3_pfd2_div2", "spll3_pfd2_div2_gate", base + 0x60c, 8, 6); 19362306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD3_DIV1] = imx_clk_hw_divider("spll3_pfd3_div1", "spll3_pfd3_div1_gate", base + 0x60c, 16, 6); 19462306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPLL3_PFD3_DIV2] = imx_clk_hw_divider("spll3_pfd3_div2", "spll3_pfd3_div2_gate", base + 0x60c, 24, 6); 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci clks[IMX8ULP_CLK_A35_SEL] = imx_clk_hw_mux2("a35_sel", base + 0x14, 28, 2, a35_sels, ARRAY_SIZE(a35_sels)); 19762306a36Sopenharmony_ci clks[IMX8ULP_CLK_A35_DIV] = imx_clk_hw_divider_flags("a35_div", "a35_sel", base + 0x14, 21, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci clks[IMX8ULP_CLK_NIC_SEL] = imx_clk_hw_mux2("nic_sel", base + 0x34, 28, 2, nic_sels, ARRAY_SIZE(nic_sels)); 20062306a36Sopenharmony_ci clks[IMX8ULP_CLK_NIC_AD_DIVPLAT] = imx_clk_hw_divider_flags("nic_ad_divplat", "nic_sel", base + 0x34, 21, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); 20162306a36Sopenharmony_ci clks[IMX8ULP_CLK_NIC_PER_DIVPLAT] = imx_clk_hw_divider_flags("nic_per_divplat", "nic_ad_divplat", base + 0x34, 14, 6, CLK_SET_RATE_PARENT); 20262306a36Sopenharmony_ci clks[IMX8ULP_CLK_XBAR_AD_DIVPLAT] = imx_clk_hw_divider_flags("xbar_ad_divplat", "nic_ad_divplat", base + 0x38, 14, 6, CLK_SET_RATE_PARENT); 20362306a36Sopenharmony_ci clks[IMX8ULP_CLK_XBAR_DIVBUS] = imx_clk_hw_divider_flags("xbar_divbus", "xbar_ad_divplat", base + 0x38, 7, 6, CLK_SET_RATE_PARENT); 20462306a36Sopenharmony_ci clks[IMX8ULP_CLK_XBAR_AD_SLOW] = imx_clk_hw_divider_flags("xbar_ad_slow", "xbar_divbus", base + 0x38, 0, 6, CLK_SET_RATE_PARENT); 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci clks[IMX8ULP_CLK_SOSC_DIV1_GATE] = imx_clk_hw_gate_dis("sosc_div1_gate", "sosc", base + 0x108, 7); 20762306a36Sopenharmony_ci clks[IMX8ULP_CLK_SOSC_DIV2_GATE] = imx_clk_hw_gate_dis("sosc_div2_gate", "sosc", base + 0x108, 15); 20862306a36Sopenharmony_ci clks[IMX8ULP_CLK_SOSC_DIV3_GATE] = imx_clk_hw_gate_dis("sosc_div3_gate", "sosc", base + 0x108, 23); 20962306a36Sopenharmony_ci clks[IMX8ULP_CLK_SOSC_DIV1] = imx_clk_hw_divider("sosc_div1", "sosc_div1_gate", base + 0x108, 0, 6); 21062306a36Sopenharmony_ci clks[IMX8ULP_CLK_SOSC_DIV2] = imx_clk_hw_divider("sosc_div2", "sosc_div2_gate", base + 0x108, 8, 6); 21162306a36Sopenharmony_ci clks[IMX8ULP_CLK_SOSC_DIV3] = imx_clk_hw_divider("sosc_div3", "sosc_div3_gate", base + 0x108, 16, 6); 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci clks[IMX8ULP_CLK_FROSC_DIV1_GATE] = imx_clk_hw_gate_dis("frosc_div1_gate", "frosc", base + 0x208, 7); 21462306a36Sopenharmony_ci clks[IMX8ULP_CLK_FROSC_DIV2_GATE] = imx_clk_hw_gate_dis("frosc_div2_gate", "frosc", base + 0x208, 15); 21562306a36Sopenharmony_ci clks[IMX8ULP_CLK_FROSC_DIV3_GATE] = imx_clk_hw_gate_dis("frosc_div3_gate", "frosc", base + 0x208, 23); 21662306a36Sopenharmony_ci clks[IMX8ULP_CLK_FROSC_DIV1] = imx_clk_hw_divider("frosc_div1", "frosc_div1_gate", base + 0x208, 0, 6); 21762306a36Sopenharmony_ci clks[IMX8ULP_CLK_FROSC_DIV2] = imx_clk_hw_divider("frosc_div2", "frosc_div2_gate", base + 0x208, 8, 6); 21862306a36Sopenharmony_ci clks[IMX8ULP_CLK_FROSC_DIV3] = imx_clk_hw_divider("frosc_div3", "frosc_div3_gate", base + 0x208, 16, 6); 21962306a36Sopenharmony_ci clks[IMX8ULP_CLK_AUD_CLK1] = imx_clk_hw_mux2("aud_clk1", base + 0x900, 0, 3, aud_clk1_sels, ARRAY_SIZE(aud_clk1_sels)); 22062306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI4_SEL] = imx_clk_hw_mux2("sai4_sel", base + 0x904, 0, 2, sai45_sels, ARRAY_SIZE(sai45_sels)); 22162306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI5_SEL] = imx_clk_hw_mux2("sai5_sel", base + 0x904, 8, 2, sai45_sels, ARRAY_SIZE(sai45_sels)); 22262306a36Sopenharmony_ci clks[IMX8ULP_CLK_ENET_TS_SEL] = imx_clk_hw_mux2("enet_ts", base + 0x700, 24, 3, enet_ts_sels, ARRAY_SIZE(enet_ts_sels)); 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci imx_check_clk_hws(clks, clk_data->num); 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); 22762306a36Sopenharmony_ci} 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_cistatic int imx8ulp_clk_cgc2_init(struct platform_device *pdev) 23062306a36Sopenharmony_ci{ 23162306a36Sopenharmony_ci struct device *dev = &pdev->dev; 23262306a36Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 23362306a36Sopenharmony_ci struct clk_hw **clks; 23462306a36Sopenharmony_ci void __iomem *base; 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_CGC2_END), 23762306a36Sopenharmony_ci GFP_KERNEL); 23862306a36Sopenharmony_ci if (!clk_data) 23962306a36Sopenharmony_ci return -ENOMEM; 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci clk_data->num = IMX8ULP_CLK_CGC2_END; 24262306a36Sopenharmony_ci clks = clk_data->hws; 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci /* CGC2 */ 24562306a36Sopenharmony_ci base = devm_platform_ioremap_resource(pdev, 0); 24662306a36Sopenharmony_ci if (WARN_ON(IS_ERR(base))) 24762306a36Sopenharmony_ci return PTR_ERR(base); 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PRE_SEL] = imx_clk_hw_mux_flags("pll4_pre_sel", base + 0x610, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4] = imx_clk_hw_pllv4(IMX_PLLV4_IMX8ULP, "pll4", "pll4_pre_sel", base + 0x600); 25262306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_VCODIV] = imx_clk_hw_divider("pll4_vcodiv", "pll4", base + 0x604, 0, 6); 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci clks[IMX8ULP_CLK_HIFI_SEL] = imx_clk_hw_mux_flags("hifi_sel", base + 0x14, 28, 3, hifi_sels, ARRAY_SIZE(hifi_sels), CLK_SET_PARENT_GATE); 25562306a36Sopenharmony_ci clks[IMX8ULP_CLK_HIFI_DIVCORE] = imx_clk_hw_divider("hifi_core_div", "hifi_sel", base + 0x14, 21, 6); 25662306a36Sopenharmony_ci clks[IMX8ULP_CLK_HIFI_DIVPLAT] = imx_clk_hw_divider("hifi_plat_div", "hifi_core_div", base + 0x14, 14, 6); 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ci clks[IMX8ULP_CLK_DDR_SEL] = imx_clk_hw_mux_flags("ddr_sel", base + 0x40, 28, 3, ddr_sels, ARRAY_SIZE(ddr_sels), CLK_GET_RATE_NOCACHE); 25962306a36Sopenharmony_ci clks[IMX8ULP_CLK_DDR_DIV] = imx_clk_hw_divider_flags("ddr_div", "ddr_sel", base + 0x40, 21, 6, CLK_IS_CRITICAL | CLK_GET_RATE_NOCACHE); 26062306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPAV_AXI_SEL] = imx_clk_hw_mux2("lpav_sel", base + 0x3c, 28, 2, lpav_sels, ARRAY_SIZE(lpav_sels)); 26162306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPAV_AXI_DIV] = imx_clk_hw_divider_flags("lpav_axi_div", "lpav_sel", base + 0x3c, 21, 6, CLK_IS_CRITICAL); 26262306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPAV_AHB_DIV] = imx_clk_hw_divider_flags("lpav_ahb_div", "lpav_axi_div", base + 0x3c, 14, 6, CLK_IS_CRITICAL); 26362306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPAV_BUS_DIV] = imx_clk_hw_divider_flags("lpav_bus_div", "lpav_axi_div", base + 0x3c, 7, 6, CLK_IS_CRITICAL); 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD0] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd0", "pll4_vcodiv", base + 0x614, 0); 26662306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD1] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd1", "pll4_vcodiv", base + 0x614, 1); 26762306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD2] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd2", "pll4_vcodiv", base + 0x614, 2); 26862306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD3] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd3", "pll4_vcodiv", base + 0x614, 3); 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD0_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd0_div1_gate", "pll4_pfd0", base + 0x608, 7); 27162306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD0_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd0_div2_gate", "pll4_pfd0", base + 0x608, 15); 27262306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD1_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd1_div1_gate", "pll4_pfd1", base + 0x608, 23); 27362306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD1_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd1_div2_gate", "pll4_pfd1", base + 0x608, 31); 27462306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD2_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd2_div1_gate", "pll4_pfd2", base + 0x60c, 7); 27562306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD2_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd2_div2_gate", "pll4_pfd2", base + 0x60c, 15); 27662306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD3_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd3_div1_gate", "pll4_pfd3", base + 0x60c, 23); 27762306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD3_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd3_div2_gate", "pll4_pfd3", base + 0x60c, 31); 27862306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD0_DIV1] = imx_clk_hw_divider_closest("pll4_pfd0_div1", "pll4_pfd0_div1_gate", base + 0x608, 0, 6); 27962306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD0_DIV2] = imx_clk_hw_divider_closest("pll4_pfd0_div2", "pll4_pfd0_div2_gate", base + 0x608, 8, 6); 28062306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD1_DIV1] = imx_clk_hw_divider_closest("pll4_pfd1_div1", "pll4_pfd1_div1_gate", base + 0x608, 16, 6); 28162306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD1_DIV2] = imx_clk_hw_divider_closest("pll4_pfd1_div2", "pll4_pfd1_div2_gate", base + 0x608, 24, 6); 28262306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD2_DIV1] = imx_clk_hw_divider_closest("pll4_pfd2_div1", "pll4_pfd2_div1_gate", base + 0x60c, 0, 6); 28362306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD2_DIV2] = imx_clk_hw_divider_closest("pll4_pfd2_div2", "pll4_pfd2_div2_gate", base + 0x60c, 8, 6); 28462306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD3_DIV1] = imx_clk_hw_divider_closest("pll4_pfd3_div1", "pll4_pfd3_div1_gate", base + 0x60c, 16, 6); 28562306a36Sopenharmony_ci clks[IMX8ULP_CLK_PLL4_PFD3_DIV2] = imx_clk_hw_divider_closest("pll4_pfd3_div2", "pll4_pfd3_div2_gate", base + 0x60c, 24, 6); 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_SOSC_DIV1_GATE] = imx_clk_hw_gate_dis("cgc2_sosc_div1_gate", "sosc", base + 0x108, 7); 28862306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_SOSC_DIV2_GATE] = imx_clk_hw_gate_dis("cgc2_sosc_div2_gate", "sosc", base + 0x108, 15); 28962306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_SOSC_DIV3_GATE] = imx_clk_hw_gate_dis("cgc2_sosc_div3_gate", "sosc", base + 0x108, 23); 29062306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_SOSC_DIV1] = imx_clk_hw_divider("cgc2_sosc_div1", "cgc2_sosc_div1_gate", base + 0x108, 0, 6); 29162306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_SOSC_DIV2] = imx_clk_hw_divider("cgc2_sosc_div2", "cgc2_sosc_div2_gate", base + 0x108, 8, 6); 29262306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_SOSC_DIV3] = imx_clk_hw_divider("cgc2_sosc_div3", "cgc2_sosc_div3_gate", base + 0x108, 16, 6); 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_FROSC_DIV1_GATE] = imx_clk_hw_gate_dis("cgc2_frosc_div1_gate", "frosc", base + 0x208, 7); 29562306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_FROSC_DIV2_GATE] = imx_clk_hw_gate_dis("cgc2_frosc_div2_gate", "frosc", base + 0x208, 15); 29662306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_FROSC_DIV3_GATE] = imx_clk_hw_gate_dis("cgc2_frosc_div3_gate", "frosc", base + 0x208, 23); 29762306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_FROSC_DIV1] = imx_clk_hw_divider("cgc2_frosc_div1", "cgc2_frosc_div1_gate", base + 0x208, 0, 6); 29862306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_FROSC_DIV2] = imx_clk_hw_divider("cgc2_frosc_div2", "cgc2_frosc_div2_gate", base + 0x208, 8, 6); 29962306a36Sopenharmony_ci clks[IMX8ULP_CLK_CGC2_FROSC_DIV3] = imx_clk_hw_divider("cgc2_frosc_div3", "cgc2_frosc_div3_gate", base + 0x208, 16, 6); 30062306a36Sopenharmony_ci clks[IMX8ULP_CLK_AUD_CLK2] = imx_clk_hw_mux2("aud_clk2", base + 0x900, 0, 3, aud_clk2_sels, ARRAY_SIZE(aud_clk2_sels)); 30162306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI6_SEL] = imx_clk_hw_mux2("sai6_sel", base + 0x904, 0, 3, sai67_sels, ARRAY_SIZE(sai67_sels)); 30262306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI7_SEL] = imx_clk_hw_mux2("sai7_sel", base + 0x904, 8, 3, sai67_sels, ARRAY_SIZE(sai67_sels)); 30362306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPDIF_SEL] = imx_clk_hw_mux2("spdif_sel", base + 0x910, 0, 3, sai67_sels, ARRAY_SIZE(sai67_sels)); 30462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DSI_PHY_REF] = imx_clk_hw_fixed("dsi_phy_ref", 24000000); 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci imx_check_clk_hws(clks, clk_data->num); 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); 30962306a36Sopenharmony_ci} 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_cistatic int imx8ulp_clk_pcc3_init(struct platform_device *pdev) 31262306a36Sopenharmony_ci{ 31362306a36Sopenharmony_ci struct device *dev = &pdev->dev; 31462306a36Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 31562306a36Sopenharmony_ci struct clk_hw **clks; 31662306a36Sopenharmony_ci void __iomem *base; 31762306a36Sopenharmony_ci int ret; 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC3_END), 32062306a36Sopenharmony_ci GFP_KERNEL); 32162306a36Sopenharmony_ci if (!clk_data) 32262306a36Sopenharmony_ci return -ENOMEM; 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ci clk_data->num = IMX8ULP_CLK_PCC3_END; 32562306a36Sopenharmony_ci clks = clk_data->hws; 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci /* PCC3 */ 32862306a36Sopenharmony_ci base = devm_platform_ioremap_resource(pdev, 0); 32962306a36Sopenharmony_ci if (WARN_ON(IS_ERR(base))) 33062306a36Sopenharmony_ci return PTR_ERR(base); 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci clks[IMX8ULP_CLK_WDOG3] = imx8ulp_clk_hw_composite("wdog3", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xa8, 1); 33362306a36Sopenharmony_ci clks[IMX8ULP_CLK_WDOG4] = imx8ulp_clk_hw_composite("wdog4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xac, 1); 33462306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPIT1] = imx8ulp_clk_hw_composite("lpit1", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xc8, 1); 33562306a36Sopenharmony_ci clks[IMX8ULP_CLK_TPM4] = imx8ulp_clk_hw_composite("tpm4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xcc, 1); 33662306a36Sopenharmony_ci clks[IMX8ULP_CLK_FLEXIO1] = imx8ulp_clk_hw_composite("flexio1", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xd4, 1); 33762306a36Sopenharmony_ci clks[IMX8ULP_CLK_I3C2] = imx8ulp_clk_hw_composite("i3c2", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xd8, 1); 33862306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPI2C4] = imx8ulp_clk_hw_composite("lpi2c4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xdc, 1); 33962306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPI2C5] = imx8ulp_clk_hw_composite("lpi2c5", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xe0, 1); 34062306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPUART4] = imx8ulp_clk_hw_composite("lpuart4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xe4, 1); 34162306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPUART5] = imx8ulp_clk_hw_composite("lpuart5", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xe8, 1); 34262306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPSPI4] = imx8ulp_clk_hw_composite("lpspi4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xec, 1); 34362306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPSPI5] = imx8ulp_clk_hw_composite("lpspi5", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xf0, 1); 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_MP] = imx_clk_hw_gate("pcc_dma1_mp", "xbar_ad_divplat", base + 0x4, 30); 34662306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH0] = imx_clk_hw_gate("pcc_dma1_ch0", "xbar_ad_divplat", base + 0x8, 30); 34762306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH1] = imx_clk_hw_gate("pcc_dma1_ch1", "xbar_ad_divplat", base + 0xc, 30); 34862306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH2] = imx_clk_hw_gate("pcc_dma1_ch2", "xbar_ad_divplat", base + 0x10, 30); 34962306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH3] = imx_clk_hw_gate("pcc_dma1_ch3", "xbar_ad_divplat", base + 0x14, 30); 35062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH4] = imx_clk_hw_gate("pcc_dma1_ch4", "xbar_ad_divplat", base + 0x18, 30); 35162306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH5] = imx_clk_hw_gate("pcc_dma1_ch5", "xbar_ad_divplat", base + 0x1c, 30); 35262306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH6] = imx_clk_hw_gate("pcc_dma1_ch6", "xbar_ad_divplat", base + 0x20, 30); 35362306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH7] = imx_clk_hw_gate("pcc_dma1_ch7", "xbar_ad_divplat", base + 0x24, 30); 35462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH8] = imx_clk_hw_gate("pcc_dma1_ch8", "xbar_ad_divplat", base + 0x28, 30); 35562306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH9] = imx_clk_hw_gate("pcc_dma1_ch9", "xbar_ad_divplat", base + 0x2c, 30); 35662306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH10] = imx_clk_hw_gate("pcc_dma1_ch10", "xbar_ad_divplat", base + 0x30, 30); 35762306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH11] = imx_clk_hw_gate("pcc_dma1_ch11", "xbar_ad_divplat", base + 0x34, 30); 35862306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH12] = imx_clk_hw_gate("pcc_dma1_ch12", "xbar_ad_divplat", base + 0x38, 30); 35962306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH13] = imx_clk_hw_gate("pcc_dma1_ch13", "xbar_ad_divplat", base + 0x3c, 30); 36062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH14] = imx_clk_hw_gate("pcc_dma1_ch14", "xbar_ad_divplat", base + 0x40, 30); 36162306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH15] = imx_clk_hw_gate("pcc_dma1_ch15", "xbar_ad_divplat", base + 0x44, 30); 36262306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH16] = imx_clk_hw_gate("pcc_dma1_ch16", "xbar_ad_divplat", base + 0x48, 30); 36362306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH17] = imx_clk_hw_gate("pcc_dma1_ch17", "xbar_ad_divplat", base + 0x4c, 30); 36462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH18] = imx_clk_hw_gate("pcc_dma1_ch18", "xbar_ad_divplat", base + 0x50, 30); 36562306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH19] = imx_clk_hw_gate("pcc_dma1_ch19", "xbar_ad_divplat", base + 0x54, 30); 36662306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH20] = imx_clk_hw_gate("pcc_dma1_ch20", "xbar_ad_divplat", base + 0x58, 30); 36762306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH21] = imx_clk_hw_gate("pcc_dma1_ch21", "xbar_ad_divplat", base + 0x5c, 30); 36862306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH22] = imx_clk_hw_gate("pcc_dma1_ch22", "xbar_ad_divplat", base + 0x60, 30); 36962306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH23] = imx_clk_hw_gate("pcc_dma1_ch23", "xbar_ad_divplat", base + 0x64, 30); 37062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH24] = imx_clk_hw_gate("pcc_dma1_ch24", "xbar_ad_divplat", base + 0x68, 30); 37162306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH25] = imx_clk_hw_gate("pcc_dma1_ch25", "xbar_ad_divplat", base + 0x6c, 30); 37262306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH26] = imx_clk_hw_gate("pcc_dma1_ch26", "xbar_ad_divplat", base + 0x70, 30); 37362306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH27] = imx_clk_hw_gate("pcc_dma1_ch27", "xbar_ad_divplat", base + 0x74, 30); 37462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH28] = imx_clk_hw_gate("pcc_dma1_ch28", "xbar_ad_divplat", base + 0x78, 30); 37562306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH29] = imx_clk_hw_gate("pcc_dma1_ch29", "xbar_ad_divplat", base + 0x7c, 30); 37662306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH30] = imx_clk_hw_gate("pcc_dma1_ch30", "xbar_ad_divplat", base + 0x80, 30); 37762306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA1_CH31] = imx_clk_hw_gate("pcc_dma1_ch31", "xbar_ad_divplat", base + 0x84, 30); 37862306a36Sopenharmony_ci clks[IMX8ULP_CLK_MU0_B] = imx_clk_hw_gate_flags("mu0_b", "xbar_ad_divplat", base + 0x88, 30, CLK_IS_CRITICAL); 37962306a36Sopenharmony_ci clks[IMX8ULP_CLK_MU3_A] = imx_clk_hw_gate("mu3_a", "xbar_ad_divplat", base + 0x8c, 30); 38062306a36Sopenharmony_ci clks[IMX8ULP_CLK_TPM5] = imx_clk_hw_gate_flags("tpm5", "sosc_div2", base + 0xd0, 30, CLK_IS_CRITICAL); 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ci imx_check_clk_hws(clks, clk_data->num); 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); 38562306a36Sopenharmony_ci if (ret) 38662306a36Sopenharmony_ci return ret; 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci imx_register_uart_clocks(); 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci /* register the pcc3 reset controller */ 39162306a36Sopenharmony_ci return imx8ulp_pcc_reset_init(pdev, base, pcc3_resets, ARRAY_SIZE(pcc3_resets)); 39262306a36Sopenharmony_ci} 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_cistatic int imx8ulp_clk_pcc4_init(struct platform_device *pdev) 39562306a36Sopenharmony_ci{ 39662306a36Sopenharmony_ci struct device *dev = &pdev->dev; 39762306a36Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 39862306a36Sopenharmony_ci struct clk_hw **clks; 39962306a36Sopenharmony_ci void __iomem *base; 40062306a36Sopenharmony_ci int ret; 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ci clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC4_END), 40362306a36Sopenharmony_ci GFP_KERNEL); 40462306a36Sopenharmony_ci if (!clk_data) 40562306a36Sopenharmony_ci return -ENOMEM; 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci clk_data->num = IMX8ULP_CLK_PCC4_END; 40862306a36Sopenharmony_ci clks = clk_data->hws; 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci /* PCC4 */ 41162306a36Sopenharmony_ci base = devm_platform_ioremap_resource(pdev, 0); 41262306a36Sopenharmony_ci if (WARN_ON(IS_ERR(base))) 41362306a36Sopenharmony_ci return PTR_ERR(base); 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_ci clks[IMX8ULP_CLK_FLEXSPI2] = imx8ulp_clk_hw_composite("flexspi2", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, true, true, base + 0x4, 1); 41662306a36Sopenharmony_ci clks[IMX8ULP_CLK_TPM6] = imx8ulp_clk_hw_composite("tpm6", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x8, 1); 41762306a36Sopenharmony_ci clks[IMX8ULP_CLK_TPM7] = imx8ulp_clk_hw_composite("tpm7", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0xc, 1); 41862306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPI2C6] = imx8ulp_clk_hw_composite("lpi2c6", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x10, 1); 41962306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPI2C7] = imx8ulp_clk_hw_composite("lpi2c7", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x14, 1); 42062306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPUART6] = imx8ulp_clk_hw_composite("lpuart6", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x18, 1); 42162306a36Sopenharmony_ci clks[IMX8ULP_CLK_LPUART7] = imx8ulp_clk_hw_composite("lpuart7", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x1c, 1); 42262306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI4] = imx8ulp_clk_hw_composite("sai4", xbar_divbus, 1, false, false, true, base + 0x20, 1); /* sai ipg, NOT from sai sel */ 42362306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI5] = imx8ulp_clk_hw_composite("sai5", xbar_divbus, 1, false, false, true, base + 0x24, 1); /* sai ipg */ 42462306a36Sopenharmony_ci clks[IMX8ULP_CLK_PCTLE] = imx_clk_hw_gate("pctle", "xbar_divbus", base + 0x28, 30); 42562306a36Sopenharmony_ci clks[IMX8ULP_CLK_PCTLF] = imx_clk_hw_gate("pctlf", "xbar_divbus", base + 0x2c, 30); 42662306a36Sopenharmony_ci clks[IMX8ULP_CLK_USDHC0] = imx8ulp_clk_hw_composite("usdhc0", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, false, true, base + 0x34, 1); 42762306a36Sopenharmony_ci clks[IMX8ULP_CLK_USDHC1] = imx8ulp_clk_hw_composite("usdhc1", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, false, true, base + 0x38, 1); 42862306a36Sopenharmony_ci clks[IMX8ULP_CLK_USDHC2] = imx8ulp_clk_hw_composite("usdhc2", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, false, true, base + 0x3c, 1); 42962306a36Sopenharmony_ci clks[IMX8ULP_CLK_USB0] = imx8ulp_clk_hw_composite("usb0", nic_per_divplat, 1, false, false, true, base + 0x40, 1); 43062306a36Sopenharmony_ci clks[IMX8ULP_CLK_USB0_PHY] = imx8ulp_clk_hw_composite("usb0_phy", xbar_divbus, 1, false, false, true, base + 0x44, 1); 43162306a36Sopenharmony_ci clks[IMX8ULP_CLK_USB1] = imx8ulp_clk_hw_composite("usb1", nic_per_divplat, 1, false, false, true, base + 0x48, 1); 43262306a36Sopenharmony_ci clks[IMX8ULP_CLK_USB1_PHY] = imx8ulp_clk_hw_composite("usb1_phy", xbar_divbus, 1, false, false, true, base + 0x4c, 1); 43362306a36Sopenharmony_ci clks[IMX8ULP_CLK_USB_XBAR] = imx_clk_hw_gate("usb_xbar", "xbar_divbus", base + 0x50, 30); 43462306a36Sopenharmony_ci clks[IMX8ULP_CLK_ENET] = imx8ulp_clk_hw_composite("enet", nic_per_divplat, 1, false, false, true, base + 0x54, 1); 43562306a36Sopenharmony_ci clks[IMX8ULP_CLK_RGPIOE] = imx_clk_hw_gate("rgpioe", "nic_per_divplat", base + 0x78, 30); 43662306a36Sopenharmony_ci clks[IMX8ULP_CLK_RGPIOF] = imx_clk_hw_gate("rgpiof", "nic_per_divplat", base + 0x7c, 30); 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci imx_check_clk_hws(clks, clk_data->num); 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); 44162306a36Sopenharmony_ci if (ret) 44262306a36Sopenharmony_ci return ret; 44362306a36Sopenharmony_ci 44462306a36Sopenharmony_ci /* register the pcc4 reset controller */ 44562306a36Sopenharmony_ci return imx8ulp_pcc_reset_init(pdev, base, pcc4_resets, ARRAY_SIZE(pcc4_resets)); 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_ci} 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_cistatic int imx8ulp_clk_pcc5_init(struct platform_device *pdev) 45062306a36Sopenharmony_ci{ 45162306a36Sopenharmony_ci struct device *dev = &pdev->dev; 45262306a36Sopenharmony_ci struct clk_hw_onecell_data *clk_data; 45362306a36Sopenharmony_ci struct clk_hw **clks; 45462306a36Sopenharmony_ci void __iomem *base; 45562306a36Sopenharmony_ci int ret; 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_ci clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC5_END), 45862306a36Sopenharmony_ci GFP_KERNEL); 45962306a36Sopenharmony_ci if (!clk_data) 46062306a36Sopenharmony_ci return -ENOMEM; 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci clk_data->num = IMX8ULP_CLK_PCC5_END; 46362306a36Sopenharmony_ci clks = clk_data->hws; 46462306a36Sopenharmony_ci 46562306a36Sopenharmony_ci /* PCC5 */ 46662306a36Sopenharmony_ci base = devm_platform_ioremap_resource(pdev, 0); 46762306a36Sopenharmony_ci if (WARN_ON(IS_ERR(base))) 46862306a36Sopenharmony_ci return PTR_ERR(base); 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_MP] = imx_clk_hw_gate("pcc_dma2_mp", "lpav_axi_div", base + 0x0, 30); 47162306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH0] = imx_clk_hw_gate("pcc_dma2_ch0", "lpav_axi_div", base + 0x4, 30); 47262306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH1] = imx_clk_hw_gate("pcc_dma2_ch1", "lpav_axi_div", base + 0x8, 30); 47362306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH2] = imx_clk_hw_gate("pcc_dma2_ch2", "lpav_axi_div", base + 0xc, 30); 47462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH3] = imx_clk_hw_gate("pcc_dma2_ch3", "lpav_axi_div", base + 0x10, 30); 47562306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH4] = imx_clk_hw_gate("pcc_dma2_ch4", "lpav_axi_div", base + 0x14, 30); 47662306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH5] = imx_clk_hw_gate("pcc_dma2_ch5", "lpav_axi_div", base + 0x18, 30); 47762306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH6] = imx_clk_hw_gate("pcc_dma2_ch6", "lpav_axi_div", base + 0x1c, 30); 47862306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH7] = imx_clk_hw_gate("pcc_dma2_ch7", "lpav_axi_div", base + 0x20, 30); 47962306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH8] = imx_clk_hw_gate("pcc_dma2_ch8", "lpav_axi_div", base + 0x24, 30); 48062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH9] = imx_clk_hw_gate("pcc_dma2_ch9", "lpav_axi_div", base + 0x28, 30); 48162306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH10] = imx_clk_hw_gate("pcc_dma2_ch10", "lpav_axi_div", base + 0x2c, 30); 48262306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH11] = imx_clk_hw_gate("pcc_dma2_ch11", "lpav_axi_div", base + 0x30, 30); 48362306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH12] = imx_clk_hw_gate("pcc_dma2_ch12", "lpav_axi_div", base + 0x34, 30); 48462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH13] = imx_clk_hw_gate("pcc_dma2_ch13", "lpav_axi_div", base + 0x38, 30); 48562306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH14] = imx_clk_hw_gate("pcc_dma2_ch14", "lpav_axi_div", base + 0x3c, 30); 48662306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH15] = imx_clk_hw_gate("pcc_dma2_ch15", "lpav_axi_div", base + 0x40, 30); 48762306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH16] = imx_clk_hw_gate("pcc_dma2_ch16", "lpav_axi_div", base + 0x44, 30); 48862306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH17] = imx_clk_hw_gate("pcc_dma2_ch17", "lpav_axi_div", base + 0x48, 30); 48962306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH18] = imx_clk_hw_gate("pcc_dma2_ch18", "lpav_axi_div", base + 0x4c, 30); 49062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH19] = imx_clk_hw_gate("pcc_dma2_ch19", "lpav_axi_div", base + 0x50, 30); 49162306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH20] = imx_clk_hw_gate("pcc_dma2_ch20", "lpav_axi_div", base + 0x54, 30); 49262306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH21] = imx_clk_hw_gate("pcc_dma2_ch21", "lpav_axi_div", base + 0x58, 30); 49362306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH22] = imx_clk_hw_gate("pcc_dma2_ch22", "lpav_axi_div", base + 0x5c, 30); 49462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH23] = imx_clk_hw_gate("pcc_dma2_ch23", "lpav_axi_div", base + 0x60, 30); 49562306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH24] = imx_clk_hw_gate("pcc_dma2_ch24", "lpav_axi_div", base + 0x64, 30); 49662306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH25] = imx_clk_hw_gate("pcc_dma2_ch25", "lpav_axi_div", base + 0x68, 30); 49762306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH26] = imx_clk_hw_gate("pcc_dma2_ch26", "lpav_axi_div", base + 0x6c, 30); 49862306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH27] = imx_clk_hw_gate("pcc_dma2_ch27", "lpav_axi_div", base + 0x70, 30); 49962306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH28] = imx_clk_hw_gate("pcc_dma2_ch28", "lpav_axi_div", base + 0x74, 30); 50062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH29] = imx_clk_hw_gate("pcc_dma2_ch29", "lpav_axi_div", base + 0x78, 30); 50162306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH30] = imx_clk_hw_gate("pcc_dma2_ch30", "lpav_axi_div", base + 0x7c, 30); 50262306a36Sopenharmony_ci clks[IMX8ULP_CLK_DMA2_CH31] = imx_clk_hw_gate("pcc_dma2_ch31", "lpav_axi_div", base + 0x80, 30); 50362306a36Sopenharmony_ci 50462306a36Sopenharmony_ci clks[IMX8ULP_CLK_AVD_SIM] = imx_clk_hw_gate("avd_sim", "lpav_bus_div", base + 0x94, 30); 50562306a36Sopenharmony_ci clks[IMX8ULP_CLK_TPM8] = imx8ulp_clk_hw_composite("tpm8", pcc5_periph_bus_sels, ARRAY_SIZE(pcc5_periph_bus_sels), true, true, true, base + 0xa0, 1); 50662306a36Sopenharmony_ci clks[IMX8ULP_CLK_MU2_B] = imx_clk_hw_gate("mu2_b", "lpav_bus_div", base + 0x84, 30); 50762306a36Sopenharmony_ci clks[IMX8ULP_CLK_MU3_B] = imx_clk_hw_gate("mu3_b", "lpav_bus_div", base + 0x88, 30); 50862306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI6] = imx8ulp_clk_hw_composite("sai6", lpav_bus_div, 1, false, false, true, base + 0xa4, 1); 50962306a36Sopenharmony_ci clks[IMX8ULP_CLK_SAI7] = imx8ulp_clk_hw_composite("sai7", lpav_bus_div, 1, false, false, true, base + 0xa8, 1); 51062306a36Sopenharmony_ci clks[IMX8ULP_CLK_SPDIF] = imx8ulp_clk_hw_composite("spdif", lpav_bus_div, 1, false, false, true, base + 0xac, 1); 51162306a36Sopenharmony_ci clks[IMX8ULP_CLK_ISI] = imx8ulp_clk_hw_composite("isi", lpav_axi_div, 1, false, false, true, base + 0xb0, 1); 51262306a36Sopenharmony_ci clks[IMX8ULP_CLK_CSI_REGS] = imx8ulp_clk_hw_composite("csi_regs", lpav_bus_div, 1, false, false, true, base + 0xb4, 1); 51362306a36Sopenharmony_ci clks[IMX8ULP_CLK_CSI] = imx8ulp_clk_hw_composite("csi", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xbc, 1); 51462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DSI] = imx8ulp_clk_hw_composite("dsi", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xc0, 1); 51562306a36Sopenharmony_ci clks[IMX8ULP_CLK_WDOG5] = imx8ulp_clk_hw_composite("wdog5", pcc5_periph_bus_sels, ARRAY_SIZE(pcc5_periph_bus_sels), true, true, true, base + 0xc8, 1); 51662306a36Sopenharmony_ci clks[IMX8ULP_CLK_EPDC] = imx8ulp_clk_hw_composite("epdc", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xcc, 1); 51762306a36Sopenharmony_ci clks[IMX8ULP_CLK_PXP] = imx8ulp_clk_hw_composite("pxp", lpav_axi_div, 1, false, false, true, base + 0xd0, 1); 51862306a36Sopenharmony_ci clks[IMX8ULP_CLK_GPU2D] = imx8ulp_clk_hw_composite("gpu2d", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xf0, 1); 51962306a36Sopenharmony_ci clks[IMX8ULP_CLK_GPU3D] = imx8ulp_clk_hw_composite("gpu3d", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xf4, 1); 52062306a36Sopenharmony_ci clks[IMX8ULP_CLK_DC_NANO] = imx8ulp_clk_hw_composite("dc_nano", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xf8, 1); 52162306a36Sopenharmony_ci clks[IMX8ULP_CLK_CSI_CLK_UI] = imx8ulp_clk_hw_composite("csi_clk_ui", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0x10c, 1); 52262306a36Sopenharmony_ci clks[IMX8ULP_CLK_CSI_CLK_ESC] = imx8ulp_clk_hw_composite("csi_clk_esc", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0x110, 1); 52362306a36Sopenharmony_ci clks[IMX8ULP_CLK_RGPIOD] = imx_clk_hw_gate("rgpiod", "lpav_axi_div", base + 0x114, 30); 52462306a36Sopenharmony_ci clks[IMX8ULP_CLK_DSI_TX_ESC] = imx_clk_hw_fixed_factor("mipi_dsi_tx_esc", "dsi", 1, 4); 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci imx_check_clk_hws(clks, clk_data->num); 52762306a36Sopenharmony_ci 52862306a36Sopenharmony_ci ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); 52962306a36Sopenharmony_ci if (ret) 53062306a36Sopenharmony_ci return ret; 53162306a36Sopenharmony_ci 53262306a36Sopenharmony_ci /* register the pcc5 reset controller */ 53362306a36Sopenharmony_ci return imx8ulp_pcc_reset_init(pdev, base, pcc5_resets, ARRAY_SIZE(pcc5_resets)); 53462306a36Sopenharmony_ci} 53562306a36Sopenharmony_ci 53662306a36Sopenharmony_cistatic int imx8ulp_clk_probe(struct platform_device *pdev) 53762306a36Sopenharmony_ci{ 53862306a36Sopenharmony_ci int (*probe)(struct platform_device *pdev); 53962306a36Sopenharmony_ci 54062306a36Sopenharmony_ci probe = of_device_get_match_data(&pdev->dev); 54162306a36Sopenharmony_ci 54262306a36Sopenharmony_ci if (probe) 54362306a36Sopenharmony_ci return probe(pdev); 54462306a36Sopenharmony_ci 54562306a36Sopenharmony_ci return 0; 54662306a36Sopenharmony_ci} 54762306a36Sopenharmony_ci 54862306a36Sopenharmony_cistatic const struct of_device_id imx8ulp_clk_dt_ids[] = { 54962306a36Sopenharmony_ci { .compatible = "fsl,imx8ulp-pcc3", .data = imx8ulp_clk_pcc3_init }, 55062306a36Sopenharmony_ci { .compatible = "fsl,imx8ulp-pcc4", .data = imx8ulp_clk_pcc4_init }, 55162306a36Sopenharmony_ci { .compatible = "fsl,imx8ulp-pcc5", .data = imx8ulp_clk_pcc5_init }, 55262306a36Sopenharmony_ci { .compatible = "fsl,imx8ulp-cgc2", .data = imx8ulp_clk_cgc2_init }, 55362306a36Sopenharmony_ci { .compatible = "fsl,imx8ulp-cgc1", .data = imx8ulp_clk_cgc1_init }, 55462306a36Sopenharmony_ci { /* sentinel */ }, 55562306a36Sopenharmony_ci}; 55662306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, imx8ulp_clk_dt_ids); 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_cistatic struct platform_driver imx8ulp_clk_driver = { 55962306a36Sopenharmony_ci .probe = imx8ulp_clk_probe, 56062306a36Sopenharmony_ci .driver = { 56162306a36Sopenharmony_ci .name = KBUILD_MODNAME, 56262306a36Sopenharmony_ci .suppress_bind_attrs = true, 56362306a36Sopenharmony_ci .of_match_table = imx8ulp_clk_dt_ids, 56462306a36Sopenharmony_ci }, 56562306a36Sopenharmony_ci}; 56662306a36Sopenharmony_cimodule_platform_driver(imx8ulp_clk_driver); 56762306a36Sopenharmony_ci 56862306a36Sopenharmony_ciMODULE_AUTHOR("Peng Fan <peng.fan@nxp.com>"); 56962306a36Sopenharmony_ciMODULE_DESCRIPTION("NXP i.MX8ULP clock driver"); 57062306a36Sopenharmony_ciMODULE_LICENSE("GPL v2"); 571