1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Purna Chandra Mandal,<purna.mandal@microchip.com>
4  * Copyright (C) 2015 Microchip Technology Inc.  All rights reserved.
5  */
6 #ifndef __MICROCHIP_CLK_PIC32_H_
7 #define __MICROCHIP_CLK_PIC32_H_
8 
9 #include <linux/clk-provider.h>
10 
11 /* PIC32 clock data */
12 struct pic32_clk_common {
13 	struct device *dev;
14 	void __iomem *iobase;
15 	spinlock_t reg_lock; /* clock lock */
16 };
17 
18 /* System PLL clock */
19 struct pic32_sys_pll_data {
20 	struct clk_init_data init_data;
21 	const u32 ctrl_reg;
22 	const u32 status_reg;
23 	const u32 lock_mask;
24 };
25 
26 /* System clock */
27 struct pic32_sys_clk_data {
28 	struct clk_init_data init_data;
29 	const u32 mux_reg;
30 	const u32 slew_reg;
31 	const u32 *parent_map;
32 	const u32 slew_div;
33 };
34 
35 /* Reference Oscillator clock */
36 struct pic32_ref_osc_data {
37 	struct clk_init_data init_data;
38 	const u32 ctrl_reg;
39 	const u32 *parent_map;
40 };
41 
42 /* Peripheral Bus clock */
43 struct pic32_periph_clk_data {
44 	struct clk_init_data init_data;
45 	const u32 ctrl_reg;
46 };
47 
48 /* External Secondary Oscillator clock  */
49 struct pic32_sec_osc_data {
50 	struct clk_init_data init_data;
51 	const u32 enable_reg;
52 	const u32 status_reg;
53 	const u32 enable_mask;
54 	const u32 status_mask;
55 	const unsigned long fixed_rate;
56 };
57 
58 extern const struct clk_ops pic32_pbclk_ops;
59 extern const struct clk_ops pic32_sclk_ops;
60 extern const struct clk_ops pic32_sclk_no_div_ops;
61 extern const struct clk_ops pic32_spll_ops;
62 extern const struct clk_ops pic32_roclk_ops;
63 extern const struct clk_ops pic32_sosc_ops;
64 
65 struct clk *pic32_periph_clk_register(const struct pic32_periph_clk_data *data,
66 				      struct pic32_clk_common *core);
67 struct clk *pic32_refo_clk_register(const struct pic32_ref_osc_data *data,
68 				    struct pic32_clk_common *core);
69 struct clk *pic32_sys_clk_register(const struct pic32_sys_clk_data *data,
70 				   struct pic32_clk_common *core);
71 struct clk *pic32_spll_clk_register(const struct pic32_sys_pll_data *data,
72 				    struct pic32_clk_common *core);
73 struct clk *pic32_sosc_clk_register(const struct pic32_sec_osc_data *data,
74 				    struct pic32_clk_common *core);
75 
76 #endif /* __MICROCHIP_CLK_PIC32_H_*/
77