blob: 205e7a562093a043080c428ad1f67b40b17ff51b [file] [log] [blame]
Michael Adisumartaf0424822018-01-15 16:15:33 -08001/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
Michael Adisumartac06df412017-09-19 10:10:35 -07002 *
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 */
Michael Adisumartaf0424822018-01-15 16:15:33 -080019#define IPA_PM_MAX_CLIENTS 11 /* actual max is value -1 since we start from 1*/
Michael Adisumartac06df412017-09-19 10:10:35 -070020#define IPA_PM_MAX_EX_CL 64
Michael Adisumartab8e74702017-11-29 20:52:59 -080021#define IPA_PM_THRESHOLD_MAX 5
Michael Adisumartac06df412017-09-19 10:10:35 -070022#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 */
33enum 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 */
47enum 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 */
58struct 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 */
70struct 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 */
85struct 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
93int ipa_pm_register(struct ipa_pm_register_params *params, u32 *hdl);
94int ipa_pm_associate_ipa_cons_to_client(u32 hdl, enum ipa_client_type consumer);
95int ipa_pm_activate(u32 hdl);
96int ipa_pm_activate_sync(u32 hdl);
97int ipa_pm_deferred_deactivate(u32 hdl);
98int ipa_pm_deactivate_sync(u32 hdl);
99int ipa_pm_set_perf_profile(u32 hdl, int throughput);
100int ipa_pm_deregister(u32 hdl);
101
102/* IPA Internal Functions */
103int ipa_pm_init(struct ipa_pm_init_params *params);
104int ipa_pm_destroy(void);
105int ipa_pm_handle_suspend(u32 pipe_bitmask);
106int ipa_pm_deactivate_all_deferred(void);
107int ipa_pm_stat(char *buf, int size);
108int ipa_pm_exceptions_stat(char *buf, int size);
109
110#endif /* _IPA_PM_H_ */