162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Hisilicon Hi6220 clock driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2015 Hisilicon Limited. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Author: Bintian Wang <bintian.wang@huawei.com> 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <linux/kernel.h> 1162306a36Sopenharmony_ci#include <linux/clk-provider.h> 1262306a36Sopenharmony_ci#include <linux/clkdev.h> 1362306a36Sopenharmony_ci#include <linux/io.h> 1462306a36Sopenharmony_ci#include <linux/slab.h> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#include <dt-bindings/clock/hi6220-clock.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#include "clk.h" 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* clocks in AO (always on) controller */ 2262306a36Sopenharmony_cistatic struct hisi_fixed_rate_clock hi6220_fixed_rate_clks[] __initdata = { 2362306a36Sopenharmony_ci { HI6220_REF32K, "ref32k", NULL, 0, 32764, }, 2462306a36Sopenharmony_ci { HI6220_CLK_TCXO, "clk_tcxo", NULL, 0, 19200000, }, 2562306a36Sopenharmony_ci { HI6220_MMC1_PAD, "mmc1_pad", NULL, 0, 100000000, }, 2662306a36Sopenharmony_ci { HI6220_MMC2_PAD, "mmc2_pad", NULL, 0, 100000000, }, 2762306a36Sopenharmony_ci { HI6220_MMC0_PAD, "mmc0_pad", NULL, 0, 200000000, }, 2862306a36Sopenharmony_ci { HI6220_PLL_BBP, "bbppll0", NULL, 0, 245760000, }, 2962306a36Sopenharmony_ci { HI6220_PLL_GPU, "gpupll", NULL, 0, 1000000000,}, 3062306a36Sopenharmony_ci { HI6220_PLL1_DDR, "ddrpll1", NULL, 0, 1066000000,}, 3162306a36Sopenharmony_ci { HI6220_PLL_SYS, "syspll", NULL, 0, 1190400000,}, 3262306a36Sopenharmony_ci { HI6220_PLL_SYS_MEDIA, "media_syspll", NULL, 0, 1190400000,}, 3362306a36Sopenharmony_ci { HI6220_DDR_SRC, "ddr_sel_src", NULL, 0, 1200000000,}, 3462306a36Sopenharmony_ci { HI6220_PLL_MEDIA, "media_pll", NULL, 0, 1440000000,}, 3562306a36Sopenharmony_ci { HI6220_PLL_DDR, "ddrpll0", NULL, 0, 1600000000,}, 3662306a36Sopenharmony_ci}; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_cistatic struct hisi_fixed_factor_clock hi6220_fixed_factor_clks[] __initdata = { 3962306a36Sopenharmony_ci { HI6220_300M, "clk_300m", "syspll", 1, 4, 0, }, 4062306a36Sopenharmony_ci { HI6220_150M, "clk_150m", "clk_300m", 1, 2, 0, }, 4162306a36Sopenharmony_ci { HI6220_PICOPHY_SRC, "picophy_src", "clk_150m", 1, 4, 0, }, 4262306a36Sopenharmony_ci { HI6220_MMC0_SRC_SEL, "mmc0srcsel", "mmc0_sel", 1, 8, 0, }, 4362306a36Sopenharmony_ci { HI6220_MMC1_SRC_SEL, "mmc1srcsel", "mmc1_sel", 1, 8, 0, }, 4462306a36Sopenharmony_ci { HI6220_MMC2_SRC_SEL, "mmc2srcsel", "mmc2_sel", 1, 8, 0, }, 4562306a36Sopenharmony_ci { HI6220_VPU_CODEC, "vpucodec", "codec_jpeg_aclk", 1, 2, 0, }, 4662306a36Sopenharmony_ci { HI6220_MMC0_SMP, "mmc0_sample", "mmc0_sel", 1, 8, 0, }, 4762306a36Sopenharmony_ci { HI6220_MMC1_SMP, "mmc1_sample", "mmc1_sel", 1, 8, 0, }, 4862306a36Sopenharmony_ci { HI6220_MMC2_SMP, "mmc2_sample", "mmc2_sel", 1, 8, 0, }, 4962306a36Sopenharmony_ci}; 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_cistatic struct hisi_gate_clock hi6220_separated_gate_clks_ao[] __initdata = { 5262306a36Sopenharmony_ci { HI6220_WDT0_PCLK, "wdt0_pclk", "ref32k", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 12, 0, }, 5362306a36Sopenharmony_ci { HI6220_WDT1_PCLK, "wdt1_pclk", "ref32k", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 13, 0, }, 5462306a36Sopenharmony_ci { HI6220_WDT2_PCLK, "wdt2_pclk", "ref32k", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 14, 0, }, 5562306a36Sopenharmony_ci { HI6220_TIMER0_PCLK, "timer0_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 15, 0, }, 5662306a36Sopenharmony_ci { HI6220_TIMER1_PCLK, "timer1_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 16, 0, }, 5762306a36Sopenharmony_ci { HI6220_TIMER2_PCLK, "timer2_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 17, 0, }, 5862306a36Sopenharmony_ci { HI6220_TIMER3_PCLK, "timer3_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 18, 0, }, 5962306a36Sopenharmony_ci { HI6220_TIMER4_PCLK, "timer4_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 19, 0, }, 6062306a36Sopenharmony_ci { HI6220_TIMER5_PCLK, "timer5_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 20, 0, }, 6162306a36Sopenharmony_ci { HI6220_TIMER6_PCLK, "timer6_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 21, 0, }, 6262306a36Sopenharmony_ci { HI6220_TIMER7_PCLK, "timer7_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 22, 0, }, 6362306a36Sopenharmony_ci { HI6220_TIMER8_PCLK, "timer8_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 23, 0, }, 6462306a36Sopenharmony_ci { HI6220_UART0_PCLK, "uart0_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 24, 0, }, 6562306a36Sopenharmony_ci { HI6220_RTC0_PCLK, "rtc0_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 25, 0, }, 6662306a36Sopenharmony_ci { HI6220_RTC1_PCLK, "rtc1_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 26, 0, }, 6762306a36Sopenharmony_ci}; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_cistatic void __init hi6220_clk_ao_init(struct device_node *np) 7062306a36Sopenharmony_ci{ 7162306a36Sopenharmony_ci struct hisi_clock_data *clk_data_ao; 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci clk_data_ao = hisi_clk_init(np, HI6220_AO_NR_CLKS); 7462306a36Sopenharmony_ci if (!clk_data_ao) 7562306a36Sopenharmony_ci return; 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci hisi_clk_register_fixed_rate(hi6220_fixed_rate_clks, 7862306a36Sopenharmony_ci ARRAY_SIZE(hi6220_fixed_rate_clks), clk_data_ao); 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci hisi_clk_register_fixed_factor(hi6220_fixed_factor_clks, 8162306a36Sopenharmony_ci ARRAY_SIZE(hi6220_fixed_factor_clks), clk_data_ao); 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci hisi_clk_register_gate_sep(hi6220_separated_gate_clks_ao, 8462306a36Sopenharmony_ci ARRAY_SIZE(hi6220_separated_gate_clks_ao), clk_data_ao); 8562306a36Sopenharmony_ci} 8662306a36Sopenharmony_ci/* Allow reset driver to probe as well */ 8762306a36Sopenharmony_ciCLK_OF_DECLARE_DRIVER(hi6220_clk_ao, "hisilicon,hi6220-aoctrl", hi6220_clk_ao_init); 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* clocks in sysctrl */ 9162306a36Sopenharmony_cistatic const char *mmc0_mux0_p[] __initdata = { "pll_ddr_gate", "syspll", }; 9262306a36Sopenharmony_cistatic const char *mmc0_mux1_p[] __initdata = { "mmc0_mux0", "pll_media_gate", }; 9362306a36Sopenharmony_cistatic const char *mmc0_src_p[] __initdata = { "mmc0srcsel", "mmc0_div", }; 9462306a36Sopenharmony_cistatic const char *mmc1_mux0_p[] __initdata = { "pll_ddr_gate", "syspll", }; 9562306a36Sopenharmony_cistatic const char *mmc1_mux1_p[] __initdata = { "mmc1_mux0", "pll_media_gate", }; 9662306a36Sopenharmony_cistatic const char *mmc1_src_p[] __initdata = { "mmc1srcsel", "mmc1_div", }; 9762306a36Sopenharmony_cistatic const char *mmc2_mux0_p[] __initdata = { "pll_ddr_gate", "syspll", }; 9862306a36Sopenharmony_cistatic const char *mmc2_mux1_p[] __initdata = { "mmc2_mux0", "pll_media_gate", }; 9962306a36Sopenharmony_cistatic const char *mmc2_src_p[] __initdata = { "mmc2srcsel", "mmc2_div", }; 10062306a36Sopenharmony_cistatic const char *mmc0_sample_in[] __initdata = { "mmc0_sample", "mmc0_pad", }; 10162306a36Sopenharmony_cistatic const char *mmc1_sample_in[] __initdata = { "mmc1_sample", "mmc1_pad", }; 10262306a36Sopenharmony_cistatic const char *mmc2_sample_in[] __initdata = { "mmc2_sample", "mmc2_pad", }; 10362306a36Sopenharmony_cistatic const char *uart1_src[] __initdata = { "clk_tcxo", "clk_150m", }; 10462306a36Sopenharmony_cistatic const char *uart2_src[] __initdata = { "clk_tcxo", "clk_150m", }; 10562306a36Sopenharmony_cistatic const char *uart3_src[] __initdata = { "clk_tcxo", "clk_150m", }; 10662306a36Sopenharmony_cistatic const char *uart4_src[] __initdata = { "clk_tcxo", "clk_150m", }; 10762306a36Sopenharmony_cistatic const char *hifi_src[] __initdata = { "syspll", "pll_media_gate", }; 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cistatic struct hisi_gate_clock hi6220_separated_gate_clks_sys[] __initdata = { 11062306a36Sopenharmony_ci { HI6220_MMC0_CLK, "mmc0_clk", "mmc0_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 0, 0, }, 11162306a36Sopenharmony_ci { HI6220_MMC0_CIUCLK, "mmc0_ciuclk", "mmc0_smp_in", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 0, 0, }, 11262306a36Sopenharmony_ci { HI6220_MMC1_CLK, "mmc1_clk", "mmc1_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 1, 0, }, 11362306a36Sopenharmony_ci { HI6220_MMC1_CIUCLK, "mmc1_ciuclk", "mmc1_smp_in", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 1, 0, }, 11462306a36Sopenharmony_ci { HI6220_MMC2_CLK, "mmc2_clk", "mmc2_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 2, 0, }, 11562306a36Sopenharmony_ci { HI6220_MMC2_CIUCLK, "mmc2_ciuclk", "mmc2_smp_in", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 2, 0, }, 11662306a36Sopenharmony_ci { HI6220_USBOTG_HCLK, "usbotg_hclk", "clk_bus", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 4, 0, }, 11762306a36Sopenharmony_ci { HI6220_CLK_PICOPHY, "clk_picophy", "cs_dapb", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 5, 0, }, 11862306a36Sopenharmony_ci { HI6220_HIFI, "hifi_clk", "hifi_div", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x210, 0, 0, }, 11962306a36Sopenharmony_ci { HI6220_DACODEC_PCLK, "dacodec_pclk", "clk_bus", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x210, 5, 0, }, 12062306a36Sopenharmony_ci { HI6220_EDMAC_ACLK, "edmac_aclk", "clk_bus", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x220, 2, 0, }, 12162306a36Sopenharmony_ci { HI6220_CS_ATB, "cs_atb", "cs_atb_div", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 0, 0, }, 12262306a36Sopenharmony_ci { HI6220_I2C0_CLK, "i2c0_clk", "clk_150m", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 1, 0, }, 12362306a36Sopenharmony_ci { HI6220_I2C1_CLK, "i2c1_clk", "clk_150m", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 2, 0, }, 12462306a36Sopenharmony_ci { HI6220_I2C2_CLK, "i2c2_clk", "clk_150m", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 3, 0, }, 12562306a36Sopenharmony_ci { HI6220_I2C3_CLK, "i2c3_clk", "clk_150m", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 4, 0, }, 12662306a36Sopenharmony_ci { HI6220_UART1_PCLK, "uart1_pclk", "uart1_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 5, 0, }, 12762306a36Sopenharmony_ci { HI6220_UART2_PCLK, "uart2_pclk", "uart2_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 6, 0, }, 12862306a36Sopenharmony_ci { HI6220_UART3_PCLK, "uart3_pclk", "uart3_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 7, 0, }, 12962306a36Sopenharmony_ci { HI6220_UART4_PCLK, "uart4_pclk", "uart4_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 8, 0, }, 13062306a36Sopenharmony_ci { HI6220_SPI_CLK, "spi_clk", "clk_150m", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 9, 0, }, 13162306a36Sopenharmony_ci { HI6220_TSENSOR_CLK, "tsensor_clk", "clk_bus", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 12, 0, }, 13262306a36Sopenharmony_ci { HI6220_DAPB_CLK, "dapb_clk", "cs_dapb", CLK_SET_RATE_PARENT|CLK_IS_CRITICAL, 0x230, 18, 0, }, 13362306a36Sopenharmony_ci { HI6220_MMU_CLK, "mmu_clk", "ddrc_axi1", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x240, 11, 0, }, 13462306a36Sopenharmony_ci { HI6220_HIFI_SEL, "hifi_sel", "hifi_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 0, 0, }, 13562306a36Sopenharmony_ci { HI6220_MMC0_SYSPLL, "mmc0_syspll", "syspll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 1, 0, }, 13662306a36Sopenharmony_ci { HI6220_MMC1_SYSPLL, "mmc1_syspll", "syspll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 2, 0, }, 13762306a36Sopenharmony_ci { HI6220_MMC2_SYSPLL, "mmc2_syspll", "syspll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 3, 0, }, 13862306a36Sopenharmony_ci { HI6220_MMC0_SEL, "mmc0_sel", "mmc0_mux1", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 6, 0, }, 13962306a36Sopenharmony_ci { HI6220_MMC1_SEL, "mmc1_sel", "mmc1_mux1", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 7, 0, }, 14062306a36Sopenharmony_ci { HI6220_BBPPLL_SEL, "bbppll_sel", "pll0_bbp_gate", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 9, 0, }, 14162306a36Sopenharmony_ci { HI6220_MEDIA_PLL_SRC, "media_pll_src", "pll_media_gate", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 10, 0, }, 14262306a36Sopenharmony_ci { HI6220_MMC2_SEL, "mmc2_sel", "mmc2_mux1", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 11, 0, }, 14362306a36Sopenharmony_ci { HI6220_CS_ATB_SYSPLL, "cs_atb_syspll", "syspll", CLK_SET_RATE_PARENT|CLK_IS_CRITICAL, 0x270, 12, 0, }, 14462306a36Sopenharmony_ci}; 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_cistatic struct hisi_mux_clock hi6220_mux_clks_sys[] __initdata = { 14762306a36Sopenharmony_ci { HI6220_MMC0_SRC, "mmc0_src", mmc0_src_p, ARRAY_SIZE(mmc0_src_p), CLK_SET_RATE_PARENT, 0x4, 0, 1, 0, }, 14862306a36Sopenharmony_ci { HI6220_MMC0_SMP_IN, "mmc0_smp_in", mmc0_sample_in, ARRAY_SIZE(mmc0_sample_in), CLK_SET_RATE_PARENT, 0x4, 0, 1, 0, }, 14962306a36Sopenharmony_ci { HI6220_MMC1_SRC, "mmc1_src", mmc1_src_p, ARRAY_SIZE(mmc1_src_p), CLK_SET_RATE_PARENT, 0x4, 2, 1, 0, }, 15062306a36Sopenharmony_ci { HI6220_MMC1_SMP_IN, "mmc1_smp_in", mmc1_sample_in, ARRAY_SIZE(mmc1_sample_in), CLK_SET_RATE_PARENT, 0x4, 2, 1, 0, }, 15162306a36Sopenharmony_ci { HI6220_MMC2_SRC, "mmc2_src", mmc2_src_p, ARRAY_SIZE(mmc2_src_p), CLK_SET_RATE_PARENT, 0x4, 4, 1, 0, }, 15262306a36Sopenharmony_ci { HI6220_MMC2_SMP_IN, "mmc2_smp_in", mmc2_sample_in, ARRAY_SIZE(mmc2_sample_in), CLK_SET_RATE_PARENT, 0x4, 4, 1, 0, }, 15362306a36Sopenharmony_ci { HI6220_HIFI_SRC, "hifi_src", hifi_src, ARRAY_SIZE(hifi_src), CLK_SET_RATE_PARENT, 0x400, 0, 1, CLK_MUX_HIWORD_MASK,}, 15462306a36Sopenharmony_ci { HI6220_UART1_SRC, "uart1_src", uart1_src, ARRAY_SIZE(uart1_src), CLK_SET_RATE_PARENT, 0x400, 1, 1, CLK_MUX_HIWORD_MASK,}, 15562306a36Sopenharmony_ci { HI6220_UART2_SRC, "uart2_src", uart2_src, ARRAY_SIZE(uart2_src), CLK_SET_RATE_PARENT, 0x400, 2, 1, CLK_MUX_HIWORD_MASK,}, 15662306a36Sopenharmony_ci { HI6220_UART3_SRC, "uart3_src", uart3_src, ARRAY_SIZE(uart3_src), CLK_SET_RATE_PARENT, 0x400, 3, 1, CLK_MUX_HIWORD_MASK,}, 15762306a36Sopenharmony_ci { HI6220_UART4_SRC, "uart4_src", uart4_src, ARRAY_SIZE(uart4_src), CLK_SET_RATE_PARENT, 0x400, 4, 1, CLK_MUX_HIWORD_MASK,}, 15862306a36Sopenharmony_ci { HI6220_MMC0_MUX0, "mmc0_mux0", mmc0_mux0_p, ARRAY_SIZE(mmc0_mux0_p), CLK_SET_RATE_PARENT, 0x400, 5, 1, CLK_MUX_HIWORD_MASK,}, 15962306a36Sopenharmony_ci { HI6220_MMC1_MUX0, "mmc1_mux0", mmc1_mux0_p, ARRAY_SIZE(mmc1_mux0_p), CLK_SET_RATE_PARENT, 0x400, 11, 1, CLK_MUX_HIWORD_MASK,}, 16062306a36Sopenharmony_ci { HI6220_MMC2_MUX0, "mmc2_mux0", mmc2_mux0_p, ARRAY_SIZE(mmc2_mux0_p), CLK_SET_RATE_PARENT, 0x400, 12, 1, CLK_MUX_HIWORD_MASK,}, 16162306a36Sopenharmony_ci { HI6220_MMC0_MUX1, "mmc0_mux1", mmc0_mux1_p, ARRAY_SIZE(mmc0_mux1_p), CLK_SET_RATE_PARENT, 0x400, 13, 1, CLK_MUX_HIWORD_MASK,}, 16262306a36Sopenharmony_ci { HI6220_MMC1_MUX1, "mmc1_mux1", mmc1_mux1_p, ARRAY_SIZE(mmc1_mux1_p), CLK_SET_RATE_PARENT, 0x400, 14, 1, CLK_MUX_HIWORD_MASK,}, 16362306a36Sopenharmony_ci { HI6220_MMC2_MUX1, "mmc2_mux1", mmc2_mux1_p, ARRAY_SIZE(mmc2_mux1_p), CLK_SET_RATE_PARENT, 0x400, 15, 1, CLK_MUX_HIWORD_MASK,}, 16462306a36Sopenharmony_ci}; 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_cistatic struct hi6220_divider_clock hi6220_div_clks_sys[] __initdata = { 16762306a36Sopenharmony_ci { HI6220_CLK_BUS, "clk_bus", "clk_300m", CLK_SET_RATE_PARENT, 0x490, 0, 4, 7, }, 16862306a36Sopenharmony_ci { HI6220_MMC0_DIV, "mmc0_div", "mmc0_syspll", CLK_SET_RATE_PARENT, 0x494, 0, 6, 7, }, 16962306a36Sopenharmony_ci { HI6220_MMC1_DIV, "mmc1_div", "mmc1_syspll", CLK_SET_RATE_PARENT, 0x498, 0, 6, 7, }, 17062306a36Sopenharmony_ci { HI6220_MMC2_DIV, "mmc2_div", "mmc2_syspll", CLK_SET_RATE_PARENT, 0x49c, 0, 6, 7, }, 17162306a36Sopenharmony_ci { HI6220_HIFI_DIV, "hifi_div", "hifi_sel", CLK_SET_RATE_PARENT, 0x4a0, 0, 4, 7, }, 17262306a36Sopenharmony_ci { HI6220_BBPPLL0_DIV, "bbppll0_div", "bbppll_sel", CLK_SET_RATE_PARENT, 0x4a0, 8, 6, 15,}, 17362306a36Sopenharmony_ci { HI6220_CS_DAPB, "cs_dapb", "picophy_src", CLK_SET_RATE_PARENT, 0x4a0, 24, 2, 31,}, 17462306a36Sopenharmony_ci { HI6220_CS_ATB_DIV, "cs_atb_div", "cs_atb_syspll", CLK_SET_RATE_PARENT, 0x4a4, 0, 4, 7, }, 17562306a36Sopenharmony_ci}; 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_cistatic void __init hi6220_clk_sys_init(struct device_node *np) 17862306a36Sopenharmony_ci{ 17962306a36Sopenharmony_ci struct hisi_clock_data *clk_data; 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci clk_data = hisi_clk_init(np, HI6220_SYS_NR_CLKS); 18262306a36Sopenharmony_ci if (!clk_data) 18362306a36Sopenharmony_ci return; 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci hisi_clk_register_gate_sep(hi6220_separated_gate_clks_sys, 18662306a36Sopenharmony_ci ARRAY_SIZE(hi6220_separated_gate_clks_sys), clk_data); 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci hisi_clk_register_mux(hi6220_mux_clks_sys, 18962306a36Sopenharmony_ci ARRAY_SIZE(hi6220_mux_clks_sys), clk_data); 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci hi6220_clk_register_divider(hi6220_div_clks_sys, 19262306a36Sopenharmony_ci ARRAY_SIZE(hi6220_div_clks_sys), clk_data); 19362306a36Sopenharmony_ci} 19462306a36Sopenharmony_ciCLK_OF_DECLARE_DRIVER(hi6220_clk_sys, "hisilicon,hi6220-sysctrl", hi6220_clk_sys_init); 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci/* clocks in media controller */ 19862306a36Sopenharmony_cistatic const char *clk_1000_1200_src[] __initdata = { "pll_gpu_gate", "media_syspll_src", }; 19962306a36Sopenharmony_cistatic const char *clk_1440_1200_src[] __initdata = { "media_syspll_src", "media_pll_src", }; 20062306a36Sopenharmony_cistatic const char *clk_1000_1440_src[] __initdata = { "pll_gpu_gate", "media_pll_src", }; 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_cistatic struct hisi_gate_clock hi6220_separated_gate_clks_media[] __initdata = { 20362306a36Sopenharmony_ci { HI6220_DSI_PCLK, "dsi_pclk", "vpucodec", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 0, 0, }, 20462306a36Sopenharmony_ci { HI6220_G3D_PCLK, "g3d_pclk", "vpucodec", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 1, 0, }, 20562306a36Sopenharmony_ci { HI6220_ACLK_CODEC_VPU, "aclk_codec_vpu", "ade_core_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 3, 0, }, 20662306a36Sopenharmony_ci { HI6220_ISP_SCLK, "isp_sclk", "isp_sclk_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 5, 0, }, 20762306a36Sopenharmony_ci { HI6220_ADE_CORE, "ade_core", "ade_core_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 6, 0, }, 20862306a36Sopenharmony_ci { HI6220_MED_MMU, "media_mmu", "mmu_clk", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 8, 0, }, 20962306a36Sopenharmony_ci { HI6220_CFG_CSI4PHY, "cfg_csi4phy", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 9, 0, }, 21062306a36Sopenharmony_ci { HI6220_CFG_CSI2PHY, "cfg_csi2phy", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 10, 0, }, 21162306a36Sopenharmony_ci { HI6220_ISP_SCLK_GATE, "isp_sclk_gate", "media_pll_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 11, 0, }, 21262306a36Sopenharmony_ci { HI6220_ISP_SCLK_GATE1, "isp_sclk_gate1", "media_pll_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 12, 0, }, 21362306a36Sopenharmony_ci { HI6220_ADE_CORE_GATE, "ade_core_gate", "media_pll_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 14, 0, }, 21462306a36Sopenharmony_ci { HI6220_CODEC_VPU_GATE, "codec_vpu_gate", "clk_1000_1440", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 15, 0, }, 21562306a36Sopenharmony_ci { HI6220_MED_SYSPLL, "media_syspll_src", "media_syspll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 17, 0, }, 21662306a36Sopenharmony_ci}; 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_cistatic struct hisi_mux_clock hi6220_mux_clks_media[] __initdata = { 21962306a36Sopenharmony_ci { HI6220_1440_1200, "clk_1440_1200", clk_1440_1200_src, ARRAY_SIZE(clk_1440_1200_src), CLK_SET_RATE_PARENT, 0x51c, 0, 1, 0, }, 22062306a36Sopenharmony_ci { HI6220_1000_1200, "clk_1000_1200", clk_1000_1200_src, ARRAY_SIZE(clk_1000_1200_src), CLK_SET_RATE_PARENT, 0x51c, 1, 1, 0, }, 22162306a36Sopenharmony_ci { HI6220_1000_1440, "clk_1000_1440", clk_1000_1440_src, ARRAY_SIZE(clk_1000_1440_src), CLK_SET_RATE_PARENT, 0x51c, 6, 1, 0, }, 22262306a36Sopenharmony_ci}; 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_cistatic struct hi6220_divider_clock hi6220_div_clks_media[] __initdata = { 22562306a36Sopenharmony_ci { HI6220_CODEC_JPEG, "codec_jpeg_aclk", "media_pll_src", CLK_SET_RATE_PARENT, 0xcbc, 0, 4, 23, }, 22662306a36Sopenharmony_ci { HI6220_ISP_SCLK_SRC, "isp_sclk_src", "isp_sclk_gate", CLK_SET_RATE_PARENT, 0xcbc, 8, 4, 15, }, 22762306a36Sopenharmony_ci { HI6220_ISP_SCLK1, "isp_sclk1", "isp_sclk_gate1", CLK_SET_RATE_PARENT, 0xcbc, 24, 4, 31, }, 22862306a36Sopenharmony_ci { HI6220_ADE_CORE_SRC, "ade_core_src", "ade_core_gate", CLK_SET_RATE_PARENT, 0xcc0, 16, 3, 23, }, 22962306a36Sopenharmony_ci { HI6220_ADE_PIX_SRC, "ade_pix_src", "clk_1440_1200", CLK_SET_RATE_PARENT, 0xcc0, 24, 6, 31, }, 23062306a36Sopenharmony_ci { HI6220_G3D_CLK, "g3d_clk", "clk_1000_1200", CLK_SET_RATE_PARENT, 0xcc4, 8, 4, 15, }, 23162306a36Sopenharmony_ci { HI6220_CODEC_VPU_SRC, "codec_vpu_src", "codec_vpu_gate", CLK_SET_RATE_PARENT, 0xcc4, 24, 6, 31, }, 23262306a36Sopenharmony_ci}; 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_cistatic void __init hi6220_clk_media_init(struct device_node *np) 23562306a36Sopenharmony_ci{ 23662306a36Sopenharmony_ci struct hisi_clock_data *clk_data; 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ci clk_data = hisi_clk_init(np, HI6220_MEDIA_NR_CLKS); 23962306a36Sopenharmony_ci if (!clk_data) 24062306a36Sopenharmony_ci return; 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci hisi_clk_register_gate_sep(hi6220_separated_gate_clks_media, 24362306a36Sopenharmony_ci ARRAY_SIZE(hi6220_separated_gate_clks_media), clk_data); 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci hisi_clk_register_mux(hi6220_mux_clks_media, 24662306a36Sopenharmony_ci ARRAY_SIZE(hi6220_mux_clks_media), clk_data); 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ci hi6220_clk_register_divider(hi6220_div_clks_media, 24962306a36Sopenharmony_ci ARRAY_SIZE(hi6220_div_clks_media), clk_data); 25062306a36Sopenharmony_ci} 25162306a36Sopenharmony_ciCLK_OF_DECLARE_DRIVER(hi6220_clk_media, "hisilicon,hi6220-mediactrl", hi6220_clk_media_init); 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci/* clocks in pmctrl */ 25562306a36Sopenharmony_cistatic struct hisi_gate_clock hi6220_gate_clks_power[] __initdata = { 25662306a36Sopenharmony_ci { HI6220_PLL_GPU_GATE, "pll_gpu_gate", "gpupll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x8, 0, 0, }, 25762306a36Sopenharmony_ci { HI6220_PLL1_DDR_GATE, "pll1_ddr_gate", "ddrpll1", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x10, 0, 0, }, 25862306a36Sopenharmony_ci { HI6220_PLL_DDR_GATE, "pll_ddr_gate", "ddrpll0", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x18, 0, 0, }, 25962306a36Sopenharmony_ci { HI6220_PLL_MEDIA_GATE, "pll_media_gate", "media_pll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x38, 0, 0, }, 26062306a36Sopenharmony_ci { HI6220_PLL0_BBP_GATE, "pll0_bbp_gate", "bbppll0", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x48, 0, 0, }, 26162306a36Sopenharmony_ci}; 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_cistatic struct hi6220_divider_clock hi6220_div_clks_power[] __initdata = { 26462306a36Sopenharmony_ci { HI6220_DDRC_SRC, "ddrc_src", "ddr_sel_src", CLK_SET_RATE_PARENT, 0x5a8, 0, 4, 0, }, 26562306a36Sopenharmony_ci { HI6220_DDRC_AXI1, "ddrc_axi1", "ddrc_src", CLK_SET_RATE_PARENT, 0x5a8, 8, 2, 0, }, 26662306a36Sopenharmony_ci}; 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_cistatic void __init hi6220_clk_power_init(struct device_node *np) 26962306a36Sopenharmony_ci{ 27062306a36Sopenharmony_ci struct hisi_clock_data *clk_data; 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_ci clk_data = hisi_clk_init(np, HI6220_POWER_NR_CLKS); 27362306a36Sopenharmony_ci if (!clk_data) 27462306a36Sopenharmony_ci return; 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci hisi_clk_register_gate(hi6220_gate_clks_power, 27762306a36Sopenharmony_ci ARRAY_SIZE(hi6220_gate_clks_power), clk_data); 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci hi6220_clk_register_divider(hi6220_div_clks_power, 28062306a36Sopenharmony_ci ARRAY_SIZE(hi6220_div_clks_power), clk_data); 28162306a36Sopenharmony_ci} 28262306a36Sopenharmony_ciCLK_OF_DECLARE(hi6220_clk_power, "hisilicon,hi6220-pmctrl", hi6220_clk_power_init); 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci/* clocks in acpu */ 28562306a36Sopenharmony_cistatic const struct hisi_gate_clock hi6220_acpu_sc_gate_sep_clks[] = { 28662306a36Sopenharmony_ci { HI6220_ACPU_SFT_AT_S, "sft_at_s", "cs_atb", 28762306a36Sopenharmony_ci CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0xc, 11, 0, }, 28862306a36Sopenharmony_ci}; 28962306a36Sopenharmony_ci 29062306a36Sopenharmony_cistatic void __init hi6220_clk_acpu_init(struct device_node *np) 29162306a36Sopenharmony_ci{ 29262306a36Sopenharmony_ci struct hisi_clock_data *clk_data; 29362306a36Sopenharmony_ci int nr = ARRAY_SIZE(hi6220_acpu_sc_gate_sep_clks); 29462306a36Sopenharmony_ci 29562306a36Sopenharmony_ci clk_data = hisi_clk_init(np, nr); 29662306a36Sopenharmony_ci if (!clk_data) 29762306a36Sopenharmony_ci return; 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ci hisi_clk_register_gate_sep(hi6220_acpu_sc_gate_sep_clks, 30062306a36Sopenharmony_ci ARRAY_SIZE(hi6220_acpu_sc_gate_sep_clks), 30162306a36Sopenharmony_ci clk_data); 30262306a36Sopenharmony_ci} 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ciCLK_OF_DECLARE(hi6220_clk_acpu, "hisilicon,hi6220-acpu-sctrl", hi6220_clk_acpu_init); 305