162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright 2017 Broadcom
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include <linux/err.h>
762306a36Sopenharmony_ci#include <linux/clk-provider.h>
862306a36Sopenharmony_ci#include <linux/of.h>
962306a36Sopenharmony_ci#include <linux/platform_device.h>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <dt-bindings/clock/bcm-sr.h>
1262306a36Sopenharmony_ci#include "clk-iproc.h"
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define REG_VAL(o, s, w) { .offset = o, .shift = s, .width = w, }
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define AON_VAL(o, pw, ps, is) { .offset = o, .pwr_width = pw, \
1762306a36Sopenharmony_ci	.pwr_shift = ps, .iso_shift = is }
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define SW_CTRL_VAL(o, s) { .offset = o, .shift = s, }
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define RESET_VAL(o, rs, prs) { .offset = o, .reset_shift = rs, \
2262306a36Sopenharmony_ci	.p_reset_shift = prs }
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define DF_VAL(o, kis, kiw, kps, kpw, kas, kaw) { .offset = o, \
2562306a36Sopenharmony_ci	.ki_shift = kis, .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, \
2662306a36Sopenharmony_ci	.ka_shift = kas, .ka_width = kaw }
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define VCO_CTRL_VAL(uo, lo) { .u_offset = uo, .l_offset = lo }
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#define ENABLE_VAL(o, es, hs, bs) { .offset = o, .enable_shift = es, \
3162306a36Sopenharmony_ci	.hold_shift = hs, .bypass_shift = bs }
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll0 = {
3562306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC |
3662306a36Sopenharmony_ci		IPROC_CLK_PLL_NEEDS_SW_CFG,
3762306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 5, 1, 0),
3862306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 12, 11),
3962306a36Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3),
4062306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x10, 31),
4162306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x10, 20, 10),
4262306a36Sopenharmony_ci	.ndiv_frac = REG_VAL(0x10, 0, 20),
4362306a36Sopenharmony_ci	.pdiv = REG_VAL(0x14, 0, 4),
4462306a36Sopenharmony_ci	.status = REG_VAL(0x30, 12, 1),
4562306a36Sopenharmony_ci};
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll0_clk[] = {
4862306a36Sopenharmony_ci	[BCM_SR_GENPLL0_125M_CLK] = {
4962306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL0_125M_CLK,
5062306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
5162306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 6, 0, 12),
5262306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 0, 9),
5362306a36Sopenharmony_ci	},
5462306a36Sopenharmony_ci	[BCM_SR_GENPLL0_SCR_CLK] = {
5562306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL0_SCR_CLK,
5662306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
5762306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 7, 1, 13),
5862306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 10, 9),
5962306a36Sopenharmony_ci	},
6062306a36Sopenharmony_ci	[BCM_SR_GENPLL0_250M_CLK] = {
6162306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL0_250M_CLK,
6262306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
6362306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 8, 2, 14),
6462306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 20, 9),
6562306a36Sopenharmony_ci	},
6662306a36Sopenharmony_ci	[BCM_SR_GENPLL0_PCIE_AXI_CLK] = {
6762306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL0_PCIE_AXI_CLK,
6862306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
6962306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 9, 3, 15),
7062306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 0, 9),
7162306a36Sopenharmony_ci	},
7262306a36Sopenharmony_ci	[BCM_SR_GENPLL0_PAXC_AXI_X2_CLK] = {
7362306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL0_PAXC_AXI_X2_CLK,
7462306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
7562306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 10, 4, 16),
7662306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 10, 9),
7762306a36Sopenharmony_ci	},
7862306a36Sopenharmony_ci	[BCM_SR_GENPLL0_PAXC_AXI_CLK] = {
7962306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL0_PAXC_AXI_CLK,
8062306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
8162306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 11, 5, 17),
8262306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 20, 9),
8362306a36Sopenharmony_ci	},
8462306a36Sopenharmony_ci};
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_cistatic int sr_genpll0_clk_init(struct platform_device *pdev)
8762306a36Sopenharmony_ci{
8862306a36Sopenharmony_ci	iproc_pll_clk_setup(pdev->dev.of_node,
8962306a36Sopenharmony_ci			    &sr_genpll0, NULL, 0, sr_genpll0_clk,
9062306a36Sopenharmony_ci			    ARRAY_SIZE(sr_genpll0_clk));
9162306a36Sopenharmony_ci	return 0;
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll2 = {
9562306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC |
9662306a36Sopenharmony_ci		IPROC_CLK_PLL_NEEDS_SW_CFG,
9762306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 1, 13, 12),
9862306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 12, 11),
9962306a36Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3),
10062306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x10, 31),
10162306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x10, 20, 10),
10262306a36Sopenharmony_ci	.ndiv_frac = REG_VAL(0x10, 0, 20),
10362306a36Sopenharmony_ci	.pdiv = REG_VAL(0x14, 0, 4),
10462306a36Sopenharmony_ci	.status = REG_VAL(0x30, 12, 1),
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll2_clk[] = {
10862306a36Sopenharmony_ci	[BCM_SR_GENPLL2_NIC_CLK] = {
10962306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL2_NIC_CLK,
11062306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
11162306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 6, 0, 12),
11262306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 0, 9),
11362306a36Sopenharmony_ci	},
11462306a36Sopenharmony_ci	[BCM_SR_GENPLL2_TS_500_CLK] = {
11562306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL2_TS_500_CLK,
11662306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
11762306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 7, 1, 13),
11862306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 10, 9),
11962306a36Sopenharmony_ci	},
12062306a36Sopenharmony_ci	[BCM_SR_GENPLL2_125_NITRO_CLK] = {
12162306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL2_125_NITRO_CLK,
12262306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
12362306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 8, 2, 14),
12462306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 20, 9),
12562306a36Sopenharmony_ci	},
12662306a36Sopenharmony_ci	[BCM_SR_GENPLL2_CHIMP_CLK] = {
12762306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL2_CHIMP_CLK,
12862306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
12962306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 9, 3, 15),
13062306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 0, 9),
13162306a36Sopenharmony_ci	},
13262306a36Sopenharmony_ci	[BCM_SR_GENPLL2_NIC_FLASH_CLK] = {
13362306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL2_NIC_FLASH_CLK,
13462306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
13562306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 10, 4, 16),
13662306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 10, 9),
13762306a36Sopenharmony_ci	},
13862306a36Sopenharmony_ci	[BCM_SR_GENPLL2_FS4_CLK] = {
13962306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL2_FS4_CLK,
14062306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 11, 5, 17),
14162306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 20, 9),
14262306a36Sopenharmony_ci	},
14362306a36Sopenharmony_ci};
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_cistatic int sr_genpll2_clk_init(struct platform_device *pdev)
14662306a36Sopenharmony_ci{
14762306a36Sopenharmony_ci	iproc_pll_clk_setup(pdev->dev.of_node,
14862306a36Sopenharmony_ci			    &sr_genpll2, NULL, 0, sr_genpll2_clk,
14962306a36Sopenharmony_ci			    ARRAY_SIZE(sr_genpll2_clk));
15062306a36Sopenharmony_ci	return 0;
15162306a36Sopenharmony_ci}
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll3 = {
15462306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC |
15562306a36Sopenharmony_ci		IPROC_CLK_PLL_NEEDS_SW_CFG,
15662306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 1, 19, 18),
15762306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 12, 11),
15862306a36Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3),
15962306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x10, 31),
16062306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x10, 20, 10),
16162306a36Sopenharmony_ci	.ndiv_frac = REG_VAL(0x10, 0, 20),
16262306a36Sopenharmony_ci	.pdiv = REG_VAL(0x14, 0, 4),
16362306a36Sopenharmony_ci	.status = REG_VAL(0x30, 12, 1),
16462306a36Sopenharmony_ci};
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll3_clk[] = {
16762306a36Sopenharmony_ci	[BCM_SR_GENPLL3_HSLS_CLK] = {
16862306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL3_HSLS_CLK,
16962306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
17062306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 6, 0, 12),
17162306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 0, 9),
17262306a36Sopenharmony_ci	},
17362306a36Sopenharmony_ci	[BCM_SR_GENPLL3_SDIO_CLK] = {
17462306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL3_SDIO_CLK,
17562306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
17662306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 7, 1, 13),
17762306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 10, 9),
17862306a36Sopenharmony_ci	},
17962306a36Sopenharmony_ci};
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_cistatic void sr_genpll3_clk_init(struct device_node *node)
18262306a36Sopenharmony_ci{
18362306a36Sopenharmony_ci	iproc_pll_clk_setup(node, &sr_genpll3, NULL, 0, sr_genpll3_clk,
18462306a36Sopenharmony_ci			    ARRAY_SIZE(sr_genpll3_clk));
18562306a36Sopenharmony_ci}
18662306a36Sopenharmony_ciCLK_OF_DECLARE(sr_genpll3_clk, "brcm,sr-genpll3", sr_genpll3_clk_init);
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll4 = {
18962306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC |
19062306a36Sopenharmony_ci		IPROC_CLK_PLL_NEEDS_SW_CFG,
19162306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 1, 25, 24),
19262306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 12, 11),
19362306a36Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3),
19462306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x10, 31),
19562306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x10, 20, 10),
19662306a36Sopenharmony_ci	.ndiv_frac = REG_VAL(0x10, 0, 20),
19762306a36Sopenharmony_ci	.pdiv = REG_VAL(0x14, 0, 4),
19862306a36Sopenharmony_ci	.status = REG_VAL(0x30, 12, 1),
19962306a36Sopenharmony_ci};
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll4_clk[] = {
20262306a36Sopenharmony_ci	[BCM_SR_GENPLL4_CCN_CLK] = {
20362306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL4_CCN_CLK,
20462306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
20562306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 6, 0, 12),
20662306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 0, 9),
20762306a36Sopenharmony_ci	},
20862306a36Sopenharmony_ci	[BCM_SR_GENPLL4_TPIU_PLL_CLK] = {
20962306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL4_TPIU_PLL_CLK,
21062306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
21162306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 7, 1, 13),
21262306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 10, 9),
21362306a36Sopenharmony_ci	},
21462306a36Sopenharmony_ci	[BCM_SR_GENPLL4_NOC_CLK] = {
21562306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL4_NOC_CLK,
21662306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
21762306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 8, 2, 14),
21862306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 20, 9),
21962306a36Sopenharmony_ci	},
22062306a36Sopenharmony_ci	[BCM_SR_GENPLL4_CHCLK_FS4_CLK] = {
22162306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL4_CHCLK_FS4_CLK,
22262306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
22362306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 9, 3, 15),
22462306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 0, 9),
22562306a36Sopenharmony_ci	},
22662306a36Sopenharmony_ci	[BCM_SR_GENPLL4_BRIDGE_FSCPU_CLK] = {
22762306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL4_BRIDGE_FSCPU_CLK,
22862306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
22962306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 10, 4, 16),
23062306a36Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 10, 9),
23162306a36Sopenharmony_ci	},
23262306a36Sopenharmony_ci};
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_cistatic int sr_genpll4_clk_init(struct platform_device *pdev)
23562306a36Sopenharmony_ci{
23662306a36Sopenharmony_ci	iproc_pll_clk_setup(pdev->dev.of_node,
23762306a36Sopenharmony_ci			    &sr_genpll4, NULL, 0, sr_genpll4_clk,
23862306a36Sopenharmony_ci			    ARRAY_SIZE(sr_genpll4_clk));
23962306a36Sopenharmony_ci	return 0;
24062306a36Sopenharmony_ci}
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_genpll5 = {
24362306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC |
24462306a36Sopenharmony_ci		IPROC_CLK_PLL_NEEDS_SW_CFG,
24562306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 1, 1, 0),
24662306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 12, 11),
24762306a36Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3),
24862306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x10, 31),
24962306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x10, 20, 10),
25062306a36Sopenharmony_ci	.ndiv_frac = REG_VAL(0x10, 0, 20),
25162306a36Sopenharmony_ci	.pdiv = REG_VAL(0x14, 0, 4),
25262306a36Sopenharmony_ci	.status = REG_VAL(0x30, 12, 1),
25362306a36Sopenharmony_ci};
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_genpll5_clk[] = {
25662306a36Sopenharmony_ci	[BCM_SR_GENPLL5_FS4_HF_CLK] = {
25762306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL5_FS4_HF_CLK,
25862306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 6, 0, 12),
25962306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 0, 9),
26062306a36Sopenharmony_ci	},
26162306a36Sopenharmony_ci	[BCM_SR_GENPLL5_CRYPTO_AE_CLK] = {
26262306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL5_CRYPTO_AE_CLK,
26362306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 7, 1, 12),
26462306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 10, 9),
26562306a36Sopenharmony_ci	},
26662306a36Sopenharmony_ci	[BCM_SR_GENPLL5_RAID_AE_CLK] = {
26762306a36Sopenharmony_ci		.channel = BCM_SR_GENPLL5_RAID_AE_CLK,
26862306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 8, 2, 14),
26962306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 20, 9),
27062306a36Sopenharmony_ci	},
27162306a36Sopenharmony_ci};
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_cistatic int sr_genpll5_clk_init(struct platform_device *pdev)
27462306a36Sopenharmony_ci{
27562306a36Sopenharmony_ci	iproc_pll_clk_setup(pdev->dev.of_node,
27662306a36Sopenharmony_ci			    &sr_genpll5, NULL, 0, sr_genpll5_clk,
27762306a36Sopenharmony_ci			    ARRAY_SIZE(sr_genpll5_clk));
27862306a36Sopenharmony_ci	return 0;
27962306a36Sopenharmony_ci}
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_lcpll0 = {
28262306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_NEEDS_SW_CFG,
28362306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 2, 19, 18),
28462306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 31, 30),
28562306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x4, 31),
28662306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x4, 16, 10),
28762306a36Sopenharmony_ci	.pdiv = REG_VAL(0x4, 26, 4),
28862306a36Sopenharmony_ci	.status = REG_VAL(0x38, 12, 1),
28962306a36Sopenharmony_ci};
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_lcpll0_clk[] = {
29262306a36Sopenharmony_ci	[BCM_SR_LCPLL0_SATA_REFP_CLK] = {
29362306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL0_SATA_REFP_CLK,
29462306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
29562306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 7, 1, 13),
29662306a36Sopenharmony_ci		.mdiv = REG_VAL(0x14, 0, 9),
29762306a36Sopenharmony_ci	},
29862306a36Sopenharmony_ci	[BCM_SR_LCPLL0_SATA_REFN_CLK] = {
29962306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL0_SATA_REFN_CLK,
30062306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
30162306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 8, 2, 14),
30262306a36Sopenharmony_ci		.mdiv = REG_VAL(0x14, 10, 9),
30362306a36Sopenharmony_ci	},
30462306a36Sopenharmony_ci	[BCM_SR_LCPLL0_SATA_350_CLK] = {
30562306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL0_SATA_350_CLK,
30662306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
30762306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 9, 3, 15),
30862306a36Sopenharmony_ci		.mdiv = REG_VAL(0x14, 20, 9),
30962306a36Sopenharmony_ci	},
31062306a36Sopenharmony_ci	[BCM_SR_LCPLL0_SATA_500_CLK] = {
31162306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL0_SATA_500_CLK,
31262306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
31362306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 10, 4, 16),
31462306a36Sopenharmony_ci		.mdiv = REG_VAL(0x18, 0, 9),
31562306a36Sopenharmony_ci	},
31662306a36Sopenharmony_ci};
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_cistatic int sr_lcpll0_clk_init(struct platform_device *pdev)
31962306a36Sopenharmony_ci{
32062306a36Sopenharmony_ci	iproc_pll_clk_setup(pdev->dev.of_node,
32162306a36Sopenharmony_ci			    &sr_lcpll0, NULL, 0, sr_lcpll0_clk,
32262306a36Sopenharmony_ci			    ARRAY_SIZE(sr_lcpll0_clk));
32362306a36Sopenharmony_ci	return 0;
32462306a36Sopenharmony_ci}
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_lcpll1 = {
32762306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_NEEDS_SW_CFG,
32862306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 2, 22, 21),
32962306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 31, 30),
33062306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x4, 31),
33162306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x4, 16, 10),
33262306a36Sopenharmony_ci	.pdiv = REG_VAL(0x4, 26, 4),
33362306a36Sopenharmony_ci	.status = REG_VAL(0x38, 12, 1),
33462306a36Sopenharmony_ci};
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_lcpll1_clk[] = {
33762306a36Sopenharmony_ci	[BCM_SR_LCPLL1_WAN_CLK] = {
33862306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL1_WAN_CLK,
33962306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
34062306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 7, 1, 13),
34162306a36Sopenharmony_ci		.mdiv = REG_VAL(0x14, 0, 9),
34262306a36Sopenharmony_ci	},
34362306a36Sopenharmony_ci	[BCM_SR_LCPLL1_USB_REF_CLK] = {
34462306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL1_USB_REF_CLK,
34562306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
34662306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 8, 2, 14),
34762306a36Sopenharmony_ci		.mdiv = REG_VAL(0x14, 10, 9),
34862306a36Sopenharmony_ci	},
34962306a36Sopenharmony_ci	[BCM_SR_LCPLL1_CRMU_TS_CLK] = {
35062306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL1_CRMU_TS_CLK,
35162306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
35262306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 9, 3, 15),
35362306a36Sopenharmony_ci		.mdiv = REG_VAL(0x14, 20, 9),
35462306a36Sopenharmony_ci	},
35562306a36Sopenharmony_ci};
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_cistatic int sr_lcpll1_clk_init(struct platform_device *pdev)
35862306a36Sopenharmony_ci{
35962306a36Sopenharmony_ci	iproc_pll_clk_setup(pdev->dev.of_node,
36062306a36Sopenharmony_ci			    &sr_lcpll1, NULL, 0, sr_lcpll1_clk,
36162306a36Sopenharmony_ci			    ARRAY_SIZE(sr_lcpll1_clk));
36262306a36Sopenharmony_ci	return 0;
36362306a36Sopenharmony_ci}
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_cistatic const struct iproc_pll_ctrl sr_lcpll_pcie = {
36662306a36Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_NEEDS_SW_CFG,
36762306a36Sopenharmony_ci	.aon = AON_VAL(0x0, 2, 25, 24),
36862306a36Sopenharmony_ci	.reset = RESET_VAL(0x0, 31, 30),
36962306a36Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x4, 31),
37062306a36Sopenharmony_ci	.ndiv_int = REG_VAL(0x4, 16, 10),
37162306a36Sopenharmony_ci	.pdiv = REG_VAL(0x4, 26, 4),
37262306a36Sopenharmony_ci	.status = REG_VAL(0x38, 12, 1),
37362306a36Sopenharmony_ci};
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_cistatic const struct iproc_clk_ctrl sr_lcpll_pcie_clk[] = {
37662306a36Sopenharmony_ci	[BCM_SR_LCPLL_PCIE_PHY_REF_CLK] = {
37762306a36Sopenharmony_ci		.channel = BCM_SR_LCPLL_PCIE_PHY_REF_CLK,
37862306a36Sopenharmony_ci		.flags = IPROC_CLK_AON,
37962306a36Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 7, 1, 13),
38062306a36Sopenharmony_ci		.mdiv = REG_VAL(0x14, 0, 9),
38162306a36Sopenharmony_ci	},
38262306a36Sopenharmony_ci};
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_cistatic int sr_lcpll_pcie_clk_init(struct platform_device *pdev)
38562306a36Sopenharmony_ci{
38662306a36Sopenharmony_ci	iproc_pll_clk_setup(pdev->dev.of_node,
38762306a36Sopenharmony_ci			    &sr_lcpll_pcie, NULL, 0, sr_lcpll_pcie_clk,
38862306a36Sopenharmony_ci			    ARRAY_SIZE(sr_lcpll_pcie_clk));
38962306a36Sopenharmony_ci	return 0;
39062306a36Sopenharmony_ci}
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_cistatic const struct of_device_id sr_clk_dt_ids[] = {
39362306a36Sopenharmony_ci	{ .compatible = "brcm,sr-genpll0", .data = sr_genpll0_clk_init },
39462306a36Sopenharmony_ci	{ .compatible = "brcm,sr-genpll2", .data = sr_genpll2_clk_init },
39562306a36Sopenharmony_ci	{ .compatible = "brcm,sr-genpll4", .data = sr_genpll4_clk_init },
39662306a36Sopenharmony_ci	{ .compatible = "brcm,sr-genpll5", .data = sr_genpll5_clk_init },
39762306a36Sopenharmony_ci	{ .compatible = "brcm,sr-lcpll0", .data = sr_lcpll0_clk_init },
39862306a36Sopenharmony_ci	{ .compatible = "brcm,sr-lcpll1", .data = sr_lcpll1_clk_init },
39962306a36Sopenharmony_ci	{ .compatible = "brcm,sr-lcpll-pcie", .data = sr_lcpll_pcie_clk_init },
40062306a36Sopenharmony_ci	{ /* sentinel */ }
40162306a36Sopenharmony_ci};
40262306a36Sopenharmony_ci
40362306a36Sopenharmony_cistatic int sr_clk_probe(struct platform_device *pdev)
40462306a36Sopenharmony_ci{
40562306a36Sopenharmony_ci	int (*probe_func)(struct platform_device *);
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_ci	probe_func = of_device_get_match_data(&pdev->dev);
40862306a36Sopenharmony_ci	if (!probe_func)
40962306a36Sopenharmony_ci		return -ENODEV;
41062306a36Sopenharmony_ci
41162306a36Sopenharmony_ci	return probe_func(pdev);
41262306a36Sopenharmony_ci}
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_cistatic struct platform_driver sr_clk_driver = {
41562306a36Sopenharmony_ci	.driver = {
41662306a36Sopenharmony_ci		.name = "sr-clk",
41762306a36Sopenharmony_ci		.of_match_table = sr_clk_dt_ids,
41862306a36Sopenharmony_ci	},
41962306a36Sopenharmony_ci	.probe = sr_clk_probe,
42062306a36Sopenharmony_ci};
42162306a36Sopenharmony_cibuiltin_platform_driver(sr_clk_driver);
422