at v6.16 20 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Generic OPP Interface 4 * 5 * Copyright (C) 2009-2010 Texas Instruments Incorporated. 6 * Nishanth Menon 7 * Romit Dasgupta 8 * Kevin Hilman 9 */ 10 11#ifndef __LINUX_OPP_H__ 12#define __LINUX_OPP_H__ 13 14#include <linux/cleanup.h> 15#include <linux/energy_model.h> 16#include <linux/err.h> 17#include <linux/notifier.h> 18 19struct clk; 20struct cpufreq_frequency_table; 21struct regulator; 22struct dev_pm_opp; 23struct device; 24struct opp_table; 25 26enum dev_pm_opp_event { 27 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, 28 OPP_EVENT_ADJUST_VOLTAGE, 29}; 30 31/** 32 * struct dev_pm_opp_supply - Power supply voltage/current values 33 * @u_volt: Target voltage in microvolts corresponding to this OPP 34 * @u_volt_min: Minimum voltage in microvolts corresponding to this OPP 35 * @u_volt_max: Maximum voltage in microvolts corresponding to this OPP 36 * @u_amp: Maximum current drawn by the device in microamperes 37 * @u_watt: Power used by the device in microwatts 38 * 39 * This structure stores the voltage/current/power values for a single power 40 * supply. 41 */ 42struct dev_pm_opp_supply { 43 unsigned long u_volt; 44 unsigned long u_volt_min; 45 unsigned long u_volt_max; 46 unsigned long u_amp; 47 unsigned long u_watt; 48}; 49 50typedef int (*config_regulators_t)(struct device *dev, 51 struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, 52 struct regulator **regulators, unsigned int count); 53 54typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table, 55 struct dev_pm_opp *opp, void *data, bool scaling_down); 56 57/** 58 * struct dev_pm_opp_config - Device OPP configuration values 59 * @clk_names: Clk names, NULL terminated array. 60 * @config_clks: Custom set clk helper. 61 * @prop_name: Name to postfix to properties. 62 * @config_regulators: Custom set regulator helper. 63 * @supported_hw: Array of hierarchy of versions to match. 64 * @supported_hw_count: Number of elements in the array. 65 * @regulator_names: Array of pointers to the names of the regulator, NULL terminated. 66 * @required_dev: The required OPP device. 67 * @required_dev_index: The index of the required OPP for the @required_dev. 68 * 69 * This structure contains platform specific OPP configurations for the device. 70 */ 71struct dev_pm_opp_config { 72 /* NULL terminated */ 73 const char * const *clk_names; 74 config_clks_t config_clks; 75 const char *prop_name; 76 config_regulators_t config_regulators; 77 const unsigned int *supported_hw; 78 unsigned int supported_hw_count; 79 const char * const *regulator_names; 80 struct device *required_dev; 81 unsigned int required_dev_index; 82}; 83 84#define OPP_LEVEL_UNSET U32_MAX 85 86/** 87 * struct dev_pm_opp_data - The data to use to initialize an OPP. 88 * @turbo: Flag to indicate whether the OPP is to be marked turbo or not. 89 * @level: The performance level for the OPP. Set level to OPP_LEVEL_UNSET if 90 * level field isn't used. 91 * @freq: The clock rate in Hz for the OPP. 92 * @u_volt: The voltage in uV for the OPP. 93 */ 94struct dev_pm_opp_data { 95 bool turbo; 96 unsigned int level; 97 unsigned long freq; 98 unsigned long u_volt; 99}; 100 101#if defined(CONFIG_PM_OPP) 102 103struct opp_table *dev_pm_opp_get_opp_table(struct device *dev); 104struct opp_table *dev_pm_opp_get_opp_table_ref(struct opp_table *opp_table); 105void dev_pm_opp_put_opp_table(struct opp_table *opp_table); 106 107unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index); 108 109unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); 110 111int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct dev_pm_opp_supply *supplies); 112 113unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp); 114 115unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index); 116 117unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); 118 119unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, 120 unsigned int index); 121 122bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); 123 124int dev_pm_opp_get_opp_count(struct device *dev); 125unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); 126unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev); 127unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev); 128unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev); 129 130struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, 131 unsigned long freq, 132 bool available); 133 134struct dev_pm_opp * 135dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, 136 u32 index, bool available); 137 138struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, 139 unsigned long *freq); 140 141struct dev_pm_opp *dev_pm_opp_find_freq_floor_indexed(struct device *dev, 142 unsigned long *freq, u32 index); 143 144struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, 145 unsigned long *freq); 146 147struct dev_pm_opp *dev_pm_opp_find_freq_ceil_indexed(struct device *dev, 148 unsigned long *freq, u32 index); 149 150struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, 151 unsigned int level); 152 153struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, 154 unsigned int *level); 155 156struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev, 157 unsigned int *level); 158 159struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev, 160 unsigned int *bw, int index); 161 162struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, 163 unsigned int *bw, int index); 164 165struct dev_pm_opp *dev_pm_opp_get(struct dev_pm_opp *opp); 166void dev_pm_opp_put(struct dev_pm_opp *opp); 167 168int dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp); 169 170void dev_pm_opp_remove(struct device *dev, unsigned long freq); 171void dev_pm_opp_remove_all_dynamic(struct device *dev); 172 173int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, 174 unsigned long u_volt, unsigned long u_volt_min, 175 unsigned long u_volt_max); 176 177int dev_pm_opp_enable(struct device *dev, unsigned long freq); 178 179int dev_pm_opp_disable(struct device *dev, unsigned long freq); 180 181int dev_pm_opp_register_notifier(struct device *dev, struct notifier_block *nb); 182int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb); 183 184int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config); 185int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config); 186void dev_pm_opp_clear_config(int token); 187int dev_pm_opp_config_clks_simple(struct device *dev, 188 struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, 189 bool scaling_down); 190 191struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp); 192int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); 193int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); 194int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp); 195int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); 196int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); 197void dev_pm_opp_remove_table(struct device *dev); 198void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); 199int dev_pm_opp_sync_regulators(struct device *dev); 200 201#else 202static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) 203{ 204 return ERR_PTR(-EOPNOTSUPP); 205} 206 207static inline struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *dev, int index) 208{ 209 return ERR_PTR(-EOPNOTSUPP); 210} 211 212static inline struct opp_table *dev_pm_opp_get_opp_table_ref(struct opp_table *opp_table) 213{ 214 return opp_table; 215} 216 217static inline void dev_pm_opp_put_opp_table(struct opp_table *opp_table) {} 218 219static inline unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index) 220{ 221 return 0; 222} 223 224static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) 225{ 226 return 0; 227} 228 229static inline int dev_pm_opp_get_supplies(struct dev_pm_opp *opp, struct dev_pm_opp_supply *supplies) 230{ 231 return -EOPNOTSUPP; 232} 233 234static inline unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp) 235{ 236 return 0; 237} 238 239static inline unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index) 240{ 241 return 0; 242} 243 244static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) 245{ 246 return 0; 247} 248 249static inline 250unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, 251 unsigned int index) 252{ 253 return 0; 254} 255 256static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) 257{ 258 return false; 259} 260 261static inline int dev_pm_opp_get_opp_count(struct device *dev) 262{ 263 return 0; 264} 265 266static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) 267{ 268 return 0; 269} 270 271static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) 272{ 273 return 0; 274} 275 276static inline unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev) 277{ 278 return 0; 279} 280 281static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) 282{ 283 return 0; 284} 285 286static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, 287 unsigned long freq, bool available) 288{ 289 return ERR_PTR(-EOPNOTSUPP); 290} 291 292static inline struct dev_pm_opp * 293dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, 294 u32 index, bool available) 295{ 296 return ERR_PTR(-EOPNOTSUPP); 297} 298 299static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, 300 unsigned long *freq) 301{ 302 return ERR_PTR(-EOPNOTSUPP); 303} 304 305static inline struct dev_pm_opp * 306dev_pm_opp_find_freq_floor_indexed(struct device *dev, unsigned long *freq, u32 index) 307{ 308 return ERR_PTR(-EOPNOTSUPP); 309} 310 311static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, 312 unsigned long *freq) 313{ 314 return ERR_PTR(-EOPNOTSUPP); 315} 316 317static inline struct dev_pm_opp * 318dev_pm_opp_find_freq_ceil_indexed(struct device *dev, unsigned long *freq, u32 index) 319{ 320 return ERR_PTR(-EOPNOTSUPP); 321} 322 323static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, 324 unsigned int level) 325{ 326 return ERR_PTR(-EOPNOTSUPP); 327} 328 329static inline struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, 330 unsigned int *level) 331{ 332 return ERR_PTR(-EOPNOTSUPP); 333} 334 335static inline struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev, 336 unsigned int *level) 337{ 338 return ERR_PTR(-EOPNOTSUPP); 339} 340 341static inline struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev, 342 unsigned int *bw, int index) 343{ 344 return ERR_PTR(-EOPNOTSUPP); 345} 346 347static inline struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, 348 unsigned int *bw, int index) 349{ 350 return ERR_PTR(-EOPNOTSUPP); 351} 352 353static inline struct dev_pm_opp *dev_pm_opp_get(struct dev_pm_opp *opp) 354{ 355 return opp; 356} 357 358static inline void dev_pm_opp_put(struct dev_pm_opp *opp) {} 359 360static inline int 361dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp) 362{ 363 return -EOPNOTSUPP; 364} 365 366static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq) 367{ 368} 369 370static inline void dev_pm_opp_remove_all_dynamic(struct device *dev) 371{ 372} 373 374static inline int 375dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, 376 unsigned long u_volt, unsigned long u_volt_min, 377 unsigned long u_volt_max) 378{ 379 return 0; 380} 381 382static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq) 383{ 384 return 0; 385} 386 387static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq) 388{ 389 return 0; 390} 391 392static inline int dev_pm_opp_register_notifier(struct device *dev, struct notifier_block *nb) 393{ 394 return -EOPNOTSUPP; 395} 396 397static inline int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nb) 398{ 399 return -EOPNOTSUPP; 400} 401 402static inline int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) 403{ 404 return -EOPNOTSUPP; 405} 406 407static inline int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) 408{ 409 return -EOPNOTSUPP; 410} 411 412static inline void dev_pm_opp_clear_config(int token) {} 413 414static inline int dev_pm_opp_config_clks_simple(struct device *dev, 415 struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, 416 bool scaling_down) 417{ 418 return -EOPNOTSUPP; 419} 420 421static inline struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, 422 struct opp_table *dst_table, struct dev_pm_opp *src_opp) 423{ 424 return ERR_PTR(-EOPNOTSUPP); 425} 426 427static inline int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate) 428{ 429 return -EOPNOTSUPP; 430} 431 432static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) 433{ 434 return -EOPNOTSUPP; 435} 436 437static inline int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) 438{ 439 return -EOPNOTSUPP; 440} 441 442static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask) 443{ 444 return -EOPNOTSUPP; 445} 446 447static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) 448{ 449 return -EINVAL; 450} 451 452static inline void dev_pm_opp_remove_table(struct device *dev) 453{ 454} 455 456static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask) 457{ 458} 459 460static inline int dev_pm_opp_sync_regulators(struct device *dev) 461{ 462 return -EOPNOTSUPP; 463} 464 465#endif /* CONFIG_PM_OPP */ 466 467#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) 468int dev_pm_opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table); 469void dev_pm_opp_free_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table); 470#else 471static inline int dev_pm_opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) 472{ 473 return -EINVAL; 474} 475 476static inline void dev_pm_opp_free_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) 477{ 478} 479#endif 480 481 482#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) 483int dev_pm_opp_of_add_table(struct device *dev); 484int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); 485int devm_pm_opp_of_add_table_indexed(struct device *dev, int index); 486void dev_pm_opp_of_remove_table(struct device *dev); 487int devm_pm_opp_of_add_table(struct device *dev); 488int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); 489void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); 490int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); 491struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); 492struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); 493int of_get_required_opp_performance_state(struct device_node *np, int index); 494bool dev_pm_opp_of_has_required_opp(struct device *dev); 495int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table); 496int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus); 497int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW, 498 unsigned long *kHz); 499static inline void dev_pm_opp_of_unregister_em(struct device *dev) 500{ 501 em_dev_unregister_perf_domain(dev); 502} 503#else 504static inline int dev_pm_opp_of_add_table(struct device *dev) 505{ 506 return -EOPNOTSUPP; 507} 508 509static inline int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) 510{ 511 return -EOPNOTSUPP; 512} 513 514static inline int devm_pm_opp_of_add_table_indexed(struct device *dev, int index) 515{ 516 return -EOPNOTSUPP; 517} 518 519static inline void dev_pm_opp_of_remove_table(struct device *dev) 520{ 521} 522 523static inline int devm_pm_opp_of_add_table(struct device *dev) 524{ 525 return -EOPNOTSUPP; 526} 527 528static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) 529{ 530 return -EOPNOTSUPP; 531} 532 533static inline void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask) 534{ 535} 536 537static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) 538{ 539 return -EOPNOTSUPP; 540} 541 542static inline struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev) 543{ 544 return NULL; 545} 546 547static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) 548{ 549 return NULL; 550} 551 552static inline int dev_pm_opp_of_register_em(struct device *dev, 553 struct cpumask *cpus) 554{ 555 return -EOPNOTSUPP; 556} 557 558static inline void dev_pm_opp_of_unregister_em(struct device *dev) 559{ 560} 561 562static inline int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW, 563 unsigned long *kHz) 564{ 565 return -EOPNOTSUPP; 566} 567 568static inline int of_get_required_opp_performance_state(struct device_node *np, int index) 569{ 570 return -EOPNOTSUPP; 571} 572 573static inline bool dev_pm_opp_of_has_required_opp(struct device *dev) 574{ 575 return false; 576} 577 578static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table) 579{ 580 return -EOPNOTSUPP; 581} 582#endif 583 584/* Scope based cleanup macro for OPP reference counting */ 585DEFINE_FREE(put_opp, struct dev_pm_opp *, if (!IS_ERR_OR_NULL(_T)) dev_pm_opp_put(_T)) 586 587/* Scope based cleanup macro for OPP table reference counting */ 588DEFINE_FREE(put_opp_table, struct opp_table *, if (!IS_ERR_OR_NULL(_T)) dev_pm_opp_put_opp_table(_T)) 589 590/* OPP Configuration helpers */ 591 592static inline int dev_pm_opp_add(struct device *dev, unsigned long freq, 593 unsigned long u_volt) 594{ 595 struct dev_pm_opp_data data = { 596 .freq = freq, 597 .u_volt = u_volt, 598 }; 599 600 return dev_pm_opp_add_dynamic(dev, &data); 601} 602 603/* Regulators helpers */ 604static inline int dev_pm_opp_set_regulators(struct device *dev, 605 const char * const names[]) 606{ 607 struct dev_pm_opp_config config = { 608 .regulator_names = names, 609 }; 610 611 return dev_pm_opp_set_config(dev, &config); 612} 613 614static inline void dev_pm_opp_put_regulators(int token) 615{ 616 dev_pm_opp_clear_config(token); 617} 618 619static inline int devm_pm_opp_set_regulators(struct device *dev, 620 const char * const names[]) 621{ 622 struct dev_pm_opp_config config = { 623 .regulator_names = names, 624 }; 625 626 return devm_pm_opp_set_config(dev, &config); 627} 628 629/* Supported-hw helpers */ 630static inline int dev_pm_opp_set_supported_hw(struct device *dev, 631 const u32 *versions, 632 unsigned int count) 633{ 634 struct dev_pm_opp_config config = { 635 .supported_hw = versions, 636 .supported_hw_count = count, 637 }; 638 639 return dev_pm_opp_set_config(dev, &config); 640} 641 642static inline void dev_pm_opp_put_supported_hw(int token) 643{ 644 dev_pm_opp_clear_config(token); 645} 646 647static inline int devm_pm_opp_set_supported_hw(struct device *dev, 648 const u32 *versions, 649 unsigned int count) 650{ 651 struct dev_pm_opp_config config = { 652 .supported_hw = versions, 653 .supported_hw_count = count, 654 }; 655 656 return devm_pm_opp_set_config(dev, &config); 657} 658 659/* clkname helpers */ 660static inline int dev_pm_opp_set_clkname(struct device *dev, const char *name) 661{ 662 const char *names[] = { name, NULL }; 663 struct dev_pm_opp_config config = { 664 .clk_names = names, 665 }; 666 667 return dev_pm_opp_set_config(dev, &config); 668} 669 670static inline void dev_pm_opp_put_clkname(int token) 671{ 672 dev_pm_opp_clear_config(token); 673} 674 675static inline int devm_pm_opp_set_clkname(struct device *dev, const char *name) 676{ 677 const char *names[] = { name, NULL }; 678 struct dev_pm_opp_config config = { 679 .clk_names = names, 680 }; 681 682 return devm_pm_opp_set_config(dev, &config); 683} 684 685/* config-regulators helpers */ 686static inline int dev_pm_opp_set_config_regulators(struct device *dev, 687 config_regulators_t helper) 688{ 689 struct dev_pm_opp_config config = { 690 .config_regulators = helper, 691 }; 692 693 return dev_pm_opp_set_config(dev, &config); 694} 695 696static inline void dev_pm_opp_put_config_regulators(int token) 697{ 698 dev_pm_opp_clear_config(token); 699} 700 701/* prop-name helpers */ 702static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name) 703{ 704 struct dev_pm_opp_config config = { 705 .prop_name = name, 706 }; 707 708 return dev_pm_opp_set_config(dev, &config); 709} 710 711static inline void dev_pm_opp_put_prop_name(int token) 712{ 713 dev_pm_opp_clear_config(token); 714} 715 716static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) 717{ 718 return dev_pm_opp_get_freq_indexed(opp, 0); 719} 720 721static inline int dev_pm_opp_set_level(struct device *dev, unsigned int level) 722{ 723 struct dev_pm_opp *opp __free(put_opp) = dev_pm_opp_find_level_exact(dev, level); 724 725 if (IS_ERR(opp)) 726 return PTR_ERR(opp); 727 728 return dev_pm_opp_set_opp(dev, opp); 729} 730 731#endif /* __LINUX_OPP_H__ */