1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright 2018 NXP 4 * Dong Aisheng <aisheng.dong@nxp.com> 5 */ 6 7 #ifndef __IMX_CLK_SCU_H 8 #define __IMX_CLK_SCU_H 9 10 #include <linux/firmware/imx/sci.h> 11 #include <linux/of.h> 12 13 extern struct list_head imx_scu_clks[]; 14 extern const struct dev_pm_ops imx_clk_lpcg_scu_pm_ops; 15 16 int imx_clk_scu_init(struct device_node *np); 17 struct clk_hw *imx_scu_of_clk_src_get(struct of_phandle_args *clkspec, 18 void *data); 19 struct clk_hw *imx_clk_scu_alloc_dev(const char *name, 20 const char * const *parents, 21 int num_parents, u32 rsrc_id, u8 clk_type); 22 23 struct clk_hw *__imx_clk_scu(struct device *dev, const char *name, 24 const char * const *parents, int num_parents, 25 u32 rsrc_id, u8 clk_type); 26 27 void imx_clk_scu_unregister(void); 28 29 struct clk_hw *__imx_clk_lpcg_scu(struct device *dev, const char *name, 30 const char *parent_name, unsigned long flags, 31 void __iomem *reg, u8 bit_idx, bool hw_gate); 32 void imx_clk_lpcg_scu_unregister(struct clk_hw *hw); 33 34 static inline struct clk_hw *imx_clk_scu(const char *name, u32 rsrc_id, 35 u8 clk_type, u8 clk_cells) 36 { 37 if (clk_cells == 2) 38 return imx_clk_scu_alloc_dev(name, NULL, 0, rsrc_id, clk_type); 39 else 40 return __imx_clk_scu(NULL, name, NULL, 0, rsrc_id, clk_type); 41 } 42 43 static inline struct clk_hw *imx_clk_scu2(const char *name, const char * const *parents, 44 int num_parents, u32 rsrc_id, u8 clk_type, 45 u8 clk_cells) 46 { 47 if (clk_cells == 2) 48 return imx_clk_scu_alloc_dev(name, parents, num_parents, rsrc_id, clk_type); 49 else 50 return __imx_clk_scu(NULL, name, parents, num_parents, rsrc_id, clk_type); 51 } 52 53 static inline struct clk_hw *imx_clk_lpcg_scu_dev(struct device *dev, const char *name, 54 const char *parent_name, unsigned long flags, 55 void __iomem *reg, u8 bit_idx, bool hw_gate) 56 { 57 return __imx_clk_lpcg_scu(dev, name, parent_name, flags, reg, 58 bit_idx, hw_gate); 59 } 60 61 static inline struct clk_hw *imx_clk_lpcg_scu(const char *name, const char *parent_name, 62 unsigned long flags, void __iomem *reg, 63 u8 bit_idx, bool hw_gate) 64 { 65 return __imx_clk_lpcg_scu(NULL, name, parent_name, flags, reg, 66 bit_idx, hw_gate); 67 } 68 #endif 69