Repository navigation
Expand file tree
/
Copy pathpm_runtime.c
More file actions
113 lines (92 loc) · 2.43 KB
/
Copy pathpm_runtime.c
File metadata and controls
113 lines (92 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2018 Intel Corporation. All rights reserved.
//
// Author: Tomasz Lauda <tomasz.lauda@linux.intel.com>
/**
* \file lib/pm_runtime.c
* \brief Runtime power management implementation
* \author Tomasz Lauda <tomasz.lauda@linux.intel.com>
*/
#include <sof/lib/alloc.h>
#include <sof/lib/memory.h>
#include <sof/lib/pm_runtime.h>
#include <sof/lib/uuid.h>
#include <sof/sof.h>
#include <sof/spinlock.h>
#include <ipc/topology.h>
#include <stdint.h>
/* d7f6712d-131c-45a7-82ed-6aa9dc2291ea */
DECLARE_SOF_UUID("pm-runtime", pm_runtime_uuid, 0xd7f6712d, 0x131c, 0x45a7,
0x82, 0xed, 0x6a, 0xa9, 0xdc, 0x22, 0x91, 0xea);
DECLARE_TR_CTX(pm_tr, SOF_UUID(pm_runtime_uuid), LOG_LEVEL_INFO);
void pm_runtime_init(struct sof *sof)
{
sof->prd = rzalloc(SOF_MEM_ZONE_SYS, SOF_MEM_FLAG_SHARED,
SOF_MEM_CAPS_RAM, sizeof(*sof->prd));
spinlock_init(&sof->prd->lock);
platform_pm_runtime_init(sof->prd);
platform_shared_commit(sof->prd, sizeof(*sof->prd));
}
void pm_runtime_get(enum pm_runtime_context context, uint32_t index)
{
tr_dbg(&pm_tr, "pm_runtime_get()");
switch (context) {
default:
platform_pm_runtime_get(context, index, RPM_ASYNC);
break;
}
}
void pm_runtime_get_sync(enum pm_runtime_context context, uint32_t index)
{
tr_dbg(&pm_tr, "pm_runtime_get_sync()");
switch (context) {
default:
platform_pm_runtime_get(context, index, 0);
break;
}
}
void pm_runtime_put(enum pm_runtime_context context, uint32_t index)
{
tr_dbg(&pm_tr, "pm_runtime_put()");
switch (context) {
default:
platform_pm_runtime_put(context, index, RPM_ASYNC);
break;
}
}
void pm_runtime_put_sync(enum pm_runtime_context context, uint32_t index)
{
tr_dbg(&pm_tr, "pm_runtime_put_sync()");
switch (context) {
default:
platform_pm_runtime_put(context, index, 0);
break;
}
}
void pm_runtime_enable(enum pm_runtime_context context, uint32_t index)
{
tr_dbg(&pm_tr, "pm_runtime_enable()");
switch (context) {
default:
platform_pm_runtime_enable(context, index);
break;
}
}
void pm_runtime_disable(enum pm_runtime_context context, uint32_t index)
{
tr_dbg(&pm_tr, "pm_runtime_disable()");
switch (context) {
default:
platform_pm_runtime_disable(context, index);
break;
}
}
bool pm_runtime_is_active(enum pm_runtime_context context, uint32_t index)
{
tr_dbg(&pm_tr, "pm_runtime_is_active()");
switch (context) {
default:
return platform_pm_runtime_is_active(context, index);
}
}