1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright(c) 2020 Intel Corporation.
4  */
5 
6 #include "intel_pxp.h"
7 #include "intel_pxp_irq.h"
8 #include "intel_pxp_pm.h"
9 #include "intel_pxp_session.h"
10 
11 void intel_pxp_suspend(struct intel_pxp *pxp, bool runtime)
12 {
13 	if (!intel_pxp_is_enabled(pxp))
14 		return;
15 
16 	pxp->arb_is_valid = false;
17 
18 	/*
19 	 * Contexts using protected objects keep a runtime PM reference, so we
20 	 * can only runtime suspend when all of them have been either closed
21 	 * or banned. Therefore, there is no need to invalidate in that
22 	 * scenario.
23 	 */
24 	if (!runtime)
25 		intel_pxp_invalidate(pxp);
26 
27 	intel_pxp_fini_hw(pxp);
28 
29 	pxp->hw_state_invalidated = false;
30 }
31 
32 void intel_pxp_resume(struct intel_pxp *pxp)
33 {
34 	if (!intel_pxp_is_enabled(pxp))
35 		return;
36 
37 	/*
38 	 * The PXP component gets automatically unbound when we go into S3 and
39 	 * re-bound after we come out, so in that scenario we can defer the
40 	 * hw init to the bind call.
41 	 */
42 	if (!pxp->pxp_component)
43 		return;
44 
45 	intel_pxp_init_hw(pxp);
46 }
47