18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (C) 2014 Broadcom Corporation
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
58c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License as
68c2ecf20Sopenharmony_ci * published by the Free Software Foundation version 2.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This program is distributed "as is" WITHOUT ANY WARRANTY of any
98c2ecf20Sopenharmony_ci * kind, whether express or implied; without even the implied warranty
108c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
118c2ecf20Sopenharmony_ci * GNU General Public License for more details.
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/kernel.h>
158c2ecf20Sopenharmony_ci#include <linux/err.h>
168c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
178c2ecf20Sopenharmony_ci#include <linux/io.h>
188c2ecf20Sopenharmony_ci#include <linux/of.h>
198c2ecf20Sopenharmony_ci#include <linux/clkdev.h>
208c2ecf20Sopenharmony_ci#include <linux/of_address.h>
218c2ecf20Sopenharmony_ci#include <linux/delay.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <dt-bindings/clock/bcm-cygnus.h>
248c2ecf20Sopenharmony_ci#include "clk-iproc.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define REG_VAL(o, s, w) { .offset = o, .shift = s, .width = w, }
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define AON_VAL(o, pw, ps, is) { .offset = o, .pwr_width = pw, \
298c2ecf20Sopenharmony_ci	.pwr_shift = ps, .iso_shift = is }
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define SW_CTRL_VAL(o, s) { .offset = o, .shift = s, }
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define ASIU_DIV_VAL(o, es, hs, hw, ls, lw) \
348c2ecf20Sopenharmony_ci		{ .offset = o, .en_shift = es, .high_shift = hs, \
358c2ecf20Sopenharmony_ci		.high_width = hw, .low_shift = ls, .low_width = lw }
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define RESET_VAL(o, rs, prs) { .offset = o, .reset_shift = rs, \
388c2ecf20Sopenharmony_ci	.p_reset_shift = prs }
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define DF_VAL(o, kis, kiw, kps, kpw, kas, kaw) { .offset = o, .ki_shift = kis,\
418c2ecf20Sopenharmony_ci	.ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas,    \
428c2ecf20Sopenharmony_ci	.ka_width = kaw }
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define VCO_CTRL_VAL(uo, lo) { .u_offset = uo, .l_offset = lo }
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define ENABLE_VAL(o, es, hs, bs) { .offset = o, .enable_shift = es, \
478c2ecf20Sopenharmony_ci	.hold_shift = hs, .bypass_shift = bs }
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define ASIU_GATE_VAL(o, es) { .offset = o, .en_shift = es }
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistatic void __init cygnus_armpll_init(struct device_node *node)
528c2ecf20Sopenharmony_ci{
538c2ecf20Sopenharmony_ci	iproc_armpll_setup(node);
548c2ecf20Sopenharmony_ci}
558c2ecf20Sopenharmony_ciCLK_OF_DECLARE(cygnus_armpll, "brcm,cygnus-armpll", cygnus_armpll_init);
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl genpll = {
588c2ecf20Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC |
598c2ecf20Sopenharmony_ci		IPROC_CLK_PLL_NEEDS_SW_CFG,
608c2ecf20Sopenharmony_ci	.aon = AON_VAL(0x0, 2, 1, 0),
618c2ecf20Sopenharmony_ci	.reset = RESET_VAL(0x0, 11, 10),
628c2ecf20Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 3),
638c2ecf20Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x10, 31),
648c2ecf20Sopenharmony_ci	.ndiv_int = REG_VAL(0x10, 20, 10),
658c2ecf20Sopenharmony_ci	.ndiv_frac = REG_VAL(0x10, 0, 20),
668c2ecf20Sopenharmony_ci	.pdiv = REG_VAL(0x14, 0, 4),
678c2ecf20Sopenharmony_ci	.vco_ctrl = VCO_CTRL_VAL(0x18, 0x1c),
688c2ecf20Sopenharmony_ci	.status = REG_VAL(0x28, 12, 1),
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl genpll_clk[] = {
728c2ecf20Sopenharmony_ci	[BCM_CYGNUS_GENPLL_AXI21_CLK] = {
738c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_GENPLL_AXI21_CLK,
748c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
758c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 6, 0, 12),
768c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x20, 0, 8),
778c2ecf20Sopenharmony_ci	},
788c2ecf20Sopenharmony_ci	[BCM_CYGNUS_GENPLL_250MHZ_CLK] = {
798c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_GENPLL_250MHZ_CLK,
808c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
818c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 7, 1, 13),
828c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x20, 10, 8),
838c2ecf20Sopenharmony_ci	},
848c2ecf20Sopenharmony_ci	[BCM_CYGNUS_GENPLL_IHOST_SYS_CLK] = {
858c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_GENPLL_IHOST_SYS_CLK,
868c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
878c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 8, 2, 14),
888c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x20, 20, 8),
898c2ecf20Sopenharmony_ci	},
908c2ecf20Sopenharmony_ci	[BCM_CYGNUS_GENPLL_ENET_SW_CLK] = {
918c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_GENPLL_ENET_SW_CLK,
928c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
938c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 9, 3, 15),
948c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x24, 0, 8),
958c2ecf20Sopenharmony_ci	},
968c2ecf20Sopenharmony_ci	[BCM_CYGNUS_GENPLL_AUDIO_125_CLK] = {
978c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_GENPLL_AUDIO_125_CLK,
988c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
998c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 10, 4, 16),
1008c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x24, 10, 8),
1018c2ecf20Sopenharmony_ci	},
1028c2ecf20Sopenharmony_ci	[BCM_CYGNUS_GENPLL_CAN_CLK] = {
1038c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_GENPLL_CAN_CLK,
1048c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
1058c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 11, 5, 17),
1068c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x24, 20, 8),
1078c2ecf20Sopenharmony_ci	},
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistatic void __init cygnus_genpll_clk_init(struct device_node *node)
1118c2ecf20Sopenharmony_ci{
1128c2ecf20Sopenharmony_ci	iproc_pll_clk_setup(node, &genpll, NULL, 0, genpll_clk,
1138c2ecf20Sopenharmony_ci			    ARRAY_SIZE(genpll_clk));
1148c2ecf20Sopenharmony_ci}
1158c2ecf20Sopenharmony_ciCLK_OF_DECLARE(cygnus_genpll, "brcm,cygnus-genpll", cygnus_genpll_clk_init);
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl lcpll0 = {
1188c2ecf20Sopenharmony_ci	.flags = IPROC_CLK_AON | IPROC_CLK_PLL_NEEDS_SW_CFG,
1198c2ecf20Sopenharmony_ci	.aon = AON_VAL(0x0, 2, 5, 4),
1208c2ecf20Sopenharmony_ci	.reset = RESET_VAL(0x0, 31, 30),
1218c2ecf20Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 27, 3, 23, 4, 19, 4),
1228c2ecf20Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x4, 31),
1238c2ecf20Sopenharmony_ci	.ndiv_int = REG_VAL(0x4, 16, 10),
1248c2ecf20Sopenharmony_ci	.pdiv = REG_VAL(0x4, 26, 4),
1258c2ecf20Sopenharmony_ci	.vco_ctrl = VCO_CTRL_VAL(0x10, 0x14),
1268c2ecf20Sopenharmony_ci	.status = REG_VAL(0x18, 12, 1),
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl lcpll0_clk[] = {
1308c2ecf20Sopenharmony_ci	[BCM_CYGNUS_LCPLL0_PCIE_PHY_REF_CLK] = {
1318c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_LCPLL0_PCIE_PHY_REF_CLK,
1328c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
1338c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 7, 1, 13),
1348c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x8, 0, 8),
1358c2ecf20Sopenharmony_ci	},
1368c2ecf20Sopenharmony_ci	[BCM_CYGNUS_LCPLL0_DDR_PHY_CLK] = {
1378c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_LCPLL0_DDR_PHY_CLK,
1388c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
1398c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 8, 2, 14),
1408c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x8, 10, 8),
1418c2ecf20Sopenharmony_ci	},
1428c2ecf20Sopenharmony_ci	[BCM_CYGNUS_LCPLL0_SDIO_CLK] = {
1438c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_LCPLL0_SDIO_CLK,
1448c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
1458c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 9, 3, 15),
1468c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x8, 20, 8),
1478c2ecf20Sopenharmony_ci	},
1488c2ecf20Sopenharmony_ci	[BCM_CYGNUS_LCPLL0_USB_PHY_REF_CLK] = {
1498c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_LCPLL0_USB_PHY_REF_CLK,
1508c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
1518c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 10, 4, 16),
1528c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0xc, 0, 8),
1538c2ecf20Sopenharmony_ci	},
1548c2ecf20Sopenharmony_ci	[BCM_CYGNUS_LCPLL0_SMART_CARD_CLK] = {
1558c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_LCPLL0_SMART_CARD_CLK,
1568c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
1578c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 11, 5, 17),
1588c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0xc, 10, 8),
1598c2ecf20Sopenharmony_ci	},
1608c2ecf20Sopenharmony_ci	[BCM_CYGNUS_LCPLL0_CH5_UNUSED] = {
1618c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_LCPLL0_CH5_UNUSED,
1628c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
1638c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x0, 12, 6, 18),
1648c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0xc, 20, 8),
1658c2ecf20Sopenharmony_ci	},
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_cistatic void __init cygnus_lcpll0_clk_init(struct device_node *node)
1698c2ecf20Sopenharmony_ci{
1708c2ecf20Sopenharmony_ci	iproc_pll_clk_setup(node, &lcpll0, NULL, 0, lcpll0_clk,
1718c2ecf20Sopenharmony_ci			    ARRAY_SIZE(lcpll0_clk));
1728c2ecf20Sopenharmony_ci}
1738c2ecf20Sopenharmony_ciCLK_OF_DECLARE(cygnus_lcpll0, "brcm,cygnus-lcpll0", cygnus_lcpll0_clk_init);
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/*
1768c2ecf20Sopenharmony_ci * MIPI PLL VCO frequency parameter table
1778c2ecf20Sopenharmony_ci */
1788c2ecf20Sopenharmony_cistatic const struct iproc_pll_vco_param mipipll_vco_params[] = {
1798c2ecf20Sopenharmony_ci	/* rate (Hz) ndiv_int ndiv_frac pdiv */
1808c2ecf20Sopenharmony_ci	{ 750000000UL,   30,     0,        1 },
1818c2ecf20Sopenharmony_ci	{ 1000000000UL,  40,     0,        1 },
1828c2ecf20Sopenharmony_ci	{ 1350000000ul,  54,     0,        1 },
1838c2ecf20Sopenharmony_ci	{ 2000000000UL,  80,     0,        1 },
1848c2ecf20Sopenharmony_ci	{ 2100000000UL,  84,     0,        1 },
1858c2ecf20Sopenharmony_ci	{ 2250000000UL,  90,     0,        1 },
1868c2ecf20Sopenharmony_ci	{ 2500000000UL,  100,    0,        1 },
1878c2ecf20Sopenharmony_ci	{ 2700000000UL,  54,     0,        0 },
1888c2ecf20Sopenharmony_ci	{ 2975000000UL,  119,    0,        1 },
1898c2ecf20Sopenharmony_ci	{ 3100000000UL,  124,    0,        1 },
1908c2ecf20Sopenharmony_ci	{ 3150000000UL,  126,    0,        1 },
1918c2ecf20Sopenharmony_ci};
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl mipipll = {
1948c2ecf20Sopenharmony_ci	.flags = IPROC_CLK_PLL_ASIU | IPROC_CLK_PLL_HAS_NDIV_FRAC |
1958c2ecf20Sopenharmony_ci		 IPROC_CLK_NEEDS_READ_BACK,
1968c2ecf20Sopenharmony_ci	.aon = AON_VAL(0x0, 4, 17, 16),
1978c2ecf20Sopenharmony_ci	.asiu = ASIU_GATE_VAL(0x0, 3),
1988c2ecf20Sopenharmony_ci	.reset = RESET_VAL(0x0, 11, 10),
1998c2ecf20Sopenharmony_ci	.dig_filter = DF_VAL(0x0, 4, 3, 0, 4, 7, 4),
2008c2ecf20Sopenharmony_ci	.ndiv_int = REG_VAL(0x10, 20, 10),
2018c2ecf20Sopenharmony_ci	.ndiv_frac = REG_VAL(0x10, 0, 20),
2028c2ecf20Sopenharmony_ci	.pdiv = REG_VAL(0x14, 0, 4),
2038c2ecf20Sopenharmony_ci	.vco_ctrl = VCO_CTRL_VAL(0x18, 0x1c),
2048c2ecf20Sopenharmony_ci	.status = REG_VAL(0x28, 12, 1),
2058c2ecf20Sopenharmony_ci};
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl mipipll_clk[] = {
2088c2ecf20Sopenharmony_ci	[BCM_CYGNUS_MIPIPLL_CH0_UNUSED] = {
2098c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_MIPIPLL_CH0_UNUSED,
2108c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_NEEDS_READ_BACK,
2118c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 12, 6, 18),
2128c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x20, 0, 8),
2138c2ecf20Sopenharmony_ci	},
2148c2ecf20Sopenharmony_ci	[BCM_CYGNUS_MIPIPLL_CH1_LCD] = {
2158c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_MIPIPLL_CH1_LCD,
2168c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_NEEDS_READ_BACK,
2178c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 13, 7, 19),
2188c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x20, 10, 8),
2198c2ecf20Sopenharmony_ci	},
2208c2ecf20Sopenharmony_ci	[BCM_CYGNUS_MIPIPLL_CH2_V3D] = {
2218c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_MIPIPLL_CH2_V3D,
2228c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_NEEDS_READ_BACK,
2238c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 14, 8, 20),
2248c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x20, 20, 8),
2258c2ecf20Sopenharmony_ci	},
2268c2ecf20Sopenharmony_ci	[BCM_CYGNUS_MIPIPLL_CH3_UNUSED] = {
2278c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_MIPIPLL_CH3_UNUSED,
2288c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_NEEDS_READ_BACK,
2298c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 15, 9, 21),
2308c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x24, 0, 8),
2318c2ecf20Sopenharmony_ci	},
2328c2ecf20Sopenharmony_ci	[BCM_CYGNUS_MIPIPLL_CH4_UNUSED] = {
2338c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_MIPIPLL_CH4_UNUSED,
2348c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_NEEDS_READ_BACK,
2358c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 16, 10, 22),
2368c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x24, 10, 8),
2378c2ecf20Sopenharmony_ci	},
2388c2ecf20Sopenharmony_ci	[BCM_CYGNUS_MIPIPLL_CH5_UNUSED] = {
2398c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_MIPIPLL_CH5_UNUSED,
2408c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_NEEDS_READ_BACK,
2418c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x4, 17, 11, 23),
2428c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x24, 20, 8),
2438c2ecf20Sopenharmony_ci	},
2448c2ecf20Sopenharmony_ci};
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_cistatic void __init cygnus_mipipll_clk_init(struct device_node *node)
2478c2ecf20Sopenharmony_ci{
2488c2ecf20Sopenharmony_ci	iproc_pll_clk_setup(node, &mipipll, mipipll_vco_params,
2498c2ecf20Sopenharmony_ci			    ARRAY_SIZE(mipipll_vco_params), mipipll_clk,
2508c2ecf20Sopenharmony_ci			    ARRAY_SIZE(mipipll_clk));
2518c2ecf20Sopenharmony_ci}
2528c2ecf20Sopenharmony_ciCLK_OF_DECLARE(cygnus_mipipll, "brcm,cygnus-mipipll", cygnus_mipipll_clk_init);
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_cistatic const struct iproc_asiu_div asiu_div[] = {
2558c2ecf20Sopenharmony_ci	[BCM_CYGNUS_ASIU_KEYPAD_CLK] = ASIU_DIV_VAL(0x0, 31, 16, 10, 0, 10),
2568c2ecf20Sopenharmony_ci	[BCM_CYGNUS_ASIU_ADC_CLK] = ASIU_DIV_VAL(0x4, 31, 16, 10, 0, 10),
2578c2ecf20Sopenharmony_ci	[BCM_CYGNUS_ASIU_PWM_CLK] = ASIU_DIV_VAL(0x8, 31, 16, 10, 0, 10),
2588c2ecf20Sopenharmony_ci};
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_cistatic const struct iproc_asiu_gate asiu_gate[] = {
2618c2ecf20Sopenharmony_ci	[BCM_CYGNUS_ASIU_KEYPAD_CLK] = ASIU_GATE_VAL(0x0, 7),
2628c2ecf20Sopenharmony_ci	[BCM_CYGNUS_ASIU_ADC_CLK] = ASIU_GATE_VAL(0x0, 9),
2638c2ecf20Sopenharmony_ci	[BCM_CYGNUS_ASIU_PWM_CLK] = ASIU_GATE_VAL(IPROC_CLK_INVALID_OFFSET, 0),
2648c2ecf20Sopenharmony_ci};
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_cistatic void __init cygnus_asiu_init(struct device_node *node)
2678c2ecf20Sopenharmony_ci{
2688c2ecf20Sopenharmony_ci	iproc_asiu_setup(node, asiu_div, asiu_gate, ARRAY_SIZE(asiu_div));
2698c2ecf20Sopenharmony_ci}
2708c2ecf20Sopenharmony_ciCLK_OF_DECLARE(cygnus_asiu_clk, "brcm,cygnus-asiu-clk", cygnus_asiu_init);
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistatic const struct iproc_pll_ctrl audiopll = {
2738c2ecf20Sopenharmony_ci	.flags = IPROC_CLK_PLL_NEEDS_SW_CFG | IPROC_CLK_PLL_HAS_NDIV_FRAC |
2748c2ecf20Sopenharmony_ci		IPROC_CLK_PLL_USER_MODE_ON | IPROC_CLK_PLL_RESET_ACTIVE_LOW |
2758c2ecf20Sopenharmony_ci		IPROC_CLK_PLL_CALC_PARAM,
2768c2ecf20Sopenharmony_ci	.reset = RESET_VAL(0x5c, 0, 1),
2778c2ecf20Sopenharmony_ci	.dig_filter = DF_VAL(0x48, 0, 3, 6, 4, 3, 3),
2788c2ecf20Sopenharmony_ci	.sw_ctrl = SW_CTRL_VAL(0x4, 0),
2798c2ecf20Sopenharmony_ci	.ndiv_int = REG_VAL(0x8, 0, 10),
2808c2ecf20Sopenharmony_ci	.ndiv_frac = REG_VAL(0x8, 10, 20),
2818c2ecf20Sopenharmony_ci	.pdiv = REG_VAL(0x44, 0, 4),
2828c2ecf20Sopenharmony_ci	.vco_ctrl = VCO_CTRL_VAL(0x0c, 0x10),
2838c2ecf20Sopenharmony_ci	.status = REG_VAL(0x54, 0, 1),
2848c2ecf20Sopenharmony_ci	.macro_mode = REG_VAL(0x0, 0, 3),
2858c2ecf20Sopenharmony_ci};
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_cistatic const struct iproc_clk_ctrl audiopll_clk[] = {
2888c2ecf20Sopenharmony_ci	[BCM_CYGNUS_AUDIOPLL_CH0] = {
2898c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_AUDIOPLL_CH0,
2908c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON | IPROC_CLK_MCLK_DIV_BY_2,
2918c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x14, 8, 10, 9),
2928c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x14, 0, 8),
2938c2ecf20Sopenharmony_ci	},
2948c2ecf20Sopenharmony_ci	[BCM_CYGNUS_AUDIOPLL_CH1] = {
2958c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_AUDIOPLL_CH1,
2968c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
2978c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x18, 8, 10, 9),
2988c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x18, 0, 8),
2998c2ecf20Sopenharmony_ci	},
3008c2ecf20Sopenharmony_ci	[BCM_CYGNUS_AUDIOPLL_CH2] = {
3018c2ecf20Sopenharmony_ci		.channel = BCM_CYGNUS_AUDIOPLL_CH2,
3028c2ecf20Sopenharmony_ci		.flags = IPROC_CLK_AON,
3038c2ecf20Sopenharmony_ci		.enable = ENABLE_VAL(0x1c, 8, 10, 9),
3048c2ecf20Sopenharmony_ci		.mdiv = REG_VAL(0x1c, 0, 8),
3058c2ecf20Sopenharmony_ci	},
3068c2ecf20Sopenharmony_ci};
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistatic void __init cygnus_audiopll_clk_init(struct device_node *node)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	iproc_pll_clk_setup(node, &audiopll, NULL, 0,
3118c2ecf20Sopenharmony_ci			    audiopll_clk,  ARRAY_SIZE(audiopll_clk));
3128c2ecf20Sopenharmony_ci}
3138c2ecf20Sopenharmony_ciCLK_OF_DECLARE(cygnus_audiopll, "brcm,cygnus-audiopll",
3148c2ecf20Sopenharmony_ci			cygnus_audiopll_clk_init);
315