| .. | .. |
|---|
| 183 | 183 | */ |
|---|
| 184 | 184 | bool clk_is_match(const struct clk *p, const struct clk *q); |
|---|
| 185 | 185 | |
|---|
| 186 | +/** |
|---|
| 187 | + * clk_rate_exclusive_get - get exclusivity over the rate control of a |
|---|
| 188 | + * producer |
|---|
| 189 | + * @clk: clock source |
|---|
| 190 | + * |
|---|
| 191 | + * This function allows drivers to get exclusive control over the rate of a |
|---|
| 192 | + * provider. It prevents any other consumer to execute, even indirectly, |
|---|
| 193 | + * opereation which could alter the rate of the provider or cause glitches |
|---|
| 194 | + * |
|---|
| 195 | + * If exlusivity is claimed more than once on clock, even by the same driver, |
|---|
| 196 | + * the rate effectively gets locked as exclusivity can't be preempted. |
|---|
| 197 | + * |
|---|
| 198 | + * Must not be called from within atomic context. |
|---|
| 199 | + * |
|---|
| 200 | + * Returns success (0) or negative errno. |
|---|
| 201 | + */ |
|---|
| 202 | +int clk_rate_exclusive_get(struct clk *clk); |
|---|
| 203 | + |
|---|
| 204 | +/** |
|---|
| 205 | + * clk_rate_exclusive_put - release exclusivity over the rate control of a |
|---|
| 206 | + * producer |
|---|
| 207 | + * @clk: clock source |
|---|
| 208 | + * |
|---|
| 209 | + * This function allows drivers to release the exclusivity it previously got |
|---|
| 210 | + * from clk_rate_exclusive_get() |
|---|
| 211 | + * |
|---|
| 212 | + * The caller must balance the number of clk_rate_exclusive_get() and |
|---|
| 213 | + * clk_rate_exclusive_put() calls. |
|---|
| 214 | + * |
|---|
| 215 | + * Must not be called from within atomic context. |
|---|
| 216 | + */ |
|---|
| 217 | +void clk_rate_exclusive_put(struct clk *clk); |
|---|
| 218 | + |
|---|
| 186 | 219 | #else |
|---|
| 187 | 220 | |
|---|
| 188 | 221 | static inline int clk_notifier_register(struct clk *clk, |
|---|
| .. | .. |
|---|
| 235 | 268 | { |
|---|
| 236 | 269 | return p == q; |
|---|
| 237 | 270 | } |
|---|
| 271 | + |
|---|
| 272 | +static inline int clk_rate_exclusive_get(struct clk *clk) |
|---|
| 273 | +{ |
|---|
| 274 | + return 0; |
|---|
| 275 | +} |
|---|
| 276 | + |
|---|
| 277 | +static inline void clk_rate_exclusive_put(struct clk *clk) {} |
|---|
| 238 | 278 | |
|---|
| 239 | 279 | #endif |
|---|
| 240 | 280 | |
|---|
| .. | .. |
|---|
| 437 | 477 | struct clk *devm_clk_get(struct device *dev, const char *id); |
|---|
| 438 | 478 | |
|---|
| 439 | 479 | /** |
|---|
| 480 | + * devm_clk_get_prepared - devm_clk_get() + clk_prepare() |
|---|
| 481 | + * @dev: device for clock "consumer" |
|---|
| 482 | + * @id: clock consumer ID |
|---|
| 483 | + * |
|---|
| 484 | + * Context: May sleep. |
|---|
| 485 | + * |
|---|
| 486 | + * Return: a struct clk corresponding to the clock producer, or |
|---|
| 487 | + * valid IS_ERR() condition containing errno. The implementation |
|---|
| 488 | + * uses @dev and @id to determine the clock consumer, and thereby |
|---|
| 489 | + * the clock producer. (IOW, @id may be identical strings, but |
|---|
| 490 | + * clk_get may return different clock producers depending on @dev.) |
|---|
| 491 | + * |
|---|
| 492 | + * The returned clk (if valid) is prepared. Drivers must however assume |
|---|
| 493 | + * that the clock is not enabled. |
|---|
| 494 | + * |
|---|
| 495 | + * The clock will automatically be unprepared and freed when the device |
|---|
| 496 | + * is unbound from the bus. |
|---|
| 497 | + */ |
|---|
| 498 | +struct clk *devm_clk_get_prepared(struct device *dev, const char *id); |
|---|
| 499 | + |
|---|
| 500 | +/** |
|---|
| 501 | + * devm_clk_get_enabled - devm_clk_get() + clk_prepare_enable() |
|---|
| 502 | + * @dev: device for clock "consumer" |
|---|
| 503 | + * @id: clock consumer ID |
|---|
| 504 | + * |
|---|
| 505 | + * Context: May sleep. |
|---|
| 506 | + * |
|---|
| 507 | + * Return: a struct clk corresponding to the clock producer, or |
|---|
| 508 | + * valid IS_ERR() condition containing errno. The implementation |
|---|
| 509 | + * uses @dev and @id to determine the clock consumer, and thereby |
|---|
| 510 | + * the clock producer. (IOW, @id may be identical strings, but |
|---|
| 511 | + * clk_get may return different clock producers depending on @dev.) |
|---|
| 512 | + * |
|---|
| 513 | + * The returned clk (if valid) is prepared and enabled. |
|---|
| 514 | + * |
|---|
| 515 | + * The clock will automatically be disabled, unprepared and freed |
|---|
| 516 | + * when the device is unbound from the bus. |
|---|
| 517 | + */ |
|---|
| 518 | +struct clk *devm_clk_get_enabled(struct device *dev, const char *id); |
|---|
| 519 | + |
|---|
| 520 | +/** |
|---|
| 440 | 521 | * devm_clk_get_optional - lookup and obtain a managed reference to an optional |
|---|
| 441 | 522 | * clock producer. |
|---|
| 442 | 523 | * @dev: device for clock "consumer" |
|---|
| .. | .. |
|---|
| 446 | 527 | * In this case, instead of returning -ENOENT, the function returns NULL. |
|---|
| 447 | 528 | */ |
|---|
| 448 | 529 | struct clk *devm_clk_get_optional(struct device *dev, const char *id); |
|---|
| 530 | + |
|---|
| 531 | +/** |
|---|
| 532 | + * devm_clk_get_optional_prepared - devm_clk_get_optional() + clk_prepare() |
|---|
| 533 | + * @dev: device for clock "consumer" |
|---|
| 534 | + * @id: clock consumer ID |
|---|
| 535 | + * |
|---|
| 536 | + * Context: May sleep. |
|---|
| 537 | + * |
|---|
| 538 | + * Return: a struct clk corresponding to the clock producer, or |
|---|
| 539 | + * valid IS_ERR() condition containing errno. The implementation |
|---|
| 540 | + * uses @dev and @id to determine the clock consumer, and thereby |
|---|
| 541 | + * the clock producer. If no such clk is found, it returns NULL |
|---|
| 542 | + * which serves as a dummy clk. That's the only difference compared |
|---|
| 543 | + * to devm_clk_get_prepared(). |
|---|
| 544 | + * |
|---|
| 545 | + * The returned clk (if valid) is prepared. Drivers must however |
|---|
| 546 | + * assume that the clock is not enabled. |
|---|
| 547 | + * |
|---|
| 548 | + * The clock will automatically be unprepared and freed when the |
|---|
| 549 | + * device is unbound from the bus. |
|---|
| 550 | + */ |
|---|
| 551 | +struct clk *devm_clk_get_optional_prepared(struct device *dev, const char *id); |
|---|
| 552 | + |
|---|
| 553 | +/** |
|---|
| 554 | + * devm_clk_get_optional_enabled - devm_clk_get_optional() + |
|---|
| 555 | + * clk_prepare_enable() |
|---|
| 556 | + * @dev: device for clock "consumer" |
|---|
| 557 | + * @id: clock consumer ID |
|---|
| 558 | + * |
|---|
| 559 | + * Context: May sleep. |
|---|
| 560 | + * |
|---|
| 561 | + * Return: a struct clk corresponding to the clock producer, or |
|---|
| 562 | + * valid IS_ERR() condition containing errno. The implementation |
|---|
| 563 | + * uses @dev and @id to determine the clock consumer, and thereby |
|---|
| 564 | + * the clock producer. If no such clk is found, it returns NULL |
|---|
| 565 | + * which serves as a dummy clk. That's the only difference compared |
|---|
| 566 | + * to devm_clk_get_enabled(). |
|---|
| 567 | + * |
|---|
| 568 | + * The returned clk (if valid) is prepared and enabled. |
|---|
| 569 | + * |
|---|
| 570 | + * The clock will automatically be disabled, unprepared and freed |
|---|
| 571 | + * when the device is unbound from the bus. |
|---|
| 572 | + */ |
|---|
| 573 | +struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id); |
|---|
| 449 | 574 | |
|---|
| 450 | 575 | /** |
|---|
| 451 | 576 | * devm_get_clk_from_child - lookup and obtain a managed reference to a |
|---|
| .. | .. |
|---|
| 463 | 588 | */ |
|---|
| 464 | 589 | struct clk *devm_get_clk_from_child(struct device *dev, |
|---|
| 465 | 590 | struct device_node *np, const char *con_id); |
|---|
| 466 | | -/** |
|---|
| 467 | | - * clk_rate_exclusive_get - get exclusivity over the rate control of a |
|---|
| 468 | | - * producer |
|---|
| 469 | | - * @clk: clock source |
|---|
| 470 | | - * |
|---|
| 471 | | - * This function allows drivers to get exclusive control over the rate of a |
|---|
| 472 | | - * provider. It prevents any other consumer to execute, even indirectly, |
|---|
| 473 | | - * opereation which could alter the rate of the provider or cause glitches |
|---|
| 474 | | - * |
|---|
| 475 | | - * If exlusivity is claimed more than once on clock, even by the same driver, |
|---|
| 476 | | - * the rate effectively gets locked as exclusivity can't be preempted. |
|---|
| 477 | | - * |
|---|
| 478 | | - * Must not be called from within atomic context. |
|---|
| 479 | | - * |
|---|
| 480 | | - * Returns success (0) or negative errno. |
|---|
| 481 | | - */ |
|---|
| 482 | | -int clk_rate_exclusive_get(struct clk *clk); |
|---|
| 483 | | - |
|---|
| 484 | | -/** |
|---|
| 485 | | - * clk_rate_exclusive_put - release exclusivity over the rate control of a |
|---|
| 486 | | - * producer |
|---|
| 487 | | - * @clk: clock source |
|---|
| 488 | | - * |
|---|
| 489 | | - * This function allows drivers to release the exclusivity it previously got |
|---|
| 490 | | - * from clk_rate_exclusive_get() |
|---|
| 491 | | - * |
|---|
| 492 | | - * The caller must balance the number of clk_rate_exclusive_get() and |
|---|
| 493 | | - * clk_rate_exclusive_put() calls. |
|---|
| 494 | | - * |
|---|
| 495 | | - * Must not be called from within atomic context. |
|---|
| 496 | | - */ |
|---|
| 497 | | -void clk_rate_exclusive_put(struct clk *clk); |
|---|
| 498 | 591 | |
|---|
| 499 | 592 | /** |
|---|
| 500 | 593 | * clk_enable - inform the system when the clock source should be running. |
|---|
| .. | .. |
|---|
| 791 | 884 | return NULL; |
|---|
| 792 | 885 | } |
|---|
| 793 | 886 | |
|---|
| 887 | +static inline struct clk *devm_clk_get_prepared(struct device *dev, |
|---|
| 888 | + const char *id) |
|---|
| 889 | +{ |
|---|
| 890 | + return NULL; |
|---|
| 891 | +} |
|---|
| 892 | + |
|---|
| 893 | +static inline struct clk *devm_clk_get_enabled(struct device *dev, |
|---|
| 894 | + const char *id) |
|---|
| 895 | +{ |
|---|
| 896 | + return NULL; |
|---|
| 897 | +} |
|---|
| 898 | + |
|---|
| 794 | 899 | static inline struct clk *devm_clk_get_optional(struct device *dev, |
|---|
| 795 | 900 | const char *id) |
|---|
| 901 | +{ |
|---|
| 902 | + return NULL; |
|---|
| 903 | +} |
|---|
| 904 | + |
|---|
| 905 | +static inline struct clk *devm_clk_get_optional_prepared(struct device *dev, |
|---|
| 906 | + const char *id) |
|---|
| 907 | +{ |
|---|
| 908 | + return NULL; |
|---|
| 909 | +} |
|---|
| 910 | + |
|---|
| 911 | +static inline struct clk *devm_clk_get_optional_enabled(struct device *dev, |
|---|
| 912 | + const char *id) |
|---|
| 796 | 913 | { |
|---|
| 797 | 914 | return NULL; |
|---|
| 798 | 915 | } |
|---|
| .. | .. |
|---|
| 829 | 946 | static inline void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) {} |
|---|
| 830 | 947 | |
|---|
| 831 | 948 | static inline void devm_clk_put(struct device *dev, struct clk *clk) {} |
|---|
| 832 | | - |
|---|
| 833 | | - |
|---|
| 834 | | -static inline int clk_rate_exclusive_get(struct clk *clk) |
|---|
| 835 | | -{ |
|---|
| 836 | | - return 0; |
|---|
| 837 | | -} |
|---|
| 838 | | - |
|---|
| 839 | | -static inline void clk_rate_exclusive_put(struct clk *clk) {} |
|---|
| 840 | 949 | |
|---|
| 841 | 950 | static inline int clk_enable(struct clk *clk) |
|---|
| 842 | 951 | { |
|---|