xref: /openbmc/linux/drivers/clk/hisilicon/crg-hi3516cv300.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
11ccea77eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2c80dfd9bSPan Wen /*
3c80dfd9bSPan Wen  * Hi3516CV300 Clock and Reset Generator Driver
4c80dfd9bSPan Wen  *
5c80dfd9bSPan Wen  * Copyright (c) 2016 HiSilicon Technologies Co., Ltd.
6c80dfd9bSPan Wen  */
7c80dfd9bSPan Wen 
8c80dfd9bSPan Wen #include <dt-bindings/clock/hi3516cv300-clock.h>
9c80dfd9bSPan Wen #include <linux/clk-provider.h>
10c80dfd9bSPan Wen #include <linux/module.h>
11*a96cbb14SRob Herring #include <linux/of.h>
12c80dfd9bSPan Wen #include <linux/platform_device.h>
13c80dfd9bSPan Wen #include "clk.h"
14c80dfd9bSPan Wen #include "crg.h"
15c80dfd9bSPan Wen #include "reset.h"
16c80dfd9bSPan Wen 
17c80dfd9bSPan Wen /* hi3516CV300 core CRG */
18c80dfd9bSPan Wen #define HI3516CV300_INNER_CLK_OFFSET	64
19c80dfd9bSPan Wen #define HI3516CV300_FIXED_3M		65
20c80dfd9bSPan Wen #define HI3516CV300_FIXED_6M		66
21c80dfd9bSPan Wen #define HI3516CV300_FIXED_24M		67
22c80dfd9bSPan Wen #define HI3516CV300_FIXED_49P5		68
23c80dfd9bSPan Wen #define HI3516CV300_FIXED_50M		69
24c80dfd9bSPan Wen #define HI3516CV300_FIXED_83P3M		70
25c80dfd9bSPan Wen #define HI3516CV300_FIXED_99M		71
26c80dfd9bSPan Wen #define HI3516CV300_FIXED_100M		72
27c80dfd9bSPan Wen #define HI3516CV300_FIXED_148P5M	73
28c80dfd9bSPan Wen #define HI3516CV300_FIXED_198M		74
29c80dfd9bSPan Wen #define HI3516CV300_FIXED_297M		75
30c80dfd9bSPan Wen #define HI3516CV300_UART_MUX		76
31c80dfd9bSPan Wen #define HI3516CV300_FMC_MUX		77
32c80dfd9bSPan Wen #define HI3516CV300_MMC0_MUX		78
33c80dfd9bSPan Wen #define HI3516CV300_MMC1_MUX		79
34c80dfd9bSPan Wen #define HI3516CV300_MMC2_MUX		80
35c80dfd9bSPan Wen #define HI3516CV300_MMC3_MUX		81
36c80dfd9bSPan Wen #define HI3516CV300_PWM_MUX		82
37c80dfd9bSPan Wen #define HI3516CV300_CRG_NR_CLKS		128
38c80dfd9bSPan Wen 
39c80dfd9bSPan Wen static const struct hisi_fixed_rate_clock hi3516cv300_fixed_rate_clks[] = {
40c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_3M, "3m", NULL, 0, 3000000, },
41c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_6M, "6m", NULL, 0, 6000000, },
42c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_24M, "24m", NULL, 0, 24000000, },
43c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_49P5, "49.5m", NULL, 0, 49500000, },
44c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_50M, "50m", NULL, 0, 50000000, },
45c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_83P3M, "83.3m", NULL, 0, 83300000, },
46c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_99M, "99m", NULL, 0, 99000000, },
47c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_100M, "100m", NULL, 0, 100000000, },
48c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_148P5M, "148.5m", NULL, 0, 148500000, },
49c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_198M, "198m", NULL, 0, 198000000, },
50c80dfd9bSPan Wen 	{ HI3516CV300_FIXED_297M, "297m", NULL, 0, 297000000, },
51c80dfd9bSPan Wen 	{ HI3516CV300_APB_CLK, "apb", NULL, 0, 50000000, },
52c80dfd9bSPan Wen };
53c80dfd9bSPan Wen 
54c80dfd9bSPan Wen static const char *const uart_mux_p[] = {"24m", "6m"};
55c80dfd9bSPan Wen static const char *const fmc_mux_p[] = {
56c80dfd9bSPan Wen 	"24m", "83.3m", "148.5m", "198m", "297m"
57c80dfd9bSPan Wen };
58c80dfd9bSPan Wen static const char *const mmc_mux_p[] = {"49.5m"};
59c80dfd9bSPan Wen static const char *const mmc2_mux_p[] = {"99m", "49.5m"};
60c80dfd9bSPan Wen static const char *const pwm_mux_p[] = {"3m", "50m", "24m", "24m"};
61c80dfd9bSPan Wen 
62c80dfd9bSPan Wen static u32 uart_mux_table[] = {0, 1};
63c80dfd9bSPan Wen static u32 fmc_mux_table[] = {0, 1, 2, 3, 4};
64c80dfd9bSPan Wen static u32 mmc_mux_table[] = {0};
65c80dfd9bSPan Wen static u32 mmc2_mux_table[] = {0, 2};
66c80dfd9bSPan Wen static u32 pwm_mux_table[] = {0, 1, 2, 3};
67c80dfd9bSPan Wen 
68c80dfd9bSPan Wen static const struct hisi_mux_clock hi3516cv300_mux_clks[] = {
69c80dfd9bSPan Wen 	{ HI3516CV300_UART_MUX, "uart_mux", uart_mux_p, ARRAY_SIZE(uart_mux_p),
70c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0xe4, 19, 1, 0, uart_mux_table, },
71c80dfd9bSPan Wen 	{ HI3516CV300_FMC_MUX, "fmc_mux", fmc_mux_p, ARRAY_SIZE(fmc_mux_p),
72c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0xc0, 2, 3, 0, fmc_mux_table, },
73c80dfd9bSPan Wen 	{ HI3516CV300_MMC0_MUX, "mmc0_mux", mmc_mux_p, ARRAY_SIZE(mmc_mux_p),
74c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0xc4, 4, 2, 0, mmc_mux_table, },
75c80dfd9bSPan Wen 	{ HI3516CV300_MMC1_MUX, "mmc1_mux", mmc_mux_p, ARRAY_SIZE(mmc_mux_p),
76c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0xc4, 12, 2, 0, mmc_mux_table, },
77c80dfd9bSPan Wen 	{ HI3516CV300_MMC2_MUX, "mmc2_mux", mmc2_mux_p, ARRAY_SIZE(mmc2_mux_p),
78c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0xc4, 20, 2, 0, mmc2_mux_table, },
79c80dfd9bSPan Wen 	{ HI3516CV300_MMC3_MUX, "mmc3_mux", mmc_mux_p, ARRAY_SIZE(mmc_mux_p),
80c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0xc8, 4, 2, 0, mmc_mux_table, },
81c80dfd9bSPan Wen 	{ HI3516CV300_PWM_MUX, "pwm_mux", pwm_mux_p, ARRAY_SIZE(pwm_mux_p),
82c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0x38, 2, 2, 0, pwm_mux_table, },
83c80dfd9bSPan Wen };
84c80dfd9bSPan Wen 
85c80dfd9bSPan Wen static const struct hisi_gate_clock hi3516cv300_gate_clks[] = {
86c80dfd9bSPan Wen 
87c80dfd9bSPan Wen 	{ HI3516CV300_UART0_CLK, "clk_uart0", "uart_mux", CLK_SET_RATE_PARENT,
88c80dfd9bSPan Wen 		0xe4, 15, 0, },
89c80dfd9bSPan Wen 	{ HI3516CV300_UART1_CLK, "clk_uart1", "uart_mux", CLK_SET_RATE_PARENT,
90c80dfd9bSPan Wen 		0xe4, 16, 0, },
91c80dfd9bSPan Wen 	{ HI3516CV300_UART2_CLK, "clk_uart2", "uart_mux", CLK_SET_RATE_PARENT,
92c80dfd9bSPan Wen 		0xe4, 17, 0, },
93c80dfd9bSPan Wen 
94c80dfd9bSPan Wen 	{ HI3516CV300_SPI0_CLK, "clk_spi0", "100m", CLK_SET_RATE_PARENT,
95c80dfd9bSPan Wen 		0xe4, 13, 0, },
96c80dfd9bSPan Wen 	{ HI3516CV300_SPI1_CLK, "clk_spi1", "100m", CLK_SET_RATE_PARENT,
97c80dfd9bSPan Wen 		0xe4, 14, 0, },
98c80dfd9bSPan Wen 
99c80dfd9bSPan Wen 	{ HI3516CV300_FMC_CLK, "clk_fmc", "fmc_mux", CLK_SET_RATE_PARENT,
100c80dfd9bSPan Wen 		0xc0, 1, 0, },
101c80dfd9bSPan Wen 	{ HI3516CV300_MMC0_CLK, "clk_mmc0", "mmc0_mux", CLK_SET_RATE_PARENT,
102c80dfd9bSPan Wen 		0xc4, 1, 0, },
103c80dfd9bSPan Wen 	{ HI3516CV300_MMC1_CLK, "clk_mmc1", "mmc1_mux", CLK_SET_RATE_PARENT,
104c80dfd9bSPan Wen 		0xc4, 9, 0, },
105c80dfd9bSPan Wen 	{ HI3516CV300_MMC2_CLK, "clk_mmc2", "mmc2_mux", CLK_SET_RATE_PARENT,
106c80dfd9bSPan Wen 		0xc4, 17, 0, },
107c80dfd9bSPan Wen 	{ HI3516CV300_MMC3_CLK, "clk_mmc3", "mmc3_mux", CLK_SET_RATE_PARENT,
108c80dfd9bSPan Wen 		0xc8, 1, 0, },
109c80dfd9bSPan Wen 
110c80dfd9bSPan Wen 	{ HI3516CV300_ETH_CLK, "clk_eth", NULL, 0, 0xec, 1, 0, },
111c80dfd9bSPan Wen 
112c80dfd9bSPan Wen 	{ HI3516CV300_DMAC_CLK, "clk_dmac", NULL, 0, 0xd8, 5, 0, },
113c80dfd9bSPan Wen 	{ HI3516CV300_PWM_CLK, "clk_pwm", "pwm_mux", CLK_SET_RATE_PARENT,
114c80dfd9bSPan Wen 		0x38, 1, 0, },
115c80dfd9bSPan Wen 
116c80dfd9bSPan Wen 	{ HI3516CV300_USB2_BUS_CLK, "clk_usb2_bus", NULL, 0, 0xb8, 0, 0, },
117c80dfd9bSPan Wen 	{ HI3516CV300_USB2_OHCI48M_CLK, "clk_usb2_ohci48m", NULL, 0,
118c80dfd9bSPan Wen 		0xb8, 1, 0, },
119c80dfd9bSPan Wen 	{ HI3516CV300_USB2_OHCI12M_CLK, "clk_usb2_ohci12m", NULL, 0,
120c80dfd9bSPan Wen 		0xb8, 2, 0, },
121c80dfd9bSPan Wen 	{ HI3516CV300_USB2_OTG_UTMI_CLK, "clk_usb2_otg_utmi", NULL, 0,
122c80dfd9bSPan Wen 		0xb8, 3, 0, },
123c80dfd9bSPan Wen 	{ HI3516CV300_USB2_HST_PHY_CLK, "clk_usb2_hst_phy", NULL, 0,
124c80dfd9bSPan Wen 		0xb8, 4, 0, },
125c80dfd9bSPan Wen 	{ HI3516CV300_USB2_UTMI0_CLK, "clk_usb2_utmi0", NULL, 0, 0xb8, 5, 0, },
126c80dfd9bSPan Wen 	{ HI3516CV300_USB2_PHY_CLK, "clk_usb2_phy", NULL, 0, 0xb8, 7, 0, },
127c80dfd9bSPan Wen };
128c80dfd9bSPan Wen 
hi3516cv300_clk_register(struct platform_device * pdev)129c80dfd9bSPan Wen static struct hisi_clock_data *hi3516cv300_clk_register(
130c80dfd9bSPan Wen 		struct platform_device *pdev)
131c80dfd9bSPan Wen {
132c80dfd9bSPan Wen 	struct hisi_clock_data *clk_data;
133c80dfd9bSPan Wen 	int ret;
134c80dfd9bSPan Wen 
135c80dfd9bSPan Wen 	clk_data = hisi_clk_alloc(pdev, HI3516CV300_CRG_NR_CLKS);
136c80dfd9bSPan Wen 	if (!clk_data)
137c80dfd9bSPan Wen 		return ERR_PTR(-ENOMEM);
138c80dfd9bSPan Wen 
139c80dfd9bSPan Wen 	ret = hisi_clk_register_fixed_rate(hi3516cv300_fixed_rate_clks,
140c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_fixed_rate_clks), clk_data);
141c80dfd9bSPan Wen 	if (ret)
142c80dfd9bSPan Wen 		return ERR_PTR(ret);
143c80dfd9bSPan Wen 
144c80dfd9bSPan Wen 	ret = hisi_clk_register_mux(hi3516cv300_mux_clks,
145c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_mux_clks), clk_data);
146c80dfd9bSPan Wen 	if (ret)
147c80dfd9bSPan Wen 		goto unregister_fixed_rate;
148c80dfd9bSPan Wen 
149c80dfd9bSPan Wen 	ret = hisi_clk_register_gate(hi3516cv300_gate_clks,
150c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_gate_clks), clk_data);
151c80dfd9bSPan Wen 	if (ret)
152c80dfd9bSPan Wen 		goto unregister_mux;
153c80dfd9bSPan Wen 
154c80dfd9bSPan Wen 	ret = of_clk_add_provider(pdev->dev.of_node,
155c80dfd9bSPan Wen 			of_clk_src_onecell_get, &clk_data->clk_data);
156c80dfd9bSPan Wen 	if (ret)
157c80dfd9bSPan Wen 		goto unregister_gate;
158c80dfd9bSPan Wen 
159c80dfd9bSPan Wen 	return clk_data;
160c80dfd9bSPan Wen 
161c80dfd9bSPan Wen unregister_gate:
162c80dfd9bSPan Wen 	hisi_clk_unregister_gate(hi3516cv300_gate_clks,
163c80dfd9bSPan Wen 				ARRAY_SIZE(hi3516cv300_gate_clks), clk_data);
164c80dfd9bSPan Wen unregister_mux:
165c80dfd9bSPan Wen 	hisi_clk_unregister_mux(hi3516cv300_mux_clks,
166c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_mux_clks), clk_data);
167c80dfd9bSPan Wen unregister_fixed_rate:
168c80dfd9bSPan Wen 	hisi_clk_unregister_fixed_rate(hi3516cv300_fixed_rate_clks,
169c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_fixed_rate_clks), clk_data);
170c80dfd9bSPan Wen 	return ERR_PTR(ret);
171c80dfd9bSPan Wen }
172c80dfd9bSPan Wen 
hi3516cv300_clk_unregister(struct platform_device * pdev)173c80dfd9bSPan Wen static void hi3516cv300_clk_unregister(struct platform_device *pdev)
174c80dfd9bSPan Wen {
175c80dfd9bSPan Wen 	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
176c80dfd9bSPan Wen 
177c80dfd9bSPan Wen 	of_clk_del_provider(pdev->dev.of_node);
178c80dfd9bSPan Wen 
179c80dfd9bSPan Wen 	hisi_clk_unregister_gate(hi3516cv300_gate_clks,
180c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_gate_clks), crg->clk_data);
181c80dfd9bSPan Wen 	hisi_clk_unregister_mux(hi3516cv300_mux_clks,
182c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_mux_clks), crg->clk_data);
183c80dfd9bSPan Wen 	hisi_clk_unregister_fixed_rate(hi3516cv300_fixed_rate_clks,
184c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_fixed_rate_clks), crg->clk_data);
185c80dfd9bSPan Wen }
186c80dfd9bSPan Wen 
187c80dfd9bSPan Wen static const struct hisi_crg_funcs hi3516cv300_crg_funcs = {
188c80dfd9bSPan Wen 	.register_clks = hi3516cv300_clk_register,
189c80dfd9bSPan Wen 	.unregister_clks = hi3516cv300_clk_unregister,
190c80dfd9bSPan Wen };
191c80dfd9bSPan Wen 
192c80dfd9bSPan Wen /* hi3516CV300 sysctrl CRG */
193c80dfd9bSPan Wen #define HI3516CV300_SYSCTRL_NR_CLKS 16
194c80dfd9bSPan Wen 
195df934cbcSArnd Bergmann static const char *const wdt_mux_p[] __initconst = { "3m", "apb" };
196c80dfd9bSPan Wen static u32 wdt_mux_table[] = {0, 1};
197c80dfd9bSPan Wen 
198c80dfd9bSPan Wen static const struct hisi_mux_clock hi3516cv300_sysctrl_mux_clks[] = {
199c80dfd9bSPan Wen 	{ HI3516CV300_WDT_CLK, "wdt", wdt_mux_p, ARRAY_SIZE(wdt_mux_p),
200c80dfd9bSPan Wen 		CLK_SET_RATE_PARENT, 0x0, 23, 1, 0, wdt_mux_table, },
201c80dfd9bSPan Wen };
202c80dfd9bSPan Wen 
hi3516cv300_sysctrl_clk_register(struct platform_device * pdev)203c80dfd9bSPan Wen static struct hisi_clock_data *hi3516cv300_sysctrl_clk_register(
204c80dfd9bSPan Wen 		struct platform_device *pdev)
205c80dfd9bSPan Wen {
206c80dfd9bSPan Wen 	struct hisi_clock_data *clk_data;
207c80dfd9bSPan Wen 	int ret;
208c80dfd9bSPan Wen 
209c80dfd9bSPan Wen 	clk_data = hisi_clk_alloc(pdev, HI3516CV300_SYSCTRL_NR_CLKS);
210c80dfd9bSPan Wen 	if (!clk_data)
211c80dfd9bSPan Wen 		return ERR_PTR(-ENOMEM);
212c80dfd9bSPan Wen 
213c80dfd9bSPan Wen 	ret = hisi_clk_register_mux(hi3516cv300_sysctrl_mux_clks,
214c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), clk_data);
215c80dfd9bSPan Wen 	if (ret)
216c80dfd9bSPan Wen 		return ERR_PTR(ret);
217c80dfd9bSPan Wen 
218c80dfd9bSPan Wen 
219c80dfd9bSPan Wen 	ret = of_clk_add_provider(pdev->dev.of_node,
220c80dfd9bSPan Wen 			of_clk_src_onecell_get, &clk_data->clk_data);
221c80dfd9bSPan Wen 	if (ret)
222c80dfd9bSPan Wen 		goto unregister_mux;
223c80dfd9bSPan Wen 
224c80dfd9bSPan Wen 	return clk_data;
225c80dfd9bSPan Wen 
226c80dfd9bSPan Wen unregister_mux:
227c80dfd9bSPan Wen 	hisi_clk_unregister_mux(hi3516cv300_sysctrl_mux_clks,
228c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), clk_data);
229c80dfd9bSPan Wen 	return ERR_PTR(ret);
230c80dfd9bSPan Wen }
231c80dfd9bSPan Wen 
hi3516cv300_sysctrl_clk_unregister(struct platform_device * pdev)232c80dfd9bSPan Wen static void hi3516cv300_sysctrl_clk_unregister(struct platform_device *pdev)
233c80dfd9bSPan Wen {
234c80dfd9bSPan Wen 	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
235c80dfd9bSPan Wen 
236c80dfd9bSPan Wen 	of_clk_del_provider(pdev->dev.of_node);
237c80dfd9bSPan Wen 
238c80dfd9bSPan Wen 	hisi_clk_unregister_mux(hi3516cv300_sysctrl_mux_clks,
239c80dfd9bSPan Wen 			ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks),
240c80dfd9bSPan Wen 			crg->clk_data);
241c80dfd9bSPan Wen }
242c80dfd9bSPan Wen 
243c80dfd9bSPan Wen static const struct hisi_crg_funcs hi3516cv300_sysctrl_funcs = {
244c80dfd9bSPan Wen 	.register_clks = hi3516cv300_sysctrl_clk_register,
245c80dfd9bSPan Wen 	.unregister_clks = hi3516cv300_sysctrl_clk_unregister,
246c80dfd9bSPan Wen };
247c80dfd9bSPan Wen 
248c80dfd9bSPan Wen static const struct of_device_id hi3516cv300_crg_match_table[] = {
249c80dfd9bSPan Wen 	{
250c80dfd9bSPan Wen 		.compatible = "hisilicon,hi3516cv300-crg",
251c80dfd9bSPan Wen 		.data = &hi3516cv300_crg_funcs
252c80dfd9bSPan Wen 	},
253c80dfd9bSPan Wen 	{
254c80dfd9bSPan Wen 		.compatible = "hisilicon,hi3516cv300-sysctrl",
255c80dfd9bSPan Wen 		.data = &hi3516cv300_sysctrl_funcs
256c80dfd9bSPan Wen 	},
257c80dfd9bSPan Wen 	{ }
258c80dfd9bSPan Wen };
259c80dfd9bSPan Wen MODULE_DEVICE_TABLE(of, hi3516cv300_crg_match_table);
260c80dfd9bSPan Wen 
hi3516cv300_crg_probe(struct platform_device * pdev)261c80dfd9bSPan Wen static int hi3516cv300_crg_probe(struct platform_device *pdev)
262c80dfd9bSPan Wen {
263c80dfd9bSPan Wen 	struct hisi_crg_dev *crg;
264c80dfd9bSPan Wen 
265c80dfd9bSPan Wen 	crg = devm_kmalloc(&pdev->dev, sizeof(*crg), GFP_KERNEL);
266c80dfd9bSPan Wen 	if (!crg)
267c80dfd9bSPan Wen 		return -ENOMEM;
268c80dfd9bSPan Wen 
269c80dfd9bSPan Wen 	crg->funcs = of_device_get_match_data(&pdev->dev);
270c80dfd9bSPan Wen 	if (!crg->funcs)
271c80dfd9bSPan Wen 		return -ENOENT;
272c80dfd9bSPan Wen 
273c80dfd9bSPan Wen 	crg->rstc = hisi_reset_init(pdev);
274c80dfd9bSPan Wen 	if (!crg->rstc)
275c80dfd9bSPan Wen 		return -ENOMEM;
276c80dfd9bSPan Wen 
277c80dfd9bSPan Wen 	crg->clk_data = crg->funcs->register_clks(pdev);
278c80dfd9bSPan Wen 	if (IS_ERR(crg->clk_data)) {
279c80dfd9bSPan Wen 		hisi_reset_exit(crg->rstc);
280c80dfd9bSPan Wen 		return PTR_ERR(crg->clk_data);
281c80dfd9bSPan Wen 	}
282c80dfd9bSPan Wen 
283c80dfd9bSPan Wen 	platform_set_drvdata(pdev, crg);
284c80dfd9bSPan Wen 	return 0;
285c80dfd9bSPan Wen }
286c80dfd9bSPan Wen 
hi3516cv300_crg_remove(struct platform_device * pdev)287bfa8370bSUwe Kleine-König static void hi3516cv300_crg_remove(struct platform_device *pdev)
288c80dfd9bSPan Wen {
289c80dfd9bSPan Wen 	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
290c80dfd9bSPan Wen 
291c80dfd9bSPan Wen 	hisi_reset_exit(crg->rstc);
292c80dfd9bSPan Wen 	crg->funcs->unregister_clks(pdev);
293c80dfd9bSPan Wen }
294c80dfd9bSPan Wen 
295c80dfd9bSPan Wen static struct platform_driver hi3516cv300_crg_driver = {
296c80dfd9bSPan Wen 	.probe          = hi3516cv300_crg_probe,
297bfa8370bSUwe Kleine-König 	.remove_new	= hi3516cv300_crg_remove,
298c80dfd9bSPan Wen 	.driver         = {
299c80dfd9bSPan Wen 		.name   = "hi3516cv300-crg",
300c80dfd9bSPan Wen 		.of_match_table = hi3516cv300_crg_match_table,
301c80dfd9bSPan Wen 	},
302c80dfd9bSPan Wen };
303c80dfd9bSPan Wen 
hi3516cv300_crg_init(void)304c80dfd9bSPan Wen static int __init hi3516cv300_crg_init(void)
305c80dfd9bSPan Wen {
306c80dfd9bSPan Wen 	return platform_driver_register(&hi3516cv300_crg_driver);
307c80dfd9bSPan Wen }
308c80dfd9bSPan Wen core_initcall(hi3516cv300_crg_init);
309c80dfd9bSPan Wen 
hi3516cv300_crg_exit(void)310c80dfd9bSPan Wen static void __exit hi3516cv300_crg_exit(void)
311c80dfd9bSPan Wen {
312c80dfd9bSPan Wen 	platform_driver_unregister(&hi3516cv300_crg_driver);
313c80dfd9bSPan Wen }
314c80dfd9bSPan Wen module_exit(hi3516cv300_crg_exit);
315c80dfd9bSPan Wen 
316c80dfd9bSPan Wen MODULE_LICENSE("GPL v2");
317c80dfd9bSPan Wen MODULE_DESCRIPTION("HiSilicon Hi3516CV300 CRG Driver");
318