Michael Adisumarta | c06df41 | 2017-09-19 10:10:35 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2017, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _IPA_PM_H_ |
| 14 | #define _IPA_PM_H_ |
| 15 | |
| 16 | #include <linux/msm_ipa.h> |
| 17 | |
| 18 | /* internal to ipa */ |
| 19 | #define IPA_PM_MAX_CLIENTS 10 |
| 20 | #define IPA_PM_MAX_EX_CL 64 |
Michael Adisumarta | b8e7470 | 2017-11-29 20:52:59 -0800 | [diff] [blame] | 21 | #define IPA_PM_THRESHOLD_MAX 5 |
Michael Adisumarta | c06df41 | 2017-09-19 10:10:35 -0700 | [diff] [blame] | 22 | #define IPA_PM_EXCEPTION_MAX 2 |
| 23 | #define IPA_PM_DEFERRED_TIMEOUT 100 |
| 24 | #define IPA_PM_STATE_MAX 7 |
| 25 | |
| 26 | /* |
| 27 | * ipa_pm group names |
| 28 | * |
| 29 | * Default stands for individual clients while other groups share one throughput |
| 30 | * Some groups also have special flags like modem which do not vote for clock |
| 31 | * but is accounted for in clock scaling while activated |
| 32 | */ |
| 33 | enum ipa_pm_group { |
| 34 | IPA_PM_GROUP_DEFAULT, |
| 35 | IPA_PM_GROUP_APPS, |
| 36 | IPA_PM_GROUP_MODEM, |
| 37 | IPA_PM_GROUP_MAX, |
| 38 | }; |
| 39 | |
| 40 | /* |
| 41 | * ipa_pm_cb_event |
| 42 | * |
| 43 | * specifies what kind of callback is being called. |
| 44 | * IPA_PM_CLIENT_ACTIVATED: the client has completed asynchronous activation |
| 45 | * IPA_PM_REQUEST_WAKEUP: wake up the client after it has been suspended |
| 46 | */ |
| 47 | enum ipa_pm_cb_event { |
| 48 | IPA_PM_CLIENT_ACTIVATED, |
| 49 | IPA_PM_REQUEST_WAKEUP, |
| 50 | IPA_PM_CB_EVENT_MAX, |
| 51 | }; |
| 52 | |
| 53 | /* |
| 54 | * struct ipa_pm_exception - clients included in exception and its threshold |
| 55 | * @usecase: comma separated client names |
| 56 | * @threshold: the threshold values for the exception |
| 57 | */ |
| 58 | struct ipa_pm_exception { |
| 59 | const char *usecase; |
| 60 | int threshold[IPA_PM_THRESHOLD_MAX]; |
| 61 | }; |
| 62 | |
| 63 | /* |
| 64 | * struct ipa_pm_init_params - parameters needed for initializng the pm |
| 65 | * @default_threshold: the thresholds used if no exception passes |
| 66 | * @threshold_size: size of the threshold |
| 67 | * @exceptions: list of exceptions for the pm |
| 68 | * @exception_size: size of the exception_list |
| 69 | */ |
| 70 | struct ipa_pm_init_params { |
| 71 | int default_threshold[IPA_PM_THRESHOLD_MAX]; |
| 72 | int threshold_size; |
| 73 | struct ipa_pm_exception exceptions[IPA_PM_EXCEPTION_MAX]; |
| 74 | int exception_size; |
| 75 | }; |
| 76 | |
| 77 | /* |
| 78 | * struct ipa_pm_register_params - parameters needed to register a client |
| 79 | * @name: name of the client |
| 80 | * @callback: pointer to the client's callback function |
| 81 | * @user_data: pointer to the client's callback parameters |
| 82 | * @group: group number of the client |
| 83 | * @skip_clk_vote: 0 if client votes for clock when activated, 1 if no vote |
| 84 | */ |
| 85 | struct ipa_pm_register_params { |
| 86 | const char *name; |
| 87 | void (*callback)(void*, enum ipa_pm_cb_event); |
| 88 | void *user_data; |
| 89 | enum ipa_pm_group group; |
| 90 | bool skip_clk_vote; |
| 91 | }; |
| 92 | |
| 93 | int ipa_pm_register(struct ipa_pm_register_params *params, u32 *hdl); |
| 94 | int ipa_pm_associate_ipa_cons_to_client(u32 hdl, enum ipa_client_type consumer); |
| 95 | int ipa_pm_activate(u32 hdl); |
| 96 | int ipa_pm_activate_sync(u32 hdl); |
| 97 | int ipa_pm_deferred_deactivate(u32 hdl); |
| 98 | int ipa_pm_deactivate_sync(u32 hdl); |
| 99 | int ipa_pm_set_perf_profile(u32 hdl, int throughput); |
| 100 | int ipa_pm_deregister(u32 hdl); |
| 101 | |
| 102 | /* IPA Internal Functions */ |
| 103 | int ipa_pm_init(struct ipa_pm_init_params *params); |
| 104 | int ipa_pm_destroy(void); |
| 105 | int ipa_pm_handle_suspend(u32 pipe_bitmask); |
| 106 | int ipa_pm_deactivate_all_deferred(void); |
| 107 | int ipa_pm_stat(char *buf, int size); |
| 108 | int ipa_pm_exceptions_stat(char *buf, int size); |
| 109 | |
| 110 | #endif /* _IPA_PM_H_ */ |