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
|
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
*/
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/tick.h>
#include <clocksource/arm_arch_timer.h>
#include <linux/ktime.h>
#include <asm/arch_timer.h>
#include <soc/qcom/rpm-notifier.h>
#include <soc/qcom/lpm_levels.h>
#include <soc/qcom/mpm.h>
static void system_sleep_exit(bool success)
{
msm_rpm_exit_sleep();
}
static int system_sleep_update_wakeup(bool from_idle)
{
uint32_t lo = ~0U, hi = ~0U;
u64 wakeup;
/* Read the hardware to get the most accurate value */
arch_timer_mem_get_cval(&lo, &hi);
wakeup = lo;
wakeup |= ((uint64_t)(hi) << 32);
msm_mpm_timer_write((uint32_t *)&wakeup);
return 0;
}
static int system_sleep_enter(struct cpumask *mask)
{
int ret = 0;
ret = msm_rpm_enter_sleep(0, mask);
if (ret)
return ret;
msm_mpm_enter_sleep(mask);
return ret;
}
static bool system_sleep_allowed(void)
{
return !msm_rpm_waiting_for_ack();
}
static struct system_pm_ops pm_ops = {
.enter = system_sleep_enter,
.exit = system_sleep_exit,
.update_wakeup = system_sleep_update_wakeup,
.sleep_allowed = system_sleep_allowed,
};
static int sys_pm_rpm_probe(struct platform_device *pdev)
{
return register_system_pm_ops(&pm_ops);
}
static const struct of_device_id sys_pm_drv_match[] = {
{ .compatible = "qcom,system-pm-rpm", },
{ }
};
static struct platform_driver sys_pm_rpm_driver = {
.probe = sys_pm_rpm_probe,
.driver = {
.name = KBUILD_MODNAME,
.suppress_bind_attrs = true,
.of_match_table = sys_pm_drv_match,
},
};
module_platform_driver(sys_pm_rpm_driver);
MODULE_DESCRIPTION("Qualcomm Technologies, Inc. (QTI) SYSTEM PM RPM Driver");
MODULE_LICENSE("GPL v2");
|