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
|
/*
* Copyright (C) ST-Ericsson SA 2011
*
* License terms: GNU General Public License (GPL) version 2
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/signal.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab5500.h>
static struct device *dev;
/* STARTUP */
#define AB5500_SYSPOR_CONTROL 0x30
/* VINT IO I2C CLOCK */
#define AB5500_RTC_VINT 0x01
int ab5500_clock_rtc_enable(int num, bool enable)
{
/* RTC_CLK{0,1,2} are bits {4,3,2}, active low */
u8 mask = BIT(4 - num);
u8 value = enable ? 0 : mask;
/* Don't allow RTC_CLK0 to be controlled. */
if (num < 1 || num > 2)
return -EINVAL;
if (!dev)
return -EAGAIN;
return abx500_mask_and_set(dev, AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP,
AB5500_RTC_VINT, mask, value);
}
static void ab5500_power_off(void)
{
sigset_t old;
sigset_t all;
sigfillset(&all);
if (!sigprocmask(SIG_BLOCK, &all, &old)) {
/* Clear dbb_on */
int ret = abx500_set(dev, AB5500_BANK_STARTUP,
AB5500_SYSPOR_CONTROL, 0);
WARN_ON(ret);
}
}
static int __devinit ab5500_power_probe(struct platform_device *pdev)
{
struct ab5500_platform_data *plat = dev_get_platdata(pdev->dev.parent);
dev = &pdev->dev;
if (plat->pm_power_off)
pm_power_off = ab5500_power_off;
return 0;
}
static int __devexit ab5500_power_remove(struct platform_device *pdev)
{
struct ab5500_platform_data *plat = dev_get_platdata(pdev->dev.parent);
if (plat->pm_power_off)
pm_power_off = NULL;
dev = NULL;
return 0;
}
static struct platform_driver ab5500_power_driver = {
.driver = {
.name = "ab5500-power",
.owner = THIS_MODULE,
},
.probe = ab5500_power_probe,
.remove = __devexit_p(ab5500_power_remove),
};
static int __init ab8500_sysctrl_init(void)
{
return platform_driver_register(&ab5500_power_driver);
}
subsys_initcall(ab8500_sysctrl_init);
MODULE_DESCRIPTION("AB5500 power driver");
MODULE_LICENSE("GPL v2");
|