1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2f8ce2547SRussell King /* 3f8ce2547SRussell King * linux/include/linux/clk.h 4f8ce2547SRussell King * 5f8ce2547SRussell King * Copyright (C) 2004 ARM Limited. 6f8ce2547SRussell King * Written by Deep Blue Solutions Limited. 7b2476490SMike Turquette * Copyright (C) 2011-2012 Linaro Ltd <mturquette@linaro.org> 8f8ce2547SRussell King */ 9686f8c5dSTodd Poynor #ifndef __LINUX_CLK_H 10686f8c5dSTodd Poynor #define __LINUX_CLK_H 11f8ce2547SRussell King 129f1612d3SShawn Guo #include <linux/err.h> 1340d3e0f4SRussell King #include <linux/kernel.h> 14b2476490SMike Turquette #include <linux/notifier.h> 1540d3e0f4SRussell King 16f8ce2547SRussell King struct device; 17f8ce2547SRussell King struct clk; 1871a2f115SKuninori Morimoto struct device_node; 1971a2f115SKuninori Morimoto struct of_phandle_args; 20f8ce2547SRussell King 21b2476490SMike Turquette /** 22b2476490SMike Turquette * DOC: clk notifier callback types 23b2476490SMike Turquette * 24b2476490SMike Turquette * PRE_RATE_CHANGE - called immediately before the clk rate is changed, 25b2476490SMike Turquette * to indicate that the rate change will proceed. Drivers must 26b2476490SMike Turquette * immediately terminate any operations that will be affected by the 27fb72a059SSoren Brinkmann * rate change. Callbacks may either return NOTIFY_DONE, NOTIFY_OK, 28fb72a059SSoren Brinkmann * NOTIFY_STOP or NOTIFY_BAD. 29b2476490SMike Turquette * 30b2476490SMike Turquette * ABORT_RATE_CHANGE: called if the rate change failed for some reason 31b2476490SMike Turquette * after PRE_RATE_CHANGE. In this case, all registered notifiers on 32b2476490SMike Turquette * the clk will be called with ABORT_RATE_CHANGE. Callbacks must 33fb72a059SSoren Brinkmann * always return NOTIFY_DONE or NOTIFY_OK. 34b2476490SMike Turquette * 35b2476490SMike Turquette * POST_RATE_CHANGE - called after the clk rate change has successfully 36fb72a059SSoren Brinkmann * completed. Callbacks must always return NOTIFY_DONE or NOTIFY_OK. 37b2476490SMike Turquette * 38b2476490SMike Turquette */ 39b2476490SMike Turquette #define PRE_RATE_CHANGE BIT(0) 40b2476490SMike Turquette #define POST_RATE_CHANGE BIT(1) 41b2476490SMike Turquette #define ABORT_RATE_CHANGE BIT(2) 42b2476490SMike Turquette 43b2476490SMike Turquette /** 44b2476490SMike Turquette * struct clk_notifier - associate a clk with a notifier 45b2476490SMike Turquette * @clk: struct clk * to associate the notifier with 46b2476490SMike Turquette * @notifier_head: a blocking_notifier_head for this clk 47b2476490SMike Turquette * @node: linked list pointers 48b2476490SMike Turquette * 49b2476490SMike Turquette * A list of struct clk_notifier is maintained by the notifier code. 50b2476490SMike Turquette * An entry is created whenever code registers the first notifier on a 51b2476490SMike Turquette * particular @clk. Future notifiers on that @clk are added to the 52b2476490SMike Turquette * @notifier_head. 53b2476490SMike Turquette */ 54b2476490SMike Turquette struct clk_notifier { 55b2476490SMike Turquette struct clk *clk; 56b2476490SMike Turquette struct srcu_notifier_head notifier_head; 57b2476490SMike Turquette struct list_head node; 58b2476490SMike Turquette }; 59b2476490SMike Turquette 60b2476490SMike Turquette /** 61b2476490SMike Turquette * struct clk_notifier_data - rate data to pass to the notifier callback 62b2476490SMike Turquette * @clk: struct clk * being changed 63b2476490SMike Turquette * @old_rate: previous rate of this clk 64b2476490SMike Turquette * @new_rate: new rate of this clk 65b2476490SMike Turquette * 66b2476490SMike Turquette * For a pre-notifier, old_rate is the clk's rate before this rate 67b2476490SMike Turquette * change, and new_rate is what the rate will be in the future. For a 68b2476490SMike Turquette * post-notifier, old_rate and new_rate are both set to the clk's 69b2476490SMike Turquette * current rate (this was done to optimize the implementation). 70b2476490SMike Turquette */ 71b2476490SMike Turquette struct clk_notifier_data { 72b2476490SMike Turquette struct clk *clk; 73b2476490SMike Turquette unsigned long old_rate; 74b2476490SMike Turquette unsigned long new_rate; 75b2476490SMike Turquette }; 76b2476490SMike Turquette 77266e4e9dSDong Aisheng /** 78266e4e9dSDong Aisheng * struct clk_bulk_data - Data used for bulk clk operations. 79266e4e9dSDong Aisheng * 80266e4e9dSDong Aisheng * @id: clock consumer ID 81266e4e9dSDong Aisheng * @clk: struct clk * to store the associated clock 82266e4e9dSDong Aisheng * 83266e4e9dSDong Aisheng * The CLK APIs provide a series of clk_bulk_() API calls as 84266e4e9dSDong Aisheng * a convenience to consumers which require multiple clks. This 85266e4e9dSDong Aisheng * structure is used to manage data for these calls. 86266e4e9dSDong Aisheng */ 87266e4e9dSDong Aisheng struct clk_bulk_data { 88266e4e9dSDong Aisheng const char *id; 89266e4e9dSDong Aisheng struct clk *clk; 90266e4e9dSDong Aisheng }; 91266e4e9dSDong Aisheng 92e81b87d2SKrzysztof Kozlowski #ifdef CONFIG_COMMON_CLK 93e81b87d2SKrzysztof Kozlowski 9486bcfa2eSMike Turquette /** 95b90f3726SRandy Dunlap * clk_notifier_register - register a clock rate-change notifier callback 9686bcfa2eSMike Turquette * @clk: clock whose rate we are interested in 9786bcfa2eSMike Turquette * @nb: notifier block with callback function pointer 9886bcfa2eSMike Turquette * 9986bcfa2eSMike Turquette * ProTip: debugging across notifier chains can be frustrating. Make sure that 10086bcfa2eSMike Turquette * your notifier callback function prints a nice big warning in case of 10186bcfa2eSMike Turquette * failure. 10286bcfa2eSMike Turquette */ 103b2476490SMike Turquette int clk_notifier_register(struct clk *clk, struct notifier_block *nb); 104b2476490SMike Turquette 10586bcfa2eSMike Turquette /** 106b90f3726SRandy Dunlap * clk_notifier_unregister - unregister a clock rate-change notifier callback 10786bcfa2eSMike Turquette * @clk: clock whose rate we are no longer interested in 10886bcfa2eSMike Turquette * @nb: notifier block which will be unregistered 10986bcfa2eSMike Turquette */ 110b2476490SMike Turquette int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb); 111b2476490SMike Turquette 1125279fc40SBoris BREZILLON /** 1136d30d50dSJerome Brunet * devm_clk_notifier_register - register a managed rate-change notifier callback 1146d30d50dSJerome Brunet * @dev: device for clock "consumer" 1156d30d50dSJerome Brunet * @clk: clock whose rate we are interested in 1166d30d50dSJerome Brunet * @nb: notifier block with callback function pointer 1176d30d50dSJerome Brunet * 1186d30d50dSJerome Brunet * Returns 0 on success, -EERROR otherwise 1196d30d50dSJerome Brunet */ 120e6fb7aeeSJerome Brunet int devm_clk_notifier_register(struct device *dev, struct clk *clk, 121e6fb7aeeSJerome Brunet struct notifier_block *nb); 1226d30d50dSJerome Brunet 1236d30d50dSJerome Brunet /** 1245279fc40SBoris BREZILLON * clk_get_accuracy - obtain the clock accuracy in ppb (parts per billion) 1255279fc40SBoris BREZILLON * for a clock source. 1265279fc40SBoris BREZILLON * @clk: clock source 1275279fc40SBoris BREZILLON * 1285279fc40SBoris BREZILLON * This gets the clock source accuracy expressed in ppb. 1295279fc40SBoris BREZILLON * A perfect clock returns 0. 1305279fc40SBoris BREZILLON */ 1315279fc40SBoris BREZILLON long clk_get_accuracy(struct clk *clk); 1325279fc40SBoris BREZILLON 133e59c5371SMike Turquette /** 134e59c5371SMike Turquette * clk_set_phase - adjust the phase shift of a clock signal 135e59c5371SMike Turquette * @clk: clock signal source 136e59c5371SMike Turquette * @degrees: number of degrees the signal is shifted 137e59c5371SMike Turquette * 138e59c5371SMike Turquette * Shifts the phase of a clock signal by the specified degrees. Returns 0 on 139e59c5371SMike Turquette * success, -EERROR otherwise. 140e59c5371SMike Turquette */ 141e59c5371SMike Turquette int clk_set_phase(struct clk *clk, int degrees); 142e59c5371SMike Turquette 143e59c5371SMike Turquette /** 144e59c5371SMike Turquette * clk_get_phase - return the phase shift of a clock signal 145e59c5371SMike Turquette * @clk: clock signal source 146e59c5371SMike Turquette * 147e59c5371SMike Turquette * Returns the phase shift of a clock node in degrees, otherwise returns 148e59c5371SMike Turquette * -EERROR. 149e59c5371SMike Turquette */ 150e59c5371SMike Turquette int clk_get_phase(struct clk *clk); 151e59c5371SMike Turquette 1523d3801efSMichael Turquette /** 1539fba738aSJerome Brunet * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal 1549fba738aSJerome Brunet * @clk: clock signal source 1559fba738aSJerome Brunet * @num: numerator of the duty cycle ratio to be applied 1569fba738aSJerome Brunet * @den: denominator of the duty cycle ratio to be applied 1579fba738aSJerome Brunet * 1589fba738aSJerome Brunet * Adjust the duty cycle of a clock signal by the specified ratio. Returns 0 on 1599fba738aSJerome Brunet * success, -EERROR otherwise. 1609fba738aSJerome Brunet */ 1619fba738aSJerome Brunet int clk_set_duty_cycle(struct clk *clk, unsigned int num, unsigned int den); 1629fba738aSJerome Brunet 1639fba738aSJerome Brunet /** 1649d1c94a6SMauro Carvalho Chehab * clk_get_scaled_duty_cycle - return the duty cycle ratio of a clock signal 1659fba738aSJerome Brunet * @clk: clock signal source 1669fba738aSJerome Brunet * @scale: scaling factor to be applied to represent the ratio as an integer 1679fba738aSJerome Brunet * 1689fba738aSJerome Brunet * Returns the duty cycle ratio multiplied by the scale provided, otherwise 1699fba738aSJerome Brunet * returns -EERROR. 1709fba738aSJerome Brunet */ 1719fba738aSJerome Brunet int clk_get_scaled_duty_cycle(struct clk *clk, unsigned int scale); 1729fba738aSJerome Brunet 1739fba738aSJerome Brunet /** 1743d3801efSMichael Turquette * clk_is_match - check if two clk's point to the same hardware clock 1753d3801efSMichael Turquette * @p: clk compared against q 1763d3801efSMichael Turquette * @q: clk compared against p 1773d3801efSMichael Turquette * 1783d3801efSMichael Turquette * Returns true if the two struct clk pointers both point to the same hardware 1790e056eb5Smchehab@s-opensource.com * clock node. Put differently, returns true if @p and @q 1800e056eb5Smchehab@s-opensource.com * share the same &struct clk_core object. 1813d3801efSMichael Turquette * 1823d3801efSMichael Turquette * Returns false otherwise. Note that two NULL clks are treated as matching. 1833d3801efSMichael Turquette */ 1843d3801efSMichael Turquette bool clk_is_match(const struct clk *p, const struct clk *q); 1853d3801efSMichael Turquette 186*2746f13fSBiju Das /** 187*2746f13fSBiju Das * clk_rate_exclusive_get - get exclusivity over the rate control of a 188*2746f13fSBiju Das * producer 189*2746f13fSBiju Das * @clk: clock source 190*2746f13fSBiju Das * 191*2746f13fSBiju Das * This function allows drivers to get exclusive control over the rate of a 192*2746f13fSBiju Das * provider. It prevents any other consumer to execute, even indirectly, 193*2746f13fSBiju Das * opereation which could alter the rate of the provider or cause glitches 194*2746f13fSBiju Das * 195*2746f13fSBiju Das * If exlusivity is claimed more than once on clock, even by the same driver, 196*2746f13fSBiju Das * the rate effectively gets locked as exclusivity can't be preempted. 197*2746f13fSBiju Das * 198*2746f13fSBiju Das * Must not be called from within atomic context. 199*2746f13fSBiju Das * 200*2746f13fSBiju Das * Returns success (0) or negative errno. 201*2746f13fSBiju Das */ 202*2746f13fSBiju Das int clk_rate_exclusive_get(struct clk *clk); 203*2746f13fSBiju Das 204*2746f13fSBiju Das /** 205*2746f13fSBiju Das * clk_rate_exclusive_put - release exclusivity over the rate control of a 206*2746f13fSBiju Das * producer 207*2746f13fSBiju Das * @clk: clock source 208*2746f13fSBiju Das * 209*2746f13fSBiju Das * This function allows drivers to release the exclusivity it previously got 210*2746f13fSBiju Das * from clk_rate_exclusive_get() 211*2746f13fSBiju Das * 212*2746f13fSBiju Das * The caller must balance the number of clk_rate_exclusive_get() and 213*2746f13fSBiju Das * clk_rate_exclusive_put() calls. 214*2746f13fSBiju Das * 215*2746f13fSBiju Das * Must not be called from within atomic context. 216*2746f13fSBiju Das */ 217*2746f13fSBiju Das void clk_rate_exclusive_put(struct clk *clk); 218*2746f13fSBiju Das 2195279fc40SBoris BREZILLON #else 2205279fc40SBoris BREZILLON 221e81b87d2SKrzysztof Kozlowski static inline int clk_notifier_register(struct clk *clk, 222e81b87d2SKrzysztof Kozlowski struct notifier_block *nb) 223e81b87d2SKrzysztof Kozlowski { 224e81b87d2SKrzysztof Kozlowski return -ENOTSUPP; 225e81b87d2SKrzysztof Kozlowski } 226e81b87d2SKrzysztof Kozlowski 227e81b87d2SKrzysztof Kozlowski static inline int clk_notifier_unregister(struct clk *clk, 228e81b87d2SKrzysztof Kozlowski struct notifier_block *nb) 229e81b87d2SKrzysztof Kozlowski { 230e81b87d2SKrzysztof Kozlowski return -ENOTSUPP; 231e81b87d2SKrzysztof Kozlowski } 232e81b87d2SKrzysztof Kozlowski 233e6fb7aeeSJerome Brunet static inline int devm_clk_notifier_register(struct device *dev, 234e6fb7aeeSJerome Brunet struct clk *clk, 235e6fb7aeeSJerome Brunet struct notifier_block *nb) 236e6fb7aeeSJerome Brunet { 237e6fb7aeeSJerome Brunet return -ENOTSUPP; 238e6fb7aeeSJerome Brunet } 239e6fb7aeeSJerome Brunet 2405279fc40SBoris BREZILLON static inline long clk_get_accuracy(struct clk *clk) 2415279fc40SBoris BREZILLON { 2425279fc40SBoris BREZILLON return -ENOTSUPP; 2435279fc40SBoris BREZILLON } 2445279fc40SBoris BREZILLON 245e59c5371SMike Turquette static inline long clk_set_phase(struct clk *clk, int phase) 246e59c5371SMike Turquette { 247e59c5371SMike Turquette return -ENOTSUPP; 248e59c5371SMike Turquette } 249e59c5371SMike Turquette 250e59c5371SMike Turquette static inline long clk_get_phase(struct clk *clk) 251e59c5371SMike Turquette { 252e59c5371SMike Turquette return -ENOTSUPP; 253e59c5371SMike Turquette } 254e59c5371SMike Turquette 2559fba738aSJerome Brunet static inline int clk_set_duty_cycle(struct clk *clk, unsigned int num, 2569fba738aSJerome Brunet unsigned int den) 2579fba738aSJerome Brunet { 2589fba738aSJerome Brunet return -ENOTSUPP; 2599fba738aSJerome Brunet } 2609fba738aSJerome Brunet 2619fba738aSJerome Brunet static inline unsigned int clk_get_scaled_duty_cycle(struct clk *clk, 2629fba738aSJerome Brunet unsigned int scale) 2639fba738aSJerome Brunet { 2649fba738aSJerome Brunet return 0; 2659fba738aSJerome Brunet } 2669fba738aSJerome Brunet 2673d3801efSMichael Turquette static inline bool clk_is_match(const struct clk *p, const struct clk *q) 2683d3801efSMichael Turquette { 2693d3801efSMichael Turquette return p == q; 2703d3801efSMichael Turquette } 2713d3801efSMichael Turquette 272*2746f13fSBiju Das static inline int clk_rate_exclusive_get(struct clk *clk) 273*2746f13fSBiju Das { 274*2746f13fSBiju Das return 0; 275*2746f13fSBiju Das } 276*2746f13fSBiju Das 277*2746f13fSBiju Das static inline void clk_rate_exclusive_put(struct clk *clk) {} 278*2746f13fSBiju Das 2797e87aed9SMark Brown #endif 280b2476490SMike Turquette 2810bfa0820SNicolas Pitre #ifdef CONFIG_HAVE_CLK_PREPARE 282f8ce2547SRussell King /** 28393abe8e4SViresh Kumar * clk_prepare - prepare a clock source 28493abe8e4SViresh Kumar * @clk: clock source 28593abe8e4SViresh Kumar * 28693abe8e4SViresh Kumar * This prepares the clock source for use. 28793abe8e4SViresh Kumar * 28893abe8e4SViresh Kumar * Must not be called from within atomic context. 28993abe8e4SViresh Kumar */ 29093abe8e4SViresh Kumar int clk_prepare(struct clk *clk); 291266e4e9dSDong Aisheng int __must_check clk_bulk_prepare(int num_clks, 292266e4e9dSDong Aisheng const struct clk_bulk_data *clks); 2930bfa0820SNicolas Pitre 2940bfa0820SNicolas Pitre /** 2950bfa0820SNicolas Pitre * clk_is_enabled_when_prepared - indicate if preparing a clock also enables it. 2960bfa0820SNicolas Pitre * @clk: clock source 2970bfa0820SNicolas Pitre * 2980bfa0820SNicolas Pitre * Returns true if clk_prepare() implicitly enables the clock, effectively 2990bfa0820SNicolas Pitre * making clk_enable()/clk_disable() no-ops, false otherwise. 3000bfa0820SNicolas Pitre * 3010bfa0820SNicolas Pitre * This is of interest mainly to the power management code where actually 3020bfa0820SNicolas Pitre * disabling the clock also requires unpreparing it to have any material 3030bfa0820SNicolas Pitre * effect. 3040bfa0820SNicolas Pitre * 3050bfa0820SNicolas Pitre * Regardless of the value returned here, the caller must always invoke 3060bfa0820SNicolas Pitre * clk_enable() or clk_prepare_enable() and counterparts for usage counts 3070bfa0820SNicolas Pitre * to be right. 3080bfa0820SNicolas Pitre */ 3090bfa0820SNicolas Pitre bool clk_is_enabled_when_prepared(struct clk *clk); 31093abe8e4SViresh Kumar #else 31193abe8e4SViresh Kumar static inline int clk_prepare(struct clk *clk) 31293abe8e4SViresh Kumar { 31393abe8e4SViresh Kumar might_sleep(); 31493abe8e4SViresh Kumar return 0; 31593abe8e4SViresh Kumar } 316266e4e9dSDong Aisheng 317570aaec7SAndrey Smirnov static inline int __must_check 318570aaec7SAndrey Smirnov clk_bulk_prepare(int num_clks, const struct clk_bulk_data *clks) 319266e4e9dSDong Aisheng { 320266e4e9dSDong Aisheng might_sleep(); 321266e4e9dSDong Aisheng return 0; 322266e4e9dSDong Aisheng } 3230bfa0820SNicolas Pitre 3240bfa0820SNicolas Pitre static inline bool clk_is_enabled_when_prepared(struct clk *clk) 3250bfa0820SNicolas Pitre { 3260bfa0820SNicolas Pitre return false; 3270bfa0820SNicolas Pitre } 32893abe8e4SViresh Kumar #endif 32993abe8e4SViresh Kumar 33093abe8e4SViresh Kumar /** 33193abe8e4SViresh Kumar * clk_unprepare - undo preparation of a clock source 33293abe8e4SViresh Kumar * @clk: clock source 33393abe8e4SViresh Kumar * 33493abe8e4SViresh Kumar * This undoes a previously prepared clock. The caller must balance 33593abe8e4SViresh Kumar * the number of prepare and unprepare calls. 33693abe8e4SViresh Kumar * 33793abe8e4SViresh Kumar * Must not be called from within atomic context. 33893abe8e4SViresh Kumar */ 33993abe8e4SViresh Kumar #ifdef CONFIG_HAVE_CLK_PREPARE 34093abe8e4SViresh Kumar void clk_unprepare(struct clk *clk); 341266e4e9dSDong Aisheng void clk_bulk_unprepare(int num_clks, const struct clk_bulk_data *clks); 34293abe8e4SViresh Kumar #else 34393abe8e4SViresh Kumar static inline void clk_unprepare(struct clk *clk) 34493abe8e4SViresh Kumar { 34593abe8e4SViresh Kumar might_sleep(); 34693abe8e4SViresh Kumar } 347570aaec7SAndrey Smirnov static inline void clk_bulk_unprepare(int num_clks, 348570aaec7SAndrey Smirnov const struct clk_bulk_data *clks) 349266e4e9dSDong Aisheng { 350266e4e9dSDong Aisheng might_sleep(); 351266e4e9dSDong Aisheng } 35293abe8e4SViresh Kumar #endif 35393abe8e4SViresh Kumar 35493abe8e4SViresh Kumar #ifdef CONFIG_HAVE_CLK 35593abe8e4SViresh Kumar /** 356f8ce2547SRussell King * clk_get - lookup and obtain a reference to a clock producer. 357f8ce2547SRussell King * @dev: device for clock "consumer" 358a58b3a4aSJan-Simon Möller * @id: clock consumer ID 359f8ce2547SRussell King * 360f8ce2547SRussell King * Returns a struct clk corresponding to the clock producer, or 361f8ce2547SRussell King * valid IS_ERR() condition containing errno. The implementation 362f8ce2547SRussell King * uses @dev and @id to determine the clock consumer, and thereby 363f8ce2547SRussell King * the clock producer. (IOW, @id may be identical strings, but 364f8ce2547SRussell King * clk_get may return different clock producers depending on @dev.) 365f8ce2547SRussell King * 366f8ce2547SRussell King * Drivers must assume that the clock source is not enabled. 367f7ad160bSAlex Raimondi * 368f7ad160bSAlex Raimondi * clk_get should not be called from within interrupt context. 369f8ce2547SRussell King */ 370f8ce2547SRussell King struct clk *clk_get(struct device *dev, const char *id); 371f8ce2547SRussell King 372f8ce2547SRussell King /** 373266e4e9dSDong Aisheng * clk_bulk_get - lookup and obtain a number of references to clock producer. 374266e4e9dSDong Aisheng * @dev: device for clock "consumer" 375266e4e9dSDong Aisheng * @num_clks: the number of clk_bulk_data 376266e4e9dSDong Aisheng * @clks: the clk_bulk_data table of consumer 377266e4e9dSDong Aisheng * 378266e4e9dSDong Aisheng * This helper function allows drivers to get several clk consumers in one 379266e4e9dSDong Aisheng * operation. If any of the clk cannot be acquired then any clks 380266e4e9dSDong Aisheng * that were obtained will be freed before returning to the caller. 381266e4e9dSDong Aisheng * 382266e4e9dSDong Aisheng * Returns 0 if all clocks specified in clk_bulk_data table are obtained 383266e4e9dSDong Aisheng * successfully, or valid IS_ERR() condition containing errno. 384266e4e9dSDong Aisheng * The implementation uses @dev and @clk_bulk_data.id to determine the 385266e4e9dSDong Aisheng * clock consumer, and thereby the clock producer. 386266e4e9dSDong Aisheng * The clock returned is stored in each @clk_bulk_data.clk field. 387266e4e9dSDong Aisheng * 388266e4e9dSDong Aisheng * Drivers must assume that the clock source is not enabled. 389266e4e9dSDong Aisheng * 390266e4e9dSDong Aisheng * clk_bulk_get should not be called from within interrupt context. 391266e4e9dSDong Aisheng */ 392266e4e9dSDong Aisheng int __must_check clk_bulk_get(struct device *dev, int num_clks, 393266e4e9dSDong Aisheng struct clk_bulk_data *clks); 394616e45dfSDong Aisheng /** 395616e45dfSDong Aisheng * clk_bulk_get_all - lookup and obtain all available references to clock 396616e45dfSDong Aisheng * producer. 397616e45dfSDong Aisheng * @dev: device for clock "consumer" 398616e45dfSDong Aisheng * @clks: pointer to the clk_bulk_data table of consumer 399616e45dfSDong Aisheng * 400616e45dfSDong Aisheng * This helper function allows drivers to get all clk consumers in one 401616e45dfSDong Aisheng * operation. If any of the clk cannot be acquired then any clks 402616e45dfSDong Aisheng * that were obtained will be freed before returning to the caller. 403616e45dfSDong Aisheng * 404616e45dfSDong Aisheng * Returns a positive value for the number of clocks obtained while the 405616e45dfSDong Aisheng * clock references are stored in the clk_bulk_data table in @clks field. 406616e45dfSDong Aisheng * Returns 0 if there're none and a negative value if something failed. 407616e45dfSDong Aisheng * 408616e45dfSDong Aisheng * Drivers must assume that the clock source is not enabled. 409616e45dfSDong Aisheng * 410616e45dfSDong Aisheng * clk_bulk_get should not be called from within interrupt context. 411616e45dfSDong Aisheng */ 412616e45dfSDong Aisheng int __must_check clk_bulk_get_all(struct device *dev, 413616e45dfSDong Aisheng struct clk_bulk_data **clks); 4142f25528eSSylwester Nawrocki 4152f25528eSSylwester Nawrocki /** 4162f25528eSSylwester Nawrocki * clk_bulk_get_optional - lookup and obtain a number of references to clock producer 4172f25528eSSylwester Nawrocki * @dev: device for clock "consumer" 4182f25528eSSylwester Nawrocki * @num_clks: the number of clk_bulk_data 4192f25528eSSylwester Nawrocki * @clks: the clk_bulk_data table of consumer 4202f25528eSSylwester Nawrocki * 4212f25528eSSylwester Nawrocki * Behaves the same as clk_bulk_get() except where there is no clock producer. 4222f25528eSSylwester Nawrocki * In this case, instead of returning -ENOENT, the function returns 0 and 4232f25528eSSylwester Nawrocki * NULL for a clk for which a clock producer could not be determined. 4242f25528eSSylwester Nawrocki */ 4252f25528eSSylwester Nawrocki int __must_check clk_bulk_get_optional(struct device *dev, int num_clks, 4262f25528eSSylwester Nawrocki struct clk_bulk_data *clks); 427266e4e9dSDong Aisheng /** 428618aee02SDong Aisheng * devm_clk_bulk_get - managed get multiple clk consumers 429618aee02SDong Aisheng * @dev: device for clock "consumer" 430618aee02SDong Aisheng * @num_clks: the number of clk_bulk_data 431618aee02SDong Aisheng * @clks: the clk_bulk_data table of consumer 432618aee02SDong Aisheng * 433618aee02SDong Aisheng * Return 0 on success, an errno on failure. 434618aee02SDong Aisheng * 435618aee02SDong Aisheng * This helper function allows drivers to get several clk 436618aee02SDong Aisheng * consumers in one operation with management, the clks will 437618aee02SDong Aisheng * automatically be freed when the device is unbound. 438618aee02SDong Aisheng */ 439618aee02SDong Aisheng int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, 440618aee02SDong Aisheng struct clk_bulk_data *clks); 441f08c2e28SDong Aisheng /** 4429bd5ef0bSSylwester Nawrocki * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks 4439bd5ef0bSSylwester Nawrocki * @dev: device for clock "consumer" 4446ee82ef0SSylwester Nawrocki * @num_clks: the number of clk_bulk_data 4459bd5ef0bSSylwester Nawrocki * @clks: pointer to the clk_bulk_data table of consumer 4469bd5ef0bSSylwester Nawrocki * 4479bd5ef0bSSylwester Nawrocki * Behaves the same as devm_clk_bulk_get() except where there is no clock 4489bd5ef0bSSylwester Nawrocki * producer. In this case, instead of returning -ENOENT, the function returns 4499bd5ef0bSSylwester Nawrocki * NULL for given clk. It is assumed all clocks in clk_bulk_data are optional. 4509bd5ef0bSSylwester Nawrocki * 4519bd5ef0bSSylwester Nawrocki * Returns 0 if all clocks specified in clk_bulk_data table are obtained 4529bd5ef0bSSylwester Nawrocki * successfully or for any clk there was no clk provider available, otherwise 4539bd5ef0bSSylwester Nawrocki * returns valid IS_ERR() condition containing errno. 4549bd5ef0bSSylwester Nawrocki * The implementation uses @dev and @clk_bulk_data.id to determine the 4559bd5ef0bSSylwester Nawrocki * clock consumer, and thereby the clock producer. 4569bd5ef0bSSylwester Nawrocki * The clock returned is stored in each @clk_bulk_data.clk field. 4579bd5ef0bSSylwester Nawrocki * 4589bd5ef0bSSylwester Nawrocki * Drivers must assume that the clock source is not enabled. 4599bd5ef0bSSylwester Nawrocki * 4609bd5ef0bSSylwester Nawrocki * clk_bulk_get should not be called from within interrupt context. 4619bd5ef0bSSylwester Nawrocki */ 4629bd5ef0bSSylwester Nawrocki int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_clks, 4639bd5ef0bSSylwester Nawrocki struct clk_bulk_data *clks); 4649bd5ef0bSSylwester Nawrocki /** 465f08c2e28SDong Aisheng * devm_clk_bulk_get_all - managed get multiple clk consumers 466f08c2e28SDong Aisheng * @dev: device for clock "consumer" 467f08c2e28SDong Aisheng * @clks: pointer to the clk_bulk_data table of consumer 468f08c2e28SDong Aisheng * 469f08c2e28SDong Aisheng * Returns a positive value for the number of clocks obtained while the 470f08c2e28SDong Aisheng * clock references are stored in the clk_bulk_data table in @clks field. 471f08c2e28SDong Aisheng * Returns 0 if there're none and a negative value if something failed. 472f08c2e28SDong Aisheng * 473f08c2e28SDong Aisheng * This helper function allows drivers to get several clk 474f08c2e28SDong Aisheng * consumers in one operation with management, the clks will 475f08c2e28SDong Aisheng * automatically be freed when the device is unbound. 476f08c2e28SDong Aisheng */ 477f08c2e28SDong Aisheng 478f08c2e28SDong Aisheng int __must_check devm_clk_bulk_get_all(struct device *dev, 479f08c2e28SDong Aisheng struct clk_bulk_data **clks); 480618aee02SDong Aisheng 481618aee02SDong Aisheng /** 482a8a97db9SMark Brown * devm_clk_get - lookup and obtain a managed reference to a clock producer. 483a8a97db9SMark Brown * @dev: device for clock "consumer" 484a58b3a4aSJan-Simon Möller * @id: clock consumer ID 485a8a97db9SMark Brown * 486af89cd45SUwe Kleine-König * Context: May sleep. 487af89cd45SUwe Kleine-König * 488af89cd45SUwe Kleine-König * Return: a struct clk corresponding to the clock producer, or 489a8a97db9SMark Brown * valid IS_ERR() condition containing errno. The implementation 490a8a97db9SMark Brown * uses @dev and @id to determine the clock consumer, and thereby 491a8a97db9SMark Brown * the clock producer. (IOW, @id may be identical strings, but 492a8a97db9SMark Brown * clk_get may return different clock producers depending on @dev.) 493a8a97db9SMark Brown * 494af89cd45SUwe Kleine-König * Drivers must assume that the clock source is neither prepared nor 495af89cd45SUwe Kleine-König * enabled. 496a8a97db9SMark Brown * 497a8a97db9SMark Brown * The clock will automatically be freed when the device is unbound 498a8a97db9SMark Brown * from the bus. 499a8a97db9SMark Brown */ 500a8a97db9SMark Brown struct clk *devm_clk_get(struct device *dev, const char *id); 501a8a97db9SMark Brown 502a8a97db9SMark Brown /** 5037ef9651eSUwe Kleine-König * devm_clk_get_prepared - devm_clk_get() + clk_prepare() 5047ef9651eSUwe Kleine-König * @dev: device for clock "consumer" 5057ef9651eSUwe Kleine-König * @id: clock consumer ID 5067ef9651eSUwe Kleine-König * 5077ef9651eSUwe Kleine-König * Context: May sleep. 5087ef9651eSUwe Kleine-König * 5097ef9651eSUwe Kleine-König * Return: a struct clk corresponding to the clock producer, or 5107ef9651eSUwe Kleine-König * valid IS_ERR() condition containing errno. The implementation 5117ef9651eSUwe Kleine-König * uses @dev and @id to determine the clock consumer, and thereby 5127ef9651eSUwe Kleine-König * the clock producer. (IOW, @id may be identical strings, but 5137ef9651eSUwe Kleine-König * clk_get may return different clock producers depending on @dev.) 5147ef9651eSUwe Kleine-König * 5157ef9651eSUwe Kleine-König * The returned clk (if valid) is prepared. Drivers must however assume 5167ef9651eSUwe Kleine-König * that the clock is not enabled. 5177ef9651eSUwe Kleine-König * 5187ef9651eSUwe Kleine-König * The clock will automatically be unprepared and freed when the device 5197ef9651eSUwe Kleine-König * is unbound from the bus. 5207ef9651eSUwe Kleine-König */ 5217ef9651eSUwe Kleine-König struct clk *devm_clk_get_prepared(struct device *dev, const char *id); 5227ef9651eSUwe Kleine-König 5237ef9651eSUwe Kleine-König /** 5247ef9651eSUwe Kleine-König * devm_clk_get_enabled - devm_clk_get() + clk_prepare_enable() 5257ef9651eSUwe Kleine-König * @dev: device for clock "consumer" 5267ef9651eSUwe Kleine-König * @id: clock consumer ID 5277ef9651eSUwe Kleine-König * 5287ef9651eSUwe Kleine-König * Context: May sleep. 5297ef9651eSUwe Kleine-König * 5307ef9651eSUwe Kleine-König * Return: a struct clk corresponding to the clock producer, or 5317ef9651eSUwe Kleine-König * valid IS_ERR() condition containing errno. The implementation 5327ef9651eSUwe Kleine-König * uses @dev and @id to determine the clock consumer, and thereby 5337ef9651eSUwe Kleine-König * the clock producer. (IOW, @id may be identical strings, but 5347ef9651eSUwe Kleine-König * clk_get may return different clock producers depending on @dev.) 5357ef9651eSUwe Kleine-König * 5367ef9651eSUwe Kleine-König * The returned clk (if valid) is prepared and enabled. 5377ef9651eSUwe Kleine-König * 5387ef9651eSUwe Kleine-König * The clock will automatically be disabled, unprepared and freed 5397ef9651eSUwe Kleine-König * when the device is unbound from the bus. 5407ef9651eSUwe Kleine-König */ 5417ef9651eSUwe Kleine-König struct clk *devm_clk_get_enabled(struct device *dev, const char *id); 5427ef9651eSUwe Kleine-König 5437ef9651eSUwe Kleine-König /** 54460b8f0ddSPhil Edworthy * devm_clk_get_optional - lookup and obtain a managed reference to an optional 54560b8f0ddSPhil Edworthy * clock producer. 54660b8f0ddSPhil Edworthy * @dev: device for clock "consumer" 54760b8f0ddSPhil Edworthy * @id: clock consumer ID 54860b8f0ddSPhil Edworthy * 549af89cd45SUwe Kleine-König * Context: May sleep. 550af89cd45SUwe Kleine-König * 551af89cd45SUwe Kleine-König * Return: a struct clk corresponding to the clock producer, or 552af89cd45SUwe Kleine-König * valid IS_ERR() condition containing errno. The implementation 553af89cd45SUwe Kleine-König * uses @dev and @id to determine the clock consumer, and thereby 554af89cd45SUwe Kleine-König * the clock producer. If no such clk is found, it returns NULL 555af89cd45SUwe Kleine-König * which serves as a dummy clk. That's the only difference compared 556af89cd45SUwe Kleine-König * to devm_clk_get(). 557af89cd45SUwe Kleine-König * 558af89cd45SUwe Kleine-König * Drivers must assume that the clock source is neither prepared nor 559af89cd45SUwe Kleine-König * enabled. 560af89cd45SUwe Kleine-König * 561af89cd45SUwe Kleine-König * The clock will automatically be freed when the device is unbound 562af89cd45SUwe Kleine-König * from the bus. 56360b8f0ddSPhil Edworthy */ 56460b8f0ddSPhil Edworthy struct clk *devm_clk_get_optional(struct device *dev, const char *id); 56560b8f0ddSPhil Edworthy 56660b8f0ddSPhil Edworthy /** 5677ef9651eSUwe Kleine-König * devm_clk_get_optional_prepared - devm_clk_get_optional() + clk_prepare() 5687ef9651eSUwe Kleine-König * @dev: device for clock "consumer" 5697ef9651eSUwe Kleine-König * @id: clock consumer ID 5707ef9651eSUwe Kleine-König * 5717ef9651eSUwe Kleine-König * Context: May sleep. 5727ef9651eSUwe Kleine-König * 5737ef9651eSUwe Kleine-König * Return: a struct clk corresponding to the clock producer, or 5747ef9651eSUwe Kleine-König * valid IS_ERR() condition containing errno. The implementation 5757ef9651eSUwe Kleine-König * uses @dev and @id to determine the clock consumer, and thereby 5767ef9651eSUwe Kleine-König * the clock producer. If no such clk is found, it returns NULL 5777ef9651eSUwe Kleine-König * which serves as a dummy clk. That's the only difference compared 5787ef9651eSUwe Kleine-König * to devm_clk_get_prepared(). 5797ef9651eSUwe Kleine-König * 5807ef9651eSUwe Kleine-König * The returned clk (if valid) is prepared. Drivers must however 5817ef9651eSUwe Kleine-König * assume that the clock is not enabled. 5827ef9651eSUwe Kleine-König * 5837ef9651eSUwe Kleine-König * The clock will automatically be unprepared and freed when the 5847ef9651eSUwe Kleine-König * device is unbound from the bus. 5857ef9651eSUwe Kleine-König */ 5867ef9651eSUwe Kleine-König struct clk *devm_clk_get_optional_prepared(struct device *dev, const char *id); 5877ef9651eSUwe Kleine-König 5887ef9651eSUwe Kleine-König /** 5897ef9651eSUwe Kleine-König * devm_clk_get_optional_enabled - devm_clk_get_optional() + 5907ef9651eSUwe Kleine-König * clk_prepare_enable() 5917ef9651eSUwe Kleine-König * @dev: device for clock "consumer" 5927ef9651eSUwe Kleine-König * @id: clock consumer ID 5937ef9651eSUwe Kleine-König * 5947ef9651eSUwe Kleine-König * Context: May sleep. 5957ef9651eSUwe Kleine-König * 5967ef9651eSUwe Kleine-König * Return: a struct clk corresponding to the clock producer, or 5977ef9651eSUwe Kleine-König * valid IS_ERR() condition containing errno. The implementation 5987ef9651eSUwe Kleine-König * uses @dev and @id to determine the clock consumer, and thereby 5997ef9651eSUwe Kleine-König * the clock producer. If no such clk is found, it returns NULL 6007ef9651eSUwe Kleine-König * which serves as a dummy clk. That's the only difference compared 6017ef9651eSUwe Kleine-König * to devm_clk_get_enabled(). 6027ef9651eSUwe Kleine-König * 6037ef9651eSUwe Kleine-König * The returned clk (if valid) is prepared and enabled. 6047ef9651eSUwe Kleine-König * 6057ef9651eSUwe Kleine-König * The clock will automatically be disabled, unprepared and freed 6067ef9651eSUwe Kleine-König * when the device is unbound from the bus. 6077ef9651eSUwe Kleine-König */ 6087ef9651eSUwe Kleine-König struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id); 6097ef9651eSUwe Kleine-König 6107ef9651eSUwe Kleine-König /** 61171a2f115SKuninori Morimoto * devm_get_clk_from_child - lookup and obtain a managed reference to a 61271a2f115SKuninori Morimoto * clock producer from child node. 61371a2f115SKuninori Morimoto * @dev: device for clock "consumer" 61471a2f115SKuninori Morimoto * @np: pointer to clock consumer node 61571a2f115SKuninori Morimoto * @con_id: clock consumer ID 61671a2f115SKuninori Morimoto * 61771a2f115SKuninori Morimoto * This function parses the clocks, and uses them to look up the 61871a2f115SKuninori Morimoto * struct clk from the registered list of clock providers by using 61971a2f115SKuninori Morimoto * @np and @con_id 62071a2f115SKuninori Morimoto * 62171a2f115SKuninori Morimoto * The clock will automatically be freed when the device is unbound 62271a2f115SKuninori Morimoto * from the bus. 62371a2f115SKuninori Morimoto */ 62471a2f115SKuninori Morimoto struct clk *devm_get_clk_from_child(struct device *dev, 62571a2f115SKuninori Morimoto struct device_node *np, const char *con_id); 62671a2f115SKuninori Morimoto 62771a2f115SKuninori Morimoto /** 628f8ce2547SRussell King * clk_enable - inform the system when the clock source should be running. 629f8ce2547SRussell King * @clk: clock source 630f8ce2547SRussell King * 631f8ce2547SRussell King * If the clock can not be enabled/disabled, this should return success. 632f8ce2547SRussell King * 63340d3e0f4SRussell King * May be called from atomic contexts. 63440d3e0f4SRussell King * 635f8ce2547SRussell King * Returns success (0) or negative errno. 636f8ce2547SRussell King */ 637f8ce2547SRussell King int clk_enable(struct clk *clk); 638f8ce2547SRussell King 639f8ce2547SRussell King /** 640266e4e9dSDong Aisheng * clk_bulk_enable - inform the system when the set of clks should be running. 641266e4e9dSDong Aisheng * @num_clks: the number of clk_bulk_data 642266e4e9dSDong Aisheng * @clks: the clk_bulk_data table of consumer 643266e4e9dSDong Aisheng * 644266e4e9dSDong Aisheng * May be called from atomic contexts. 645266e4e9dSDong Aisheng * 646266e4e9dSDong Aisheng * Returns success (0) or negative errno. 647266e4e9dSDong Aisheng */ 648266e4e9dSDong Aisheng int __must_check clk_bulk_enable(int num_clks, 649266e4e9dSDong Aisheng const struct clk_bulk_data *clks); 650266e4e9dSDong Aisheng 651266e4e9dSDong Aisheng /** 652f8ce2547SRussell King * clk_disable - inform the system when the clock source is no longer required. 653f8ce2547SRussell King * @clk: clock source 654f8ce2547SRussell King * 655f8ce2547SRussell King * Inform the system that a clock source is no longer required by 656f8ce2547SRussell King * a driver and may be shut down. 657f8ce2547SRussell King * 65840d3e0f4SRussell King * May be called from atomic contexts. 65940d3e0f4SRussell King * 660f8ce2547SRussell King * Implementation detail: if the clock source is shared between 661f8ce2547SRussell King * multiple drivers, clk_enable() calls must be balanced by the 662f8ce2547SRussell King * same number of clk_disable() calls for the clock source to be 663f8ce2547SRussell King * disabled. 664f8ce2547SRussell King */ 665f8ce2547SRussell King void clk_disable(struct clk *clk); 666f8ce2547SRussell King 667f8ce2547SRussell King /** 668266e4e9dSDong Aisheng * clk_bulk_disable - inform the system when the set of clks is no 669266e4e9dSDong Aisheng * longer required. 670266e4e9dSDong Aisheng * @num_clks: the number of clk_bulk_data 671266e4e9dSDong Aisheng * @clks: the clk_bulk_data table of consumer 672266e4e9dSDong Aisheng * 673266e4e9dSDong Aisheng * Inform the system that a set of clks is no longer required by 674266e4e9dSDong Aisheng * a driver and may be shut down. 675266e4e9dSDong Aisheng * 676266e4e9dSDong Aisheng * May be called from atomic contexts. 677266e4e9dSDong Aisheng * 678266e4e9dSDong Aisheng * Implementation detail: if the set of clks is shared between 679266e4e9dSDong Aisheng * multiple drivers, clk_bulk_enable() calls must be balanced by the 680266e4e9dSDong Aisheng * same number of clk_bulk_disable() calls for the clock source to be 681266e4e9dSDong Aisheng * disabled. 682266e4e9dSDong Aisheng */ 683266e4e9dSDong Aisheng void clk_bulk_disable(int num_clks, const struct clk_bulk_data *clks); 684266e4e9dSDong Aisheng 685266e4e9dSDong Aisheng /** 686f8ce2547SRussell King * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. 687f8ce2547SRussell King * This is only valid once the clock source has been enabled. 688f8ce2547SRussell King * @clk: clock source 689f8ce2547SRussell King */ 690f8ce2547SRussell King unsigned long clk_get_rate(struct clk *clk); 691f8ce2547SRussell King 692f8ce2547SRussell King /** 693f8ce2547SRussell King * clk_put - "free" the clock source 694f8ce2547SRussell King * @clk: clock source 695f8ce2547SRussell King * 696f8ce2547SRussell King * Note: drivers must ensure that all clk_enable calls made on this 697f8ce2547SRussell King * clock source are balanced by clk_disable calls prior to calling 698f8ce2547SRussell King * this function. 699f7ad160bSAlex Raimondi * 700f7ad160bSAlex Raimondi * clk_put should not be called from within interrupt context. 701f8ce2547SRussell King */ 702f8ce2547SRussell King void clk_put(struct clk *clk); 703f8ce2547SRussell King 704a8a97db9SMark Brown /** 705266e4e9dSDong Aisheng * clk_bulk_put - "free" the clock source 706266e4e9dSDong Aisheng * @num_clks: the number of clk_bulk_data 707266e4e9dSDong Aisheng * @clks: the clk_bulk_data table of consumer 708266e4e9dSDong Aisheng * 709266e4e9dSDong Aisheng * Note: drivers must ensure that all clk_bulk_enable calls made on this 710266e4e9dSDong Aisheng * clock source are balanced by clk_bulk_disable calls prior to calling 711266e4e9dSDong Aisheng * this function. 712266e4e9dSDong Aisheng * 713266e4e9dSDong Aisheng * clk_bulk_put should not be called from within interrupt context. 714266e4e9dSDong Aisheng */ 715266e4e9dSDong Aisheng void clk_bulk_put(int num_clks, struct clk_bulk_data *clks); 716266e4e9dSDong Aisheng 717266e4e9dSDong Aisheng /** 718616e45dfSDong Aisheng * clk_bulk_put_all - "free" all the clock source 719616e45dfSDong Aisheng * @num_clks: the number of clk_bulk_data 720616e45dfSDong Aisheng * @clks: the clk_bulk_data table of consumer 721616e45dfSDong Aisheng * 722616e45dfSDong Aisheng * Note: drivers must ensure that all clk_bulk_enable calls made on this 723616e45dfSDong Aisheng * clock source are balanced by clk_bulk_disable calls prior to calling 724616e45dfSDong Aisheng * this function. 725616e45dfSDong Aisheng * 726616e45dfSDong Aisheng * clk_bulk_put_all should not be called from within interrupt context. 727616e45dfSDong Aisheng */ 728616e45dfSDong Aisheng void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks); 729616e45dfSDong Aisheng 730616e45dfSDong Aisheng /** 731a8a97db9SMark Brown * devm_clk_put - "free" a managed clock source 732da3dae54SMasanari Iida * @dev: device used to acquire the clock 733a8a97db9SMark Brown * @clk: clock source acquired with devm_clk_get() 734a8a97db9SMark Brown * 735a8a97db9SMark Brown * Note: drivers must ensure that all clk_enable calls made on this 736a8a97db9SMark Brown * clock source are balanced by clk_disable calls prior to calling 737a8a97db9SMark Brown * this function. 738a8a97db9SMark Brown * 739a8a97db9SMark Brown * clk_put should not be called from within interrupt context. 740a8a97db9SMark Brown */ 741a8a97db9SMark Brown void devm_clk_put(struct device *dev, struct clk *clk); 742f8ce2547SRussell King 743f8ce2547SRussell King /* 744f8ce2547SRussell King * The remaining APIs are optional for machine class support. 745f8ce2547SRussell King */ 746f8ce2547SRussell King 747f8ce2547SRussell King 748f8ce2547SRussell King /** 749f8ce2547SRussell King * clk_round_rate - adjust a rate to the exact rate a clock can provide 750f8ce2547SRussell King * @clk: clock source 751f8ce2547SRussell King * @rate: desired clock rate in Hz 752f8ce2547SRussell King * 753d2d14a77SRussell King * This answers the question "if I were to pass @rate to clk_set_rate(), 754d2d14a77SRussell King * what clock rate would I end up with?" without changing the hardware 755d2d14a77SRussell King * in any way. In other words: 756d2d14a77SRussell King * 757d2d14a77SRussell King * rate = clk_round_rate(clk, r); 758d2d14a77SRussell King * 759d2d14a77SRussell King * and: 760d2d14a77SRussell King * 761d2d14a77SRussell King * clk_set_rate(clk, r); 762d2d14a77SRussell King * rate = clk_get_rate(clk); 763d2d14a77SRussell King * 764d2d14a77SRussell King * are equivalent except the former does not modify the clock hardware 765d2d14a77SRussell King * in any way. 766d2d14a77SRussell King * 767f8ce2547SRussell King * Returns rounded clock rate in Hz, or negative errno. 768f8ce2547SRussell King */ 769f8ce2547SRussell King long clk_round_rate(struct clk *clk, unsigned long rate); 770f8ce2547SRussell King 771f8ce2547SRussell King /** 772f8ce2547SRussell King * clk_set_rate - set the clock rate for a clock source 773f8ce2547SRussell King * @clk: clock source 774f8ce2547SRussell King * @rate: desired clock rate in Hz 775f8ce2547SRussell King * 77664c76b31SMartin Blumenstingl * Updating the rate starts at the top-most affected clock and then 77764c76b31SMartin Blumenstingl * walks the tree down to the bottom-most clock that needs updating. 77864c76b31SMartin Blumenstingl * 779f8ce2547SRussell King * Returns success (0) or negative errno. 780f8ce2547SRussell King */ 781f8ce2547SRussell King int clk_set_rate(struct clk *clk, unsigned long rate); 782f8ce2547SRussell King 783f8ce2547SRussell King /** 78455e9b8b7SJerome Brunet * clk_set_rate_exclusive- set the clock rate and claim exclusivity over 78555e9b8b7SJerome Brunet * clock source 78655e9b8b7SJerome Brunet * @clk: clock source 78755e9b8b7SJerome Brunet * @rate: desired clock rate in Hz 78855e9b8b7SJerome Brunet * 78955e9b8b7SJerome Brunet * This helper function allows drivers to atomically set the rate of a producer 79055e9b8b7SJerome Brunet * and claim exclusivity over the rate control of the producer. 79155e9b8b7SJerome Brunet * 79255e9b8b7SJerome Brunet * It is essentially a combination of clk_set_rate() and 79355e9b8b7SJerome Brunet * clk_rate_exclusite_get(). Caller must balance this call with a call to 79455e9b8b7SJerome Brunet * clk_rate_exclusive_put() 79555e9b8b7SJerome Brunet * 79655e9b8b7SJerome Brunet * Returns success (0) or negative errno. 79755e9b8b7SJerome Brunet */ 79855e9b8b7SJerome Brunet int clk_set_rate_exclusive(struct clk *clk, unsigned long rate); 79955e9b8b7SJerome Brunet 80055e9b8b7SJerome Brunet /** 8014e88f3deSThierry Reding * clk_has_parent - check if a clock is a possible parent for another 8024e88f3deSThierry Reding * @clk: clock source 8034e88f3deSThierry Reding * @parent: parent clock source 8044e88f3deSThierry Reding * 8054e88f3deSThierry Reding * This function can be used in drivers that need to check that a clock can be 8064e88f3deSThierry Reding * the parent of another without actually changing the parent. 8074e88f3deSThierry Reding * 8084e88f3deSThierry Reding * Returns true if @parent is a possible parent for @clk, false otherwise. 8094e88f3deSThierry Reding */ 81022fb0e28SMaxime Ripard bool clk_has_parent(const struct clk *clk, const struct clk *parent); 8114e88f3deSThierry Reding 8124e88f3deSThierry Reding /** 8131c8e6004STomeu Vizoso * clk_set_rate_range - set a rate range for a clock source 8141c8e6004STomeu Vizoso * @clk: clock source 8151c8e6004STomeu Vizoso * @min: desired minimum clock rate in Hz, inclusive 8161c8e6004STomeu Vizoso * @max: desired maximum clock rate in Hz, inclusive 8171c8e6004STomeu Vizoso * 8181c8e6004STomeu Vizoso * Returns success (0) or negative errno. 8191c8e6004STomeu Vizoso */ 8201c8e6004STomeu Vizoso int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max); 8211c8e6004STomeu Vizoso 8221c8e6004STomeu Vizoso /** 8231c8e6004STomeu Vizoso * clk_set_min_rate - set a minimum clock rate for a clock source 8241c8e6004STomeu Vizoso * @clk: clock source 8251c8e6004STomeu Vizoso * @rate: desired minimum clock rate in Hz, inclusive 8261c8e6004STomeu Vizoso * 8271c8e6004STomeu Vizoso * Returns success (0) or negative errno. 8281c8e6004STomeu Vizoso */ 8291c8e6004STomeu Vizoso int clk_set_min_rate(struct clk *clk, unsigned long rate); 8301c8e6004STomeu Vizoso 8311c8e6004STomeu Vizoso /** 8321c8e6004STomeu Vizoso * clk_set_max_rate - set a maximum clock rate for a clock source 8331c8e6004STomeu Vizoso * @clk: clock source 8341c8e6004STomeu Vizoso * @rate: desired maximum clock rate in Hz, inclusive 8351c8e6004STomeu Vizoso * 8361c8e6004STomeu Vizoso * Returns success (0) or negative errno. 8371c8e6004STomeu Vizoso */ 8381c8e6004STomeu Vizoso int clk_set_max_rate(struct clk *clk, unsigned long rate); 8391c8e6004STomeu Vizoso 8401c8e6004STomeu Vizoso /** 841f8ce2547SRussell King * clk_set_parent - set the parent clock source for this clock 842f8ce2547SRussell King * @clk: clock source 843f8ce2547SRussell King * @parent: parent clock source 844f8ce2547SRussell King * 845f8ce2547SRussell King * Returns success (0) or negative errno. 846f8ce2547SRussell King */ 847f8ce2547SRussell King int clk_set_parent(struct clk *clk, struct clk *parent); 848f8ce2547SRussell King 849f8ce2547SRussell King /** 850f8ce2547SRussell King * clk_get_parent - get the parent clock source for this clock 851f8ce2547SRussell King * @clk: clock source 852f8ce2547SRussell King * 853f8ce2547SRussell King * Returns struct clk corresponding to parent clock source, or 854f8ce2547SRussell King * valid IS_ERR() condition containing errno. 855f8ce2547SRussell King */ 856f8ce2547SRussell King struct clk *clk_get_parent(struct clk *clk); 857f8ce2547SRussell King 85805fd8e73SSascha Hauer /** 85905fd8e73SSascha Hauer * clk_get_sys - get a clock based upon the device name 86005fd8e73SSascha Hauer * @dev_id: device name 86105fd8e73SSascha Hauer * @con_id: connection ID 86205fd8e73SSascha Hauer * 86305fd8e73SSascha Hauer * Returns a struct clk corresponding to the clock producer, or 86405fd8e73SSascha Hauer * valid IS_ERR() condition containing errno. The implementation 86505fd8e73SSascha Hauer * uses @dev_id and @con_id to determine the clock consumer, and 86605fd8e73SSascha Hauer * thereby the clock producer. In contrast to clk_get() this function 86705fd8e73SSascha Hauer * takes the device name instead of the device itself for identification. 86805fd8e73SSascha Hauer * 86905fd8e73SSascha Hauer * Drivers must assume that the clock source is not enabled. 87005fd8e73SSascha Hauer * 87105fd8e73SSascha Hauer * clk_get_sys should not be called from within interrupt context. 87205fd8e73SSascha Hauer */ 87305fd8e73SSascha Hauer struct clk *clk_get_sys(const char *dev_id, const char *con_id); 87405fd8e73SSascha Hauer 8758b95d1ceSRuss Dill /** 8768b95d1ceSRuss Dill * clk_save_context - save clock context for poweroff 8778b95d1ceSRuss Dill * 8788b95d1ceSRuss Dill * Saves the context of the clock register for powerstates in which the 8798b95d1ceSRuss Dill * contents of the registers will be lost. Occurs deep within the suspend 8808b95d1ceSRuss Dill * code so locking is not necessary. 8818b95d1ceSRuss Dill */ 8828b95d1ceSRuss Dill int clk_save_context(void); 8838b95d1ceSRuss Dill 8848b95d1ceSRuss Dill /** 8858b95d1ceSRuss Dill * clk_restore_context - restore clock context after poweroff 8868b95d1ceSRuss Dill * 8878b95d1ceSRuss Dill * This occurs with all clocks enabled. Occurs deep within the resume code 8888b95d1ceSRuss Dill * so locking is not necessary. 8898b95d1ceSRuss Dill */ 8908b95d1ceSRuss Dill void clk_restore_context(void); 8918b95d1ceSRuss Dill 89293abe8e4SViresh Kumar #else /* !CONFIG_HAVE_CLK */ 89393abe8e4SViresh Kumar 89493abe8e4SViresh Kumar static inline struct clk *clk_get(struct device *dev, const char *id) 89593abe8e4SViresh Kumar { 89693abe8e4SViresh Kumar return NULL; 89793abe8e4SViresh Kumar } 89893abe8e4SViresh Kumar 8996e0d4ff4SDong Aisheng static inline int __must_check clk_bulk_get(struct device *dev, int num_clks, 900266e4e9dSDong Aisheng struct clk_bulk_data *clks) 901266e4e9dSDong Aisheng { 902266e4e9dSDong Aisheng return 0; 903266e4e9dSDong Aisheng } 904266e4e9dSDong Aisheng 9052f25528eSSylwester Nawrocki static inline int __must_check clk_bulk_get_optional(struct device *dev, 9062f25528eSSylwester Nawrocki int num_clks, struct clk_bulk_data *clks) 9072f25528eSSylwester Nawrocki { 9082f25528eSSylwester Nawrocki return 0; 9092f25528eSSylwester Nawrocki } 9102f25528eSSylwester Nawrocki 911616e45dfSDong Aisheng static inline int __must_check clk_bulk_get_all(struct device *dev, 912616e45dfSDong Aisheng struct clk_bulk_data **clks) 913616e45dfSDong Aisheng { 914616e45dfSDong Aisheng return 0; 915616e45dfSDong Aisheng } 916616e45dfSDong Aisheng 91793abe8e4SViresh Kumar static inline struct clk *devm_clk_get(struct device *dev, const char *id) 91893abe8e4SViresh Kumar { 91993abe8e4SViresh Kumar return NULL; 92093abe8e4SViresh Kumar } 92193abe8e4SViresh Kumar 9227ef9651eSUwe Kleine-König static inline struct clk *devm_clk_get_prepared(struct device *dev, 9237ef9651eSUwe Kleine-König const char *id) 9247ef9651eSUwe Kleine-König { 9257ef9651eSUwe Kleine-König return NULL; 9267ef9651eSUwe Kleine-König } 9277ef9651eSUwe Kleine-König 9287ef9651eSUwe Kleine-König static inline struct clk *devm_clk_get_enabled(struct device *dev, 9297ef9651eSUwe Kleine-König const char *id) 9307ef9651eSUwe Kleine-König { 9317ef9651eSUwe Kleine-König return NULL; 9327ef9651eSUwe Kleine-König } 9337ef9651eSUwe Kleine-König 93460b8f0ddSPhil Edworthy static inline struct clk *devm_clk_get_optional(struct device *dev, 93560b8f0ddSPhil Edworthy const char *id) 93660b8f0ddSPhil Edworthy { 93760b8f0ddSPhil Edworthy return NULL; 93860b8f0ddSPhil Edworthy } 93960b8f0ddSPhil Edworthy 9407ef9651eSUwe Kleine-König static inline struct clk *devm_clk_get_optional_prepared(struct device *dev, 9417ef9651eSUwe Kleine-König const char *id) 9427ef9651eSUwe Kleine-König { 9437ef9651eSUwe Kleine-König return NULL; 9447ef9651eSUwe Kleine-König } 9457ef9651eSUwe Kleine-König 9467ef9651eSUwe Kleine-König static inline struct clk *devm_clk_get_optional_enabled(struct device *dev, 9477ef9651eSUwe Kleine-König const char *id) 9487ef9651eSUwe Kleine-König { 9497ef9651eSUwe Kleine-König return NULL; 9507ef9651eSUwe Kleine-König } 9517ef9651eSUwe Kleine-König 9526e0d4ff4SDong Aisheng static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, 953618aee02SDong Aisheng struct clk_bulk_data *clks) 954618aee02SDong Aisheng { 955618aee02SDong Aisheng return 0; 956618aee02SDong Aisheng } 957618aee02SDong Aisheng 9589bd5ef0bSSylwester Nawrocki static inline int __must_check devm_clk_bulk_get_optional(struct device *dev, 9599bd5ef0bSSylwester Nawrocki int num_clks, struct clk_bulk_data *clks) 9609bd5ef0bSSylwester Nawrocki { 9619bd5ef0bSSylwester Nawrocki return 0; 9629bd5ef0bSSylwester Nawrocki } 9639bd5ef0bSSylwester Nawrocki 964f08c2e28SDong Aisheng static inline int __must_check devm_clk_bulk_get_all(struct device *dev, 965f08c2e28SDong Aisheng struct clk_bulk_data **clks) 966f08c2e28SDong Aisheng { 967f08c2e28SDong Aisheng 968f08c2e28SDong Aisheng return 0; 969f08c2e28SDong Aisheng } 970f08c2e28SDong Aisheng 97171a2f115SKuninori Morimoto static inline struct clk *devm_get_clk_from_child(struct device *dev, 97271a2f115SKuninori Morimoto struct device_node *np, const char *con_id) 97371a2f115SKuninori Morimoto { 97471a2f115SKuninori Morimoto return NULL; 97571a2f115SKuninori Morimoto } 97671a2f115SKuninori Morimoto 97793abe8e4SViresh Kumar static inline void clk_put(struct clk *clk) {} 97893abe8e4SViresh Kumar 979266e4e9dSDong Aisheng static inline void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) {} 980266e4e9dSDong Aisheng 981616e45dfSDong Aisheng static inline void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) {} 982616e45dfSDong Aisheng 98393abe8e4SViresh Kumar static inline void devm_clk_put(struct device *dev, struct clk *clk) {} 98493abe8e4SViresh Kumar 98593abe8e4SViresh Kumar static inline int clk_enable(struct clk *clk) 98693abe8e4SViresh Kumar { 98793abe8e4SViresh Kumar return 0; 98893abe8e4SViresh Kumar } 98993abe8e4SViresh Kumar 990570aaec7SAndrey Smirnov static inline int __must_check clk_bulk_enable(int num_clks, 991570aaec7SAndrey Smirnov const struct clk_bulk_data *clks) 992266e4e9dSDong Aisheng { 993266e4e9dSDong Aisheng return 0; 994266e4e9dSDong Aisheng } 995266e4e9dSDong Aisheng 99693abe8e4SViresh Kumar static inline void clk_disable(struct clk *clk) {} 99793abe8e4SViresh Kumar 998266e4e9dSDong Aisheng 999266e4e9dSDong Aisheng static inline void clk_bulk_disable(int num_clks, 1000570aaec7SAndrey Smirnov const struct clk_bulk_data *clks) {} 1001266e4e9dSDong Aisheng 100293abe8e4SViresh Kumar static inline unsigned long clk_get_rate(struct clk *clk) 100393abe8e4SViresh Kumar { 100493abe8e4SViresh Kumar return 0; 100593abe8e4SViresh Kumar } 100693abe8e4SViresh Kumar 100793abe8e4SViresh Kumar static inline int clk_set_rate(struct clk *clk, unsigned long rate) 100893abe8e4SViresh Kumar { 100993abe8e4SViresh Kumar return 0; 101093abe8e4SViresh Kumar } 101193abe8e4SViresh Kumar 101255e9b8b7SJerome Brunet static inline int clk_set_rate_exclusive(struct clk *clk, unsigned long rate) 101355e9b8b7SJerome Brunet { 101455e9b8b7SJerome Brunet return 0; 101555e9b8b7SJerome Brunet } 101655e9b8b7SJerome Brunet 101793abe8e4SViresh Kumar static inline long clk_round_rate(struct clk *clk, unsigned long rate) 101893abe8e4SViresh Kumar { 101993abe8e4SViresh Kumar return 0; 102093abe8e4SViresh Kumar } 102193abe8e4SViresh Kumar 10224e88f3deSThierry Reding static inline bool clk_has_parent(struct clk *clk, struct clk *parent) 10234e88f3deSThierry Reding { 10244e88f3deSThierry Reding return true; 10254e88f3deSThierry Reding } 10264e88f3deSThierry Reding 1027b88c9f41SDmitry Osipenko static inline int clk_set_rate_range(struct clk *clk, unsigned long min, 1028b88c9f41SDmitry Osipenko unsigned long max) 1029b88c9f41SDmitry Osipenko { 1030b88c9f41SDmitry Osipenko return 0; 1031b88c9f41SDmitry Osipenko } 1032b88c9f41SDmitry Osipenko 1033b88c9f41SDmitry Osipenko static inline int clk_set_min_rate(struct clk *clk, unsigned long rate) 1034b88c9f41SDmitry Osipenko { 1035b88c9f41SDmitry Osipenko return 0; 1036b88c9f41SDmitry Osipenko } 1037b88c9f41SDmitry Osipenko 1038b88c9f41SDmitry Osipenko static inline int clk_set_max_rate(struct clk *clk, unsigned long rate) 1039b88c9f41SDmitry Osipenko { 1040b88c9f41SDmitry Osipenko return 0; 1041b88c9f41SDmitry Osipenko } 1042b88c9f41SDmitry Osipenko 104393abe8e4SViresh Kumar static inline int clk_set_parent(struct clk *clk, struct clk *parent) 104493abe8e4SViresh Kumar { 104593abe8e4SViresh Kumar return 0; 104693abe8e4SViresh Kumar } 104793abe8e4SViresh Kumar 104893abe8e4SViresh Kumar static inline struct clk *clk_get_parent(struct clk *clk) 104993abe8e4SViresh Kumar { 105093abe8e4SViresh Kumar return NULL; 105193abe8e4SViresh Kumar } 105293abe8e4SViresh Kumar 1053b81ea968SDaniel Lezcano static inline struct clk *clk_get_sys(const char *dev_id, const char *con_id) 1054b81ea968SDaniel Lezcano { 1055b81ea968SDaniel Lezcano return NULL; 1056b81ea968SDaniel Lezcano } 10578b95d1ceSRuss Dill 10588b95d1ceSRuss Dill static inline int clk_save_context(void) 10598b95d1ceSRuss Dill { 10608b95d1ceSRuss Dill return 0; 10618b95d1ceSRuss Dill } 10628b95d1ceSRuss Dill 10638b95d1ceSRuss Dill static inline void clk_restore_context(void) {} 10648b95d1ceSRuss Dill 106593abe8e4SViresh Kumar #endif 106693abe8e4SViresh Kumar 106793abe8e4SViresh Kumar /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ 106893abe8e4SViresh Kumar static inline int clk_prepare_enable(struct clk *clk) 106993abe8e4SViresh Kumar { 107093abe8e4SViresh Kumar int ret; 107193abe8e4SViresh Kumar 107293abe8e4SViresh Kumar ret = clk_prepare(clk); 107393abe8e4SViresh Kumar if (ret) 107493abe8e4SViresh Kumar return ret; 107593abe8e4SViresh Kumar ret = clk_enable(clk); 107693abe8e4SViresh Kumar if (ret) 107793abe8e4SViresh Kumar clk_unprepare(clk); 107893abe8e4SViresh Kumar 107993abe8e4SViresh Kumar return ret; 108093abe8e4SViresh Kumar } 108193abe8e4SViresh Kumar 108293abe8e4SViresh Kumar /* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */ 108393abe8e4SViresh Kumar static inline void clk_disable_unprepare(struct clk *clk) 108493abe8e4SViresh Kumar { 108593abe8e4SViresh Kumar clk_disable(clk); 108693abe8e4SViresh Kumar clk_unprepare(clk); 108793abe8e4SViresh Kumar } 108893abe8e4SViresh Kumar 1089570aaec7SAndrey Smirnov static inline int __must_check 1090570aaec7SAndrey Smirnov clk_bulk_prepare_enable(int num_clks, const struct clk_bulk_data *clks) 10913c48d86cSBjorn Andersson { 10923c48d86cSBjorn Andersson int ret; 10933c48d86cSBjorn Andersson 10943c48d86cSBjorn Andersson ret = clk_bulk_prepare(num_clks, clks); 10953c48d86cSBjorn Andersson if (ret) 10963c48d86cSBjorn Andersson return ret; 10973c48d86cSBjorn Andersson ret = clk_bulk_enable(num_clks, clks); 10983c48d86cSBjorn Andersson if (ret) 10993c48d86cSBjorn Andersson clk_bulk_unprepare(num_clks, clks); 11003c48d86cSBjorn Andersson 11013c48d86cSBjorn Andersson return ret; 11023c48d86cSBjorn Andersson } 11033c48d86cSBjorn Andersson 11043c48d86cSBjorn Andersson static inline void clk_bulk_disable_unprepare(int num_clks, 1105570aaec7SAndrey Smirnov const struct clk_bulk_data *clks) 11063c48d86cSBjorn Andersson { 11073c48d86cSBjorn Andersson clk_bulk_disable(num_clks, clks); 11083c48d86cSBjorn Andersson clk_bulk_unprepare(num_clks, clks); 11093c48d86cSBjorn Andersson } 11103c48d86cSBjorn Andersson 111160b8f0ddSPhil Edworthy /** 1112c9744843SMaxime Ripard * clk_drop_range - Reset any range set on that clock 1113c9744843SMaxime Ripard * @clk: clock source 1114c9744843SMaxime Ripard * 1115c9744843SMaxime Ripard * Returns success (0) or negative errno. 1116c9744843SMaxime Ripard */ 1117c9744843SMaxime Ripard static inline int clk_drop_range(struct clk *clk) 1118c9744843SMaxime Ripard { 1119c9744843SMaxime Ripard return clk_set_rate_range(clk, 0, ULONG_MAX); 1120c9744843SMaxime Ripard } 1121c9744843SMaxime Ripard 1122c9744843SMaxime Ripard /** 112360b8f0ddSPhil Edworthy * clk_get_optional - lookup and obtain a reference to an optional clock 112460b8f0ddSPhil Edworthy * producer. 112560b8f0ddSPhil Edworthy * @dev: device for clock "consumer" 112660b8f0ddSPhil Edworthy * @id: clock consumer ID 112760b8f0ddSPhil Edworthy * 112860b8f0ddSPhil Edworthy * Behaves the same as clk_get() except where there is no clock producer. In 112960b8f0ddSPhil Edworthy * this case, instead of returning -ENOENT, the function returns NULL. 113060b8f0ddSPhil Edworthy */ 113160b8f0ddSPhil Edworthy static inline struct clk *clk_get_optional(struct device *dev, const char *id) 113260b8f0ddSPhil Edworthy { 113360b8f0ddSPhil Edworthy struct clk *clk = clk_get(dev, id); 113460b8f0ddSPhil Edworthy 113560b8f0ddSPhil Edworthy if (clk == ERR_PTR(-ENOENT)) 113660b8f0ddSPhil Edworthy return NULL; 113760b8f0ddSPhil Edworthy 113860b8f0ddSPhil Edworthy return clk; 113960b8f0ddSPhil Edworthy } 114060b8f0ddSPhil Edworthy 1141137f8a72SRob Herring #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) 1142766e6a4eSGrant Likely struct clk *of_clk_get(struct device_node *np, int index); 1143766e6a4eSGrant Likely struct clk *of_clk_get_by_name(struct device_node *np, const char *name); 1144766e6a4eSGrant Likely struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); 1145766e6a4eSGrant Likely #else 1146766e6a4eSGrant Likely static inline struct clk *of_clk_get(struct device_node *np, int index) 1147766e6a4eSGrant Likely { 11489f1612d3SShawn Guo return ERR_PTR(-ENOENT); 1149766e6a4eSGrant Likely } 1150766e6a4eSGrant Likely static inline struct clk *of_clk_get_by_name(struct device_node *np, 1151766e6a4eSGrant Likely const char *name) 1152766e6a4eSGrant Likely { 11539f1612d3SShawn Guo return ERR_PTR(-ENOENT); 1154766e6a4eSGrant Likely } 1155428c9de5SGeert Uytterhoeven static inline struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) 1156428c9de5SGeert Uytterhoeven { 1157428c9de5SGeert Uytterhoeven return ERR_PTR(-ENOENT); 1158428c9de5SGeert Uytterhoeven } 1159766e6a4eSGrant Likely #endif 1160766e6a4eSGrant Likely 1161f8ce2547SRussell King #endif 1162