clk: Port Linux common clock framework [CCF] for imx6q to U-boot (tag: v5.1.12)
[oweals/u-boot.git] / drivers / clk / imx / clk.h
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2019 DENX Software Engineering
4  * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
5  */
6 #ifndef __MACH_IMX_CLK_H
7 #define __MACH_IMX_CLK_H
8
9 #include <linux/clk-provider.h>
10
11 enum imx_pllv3_type {
12         IMX_PLLV3_GENERIC,
13         IMX_PLLV3_SYS,
14         IMX_PLLV3_USB,
15         IMX_PLLV3_USB_VF610,
16         IMX_PLLV3_AV,
17         IMX_PLLV3_ENET,
18         IMX_PLLV3_ENET_IMX7,
19         IMX_PLLV3_SYS_VF610,
20         IMX_PLLV3_DDR_IMX7,
21 };
22
23 struct clk *clk_register_gate2(struct device *dev, const char *name,
24                 const char *parent_name, unsigned long flags,
25                 void __iomem *reg, u8 bit_idx, u8 cgr_val,
26                 u8 clk_gate_flags);
27
28 struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
29                           const char *parent_name, void __iomem *base,
30                           u32 div_mask);
31
32 static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
33                                         void __iomem *reg, u8 shift)
34 {
35         return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
36                         shift, 0x3, 0);
37 }
38
39 static inline struct clk *imx_clk_fixed_factor(const char *name,
40                 const char *parent, unsigned int mult, unsigned int div)
41 {
42         return clk_register_fixed_factor(NULL, name, parent,
43                         CLK_SET_RATE_PARENT, mult, div);
44 }
45
46 static inline struct clk *imx_clk_divider(const char *name, const char *parent,
47                 void __iomem *reg, u8 shift, u8 width)
48 {
49         return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
50                         reg, shift, width, 0);
51 }
52
53 struct clk *imx_clk_pfd(const char *name, const char *parent_name,
54                         void __iomem *reg, u8 idx);
55
56 struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
57                               u8 shift, u8 width, const char * const *parents,
58                               int num_parents, void (*fixup)(u32 *val));
59
60 static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
61                         u8 shift, u8 width, const char * const *parents,
62                         int num_parents)
63 {
64         return clk_register_mux(NULL, name, parents, num_parents,
65                         CLK_SET_RATE_NO_REPARENT, reg, shift,
66                         width, 0);
67 }
68
69 #endif /* __MACH_IMX_CLK_H */