18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2016 Icenowy Zheng <icenowy@aosc.io>
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
88c2ecf20Sopenharmony_ci#include <linux/io.h>
98c2ecf20Sopenharmony_ci#include <linux/of_address.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "ccu_common.h"
128c2ecf20Sopenharmony_ci#include "ccu_reset.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "ccu_div.h"
158c2ecf20Sopenharmony_ci#include "ccu_gate.h"
168c2ecf20Sopenharmony_ci#include "ccu_mp.h"
178c2ecf20Sopenharmony_ci#include "ccu_mult.h"
188c2ecf20Sopenharmony_ci#include "ccu_nk.h"
198c2ecf20Sopenharmony_ci#include "ccu_nkm.h"
208c2ecf20Sopenharmony_ci#include "ccu_nkmp.h"
218c2ecf20Sopenharmony_ci#include "ccu_nm.h"
228c2ecf20Sopenharmony_ci#include "ccu_phase.h"
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include "ccu-suniv-f1c100s.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistatic struct ccu_nkmp pll_cpu_clk = {
278c2ecf20Sopenharmony_ci	.enable = BIT(31),
288c2ecf20Sopenharmony_ci	.lock	= BIT(28),
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	.n	= _SUNXI_CCU_MULT(8, 5),
318c2ecf20Sopenharmony_ci	.k	= _SUNXI_CCU_MULT(4, 2),
328c2ecf20Sopenharmony_ci	.m	= _SUNXI_CCU_DIV(0, 2),
338c2ecf20Sopenharmony_ci	/* MAX is guessed by the BSP table */
348c2ecf20Sopenharmony_ci	.p	= _SUNXI_CCU_DIV_MAX(16, 2, 4),
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	.common	= {
378c2ecf20Sopenharmony_ci		.reg		= 0x000,
388c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-cpu", "osc24M",
398c2ecf20Sopenharmony_ci					      &ccu_nkmp_ops,
408c2ecf20Sopenharmony_ci					      CLK_SET_RATE_UNGATE),
418c2ecf20Sopenharmony_ci	},
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/*
458c2ecf20Sopenharmony_ci * The Audio PLL is supposed to have 4 outputs: 3 fixed factors from
468c2ecf20Sopenharmony_ci * the base (2x, 4x and 8x), and one variable divider (the one true
478c2ecf20Sopenharmony_ci * pll audio).
488c2ecf20Sopenharmony_ci *
498c2ecf20Sopenharmony_ci * We don't have any need for the variable divider for now, so we just
508c2ecf20Sopenharmony_ci * hardcode it to match with the clock names
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci#define SUNIV_PLL_AUDIO_REG	0x008
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base",
558c2ecf20Sopenharmony_ci				   "osc24M", 0x008,
568c2ecf20Sopenharmony_ci				   8, 7,		/* N */
578c2ecf20Sopenharmony_ci				   0, 5,		/* M */
588c2ecf20Sopenharmony_ci				   BIT(31),		/* gate */
598c2ecf20Sopenharmony_ci				   BIT(28),		/* lock */
608c2ecf20Sopenharmony_ci				   CLK_SET_RATE_UNGATE);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video",
638c2ecf20Sopenharmony_ci					"osc24M", 0x010,
648c2ecf20Sopenharmony_ci					8, 7,		/* N */
658c2ecf20Sopenharmony_ci					0, 4,		/* M */
668c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
678c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
688c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
698c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
708c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
718c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
728c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve",
758c2ecf20Sopenharmony_ci					"osc24M", 0x018,
768c2ecf20Sopenharmony_ci					8, 7,		/* N */
778c2ecf20Sopenharmony_ci					0, 4,		/* M */
788c2ecf20Sopenharmony_ci					BIT(24),	/* frac enable */
798c2ecf20Sopenharmony_ci					BIT(25),	/* frac select */
808c2ecf20Sopenharmony_ci					270000000,	/* frac rate 0 */
818c2ecf20Sopenharmony_ci					297000000,	/* frac rate 1 */
828c2ecf20Sopenharmony_ci					BIT(31),	/* gate */
838c2ecf20Sopenharmony_ci					BIT(28),	/* lock */
848c2ecf20Sopenharmony_ci					CLK_SET_RATE_UNGATE);
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr",
878c2ecf20Sopenharmony_ci				    "osc24M", 0x020,
888c2ecf20Sopenharmony_ci				    8, 5,		/* N */
898c2ecf20Sopenharmony_ci				    4, 2,		/* K */
908c2ecf20Sopenharmony_ci				    0, 2,		/* M */
918c2ecf20Sopenharmony_ci				    BIT(31),		/* gate */
928c2ecf20Sopenharmony_ci				    BIT(28),		/* lock */
938c2ecf20Sopenharmony_ci				    CLK_IS_CRITICAL);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_cistatic struct ccu_nk pll_periph_clk = {
968c2ecf20Sopenharmony_ci	.enable		= BIT(31),
978c2ecf20Sopenharmony_ci	.lock		= BIT(28),
988c2ecf20Sopenharmony_ci	.k		= _SUNXI_CCU_MULT(4, 2),
998c2ecf20Sopenharmony_ci	.n		= _SUNXI_CCU_MULT(8, 5),
1008c2ecf20Sopenharmony_ci	.common		= {
1018c2ecf20Sopenharmony_ci		.reg		= 0x028,
1028c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT("pll-periph", "osc24M",
1038c2ecf20Sopenharmony_ci					      &ccu_nk_ops, 0),
1048c2ecf20Sopenharmony_ci	},
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistatic const char * const cpu_parents[] = { "osc32k", "osc24M",
1088c2ecf20Sopenharmony_ci					     "pll-cpu", "pll-cpu" };
1098c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents,
1108c2ecf20Sopenharmony_ci		     0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_cistatic const char * const ahb_parents[] = { "osc32k", "osc24M",
1138c2ecf20Sopenharmony_ci					    "cpu", "pll-periph" };
1148c2ecf20Sopenharmony_cistatic const struct ccu_mux_var_prediv ahb_predivs[] = {
1158c2ecf20Sopenharmony_ci	{ .index = 3, .shift = 6, .width = 2 },
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_cistatic struct ccu_div ahb_clk = {
1188c2ecf20Sopenharmony_ci	.div		= _SUNXI_CCU_DIV_FLAGS(4, 2, CLK_DIVIDER_POWER_OF_TWO),
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	.mux		= {
1218c2ecf20Sopenharmony_ci		.shift	= 12,
1228c2ecf20Sopenharmony_ci		.width	= 2,
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci		.var_predivs	= ahb_predivs,
1258c2ecf20Sopenharmony_ci		.n_var_predivs	= ARRAY_SIZE(ahb_predivs),
1268c2ecf20Sopenharmony_ci	},
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	.common		= {
1298c2ecf20Sopenharmony_ci		.reg		= 0x054,
1308c2ecf20Sopenharmony_ci		.features	= CCU_FEATURE_VARIABLE_PREDIV,
1318c2ecf20Sopenharmony_ci		.hw.init	= CLK_HW_INIT_PARENTS("ahb",
1328c2ecf20Sopenharmony_ci						      ahb_parents,
1338c2ecf20Sopenharmony_ci						      &ccu_div_ops,
1348c2ecf20Sopenharmony_ci						      0),
1358c2ecf20Sopenharmony_ci	},
1368c2ecf20Sopenharmony_ci};
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistatic struct clk_div_table apb_div_table[] = {
1398c2ecf20Sopenharmony_ci	{ .val = 0, .div = 2 },
1408c2ecf20Sopenharmony_ci	{ .val = 1, .div = 2 },
1418c2ecf20Sopenharmony_ci	{ .val = 2, .div = 4 },
1428c2ecf20Sopenharmony_ci	{ .val = 3, .div = 8 },
1438c2ecf20Sopenharmony_ci	{ /* Sentinel */ },
1448c2ecf20Sopenharmony_ci};
1458c2ecf20Sopenharmony_cistatic SUNXI_CCU_DIV_TABLE(apb_clk, "apb", "ahb",
1468c2ecf20Sopenharmony_ci			   0x054, 8, 2, apb_div_table, 0);
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dma_clk,	"bus-dma",	"ahb",
1498c2ecf20Sopenharmony_ci		      0x060, BIT(6), 0);
1508c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc0_clk,	"bus-mmc0",	"ahb",
1518c2ecf20Sopenharmony_ci		      0x060, BIT(8), 0);
1528c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_mmc1_clk,	"bus-mmc1",	"ahb",
1538c2ecf20Sopenharmony_ci		      0x060, BIT(9), 0);
1548c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_dram_clk,	"bus-dram",	"ahb",
1558c2ecf20Sopenharmony_ci		      0x060, BIT(14), 0);
1568c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi0_clk,	"bus-spi0",	"ahb",
1578c2ecf20Sopenharmony_ci		      0x060, BIT(20), 0);
1588c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spi1_clk,	"bus-spi1",	"ahb",
1598c2ecf20Sopenharmony_ci		      0x060, BIT(21), 0);
1608c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_otg_clk,	"bus-otg",	"ahb",
1618c2ecf20Sopenharmony_ci		      0x060, BIT(24), 0);
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ve_clk,	"bus-ve",	"ahb",
1648c2ecf20Sopenharmony_ci		      0x064, BIT(0), 0);
1658c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_lcd_clk,	"bus-lcd",	"ahb",
1668c2ecf20Sopenharmony_ci		      0x064, BIT(4), 0);
1678c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_deinterlace_clk,	"bus-deinterlace",	"ahb",
1688c2ecf20Sopenharmony_ci		      0x064, BIT(5), 0);
1698c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_csi_clk,	"bus-csi",	"ahb",
1708c2ecf20Sopenharmony_ci		      0x064, BIT(8), 0);
1718c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tvd_clk,	"bus-tvd",	"ahb",
1728c2ecf20Sopenharmony_ci		      0x064, BIT(9), 0);
1738c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_tve_clk,	"bus-tve",	"ahb",
1748c2ecf20Sopenharmony_ci		      0x064, BIT(10), 0);
1758c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_be_clk,	"bus-de-be",	"ahb",
1768c2ecf20Sopenharmony_ci		      0x064, BIT(12), 0);
1778c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_de_fe_clk,	"bus-de-fe",	"ahb",
1788c2ecf20Sopenharmony_ci		      0x064, BIT(14), 0);
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_codec_clk,	"bus-codec",	"apb",
1818c2ecf20Sopenharmony_ci		      0x068, BIT(0), 0);
1828c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_spdif_clk,	"bus-spdif",	"apb",
1838c2ecf20Sopenharmony_ci		      0x068, BIT(1), 0);
1848c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_ir_clk,	"bus-ir",	"apb",
1858c2ecf20Sopenharmony_ci		      0x068, BIT(2), 0);
1868c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_rsb_clk,	"bus-rsb",	"apb",
1878c2ecf20Sopenharmony_ci		      0x068, BIT(3), 0);
1888c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2s0_clk,	"bus-i2s0",	"apb",
1898c2ecf20Sopenharmony_ci		      0x068, BIT(12), 0);
1908c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c0_clk,	"bus-i2c0",	"apb",
1918c2ecf20Sopenharmony_ci		      0x068, BIT(16), 0);
1928c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c1_clk,	"bus-i2c1",	"apb",
1938c2ecf20Sopenharmony_ci		      0x068, BIT(17), 0);
1948c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_i2c2_clk,	"bus-i2c2",	"apb",
1958c2ecf20Sopenharmony_ci		      0x068, BIT(18), 0);
1968c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_pio_clk,	"bus-pio",	"apb",
1978c2ecf20Sopenharmony_ci		      0x068, BIT(19), 0);
1988c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart0_clk,	"bus-uart0",	"apb",
1998c2ecf20Sopenharmony_ci		      0x068, BIT(20), 0);
2008c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart1_clk,	"bus-uart1",	"apb",
2018c2ecf20Sopenharmony_ci		      0x068, BIT(21), 0);
2028c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(bus_uart2_clk,	"bus-uart2",	"apb",
2038c2ecf20Sopenharmony_ci		      0x068, BIT(22), 0);
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_cistatic const char * const mod0_default_parents[] = { "osc24M", "pll-periph" };
2068c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc0_clk, "mmc0", mod0_default_parents, 0x088,
2078c2ecf20Sopenharmony_ci				  0, 4,		/* M */
2088c2ecf20Sopenharmony_ci				  16, 2,	/* P */
2098c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
2108c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
2118c2ecf20Sopenharmony_ci				  0);
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_sample_clk, "mmc0_sample", "mmc0",
2148c2ecf20Sopenharmony_ci		       0x088, 20, 3, 0);
2158c2ecf20Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc0_output_clk, "mmc0_output", "mmc0",
2168c2ecf20Sopenharmony_ci		       0x088, 8, 3, 0);
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistatic SUNXI_CCU_MP_WITH_MUX_GATE(mmc1_clk, "mmc1", mod0_default_parents, 0x08c,
2198c2ecf20Sopenharmony_ci				  0, 4,		/* M */
2208c2ecf20Sopenharmony_ci				  16, 2,	/* P */
2218c2ecf20Sopenharmony_ci				  24, 2,	/* mux */
2228c2ecf20Sopenharmony_ci				  BIT(31),	/* gate */
2238c2ecf20Sopenharmony_ci				  0);
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_sample_clk, "mmc1_sample", "mmc1",
2268c2ecf20Sopenharmony_ci		       0x08c, 20, 3, 0);
2278c2ecf20Sopenharmony_cistatic SUNXI_CCU_PHASE(mmc1_output_clk, "mmc1_output", "mmc1",
2288c2ecf20Sopenharmony_ci		       0x08c, 8, 3, 0);
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistatic const char * const i2s_spdif_parents[] = { "pll-audio-8x",
2318c2ecf20Sopenharmony_ci						  "pll-audio-4x",
2328c2ecf20Sopenharmony_ci						  "pll-audio-2x",
2338c2ecf20Sopenharmony_ci						  "pll-audio" };
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(i2s_clk, "i2s", i2s_spdif_parents,
2368c2ecf20Sopenharmony_ci			       0x0b0, 16, 2, BIT(31), 0);
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_WITH_GATE(spdif_clk, "spdif", i2s_spdif_parents,
2398c2ecf20Sopenharmony_ci			       0x0b4, 16, 2, BIT(31), 0);
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/* The BSP header file has a CIR_CFG, but no mod clock uses this definition */
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(usb_phy0_clk,	"usb-phy0",	"osc24M",
2448c2ecf20Sopenharmony_ci		      0x0cc, BIT(1), 0);
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_ve_clk,	"dram-ve",	"pll-ddr",
2478c2ecf20Sopenharmony_ci		      0x100, BIT(0), 0);
2488c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_csi_clk,	"dram-csi",	"pll-ddr",
2498c2ecf20Sopenharmony_ci		      0x100, BIT(1), 0);
2508c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_deinterlace_clk,	"dram-deinterlace",
2518c2ecf20Sopenharmony_ci		      "pll-ddr", 0x100, BIT(2), 0);
2528c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_tvd_clk,	"dram-tvd",	"pll-ddr",
2538c2ecf20Sopenharmony_ci		      0x100, BIT(3), 0);
2548c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_de_fe_clk,	"dram-de-fe",	"pll-ddr",
2558c2ecf20Sopenharmony_ci		      0x100, BIT(24), 0);
2568c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(dram_de_be_clk,	"dram-de-be",	"pll-ddr",
2578c2ecf20Sopenharmony_ci		      0x100, BIT(26), 0);
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_cistatic const char * const de_parents[] = { "pll-video", "pll-periph" };
2608c2ecf20Sopenharmony_cistatic const u8 de_table[] = { 0, 2, };
2618c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(de_be_clk, "de-be",
2628c2ecf20Sopenharmony_ci				       de_parents, de_table,
2638c2ecf20Sopenharmony_ci				       0x104, 0, 4, 24, 3, BIT(31), 0);
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(de_fe_clk, "de-fe",
2668c2ecf20Sopenharmony_ci				       de_parents, de_table,
2678c2ecf20Sopenharmony_ci				       0x10c, 0, 4, 24, 3, BIT(31), 0);
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_cistatic const char * const tcon_parents[] = { "pll-video", "pll-video-2x" };
2708c2ecf20Sopenharmony_cistatic const u8 tcon_table[] = { 0, 2, };
2718c2ecf20Sopenharmony_cistatic SUNXI_CCU_MUX_TABLE_WITH_GATE(tcon_clk, "tcon",
2728c2ecf20Sopenharmony_ci				     tcon_parents, tcon_table,
2738c2ecf20Sopenharmony_ci				     0x118, 24, 3, BIT(31),
2748c2ecf20Sopenharmony_ci				     CLK_SET_RATE_PARENT);
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_cistatic const char * const deinterlace_parents[] = { "pll-video",
2778c2ecf20Sopenharmony_ci						    "pll-video-2x" };
2788c2ecf20Sopenharmony_cistatic const u8 deinterlace_table[] = { 0, 2, };
2798c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(deinterlace_clk, "deinterlace",
2808c2ecf20Sopenharmony_ci				       deinterlace_parents, deinterlace_table,
2818c2ecf20Sopenharmony_ci				       0x11c, 0, 4, 24, 3, BIT(31), 0);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_cistatic const char * const tve_clk2_parents[] = { "pll-video",
2848c2ecf20Sopenharmony_ci						 "pll-video-2x" };
2858c2ecf20Sopenharmony_cistatic const u8 tve_clk2_table[] = { 0, 2, };
2868c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(tve_clk2_clk, "tve-clk2",
2878c2ecf20Sopenharmony_ci				       tve_clk2_parents, tve_clk2_table,
2888c2ecf20Sopenharmony_ci				       0x120, 0, 4, 24, 3, BIT(31), 0);
2898c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_GATE(tve_clk1_clk, "tve-clk1", "tve-clk2",
2908c2ecf20Sopenharmony_ci			     0x120, 8, 1, BIT(15), 0);
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cistatic const char * const tvd_parents[] = { "pll-video", "osc24M",
2938c2ecf20Sopenharmony_ci					    "pll-video-2x" };
2948c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_GATE(tvd_clk, "tvd", tvd_parents,
2958c2ecf20Sopenharmony_ci				 0x124, 0, 4, 24, 3, BIT(31), 0);
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_cistatic const char * const csi_parents[] = { "pll-video", "osc24M" };
2988c2ecf20Sopenharmony_cistatic const u8 csi_table[] = { 0, 5, };
2998c2ecf20Sopenharmony_cistatic SUNXI_CCU_M_WITH_MUX_TABLE_GATE(csi_clk, "csi", csi_parents, csi_table,
3008c2ecf20Sopenharmony_ci				       0x120, 0, 4, 8, 3, BIT(15), 0);
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci/*
3038c2ecf20Sopenharmony_ci * TODO: BSP says the parent is pll-audio, however common sense and experience
3048c2ecf20Sopenharmony_ci * told us it should be pll-ve. pll-ve is totally not used in BSP code.
3058c2ecf20Sopenharmony_ci */
3068c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(ve_clk, "ve", "pll-audio", 0x13c, BIT(31), 0);
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(codec_clk, "codec", "pll-audio", 0x140, BIT(31), 0);
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_cistatic SUNXI_CCU_GATE(avs_clk, "avs", "osc24M", 0x144, BIT(31), 0);
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistatic struct ccu_common *suniv_ccu_clks[] = {
3138c2ecf20Sopenharmony_ci	&pll_cpu_clk.common,
3148c2ecf20Sopenharmony_ci	&pll_audio_base_clk.common,
3158c2ecf20Sopenharmony_ci	&pll_video_clk.common,
3168c2ecf20Sopenharmony_ci	&pll_ve_clk.common,
3178c2ecf20Sopenharmony_ci	&pll_ddr0_clk.common,
3188c2ecf20Sopenharmony_ci	&pll_periph_clk.common,
3198c2ecf20Sopenharmony_ci	&cpu_clk.common,
3208c2ecf20Sopenharmony_ci	&ahb_clk.common,
3218c2ecf20Sopenharmony_ci	&apb_clk.common,
3228c2ecf20Sopenharmony_ci	&bus_dma_clk.common,
3238c2ecf20Sopenharmony_ci	&bus_mmc0_clk.common,
3248c2ecf20Sopenharmony_ci	&bus_mmc1_clk.common,
3258c2ecf20Sopenharmony_ci	&bus_dram_clk.common,
3268c2ecf20Sopenharmony_ci	&bus_spi0_clk.common,
3278c2ecf20Sopenharmony_ci	&bus_spi1_clk.common,
3288c2ecf20Sopenharmony_ci	&bus_otg_clk.common,
3298c2ecf20Sopenharmony_ci	&bus_ve_clk.common,
3308c2ecf20Sopenharmony_ci	&bus_lcd_clk.common,
3318c2ecf20Sopenharmony_ci	&bus_deinterlace_clk.common,
3328c2ecf20Sopenharmony_ci	&bus_csi_clk.common,
3338c2ecf20Sopenharmony_ci	&bus_tve_clk.common,
3348c2ecf20Sopenharmony_ci	&bus_tvd_clk.common,
3358c2ecf20Sopenharmony_ci	&bus_de_be_clk.common,
3368c2ecf20Sopenharmony_ci	&bus_de_fe_clk.common,
3378c2ecf20Sopenharmony_ci	&bus_codec_clk.common,
3388c2ecf20Sopenharmony_ci	&bus_spdif_clk.common,
3398c2ecf20Sopenharmony_ci	&bus_ir_clk.common,
3408c2ecf20Sopenharmony_ci	&bus_rsb_clk.common,
3418c2ecf20Sopenharmony_ci	&bus_i2s0_clk.common,
3428c2ecf20Sopenharmony_ci	&bus_i2c0_clk.common,
3438c2ecf20Sopenharmony_ci	&bus_i2c1_clk.common,
3448c2ecf20Sopenharmony_ci	&bus_i2c2_clk.common,
3458c2ecf20Sopenharmony_ci	&bus_pio_clk.common,
3468c2ecf20Sopenharmony_ci	&bus_uart0_clk.common,
3478c2ecf20Sopenharmony_ci	&bus_uart1_clk.common,
3488c2ecf20Sopenharmony_ci	&bus_uart2_clk.common,
3498c2ecf20Sopenharmony_ci	&mmc0_clk.common,
3508c2ecf20Sopenharmony_ci	&mmc0_sample_clk.common,
3518c2ecf20Sopenharmony_ci	&mmc0_output_clk.common,
3528c2ecf20Sopenharmony_ci	&mmc1_clk.common,
3538c2ecf20Sopenharmony_ci	&mmc1_sample_clk.common,
3548c2ecf20Sopenharmony_ci	&mmc1_output_clk.common,
3558c2ecf20Sopenharmony_ci	&i2s_clk.common,
3568c2ecf20Sopenharmony_ci	&spdif_clk.common,
3578c2ecf20Sopenharmony_ci	&usb_phy0_clk.common,
3588c2ecf20Sopenharmony_ci	&dram_ve_clk.common,
3598c2ecf20Sopenharmony_ci	&dram_csi_clk.common,
3608c2ecf20Sopenharmony_ci	&dram_deinterlace_clk.common,
3618c2ecf20Sopenharmony_ci	&dram_tvd_clk.common,
3628c2ecf20Sopenharmony_ci	&dram_de_fe_clk.common,
3638c2ecf20Sopenharmony_ci	&dram_de_be_clk.common,
3648c2ecf20Sopenharmony_ci	&de_be_clk.common,
3658c2ecf20Sopenharmony_ci	&de_fe_clk.common,
3668c2ecf20Sopenharmony_ci	&tcon_clk.common,
3678c2ecf20Sopenharmony_ci	&deinterlace_clk.common,
3688c2ecf20Sopenharmony_ci	&tve_clk2_clk.common,
3698c2ecf20Sopenharmony_ci	&tve_clk1_clk.common,
3708c2ecf20Sopenharmony_ci	&tvd_clk.common,
3718c2ecf20Sopenharmony_ci	&csi_clk.common,
3728c2ecf20Sopenharmony_ci	&ve_clk.common,
3738c2ecf20Sopenharmony_ci	&codec_clk.common,
3748c2ecf20Sopenharmony_ci	&avs_clk.common,
3758c2ecf20Sopenharmony_ci};
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_cistatic const struct clk_hw *clk_parent_pll_audio[] = {
3788c2ecf20Sopenharmony_ci	&pll_audio_base_clk.common.hw
3798c2ecf20Sopenharmony_ci};
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio",
3828c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
3838c2ecf20Sopenharmony_ci			    4, 1, CLK_SET_RATE_PARENT);
3848c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x",
3858c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
3868c2ecf20Sopenharmony_ci			    2, 1, CLK_SET_RATE_PARENT);
3878c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_4x_clk, "pll-audio-4x",
3888c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
3898c2ecf20Sopenharmony_ci			    1, 1, CLK_SET_RATE_PARENT);
3908c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HWS(pll_audio_8x_clk, "pll-audio-8x",
3918c2ecf20Sopenharmony_ci			    clk_parent_pll_audio,
3928c2ecf20Sopenharmony_ci			    1, 2, CLK_SET_RATE_PARENT);
3938c2ecf20Sopenharmony_cistatic CLK_FIXED_FACTOR_HW(pll_video_2x_clk, "pll-video-2x",
3948c2ecf20Sopenharmony_ci			    &pll_video_clk.common.hw,
3958c2ecf20Sopenharmony_ci			    1, 2, 0);
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_cistatic struct clk_hw_onecell_data suniv_hw_clks = {
3988c2ecf20Sopenharmony_ci	.hws	= {
3998c2ecf20Sopenharmony_ci		[CLK_PLL_CPU]		= &pll_cpu_clk.common.hw,
4008c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_BASE]	= &pll_audio_base_clk.common.hw,
4018c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO]		= &pll_audio_clk.hw,
4028c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_2X]	= &pll_audio_2x_clk.hw,
4038c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_4X]	= &pll_audio_4x_clk.hw,
4048c2ecf20Sopenharmony_ci		[CLK_PLL_AUDIO_8X]	= &pll_audio_8x_clk.hw,
4058c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO]		= &pll_video_clk.common.hw,
4068c2ecf20Sopenharmony_ci		[CLK_PLL_VIDEO_2X]	= &pll_video_2x_clk.hw,
4078c2ecf20Sopenharmony_ci		[CLK_PLL_VE]		= &pll_ve_clk.common.hw,
4088c2ecf20Sopenharmony_ci		[CLK_PLL_DDR0]		= &pll_ddr0_clk.common.hw,
4098c2ecf20Sopenharmony_ci		[CLK_PLL_PERIPH]	= &pll_periph_clk.common.hw,
4108c2ecf20Sopenharmony_ci		[CLK_CPU]		= &cpu_clk.common.hw,
4118c2ecf20Sopenharmony_ci		[CLK_AHB]		= &ahb_clk.common.hw,
4128c2ecf20Sopenharmony_ci		[CLK_APB]		= &apb_clk.common.hw,
4138c2ecf20Sopenharmony_ci		[CLK_BUS_DMA]		= &bus_dma_clk.common.hw,
4148c2ecf20Sopenharmony_ci		[CLK_BUS_MMC0]		= &bus_mmc0_clk.common.hw,
4158c2ecf20Sopenharmony_ci		[CLK_BUS_MMC1]		= &bus_mmc1_clk.common.hw,
4168c2ecf20Sopenharmony_ci		[CLK_BUS_DRAM]		= &bus_dram_clk.common.hw,
4178c2ecf20Sopenharmony_ci		[CLK_BUS_SPI0]		= &bus_spi0_clk.common.hw,
4188c2ecf20Sopenharmony_ci		[CLK_BUS_SPI1]		= &bus_spi1_clk.common.hw,
4198c2ecf20Sopenharmony_ci		[CLK_BUS_OTG]		= &bus_otg_clk.common.hw,
4208c2ecf20Sopenharmony_ci		[CLK_BUS_VE]		= &bus_ve_clk.common.hw,
4218c2ecf20Sopenharmony_ci		[CLK_BUS_LCD]		= &bus_lcd_clk.common.hw,
4228c2ecf20Sopenharmony_ci		[CLK_BUS_DEINTERLACE]	= &bus_deinterlace_clk.common.hw,
4238c2ecf20Sopenharmony_ci		[CLK_BUS_CSI]		= &bus_csi_clk.common.hw,
4248c2ecf20Sopenharmony_ci		[CLK_BUS_TVD]		= &bus_tvd_clk.common.hw,
4258c2ecf20Sopenharmony_ci		[CLK_BUS_TVE]		= &bus_tve_clk.common.hw,
4268c2ecf20Sopenharmony_ci		[CLK_BUS_DE_BE]		= &bus_de_be_clk.common.hw,
4278c2ecf20Sopenharmony_ci		[CLK_BUS_DE_FE]		= &bus_de_fe_clk.common.hw,
4288c2ecf20Sopenharmony_ci		[CLK_BUS_CODEC]		= &bus_codec_clk.common.hw,
4298c2ecf20Sopenharmony_ci		[CLK_BUS_SPDIF]		= &bus_spdif_clk.common.hw,
4308c2ecf20Sopenharmony_ci		[CLK_BUS_IR]		= &bus_ir_clk.common.hw,
4318c2ecf20Sopenharmony_ci		[CLK_BUS_RSB]		= &bus_rsb_clk.common.hw,
4328c2ecf20Sopenharmony_ci		[CLK_BUS_I2S0]		= &bus_i2s0_clk.common.hw,
4338c2ecf20Sopenharmony_ci		[CLK_BUS_I2C0]		= &bus_i2c0_clk.common.hw,
4348c2ecf20Sopenharmony_ci		[CLK_BUS_I2C1]		= &bus_i2c1_clk.common.hw,
4358c2ecf20Sopenharmony_ci		[CLK_BUS_I2C2]		= &bus_i2c2_clk.common.hw,
4368c2ecf20Sopenharmony_ci		[CLK_BUS_PIO]		= &bus_pio_clk.common.hw,
4378c2ecf20Sopenharmony_ci		[CLK_BUS_UART0]		= &bus_uart0_clk.common.hw,
4388c2ecf20Sopenharmony_ci		[CLK_BUS_UART1]		= &bus_uart1_clk.common.hw,
4398c2ecf20Sopenharmony_ci		[CLK_BUS_UART2]		= &bus_uart2_clk.common.hw,
4408c2ecf20Sopenharmony_ci		[CLK_MMC0]		= &mmc0_clk.common.hw,
4418c2ecf20Sopenharmony_ci		[CLK_MMC0_SAMPLE]	= &mmc0_sample_clk.common.hw,
4428c2ecf20Sopenharmony_ci		[CLK_MMC0_OUTPUT]	= &mmc0_output_clk.common.hw,
4438c2ecf20Sopenharmony_ci		[CLK_MMC1]		= &mmc1_clk.common.hw,
4448c2ecf20Sopenharmony_ci		[CLK_MMC1_SAMPLE]	= &mmc1_sample_clk.common.hw,
4458c2ecf20Sopenharmony_ci		[CLK_MMC1_OUTPUT]	= &mmc1_output_clk.common.hw,
4468c2ecf20Sopenharmony_ci		[CLK_I2S]		= &i2s_clk.common.hw,
4478c2ecf20Sopenharmony_ci		[CLK_SPDIF]		= &spdif_clk.common.hw,
4488c2ecf20Sopenharmony_ci		[CLK_USB_PHY0]		= &usb_phy0_clk.common.hw,
4498c2ecf20Sopenharmony_ci		[CLK_DRAM_VE]		= &dram_ve_clk.common.hw,
4508c2ecf20Sopenharmony_ci		[CLK_DRAM_CSI]		= &dram_csi_clk.common.hw,
4518c2ecf20Sopenharmony_ci		[CLK_DRAM_DEINTERLACE]	= &dram_deinterlace_clk.common.hw,
4528c2ecf20Sopenharmony_ci		[CLK_DRAM_TVD]		= &dram_tvd_clk.common.hw,
4538c2ecf20Sopenharmony_ci		[CLK_DRAM_DE_FE]	= &dram_de_fe_clk.common.hw,
4548c2ecf20Sopenharmony_ci		[CLK_DRAM_DE_BE]	= &dram_de_be_clk.common.hw,
4558c2ecf20Sopenharmony_ci		[CLK_DE_BE]		= &de_be_clk.common.hw,
4568c2ecf20Sopenharmony_ci		[CLK_DE_FE]		= &de_fe_clk.common.hw,
4578c2ecf20Sopenharmony_ci		[CLK_TCON]		= &tcon_clk.common.hw,
4588c2ecf20Sopenharmony_ci		[CLK_DEINTERLACE]	= &deinterlace_clk.common.hw,
4598c2ecf20Sopenharmony_ci		[CLK_TVE2_CLK]		= &tve_clk2_clk.common.hw,
4608c2ecf20Sopenharmony_ci		[CLK_TVE1_CLK]		= &tve_clk1_clk.common.hw,
4618c2ecf20Sopenharmony_ci		[CLK_TVD]		= &tvd_clk.common.hw,
4628c2ecf20Sopenharmony_ci		[CLK_CSI]		= &csi_clk.common.hw,
4638c2ecf20Sopenharmony_ci		[CLK_VE]		= &ve_clk.common.hw,
4648c2ecf20Sopenharmony_ci		[CLK_CODEC]		= &codec_clk.common.hw,
4658c2ecf20Sopenharmony_ci		[CLK_AVS]		= &avs_clk.common.hw,
4668c2ecf20Sopenharmony_ci	},
4678c2ecf20Sopenharmony_ci	.num	= CLK_NUMBER,
4688c2ecf20Sopenharmony_ci};
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_cistatic struct ccu_reset_map suniv_ccu_resets[] = {
4718c2ecf20Sopenharmony_ci	[RST_USB_PHY0]		=  { 0x0cc, BIT(0) },
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci	[RST_BUS_DMA]		=  { 0x2c0, BIT(6) },
4748c2ecf20Sopenharmony_ci	[RST_BUS_MMC0]		=  { 0x2c0, BIT(8) },
4758c2ecf20Sopenharmony_ci	[RST_BUS_MMC1]		=  { 0x2c0, BIT(9) },
4768c2ecf20Sopenharmony_ci	[RST_BUS_DRAM]		=  { 0x2c0, BIT(14) },
4778c2ecf20Sopenharmony_ci	[RST_BUS_SPI0]		=  { 0x2c0, BIT(20) },
4788c2ecf20Sopenharmony_ci	[RST_BUS_SPI1]		=  { 0x2c0, BIT(21) },
4798c2ecf20Sopenharmony_ci	[RST_BUS_OTG]		=  { 0x2c0, BIT(24) },
4808c2ecf20Sopenharmony_ci	[RST_BUS_VE]		=  { 0x2c4, BIT(0) },
4818c2ecf20Sopenharmony_ci	[RST_BUS_LCD]		=  { 0x2c4, BIT(4) },
4828c2ecf20Sopenharmony_ci	[RST_BUS_DEINTERLACE]	=  { 0x2c4, BIT(5) },
4838c2ecf20Sopenharmony_ci	[RST_BUS_CSI]		=  { 0x2c4, BIT(8) },
4848c2ecf20Sopenharmony_ci	[RST_BUS_TVD]		=  { 0x2c4, BIT(9) },
4858c2ecf20Sopenharmony_ci	[RST_BUS_TVE]		=  { 0x2c4, BIT(10) },
4868c2ecf20Sopenharmony_ci	[RST_BUS_DE_BE]		=  { 0x2c4, BIT(12) },
4878c2ecf20Sopenharmony_ci	[RST_BUS_DE_FE]		=  { 0x2c4, BIT(14) },
4888c2ecf20Sopenharmony_ci	[RST_BUS_CODEC]		=  { 0x2d0, BIT(0) },
4898c2ecf20Sopenharmony_ci	[RST_BUS_SPDIF]		=  { 0x2d0, BIT(1) },
4908c2ecf20Sopenharmony_ci	[RST_BUS_IR]		=  { 0x2d0, BIT(2) },
4918c2ecf20Sopenharmony_ci	[RST_BUS_RSB]		=  { 0x2d0, BIT(3) },
4928c2ecf20Sopenharmony_ci	[RST_BUS_I2S0]		=  { 0x2d0, BIT(12) },
4938c2ecf20Sopenharmony_ci	[RST_BUS_I2C0]		=  { 0x2d0, BIT(16) },
4948c2ecf20Sopenharmony_ci	[RST_BUS_I2C1]		=  { 0x2d0, BIT(17) },
4958c2ecf20Sopenharmony_ci	[RST_BUS_I2C2]		=  { 0x2d0, BIT(18) },
4968c2ecf20Sopenharmony_ci	[RST_BUS_UART0]		=  { 0x2d0, BIT(20) },
4978c2ecf20Sopenharmony_ci	[RST_BUS_UART1]		=  { 0x2d0, BIT(21) },
4988c2ecf20Sopenharmony_ci	[RST_BUS_UART2]		=  { 0x2d0, BIT(22) },
4998c2ecf20Sopenharmony_ci};
5008c2ecf20Sopenharmony_ci
5018c2ecf20Sopenharmony_cistatic const struct sunxi_ccu_desc suniv_ccu_desc = {
5028c2ecf20Sopenharmony_ci	.ccu_clks	= suniv_ccu_clks,
5038c2ecf20Sopenharmony_ci	.num_ccu_clks	= ARRAY_SIZE(suniv_ccu_clks),
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci	.hw_clks	= &suniv_hw_clks,
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci	.resets		= suniv_ccu_resets,
5088c2ecf20Sopenharmony_ci	.num_resets	= ARRAY_SIZE(suniv_ccu_resets),
5098c2ecf20Sopenharmony_ci};
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_cistatic struct ccu_pll_nb suniv_pll_cpu_nb = {
5128c2ecf20Sopenharmony_ci	.common	= &pll_cpu_clk.common,
5138c2ecf20Sopenharmony_ci	/* copy from pll_cpu_clk */
5148c2ecf20Sopenharmony_ci	.enable	= BIT(31),
5158c2ecf20Sopenharmony_ci	.lock	= BIT(28),
5168c2ecf20Sopenharmony_ci};
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_cistatic struct ccu_mux_nb suniv_cpu_nb = {
5198c2ecf20Sopenharmony_ci	.common		= &cpu_clk.common,
5208c2ecf20Sopenharmony_ci	.cm		= &cpu_clk.mux,
5218c2ecf20Sopenharmony_ci	.delay_us	= 1, /* > 8 clock cycles at 24 MHz */
5228c2ecf20Sopenharmony_ci	.bypass_index	= 1, /* index of 24 MHz oscillator */
5238c2ecf20Sopenharmony_ci};
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_cistatic void __init suniv_f1c100s_ccu_setup(struct device_node *node)
5268c2ecf20Sopenharmony_ci{
5278c2ecf20Sopenharmony_ci	void __iomem *reg;
5288c2ecf20Sopenharmony_ci	u32 val;
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
5318c2ecf20Sopenharmony_ci	if (IS_ERR(reg)) {
5328c2ecf20Sopenharmony_ci		pr_err("%pOF: Could not map the clock registers\n", node);
5338c2ecf20Sopenharmony_ci		return;
5348c2ecf20Sopenharmony_ci	}
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci	/* Force the PLL-Audio-1x divider to 4 */
5378c2ecf20Sopenharmony_ci	val = readl(reg + SUNIV_PLL_AUDIO_REG);
5388c2ecf20Sopenharmony_ci	val &= ~GENMASK(19, 16);
5398c2ecf20Sopenharmony_ci	writel(val | (3 << 16), reg + SUNIV_PLL_AUDIO_REG);
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci	sunxi_ccu_probe(node, reg, &suniv_ccu_desc);
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci	/* Gate then ungate PLL CPU after any rate changes */
5448c2ecf20Sopenharmony_ci	ccu_pll_notifier_register(&suniv_pll_cpu_nb);
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci	/* Reparent CPU during PLL CPU rate changes */
5478c2ecf20Sopenharmony_ci	ccu_mux_notifier_register(pll_cpu_clk.common.hw.clk,
5488c2ecf20Sopenharmony_ci				  &suniv_cpu_nb);
5498c2ecf20Sopenharmony_ci}
5508c2ecf20Sopenharmony_ciCLK_OF_DECLARE(suniv_f1c100s_ccu, "allwinner,suniv-f1c100s-ccu",
5518c2ecf20Sopenharmony_ci	       suniv_f1c100s_ccu_setup);
552