162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2021 Dávid Virág <virag.david003@gmail.com>
462306a36Sopenharmony_ci * Author: Dávid Virág <virag.david003@gmail.com>
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Common Clock Framework support for Exynos7885 SoC.
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/clk.h>
1062306a36Sopenharmony_ci#include <linux/clk-provider.h>
1162306a36Sopenharmony_ci#include <linux/of.h>
1262306a36Sopenharmony_ci#include <linux/platform_device.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include <dt-bindings/clock/exynos7885.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include "clk.h"
1762306a36Sopenharmony_ci#include "clk-exynos-arm64.h"
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/* NOTE: Must be equal to the last clock ID increased by one */
2062306a36Sopenharmony_ci#define CLKS_NR_TOP			(CLK_GOUT_FSYS_USB30DRD + 1)
2162306a36Sopenharmony_ci#define CLKS_NR_CORE			(CLK_GOUT_TREX_P_CORE_PCLK_P_CORE + 1)
2262306a36Sopenharmony_ci#define CLKS_NR_PERI			(CLK_GOUT_WDT1_PCLK + 1)
2362306a36Sopenharmony_ci#define CLKS_NR_FSYS			(CLK_GOUT_MMC_SDIO_SDCLKIN + 1)
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/* ---- CMU_TOP ------------------------------------------------------------- */
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* Register Offset definitions for CMU_TOP (0x12060000) */
2862306a36Sopenharmony_ci#define PLL_LOCKTIME_PLL_SHARED0		0x0000
2962306a36Sopenharmony_ci#define PLL_LOCKTIME_PLL_SHARED1		0x0004
3062306a36Sopenharmony_ci#define PLL_CON0_PLL_SHARED0			0x0100
3162306a36Sopenharmony_ci#define PLL_CON0_PLL_SHARED1			0x0120
3262306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_CORE_BUS		0x1014
3362306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_CORE_CCI		0x1018
3462306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_CORE_G3D		0x101c
3562306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_FSYS_BUS		0x1028
3662306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_CARD	0x102c
3762306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_EMBD	0x1030
3862306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_SDIO	0x1034
3962306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_FSYS_USB30DRD	0x1038
4062306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_BUS		0x1058
4162306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_SPI0	0x105c
4262306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_SPI1	0x1060
4362306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_UART0	0x1064
4462306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_UART1	0x1068
4562306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_UART2	0x106c
4662306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_USI0	0x1070
4762306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_USI1	0x1074
4862306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLKCMU_PERI_USI2	0x1078
4962306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_CORE_BUS		0x181c
5062306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_CORE_CCI		0x1820
5162306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_CORE_G3D		0x1824
5262306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_FSYS_BUS		0x1844
5362306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_FSYS_MMC_CARD	0x1848
5462306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_FSYS_MMC_EMBD	0x184c
5562306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_FSYS_MMC_SDIO	0x1850
5662306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_FSYS_USB30DRD	0x1854
5762306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_BUS		0x1874
5862306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_SPI0		0x1878
5962306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_SPI1		0x187c
6062306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_UART0		0x1880
6162306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_UART1		0x1884
6262306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_UART2		0x1888
6362306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_USI0		0x188c
6462306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_USI1		0x1890
6562306a36Sopenharmony_ci#define CLK_CON_DIV_CLKCMU_PERI_USI2		0x1894
6662306a36Sopenharmony_ci#define CLK_CON_DIV_PLL_SHARED0_DIV2		0x189c
6762306a36Sopenharmony_ci#define CLK_CON_DIV_PLL_SHARED0_DIV3		0x18a0
6862306a36Sopenharmony_ci#define CLK_CON_DIV_PLL_SHARED0_DIV4		0x18a4
6962306a36Sopenharmony_ci#define CLK_CON_DIV_PLL_SHARED0_DIV5		0x18a8
7062306a36Sopenharmony_ci#define CLK_CON_DIV_PLL_SHARED1_DIV2		0x18ac
7162306a36Sopenharmony_ci#define CLK_CON_DIV_PLL_SHARED1_DIV3		0x18b0
7262306a36Sopenharmony_ci#define CLK_CON_DIV_PLL_SHARED1_DIV4		0x18b4
7362306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMUC_PERI_UART1	0x2004
7462306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_CORE_BUS	0x201c
7562306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_CORE_CCI	0x2020
7662306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_CORE_G3D	0x2024
7762306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_FSYS_BUS	0x2044
7862306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_CARD	0x2048
7962306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_EMBD	0x204c
8062306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_SDIO	0x2050
8162306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_FSYS_USB30DRD	0x2054
8262306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_BUS	0x207c
8362306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_SPI0	0x2080
8462306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_SPI1	0x2084
8562306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_UART0	0x2088
8662306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_UART2	0x208c
8762306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_USI0	0x2090
8862306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_USI1	0x2094
8962306a36Sopenharmony_ci#define CLK_CON_GAT_GATE_CLKCMU_PERI_USI2	0x2098
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_cistatic const unsigned long top_clk_regs[] __initconst = {
9262306a36Sopenharmony_ci	PLL_LOCKTIME_PLL_SHARED0,
9362306a36Sopenharmony_ci	PLL_LOCKTIME_PLL_SHARED1,
9462306a36Sopenharmony_ci	PLL_CON0_PLL_SHARED0,
9562306a36Sopenharmony_ci	PLL_CON0_PLL_SHARED1,
9662306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_CORE_BUS,
9762306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_CORE_CCI,
9862306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_CORE_G3D,
9962306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_FSYS_BUS,
10062306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_CARD,
10162306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_EMBD,
10262306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_SDIO,
10362306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_FSYS_USB30DRD,
10462306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_BUS,
10562306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_SPI0,
10662306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_SPI1,
10762306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_UART0,
10862306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_UART1,
10962306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_UART2,
11062306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_USI0,
11162306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_USI1,
11262306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLKCMU_PERI_USI2,
11362306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_CORE_BUS,
11462306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_CORE_CCI,
11562306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_CORE_G3D,
11662306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_FSYS_BUS,
11762306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_FSYS_MMC_CARD,
11862306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_FSYS_MMC_EMBD,
11962306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_FSYS_MMC_SDIO,
12062306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_FSYS_USB30DRD,
12162306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_BUS,
12262306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_SPI0,
12362306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_SPI1,
12462306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_UART0,
12562306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_UART1,
12662306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_UART2,
12762306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_USI0,
12862306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_USI1,
12962306a36Sopenharmony_ci	CLK_CON_DIV_CLKCMU_PERI_USI2,
13062306a36Sopenharmony_ci	CLK_CON_DIV_PLL_SHARED0_DIV2,
13162306a36Sopenharmony_ci	CLK_CON_DIV_PLL_SHARED0_DIV3,
13262306a36Sopenharmony_ci	CLK_CON_DIV_PLL_SHARED0_DIV4,
13362306a36Sopenharmony_ci	CLK_CON_DIV_PLL_SHARED0_DIV5,
13462306a36Sopenharmony_ci	CLK_CON_DIV_PLL_SHARED1_DIV2,
13562306a36Sopenharmony_ci	CLK_CON_DIV_PLL_SHARED1_DIV3,
13662306a36Sopenharmony_ci	CLK_CON_DIV_PLL_SHARED1_DIV4,
13762306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMUC_PERI_UART1,
13862306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_CORE_BUS,
13962306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_CORE_CCI,
14062306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_CORE_G3D,
14162306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_FSYS_BUS,
14262306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_CARD,
14362306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_EMBD,
14462306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_SDIO,
14562306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_FSYS_USB30DRD,
14662306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_BUS,
14762306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_SPI0,
14862306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_SPI1,
14962306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_UART0,
15062306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_UART2,
15162306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_USI0,
15262306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_USI1,
15362306a36Sopenharmony_ci	CLK_CON_GAT_GATE_CLKCMU_PERI_USI2,
15462306a36Sopenharmony_ci};
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_cistatic const struct samsung_pll_clock top_pll_clks[] __initconst = {
15762306a36Sopenharmony_ci	PLL(pll_1417x, CLK_FOUT_SHARED0_PLL, "fout_shared0_pll", "oscclk",
15862306a36Sopenharmony_ci	    PLL_LOCKTIME_PLL_SHARED0, PLL_CON0_PLL_SHARED0,
15962306a36Sopenharmony_ci	    NULL),
16062306a36Sopenharmony_ci	PLL(pll_1417x, CLK_FOUT_SHARED1_PLL, "fout_shared1_pll", "oscclk",
16162306a36Sopenharmony_ci	    PLL_LOCKTIME_PLL_SHARED1, PLL_CON0_PLL_SHARED1,
16262306a36Sopenharmony_ci	    NULL),
16362306a36Sopenharmony_ci};
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci/* List of parent clocks for Muxes in CMU_TOP: for CMU_CORE */
16662306a36Sopenharmony_ciPNAME(mout_core_bus_p)		= { "dout_shared0_div2", "dout_shared1_div2",
16762306a36Sopenharmony_ci				    "dout_shared0_div3", "dout_shared0_div3" };
16862306a36Sopenharmony_ciPNAME(mout_core_cci_p)		= { "dout_shared0_div2", "dout_shared1_div2",
16962306a36Sopenharmony_ci				    "dout_shared0_div3", "dout_shared0_div3" };
17062306a36Sopenharmony_ciPNAME(mout_core_g3d_p)		= { "dout_shared0_div2", "dout_shared1_div2",
17162306a36Sopenharmony_ci				    "dout_shared0_div3", "dout_shared0_div3" };
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci/* List of parent clocks for Muxes in CMU_TOP: for CMU_PERI */
17462306a36Sopenharmony_ciPNAME(mout_peri_bus_p)		= { "dout_shared0_div4", "dout_shared1_div4" };
17562306a36Sopenharmony_ciPNAME(mout_peri_spi0_p)		= { "oscclk", "dout_shared0_div4" };
17662306a36Sopenharmony_ciPNAME(mout_peri_spi1_p)		= { "oscclk", "dout_shared0_div4" };
17762306a36Sopenharmony_ciPNAME(mout_peri_uart0_p)	= { "oscclk", "dout_shared0_div4" };
17862306a36Sopenharmony_ciPNAME(mout_peri_uart1_p)	= { "oscclk", "dout_shared0_div4" };
17962306a36Sopenharmony_ciPNAME(mout_peri_uart2_p)	= { "oscclk", "dout_shared0_div4" };
18062306a36Sopenharmony_ciPNAME(mout_peri_usi0_p)		= { "oscclk", "dout_shared0_div4" };
18162306a36Sopenharmony_ciPNAME(mout_peri_usi1_p)		= { "oscclk", "dout_shared0_div4" };
18262306a36Sopenharmony_ciPNAME(mout_peri_usi2_p)		= { "oscclk", "dout_shared0_div4" };
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci/* List of parent clocks for Muxes in CMU_TOP: for CMU_FSYS */
18562306a36Sopenharmony_ciPNAME(mout_fsys_bus_p)		= { "dout_shared0_div2", "dout_shared1_div2" };
18662306a36Sopenharmony_ciPNAME(mout_fsys_mmc_card_p)	= { "dout_shared0_div2", "dout_shared1_div2" };
18762306a36Sopenharmony_ciPNAME(mout_fsys_mmc_embd_p)	= { "dout_shared0_div2", "dout_shared1_div2" };
18862306a36Sopenharmony_ciPNAME(mout_fsys_mmc_sdio_p)	= { "dout_shared0_div2", "dout_shared1_div2" };
18962306a36Sopenharmony_ciPNAME(mout_fsys_usb30drd_p)	= { "dout_shared0_div4", "dout_shared1_div4" };
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_cistatic const struct samsung_mux_clock top_mux_clks[] __initconst = {
19262306a36Sopenharmony_ci	/* CORE */
19362306a36Sopenharmony_ci	MUX(CLK_MOUT_CORE_BUS, "mout_core_bus", mout_core_bus_p,
19462306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_CORE_BUS, 0, 2),
19562306a36Sopenharmony_ci	MUX(CLK_MOUT_CORE_CCI, "mout_core_cci", mout_core_cci_p,
19662306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_CORE_CCI, 0, 2),
19762306a36Sopenharmony_ci	MUX(CLK_MOUT_CORE_G3D, "mout_core_g3d", mout_core_g3d_p,
19862306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_CORE_G3D, 0, 2),
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci	/* PERI */
20162306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_BUS, "mout_peri_bus", mout_peri_bus_p,
20262306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_BUS, 0, 1),
20362306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_SPI0, "mout_peri_spi0", mout_peri_spi0_p,
20462306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_SPI0, 0, 1),
20562306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_SPI1, "mout_peri_spi1", mout_peri_spi1_p,
20662306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_SPI1, 0, 1),
20762306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_UART0, "mout_peri_uart0", mout_peri_uart0_p,
20862306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_UART0, 0, 1),
20962306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_UART1, "mout_peri_uart1", mout_peri_uart1_p,
21062306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_UART1, 0, 1),
21162306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_UART2, "mout_peri_uart2", mout_peri_uart2_p,
21262306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_UART2, 0, 1),
21362306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_USI0, "mout_peri_usi0", mout_peri_usi0_p,
21462306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_USI0, 0, 1),
21562306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_USI1, "mout_peri_usi1", mout_peri_usi1_p,
21662306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_USI1, 0, 1),
21762306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_USI2, "mout_peri_usi2", mout_peri_usi2_p,
21862306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_PERI_USI2, 0, 1),
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci	/* FSYS */
22162306a36Sopenharmony_ci	MUX(CLK_MOUT_FSYS_BUS, "mout_fsys_bus", mout_fsys_bus_p,
22262306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_FSYS_BUS, 0, 1),
22362306a36Sopenharmony_ci	MUX(CLK_MOUT_FSYS_MMC_CARD, "mout_fsys_mmc_card", mout_fsys_mmc_card_p,
22462306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_CARD, 0, 1),
22562306a36Sopenharmony_ci	MUX(CLK_MOUT_FSYS_MMC_EMBD, "mout_fsys_mmc_embd", mout_fsys_mmc_embd_p,
22662306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_EMBD, 0, 1),
22762306a36Sopenharmony_ci	MUX(CLK_MOUT_FSYS_MMC_SDIO, "mout_fsys_mmc_sdio", mout_fsys_mmc_sdio_p,
22862306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_FSYS_MMC_SDIO, 0, 1),
22962306a36Sopenharmony_ci	MUX(CLK_MOUT_FSYS_USB30DRD, "mout_fsys_usb30drd", mout_fsys_usb30drd_p,
23062306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLKCMU_FSYS_USB30DRD, 0, 1),
23162306a36Sopenharmony_ci};
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_cistatic const struct samsung_div_clock top_div_clks[] __initconst = {
23462306a36Sopenharmony_ci	/* TOP */
23562306a36Sopenharmony_ci	DIV(CLK_DOUT_SHARED0_DIV2, "dout_shared0_div2", "fout_shared0_pll",
23662306a36Sopenharmony_ci	    CLK_CON_DIV_PLL_SHARED0_DIV2, 0, 1),
23762306a36Sopenharmony_ci	DIV(CLK_DOUT_SHARED0_DIV3, "dout_shared0_div3", "fout_shared0_pll",
23862306a36Sopenharmony_ci	    CLK_CON_DIV_PLL_SHARED0_DIV3, 0, 2),
23962306a36Sopenharmony_ci	DIV(CLK_DOUT_SHARED0_DIV4, "dout_shared0_div4", "dout_shared0_div2",
24062306a36Sopenharmony_ci	    CLK_CON_DIV_PLL_SHARED0_DIV4, 0, 1),
24162306a36Sopenharmony_ci	DIV(CLK_DOUT_SHARED0_DIV5, "dout_shared0_div5", "fout_shared0_pll",
24262306a36Sopenharmony_ci	    CLK_CON_DIV_PLL_SHARED0_DIV5, 0, 3),
24362306a36Sopenharmony_ci	DIV(CLK_DOUT_SHARED1_DIV2, "dout_shared1_div2", "fout_shared1_pll",
24462306a36Sopenharmony_ci	    CLK_CON_DIV_PLL_SHARED1_DIV2, 0, 1),
24562306a36Sopenharmony_ci	DIV(CLK_DOUT_SHARED1_DIV3, "dout_shared1_div3", "fout_shared1_pll",
24662306a36Sopenharmony_ci	    CLK_CON_DIV_PLL_SHARED1_DIV3, 0, 2),
24762306a36Sopenharmony_ci	DIV(CLK_DOUT_SHARED1_DIV4, "dout_shared1_div4", "dout_shared1_div2",
24862306a36Sopenharmony_ci	    CLK_CON_DIV_PLL_SHARED1_DIV4, 0, 1),
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci	/* CORE */
25162306a36Sopenharmony_ci	DIV(CLK_DOUT_CORE_BUS, "dout_core_bus", "gout_core_bus",
25262306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_CORE_BUS, 0, 3),
25362306a36Sopenharmony_ci	DIV(CLK_DOUT_CORE_CCI, "dout_core_cci", "gout_core_cci",
25462306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_CORE_CCI, 0, 3),
25562306a36Sopenharmony_ci	DIV(CLK_DOUT_CORE_G3D, "dout_core_g3d", "gout_core_g3d",
25662306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_CORE_G3D, 0, 3),
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci	/* PERI */
25962306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_BUS, "dout_peri_bus", "gout_peri_bus",
26062306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_BUS, 0, 4),
26162306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_SPI0, "dout_peri_spi0", "gout_peri_spi0",
26262306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_SPI0, 0, 6),
26362306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_SPI1, "dout_peri_spi1", "gout_peri_spi1",
26462306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_SPI1, 0, 6),
26562306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_UART0, "dout_peri_uart0", "gout_peri_uart0",
26662306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_UART0, 0, 4),
26762306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_UART1, "dout_peri_uart1", "gout_peri_uart1",
26862306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_UART1, 0, 4),
26962306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_UART2, "dout_peri_uart2", "gout_peri_uart2",
27062306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_UART2, 0, 4),
27162306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_USI0, "dout_peri_usi0", "gout_peri_usi0",
27262306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_USI0, 0, 4),
27362306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_USI1, "dout_peri_usi1", "gout_peri_usi1",
27462306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_USI1, 0, 4),
27562306a36Sopenharmony_ci	DIV(CLK_DOUT_PERI_USI2, "dout_peri_usi2", "gout_peri_usi2",
27662306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_PERI_USI2, 0, 4),
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_ci	/* FSYS */
27962306a36Sopenharmony_ci	DIV(CLK_DOUT_FSYS_BUS, "dout_fsys_bus", "gout_fsys_bus",
28062306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_FSYS_BUS, 0, 4),
28162306a36Sopenharmony_ci	DIV(CLK_DOUT_FSYS_MMC_CARD, "dout_fsys_mmc_card", "gout_fsys_mmc_card",
28262306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_FSYS_MMC_CARD, 0, 9),
28362306a36Sopenharmony_ci	DIV(CLK_DOUT_FSYS_MMC_EMBD, "dout_fsys_mmc_embd", "gout_fsys_mmc_embd",
28462306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_FSYS_MMC_EMBD, 0, 9),
28562306a36Sopenharmony_ci	DIV(CLK_DOUT_FSYS_MMC_SDIO, "dout_fsys_mmc_sdio", "gout_fsys_mmc_sdio",
28662306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_FSYS_MMC_SDIO, 0, 9),
28762306a36Sopenharmony_ci	DIV(CLK_DOUT_FSYS_USB30DRD, "dout_fsys_usb30drd", "gout_fsys_usb30drd",
28862306a36Sopenharmony_ci	    CLK_CON_DIV_CLKCMU_FSYS_USB30DRD, 0, 4),
28962306a36Sopenharmony_ci};
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_cistatic const struct samsung_gate_clock top_gate_clks[] __initconst = {
29262306a36Sopenharmony_ci	/* CORE */
29362306a36Sopenharmony_ci	GATE(CLK_GOUT_CORE_BUS, "gout_core_bus", "mout_core_bus",
29462306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_CORE_BUS, 21, 0, 0),
29562306a36Sopenharmony_ci	GATE(CLK_GOUT_CORE_CCI, "gout_core_cci", "mout_core_cci",
29662306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_CORE_CCI, 21, 0, 0),
29762306a36Sopenharmony_ci	GATE(CLK_GOUT_CORE_G3D, "gout_core_g3d", "mout_core_g3d",
29862306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_CORE_G3D, 21, 0, 0),
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci	/* PERI */
30162306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_BUS, "gout_peri_bus", "mout_peri_bus",
30262306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_BUS, 21, 0, 0),
30362306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_SPI0, "gout_peri_spi0", "mout_peri_spi0",
30462306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_SPI0, 21, 0, 0),
30562306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_SPI1, "gout_peri_spi1", "mout_peri_spi1",
30662306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_SPI1, 21, 0, 0),
30762306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_UART0, "gout_peri_uart0", "mout_peri_uart0",
30862306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_UART0, 21, 0, 0),
30962306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_UART1, "gout_peri_uart1", "mout_peri_uart1",
31062306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMUC_PERI_UART1, 21, 0, 0),
31162306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_UART2, "gout_peri_uart2", "mout_peri_uart2",
31262306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_UART2, 21, 0, 0),
31362306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_USI0, "gout_peri_usi0", "mout_peri_usi0",
31462306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_USI0, 21, 0, 0),
31562306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_USI1, "gout_peri_usi1", "mout_peri_usi1",
31662306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_USI1, 21, 0, 0),
31762306a36Sopenharmony_ci	GATE(CLK_GOUT_PERI_USI2, "gout_peri_usi2", "mout_peri_usi2",
31862306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_PERI_USI2, 21, 0, 0),
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_ci	/* FSYS */
32162306a36Sopenharmony_ci	GATE(CLK_GOUT_FSYS_BUS, "gout_fsys_bus", "mout_fsys_bus",
32262306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_FSYS_BUS, 21, 0, 0),
32362306a36Sopenharmony_ci	GATE(CLK_GOUT_FSYS_MMC_CARD, "gout_fsys_mmc_card", "mout_fsys_mmc_card",
32462306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_CARD, 21, 0, 0),
32562306a36Sopenharmony_ci	GATE(CLK_GOUT_FSYS_MMC_EMBD, "gout_fsys_mmc_embd", "mout_fsys_mmc_embd",
32662306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_EMBD, 21, 0, 0),
32762306a36Sopenharmony_ci	GATE(CLK_GOUT_FSYS_MMC_SDIO, "gout_fsys_mmc_sdio", "mout_fsys_mmc_sdio",
32862306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_FSYS_MMC_SDIO, 21, 0, 0),
32962306a36Sopenharmony_ci	GATE(CLK_GOUT_FSYS_USB30DRD, "gout_fsys_usb30drd", "mout_fsys_usb30drd",
33062306a36Sopenharmony_ci	     CLK_CON_GAT_GATE_CLKCMU_FSYS_USB30DRD, 21, 0, 0),
33162306a36Sopenharmony_ci};
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_cistatic const struct samsung_cmu_info top_cmu_info __initconst = {
33462306a36Sopenharmony_ci	.pll_clks		= top_pll_clks,
33562306a36Sopenharmony_ci	.nr_pll_clks		= ARRAY_SIZE(top_pll_clks),
33662306a36Sopenharmony_ci	.mux_clks		= top_mux_clks,
33762306a36Sopenharmony_ci	.nr_mux_clks		= ARRAY_SIZE(top_mux_clks),
33862306a36Sopenharmony_ci	.div_clks		= top_div_clks,
33962306a36Sopenharmony_ci	.nr_div_clks		= ARRAY_SIZE(top_div_clks),
34062306a36Sopenharmony_ci	.gate_clks		= top_gate_clks,
34162306a36Sopenharmony_ci	.nr_gate_clks		= ARRAY_SIZE(top_gate_clks),
34262306a36Sopenharmony_ci	.nr_clk_ids		= CLKS_NR_TOP,
34362306a36Sopenharmony_ci	.clk_regs		= top_clk_regs,
34462306a36Sopenharmony_ci	.nr_clk_regs		= ARRAY_SIZE(top_clk_regs),
34562306a36Sopenharmony_ci};
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_cistatic void __init exynos7885_cmu_top_init(struct device_node *np)
34862306a36Sopenharmony_ci{
34962306a36Sopenharmony_ci	exynos_arm64_register_cmu(NULL, np, &top_cmu_info);
35062306a36Sopenharmony_ci}
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ci/* Register CMU_TOP early, as it's a dependency for other early domains */
35362306a36Sopenharmony_ciCLK_OF_DECLARE(exynos7885_cmu_top, "samsung,exynos7885-cmu-top",
35462306a36Sopenharmony_ci	       exynos7885_cmu_top_init);
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci/* ---- CMU_PERI ------------------------------------------------------------ */
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ci/* Register Offset definitions for CMU_PERI (0x10010000) */
35962306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_BUS_USER	0x0100
36062306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_SPI0_USER	0x0120
36162306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_SPI1_USER	0x0140
36262306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_UART0_USER	0x0160
36362306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_UART1_USER	0x0180
36462306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_UART2_USER	0x01a0
36562306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_USI0_USER	0x01c0
36662306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_USI1_USER	0x01e0
36762306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_PERI_USI2_USER	0x0200
36862306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_GPIO_TOP_PCLK	0x2024
36962306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_HSI2C_0_PCLK	0x2028
37062306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_HSI2C_1_PCLK	0x202c
37162306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_HSI2C_2_PCLK	0x2030
37262306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_HSI2C_3_PCLK	0x2034
37362306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_0_PCLK	0x2038
37462306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_1_PCLK	0x203c
37562306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_2_PCLK	0x2040
37662306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_3_PCLK	0x2044
37762306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_4_PCLK	0x2048
37862306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_5_PCLK	0x204c
37962306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_6_PCLK	0x2050
38062306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_I2C_7_PCLK	0x2054
38162306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_PWM_MOTOR_PCLK	0x2058
38262306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_SPI_0_PCLK	0x205c
38362306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_SPI_0_EXT_CLK	0x2060
38462306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_SPI_1_PCLK	0x2064
38562306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_SPI_1_EXT_CLK	0x2068
38662306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_UART_0_EXT_UCLK	0x206c
38762306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_UART_0_PCLK	0x2070
38862306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_UART_1_EXT_UCLK	0x2074
38962306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_UART_1_PCLK	0x2078
39062306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_UART_2_EXT_UCLK	0x207c
39162306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_UART_2_PCLK	0x2080
39262306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_USI0_PCLK		0x2084
39362306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_USI0_SCLK		0x2088
39462306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_USI1_PCLK		0x208c
39562306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_USI1_SCLK		0x2090
39662306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_USI2_PCLK		0x2094
39762306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_USI2_SCLK		0x2098
39862306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_MCT_PCLK		0x20a0
39962306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_SYSREG_PERI_PCLK	0x20b0
40062306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_WDT_CLUSTER0_PCLK	0x20b4
40162306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_PERI_WDT_CLUSTER1_PCLK	0x20b8
40262306a36Sopenharmony_ci
40362306a36Sopenharmony_cistatic const unsigned long peri_clk_regs[] __initconst = {
40462306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_BUS_USER,
40562306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_SPI0_USER,
40662306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_SPI1_USER,
40762306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_UART0_USER,
40862306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_UART1_USER,
40962306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_UART2_USER,
41062306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_USI0_USER,
41162306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_USI1_USER,
41262306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_PERI_USI2_USER,
41362306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_GPIO_TOP_PCLK,
41462306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_HSI2C_0_PCLK,
41562306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_HSI2C_1_PCLK,
41662306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_HSI2C_2_PCLK,
41762306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_HSI2C_3_PCLK,
41862306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_0_PCLK,
41962306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_1_PCLK,
42062306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_2_PCLK,
42162306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_3_PCLK,
42262306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_4_PCLK,
42362306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_5_PCLK,
42462306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_6_PCLK,
42562306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_I2C_7_PCLK,
42662306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_PWM_MOTOR_PCLK,
42762306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_SPI_0_PCLK,
42862306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_SPI_0_EXT_CLK,
42962306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_SPI_1_PCLK,
43062306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_SPI_1_EXT_CLK,
43162306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_UART_0_EXT_UCLK,
43262306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_UART_0_PCLK,
43362306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_UART_1_EXT_UCLK,
43462306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_UART_1_PCLK,
43562306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_UART_2_EXT_UCLK,
43662306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_UART_2_PCLK,
43762306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_USI0_PCLK,
43862306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_USI0_SCLK,
43962306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_USI1_PCLK,
44062306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_USI1_SCLK,
44162306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_USI2_PCLK,
44262306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_USI2_SCLK,
44362306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_MCT_PCLK,
44462306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_SYSREG_PERI_PCLK,
44562306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_WDT_CLUSTER0_PCLK,
44662306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_PERI_WDT_CLUSTER1_PCLK,
44762306a36Sopenharmony_ci};
44862306a36Sopenharmony_ci
44962306a36Sopenharmony_ci/* List of parent clocks for Muxes in CMU_PERI */
45062306a36Sopenharmony_ciPNAME(mout_peri_bus_user_p)	= { "oscclk", "dout_peri_bus" };
45162306a36Sopenharmony_ciPNAME(mout_peri_spi0_user_p)	= { "oscclk", "dout_peri_spi0" };
45262306a36Sopenharmony_ciPNAME(mout_peri_spi1_user_p)	= { "oscclk", "dout_peri_spi1" };
45362306a36Sopenharmony_ciPNAME(mout_peri_uart0_user_p)	= { "oscclk", "dout_peri_uart0" };
45462306a36Sopenharmony_ciPNAME(mout_peri_uart1_user_p)	= { "oscclk", "dout_peri_uart1" };
45562306a36Sopenharmony_ciPNAME(mout_peri_uart2_user_p)	= { "oscclk", "dout_peri_uart2" };
45662306a36Sopenharmony_ciPNAME(mout_peri_usi0_user_p)	= { "oscclk", "dout_peri_usi0" };
45762306a36Sopenharmony_ciPNAME(mout_peri_usi1_user_p)	= { "oscclk", "dout_peri_usi1" };
45862306a36Sopenharmony_ciPNAME(mout_peri_usi2_user_p)	= { "oscclk", "dout_peri_usi2" };
45962306a36Sopenharmony_ci
46062306a36Sopenharmony_cistatic const struct samsung_mux_clock peri_mux_clks[] __initconst = {
46162306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_BUS_USER, "mout_peri_bus_user", mout_peri_bus_user_p,
46262306a36Sopenharmony_ci	    PLL_CON0_MUX_CLKCMU_PERI_BUS_USER, 4, 1),
46362306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_SPI0_USER, "mout_peri_spi0_user", mout_peri_spi0_user_p,
46462306a36Sopenharmony_ci	    PLL_CON0_MUX_CLKCMU_PERI_SPI0_USER, 4, 1),
46562306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_SPI1_USER, "mout_peri_spi1_user", mout_peri_spi1_user_p,
46662306a36Sopenharmony_ci	    PLL_CON0_MUX_CLKCMU_PERI_SPI1_USER, 4, 1),
46762306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_UART0_USER, "mout_peri_uart0_user",
46862306a36Sopenharmony_ci	    mout_peri_uart0_user_p, PLL_CON0_MUX_CLKCMU_PERI_UART0_USER, 4, 1),
46962306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_UART1_USER, "mout_peri_uart1_user",
47062306a36Sopenharmony_ci	    mout_peri_uart1_user_p, PLL_CON0_MUX_CLKCMU_PERI_UART1_USER, 4, 1),
47162306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_UART2_USER, "mout_peri_uart2_user",
47262306a36Sopenharmony_ci	    mout_peri_uart2_user_p, PLL_CON0_MUX_CLKCMU_PERI_UART2_USER, 4, 1),
47362306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_USI0_USER, "mout_peri_usi0_user",
47462306a36Sopenharmony_ci	    mout_peri_usi0_user_p, PLL_CON0_MUX_CLKCMU_PERI_USI0_USER, 4, 1),
47562306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_USI1_USER, "mout_peri_usi1_user",
47662306a36Sopenharmony_ci	    mout_peri_usi1_user_p, PLL_CON0_MUX_CLKCMU_PERI_USI1_USER, 4, 1),
47762306a36Sopenharmony_ci	MUX(CLK_MOUT_PERI_USI2_USER, "mout_peri_usi2_user",
47862306a36Sopenharmony_ci	    mout_peri_usi2_user_p, PLL_CON0_MUX_CLKCMU_PERI_USI2_USER, 4, 1),
47962306a36Sopenharmony_ci};
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_cistatic const struct samsung_gate_clock peri_gate_clks[] __initconst = {
48262306a36Sopenharmony_ci	/* TODO: Should be enabled in GPIO driver (or made CLK_IS_CRITICAL) */
48362306a36Sopenharmony_ci	GATE(CLK_GOUT_GPIO_TOP_PCLK, "gout_gpio_top_pclk",
48462306a36Sopenharmony_ci	     "mout_peri_bus_user",
48562306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_GPIO_TOP_PCLK, 21, CLK_IGNORE_UNUSED, 0),
48662306a36Sopenharmony_ci	GATE(CLK_GOUT_HSI2C0_PCLK, "gout_hsi2c0_pclk", "mout_peri_bus_user",
48762306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_HSI2C_0_PCLK, 21, 0, 0),
48862306a36Sopenharmony_ci	GATE(CLK_GOUT_HSI2C1_PCLK, "gout_hsi2c1_pclk", "mout_peri_bus_user",
48962306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_HSI2C_1_PCLK, 21, 0, 0),
49062306a36Sopenharmony_ci	GATE(CLK_GOUT_HSI2C2_PCLK, "gout_hsi2c2_pclk", "mout_peri_bus_user",
49162306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_HSI2C_2_PCLK, 21, 0, 0),
49262306a36Sopenharmony_ci	GATE(CLK_GOUT_HSI2C3_PCLK, "gout_hsi2c3_pclk", "mout_peri_bus_user",
49362306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_HSI2C_3_PCLK, 21, 0, 0),
49462306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C0_PCLK, "gout_i2c0_pclk", "mout_peri_bus_user",
49562306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_0_PCLK, 21, 0, 0),
49662306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C1_PCLK, "gout_i2c1_pclk", "mout_peri_bus_user",
49762306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_1_PCLK, 21, 0, 0),
49862306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C2_PCLK, "gout_i2c2_pclk", "mout_peri_bus_user",
49962306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_2_PCLK, 21, 0, 0),
50062306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C3_PCLK, "gout_i2c3_pclk", "mout_peri_bus_user",
50162306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_3_PCLK, 21, 0, 0),
50262306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C4_PCLK, "gout_i2c4_pclk", "mout_peri_bus_user",
50362306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_4_PCLK, 21, 0, 0),
50462306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C5_PCLK, "gout_i2c5_pclk", "mout_peri_bus_user",
50562306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_5_PCLK, 21, 0, 0),
50662306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C6_PCLK, "gout_i2c6_pclk", "mout_peri_bus_user",
50762306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_6_PCLK, 21, 0, 0),
50862306a36Sopenharmony_ci	GATE(CLK_GOUT_I2C7_PCLK, "gout_i2c7_pclk", "mout_peri_bus_user",
50962306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_I2C_7_PCLK, 21, 0, 0),
51062306a36Sopenharmony_ci	GATE(CLK_GOUT_PWM_MOTOR_PCLK, "gout_pwm_motor_pclk",
51162306a36Sopenharmony_ci	     "mout_peri_bus_user",
51262306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_PWM_MOTOR_PCLK, 21, 0, 0),
51362306a36Sopenharmony_ci	GATE(CLK_GOUT_SPI0_PCLK, "gout_spi0_pclk", "mout_peri_bus_user",
51462306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_SPI_0_PCLK, 21, 0, 0),
51562306a36Sopenharmony_ci	GATE(CLK_GOUT_SPI0_EXT_CLK, "gout_spi0_ipclk", "mout_peri_spi0_user",
51662306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_SPI_0_EXT_CLK, 21, 0, 0),
51762306a36Sopenharmony_ci	GATE(CLK_GOUT_SPI1_PCLK, "gout_spi1_pclk", "mout_peri_bus_user",
51862306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_SPI_1_PCLK, 21, 0, 0),
51962306a36Sopenharmony_ci	GATE(CLK_GOUT_SPI1_EXT_CLK, "gout_spi1_ipclk", "mout_peri_spi1_user",
52062306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_SPI_1_EXT_CLK, 21, 0, 0),
52162306a36Sopenharmony_ci	GATE(CLK_GOUT_UART0_EXT_UCLK, "gout_uart0_ext_uclk", "mout_peri_uart0_user",
52262306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_UART_0_EXT_UCLK, 21, 0, 0),
52362306a36Sopenharmony_ci	GATE(CLK_GOUT_UART0_PCLK, "gout_uart0_pclk", "mout_peri_bus_user",
52462306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_UART_0_PCLK, 21, 0, 0),
52562306a36Sopenharmony_ci	GATE(CLK_GOUT_UART1_EXT_UCLK, "gout_uart1_ext_uclk", "mout_peri_uart1_user",
52662306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_UART_1_EXT_UCLK, 21, 0, 0),
52762306a36Sopenharmony_ci	GATE(CLK_GOUT_UART1_PCLK, "gout_uart1_pclk", "mout_peri_bus_user",
52862306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_UART_1_PCLK, 21, 0, 0),
52962306a36Sopenharmony_ci	GATE(CLK_GOUT_UART2_EXT_UCLK, "gout_uart2_ext_uclk", "mout_peri_uart2_user",
53062306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_UART_2_EXT_UCLK, 21, 0, 0),
53162306a36Sopenharmony_ci	GATE(CLK_GOUT_UART2_PCLK, "gout_uart2_pclk", "mout_peri_bus_user",
53262306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_UART_2_PCLK, 21, 0, 0),
53362306a36Sopenharmony_ci	GATE(CLK_GOUT_USI0_PCLK, "gout_usi0_pclk", "mout_peri_bus_user",
53462306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_USI0_PCLK, 21, 0, 0),
53562306a36Sopenharmony_ci	GATE(CLK_GOUT_USI0_SCLK, "gout_usi0_sclk", "mout_peri_usi0_user",
53662306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_USI0_SCLK, 21, 0, 0),
53762306a36Sopenharmony_ci	GATE(CLK_GOUT_USI1_PCLK, "gout_usi1_pclk", "mout_peri_bus_user",
53862306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_USI1_PCLK, 21, 0, 0),
53962306a36Sopenharmony_ci	GATE(CLK_GOUT_USI1_SCLK, "gout_usi1_sclk", "mout_peri_usi1_user",
54062306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_USI1_SCLK, 21, 0, 0),
54162306a36Sopenharmony_ci	GATE(CLK_GOUT_USI2_PCLK, "gout_usi2_pclk", "mout_peri_bus_user",
54262306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_USI2_PCLK, 21, 0, 0),
54362306a36Sopenharmony_ci	GATE(CLK_GOUT_USI2_SCLK, "gout_usi2_sclk", "mout_peri_usi2_user",
54462306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_USI2_SCLK, 21, 0, 0),
54562306a36Sopenharmony_ci	GATE(CLK_GOUT_MCT_PCLK, "gout_mct_pclk", "mout_peri_bus_user",
54662306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_MCT_PCLK, 21, 0, 0),
54762306a36Sopenharmony_ci	GATE(CLK_GOUT_SYSREG_PERI_PCLK, "gout_sysreg_peri_pclk",
54862306a36Sopenharmony_ci	     "mout_peri_bus_user",
54962306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_SYSREG_PERI_PCLK, 21, 0, 0),
55062306a36Sopenharmony_ci	GATE(CLK_GOUT_WDT0_PCLK, "gout_wdt0_pclk", "mout_peri_bus_user",
55162306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_WDT_CLUSTER0_PCLK, 21, 0, 0),
55262306a36Sopenharmony_ci	GATE(CLK_GOUT_WDT1_PCLK, "gout_wdt1_pclk", "mout_peri_bus_user",
55362306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_PERI_WDT_CLUSTER1_PCLK, 21, 0, 0),
55462306a36Sopenharmony_ci};
55562306a36Sopenharmony_ci
55662306a36Sopenharmony_cistatic const struct samsung_cmu_info peri_cmu_info __initconst = {
55762306a36Sopenharmony_ci	.mux_clks		= peri_mux_clks,
55862306a36Sopenharmony_ci	.nr_mux_clks		= ARRAY_SIZE(peri_mux_clks),
55962306a36Sopenharmony_ci	.gate_clks		= peri_gate_clks,
56062306a36Sopenharmony_ci	.nr_gate_clks		= ARRAY_SIZE(peri_gate_clks),
56162306a36Sopenharmony_ci	.nr_clk_ids		= CLKS_NR_PERI,
56262306a36Sopenharmony_ci	.clk_regs		= peri_clk_regs,
56362306a36Sopenharmony_ci	.nr_clk_regs		= ARRAY_SIZE(peri_clk_regs),
56462306a36Sopenharmony_ci	.clk_name		= "dout_peri_bus",
56562306a36Sopenharmony_ci};
56662306a36Sopenharmony_ci
56762306a36Sopenharmony_cistatic void __init exynos7885_cmu_peri_init(struct device_node *np)
56862306a36Sopenharmony_ci{
56962306a36Sopenharmony_ci	exynos_arm64_register_cmu(NULL, np, &peri_cmu_info);
57062306a36Sopenharmony_ci}
57162306a36Sopenharmony_ci
57262306a36Sopenharmony_ci/* Register CMU_PERI early, as it's needed for MCT timer */
57362306a36Sopenharmony_ciCLK_OF_DECLARE(exynos7885_cmu_peri, "samsung,exynos7885-cmu-peri",
57462306a36Sopenharmony_ci	       exynos7885_cmu_peri_init);
57562306a36Sopenharmony_ci
57662306a36Sopenharmony_ci/* ---- CMU_CORE ------------------------------------------------------------ */
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_ci/* Register Offset definitions for CMU_CORE (0x12000000) */
57962306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_CORE_BUS_USER		0x0100
58062306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_CORE_CCI_USER		0x0120
58162306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_CORE_G3D_USER		0x0140
58262306a36Sopenharmony_ci#define CLK_CON_MUX_MUX_CLK_CORE_GIC			0x1000
58362306a36Sopenharmony_ci#define CLK_CON_DIV_DIV_CLK_CORE_BUSP			0x1800
58462306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_CCI_550_ACLK		0x2054
58562306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_GIC400_CLK		0x2058
58662306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_ACLK		0x215c
58762306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_GCLK		0x2160
58862306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_PCLK		0x2164
58962306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_ACLK_P_CORE	0x2168
59062306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_CCLK_P_CORE	0x216c
59162306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_PCLK		0x2170
59262306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_PCLK_P_CORE	0x2174
59362306a36Sopenharmony_ci
59462306a36Sopenharmony_cistatic const unsigned long core_clk_regs[] __initconst = {
59562306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_CORE_BUS_USER,
59662306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_CORE_CCI_USER,
59762306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_CORE_G3D_USER,
59862306a36Sopenharmony_ci	CLK_CON_MUX_MUX_CLK_CORE_GIC,
59962306a36Sopenharmony_ci	CLK_CON_DIV_DIV_CLK_CORE_BUSP,
60062306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_CCI_550_ACLK,
60162306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_GIC400_CLK,
60262306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_ACLK,
60362306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_GCLK,
60462306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_PCLK,
60562306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_ACLK_P_CORE,
60662306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_CCLK_P_CORE,
60762306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_PCLK,
60862306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_PCLK_P_CORE,
60962306a36Sopenharmony_ci};
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_ci/* List of parent clocks for Muxes in CMU_CORE */
61262306a36Sopenharmony_ciPNAME(mout_core_bus_user_p)		= { "oscclk", "dout_core_bus" };
61362306a36Sopenharmony_ciPNAME(mout_core_cci_user_p)		= { "oscclk", "dout_core_cci" };
61462306a36Sopenharmony_ciPNAME(mout_core_g3d_user_p)		= { "oscclk", "dout_core_g3d" };
61562306a36Sopenharmony_ciPNAME(mout_core_gic_p)			= { "dout_core_busp", "oscclk" };
61662306a36Sopenharmony_ci
61762306a36Sopenharmony_cistatic const struct samsung_mux_clock core_mux_clks[] __initconst = {
61862306a36Sopenharmony_ci	MUX(CLK_MOUT_CORE_BUS_USER, "mout_core_bus_user", mout_core_bus_user_p,
61962306a36Sopenharmony_ci	    PLL_CON0_MUX_CLKCMU_CORE_BUS_USER, 4, 1),
62062306a36Sopenharmony_ci	MUX(CLK_MOUT_CORE_CCI_USER, "mout_core_cci_user", mout_core_cci_user_p,
62162306a36Sopenharmony_ci	    PLL_CON0_MUX_CLKCMU_CORE_CCI_USER, 4, 1),
62262306a36Sopenharmony_ci	MUX(CLK_MOUT_CORE_G3D_USER, "mout_core_g3d_user", mout_core_g3d_user_p,
62362306a36Sopenharmony_ci	    PLL_CON0_MUX_CLKCMU_CORE_G3D_USER, 4, 1),
62462306a36Sopenharmony_ci	MUX(CLK_MOUT_CORE_GIC, "mout_core_gic", mout_core_gic_p,
62562306a36Sopenharmony_ci	    CLK_CON_MUX_MUX_CLK_CORE_GIC, 0, 1),
62662306a36Sopenharmony_ci};
62762306a36Sopenharmony_ci
62862306a36Sopenharmony_cistatic const struct samsung_div_clock core_div_clks[] __initconst = {
62962306a36Sopenharmony_ci	DIV(CLK_DOUT_CORE_BUSP, "dout_core_busp", "mout_core_bus_user",
63062306a36Sopenharmony_ci	    CLK_CON_DIV_DIV_CLK_CORE_BUSP, 0, 2),
63162306a36Sopenharmony_ci};
63262306a36Sopenharmony_ci
63362306a36Sopenharmony_cistatic const struct samsung_gate_clock core_gate_clks[] __initconst = {
63462306a36Sopenharmony_ci	/* CCI (interconnect) clock must be always running */
63562306a36Sopenharmony_ci	GATE(CLK_GOUT_CCI_ACLK, "gout_cci_aclk", "mout_core_cci_user",
63662306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_CORE_CCI_550_ACLK, 21, CLK_IS_CRITICAL, 0),
63762306a36Sopenharmony_ci	/* GIC (interrupt controller) clock must be always running */
63862306a36Sopenharmony_ci	GATE(CLK_GOUT_GIC400_CLK, "gout_gic400_clk", "mout_core_gic",
63962306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_CORE_GIC400_CLK, 21, CLK_IS_CRITICAL, 0),
64062306a36Sopenharmony_ci	/*
64162306a36Sopenharmony_ci	 * TREX D and P Core (seems to be related to "bus traffic shaper")
64262306a36Sopenharmony_ci	 * clocks must always be running
64362306a36Sopenharmony_ci	 */
64462306a36Sopenharmony_ci	GATE(CLK_GOUT_TREX_D_CORE_ACLK, "gout_trex_d_core_aclk", "mout_core_bus_user",
64562306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_ACLK, 21, CLK_IS_CRITICAL, 0),
64662306a36Sopenharmony_ci	GATE(CLK_GOUT_TREX_D_CORE_GCLK, "gout_trex_d_core_gclk", "mout_core_g3d_user",
64762306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_GCLK, 21, CLK_IS_CRITICAL, 0),
64862306a36Sopenharmony_ci	GATE(CLK_GOUT_TREX_D_CORE_PCLK, "gout_trex_d_core_pclk", "dout_core_busp",
64962306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_CORE_TREX_D_CORE_PCLK, 21, CLK_IS_CRITICAL, 0),
65062306a36Sopenharmony_ci	GATE(CLK_GOUT_TREX_P_CORE_ACLK_P_CORE, "gout_trex_p_core_aclk_p_core",
65162306a36Sopenharmony_ci	     "mout_core_bus_user", CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_ACLK_P_CORE, 21,
65262306a36Sopenharmony_ci	     CLK_IS_CRITICAL, 0),
65362306a36Sopenharmony_ci	GATE(CLK_GOUT_TREX_P_CORE_CCLK_P_CORE, "gout_trex_p_core_cclk_p_core",
65462306a36Sopenharmony_ci	     "mout_core_cci_user", CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_CCLK_P_CORE, 21,
65562306a36Sopenharmony_ci	     CLK_IS_CRITICAL, 0),
65662306a36Sopenharmony_ci	GATE(CLK_GOUT_TREX_P_CORE_PCLK, "gout_trex_p_core_pclk", "dout_core_busp",
65762306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_PCLK, 21, CLK_IS_CRITICAL, 0),
65862306a36Sopenharmony_ci	GATE(CLK_GOUT_TREX_P_CORE_PCLK_P_CORE, "gout_trex_p_core_pclk_p_core",
65962306a36Sopenharmony_ci	     "dout_core_busp", CLK_CON_GAT_GOUT_CORE_TREX_P_CORE_PCLK_P_CORE, 21,
66062306a36Sopenharmony_ci	     CLK_IS_CRITICAL, 0),
66162306a36Sopenharmony_ci};
66262306a36Sopenharmony_ci
66362306a36Sopenharmony_cistatic const struct samsung_cmu_info core_cmu_info __initconst = {
66462306a36Sopenharmony_ci	.mux_clks		= core_mux_clks,
66562306a36Sopenharmony_ci	.nr_mux_clks		= ARRAY_SIZE(core_mux_clks),
66662306a36Sopenharmony_ci	.div_clks		= core_div_clks,
66762306a36Sopenharmony_ci	.nr_div_clks		= ARRAY_SIZE(core_div_clks),
66862306a36Sopenharmony_ci	.gate_clks		= core_gate_clks,
66962306a36Sopenharmony_ci	.nr_gate_clks		= ARRAY_SIZE(core_gate_clks),
67062306a36Sopenharmony_ci	.nr_clk_ids		= CLKS_NR_CORE,
67162306a36Sopenharmony_ci	.clk_regs		= core_clk_regs,
67262306a36Sopenharmony_ci	.nr_clk_regs		= ARRAY_SIZE(core_clk_regs),
67362306a36Sopenharmony_ci	.clk_name		= "dout_core_bus",
67462306a36Sopenharmony_ci};
67562306a36Sopenharmony_ci
67662306a36Sopenharmony_ci/* ---- CMU_FSYS ------------------------------------------------------------ */
67762306a36Sopenharmony_ci
67862306a36Sopenharmony_ci/* Register Offset definitions for CMU_FSYS (0x13400000) */
67962306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_FSYS_BUS_USER	0x0100
68062306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_FSYS_MMC_CARD_USER	0x0120
68162306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_FSYS_MMC_EMBD_USER	0x0140
68262306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_FSYS_MMC_SDIO_USER	0x0160
68362306a36Sopenharmony_ci#define PLL_CON0_MUX_CLKCMU_FSYS_USB30DRD_USER	0x0180
68462306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_FSYS_MMC_CARD_I_ACLK	0x2030
68562306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_FSYS_MMC_CARD_SDCLKIN	0x2034
68662306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_FSYS_MMC_EMBD_I_ACLK	0x2038
68762306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_FSYS_MMC_EMBD_SDCLKIN	0x203c
68862306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_FSYS_MMC_SDIO_I_ACLK	0x2040
68962306a36Sopenharmony_ci#define CLK_CON_GAT_GOUT_FSYS_MMC_SDIO_SDCLKIN	0x2044
69062306a36Sopenharmony_ci
69162306a36Sopenharmony_cistatic const unsigned long fsys_clk_regs[] __initconst = {
69262306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_FSYS_BUS_USER,
69362306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_FSYS_MMC_CARD_USER,
69462306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_FSYS_MMC_EMBD_USER,
69562306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_FSYS_MMC_SDIO_USER,
69662306a36Sopenharmony_ci	PLL_CON0_MUX_CLKCMU_FSYS_USB30DRD_USER,
69762306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_FSYS_MMC_CARD_I_ACLK,
69862306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_FSYS_MMC_CARD_SDCLKIN,
69962306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_FSYS_MMC_EMBD_I_ACLK,
70062306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_FSYS_MMC_EMBD_SDCLKIN,
70162306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_FSYS_MMC_SDIO_I_ACLK,
70262306a36Sopenharmony_ci	CLK_CON_GAT_GOUT_FSYS_MMC_SDIO_SDCLKIN,
70362306a36Sopenharmony_ci};
70462306a36Sopenharmony_ci
70562306a36Sopenharmony_ci/* List of parent clocks for Muxes in CMU_FSYS */
70662306a36Sopenharmony_ciPNAME(mout_fsys_bus_user_p)		= { "oscclk", "dout_fsys_bus" };
70762306a36Sopenharmony_ciPNAME(mout_fsys_mmc_card_user_p)	= { "oscclk", "dout_fsys_mmc_card" };
70862306a36Sopenharmony_ciPNAME(mout_fsys_mmc_embd_user_p)	= { "oscclk", "dout_fsys_mmc_embd" };
70962306a36Sopenharmony_ciPNAME(mout_fsys_mmc_sdio_user_p)	= { "oscclk", "dout_fsys_mmc_sdio" };
71062306a36Sopenharmony_ciPNAME(mout_fsys_usb30drd_user_p)	= { "oscclk", "dout_fsys_usb30drd" };
71162306a36Sopenharmony_ci
71262306a36Sopenharmony_cistatic const struct samsung_mux_clock fsys_mux_clks[] __initconst = {
71362306a36Sopenharmony_ci	MUX(CLK_MOUT_FSYS_BUS_USER, "mout_fsys_bus_user", mout_fsys_bus_user_p,
71462306a36Sopenharmony_ci	    PLL_CON0_MUX_CLKCMU_FSYS_BUS_USER, 4, 1),
71562306a36Sopenharmony_ci	MUX_F(CLK_MOUT_FSYS_MMC_CARD_USER, "mout_fsys_mmc_card_user",
71662306a36Sopenharmony_ci	      mout_fsys_mmc_card_user_p, PLL_CON0_MUX_CLKCMU_FSYS_MMC_CARD_USER,
71762306a36Sopenharmony_ci	      4, 1, CLK_SET_RATE_PARENT, 0),
71862306a36Sopenharmony_ci	MUX_F(CLK_MOUT_FSYS_MMC_EMBD_USER, "mout_fsys_mmc_embd_user",
71962306a36Sopenharmony_ci	      mout_fsys_mmc_embd_user_p, PLL_CON0_MUX_CLKCMU_FSYS_MMC_EMBD_USER,
72062306a36Sopenharmony_ci	      4, 1, CLK_SET_RATE_PARENT, 0),
72162306a36Sopenharmony_ci	MUX_F(CLK_MOUT_FSYS_MMC_SDIO_USER, "mout_fsys_mmc_sdio_user",
72262306a36Sopenharmony_ci	      mout_fsys_mmc_sdio_user_p, PLL_CON0_MUX_CLKCMU_FSYS_MMC_SDIO_USER,
72362306a36Sopenharmony_ci	      4, 1, CLK_SET_RATE_PARENT, 0),
72462306a36Sopenharmony_ci	MUX_F(CLK_MOUT_FSYS_USB30DRD_USER, "mout_fsys_usb30drd_user",
72562306a36Sopenharmony_ci	      mout_fsys_usb30drd_user_p, PLL_CON0_MUX_CLKCMU_FSYS_USB30DRD_USER,
72662306a36Sopenharmony_ci	      4, 1, CLK_SET_RATE_PARENT, 0),
72762306a36Sopenharmony_ci};
72862306a36Sopenharmony_ci
72962306a36Sopenharmony_cistatic const struct samsung_gate_clock fsys_gate_clks[] __initconst = {
73062306a36Sopenharmony_ci	GATE(CLK_GOUT_MMC_CARD_ACLK, "gout_mmc_card_aclk", "mout_fsys_bus_user",
73162306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_FSYS_MMC_CARD_I_ACLK, 21, 0, 0),
73262306a36Sopenharmony_ci	GATE(CLK_GOUT_MMC_CARD_SDCLKIN, "gout_mmc_card_sdclkin",
73362306a36Sopenharmony_ci	     "mout_fsys_mmc_card_user", CLK_CON_GAT_GOUT_FSYS_MMC_CARD_SDCLKIN,
73462306a36Sopenharmony_ci	     21, CLK_SET_RATE_PARENT, 0),
73562306a36Sopenharmony_ci	GATE(CLK_GOUT_MMC_EMBD_ACLK, "gout_mmc_embd_aclk", "mout_fsys_bus_user",
73662306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_FSYS_MMC_EMBD_I_ACLK, 21, 0, 0),
73762306a36Sopenharmony_ci	GATE(CLK_GOUT_MMC_EMBD_SDCLKIN, "gout_mmc_embd_sdclkin",
73862306a36Sopenharmony_ci	     "mout_fsys_mmc_embd_user", CLK_CON_GAT_GOUT_FSYS_MMC_EMBD_SDCLKIN,
73962306a36Sopenharmony_ci	     21, CLK_SET_RATE_PARENT, 0),
74062306a36Sopenharmony_ci	GATE(CLK_GOUT_MMC_SDIO_ACLK, "gout_mmc_sdio_aclk", "mout_fsys_bus_user",
74162306a36Sopenharmony_ci	     CLK_CON_GAT_GOUT_FSYS_MMC_SDIO_I_ACLK, 21, 0, 0),
74262306a36Sopenharmony_ci	GATE(CLK_GOUT_MMC_SDIO_SDCLKIN, "gout_mmc_sdio_sdclkin",
74362306a36Sopenharmony_ci	     "mout_fsys_mmc_sdio_user", CLK_CON_GAT_GOUT_FSYS_MMC_SDIO_SDCLKIN,
74462306a36Sopenharmony_ci	     21, CLK_SET_RATE_PARENT, 0),
74562306a36Sopenharmony_ci};
74662306a36Sopenharmony_ci
74762306a36Sopenharmony_cistatic const struct samsung_cmu_info fsys_cmu_info __initconst = {
74862306a36Sopenharmony_ci	.mux_clks		= fsys_mux_clks,
74962306a36Sopenharmony_ci	.nr_mux_clks		= ARRAY_SIZE(fsys_mux_clks),
75062306a36Sopenharmony_ci	.gate_clks		= fsys_gate_clks,
75162306a36Sopenharmony_ci	.nr_gate_clks		= ARRAY_SIZE(fsys_gate_clks),
75262306a36Sopenharmony_ci	.nr_clk_ids		= CLKS_NR_FSYS,
75362306a36Sopenharmony_ci	.clk_regs		= fsys_clk_regs,
75462306a36Sopenharmony_ci	.nr_clk_regs		= ARRAY_SIZE(fsys_clk_regs),
75562306a36Sopenharmony_ci	.clk_name		= "dout_fsys_bus",
75662306a36Sopenharmony_ci};
75762306a36Sopenharmony_ci
75862306a36Sopenharmony_ci/* ---- platform_driver ----------------------------------------------------- */
75962306a36Sopenharmony_ci
76062306a36Sopenharmony_cistatic int __init exynos7885_cmu_probe(struct platform_device *pdev)
76162306a36Sopenharmony_ci{
76262306a36Sopenharmony_ci	const struct samsung_cmu_info *info;
76362306a36Sopenharmony_ci	struct device *dev = &pdev->dev;
76462306a36Sopenharmony_ci
76562306a36Sopenharmony_ci	info = of_device_get_match_data(dev);
76662306a36Sopenharmony_ci	exynos_arm64_register_cmu(dev, dev->of_node, info);
76762306a36Sopenharmony_ci
76862306a36Sopenharmony_ci	return 0;
76962306a36Sopenharmony_ci}
77062306a36Sopenharmony_ci
77162306a36Sopenharmony_cistatic const struct of_device_id exynos7885_cmu_of_match[] = {
77262306a36Sopenharmony_ci	{
77362306a36Sopenharmony_ci		.compatible = "samsung,exynos7885-cmu-core",
77462306a36Sopenharmony_ci		.data = &core_cmu_info,
77562306a36Sopenharmony_ci	}, {
77662306a36Sopenharmony_ci		.compatible = "samsung,exynos7885-cmu-fsys",
77762306a36Sopenharmony_ci		.data = &fsys_cmu_info,
77862306a36Sopenharmony_ci	}, {
77962306a36Sopenharmony_ci	},
78062306a36Sopenharmony_ci};
78162306a36Sopenharmony_ci
78262306a36Sopenharmony_cistatic struct platform_driver exynos7885_cmu_driver __refdata = {
78362306a36Sopenharmony_ci	.driver	= {
78462306a36Sopenharmony_ci		.name = "exynos7885-cmu",
78562306a36Sopenharmony_ci		.of_match_table = exynos7885_cmu_of_match,
78662306a36Sopenharmony_ci		.suppress_bind_attrs = true,
78762306a36Sopenharmony_ci	},
78862306a36Sopenharmony_ci	.probe = exynos7885_cmu_probe,
78962306a36Sopenharmony_ci};
79062306a36Sopenharmony_ci
79162306a36Sopenharmony_cistatic int __init exynos7885_cmu_init(void)
79262306a36Sopenharmony_ci{
79362306a36Sopenharmony_ci	return platform_driver_register(&exynos7885_cmu_driver);
79462306a36Sopenharmony_ci}
79562306a36Sopenharmony_cicore_initcall(exynos7885_cmu_init);
796