| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/include/linux/clk.h |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2004 ARM Limited. |
|---|
| 5 | 6 | * Written by Deep Blue Solutions Limited. |
|---|
| 6 | 7 | * Copyright (C) 2011-2012 Linaro Ltd <mturquette@linaro.org> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | #ifndef __LINUX_CLK_H |
|---|
| 13 | 10 | #define __LINUX_CLK_H |
|---|
| .. | .. |
|---|
| 113 | 110 | int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb); |
|---|
| 114 | 111 | |
|---|
| 115 | 112 | /** |
|---|
| 113 | + * devm_clk_notifier_register - register a managed rate-change notifier callback |
|---|
| 114 | + * @dev: device for clock "consumer" |
|---|
| 115 | + * @clk: clock whose rate we are interested in |
|---|
| 116 | + * @nb: notifier block with callback function pointer |
|---|
| 117 | + * |
|---|
| 118 | + * Returns 0 on success, -EERROR otherwise |
|---|
| 119 | + */ |
|---|
| 120 | +int devm_clk_notifier_register(struct device *dev, struct clk *clk, |
|---|
| 121 | + struct notifier_block *nb); |
|---|
| 122 | + |
|---|
| 123 | +/** |
|---|
| 116 | 124 | * clk_get_accuracy - obtain the clock accuracy in ppb (parts per billion) |
|---|
| 117 | 125 | * for a clock source. |
|---|
| 118 | 126 | * @clk: clock source |
|---|
| .. | .. |
|---|
| 189 | 197 | return -ENOTSUPP; |
|---|
| 190 | 198 | } |
|---|
| 191 | 199 | |
|---|
| 200 | +static inline int devm_clk_notifier_register(struct device *dev, |
|---|
| 201 | + struct clk *clk, |
|---|
| 202 | + struct notifier_block *nb) |
|---|
| 203 | +{ |
|---|
| 204 | + return -ENOTSUPP; |
|---|
| 205 | +} |
|---|
| 206 | + |
|---|
| 192 | 207 | static inline long clk_get_accuracy(struct clk *clk) |
|---|
| 193 | 208 | { |
|---|
| 194 | 209 | return -ENOTSUPP; |
|---|
| .. | .. |
|---|
| 242 | 257 | return 0; |
|---|
| 243 | 258 | } |
|---|
| 244 | 259 | |
|---|
| 245 | | -static inline int __must_check clk_bulk_prepare(int num_clks, struct clk_bulk_data *clks) |
|---|
| 260 | +static inline int __must_check |
|---|
| 261 | +clk_bulk_prepare(int num_clks, const struct clk_bulk_data *clks) |
|---|
| 246 | 262 | { |
|---|
| 247 | 263 | might_sleep(); |
|---|
| 248 | 264 | return 0; |
|---|
| .. | .. |
|---|
| 266 | 282 | { |
|---|
| 267 | 283 | might_sleep(); |
|---|
| 268 | 284 | } |
|---|
| 269 | | -static inline void clk_bulk_unprepare(int num_clks, struct clk_bulk_data *clks) |
|---|
| 285 | +static inline void clk_bulk_unprepare(int num_clks, |
|---|
| 286 | + const struct clk_bulk_data *clks) |
|---|
| 270 | 287 | { |
|---|
| 271 | 288 | might_sleep(); |
|---|
| 272 | 289 | } |
|---|
| .. | .. |
|---|
| 362 | 379 | /** |
|---|
| 363 | 380 | * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks |
|---|
| 364 | 381 | * @dev: device for clock "consumer" |
|---|
| 382 | + * @num_clks: the number of clk_bulk_data |
|---|
| 365 | 383 | * @clks: pointer to the clk_bulk_data table of consumer |
|---|
| 366 | 384 | * |
|---|
| 367 | 385 | * Behaves the same as devm_clk_bulk_get() except where there is no clock |
|---|
| .. | .. |
|---|
| 627 | 645 | * @clk: clock source |
|---|
| 628 | 646 | * @rate: desired clock rate in Hz |
|---|
| 629 | 647 | * |
|---|
| 648 | + * Updating the rate starts at the top-most affected clock and then |
|---|
| 649 | + * walks the tree down to the bottom-most clock that needs updating. |
|---|
| 650 | + * |
|---|
| 630 | 651 | * Returns success (0) or negative errno. |
|---|
| 631 | 652 | */ |
|---|
| 632 | 653 | int clk_set_rate(struct clk *clk, unsigned long rate); |
|---|
| .. | .. |
|---|
| 723 | 744 | */ |
|---|
| 724 | 745 | struct clk *clk_get_sys(const char *dev_id, const char *con_id); |
|---|
| 725 | 746 | |
|---|
| 747 | +/** |
|---|
| 748 | + * clk_save_context - save clock context for poweroff |
|---|
| 749 | + * |
|---|
| 750 | + * Saves the context of the clock register for powerstates in which the |
|---|
| 751 | + * contents of the registers will be lost. Occurs deep within the suspend |
|---|
| 752 | + * code so locking is not necessary. |
|---|
| 753 | + */ |
|---|
| 754 | +int clk_save_context(void); |
|---|
| 755 | + |
|---|
| 756 | +/** |
|---|
| 757 | + * clk_restore_context - restore clock context after poweroff |
|---|
| 758 | + * |
|---|
| 759 | + * This occurs with all clocks enabled. Occurs deep within the resume code |
|---|
| 760 | + * so locking is not necessary. |
|---|
| 761 | + */ |
|---|
| 762 | +void clk_restore_context(void); |
|---|
| 763 | + |
|---|
| 726 | 764 | #else /* !CONFIG_HAVE_CLK */ |
|---|
| 727 | 765 | |
|---|
| 728 | 766 | static inline struct clk *clk_get(struct device *dev, const char *id) |
|---|
| .. | .. |
|---|
| 805 | 843 | return 0; |
|---|
| 806 | 844 | } |
|---|
| 807 | 845 | |
|---|
| 808 | | -static inline int __must_check clk_bulk_enable(int num_clks, struct clk_bulk_data *clks) |
|---|
| 846 | +static inline int __must_check clk_bulk_enable(int num_clks, |
|---|
| 847 | + const struct clk_bulk_data *clks) |
|---|
| 809 | 848 | { |
|---|
| 810 | 849 | return 0; |
|---|
| 811 | 850 | } |
|---|
| .. | .. |
|---|
| 814 | 853 | |
|---|
| 815 | 854 | |
|---|
| 816 | 855 | static inline void clk_bulk_disable(int num_clks, |
|---|
| 817 | | - struct clk_bulk_data *clks) {} |
|---|
| 856 | + const struct clk_bulk_data *clks) {} |
|---|
| 818 | 857 | |
|---|
| 819 | 858 | static inline unsigned long clk_get_rate(struct clk *clk) |
|---|
| 820 | 859 | { |
|---|
| .. | .. |
|---|
| 841 | 880 | return true; |
|---|
| 842 | 881 | } |
|---|
| 843 | 882 | |
|---|
| 883 | +static inline int clk_set_rate_range(struct clk *clk, unsigned long min, |
|---|
| 884 | + unsigned long max) |
|---|
| 885 | +{ |
|---|
| 886 | + return 0; |
|---|
| 887 | +} |
|---|
| 888 | + |
|---|
| 889 | +static inline int clk_set_min_rate(struct clk *clk, unsigned long rate) |
|---|
| 890 | +{ |
|---|
| 891 | + return 0; |
|---|
| 892 | +} |
|---|
| 893 | + |
|---|
| 894 | +static inline int clk_set_max_rate(struct clk *clk, unsigned long rate) |
|---|
| 895 | +{ |
|---|
| 896 | + return 0; |
|---|
| 897 | +} |
|---|
| 898 | + |
|---|
| 844 | 899 | static inline int clk_set_parent(struct clk *clk, struct clk *parent) |
|---|
| 845 | 900 | { |
|---|
| 846 | 901 | return 0; |
|---|
| .. | .. |
|---|
| 855 | 910 | { |
|---|
| 856 | 911 | return NULL; |
|---|
| 857 | 912 | } |
|---|
| 913 | + |
|---|
| 914 | +static inline int clk_save_context(void) |
|---|
| 915 | +{ |
|---|
| 916 | + return 0; |
|---|
| 917 | +} |
|---|
| 918 | + |
|---|
| 919 | +static inline void clk_restore_context(void) {} |
|---|
| 920 | + |
|---|
| 858 | 921 | #endif |
|---|
| 859 | 922 | |
|---|
| 860 | 923 | /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ |
|---|
| .. | .. |
|---|
| 879 | 942 | clk_unprepare(clk); |
|---|
| 880 | 943 | } |
|---|
| 881 | 944 | |
|---|
| 882 | | -static inline int __must_check clk_bulk_prepare_enable(int num_clks, |
|---|
| 883 | | - struct clk_bulk_data *clks) |
|---|
| 945 | +static inline int __must_check |
|---|
| 946 | +clk_bulk_prepare_enable(int num_clks, const struct clk_bulk_data *clks) |
|---|
| 884 | 947 | { |
|---|
| 885 | 948 | int ret; |
|---|
| 886 | 949 | |
|---|
| .. | .. |
|---|
| 895 | 958 | } |
|---|
| 896 | 959 | |
|---|
| 897 | 960 | static inline void clk_bulk_disable_unprepare(int num_clks, |
|---|
| 898 | | - struct clk_bulk_data *clks) |
|---|
| 961 | + const struct clk_bulk_data *clks) |
|---|
| 899 | 962 | { |
|---|
| 900 | 963 | clk_bulk_disable(num_clks, clks); |
|---|
| 901 | 964 | clk_bulk_unprepare(num_clks, clks); |
|---|