Rafael J. Wysocki | b5e8d26 | 2011-08-25 15:34:19 +0200 | [diff] [blame] | 1 | /* |
| 2 | * pm_clock.h - Definitions and headers related to device clocks. |
| 3 | * |
| 4 | * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp. |
| 5 | * |
| 6 | * This file is released under the GPLv2. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _LINUX_PM_CLOCK_H |
| 10 | #define _LINUX_PM_CLOCK_H |
| 11 | |
| 12 | #include <linux/device.h> |
| 13 | #include <linux/notifier.h> |
| 14 | |
| 15 | struct pm_clk_notifier_block { |
| 16 | struct notifier_block nb; |
| 17 | struct dev_pm_domain *pm_domain; |
| 18 | char *con_ids[]; |
| 19 | }; |
| 20 | |
Geert Uytterhoeven | 245bd6f | 2014-11-06 15:51:00 +0200 | [diff] [blame] | 21 | struct clk; |
| 22 | |
Rajendra Nayak | 75f5040 | 2015-04-23 14:03:09 +0530 | [diff] [blame] | 23 | #ifdef CONFIG_PM |
| 24 | extern int pm_clk_runtime_suspend(struct device *dev); |
| 25 | extern int pm_clk_runtime_resume(struct device *dev); |
| 26 | #define USE_PM_CLK_RUNTIME_OPS \ |
| 27 | .runtime_suspend = pm_clk_runtime_suspend, \ |
| 28 | .runtime_resume = pm_clk_runtime_resume, |
| 29 | #else |
| 30 | #define USE_PM_CLK_RUNTIME_OPS |
| 31 | #endif |
| 32 | |
Rafael J. Wysocki | b5e8d26 | 2011-08-25 15:34:19 +0200 | [diff] [blame] | 33 | #ifdef CONFIG_PM_CLK |
| 34 | static inline bool pm_clk_no_clocks(struct device *dev) |
| 35 | { |
| 36 | return dev && dev->power.subsys_data |
| 37 | && list_empty(&dev->power.subsys_data->clock_list); |
| 38 | } |
| 39 | |
| 40 | extern void pm_clk_init(struct device *dev); |
| 41 | extern int pm_clk_create(struct device *dev); |
| 42 | extern void pm_clk_destroy(struct device *dev); |
| 43 | extern int pm_clk_add(struct device *dev, const char *con_id); |
Geert Uytterhoeven | 245bd6f | 2014-11-06 15:51:00 +0200 | [diff] [blame] | 44 | extern int pm_clk_add_clk(struct device *dev, struct clk *clk); |
Rafael J. Wysocki | b5e8d26 | 2011-08-25 15:34:19 +0200 | [diff] [blame] | 45 | extern void pm_clk_remove(struct device *dev, const char *con_id); |
| 46 | extern int pm_clk_suspend(struct device *dev); |
| 47 | extern int pm_clk_resume(struct device *dev); |
| 48 | #else |
| 49 | static inline bool pm_clk_no_clocks(struct device *dev) |
| 50 | { |
| 51 | return true; |
| 52 | } |
| 53 | static inline void pm_clk_init(struct device *dev) |
| 54 | { |
| 55 | } |
| 56 | static inline int pm_clk_create(struct device *dev) |
| 57 | { |
| 58 | return -EINVAL; |
| 59 | } |
| 60 | static inline void pm_clk_destroy(struct device *dev) |
| 61 | { |
| 62 | } |
| 63 | static inline int pm_clk_add(struct device *dev, const char *con_id) |
| 64 | { |
| 65 | return -EINVAL; |
| 66 | } |
Geert Uytterhoeven | 245bd6f | 2014-11-06 15:51:00 +0200 | [diff] [blame] | 67 | |
| 68 | static inline int pm_clk_add_clk(struct device *dev, struct clk *clk) |
| 69 | { |
| 70 | return -EINVAL; |
| 71 | } |
Rafael J. Wysocki | b5e8d26 | 2011-08-25 15:34:19 +0200 | [diff] [blame] | 72 | static inline void pm_clk_remove(struct device *dev, const char *con_id) |
| 73 | { |
| 74 | } |
| 75 | #define pm_clk_suspend NULL |
| 76 | #define pm_clk_resume NULL |
| 77 | #endif |
| 78 | |
| 79 | #ifdef CONFIG_HAVE_CLK |
| 80 | extern void pm_clk_add_notifier(struct bus_type *bus, |
| 81 | struct pm_clk_notifier_block *clknb); |
| 82 | #else |
| 83 | static inline void pm_clk_add_notifier(struct bus_type *bus, |
| 84 | struct pm_clk_notifier_block *clknb) |
| 85 | { |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | #endif |