clk.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2015 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. * Copyright (c) 2016, NVIDIA CORPORATION.
  6. */
  7. #ifndef _CLK_H_
  8. #define _CLK_H_
  9. #include <dm/ofnode.h>
  10. #include <linux/err.h>
  11. #include <linux/errno.h>
  12. #include <linux/types.h>
  13. /**
  14. * DOC: Overview
  15. *
  16. * A clock is a hardware signal that oscillates autonomously at a specific
  17. * frequency and duty cycle. Most hardware modules require one or more clock
  18. * signal to drive their operation. Clock signals are typically generated
  19. * externally to the HW module consuming them, by an entity this API calls a
  20. * clock provider. This API provides a standard means for drivers to enable and
  21. * disable clocks, and to set the rate at which they oscillate.
  22. *
  23. * A driver that implements UCLASS_CLK is a clock provider. A provider will
  24. * often implement multiple separate clocks, since the hardware it manages
  25. * often has this capability. clk-uclass.h describes the interface which
  26. * clock providers must implement.
  27. *
  28. * Clock consumers/clients are the HW modules driven by the clock signals. This
  29. * header file describes the API used by drivers for those HW modules.
  30. */
  31. struct udevice;
  32. /**
  33. * struct clk - A handle to (allowing control of) a single clock.
  34. * @dev: The device which implements the clock signal.
  35. * @rate: The clock rate (in HZ).
  36. * @flags: Flags used across common clock structure (e.g. %CLK_)
  37. * Clock IP blocks specific flags (i.e. mux, div, gate, etc) are defined
  38. * in struct's for those devices (e.g. &struct clk_mux).
  39. * @enable_count: The number of times this clock has been enabled.
  40. * @id: The clock signal ID within the provider.
  41. * @data: An optional data field for scenarios where a single integer ID is not
  42. * sufficient. If used, it can be populated through an .of_xlate op and
  43. * processed during the various clock ops.
  44. *
  45. * Clients provide storage for clock handles. The content of the structure is
  46. * managed solely by the clock API and clock drivers. A clock struct is
  47. * initialized by "get"ing the clock struct. The clock struct is passed to all
  48. * other clock APIs to identify which clock signal to operate upon.
  49. *
  50. * Should additional information to identify and configure any clock signal
  51. * for any provider be required in the future, the struct could be expanded to
  52. * either (a) add more fields to allow clock providers to store additional
  53. * information, or (b) replace the id field with an opaque pointer, which the
  54. * provider would dynamically allocated during its .of_xlate op, and process
  55. * during is .request op. This may require the addition of an extra op to clean
  56. * up the allocation.
  57. */
  58. struct clk {
  59. struct udevice *dev;
  60. long long rate; /* in HZ */
  61. u32 flags;
  62. int enable_count;
  63. /*
  64. * Written by of_xlate. In the future, we might add more fields here.
  65. */
  66. unsigned long id;
  67. unsigned long data;
  68. };
  69. /**
  70. * struct clk_bulk - A handle to (allowing control of) a bulk of clocks.
  71. * @clks: An array of clock handles.
  72. * @count: The number of clock handles in the clks array.
  73. *
  74. * Clients provide storage for the clock bulk. The content of the structure is
  75. * managed solely by the clock API. A clock bulk struct is
  76. * initialized by "get"ing the clock bulk struct.
  77. * The clock bulk struct is passed to all other bulk clock APIs to apply
  78. * the API to all the clock in the bulk struct.
  79. */
  80. struct clk_bulk {
  81. struct clk *clks;
  82. unsigned int count;
  83. };
  84. struct phandle_1_arg;
  85. #if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(CLK)
  86. /**
  87. * clk_get_by_phandle() - Get a clock by its phandle information (of-platadata)
  88. * @dev: Device containing the phandle
  89. * @cells: Phandle info
  90. * @clk: A pointer to a clock struct to initialise
  91. *
  92. * This function is used when of-platdata is enabled.
  93. *
  94. * This looks up a clock using the phandle info. With dtoc, each phandle in the
  95. * 'clocks' property is transformed into an idx representing the device.
  96. * For example::
  97. *
  98. * clocks = <&dpll_mpu_ck 23>;
  99. *
  100. * might result in::
  101. *
  102. * .clocks = {1, {23}},},
  103. *
  104. * indicating that the clock is udevice idx 1 in dt-plat.c with an argument of
  105. * 23. This function can return a valid clock given the above information. In
  106. * this example it would return a clock containing the 'dpll_mpu_ck' device and
  107. * the clock ID 23.
  108. *
  109. * Return: 0 if OK, or a negative error code.
  110. */
  111. int clk_get_by_phandle(struct udevice *dev, const struct phandle_1_arg *cells,
  112. struct clk *clk);
  113. /**
  114. * clk_get_by_index() - Get/request a clock by integer index.
  115. * @dev: The client device.
  116. * @index: The index of the clock to request, within the client's list of
  117. * clocks.
  118. * @clk: A pointer to a clock struct to initialize.
  119. *
  120. * This looks up and requests a clock. The index is relative to the client
  121. * device; each device is assumed to have n clocks associated with it somehow,
  122. * and this function finds and requests one of them. The mapping of client
  123. * device clock indices to provider clocks may be via device-tree properties,
  124. * board-provided mapping tables, or some other mechanism.
  125. *
  126. * Return: 0 if OK, or a negative error code.
  127. */
  128. int clk_get_by_index(struct udevice *dev, int index, struct clk *clk);
  129. /**
  130. * clk_get_by_index_nodev() - Get/request a clock by integer index without a
  131. * device.
  132. * @node: The client ofnode.
  133. * @index: The index of the clock to request, within the client's list of
  134. * clocks.
  135. * @clk: A pointer to a clock struct to initialize.
  136. *
  137. * Return: 0 if OK, or a negative error code.
  138. */
  139. int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk);
  140. /**
  141. * clk_get_bulk() - Get/request all clocks of a device.
  142. * @dev: The client device.
  143. * @bulk: A pointer to a clock bulk struct to initialize.
  144. *
  145. * This looks up and requests all clocks of the client device; each device is
  146. * assumed to have n clocks associated with it somehow, and this function finds
  147. * and requests all of them in a separate structure. The mapping of client
  148. * device clock indices to provider clocks may be via device-tree properties,
  149. * board-provided mapping tables, or some other mechanism.
  150. *
  151. * Return: 0 if OK, or a negative error code.
  152. */
  153. int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk);
  154. /**
  155. * clk_get_by_name() - Get/request a clock by name.
  156. * @dev: The client device.
  157. * @name: The name of the clock to request, within the client's list of
  158. * clocks, or NULL to request the first clock in the list.
  159. * @clk: A pointer to a clock struct to initialize.
  160. *
  161. * This looks up and requests a clock. The name is relative to the client
  162. * device; each device is assumed to have n clocks associated with it somehow,
  163. * and this function finds and requests one of them. The mapping of client
  164. * device clock names to provider clocks may be via device-tree properties,
  165. * board-provided mapping tables, or some other mechanism.
  166. *
  167. * Return: 0 if OK, or a negative error code.
  168. */
  169. int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk);
  170. /**
  171. * clk_get_by_name_nodev - Get/request a clock by name without a device.
  172. * @node: The client ofnode.
  173. * @name: The name of the clock to request, within the client's list of
  174. * clocks, or NULL to request the first clock in the list.
  175. * @clk: A pointer to a clock struct to initialize.
  176. *
  177. * Return: 0 if OK, or a negative error code.
  178. */
  179. int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk);
  180. /**
  181. * devm_clk_get() - lookup and obtain a managed reference to a clock producer.
  182. * @dev: device for clock "consumer"
  183. * @id: clock consumer ID
  184. *
  185. * The implementation uses @dev and @id to determine the clock consumer, and
  186. * thereby the clock producer. (IOW, @id may be identical strings, but clk_get
  187. * may return different clock producers depending on @dev.)
  188. *
  189. * Drivers must assume that the clock source is not enabled.
  190. *
  191. * The clock will automatically be freed when the device is unbound
  192. * from the bus.
  193. *
  194. * Return:
  195. * a struct clk corresponding to the clock producer, or
  196. * valid IS_ERR() condition containing errno
  197. */
  198. struct clk *devm_clk_get(struct udevice *dev, const char *id);
  199. /**
  200. * devm_clk_get_optional() - lookup and obtain a managed reference to an
  201. * optional clock producer.
  202. * @dev: device for clock "consumer"
  203. * @id: clock consumer ID
  204. *
  205. * Behaves the same as devm_clk_get() except where there is no clock producer.
  206. * In this case, instead of returning -%ENOENT, the function returns NULL.
  207. */
  208. static inline struct clk *devm_clk_get_optional(struct udevice *dev,
  209. const char *id)
  210. {
  211. struct clk *clk = devm_clk_get(dev, id);
  212. if (PTR_ERR(clk) == -ENODATA)
  213. return NULL;
  214. return clk;
  215. }
  216. /**
  217. * clk_release_all() - Disable (turn off)/Free an array of previously
  218. * requested clocks.
  219. * @clk: A clock struct array that was previously successfully
  220. * requested by clk_request/get_by_*().
  221. * @count: Number of clock contained in the array
  222. *
  223. * For each clock contained in the clock array, this function will check if
  224. * clock has been previously requested and then will disable and free it.
  225. *
  226. * Return: zero on success, or -ve error code.
  227. */
  228. int clk_release_all(struct clk *clk, int count);
  229. /**
  230. * devm_clk_put - "free" a managed clock source
  231. * @dev: device used to acquire the clock
  232. * @clk: clock source acquired with devm_clk_get()
  233. *
  234. * Note: drivers must ensure that all clk_enable calls made on this
  235. * clock source are balanced by clk_disable calls prior to calling
  236. * this function.
  237. *
  238. * clk_put should not be called from within interrupt context.
  239. */
  240. void devm_clk_put(struct udevice *dev, struct clk *clk);
  241. #else
  242. static inline int clk_get_by_phandle(struct udevice *dev, const
  243. struct phandle_1_arg *cells,
  244. struct clk *clk)
  245. {
  246. return -ENOSYS;
  247. }
  248. static inline int clk_get_by_index(struct udevice *dev, int index,
  249. struct clk *clk)
  250. {
  251. return -ENOSYS;
  252. }
  253. static inline int clk_get_by_index_nodev(ofnode node, int index,
  254. struct clk *clk)
  255. {
  256. return -ENOSYS;
  257. }
  258. static inline int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
  259. {
  260. return -ENOSYS;
  261. }
  262. static inline int clk_get_by_name(struct udevice *dev, const char *name,
  263. struct clk *clk)
  264. {
  265. return -ENOSYS;
  266. }
  267. static inline struct clk *devm_clk_get(struct udevice *dev, const char *id)
  268. {
  269. return ERR_PTR(-ENOSYS);
  270. }
  271. static inline struct clk *devm_clk_get_optional(struct udevice *dev,
  272. const char *id)
  273. {
  274. return ERR_PTR(-ENOSYS);
  275. }
  276. static inline int
  277. clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
  278. {
  279. return -ENOSYS;
  280. }
  281. static inline int clk_release_all(struct clk *clk, int count)
  282. {
  283. return -ENOSYS;
  284. }
  285. static inline void devm_clk_put(struct udevice *dev, struct clk *clk)
  286. {
  287. }
  288. #endif
  289. /**
  290. * clk_get_by_name_optional() - Get/request a optional clock by name.
  291. * @dev: The client device.
  292. * @name: The name of the clock to request, within the client's list of
  293. * clocks.
  294. * @clk: A pointer to a clock struct to initialize.
  295. *
  296. * Behaves the same as clk_get_by_name(), except when there is no clock
  297. * provider. In the latter case, return 0.
  298. *
  299. * Return: 0 if OK, or a negative error code.
  300. */
  301. static inline int clk_get_by_name_optional(struct udevice *dev,
  302. const char *name, struct clk *clk)
  303. {
  304. int ret;
  305. ret = clk_get_by_name(dev, name, clk);
  306. if (ret == -ENODATA)
  307. return 0;
  308. return ret;
  309. }
  310. /**
  311. * clk_get_by_name_nodev_optional - Get/request an optinonal clock by name
  312. * without a device.
  313. * @node: The client ofnode.
  314. * @name: The name of the clock to request, within the client's list of
  315. * clocks.
  316. * @clk: A pointer to a clock struct to initialize.
  317. *
  318. * Behaves the same as clk_get_by_name_nodev() except where there is
  319. * no clock producer, in this case, skip the error number -%ENODATA, and
  320. * the function returns 0.
  321. */
  322. static inline int clk_get_by_name_nodev_optional(ofnode node, const char *name,
  323. struct clk *clk)
  324. {
  325. int ret;
  326. ret = clk_get_by_name_nodev(node, name, clk);
  327. if (ret == -ENODATA)
  328. return 0;
  329. return ret;
  330. }
  331. /**
  332. * enum clk_defaults_stage - What stage clk_set_defaults() is called at
  333. * @CLK_DEFAULTS_PRE: Called before probe. Setting of defaults for clocks owned
  334. * by this clock driver will be defered until after probing.
  335. * @CLK_DEFAULTS_POST: Called after probe. Only defaults for clocks owned by
  336. * this clock driver will be set.
  337. * @CLK_DEFAULTS_POST_FORCE: Called after probe, and always set defaults, even
  338. * before relocation. Usually, defaults are not set
  339. * pre-relocation to avoid setting them twice (when
  340. * the device is probed again post-relocation). This
  341. * may incur a performance cost as device tree
  342. * properties must be parsed for a second time.
  343. * However, when not using SPL, pre-relocation may be
  344. * the only time we can set defaults for some clocks
  345. * (such as those used for the RAM we will relocate
  346. * into).
  347. */
  348. enum clk_defaults_stage {
  349. CLK_DEFAULTS_PRE = 0,
  350. CLK_DEFAULTS_POST = 1,
  351. CLK_DEFAULTS_POST_FORCE,
  352. };
  353. #if CONFIG_IS_ENABLED(OF_REAL) && CONFIG_IS_ENABLED(CLK)
  354. /**
  355. * clk_set_defaults - Process ``assigned-{clocks/clock-parents/clock-rates}``
  356. * properties to configure clocks
  357. * @dev: A device to process (the ofnode associated with this device
  358. * will be processed).
  359. * @stage: The stage of the probing process this function is called during.
  360. *
  361. * Return: zero on success, or -ve error code.
  362. */
  363. int clk_set_defaults(struct udevice *dev, enum clk_defaults_stage stage);
  364. #else
  365. static inline int clk_set_defaults(struct udevice *dev, int stage)
  366. {
  367. return 0;
  368. }
  369. #endif
  370. /**
  371. * clk_release_bulk() - Disable (turn off)/Free an array of previously
  372. * requested clocks in a clock bulk struct.
  373. * @bulk: A clock bulk struct that was previously successfully
  374. * requested by clk_get_bulk().
  375. *
  376. * For each clock contained in the clock bulk struct, this function will check
  377. * if clock has been previously requested and then will disable and free it.
  378. *
  379. * Return: zero on success, or -ve error code.
  380. */
  381. static inline int clk_release_bulk(struct clk_bulk *bulk)
  382. {
  383. return clk_release_all(bulk->clks, bulk->count);
  384. }
  385. #if CONFIG_IS_ENABLED(CLK)
  386. /**
  387. * clk_request() - Request a clock by provider-specific ID.
  388. * @dev: The clock provider device.
  389. * @clk: A pointer to a clock struct to initialize. The caller must
  390. * have already initialized any field in this struct which the
  391. * clock provider uses to identify the clock.
  392. *
  393. * This requests a clock using a provider-specific ID. Generally, this function
  394. * should not be used, since clk_get_by_index/name() provide an interface that
  395. * better separates clients from intimate knowledge of clock providers.
  396. * However, this function may be useful in core SoC-specific code.
  397. *
  398. * Return: 0 if OK, or a negative error code.
  399. */
  400. int clk_request(struct udevice *dev, struct clk *clk);
  401. /**
  402. * clk_free() - Free a previously requested clock.
  403. * @clk: A clock struct that was previously successfully requested by
  404. * clk_request/get_by_*().
  405. *
  406. * Free resources allocated by clk_request() (or any clk_get_* function).
  407. */
  408. void clk_free(struct clk *clk);
  409. /**
  410. * clk_get_rate() - Get current clock rate.
  411. * @clk: A clock struct that was previously successfully requested by
  412. * clk_request/get_by_*().
  413. *
  414. * Return: clock rate in Hz on success, 0 for invalid clock, or -ve error code
  415. * for other errors.
  416. */
  417. ulong clk_get_rate(struct clk *clk);
  418. /**
  419. * clk_get_parent() - Get current clock's parent.
  420. * @clk: A clock struct that was previously successfully requested by
  421. * clk_request/get_by_*().
  422. *
  423. * Return: pointer to parent's struct clk, or error code passed as pointer
  424. */
  425. struct clk *clk_get_parent(struct clk *clk);
  426. /**
  427. * clk_get_parent_rate() - Get parent of current clock rate.
  428. * @clk: A clock struct that was previously successfully requested by
  429. * clk_request/get_by_*().
  430. *
  431. * Return: clock rate in Hz, or -ve error code.
  432. */
  433. ulong clk_get_parent_rate(struct clk *clk);
  434. /**
  435. * clk_round_rate() - Adjust a rate to the exact rate a clock can provide
  436. * @clk: A clock struct that was previously successfully requested by
  437. * clk_request/get_by_*().
  438. * @rate: desired clock rate in Hz.
  439. *
  440. * This answers the question "if I were to pass @rate to clk_set_rate(),
  441. * what clock rate would I end up with?" without changing the hardware
  442. * in any way. In other words::
  443. *
  444. * rate = clk_round_rate(clk, r);
  445. *
  446. * and::
  447. *
  448. * rate = clk_set_rate(clk, r);
  449. *
  450. * are equivalent except the former does not modify the clock hardware
  451. * in any way.
  452. *
  453. * Return: rounded rate in Hz, or -ve error code.
  454. */
  455. ulong clk_round_rate(struct clk *clk, ulong rate);
  456. /**
  457. * clk_set_rate() - Set current clock rate.
  458. * @clk: A clock struct that was previously successfully requested by
  459. * clk_request/get_by_*().
  460. * @rate: New clock rate in Hz.
  461. *
  462. * Return: new rate, or -ve error code.
  463. */
  464. ulong clk_set_rate(struct clk *clk, ulong rate);
  465. /**
  466. * clk_set_parent() - Set current clock parent.
  467. * @clk: A clock struct that was previously successfully requested by
  468. * clk_request/get_by_*().
  469. * @parent: A clock struct that was previously successfully requested by
  470. * clk_request/get_by_*().
  471. *
  472. * Return: new rate, or -ve error code.
  473. */
  474. int clk_set_parent(struct clk *clk, struct clk *parent);
  475. /**
  476. * clk_enable() - Enable (turn on) a clock.
  477. * @clk: A clock struct that was previously successfully requested by
  478. * clk_request/get_by_*().
  479. *
  480. * Return: zero on success, or -ve error code.
  481. */
  482. int clk_enable(struct clk *clk);
  483. /**
  484. * clk_enable_bulk() - Enable (turn on) all clocks in a clock bulk struct.
  485. * @bulk: A clock bulk struct that was previously successfully requested
  486. * by clk_get_bulk().
  487. *
  488. * Return: zero on success, or -ve error code.
  489. */
  490. int clk_enable_bulk(struct clk_bulk *bulk);
  491. /**
  492. * clk_disable() - Disable (turn off) a clock.
  493. * @clk: A clock struct that was previously successfully requested by
  494. * clk_request/get_by_*().
  495. *
  496. * Return: zero on success, or -ve error code.
  497. */
  498. int clk_disable(struct clk *clk);
  499. /**
  500. * clk_disable_bulk() - Disable (turn off) all clocks in a clock bulk struct.
  501. * @bulk: A clock bulk struct that was previously successfully requested
  502. * by clk_get_bulk().
  503. *
  504. * Return: zero on success, or -ve error code.
  505. */
  506. int clk_disable_bulk(struct clk_bulk *bulk);
  507. /**
  508. * clk_is_match - check if two clk's point to the same hardware clock
  509. * @p: clk compared against q
  510. * @q: clk compared against p
  511. *
  512. * Return:
  513. * %true if the two struct clk pointers both point to the same hardware clock
  514. * node, and %false otherwise. Note that two %NULL clks are treated as matching.
  515. */
  516. bool clk_is_match(const struct clk *p, const struct clk *q);
  517. /**
  518. * clk_get_by_id() - Get the clock by its ID
  519. * @id: The clock ID to search for
  520. * @clkp: A pointer to clock struct that has been found among added clocks
  521. * to UCLASS_CLK
  522. *
  523. * Return: zero on success, or -ENOENT on error
  524. */
  525. int clk_get_by_id(ulong id, struct clk **clkp);
  526. /**
  527. * clk_dev_binded() - Check whether the clk has a device binded
  528. * @clk: A pointer to the clk
  529. *
  530. * Return: true on binded, or false on no
  531. */
  532. bool clk_dev_binded(struct clk *clk);
  533. #else /* CONFIG_IS_ENABLED(CLK) */
  534. static inline int clk_request(struct udevice *dev, struct clk *clk)
  535. {
  536. return -ENOSYS;
  537. }
  538. static inline void clk_free(struct clk *clk)
  539. {
  540. return;
  541. }
  542. static inline ulong clk_get_rate(struct clk *clk)
  543. {
  544. return -ENOSYS;
  545. }
  546. static inline struct clk *clk_get_parent(struct clk *clk)
  547. {
  548. return ERR_PTR(-ENOSYS);
  549. }
  550. static inline ulong clk_get_parent_rate(struct clk *clk)
  551. {
  552. return -ENOSYS;
  553. }
  554. static inline ulong clk_round_rate(struct clk *clk, ulong rate)
  555. {
  556. return -ENOSYS;
  557. }
  558. static inline ulong clk_set_rate(struct clk *clk, ulong rate)
  559. {
  560. return -ENOSYS;
  561. }
  562. static inline int clk_set_parent(struct clk *clk, struct clk *parent)
  563. {
  564. return -ENOSYS;
  565. }
  566. static inline int clk_enable(struct clk *clk)
  567. {
  568. return 0;
  569. }
  570. static inline int clk_enable_bulk(struct clk_bulk *bulk)
  571. {
  572. return 0;
  573. }
  574. static inline int clk_disable(struct clk *clk)
  575. {
  576. return 0;
  577. }
  578. static inline int clk_disable_bulk(struct clk_bulk *bulk)
  579. {
  580. return 0;
  581. }
  582. static inline bool clk_is_match(const struct clk *p, const struct clk *q)
  583. {
  584. return false;
  585. }
  586. static inline int clk_get_by_id(ulong id, struct clk **clkp)
  587. {
  588. return -ENOSYS;
  589. }
  590. static inline bool clk_dev_binded(struct clk *clk)
  591. {
  592. return false;
  593. }
  594. #endif /* CONFIG_IS_ENABLED(CLK) */
  595. /**
  596. * clk_valid() - check if clk is valid
  597. * @clk: the clock to check
  598. *
  599. * Return: true if valid, or false
  600. */
  601. static inline bool clk_valid(struct clk *clk)
  602. {
  603. return clk && !!clk->dev;
  604. }
  605. int soc_clk_dump(void);
  606. #endif
  607. #define clk_prepare_enable(clk) clk_enable(clk)
  608. #define clk_disable_unprepare(clk) clk_disable(clk)