162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Hi3516CV300 Clock and Reset Generator Driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <dt-bindings/clock/hi3516cv300-clock.h>
962306a36Sopenharmony_ci#include <linux/clk-provider.h>
1062306a36Sopenharmony_ci#include <linux/module.h>
1162306a36Sopenharmony_ci#include <linux/of.h>
1262306a36Sopenharmony_ci#include <linux/platform_device.h>
1362306a36Sopenharmony_ci#include "clk.h"
1462306a36Sopenharmony_ci#include "crg.h"
1562306a36Sopenharmony_ci#include "reset.h"
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/* hi3516CV300 core CRG */
1862306a36Sopenharmony_ci#define HI3516CV300_INNER_CLK_OFFSET	64
1962306a36Sopenharmony_ci#define HI3516CV300_FIXED_3M		65
2062306a36Sopenharmony_ci#define HI3516CV300_FIXED_6M		66
2162306a36Sopenharmony_ci#define HI3516CV300_FIXED_24M		67
2262306a36Sopenharmony_ci#define HI3516CV300_FIXED_49P5		68
2362306a36Sopenharmony_ci#define HI3516CV300_FIXED_50M		69
2462306a36Sopenharmony_ci#define HI3516CV300_FIXED_83P3M		70
2562306a36Sopenharmony_ci#define HI3516CV300_FIXED_99M		71
2662306a36Sopenharmony_ci#define HI3516CV300_FIXED_100M		72
2762306a36Sopenharmony_ci#define HI3516CV300_FIXED_148P5M	73
2862306a36Sopenharmony_ci#define HI3516CV300_FIXED_198M		74
2962306a36Sopenharmony_ci#define HI3516CV300_FIXED_297M		75
3062306a36Sopenharmony_ci#define HI3516CV300_UART_MUX		76
3162306a36Sopenharmony_ci#define HI3516CV300_FMC_MUX		77
3262306a36Sopenharmony_ci#define HI3516CV300_MMC0_MUX		78
3362306a36Sopenharmony_ci#define HI3516CV300_MMC1_MUX		79
3462306a36Sopenharmony_ci#define HI3516CV300_MMC2_MUX		80
3562306a36Sopenharmony_ci#define HI3516CV300_MMC3_MUX		81
3662306a36Sopenharmony_ci#define HI3516CV300_PWM_MUX		82
3762306a36Sopenharmony_ci#define HI3516CV300_CRG_NR_CLKS		128
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_cistatic const struct hisi_fixed_rate_clock hi3516cv300_fixed_rate_clks[] = {
4062306a36Sopenharmony_ci	{ HI3516CV300_FIXED_3M, "3m", NULL, 0, 3000000, },
4162306a36Sopenharmony_ci	{ HI3516CV300_FIXED_6M, "6m", NULL, 0, 6000000, },
4262306a36Sopenharmony_ci	{ HI3516CV300_FIXED_24M, "24m", NULL, 0, 24000000, },
4362306a36Sopenharmony_ci	{ HI3516CV300_FIXED_49P5, "49.5m", NULL, 0, 49500000, },
4462306a36Sopenharmony_ci	{ HI3516CV300_FIXED_50M, "50m", NULL, 0, 50000000, },
4562306a36Sopenharmony_ci	{ HI3516CV300_FIXED_83P3M, "83.3m", NULL, 0, 83300000, },
4662306a36Sopenharmony_ci	{ HI3516CV300_FIXED_99M, "99m", NULL, 0, 99000000, },
4762306a36Sopenharmony_ci	{ HI3516CV300_FIXED_100M, "100m", NULL, 0, 100000000, },
4862306a36Sopenharmony_ci	{ HI3516CV300_FIXED_148P5M, "148.5m", NULL, 0, 148500000, },
4962306a36Sopenharmony_ci	{ HI3516CV300_FIXED_198M, "198m", NULL, 0, 198000000, },
5062306a36Sopenharmony_ci	{ HI3516CV300_FIXED_297M, "297m", NULL, 0, 297000000, },
5162306a36Sopenharmony_ci	{ HI3516CV300_APB_CLK, "apb", NULL, 0, 50000000, },
5262306a36Sopenharmony_ci};
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_cistatic const char *const uart_mux_p[] = {"24m", "6m"};
5562306a36Sopenharmony_cistatic const char *const fmc_mux_p[] = {
5662306a36Sopenharmony_ci	"24m", "83.3m", "148.5m", "198m", "297m"
5762306a36Sopenharmony_ci};
5862306a36Sopenharmony_cistatic const char *const mmc_mux_p[] = {"49.5m"};
5962306a36Sopenharmony_cistatic const char *const mmc2_mux_p[] = {"99m", "49.5m"};
6062306a36Sopenharmony_cistatic const char *const pwm_mux_p[] = {"3m", "50m", "24m", "24m"};
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistatic u32 uart_mux_table[] = {0, 1};
6362306a36Sopenharmony_cistatic u32 fmc_mux_table[] = {0, 1, 2, 3, 4};
6462306a36Sopenharmony_cistatic u32 mmc_mux_table[] = {0};
6562306a36Sopenharmony_cistatic u32 mmc2_mux_table[] = {0, 2};
6662306a36Sopenharmony_cistatic u32 pwm_mux_table[] = {0, 1, 2, 3};
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_cistatic const struct hisi_mux_clock hi3516cv300_mux_clks[] = {
6962306a36Sopenharmony_ci	{ HI3516CV300_UART_MUX, "uart_mux", uart_mux_p, ARRAY_SIZE(uart_mux_p),
7062306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0xe4, 19, 1, 0, uart_mux_table, },
7162306a36Sopenharmony_ci	{ HI3516CV300_FMC_MUX, "fmc_mux", fmc_mux_p, ARRAY_SIZE(fmc_mux_p),
7262306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0xc0, 2, 3, 0, fmc_mux_table, },
7362306a36Sopenharmony_ci	{ HI3516CV300_MMC0_MUX, "mmc0_mux", mmc_mux_p, ARRAY_SIZE(mmc_mux_p),
7462306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0xc4, 4, 2, 0, mmc_mux_table, },
7562306a36Sopenharmony_ci	{ HI3516CV300_MMC1_MUX, "mmc1_mux", mmc_mux_p, ARRAY_SIZE(mmc_mux_p),
7662306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0xc4, 12, 2, 0, mmc_mux_table, },
7762306a36Sopenharmony_ci	{ HI3516CV300_MMC2_MUX, "mmc2_mux", mmc2_mux_p, ARRAY_SIZE(mmc2_mux_p),
7862306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0xc4, 20, 2, 0, mmc2_mux_table, },
7962306a36Sopenharmony_ci	{ HI3516CV300_MMC3_MUX, "mmc3_mux", mmc_mux_p, ARRAY_SIZE(mmc_mux_p),
8062306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0xc8, 4, 2, 0, mmc_mux_table, },
8162306a36Sopenharmony_ci	{ HI3516CV300_PWM_MUX, "pwm_mux", pwm_mux_p, ARRAY_SIZE(pwm_mux_p),
8262306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0x38, 2, 2, 0, pwm_mux_table, },
8362306a36Sopenharmony_ci};
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_cistatic const struct hisi_gate_clock hi3516cv300_gate_clks[] = {
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	{ HI3516CV300_UART0_CLK, "clk_uart0", "uart_mux", CLK_SET_RATE_PARENT,
8862306a36Sopenharmony_ci		0xe4, 15, 0, },
8962306a36Sopenharmony_ci	{ HI3516CV300_UART1_CLK, "clk_uart1", "uart_mux", CLK_SET_RATE_PARENT,
9062306a36Sopenharmony_ci		0xe4, 16, 0, },
9162306a36Sopenharmony_ci	{ HI3516CV300_UART2_CLK, "clk_uart2", "uart_mux", CLK_SET_RATE_PARENT,
9262306a36Sopenharmony_ci		0xe4, 17, 0, },
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	{ HI3516CV300_SPI0_CLK, "clk_spi0", "100m", CLK_SET_RATE_PARENT,
9562306a36Sopenharmony_ci		0xe4, 13, 0, },
9662306a36Sopenharmony_ci	{ HI3516CV300_SPI1_CLK, "clk_spi1", "100m", CLK_SET_RATE_PARENT,
9762306a36Sopenharmony_ci		0xe4, 14, 0, },
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci	{ HI3516CV300_FMC_CLK, "clk_fmc", "fmc_mux", CLK_SET_RATE_PARENT,
10062306a36Sopenharmony_ci		0xc0, 1, 0, },
10162306a36Sopenharmony_ci	{ HI3516CV300_MMC0_CLK, "clk_mmc0", "mmc0_mux", CLK_SET_RATE_PARENT,
10262306a36Sopenharmony_ci		0xc4, 1, 0, },
10362306a36Sopenharmony_ci	{ HI3516CV300_MMC1_CLK, "clk_mmc1", "mmc1_mux", CLK_SET_RATE_PARENT,
10462306a36Sopenharmony_ci		0xc4, 9, 0, },
10562306a36Sopenharmony_ci	{ HI3516CV300_MMC2_CLK, "clk_mmc2", "mmc2_mux", CLK_SET_RATE_PARENT,
10662306a36Sopenharmony_ci		0xc4, 17, 0, },
10762306a36Sopenharmony_ci	{ HI3516CV300_MMC3_CLK, "clk_mmc3", "mmc3_mux", CLK_SET_RATE_PARENT,
10862306a36Sopenharmony_ci		0xc8, 1, 0, },
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci	{ HI3516CV300_ETH_CLK, "clk_eth", NULL, 0, 0xec, 1, 0, },
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci	{ HI3516CV300_DMAC_CLK, "clk_dmac", NULL, 0, 0xd8, 5, 0, },
11362306a36Sopenharmony_ci	{ HI3516CV300_PWM_CLK, "clk_pwm", "pwm_mux", CLK_SET_RATE_PARENT,
11462306a36Sopenharmony_ci		0x38, 1, 0, },
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci	{ HI3516CV300_USB2_BUS_CLK, "clk_usb2_bus", NULL, 0, 0xb8, 0, 0, },
11762306a36Sopenharmony_ci	{ HI3516CV300_USB2_OHCI48M_CLK, "clk_usb2_ohci48m", NULL, 0,
11862306a36Sopenharmony_ci		0xb8, 1, 0, },
11962306a36Sopenharmony_ci	{ HI3516CV300_USB2_OHCI12M_CLK, "clk_usb2_ohci12m", NULL, 0,
12062306a36Sopenharmony_ci		0xb8, 2, 0, },
12162306a36Sopenharmony_ci	{ HI3516CV300_USB2_OTG_UTMI_CLK, "clk_usb2_otg_utmi", NULL, 0,
12262306a36Sopenharmony_ci		0xb8, 3, 0, },
12362306a36Sopenharmony_ci	{ HI3516CV300_USB2_HST_PHY_CLK, "clk_usb2_hst_phy", NULL, 0,
12462306a36Sopenharmony_ci		0xb8, 4, 0, },
12562306a36Sopenharmony_ci	{ HI3516CV300_USB2_UTMI0_CLK, "clk_usb2_utmi0", NULL, 0, 0xb8, 5, 0, },
12662306a36Sopenharmony_ci	{ HI3516CV300_USB2_PHY_CLK, "clk_usb2_phy", NULL, 0, 0xb8, 7, 0, },
12762306a36Sopenharmony_ci};
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_cistatic struct hisi_clock_data *hi3516cv300_clk_register(
13062306a36Sopenharmony_ci		struct platform_device *pdev)
13162306a36Sopenharmony_ci{
13262306a36Sopenharmony_ci	struct hisi_clock_data *clk_data;
13362306a36Sopenharmony_ci	int ret;
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci	clk_data = hisi_clk_alloc(pdev, HI3516CV300_CRG_NR_CLKS);
13662306a36Sopenharmony_ci	if (!clk_data)
13762306a36Sopenharmony_ci		return ERR_PTR(-ENOMEM);
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci	ret = hisi_clk_register_fixed_rate(hi3516cv300_fixed_rate_clks,
14062306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_fixed_rate_clks), clk_data);
14162306a36Sopenharmony_ci	if (ret)
14262306a36Sopenharmony_ci		return ERR_PTR(ret);
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci	ret = hisi_clk_register_mux(hi3516cv300_mux_clks,
14562306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_mux_clks), clk_data);
14662306a36Sopenharmony_ci	if (ret)
14762306a36Sopenharmony_ci		goto unregister_fixed_rate;
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci	ret = hisi_clk_register_gate(hi3516cv300_gate_clks,
15062306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_gate_clks), clk_data);
15162306a36Sopenharmony_ci	if (ret)
15262306a36Sopenharmony_ci		goto unregister_mux;
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci	ret = of_clk_add_provider(pdev->dev.of_node,
15562306a36Sopenharmony_ci			of_clk_src_onecell_get, &clk_data->clk_data);
15662306a36Sopenharmony_ci	if (ret)
15762306a36Sopenharmony_ci		goto unregister_gate;
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci	return clk_data;
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ciunregister_gate:
16262306a36Sopenharmony_ci	hisi_clk_unregister_gate(hi3516cv300_gate_clks,
16362306a36Sopenharmony_ci				ARRAY_SIZE(hi3516cv300_gate_clks), clk_data);
16462306a36Sopenharmony_ciunregister_mux:
16562306a36Sopenharmony_ci	hisi_clk_unregister_mux(hi3516cv300_mux_clks,
16662306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_mux_clks), clk_data);
16762306a36Sopenharmony_ciunregister_fixed_rate:
16862306a36Sopenharmony_ci	hisi_clk_unregister_fixed_rate(hi3516cv300_fixed_rate_clks,
16962306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_fixed_rate_clks), clk_data);
17062306a36Sopenharmony_ci	return ERR_PTR(ret);
17162306a36Sopenharmony_ci}
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_cistatic void hi3516cv300_clk_unregister(struct platform_device *pdev)
17462306a36Sopenharmony_ci{
17562306a36Sopenharmony_ci	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci	of_clk_del_provider(pdev->dev.of_node);
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci	hisi_clk_unregister_gate(hi3516cv300_gate_clks,
18062306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_gate_clks), crg->clk_data);
18162306a36Sopenharmony_ci	hisi_clk_unregister_mux(hi3516cv300_mux_clks,
18262306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_mux_clks), crg->clk_data);
18362306a36Sopenharmony_ci	hisi_clk_unregister_fixed_rate(hi3516cv300_fixed_rate_clks,
18462306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_fixed_rate_clks), crg->clk_data);
18562306a36Sopenharmony_ci}
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_cistatic const struct hisi_crg_funcs hi3516cv300_crg_funcs = {
18862306a36Sopenharmony_ci	.register_clks = hi3516cv300_clk_register,
18962306a36Sopenharmony_ci	.unregister_clks = hi3516cv300_clk_unregister,
19062306a36Sopenharmony_ci};
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci/* hi3516CV300 sysctrl CRG */
19362306a36Sopenharmony_ci#define HI3516CV300_SYSCTRL_NR_CLKS 16
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_cistatic const char *const wdt_mux_p[] __initconst = { "3m", "apb" };
19662306a36Sopenharmony_cistatic u32 wdt_mux_table[] = {0, 1};
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_cistatic const struct hisi_mux_clock hi3516cv300_sysctrl_mux_clks[] = {
19962306a36Sopenharmony_ci	{ HI3516CV300_WDT_CLK, "wdt", wdt_mux_p, ARRAY_SIZE(wdt_mux_p),
20062306a36Sopenharmony_ci		CLK_SET_RATE_PARENT, 0x0, 23, 1, 0, wdt_mux_table, },
20162306a36Sopenharmony_ci};
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_cistatic struct hisi_clock_data *hi3516cv300_sysctrl_clk_register(
20462306a36Sopenharmony_ci		struct platform_device *pdev)
20562306a36Sopenharmony_ci{
20662306a36Sopenharmony_ci	struct hisi_clock_data *clk_data;
20762306a36Sopenharmony_ci	int ret;
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci	clk_data = hisi_clk_alloc(pdev, HI3516CV300_SYSCTRL_NR_CLKS);
21062306a36Sopenharmony_ci	if (!clk_data)
21162306a36Sopenharmony_ci		return ERR_PTR(-ENOMEM);
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci	ret = hisi_clk_register_mux(hi3516cv300_sysctrl_mux_clks,
21462306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), clk_data);
21562306a36Sopenharmony_ci	if (ret)
21662306a36Sopenharmony_ci		return ERR_PTR(ret);
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci	ret = of_clk_add_provider(pdev->dev.of_node,
22062306a36Sopenharmony_ci			of_clk_src_onecell_get, &clk_data->clk_data);
22162306a36Sopenharmony_ci	if (ret)
22262306a36Sopenharmony_ci		goto unregister_mux;
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci	return clk_data;
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ciunregister_mux:
22762306a36Sopenharmony_ci	hisi_clk_unregister_mux(hi3516cv300_sysctrl_mux_clks,
22862306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), clk_data);
22962306a36Sopenharmony_ci	return ERR_PTR(ret);
23062306a36Sopenharmony_ci}
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_cistatic void hi3516cv300_sysctrl_clk_unregister(struct platform_device *pdev)
23362306a36Sopenharmony_ci{
23462306a36Sopenharmony_ci	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci	of_clk_del_provider(pdev->dev.of_node);
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci	hisi_clk_unregister_mux(hi3516cv300_sysctrl_mux_clks,
23962306a36Sopenharmony_ci			ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks),
24062306a36Sopenharmony_ci			crg->clk_data);
24162306a36Sopenharmony_ci}
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_cistatic const struct hisi_crg_funcs hi3516cv300_sysctrl_funcs = {
24462306a36Sopenharmony_ci	.register_clks = hi3516cv300_sysctrl_clk_register,
24562306a36Sopenharmony_ci	.unregister_clks = hi3516cv300_sysctrl_clk_unregister,
24662306a36Sopenharmony_ci};
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_cistatic const struct of_device_id hi3516cv300_crg_match_table[] = {
24962306a36Sopenharmony_ci	{
25062306a36Sopenharmony_ci		.compatible = "hisilicon,hi3516cv300-crg",
25162306a36Sopenharmony_ci		.data = &hi3516cv300_crg_funcs
25262306a36Sopenharmony_ci	},
25362306a36Sopenharmony_ci	{
25462306a36Sopenharmony_ci		.compatible = "hisilicon,hi3516cv300-sysctrl",
25562306a36Sopenharmony_ci		.data = &hi3516cv300_sysctrl_funcs
25662306a36Sopenharmony_ci	},
25762306a36Sopenharmony_ci	{ }
25862306a36Sopenharmony_ci};
25962306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, hi3516cv300_crg_match_table);
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_cistatic int hi3516cv300_crg_probe(struct platform_device *pdev)
26262306a36Sopenharmony_ci{
26362306a36Sopenharmony_ci	struct hisi_crg_dev *crg;
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci	crg = devm_kmalloc(&pdev->dev, sizeof(*crg), GFP_KERNEL);
26662306a36Sopenharmony_ci	if (!crg)
26762306a36Sopenharmony_ci		return -ENOMEM;
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_ci	crg->funcs = of_device_get_match_data(&pdev->dev);
27062306a36Sopenharmony_ci	if (!crg->funcs)
27162306a36Sopenharmony_ci		return -ENOENT;
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci	crg->rstc = hisi_reset_init(pdev);
27462306a36Sopenharmony_ci	if (!crg->rstc)
27562306a36Sopenharmony_ci		return -ENOMEM;
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ci	crg->clk_data = crg->funcs->register_clks(pdev);
27862306a36Sopenharmony_ci	if (IS_ERR(crg->clk_data)) {
27962306a36Sopenharmony_ci		hisi_reset_exit(crg->rstc);
28062306a36Sopenharmony_ci		return PTR_ERR(crg->clk_data);
28162306a36Sopenharmony_ci	}
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci	platform_set_drvdata(pdev, crg);
28462306a36Sopenharmony_ci	return 0;
28562306a36Sopenharmony_ci}
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_cistatic void hi3516cv300_crg_remove(struct platform_device *pdev)
28862306a36Sopenharmony_ci{
28962306a36Sopenharmony_ci	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci	hisi_reset_exit(crg->rstc);
29262306a36Sopenharmony_ci	crg->funcs->unregister_clks(pdev);
29362306a36Sopenharmony_ci}
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_cistatic struct platform_driver hi3516cv300_crg_driver = {
29662306a36Sopenharmony_ci	.probe          = hi3516cv300_crg_probe,
29762306a36Sopenharmony_ci	.remove_new	= hi3516cv300_crg_remove,
29862306a36Sopenharmony_ci	.driver         = {
29962306a36Sopenharmony_ci		.name   = "hi3516cv300-crg",
30062306a36Sopenharmony_ci		.of_match_table = hi3516cv300_crg_match_table,
30162306a36Sopenharmony_ci	},
30262306a36Sopenharmony_ci};
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_cistatic int __init hi3516cv300_crg_init(void)
30562306a36Sopenharmony_ci{
30662306a36Sopenharmony_ci	return platform_driver_register(&hi3516cv300_crg_driver);
30762306a36Sopenharmony_ci}
30862306a36Sopenharmony_cicore_initcall(hi3516cv300_crg_init);
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_cistatic void __exit hi3516cv300_crg_exit(void)
31162306a36Sopenharmony_ci{
31262306a36Sopenharmony_ci	platform_driver_unregister(&hi3516cv300_crg_driver);
31362306a36Sopenharmony_ci}
31462306a36Sopenharmony_cimodule_exit(hi3516cv300_crg_exit);
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ciMODULE_LICENSE("GPL v2");
31762306a36Sopenharmony_ciMODULE_DESCRIPTION("HiSilicon Hi3516CV300 CRG Driver");
318