18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Synopsys AXS10X SDP Generic PLL clock driver
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2017 Synopsys
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public
78c2ecf20Sopenharmony_ci * License version 2. This program is licensed "as is" without any
88c2ecf20Sopenharmony_ci * warranty of any kind, whether express or implied.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
128c2ecf20Sopenharmony_ci#include <linux/module.h>
138c2ecf20Sopenharmony_ci#include <linux/clk-provider.h>
148c2ecf20Sopenharmony_ci#include <linux/delay.h>
158c2ecf20Sopenharmony_ci#include <linux/err.h>
168c2ecf20Sopenharmony_ci#include <linux/device.h>
178c2ecf20Sopenharmony_ci#include <linux/io.h>
188c2ecf20Sopenharmony_ci#include <linux/of_address.h>
198c2ecf20Sopenharmony_ci#include <linux/of_device.h>
208c2ecf20Sopenharmony_ci#include <linux/slab.h>
218c2ecf20Sopenharmony_ci#include <linux/of.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* PLL registers addresses */
248c2ecf20Sopenharmony_ci#define PLL_REG_IDIV	0x0
258c2ecf20Sopenharmony_ci#define PLL_REG_FBDIV	0x4
268c2ecf20Sopenharmony_ci#define PLL_REG_ODIV	0x8
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/*
298c2ecf20Sopenharmony_ci * Bit fields of the PLL IDIV/FBDIV/ODIV registers:
308c2ecf20Sopenharmony_ci *  ________________________________________________________________________
318c2ecf20Sopenharmony_ci * |31                15|    14    |   13   |  12  |11         6|5         0|
328c2ecf20Sopenharmony_ci * |-------RESRVED------|-NOUPDATE-|-BYPASS-|-EDGE-|--HIGHTIME--|--LOWTIME--|
338c2ecf20Sopenharmony_ci * |____________________|__________|________|______|____________|___________|
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * Following macros determine the way of access to these registers
368c2ecf20Sopenharmony_ci * They should be set up only using the macros.
378c2ecf20Sopenharmony_ci * reg should be an u32 variable.
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define PLL_REG_GET_LOW(reg)			\
418c2ecf20Sopenharmony_ci	(((reg) & (0x3F << 0)) >> 0)
428c2ecf20Sopenharmony_ci#define PLL_REG_GET_HIGH(reg)			\
438c2ecf20Sopenharmony_ci	(((reg) & (0x3F << 6)) >> 6)
448c2ecf20Sopenharmony_ci#define PLL_REG_GET_EDGE(reg)			\
458c2ecf20Sopenharmony_ci	(((reg) & (BIT(12))) ? 1 : 0)
468c2ecf20Sopenharmony_ci#define PLL_REG_GET_BYPASS(reg)			\
478c2ecf20Sopenharmony_ci	(((reg) & (BIT(13))) ? 1 : 0)
488c2ecf20Sopenharmony_ci#define PLL_REG_GET_NOUPD(reg)			\
498c2ecf20Sopenharmony_ci	(((reg) & (BIT(14))) ? 1 : 0)
508c2ecf20Sopenharmony_ci#define PLL_REG_GET_PAD(reg)			\
518c2ecf20Sopenharmony_ci	(((reg) & (0x1FFFF << 15)) >> 15)
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define PLL_REG_SET_LOW(reg, value)		\
548c2ecf20Sopenharmony_ci	{ reg |= (((value) & 0x3F) << 0); }
558c2ecf20Sopenharmony_ci#define PLL_REG_SET_HIGH(reg, value)		\
568c2ecf20Sopenharmony_ci	{ reg |= (((value) & 0x3F) << 6); }
578c2ecf20Sopenharmony_ci#define PLL_REG_SET_EDGE(reg, value)		\
588c2ecf20Sopenharmony_ci	{ reg |= (((value) & 0x01) << 12); }
598c2ecf20Sopenharmony_ci#define PLL_REG_SET_BYPASS(reg, value)		\
608c2ecf20Sopenharmony_ci	{ reg |= (((value) & 0x01) << 13); }
618c2ecf20Sopenharmony_ci#define PLL_REG_SET_NOUPD(reg, value)		\
628c2ecf20Sopenharmony_ci	{ reg |= (((value) & 0x01) << 14); }
638c2ecf20Sopenharmony_ci#define PLL_REG_SET_PAD(reg, value)		\
648c2ecf20Sopenharmony_ci	{ reg |= (((value) & 0x1FFFF) << 15); }
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define PLL_LOCK	BIT(0)
678c2ecf20Sopenharmony_ci#define PLL_ERROR	BIT(1)
688c2ecf20Sopenharmony_ci#define PLL_MAX_LOCK_TIME 100 /* 100 us */
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_cistruct axs10x_pll_cfg {
718c2ecf20Sopenharmony_ci	u32 rate;
728c2ecf20Sopenharmony_ci	u32 idiv;
738c2ecf20Sopenharmony_ci	u32 fbdiv;
748c2ecf20Sopenharmony_ci	u32 odiv;
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistatic const struct axs10x_pll_cfg arc_pll_cfg[] = {
788c2ecf20Sopenharmony_ci	{ 33333333,  1, 1,  1 },
798c2ecf20Sopenharmony_ci	{ 50000000,  1, 30, 20 },
808c2ecf20Sopenharmony_ci	{ 75000000,  2, 45, 10 },
818c2ecf20Sopenharmony_ci	{ 90000000,  2, 54, 10 },
828c2ecf20Sopenharmony_ci	{ 100000000, 1, 30, 10 },
838c2ecf20Sopenharmony_ci	{ 125000000, 2, 45, 6 },
848c2ecf20Sopenharmony_ci	{}
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistatic const struct axs10x_pll_cfg pgu_pll_cfg[] = {
888c2ecf20Sopenharmony_ci	{ 25200000, 1, 84, 90 },
898c2ecf20Sopenharmony_ci	{ 50000000, 1, 100, 54 },
908c2ecf20Sopenharmony_ci	{ 74250000, 1, 44, 16 },
918c2ecf20Sopenharmony_ci	{}
928c2ecf20Sopenharmony_ci};
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistruct axs10x_pll_clk {
958c2ecf20Sopenharmony_ci	struct clk_hw hw;
968c2ecf20Sopenharmony_ci	void __iomem *base;
978c2ecf20Sopenharmony_ci	void __iomem *lock;
988c2ecf20Sopenharmony_ci	const struct axs10x_pll_cfg *pll_cfg;
998c2ecf20Sopenharmony_ci	struct device *dev;
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistatic inline void axs10x_pll_write(struct axs10x_pll_clk *clk, u32 reg,
1038c2ecf20Sopenharmony_ci				    u32 val)
1048c2ecf20Sopenharmony_ci{
1058c2ecf20Sopenharmony_ci	iowrite32(val, clk->base + reg);
1068c2ecf20Sopenharmony_ci}
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cistatic inline u32 axs10x_pll_read(struct axs10x_pll_clk *clk, u32 reg)
1098c2ecf20Sopenharmony_ci{
1108c2ecf20Sopenharmony_ci	return ioread32(clk->base + reg);
1118c2ecf20Sopenharmony_ci}
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_cistatic inline struct axs10x_pll_clk *to_axs10x_pll_clk(struct clk_hw *hw)
1148c2ecf20Sopenharmony_ci{
1158c2ecf20Sopenharmony_ci	return container_of(hw, struct axs10x_pll_clk, hw);
1168c2ecf20Sopenharmony_ci}
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistatic inline u32 axs10x_div_get_value(u32 reg)
1198c2ecf20Sopenharmony_ci{
1208c2ecf20Sopenharmony_ci	if (PLL_REG_GET_BYPASS(reg))
1218c2ecf20Sopenharmony_ci		return 1;
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	return PLL_REG_GET_HIGH(reg) + PLL_REG_GET_LOW(reg);
1248c2ecf20Sopenharmony_ci}
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_cistatic inline u32 axs10x_encode_div(unsigned int id, int upd)
1278c2ecf20Sopenharmony_ci{
1288c2ecf20Sopenharmony_ci	u32 div = 0;
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	PLL_REG_SET_LOW(div, (id % 2 == 0) ? id >> 1 : (id >> 1) + 1);
1318c2ecf20Sopenharmony_ci	PLL_REG_SET_HIGH(div, id >> 1);
1328c2ecf20Sopenharmony_ci	PLL_REG_SET_EDGE(div, id % 2);
1338c2ecf20Sopenharmony_ci	PLL_REG_SET_BYPASS(div, id == 1 ? 1 : 0);
1348c2ecf20Sopenharmony_ci	PLL_REG_SET_NOUPD(div, upd == 0 ? 1 : 0);
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	return div;
1378c2ecf20Sopenharmony_ci}
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic unsigned long axs10x_pll_recalc_rate(struct clk_hw *hw,
1408c2ecf20Sopenharmony_ci					    unsigned long parent_rate)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	u64 rate;
1438c2ecf20Sopenharmony_ci	u32 idiv, fbdiv, odiv;
1448c2ecf20Sopenharmony_ci	struct axs10x_pll_clk *clk = to_axs10x_pll_clk(hw);
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	idiv = axs10x_div_get_value(axs10x_pll_read(clk, PLL_REG_IDIV));
1478c2ecf20Sopenharmony_ci	fbdiv = axs10x_div_get_value(axs10x_pll_read(clk, PLL_REG_FBDIV));
1488c2ecf20Sopenharmony_ci	odiv = axs10x_div_get_value(axs10x_pll_read(clk, PLL_REG_ODIV));
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	rate = (u64)parent_rate * fbdiv;
1518c2ecf20Sopenharmony_ci	do_div(rate, idiv * odiv);
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	return rate;
1548c2ecf20Sopenharmony_ci}
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistatic long axs10x_pll_round_rate(struct clk_hw *hw, unsigned long rate,
1578c2ecf20Sopenharmony_ci				  unsigned long *prate)
1588c2ecf20Sopenharmony_ci{
1598c2ecf20Sopenharmony_ci	int i;
1608c2ecf20Sopenharmony_ci	long best_rate;
1618c2ecf20Sopenharmony_ci	struct axs10x_pll_clk *clk = to_axs10x_pll_clk(hw);
1628c2ecf20Sopenharmony_ci	const struct axs10x_pll_cfg *pll_cfg = clk->pll_cfg;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	if (pll_cfg[0].rate == 0)
1658c2ecf20Sopenharmony_ci		return -EINVAL;
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	best_rate = pll_cfg[0].rate;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	for (i = 1; pll_cfg[i].rate != 0; i++) {
1708c2ecf20Sopenharmony_ci		if (abs(rate - pll_cfg[i].rate) < abs(rate - best_rate))
1718c2ecf20Sopenharmony_ci			best_rate = pll_cfg[i].rate;
1728c2ecf20Sopenharmony_ci	}
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	return best_rate;
1758c2ecf20Sopenharmony_ci}
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistatic int axs10x_pll_set_rate(struct clk_hw *hw, unsigned long rate,
1788c2ecf20Sopenharmony_ci			       unsigned long parent_rate)
1798c2ecf20Sopenharmony_ci{
1808c2ecf20Sopenharmony_ci	int i;
1818c2ecf20Sopenharmony_ci	struct axs10x_pll_clk *clk = to_axs10x_pll_clk(hw);
1828c2ecf20Sopenharmony_ci	const struct axs10x_pll_cfg *pll_cfg = clk->pll_cfg;
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	for (i = 0; pll_cfg[i].rate != 0; i++) {
1858c2ecf20Sopenharmony_ci		if (pll_cfg[i].rate == rate) {
1868c2ecf20Sopenharmony_ci			axs10x_pll_write(clk, PLL_REG_IDIV,
1878c2ecf20Sopenharmony_ci					 axs10x_encode_div(pll_cfg[i].idiv, 0));
1888c2ecf20Sopenharmony_ci			axs10x_pll_write(clk, PLL_REG_FBDIV,
1898c2ecf20Sopenharmony_ci					 axs10x_encode_div(pll_cfg[i].fbdiv, 0));
1908c2ecf20Sopenharmony_ci			axs10x_pll_write(clk, PLL_REG_ODIV,
1918c2ecf20Sopenharmony_ci					 axs10x_encode_div(pll_cfg[i].odiv, 1));
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci			/*
1948c2ecf20Sopenharmony_ci			 * Wait until CGU relocks and check error status.
1958c2ecf20Sopenharmony_ci			 * If after timeout CGU is unlocked yet return error
1968c2ecf20Sopenharmony_ci			 */
1978c2ecf20Sopenharmony_ci			udelay(PLL_MAX_LOCK_TIME);
1988c2ecf20Sopenharmony_ci			if (!(ioread32(clk->lock) & PLL_LOCK))
1998c2ecf20Sopenharmony_ci				return -ETIMEDOUT;
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci			if (ioread32(clk->lock) & PLL_ERROR)
2028c2ecf20Sopenharmony_ci				return -EINVAL;
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci			return 0;
2058c2ecf20Sopenharmony_ci		}
2068c2ecf20Sopenharmony_ci	}
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci	dev_err(clk->dev, "invalid rate=%ld, parent_rate=%ld\n", rate,
2098c2ecf20Sopenharmony_ci			parent_rate);
2108c2ecf20Sopenharmony_ci	return -EINVAL;
2118c2ecf20Sopenharmony_ci}
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_cistatic const struct clk_ops axs10x_pll_ops = {
2148c2ecf20Sopenharmony_ci	.recalc_rate = axs10x_pll_recalc_rate,
2158c2ecf20Sopenharmony_ci	.round_rate = axs10x_pll_round_rate,
2168c2ecf20Sopenharmony_ci	.set_rate = axs10x_pll_set_rate,
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_cistatic int axs10x_pll_clk_probe(struct platform_device *pdev)
2208c2ecf20Sopenharmony_ci{
2218c2ecf20Sopenharmony_ci	struct device *dev = &pdev->dev;
2228c2ecf20Sopenharmony_ci	const char *parent_name;
2238c2ecf20Sopenharmony_ci	struct axs10x_pll_clk *pll_clk;
2248c2ecf20Sopenharmony_ci	struct clk_init_data init = { };
2258c2ecf20Sopenharmony_ci	int ret;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	pll_clk = devm_kzalloc(dev, sizeof(*pll_clk), GFP_KERNEL);
2288c2ecf20Sopenharmony_ci	if (!pll_clk)
2298c2ecf20Sopenharmony_ci		return -ENOMEM;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	pll_clk->base = devm_platform_ioremap_resource(pdev, 0);
2328c2ecf20Sopenharmony_ci	if (IS_ERR(pll_clk->base))
2338c2ecf20Sopenharmony_ci		return PTR_ERR(pll_clk->base);
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	pll_clk->lock = devm_platform_ioremap_resource(pdev, 1);
2368c2ecf20Sopenharmony_ci	if (IS_ERR(pll_clk->lock))
2378c2ecf20Sopenharmony_ci		return PTR_ERR(pll_clk->lock);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	init.name = dev->of_node->name;
2408c2ecf20Sopenharmony_ci	init.ops = &axs10x_pll_ops;
2418c2ecf20Sopenharmony_ci	parent_name = of_clk_get_parent_name(dev->of_node, 0);
2428c2ecf20Sopenharmony_ci	init.parent_names = &parent_name;
2438c2ecf20Sopenharmony_ci	init.num_parents = 1;
2448c2ecf20Sopenharmony_ci	pll_clk->hw.init = &init;
2458c2ecf20Sopenharmony_ci	pll_clk->dev = dev;
2468c2ecf20Sopenharmony_ci	pll_clk->pll_cfg = of_device_get_match_data(dev);
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	if (!pll_clk->pll_cfg) {
2498c2ecf20Sopenharmony_ci		dev_err(dev, "No OF match data provided\n");
2508c2ecf20Sopenharmony_ci		return -EINVAL;
2518c2ecf20Sopenharmony_ci	}
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	ret = devm_clk_hw_register(dev, &pll_clk->hw);
2548c2ecf20Sopenharmony_ci	if (ret) {
2558c2ecf20Sopenharmony_ci		dev_err(dev, "failed to register %s clock\n", init.name);
2568c2ecf20Sopenharmony_ci		return ret;
2578c2ecf20Sopenharmony_ci	}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get,
2608c2ecf20Sopenharmony_ci			&pll_clk->hw);
2618c2ecf20Sopenharmony_ci}
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_cistatic int axs10x_pll_clk_remove(struct platform_device *pdev)
2648c2ecf20Sopenharmony_ci{
2658c2ecf20Sopenharmony_ci	of_clk_del_provider(pdev->dev.of_node);
2668c2ecf20Sopenharmony_ci	return 0;
2678c2ecf20Sopenharmony_ci}
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_cistatic void __init of_axs10x_pll_clk_setup(struct device_node *node)
2708c2ecf20Sopenharmony_ci{
2718c2ecf20Sopenharmony_ci	const char *parent_name;
2728c2ecf20Sopenharmony_ci	struct axs10x_pll_clk *pll_clk;
2738c2ecf20Sopenharmony_ci	struct clk_init_data init = { };
2748c2ecf20Sopenharmony_ci	int ret;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
2778c2ecf20Sopenharmony_ci	if (!pll_clk)
2788c2ecf20Sopenharmony_ci		return;
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	pll_clk->base = of_iomap(node, 0);
2818c2ecf20Sopenharmony_ci	if (!pll_clk->base) {
2828c2ecf20Sopenharmony_ci		pr_err("failed to map pll div registers\n");
2838c2ecf20Sopenharmony_ci		goto err_free_pll_clk;
2848c2ecf20Sopenharmony_ci	}
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	pll_clk->lock = of_iomap(node, 1);
2878c2ecf20Sopenharmony_ci	if (!pll_clk->lock) {
2888c2ecf20Sopenharmony_ci		pr_err("failed to map pll lock register\n");
2898c2ecf20Sopenharmony_ci		goto err_unmap_base;
2908c2ecf20Sopenharmony_ci	}
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	init.name = node->name;
2938c2ecf20Sopenharmony_ci	init.ops = &axs10x_pll_ops;
2948c2ecf20Sopenharmony_ci	parent_name = of_clk_get_parent_name(node, 0);
2958c2ecf20Sopenharmony_ci	init.parent_names = &parent_name;
2968c2ecf20Sopenharmony_ci	init.num_parents = parent_name ? 1 : 0;
2978c2ecf20Sopenharmony_ci	pll_clk->hw.init = &init;
2988c2ecf20Sopenharmony_ci	pll_clk->pll_cfg = arc_pll_cfg;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	ret = clk_hw_register(NULL, &pll_clk->hw);
3018c2ecf20Sopenharmony_ci	if (ret) {
3028c2ecf20Sopenharmony_ci		pr_err("failed to register %pOFn clock\n", node);
3038c2ecf20Sopenharmony_ci		goto err_unmap_lock;
3048c2ecf20Sopenharmony_ci	}
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	ret = of_clk_add_hw_provider(node, of_clk_hw_simple_get, &pll_clk->hw);
3078c2ecf20Sopenharmony_ci	if (ret) {
3088c2ecf20Sopenharmony_ci		pr_err("failed to add hw provider for %pOFn clock\n", node);
3098c2ecf20Sopenharmony_ci		goto err_unregister_clk;
3108c2ecf20Sopenharmony_ci	}
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	return;
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_cierr_unregister_clk:
3158c2ecf20Sopenharmony_ci	clk_hw_unregister(&pll_clk->hw);
3168c2ecf20Sopenharmony_cierr_unmap_lock:
3178c2ecf20Sopenharmony_ci	iounmap(pll_clk->lock);
3188c2ecf20Sopenharmony_cierr_unmap_base:
3198c2ecf20Sopenharmony_ci	iounmap(pll_clk->base);
3208c2ecf20Sopenharmony_cierr_free_pll_clk:
3218c2ecf20Sopenharmony_ci	kfree(pll_clk);
3228c2ecf20Sopenharmony_ci}
3238c2ecf20Sopenharmony_ciCLK_OF_DECLARE(axs10x_pll_clock, "snps,axs10x-arc-pll-clock",
3248c2ecf20Sopenharmony_ci	       of_axs10x_pll_clk_setup);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistatic const struct of_device_id axs10x_pll_clk_id[] = {
3278c2ecf20Sopenharmony_ci	{ .compatible = "snps,axs10x-pgu-pll-clock", .data = &pgu_pll_cfg},
3288c2ecf20Sopenharmony_ci	{ }
3298c2ecf20Sopenharmony_ci};
3308c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, axs10x_pll_clk_id);
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistatic struct platform_driver axs10x_pll_clk_driver = {
3338c2ecf20Sopenharmony_ci	.driver = {
3348c2ecf20Sopenharmony_ci		.name = "axs10x-pll-clock",
3358c2ecf20Sopenharmony_ci		.of_match_table = axs10x_pll_clk_id,
3368c2ecf20Sopenharmony_ci	},
3378c2ecf20Sopenharmony_ci	.probe = axs10x_pll_clk_probe,
3388c2ecf20Sopenharmony_ci	.remove = axs10x_pll_clk_remove,
3398c2ecf20Sopenharmony_ci};
3408c2ecf20Sopenharmony_cibuiltin_platform_driver(axs10x_pll_clk_driver);
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ciMODULE_AUTHOR("Vlad Zakharov <vzakhar@synopsys.com>");
3438c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Synopsys AXS10X SDP Generic PLL Clock Driver");
3448c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
345