xref: /OK3568_Linux_fs/kernel/drivers/net/ipa/ipa_clock.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun 
3*4882a593Smuzhiyun /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4*4882a593Smuzhiyun  * Copyright (C) 2018-2020 Linaro Ltd.
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef _IPA_CLOCK_H_
7*4882a593Smuzhiyun #define _IPA_CLOCK_H_
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun struct device;
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun struct ipa;
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun /**
14*4882a593Smuzhiyun  * ipa_clock_rate() - Return the current IPA core clock rate
15*4882a593Smuzhiyun  * @ipa:	IPA structure
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * Return: The current clock rate (in Hz), or 0.
18*4882a593Smuzhiyun  */
19*4882a593Smuzhiyun u32 ipa_clock_rate(struct ipa *ipa);
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun /**
22*4882a593Smuzhiyun  * ipa_clock_init() - Initialize IPA clocking
23*4882a593Smuzhiyun  * @dev:	IPA device
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * Return:	A pointer to an ipa_clock structure, or a pointer-coded error
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun struct ipa_clock *ipa_clock_init(struct device *dev);
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /**
30*4882a593Smuzhiyun  * ipa_clock_exit() - Inverse of ipa_clock_init()
31*4882a593Smuzhiyun  * @clock:	IPA clock pointer
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun void ipa_clock_exit(struct ipa_clock *clock);
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /**
36*4882a593Smuzhiyun  * ipa_clock_get() - Get an IPA clock reference
37*4882a593Smuzhiyun  * @ipa:	IPA pointer
38*4882a593Smuzhiyun  *
39*4882a593Smuzhiyun  * This call blocks if this is the first reference.
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun void ipa_clock_get(struct ipa *ipa);
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /**
44*4882a593Smuzhiyun  * ipa_clock_get_additional() - Get an IPA clock reference if not first
45*4882a593Smuzhiyun  * @ipa:	IPA pointer
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  * This returns immediately, and only takes a reference if not the first
48*4882a593Smuzhiyun  */
49*4882a593Smuzhiyun bool ipa_clock_get_additional(struct ipa *ipa);
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun /**
52*4882a593Smuzhiyun  * ipa_clock_put() - Drop an IPA clock reference
53*4882a593Smuzhiyun  * @ipa:	IPA pointer
54*4882a593Smuzhiyun  *
55*4882a593Smuzhiyun  * This drops a clock reference.  If the last reference is being dropped,
56*4882a593Smuzhiyun  * the clock is stopped and RX endpoints are suspended.  This call will
57*4882a593Smuzhiyun  * not block unless the last reference is dropped.
58*4882a593Smuzhiyun  */
59*4882a593Smuzhiyun void ipa_clock_put(struct ipa *ipa);
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun #endif /* _IPA_CLOCK_H_ */
62