drm/msm/dsi: use devm_clk_*register to registe DSI PHY clocks
[sfrench/cifs-2.6.git] / drivers / gpu / drm / msm / dsi / phy / dsi_pll.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
4  */
5
6 #ifndef __DSI_PLL_H__
7 #define __DSI_PLL_H__
8
9 #include <linux/clk-provider.h>
10 #include <linux/delay.h>
11
12 #include "dsi.h"
13
14 struct msm_dsi_pll {
15         struct clk_hw   clk_hw;
16         bool            pll_on;
17         bool            state_saved;
18
19         const struct msm_dsi_phy_cfg *cfg;
20 };
21
22 #define hw_clk_to_pll(x) container_of(x, struct msm_dsi_pll, clk_hw)
23
24 static inline void pll_write(void __iomem *reg, u32 data)
25 {
26         msm_writel(data, reg);
27 }
28
29 static inline u32 pll_read(const void __iomem *reg)
30 {
31         return msm_readl(reg);
32 }
33
34 static inline void pll_write_udelay(void __iomem *reg, u32 data, u32 delay_us)
35 {
36         pll_write(reg, data);
37         udelay(delay_us);
38 }
39
40 static inline void pll_write_ndelay(void __iomem *reg, u32 data, u32 delay_ns)
41 {
42         pll_write((reg), data);
43         ndelay(delay_ns);
44 }
45
46 /*
47  * DSI PLL Helper functions
48  */
49
50 /* clock callbacks */
51 long msm_dsi_pll_helper_clk_round_rate(struct clk_hw *hw,
52                 unsigned long rate, unsigned long *parent_rate);
53 int msm_dsi_pll_helper_clk_prepare(struct clk_hw *hw);
54 void msm_dsi_pll_helper_clk_unprepare(struct clk_hw *hw);
55
56 #endif /* __DSI_PLL_H__ */
57