blob: 2bfbb40ca9d2576723f38fafd7e1ddf79c7b4feb [file] [log] [blame]
Amit Kucheriaebf0bd32009-08-31 18:32:18 +02001/*
2 * linux/drivers/i2c/chips/twl4030-power.c
3 *
4 * Handle TWL4030 Power initialization
5 *
6 * Copyright (C) 2008 Nokia Corporation
7 * Copyright (C) 2006 Texas Instruments, Inc
8 *
9 * Written by Kalle Jokiniemi
10 * Peter De Schrijver <peter.de-schrijver@nokia.com>
11 * Several fixes by Amit Kucheria <amit.kucheria@verdurent.com>
12 *
13 * This file is subject to the terms and conditions of the GNU General
14 * Public License. See the file "COPYING" in the main directory of this
15 * archive for more details.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#include <linux/module.h>
28#include <linux/pm.h>
Santosh Shilimkarb07682b2009-12-13 20:05:51 +010029#include <linux/i2c/twl.h>
Amit Kucheriaebf0bd32009-08-31 18:32:18 +020030#include <linux/platform_device.h>
Florian Vaussardb0fc1da2013-06-18 15:17:58 +020031#include <linux/of.h>
Tony Lindgrene7cd1d12014-05-20 11:17:54 -070032#include <linux/of_device.h>
Amit Kucheriaebf0bd32009-08-31 18:32:18 +020033
34#include <asm/mach-types.h>
35
36static u8 twl4030_start_script_address = 0x2b;
37
Tony Lindgren32057282014-05-20 11:17:53 -070038/* Register bits for P1, P2 and P3_SW_EVENTS */
39#define PWR_STOPON_PRWON BIT(6)
40#define PWR_STOPON_SYSEN BIT(5)
41#define PWR_ENABLE_WARMRESET BIT(4)
42#define PWR_LVL_WAKEUP BIT(3)
43#define PWR_DEVACT BIT(2)
44#define PWR_DEVSLP BIT(1)
45#define PWR_DEVOFF BIT(0)
46
Igor Grinberg26cc3ab2011-11-13 11:49:50 +020047#define SEQ_OFFSYNC (1 << 0)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +020048
49#define PHY_TO_OFF_PM_MASTER(p) (p - 0x36)
50#define PHY_TO_OFF_PM_RECEIVER(p) (p - 0x5b)
51
52/* resource - hfclk */
53#define R_HFCLKOUT_DEV_GRP PHY_TO_OFF_PM_RECEIVER(0xe6)
54
55/* PM events */
56#define R_P1_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x46)
57#define R_P2_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x47)
58#define R_P3_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x48)
59#define R_CFG_P1_TRANSITION PHY_TO_OFF_PM_MASTER(0x36)
60#define R_CFG_P2_TRANSITION PHY_TO_OFF_PM_MASTER(0x37)
61#define R_CFG_P3_TRANSITION PHY_TO_OFF_PM_MASTER(0x38)
62
Amit Kucheriaebf0bd32009-08-31 18:32:18 +020063#define END_OF_SCRIPT 0x3f
64
65#define R_SEQ_ADD_A2S PHY_TO_OFF_PM_MASTER(0x55)
66#define R_SEQ_ADD_S2A12 PHY_TO_OFF_PM_MASTER(0x56)
67#define R_SEQ_ADD_S2A3 PHY_TO_OFF_PM_MASTER(0x57)
68#define R_SEQ_ADD_WARM PHY_TO_OFF_PM_MASTER(0x58)
69#define R_MEMORY_ADDRESS PHY_TO_OFF_PM_MASTER(0x59)
70#define R_MEMORY_DATA PHY_TO_OFF_PM_MASTER(0x5a)
71
Amit Kucheria890463f2009-10-19 15:10:48 +030072/* resource configuration registers
73 <RESOURCE>_DEV_GRP at address 'n+0'
74 <RESOURCE>_TYPE at address 'n+1'
75 <RESOURCE>_REMAP at address 'n+2'
76 <RESOURCE>_DEDICATED at address 'n+3'
77*/
Amit Kucheriae97d1542009-10-19 15:10:44 +030078#define DEV_GRP_OFFSET 0
Amit Kucheriaebf0bd32009-08-31 18:32:18 +020079#define TYPE_OFFSET 1
Amit Kucheriab4ead612009-10-19 15:11:00 +030080#define REMAP_OFFSET 2
81#define DEDICATED_OFFSET 3
Amit Kucheriaebf0bd32009-08-31 18:32:18 +020082
Amit Kucheriae97d1542009-10-19 15:10:44 +030083/* Bit positions in the registers */
Amit Kucheria890463f2009-10-19 15:10:48 +030084
85/* <RESOURCE>_DEV_GRP */
Amit Kucheriae97d1542009-10-19 15:10:44 +030086#define DEV_GRP_SHIFT 5
87#define DEV_GRP_MASK (7 << DEV_GRP_SHIFT)
Amit Kucheria890463f2009-10-19 15:10:48 +030088
89/* <RESOURCE>_TYPE */
Amit Kucheriaebf0bd32009-08-31 18:32:18 +020090#define TYPE_SHIFT 0
91#define TYPE_MASK (7 << TYPE_SHIFT)
92#define TYPE2_SHIFT 3
93#define TYPE2_MASK (3 << TYPE2_SHIFT)
94
Amit Kucheriab4ead612009-10-19 15:11:00 +030095/* <RESOURCE>_REMAP */
96#define SLEEP_STATE_SHIFT 0
97#define SLEEP_STATE_MASK (0xf << SLEEP_STATE_SHIFT)
98#define OFF_STATE_SHIFT 4
99#define OFF_STATE_MASK (0xf << OFF_STATE_SHIFT)
100
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200101static u8 res_config_addrs[] = {
102 [RES_VAUX1] = 0x17,
103 [RES_VAUX2] = 0x1b,
104 [RES_VAUX3] = 0x1f,
105 [RES_VAUX4] = 0x23,
106 [RES_VMMC1] = 0x27,
107 [RES_VMMC2] = 0x2b,
108 [RES_VPLL1] = 0x2f,
109 [RES_VPLL2] = 0x33,
110 [RES_VSIM] = 0x37,
111 [RES_VDAC] = 0x3b,
112 [RES_VINTANA1] = 0x3f,
113 [RES_VINTANA2] = 0x43,
114 [RES_VINTDIG] = 0x47,
115 [RES_VIO] = 0x4b,
116 [RES_VDD1] = 0x55,
117 [RES_VDD2] = 0x63,
118 [RES_VUSB_1V5] = 0x71,
119 [RES_VUSB_1V8] = 0x74,
120 [RES_VUSB_3V1] = 0x77,
121 [RES_VUSBCP] = 0x7a,
122 [RES_REGEN] = 0x7f,
123 [RES_NRES_PWRON] = 0x82,
124 [RES_CLKEN] = 0x85,
125 [RES_SYSEN] = 0x88,
126 [RES_HFCLKOUT] = 0x8b,
127 [RES_32KCLKOUT] = 0x8e,
128 [RES_RESET] = 0x91,
Lesly A Md7ac8292011-04-14 17:57:51 +0530129 [RES_MAIN_REF] = 0x94,
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200130};
131
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700132/*
133 * Usable values for .remap_sleep and .remap_off
134 * Based on table "5.3.3 Resource Operating modes"
135 */
136enum {
137 TWL_REMAP_OFF = 0,
138 TWL_REMAP_SLEEP = 8,
139 TWL_REMAP_ACTIVE = 9,
140};
141
142/*
143 * Macros to configure the PM register states for various resources.
144 * Note that we can make MSG_SINGULAR etc private to this driver once
145 * omap3 has been made DT only.
146 */
147#define TWL_DFLT_DELAY 2 /* typically 2 32 KiHz cycles */
Tony Lindgren76714d22014-05-20 11:17:54 -0700148#define TWL_DEV_GRP_P123 (DEV_GRP_P1 | DEV_GRP_P2 | DEV_GRP_P3)
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700149#define TWL_RESOURCE_SET(res, state) \
150 { MSG_SINGULAR(DEV_GRP_NULL, (res), (state)), TWL_DFLT_DELAY }
151#define TWL_RESOURCE_ON(res) TWL_RESOURCE_SET(res, RES_STATE_ACTIVE)
152#define TWL_RESOURCE_OFF(res) TWL_RESOURCE_SET(res, RES_STATE_OFF)
153#define TWL_RESOURCE_RESET(res) TWL_RESOURCE_SET(res, RES_STATE_WRST)
154/*
155 * It seems that type1 and type2 is just the resource init order
156 * number for the type1 and type2 group.
157 */
Tony Lindgren76714d22014-05-20 11:17:54 -0700158#define TWL_RESOURCE_SET_ACTIVE(res, state) \
159 { MSG_SINGULAR(DEV_GRP_NULL, (res), RES_STATE_ACTIVE), (state) }
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700160#define TWL_RESOURCE_GROUP_RESET(group, type1, type2) \
161 { MSG_BROADCAST(DEV_GRP_NULL, (group), (type1), (type2), \
162 RES_STATE_WRST), TWL_DFLT_DELAY }
Tony Lindgren76714d22014-05-20 11:17:54 -0700163#define TWL_RESOURCE_GROUP_SLEEP(group, type, type2) \
164 { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \
165 RES_STATE_SLEEP), TWL_DFLT_DELAY }
166#define TWL_RESOURCE_GROUP_ACTIVE(group, type, type2) \
167 { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \
168 RES_STATE_ACTIVE), TWL_DFLT_DELAY }
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700169#define TWL_REMAP_SLEEP(res, devgrp, typ, typ2) \
170 { .resource = (res), .devgroup = (devgrp), \
171 .type = (typ), .type2 = (typ2), \
172 .remap_off = TWL_REMAP_OFF, \
173 .remap_sleep = TWL_REMAP_SLEEP, }
Tony Lindgren76714d22014-05-20 11:17:54 -0700174#define TWL_REMAP_OFF(res, devgrp, typ, typ2) \
175 { .resource = (res), .devgroup = (devgrp), \
176 .type = (typ), .type2 = (typ2), \
177 .remap_off = TWL_REMAP_OFF, .remap_sleep = TWL_REMAP_OFF, }
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700178
Bill Pembertonf791be42012-11-19 13:23:04 -0500179static int twl4030_write_script_byte(u8 address, u8 byte)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200180{
181 int err;
182
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100183 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_MEMORY_ADDRESS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200184 if (err)
185 goto out;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100186 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, byte, R_MEMORY_DATA);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200187out:
188 return err;
189}
190
Bill Pembertonf791be42012-11-19 13:23:04 -0500191static int twl4030_write_script_ins(u8 address, u16 pmb_message,
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200192 u8 delay, u8 next)
193{
194 int err;
195
196 address *= 4;
197 err = twl4030_write_script_byte(address++, pmb_message >> 8);
198 if (err)
199 goto out;
200 err = twl4030_write_script_byte(address++, pmb_message & 0xff);
201 if (err)
202 goto out;
203 err = twl4030_write_script_byte(address++, delay);
204 if (err)
205 goto out;
206 err = twl4030_write_script_byte(address++, next);
207out:
208 return err;
209}
210
Bill Pembertonf791be42012-11-19 13:23:04 -0500211static int twl4030_write_script(u8 address, struct twl4030_ins *script,
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200212 int len)
213{
Arnd Bergmannf65e9ea2013-01-25 14:14:26 +0000214 int err = -EINVAL;
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200215
216 for (; len; len--, address++, script++) {
217 if (len == 1) {
218 err = twl4030_write_script_ins(address,
219 script->pmb_message,
220 script->delay,
221 END_OF_SCRIPT);
222 if (err)
223 break;
224 } else {
225 err = twl4030_write_script_ins(address,
226 script->pmb_message,
227 script->delay,
228 address + 1);
229 if (err)
230 break;
231 }
232 }
233 return err;
234}
235
Bill Pembertonf791be42012-11-19 13:23:04 -0500236static int twl4030_config_wakeup3_sequence(u8 address)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200237{
238 int err;
239 u8 data;
240
241 /* Set SLEEP to ACTIVE SEQ address for P3 */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100242 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A3);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200243 if (err)
244 goto out;
245
246 /* P3 LVL_WAKEUP should be on LEVEL */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100247 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P3_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200248 if (err)
249 goto out;
Tony Lindgren32057282014-05-20 11:17:53 -0700250 data |= PWR_LVL_WAKEUP;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100251 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P3_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200252out:
253 if (err)
254 pr_err("TWL4030 wakeup sequence for P3 config error\n");
255 return err;
256}
257
Bill Pembertonf791be42012-11-19 13:23:04 -0500258static int twl4030_config_wakeup12_sequence(u8 address)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200259{
260 int err = 0;
261 u8 data;
262
263 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100264 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A12);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200265 if (err)
266 goto out;
267
268 /* P1/P2 LVL_WAKEUP should be on LEVEL */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100269 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P1_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200270 if (err)
271 goto out;
272
Tony Lindgren32057282014-05-20 11:17:53 -0700273 data |= PWR_LVL_WAKEUP;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100274 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P1_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200275 if (err)
276 goto out;
277
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100278 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P2_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200279 if (err)
280 goto out;
281
Tony Lindgren32057282014-05-20 11:17:53 -0700282 data |= PWR_LVL_WAKEUP;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100283 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P2_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200284 if (err)
285 goto out;
286
287 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) {
288 /* Disabling AC charger effect on sleep-active transitions */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100289 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data,
290 R_CFG_P1_TRANSITION);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200291 if (err)
292 goto out;
293 data &= ~(1<<1);
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100294 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data,
295 R_CFG_P1_TRANSITION);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200296 if (err)
297 goto out;
298 }
299
300out:
301 if (err)
302 pr_err("TWL4030 wakeup sequence for P1 and P2" \
303 "config error\n");
304 return err;
305}
306
Bill Pembertonf791be42012-11-19 13:23:04 -0500307static int twl4030_config_sleep_sequence(u8 address)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200308{
309 int err;
310
311 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100312 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_A2S);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200313
314 if (err)
315 pr_err("TWL4030 sleep sequence config error\n");
316
317 return err;
318}
319
Bill Pembertonf791be42012-11-19 13:23:04 -0500320static int twl4030_config_warmreset_sequence(u8 address)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200321{
322 int err;
323 u8 rd_data;
324
325 /* Set WARM RESET SEQ address for P1 */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100326 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_WARM);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200327 if (err)
328 goto out;
329
330 /* P1/P2/P3 enable WARMRESET */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100331 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P1_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200332 if (err)
333 goto out;
334
Tony Lindgren32057282014-05-20 11:17:53 -0700335 rd_data |= PWR_ENABLE_WARMRESET;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100336 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P1_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200337 if (err)
338 goto out;
339
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100340 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P2_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200341 if (err)
342 goto out;
343
Tony Lindgren32057282014-05-20 11:17:53 -0700344 rd_data |= PWR_ENABLE_WARMRESET;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100345 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P2_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200346 if (err)
347 goto out;
348
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100349 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P3_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200350 if (err)
351 goto out;
352
Tony Lindgren32057282014-05-20 11:17:53 -0700353 rd_data |= PWR_ENABLE_WARMRESET;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100354 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P3_SW_EVENTS);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200355out:
356 if (err)
357 pr_err("TWL4030 warmreset seq config error\n");
358 return err;
359}
360
Bill Pembertonf791be42012-11-19 13:23:04 -0500361static int twl4030_configure_resource(struct twl4030_resconfig *rconfig)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200362{
363 int rconfig_addr;
364 int err;
365 u8 type;
366 u8 grp;
Amit Kucheriab4ead612009-10-19 15:11:00 +0300367 u8 remap;
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200368
369 if (rconfig->resource > TOTAL_RESOURCES) {
370 pr_err("TWL4030 Resource %d does not exist\n",
371 rconfig->resource);
372 return -EINVAL;
373 }
374
375 rconfig_addr = res_config_addrs[rconfig->resource];
376
377 /* Set resource group */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100378 err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &grp,
Balaji T Kfc7b92f2009-12-13 21:23:33 +0100379 rconfig_addr + DEV_GRP_OFFSET);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200380 if (err) {
381 pr_err("TWL4030 Resource %d group could not be read\n",
382 rconfig->resource);
383 return err;
384 }
385
Aaro Koskinen56baa662009-10-19 21:24:02 +0200386 if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) {
Amit Kucheriae97d1542009-10-19 15:10:44 +0300387 grp &= ~DEV_GRP_MASK;
388 grp |= rconfig->devgroup << DEV_GRP_SHIFT;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100389 err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER,
Balaji T Kfc7b92f2009-12-13 21:23:33 +0100390 grp, rconfig_addr + DEV_GRP_OFFSET);
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200391 if (err < 0) {
392 pr_err("TWL4030 failed to program devgroup\n");
393 return err;
394 }
395 }
396
397 /* Set resource types */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100398 err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &type,
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200399 rconfig_addr + TYPE_OFFSET);
400 if (err < 0) {
401 pr_err("TWL4030 Resource %d type could not be read\n",
402 rconfig->resource);
403 return err;
404 }
405
Aaro Koskinen56baa662009-10-19 21:24:02 +0200406 if (rconfig->type != TWL4030_RESCONFIG_UNDEF) {
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200407 type &= ~TYPE_MASK;
408 type |= rconfig->type << TYPE_SHIFT;
409 }
410
Aaro Koskinen56baa662009-10-19 21:24:02 +0200411 if (rconfig->type2 != TWL4030_RESCONFIG_UNDEF) {
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200412 type &= ~TYPE2_MASK;
413 type |= rconfig->type2 << TYPE2_SHIFT;
414 }
415
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100416 err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER,
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200417 type, rconfig_addr + TYPE_OFFSET);
418 if (err < 0) {
419 pr_err("TWL4030 failed to program resource type\n");
420 return err;
421 }
422
Amit Kucheriab4ead612009-10-19 15:11:00 +0300423 /* Set remap states */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100424 err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &remap,
Balaji T Kfc7b92f2009-12-13 21:23:33 +0100425 rconfig_addr + REMAP_OFFSET);
Amit Kucheriab4ead612009-10-19 15:11:00 +0300426 if (err < 0) {
427 pr_err("TWL4030 Resource %d remap could not be read\n",
428 rconfig->resource);
429 return err;
430 }
431
Amit Kucheria53cf9a62009-10-21 14:49:22 +0300432 if (rconfig->remap_off != TWL4030_RESCONFIG_UNDEF) {
Amit Kucheriab4ead612009-10-19 15:11:00 +0300433 remap &= ~OFF_STATE_MASK;
434 remap |= rconfig->remap_off << OFF_STATE_SHIFT;
435 }
436
Amit Kucheria53cf9a62009-10-21 14:49:22 +0300437 if (rconfig->remap_sleep != TWL4030_RESCONFIG_UNDEF) {
Amit Kucheriab4ead612009-10-19 15:11:00 +0300438 remap &= ~SLEEP_STATE_MASK;
Mike Turquette1ea933f2010-02-05 09:51:37 +0100439 remap |= rconfig->remap_sleep << SLEEP_STATE_SHIFT;
Amit Kucheriab4ead612009-10-19 15:11:00 +0300440 }
441
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100442 err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER,
Balaji T Kfc7b92f2009-12-13 21:23:33 +0100443 remap,
444 rconfig_addr + REMAP_OFFSET);
Amit Kucheriab4ead612009-10-19 15:11:00 +0300445 if (err < 0) {
446 pr_err("TWL4030 failed to program remap\n");
447 return err;
448 }
449
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200450 return 0;
451}
452
Bill Pembertonf791be42012-11-19 13:23:04 -0500453static int load_twl4030_script(struct twl4030_script *tscript,
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200454 u8 address)
455{
456 int err;
Amit Kucheria75a74562009-08-17 17:01:56 +0300457 static int order;
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200458
459 /* Make sure the script isn't going beyond last valid address (0x3f) */
460 if ((address + tscript->size) > END_OF_SCRIPT) {
461 pr_err("TWL4030 scripts too big error\n");
462 return -EINVAL;
463 }
464
465 err = twl4030_write_script(address, tscript->script, tscript->size);
466 if (err)
467 goto out;
468
469 if (tscript->flags & TWL4030_WRST_SCRIPT) {
470 err = twl4030_config_warmreset_sequence(address);
471 if (err)
472 goto out;
473 }
474 if (tscript->flags & TWL4030_WAKEUP12_SCRIPT) {
Tony Lindgrenfc7d76e2014-05-13 18:34:04 -0700475 /* Reset any existing sleep script to avoid hangs on reboot */
476 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
477 R_SEQ_ADD_A2S);
478 if (err)
479 goto out;
480
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200481 err = twl4030_config_wakeup12_sequence(address);
482 if (err)
483 goto out;
Amit Kucheria75a74562009-08-17 17:01:56 +0300484 order = 1;
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200485 }
486 if (tscript->flags & TWL4030_WAKEUP3_SCRIPT) {
487 err = twl4030_config_wakeup3_sequence(address);
488 if (err)
489 goto out;
490 }
Lesly A Mc62dd362011-04-14 17:57:49 +0530491 if (tscript->flags & TWL4030_SLEEP_SCRIPT) {
Lesly A M1f968ff2011-04-14 17:57:50 +0530492 if (!order)
Amit Kucheria75a74562009-08-17 17:01:56 +0300493 pr_warning("TWL4030: Bad order of scripts (sleep "\
494 "script before wakeup) Leads to boot"\
495 "failure on some boards\n");
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200496 err = twl4030_config_sleep_sequence(address);
Lesly A Mc62dd362011-04-14 17:57:49 +0530497 }
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200498out:
499 return err;
500}
501
Mike Turquette11a441c2010-02-22 11:16:30 -0600502int twl4030_remove_script(u8 flags)
503{
504 int err = 0;
505
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100506 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
507 TWL4030_PM_MASTER_PROTECT_KEY);
Mike Turquette11a441c2010-02-22 11:16:30 -0600508 if (err) {
509 pr_err("twl4030: unable to unlock PROTECT_KEY\n");
510 return err;
511 }
512
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100513 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
514 TWL4030_PM_MASTER_PROTECT_KEY);
Mike Turquette11a441c2010-02-22 11:16:30 -0600515 if (err) {
516 pr_err("twl4030: unable to unlock PROTECT_KEY\n");
517 return err;
518 }
519
520 if (flags & TWL4030_WRST_SCRIPT) {
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100521 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
522 R_SEQ_ADD_WARM);
Mike Turquette11a441c2010-02-22 11:16:30 -0600523 if (err)
524 return err;
525 }
526 if (flags & TWL4030_WAKEUP12_SCRIPT) {
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100527 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
528 R_SEQ_ADD_S2A12);
Lesly A Meac78a22011-05-04 17:38:53 +0530529 if (err)
Mike Turquette11a441c2010-02-22 11:16:30 -0600530 return err;
531 }
532 if (flags & TWL4030_WAKEUP3_SCRIPT) {
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100533 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
534 R_SEQ_ADD_S2A3);
Mike Turquette11a441c2010-02-22 11:16:30 -0600535 if (err)
536 return err;
537 }
538 if (flags & TWL4030_SLEEP_SCRIPT) {
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100539 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
540 R_SEQ_ADD_A2S);
Mike Turquette11a441c2010-02-22 11:16:30 -0600541 if (err)
542 return err;
543 }
544
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100545 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
546 TWL4030_PM_MASTER_PROTECT_KEY);
Mike Turquette11a441c2010-02-22 11:16:30 -0600547 if (err)
548 pr_err("TWL4030 Unable to relock registers\n");
549
550 return err;
551}
552
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700553static int
554twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
Florian Vaussardf58cb402013-06-18 15:17:57 +0200555{
556 int err;
557 int i;
558 u8 address = twl4030_start_script_address;
559
560 for (i = 0; i < pdata->num; i++) {
561 err = load_twl4030_script(pdata->scripts[i], address);
562 if (err)
563 return err;
564 address += pdata->scripts[i]->size;
565 }
566
567 return 0;
568}
569
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700570static int
571twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
Florian Vaussardf58cb402013-06-18 15:17:57 +0200572{
573 struct twl4030_resconfig *resconfig = pdata->resource_config;
574 int err;
575
576 if (resconfig) {
577 while (resconfig->resource) {
578 err = twl4030_configure_resource(resconfig);
579 if (err)
580 return err;
581 resconfig++;
582 }
583 }
584
585 return 0;
586}
587
Igor Grinberg26cc3ab2011-11-13 11:49:50 +0200588/*
589 * In master mode, start the power off sequence.
590 * After a successful execution, TWL shuts down the power to the SoC
591 * and all peripherals connected to it.
592 */
593void twl4030_power_off(void)
594{
595 int err;
596
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100597 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, PWR_DEVOFF,
Igor Grinberg26cc3ab2011-11-13 11:49:50 +0200598 TWL4030_PM_MASTER_P1_SW_EVENTS);
599 if (err)
600 pr_err("TWL4030 Unable to power off\n");
601}
602
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700603static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200604 struct device_node *node)
605{
606 if (pdata && pdata->use_poweroff)
607 return true;
608
609 if (of_property_read_bool(node, "ti,use_poweroff"))
610 return true;
611
612 return false;
613}
614
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700615#ifdef CONFIG_OF
616
617/* Generic warm reset configuration for omap3 */
618
619static struct twl4030_ins omap3_wrst_seq[] = {
620 TWL_RESOURCE_OFF(RES_NRES_PWRON),
621 TWL_RESOURCE_OFF(RES_RESET),
622 TWL_RESOURCE_RESET(RES_MAIN_REF),
623 TWL_RESOURCE_GROUP_RESET(RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2),
624 TWL_RESOURCE_RESET(RES_VUSB_3V1),
625 TWL_RESOURCE_GROUP_RESET(RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1),
626 TWL_RESOURCE_GROUP_RESET(RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0),
627 TWL_RESOURCE_ON(RES_RESET),
628 TWL_RESOURCE_ON(RES_NRES_PWRON),
629};
630
631static struct twl4030_script omap3_wrst_script = {
632 .script = omap3_wrst_seq,
633 .size = ARRAY_SIZE(omap3_wrst_seq),
634 .flags = TWL4030_WRST_SCRIPT,
635};
636
637static struct twl4030_script *omap3_reset_scripts[] = {
638 &omap3_wrst_script,
639};
640
641static struct twl4030_resconfig omap3_rconfig[] = {
642 TWL_REMAP_SLEEP(RES_HFCLKOUT, DEV_GRP_P3, -1, -1),
643 TWL_REMAP_SLEEP(RES_VDD1, DEV_GRP_P1, -1, -1),
644 TWL_REMAP_SLEEP(RES_VDD2, DEV_GRP_P1, -1, -1),
645 { 0, 0 },
646};
647
648static struct twl4030_power_data omap3_reset = {
649 .scripts = omap3_reset_scripts,
650 .num = ARRAY_SIZE(omap3_reset_scripts),
651 .resource_config = omap3_rconfig,
652};
653
Tony Lindgren76714d22014-05-20 11:17:54 -0700654/* Recommended generic default idle configuration for off-idle */
655
656/* Broadcast message to put res to sleep */
657static struct twl4030_ins omap3_idle_sleep_on_seq[] = {
658 TWL_RESOURCE_GROUP_SLEEP(RES_GRP_ALL, RES_TYPE_ALL, 0),
659};
660
661static struct twl4030_script omap3_idle_sleep_on_script = {
662 .script = omap3_idle_sleep_on_seq,
663 .size = ARRAY_SIZE(omap3_idle_sleep_on_seq),
664 .flags = TWL4030_SLEEP_SCRIPT,
665};
666
667/* Broadcast message to put res to active */
668static struct twl4030_ins omap3_idle_wakeup_p12_seq[] = {
669 TWL_RESOURCE_GROUP_ACTIVE(RES_GRP_ALL, RES_TYPE_ALL, 0),
670};
671
672static struct twl4030_script omap3_idle_wakeup_p12_script = {
673 .script = omap3_idle_wakeup_p12_seq,
674 .size = ARRAY_SIZE(omap3_idle_wakeup_p12_seq),
675 .flags = TWL4030_WAKEUP12_SCRIPT,
676};
677
678/* Broadcast message to put res to active */
679static struct twl4030_ins omap3_idle_wakeup_p3_seq[] = {
680 TWL_RESOURCE_SET_ACTIVE(RES_CLKEN, 0x37),
681 TWL_RESOURCE_GROUP_ACTIVE(RES_GRP_ALL, RES_TYPE_ALL, 0),
682};
683
684static struct twl4030_script omap3_idle_wakeup_p3_script = {
685 .script = omap3_idle_wakeup_p3_seq,
686 .size = ARRAY_SIZE(omap3_idle_wakeup_p3_seq),
687 .flags = TWL4030_WAKEUP3_SCRIPT,
688};
689
690static struct twl4030_script *omap3_idle_scripts[] = {
691 &omap3_idle_wakeup_p12_script,
692 &omap3_idle_wakeup_p3_script,
693 &omap3_wrst_script,
694 &omap3_idle_sleep_on_script,
695};
696
697/*
698 * Recommended configuration based on "Recommended Sleep
699 * Sequences for the Zoom Platform":
700 * http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
701 * Note that the type1 and type2 seem to be just the init order number
702 * for type1 and type2 groups as specified in the document mentioned
703 * above.
704 */
705static struct twl4030_resconfig omap3_idle_rconfig[] = {
706 TWL_REMAP_SLEEP(RES_VAUX1, DEV_GRP_NULL, 0, 0),
707 TWL_REMAP_SLEEP(RES_VAUX2, DEV_GRP_NULL, 0, 0),
708 TWL_REMAP_SLEEP(RES_VAUX3, DEV_GRP_NULL, 0, 0),
709 TWL_REMAP_SLEEP(RES_VAUX4, DEV_GRP_NULL, 0, 0),
710 TWL_REMAP_SLEEP(RES_VMMC1, DEV_GRP_NULL, 0, 0),
711 TWL_REMAP_SLEEP(RES_VMMC2, DEV_GRP_NULL, 0, 0),
712 TWL_REMAP_OFF(RES_VPLL1, DEV_GRP_P1, 3, 1),
713 TWL_REMAP_SLEEP(RES_VPLL2, DEV_GRP_P1, 0, 0),
714 TWL_REMAP_SLEEP(RES_VSIM, DEV_GRP_NULL, 0, 0),
715 TWL_REMAP_SLEEP(RES_VDAC, DEV_GRP_NULL, 0, 0),
716 TWL_REMAP_SLEEP(RES_VINTANA1, TWL_DEV_GRP_P123, 1, 2),
717 TWL_REMAP_SLEEP(RES_VINTANA2, TWL_DEV_GRP_P123, 0, 2),
718 TWL_REMAP_SLEEP(RES_VINTDIG, TWL_DEV_GRP_P123, 1, 2),
719 TWL_REMAP_SLEEP(RES_VIO, TWL_DEV_GRP_P123, 2, 2),
720 TWL_REMAP_OFF(RES_VDD1, DEV_GRP_P1, 4, 1),
721 TWL_REMAP_OFF(RES_VDD2, DEV_GRP_P1, 3, 1),
722 TWL_REMAP_SLEEP(RES_VUSB_1V5, DEV_GRP_NULL, 0, 0),
723 TWL_REMAP_SLEEP(RES_VUSB_1V8, DEV_GRP_NULL, 0, 0),
724 TWL_REMAP_SLEEP(RES_VUSB_3V1, TWL_DEV_GRP_P123, 0, 0),
725 /* Resource #20 USB charge pump skipped */
726 TWL_REMAP_SLEEP(RES_REGEN, TWL_DEV_GRP_P123, 2, 1),
727 TWL_REMAP_SLEEP(RES_NRES_PWRON, TWL_DEV_GRP_P123, 0, 1),
728 TWL_REMAP_SLEEP(RES_CLKEN, TWL_DEV_GRP_P123, 3, 2),
729 TWL_REMAP_SLEEP(RES_SYSEN, TWL_DEV_GRP_P123, 6, 1),
730 TWL_REMAP_SLEEP(RES_HFCLKOUT, DEV_GRP_P3, 0, 2),
731 TWL_REMAP_SLEEP(RES_32KCLKOUT, TWL_DEV_GRP_P123, 0, 0),
732 TWL_REMAP_SLEEP(RES_RESET, TWL_DEV_GRP_P123, 6, 0),
733 TWL_REMAP_SLEEP(RES_MAIN_REF, TWL_DEV_GRP_P123, 0, 0),
734 { /* Terminator */ },
735};
736
737static struct twl4030_power_data omap3_idle = {
738 .scripts = omap3_idle_scripts,
739 .num = ARRAY_SIZE(omap3_idle_scripts),
740 .resource_config = omap3_idle_rconfig,
741};
742
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700743static struct of_device_id twl4030_power_of_match[] = {
744 {
745 .compatible = "ti,twl4030-power-reset",
746 .data = &omap3_reset,
747 },
Tony Lindgren76714d22014-05-20 11:17:54 -0700748 {
749 .compatible = "ti,twl4030-power-idle",
750 .data = &omap3_idle,
751 },
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700752 { },
753};
754MODULE_DEVICE_TABLE(of, twl4030_power_of_match);
755#endif /* CONFIG_OF */
756
Jingoo Hanfae01582013-08-01 10:52:55 +0900757static int twl4030_power_probe(struct platform_device *pdev)
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200758{
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700759 const struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev);
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200760 struct device_node *node = pdev->dev.of_node;
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700761 const struct of_device_id *match;
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200762 int err = 0;
Florian Vaussardcb3cabd2013-06-18 15:18:00 +0200763 int err2 = 0;
Florian Vaussardf58cb402013-06-18 15:17:57 +0200764 u8 val;
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200765
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200766 if (!pdata && !node) {
767 dev_err(&pdev->dev, "Platform data is missing\n");
768 return -EINVAL;
769 }
770
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100771 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
772 TWL4030_PM_MASTER_PROTECT_KEY);
Florian Vaussarde77a4c22013-06-18 15:17:59 +0200773 err |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
774 TWL4030_PM_MASTER_KEY_CFG2,
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100775 TWL4030_PM_MASTER_PROTECT_KEY);
Florian Vaussarde77a4c22013-06-18 15:17:59 +0200776
777 if (err) {
778 pr_err("TWL4030 Unable to unlock registers\n");
779 return err;
780 }
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200781
Tony Lindgrene7cd1d12014-05-20 11:17:54 -0700782 match = of_match_device(of_match_ptr(twl4030_power_of_match),
783 &pdev->dev);
784 if (match && match->data)
785 pdata = match->data;
786
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200787 if (pdata) {
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200788 err = twl4030_power_configure_scripts(pdata);
Florian Vaussarde77a4c22013-06-18 15:17:59 +0200789 if (err) {
790 pr_err("TWL4030 failed to load scripts\n");
Florian Vaussardcb3cabd2013-06-18 15:18:00 +0200791 goto relock;
Florian Vaussarde77a4c22013-06-18 15:17:59 +0200792 }
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200793 err = twl4030_power_configure_resources(pdata);
Florian Vaussarde77a4c22013-06-18 15:17:59 +0200794 if (err) {
795 pr_err("TWL4030 failed to configure resource\n");
Florian Vaussardcb3cabd2013-06-18 15:18:00 +0200796 goto relock;
Florian Vaussarde77a4c22013-06-18 15:17:59 +0200797 }
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200798 }
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200799
Igor Grinberg26cc3ab2011-11-13 11:49:50 +0200800 /* Board has to be wired properly to use this feature */
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200801 if (twl4030_power_use_poweroff(pdata, node) && !pm_power_off) {
Igor Grinberg26cc3ab2011-11-13 11:49:50 +0200802 /* Default for SEQ_OFFSYNC is set, lets ensure this */
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100803 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
Igor Grinberg26cc3ab2011-11-13 11:49:50 +0200804 TWL4030_PM_MASTER_CFG_P123_TRANSITION);
805 if (err) {
806 pr_warning("TWL4030 Unable to read registers\n");
807
808 } else if (!(val & SEQ_OFFSYNC)) {
809 val |= SEQ_OFFSYNC;
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100810 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val,
Igor Grinberg26cc3ab2011-11-13 11:49:50 +0200811 TWL4030_PM_MASTER_CFG_P123_TRANSITION);
812 if (err) {
813 pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n");
814 goto relock;
815 }
816 }
817
818 pm_power_off = twl4030_power_off;
819 }
820
821relock:
Florian Vaussardcb3cabd2013-06-18 15:18:00 +0200822 err2 = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
Peter Ujfalusi4850f122012-11-13 09:28:52 +0100823 TWL4030_PM_MASTER_PROTECT_KEY);
Florian Vaussardcb3cabd2013-06-18 15:18:00 +0200824 if (err2) {
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200825 pr_err("TWL4030 Unable to relock registers\n");
Florian Vaussardcb3cabd2013-06-18 15:18:00 +0200826 return err2;
827 }
828
Florian Vaussard637d6892013-06-18 15:17:56 +0200829 return err;
Amit Kucheriaebf0bd32009-08-31 18:32:18 +0200830}
Florian Vaussard637d6892013-06-18 15:17:56 +0200831
832static int twl4030_power_remove(struct platform_device *pdev)
833{
834 return 0;
835}
836
837static struct platform_driver twl4030_power_driver = {
838 .driver = {
839 .name = "twl4030_power",
840 .owner = THIS_MODULE,
Florian Vaussardb0fc1da2013-06-18 15:17:58 +0200841 .of_match_table = of_match_ptr(twl4030_power_of_match),
Florian Vaussard637d6892013-06-18 15:17:56 +0200842 },
843 .probe = twl4030_power_probe,
844 .remove = twl4030_power_remove,
845};
846
847module_platform_driver(twl4030_power_driver);
848
849MODULE_AUTHOR("Nokia Corporation");
850MODULE_AUTHOR("Texas Instruments, Inc.");
851MODULE_DESCRIPTION("Power management for TWL4030");
852MODULE_LICENSE("GPL");
853MODULE_ALIAS("platform:twl4030_power");