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
|
From 41b834aed6b2902683102eacff56428158792187 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20W=C3=B6rndl-Aichriedler?= <bwa@xdevelop.at>
Date: Sat, 15 May 2010 16:34:05 +0200
Subject: [PATCH 18/30] Add power-off support for the TWL4030 companion
This patch adds support for the power-off on shutdown feature of the TWL4030
---
drivers/mfd/Kconfig | 6 ++++++
drivers/mfd/twl-core.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 3ed3ff0..fe2370a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -210,6 +210,12 @@ config TWL4030_CODEC
select MFD_CORE
default n
+config TWL4030_POWEROFF
+ bool "TWL4030 Allow power-off on shutdown"
+ depends on TWL4030_CORE
+ help
+ Enables the CPU to power-off the system on shutdown
+
config TWL6030_PWM
tristate "TWL6030 PWM (Pulse Width Modulator) Support"
depends on TWL4030_CORE
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 960b5be..8804550 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -122,6 +122,12 @@
#define twl_has_bci() false
#endif
+#if defined (CONFIG_TWL4030_POWEROFF)
+#define twl_has_poweroff() true
+#else
+#define twl_has_poweroff() false
+#endif
+
/* Triton Core internal information (BEGIN) */
/* Last - for index max*/
@@ -224,6 +230,10 @@
#define TWL5031 BIT(2) /* twl5031 has different registers */
#define TWL6030_CLASS BIT(3) /* TWL6030 class */
+/* for pm_power_off */
+#define PWR_P1_SW_EVENTS 0x10
+#define PWR_DEVOFF (1 << 0)
+
/*----------------------------------------------------------------------*/
/* is driver active, bound to a chip? */
@@ -1006,6 +1016,30 @@ static int twl_remove(struct i2c_client *client)
return 0;
}
+static void twl_poweroff(void)
+{
+ int err;
+ u8 val;
+
+ err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val,
+ PWR_P1_SW_EVENTS);
+ if (err) {
+ pr_err("%s: i2c error %d while reading TWL4030"
+ "PM_MASTER P1_SW_EVENTS\n",
+ DRIVER_NAME, err);
+ return;
+ }
+
+ val |= PWR_DEVOFF;
+
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val,
+ PWR_P1_SW_EVENTS);
+ if (err)
+ pr_err("%s: i2c error %d while writing TWL4030"
+ "PM_MASTER P1_SW_EVENTS\n",
+ DRIVER_NAME, err);
+}
+
/* NOTE: this driver only handles a single twl4030/tps659x0 chip */
static int __devinit
twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
@@ -1093,6 +1127,12 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
}
+ if(twl_has_poweroff())
+ {
+ /* initialize pm_power_off routine */
+ pm_power_off = twl_poweroff;
+ }
+
status = add_children(pdata, id->driver_data);
fail:
if (status < 0)
--
1.6.6.1
|