Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * pm_clock.h - Definitions and headers related to device clocks.
0004  *
0005  * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
0006  */
0007 
0008 #ifndef _LINUX_PM_CLOCK_H
0009 #define _LINUX_PM_CLOCK_H
0010 
0011 #include <linux/device.h>
0012 #include <linux/notifier.h>
0013 
0014 struct pm_clk_notifier_block {
0015     struct notifier_block nb;
0016     struct dev_pm_domain *pm_domain;
0017     char *con_ids[];
0018 };
0019 
0020 struct clk;
0021 
0022 #ifdef CONFIG_PM
0023 extern int pm_clk_runtime_suspend(struct device *dev);
0024 extern int pm_clk_runtime_resume(struct device *dev);
0025 #define USE_PM_CLK_RUNTIME_OPS \
0026     .runtime_suspend = pm_clk_runtime_suspend, \
0027     .runtime_resume = pm_clk_runtime_resume,
0028 #else
0029 #define USE_PM_CLK_RUNTIME_OPS
0030 #endif
0031 
0032 #ifdef CONFIG_PM_CLK
0033 static inline bool pm_clk_no_clocks(struct device *dev)
0034 {
0035     return dev && dev->power.subsys_data
0036         && list_empty(&dev->power.subsys_data->clock_list);
0037 }
0038 
0039 extern void pm_clk_init(struct device *dev);
0040 extern int pm_clk_create(struct device *dev);
0041 extern void pm_clk_destroy(struct device *dev);
0042 extern int pm_clk_add(struct device *dev, const char *con_id);
0043 extern int pm_clk_add_clk(struct device *dev, struct clk *clk);
0044 extern int of_pm_clk_add_clk(struct device *dev, const char *name);
0045 extern int of_pm_clk_add_clks(struct device *dev);
0046 extern void pm_clk_remove(struct device *dev, const char *con_id);
0047 extern void pm_clk_remove_clk(struct device *dev, struct clk *clk);
0048 extern int pm_clk_suspend(struct device *dev);
0049 extern int pm_clk_resume(struct device *dev);
0050 extern int devm_pm_clk_create(struct device *dev);
0051 #else
0052 static inline bool pm_clk_no_clocks(struct device *dev)
0053 {
0054     return true;
0055 }
0056 static inline void pm_clk_init(struct device *dev)
0057 {
0058 }
0059 static inline int pm_clk_create(struct device *dev)
0060 {
0061     return -EINVAL;
0062 }
0063 static inline void pm_clk_destroy(struct device *dev)
0064 {
0065 }
0066 static inline int pm_clk_add(struct device *dev, const char *con_id)
0067 {
0068     return -EINVAL;
0069 }
0070 
0071 static inline int pm_clk_add_clk(struct device *dev, struct clk *clk)
0072 {
0073     return -EINVAL;
0074 }
0075 static inline int of_pm_clk_add_clks(struct device *dev)
0076 {
0077     return -EINVAL;
0078 }
0079 static inline void pm_clk_remove(struct device *dev, const char *con_id)
0080 {
0081 }
0082 #define pm_clk_suspend  NULL
0083 #define pm_clk_resume   NULL
0084 static inline void pm_clk_remove_clk(struct device *dev, struct clk *clk)
0085 {
0086 }
0087 static inline int devm_pm_clk_create(struct device *dev)
0088 {
0089     return -EINVAL;
0090 }
0091 #endif
0092 
0093 #ifdef CONFIG_HAVE_CLK
0094 extern void pm_clk_add_notifier(struct bus_type *bus,
0095                     struct pm_clk_notifier_block *clknb);
0096 #else
0097 static inline void pm_clk_add_notifier(struct bus_type *bus,
0098                     struct pm_clk_notifier_block *clknb)
0099 {
0100 }
0101 #endif
0102 
0103 #endif