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