summaryrefslogtreecommitdiffstats
path: root/extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0010-MFD-TWL4030-power-scripts-for-OMAP3-boards.patch
diff options
context:
space:
mode:
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0010-MFD-TWL4030-power-scripts-for-OMAP3-boards.patch')
-rw-r--r--extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0010-MFD-TWL4030-power-scripts-for-OMAP3-boards.patch705
1 files changed, 705 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0010-MFD-TWL4030-power-scripts-for-OMAP3-boards.patch b/extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0010-MFD-TWL4030-power-scripts-for-OMAP3-boards.patch
new file mode 100644
index 00000000..84e1ae7e
--- /dev/null
+++ b/extras/recipes-kernel/linux/linux-omap-2.6.39/mfd/0010-MFD-TWL4030-power-scripts-for-OMAP3-boards.patch
@@ -0,0 +1,705 @@
1From 0b29e1f61b85dd2d04f035088b70dc287d15b9f0 Mon Sep 17 00:00:00 2001
2From: Lesly A M <leslyam@ti.com>
3Date: Wed, 1 Jun 2011 14:56:49 -0700
4Subject: [PATCH 10/13] MFD: TWL4030: power scripts for OMAP3 boards
5
6Power bus message sequence for TWL4030 to enter sleep/wakeup/warm_reset.
7
8TWL4030 power scripts which can be used by different OMAP3 boards
9with the power companion chip (TWL4030 series).
10
11The twl4030 generic script can be used by any board file to update
12the power data in twl4030_platform_data.
13
14Since the TWL4030 power script has dependency with APIs in twl4030-power.c
15removing the __init for these APIs.
16
17For more information please see:
18 http://omapedia.org/wiki/TWL4030_power_scripts
19
20Signed-off-by: Lesly A M <leslyam@ti.com>
21Cc: Nishanth Menon <nm@ti.com>
22Cc: David Derrick <dderrick@ti.com>
23Cc: Samuel Ortiz <sameo@linux.intel.com>
24---
25 arch/arm/configs/omap2plus_defconfig | 1 +
26 arch/arm/mach-omap2/devices.c | 15 ++
27 drivers/mfd/Kconfig | 11 +
28 drivers/mfd/Makefile | 1 +
29 drivers/mfd/twl4030-power.c | 31 ++--
30 drivers/mfd/twl4030-script-omap.c | 373 ++++++++++++++++++++++++++++++++++
31 include/linux/i2c/twl.h | 41 ++++-
32 7 files changed, 454 insertions(+), 19 deletions(-)
33 create mode 100644 drivers/mfd/twl4030-script-omap.c
34
35diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
36index 076db52..d9b9858 100644
37--- a/arch/arm/configs/omap2plus_defconfig
38+++ b/arch/arm/configs/omap2plus_defconfig
39@@ -184,6 +184,7 @@ CONFIG_TWL4030_WATCHDOG=y
40 CONFIG_MENELAUS=y
41 CONFIG_TWL4030_CORE=y
42 CONFIG_TWL4030_POWER=y
43+CONFIG_TWL4030_SCRIPT=m
44 CONFIG_REGULATOR=y
45 CONFIG_REGULATOR_TWL4030=y
46 CONFIG_REGULATOR_TPS65023=y
47diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
48index 7b85585..7653329 100644
49--- a/arch/arm/mach-omap2/devices.c
50+++ b/arch/arm/mach-omap2/devices.c
51@@ -329,6 +329,20 @@ static void omap_init_audio(void)
52 static inline void omap_init_audio(void) {}
53 #endif
54
55+#ifdef CONFIG_ARCH_OMAP3
56+static struct platform_device omap_twl4030_script = {
57+ .name = "twl4030_script",
58+ .id = -1,
59+};
60+
61+static void omap_init_twl4030_script(void)
62+{
63+ platform_device_register(&omap_twl4030_script);
64+}
65+#else
66+static inline void omap_init_twl4030_script(void) {}
67+#endif
68+
69 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
70
71 #include <plat/mcspi.h>
72@@ -691,6 +705,7 @@ static int __init omap2_init_devices(void)
73 omap_init_sham();
74 omap_init_aes();
75 omap_init_vout();
76+ omap_init_twl4030_script();
77
78 return 0;
79 }
80diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
81index fe2370a..ea25d93 100644
82--- a/drivers/mfd/Kconfig
83+++ b/drivers/mfd/Kconfig
84@@ -204,6 +204,17 @@ config TWL4030_POWER
85 and load scripts controlling which resources are switched off/on
86 or reset when a sleep, wakeup or warm reset event occurs.
87
88+config TWL4030_SCRIPT
89+ tristate "Support TWL4030 script for OMAP3 boards"
90+ depends on TWL4030_CORE && TWL4030_POWER
91+ help
92+ Say yes here if you want to use the twl4030 power scripts
93+ for OMAP3 boards. Power bus message sequence for
94+ TWL4030 to enter sleep/wakeup/warm_reset.
95+
96+ TWL4030 power scripts which can be used by different
97+ OMAP3 boards with the power companion chip (TWL4030 series).
98+
99 config TWL4030_CODEC
100 bool
101 depends on TWL4030_CORE
102diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
103index 419caa9..53ada21 100644
104--- a/drivers/mfd/Makefile
105+++ b/drivers/mfd/Makefile
106@@ -42,6 +42,7 @@ obj-$(CONFIG_TWL4030_MADC) += twl4030-madc.o
107 obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
108 obj-$(CONFIG_TWL4030_CODEC) += twl4030-codec.o
109 obj-$(CONFIG_TWL6030_PWM) += twl6030-pwm.o
110+obj-$(CONFIG_TWL4030_SCRIPT) += twl4030-script-omap.o
111
112 obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o
113
114diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
115index 8162e43..91d5bc8 100644
116--- a/drivers/mfd/twl4030-power.c
117+++ b/drivers/mfd/twl4030-power.c
118@@ -123,7 +123,7 @@ static u8 res_config_addrs[] = {
119 [RES_MAIN_REF] = 0x94,
120 };
121
122-static int __init twl4030_write_script_byte(u8 address, u8 byte)
123+static int twl4030_write_script_byte(u8 address, u8 byte)
124 {
125 int err;
126
127@@ -137,7 +137,7 @@ out:
128 return err;
129 }
130
131-static int __init twl4030_write_script_ins(u8 address, u16 pmb_message,
132+static int twl4030_write_script_ins(u8 address, u16 pmb_message,
133 u8 delay, u8 next)
134 {
135 int err;
136@@ -157,7 +157,7 @@ out:
137 return err;
138 }
139
140-static int __init twl4030_write_script(u8 address, struct twl4030_ins *script,
141+static int twl4030_write_script(u8 address, struct twl4030_ins *script,
142 int len)
143 {
144 int err;
145@@ -182,7 +182,7 @@ static int __init twl4030_write_script(u8 address, struct twl4030_ins *script,
146 return err;
147 }
148
149-static int __init twl4030_config_wakeup3_sequence(u8 address)
150+static int twl4030_config_wakeup3_sequence(u8 address)
151 {
152 int err;
153 u8 data;
154@@ -207,7 +207,7 @@ out:
155 return err;
156 }
157
158-static int __init twl4030_config_wakeup12_sequence(u8 address)
159+static int twl4030_config_wakeup12_sequence(u8 address)
160 {
161 int err = 0;
162 u8 data;
163@@ -261,7 +261,7 @@ out:
164 return err;
165 }
166
167-static int __init twl4030_config_sleep_sequence(u8 address)
168+static int twl4030_config_sleep_sequence(u8 address)
169 {
170 int err;
171
172@@ -275,7 +275,7 @@ static int __init twl4030_config_sleep_sequence(u8 address)
173 return err;
174 }
175
176-static int __init twl4030_config_warmreset_sequence(u8 address)
177+static int twl4030_config_warmreset_sequence(u8 address)
178 {
179 int err;
180 u8 rd_data;
181@@ -323,7 +323,7 @@ out:
182 return err;
183 }
184
185-static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
186+static int twl4030_configure_resource(struct twl4030_resconfig *rconfig)
187 {
188 int rconfig_addr;
189 int err;
190@@ -415,7 +415,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
191 return 0;
192 }
193
194-static int __init load_twl4030_script(struct twl4030_script *tscript,
195+static int load_twl4030_script(struct twl4030_script *tscript,
196 u8 address)
197 {
198 int err;
199@@ -510,8 +510,9 @@ int twl4030_remove_script(u8 flags)
200
201 return err;
202 }
203+EXPORT_SYMBOL_GPL(twl4030_remove_script);
204
205-void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
206+int twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
207 {
208 int err = 0;
209 int i;
210@@ -529,7 +530,6 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
211 TWL4030_PM_MASTER_PROTECT_KEY);
212 if (err)
213 goto unlock;
214-
215 for (i = 0; i < twl4030_scripts->num; i++) {
216 err = load_twl4030_script(twl4030_scripts->scripts[i], address);
217 if (err)
218@@ -552,18 +552,19 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
219 TWL4030_PM_MASTER_PROTECT_KEY);
220 if (err)
221 pr_err("TWL4030 Unable to relock registers\n");
222- return;
223+ return err;
224
225 unlock:
226 if (err)
227 pr_err("TWL4030 Unable to unlock registers\n");
228- return;
229+ return err;
230 load:
231 if (err)
232 pr_err("TWL4030 failed to load scripts\n");
233- return;
234+ return err;
235 resource:
236 if (err)
237 pr_err("TWL4030 failed to configure resource\n");
238- return;
239+ return err;
240 }
241+EXPORT_SYMBOL_GPL(twl4030_power_init);
242diff --git a/drivers/mfd/twl4030-script-omap.c b/drivers/mfd/twl4030-script-omap.c
243new file mode 100644
244index 0000000..867a442
245--- /dev/null
246+++ b/drivers/mfd/twl4030-script-omap.c
247@@ -0,0 +1,373 @@
248+/*
249+ * OMAP power script for PMIC TWL4030
250+ *
251+ * Author: Lesly A M <leslyam@ti.com>
252+ *
253+ * Copyright (C) 2010 Texas Instruments, Inc.
254+ * Lesly A M <leslyam@ti.com>
255+ *
256+ * This program is free software; you can redistribute it and/or modify
257+ * it under the terms of the GNU General Public License version 2 as
258+ * published by the Free Software Foundation.
259+ */
260+
261+#include <linux/kernel.h>
262+#include <linux/module.h>
263+#include <linux/platform_device.h>
264+
265+#include <linux/i2c/twl.h>
266+
267+/*
268+ * power management signal connections for OMAP3430 with TWL5030
269+ *
270+ * TWL5030 OMAP3430
271+ * ______________________ _____________________
272+ * | | | |
273+ * | (P1) NSLEEP1|<----------|SYS_OFFMODE |
274+ * | NRESWARM|<----------|NWARMRESET |
275+ * | (P2) NSLEEP2|---| | |
276+ * | | === | |
277+ * | | - | |
278+ * | | | |
279+ * | VDD1 |---------->| VDD1 |
280+ * | VDD2 |---------->| VDD2 |
281+ * | VIO |---------->| VDDS |
282+ * ________ | VAUX1 | | |
283+ * | | | ... | | |
284+ * | ENABLE|<--------|CLKEN CLKREQ|<----------|SYS_CLKREQ |
285+ * | CLKOUT|-------->|HFCLKIN (P3) HFCLKOUT|---------->|XTALIN |
286+ * |________| |______________________| |_____________________|
287+ *
288+ *
289+ * Signal descriptions:
290+ *
291+ * SYS_OFFMODE - OMAP drives this signal low only when the OMAP is in the
292+ * OFF idle mode. It is driven high when a wake up event is detected.
293+ * This signal should control the P1 device group in the PMIC.
294+ *
295+ * SYS_CLKREQ - OMAP should drive this signal low when the OMAP goes into
296+ * any idle mode. This signal should control the P3 device group
297+ * in the PMIC. It is used to notify PMIC when XTALIN is no longer needed.
298+ *
299+ * NSLEEP1(P1) - When this signal goes low the P1 sleep sequence is executed
300+ * in the PMIC turning off certain resources. When this signal goes high
301+ * the P1 active sequence is executed turning back on certain resources.
302+ *
303+ * NSLEEP2(P2) - This signal controls the P2 device group of the PMIC.
304+ * It is not used in this setup and should be tied to ground.
305+ * This can be used for connecting a different processor or MODEM chip.
306+ *
307+ * CLKREQ(P3) - When this signal goes low the P3 sleep sequence is executed
308+ * in the PMIC turning off HFCLKOUT. When this signal goes high
309+ * the P3 active sequence is executed turning back on HFCLKOUT and other
310+ * resources.
311+ *
312+ * CLKEN - Enable signal for oscillator. Should only go low when OMAP is
313+ * in the OFF idle mode due to long oscillator startup times.
314+ *
315+ * HFCLKIN - Oscillator output clock into PMIC.
316+ *
317+ * HFCLKOUT - System clock output from PMIC to OMAP.
318+ *
319+ * XTALIN - OMAP system clock input(HFCLKOUT).
320+ */
321+
322+/*
323+ * Recommended sleep and active sequences for TWL5030 when connected to OMAP3
324+ *
325+ * WARNING: If the board is using NSLEEP2(P2), should modify this script and
326+ * setuptime values accordingly.
327+ *
328+ * Chip Retention/Off (using i2c for scaling voltage):
329+ * When OMAP de-assert the SYS_CLKREQ signal, only HFCLKOUT is affected
330+ * since it is the only resource assigned to P3 only.
331+ *
332+ * Sysoff (using sys_off signal):
333+ * When OMAP de-assert the SYS_OFFMODE signal A2S(active to sleep sequence)
334+ * on the PMIC is executed. This will put resources of TYPE2=1 and TYPE2=2
335+ * into sleep. At this point only resources assigned to P1 only will be
336+ * affected (VDD1, VDD2 & VPLL1).
337+ *
338+ * Next the OMAP will lower SYS_CLKREQ which will allow the A2S sequence
339+ * in PMIC to execute again. This will put resources of TYPE2=1 and TYPE2=2
340+ * into sleep but will affect resources that are assigned to P3(HFCLKOUT)
341+ * only or assigned to P1 and P3.
342+ *
343+ * On wakeup event OMAP goes active and pulls the SYS_CLKREQ high,
344+ * which will execute the P3 S2A sequence on the PMIC. This will turn on
345+ * resources assigned to P3 or assigned to P1 and P3 and of TYPE2=2.
346+ *
347+ * Next the OMAP will wait the PRM_VOLTOFFSET time and then de-assert
348+ * the SYS_OFFMODE pin allowing the PMIC to execute the P1 S2A active
349+ * sequence. This will turn on resources assigned to P1 or assigned to
350+ * P1 and P3 and of TYPE2=1.
351+ *
352+ * Timing diagram for OMAP wakeup from OFFMODE using sys_off signal
353+ * _____________________________________________________________
354+ * OMAP active __/
355+ * |<--------------------PRM_CLKSETP-------------------->|
356+ * ______________________________________________________
357+ * SYS_CLKREQ _________/
358+ * ___________________________________________________
359+ * CLKEN ____________/
360+ *
361+ * HFCLKIN _______________________________________________/////////////////
362+ *
363+ * HFCLKOUT __________________________________________________//////////////
364+ * |<---PRM_VOLTOFFSET-->|
365+ * ________________________________
366+ * SYS_OFFMODE _______________________________/
367+ * |<--------PRM_VOLTSETUP2------->|
368+ * ___________
369+ * VPLL1 ____________________________________________________/
370+ * __
371+ * VDD1 _____________________________________________________________/
372+ * __
373+ * VDD2 _____________________________________________________________/
374+ *
375+ * Other resources which are not handled by this script should be
376+ * controlled by the respective drivers using them (VAUX1, VAUX2, VAUX3,
377+ * VAUX4, VMMC1, VMMC2, VPLL2, VSIM, VDAC, VUSB1V5, VUSB1V8 & VUSB3V1).
378+ *
379+ * More info:
380+ * http://omapedia.org/wiki/TWL4030_power_scripts
381+ */
382+
383+/**
384+ * DOC: Sleep to active sequence for P1/P2
385+ *
386+ * Sequence to control the TWL4030 Power resources,
387+ * when the system wakeup from sleep.
388+ * Executed upon P1_P2 transition for wakeup
389+ * (sys_offmode signal de-asserted on OMAP).
390+ */
391+static struct twl4030_ins wakeup_p12_seq[] __initdata = {
392+ /*
393+ * Broadcast message to put resources to active
394+ *
395+ * Since we are not using TYPE, resources which have TYPE2 configured
396+ * as 1 will be targeted (VPLL1, VDD1, VDD2, REGEN, NRES_PWRON, SYSEN).
397+ */
398+ {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
399+ RES_STATE_ACTIVE), 2},
400+};
401+
402+static struct twl4030_script wakeup_p12_script __initdata = {
403+ .script = wakeup_p12_seq,
404+ .size = ARRAY_SIZE(wakeup_p12_seq),
405+ .flags = TWL4030_WAKEUP12_SCRIPT,
406+};
407+
408+/**
409+ * DOC: Sleep to active sequence for P3
410+ *
411+ * Sequence to control the TWL4030 Power resources,
412+ * when the system wakeup from sleep.
413+ * Executed upon P3 transition for wakeup
414+ * (clkreq signal asserted on OMAP).
415+ */
416+static struct twl4030_ins wakeup_p3_seq[] __initdata = {
417+ /*
418+ * Broadcast message to put resources to active
419+ *
420+ * Since we are not using TYPE, resources which have TYPE2 configured
421+ * as 2 will be targeted
422+ * (VINTANA1, VINTANA2, VINTDIG, VIO, CLKEN, HFCLKOUT).
423+ */
424+ {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
425+ RES_STATE_ACTIVE), 2},
426+};
427+
428+static struct twl4030_script wakeup_p3_script __initdata = {
429+ .script = wakeup_p3_seq,
430+ .size = ARRAY_SIZE(wakeup_p3_seq),
431+ .flags = TWL4030_WAKEUP3_SCRIPT,
432+};
433+
434+/**
435+ * DOC: Active to sleep sequence for P1/P2/P3
436+ *
437+ * Sequence to control the TWL4030 Power resources,
438+ * when the system goes into sleep.
439+ * Executed upon P1_P2/P3 transition for sleep.
440+ * (sys_offmode signal asserted/clkreq de-asserted on OMAP).
441+ */
442+static struct twl4030_ins sleep_on_seq[] __initdata = {
443+ /* Broadcast message to put res to sleep (TYPE2 = 1, 2) */
444+ {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
445+ RES_STATE_SLEEP), 2},
446+ {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
447+ RES_STATE_SLEEP), 2},
448+};
449+
450+static struct twl4030_script sleep_on_script __initdata = {
451+ .script = sleep_on_seq,
452+ .size = ARRAY_SIZE(sleep_on_seq),
453+ .flags = TWL4030_SLEEP_SCRIPT,
454+};
455+
456+/**
457+ * DOC: Warm reset sequence
458+ *
459+ * Sequence to reset the TWL4030 Power resources,
460+ * when the system gets warm reset.
461+ * Executed upon warm reset signal.
462+ *
463+ * First the device is put in reset, then the system clock is requested to
464+ * the external oscillator, and default ON power reference and power providers
465+ * are enabled. Next some additional resources which are software controlled
466+ * are enabled. Finally sequence is ended by the release of TWL5030 reset.
467+ */
468+static struct twl4030_ins wrst_seq[] __initdata = {
469+ /*
470+ * As a workaround for OMAP Erratum (ID: i537 - OMAP HS devices are
471+ * not recovering from warm reset while in OFF mode)
472+ * NRESPWRON is toggled to force a power on reset condition to OMAP
473+ */
474+ /* Trun OFF NRES_PWRON */
475+ {MSG_SINGULAR(DEV_GRP_NULL, RES_NRES_PWRON, RES_STATE_OFF), 2},
476+ /* Reset twl4030 */
477+ {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
478+ /* Reset MAIN_REF */
479+ {MSG_SINGULAR(DEV_GRP_NULL, RES_MAIN_REF, RES_STATE_WRST), 2},
480+ /* Reset All type2_group2 */
481+ {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
482+ RES_STATE_WRST), 2},
483+ /* Reset VUSB_3v1 */
484+ {MSG_SINGULAR(DEV_GRP_NULL, RES_VUSB_3V1, RES_STATE_WRST), 2},
485+ /* Reset All type2_group1 */
486+ {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
487+ RES_STATE_WRST), 2},
488+ /* Reset the Reset & Contorl_signals */
489+ {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0,
490+ RES_STATE_WRST), 2},
491+ /* Re-enable twl4030 */
492+ {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
493+ /* Trun ON NRES_PWRON */
494+ {MSG_SINGULAR(DEV_GRP_NULL, RES_NRES_PWRON, RES_STATE_ACTIVE), 2},
495+};
496+
497+static struct twl4030_script wrst_script __initdata = {
498+ .script = wrst_seq,
499+ .size = ARRAY_SIZE(wrst_seq),
500+ .flags = TWL4030_WRST_SCRIPT,
501+};
502+
503+/* TWL4030 script for sleep, wakeup & warm_reset */
504+static struct twl4030_script *twl4030_scripts[] __initdata = {
505+ &wakeup_p12_script,
506+ &wakeup_p3_script,
507+ &sleep_on_script,
508+ &wrst_script,
509+};
510+
511+/**
512+ * DOC: TWL4030 resource configuration
513+ *
514+ * Resource which are attached to P1 device group alone
515+ * will go to sleep state, when sys_off signal from OMAP is de-asserted.
516+ * (VPLL1, VDD1, VDD2)
517+ *
518+ * None of the resources are attached to P2 device group alone.
519+ * (WARNING: If MODEM or connectivity chip is connected to NSLEEP2 PIN on
520+ * TWL4030, should modify the resource configuration accordingly).
521+ *
522+ * Resource which are attached to P3 device group alone
523+ * will go to sleep state, when clk_req signal from OMAP is de-asserted.
524+ * (HFCLKOUT)
525+ *
526+ * Resource which are attached to more than one device group
527+ * will go to sleep state, when corresponding signals are de-asserted.
528+ * (VINTANA1, VINTANA2, VINTDIG, VIO, REGEN, NRESPWRON, CLKEN, SYSEN)
529+ *
530+ * REGEN is an output of the device which can be connected to slave power ICs
531+ * or external LDOs that power on before voltage for the IO interface (VIO).
532+ *
533+ * SYSEN is a bidirectional signal of the device that controls slave power ICs.
534+ * In master mode, the device sets SYSEN high to enable the slave power ICs.
535+ * In slave mode, when one of the power ICs drives the SYSEN signal low,
536+ * all devices of the platform stay in the wait-on state.
537+ *
538+ * Resource which are attached to none of the device group by default
539+ * will be in sleep state. These resource should be controlled by
540+ * the respective drivers using them.
541+ * Resource which are controlled by drivers are not modified here.
542+ * (VAUX1, VAUX2, VAUX3, VAUX4, VMMC1, VMMC2, VPLL2, VSIM, VDAC,
543+ * VUSB1V5, VUSB1V8, VUSB3V1)
544+ *
545+ * Resource using reset values.
546+ * (32KCLKOUT, TRITON_RESET, MAINREF)
547+ */
548+static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
549+ { .resource = RES_VPLL1, .devgroup = DEV_GRP_P1, .type = 3,
550+ .type2 = 1, .remap_sleep = RES_STATE_OFF },
551+ { .resource = RES_VINTANA1, .devgroup = DEV_GRP_ALL, .type = 1,
552+ .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
553+ { .resource = RES_VINTANA2, .devgroup = DEV_GRP_ALL, .type = 0,
554+ .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
555+ { .resource = RES_VINTDIG, .devgroup = DEV_GRP_ALL, .type = 1,
556+ .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
557+ { .resource = RES_VIO, .devgroup = DEV_GRP_ALL, .type = 2,
558+ .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
559+ { .resource = RES_VDD1, .devgroup = DEV_GRP_P1,
560+ .type = 4, .type2 = 1, .remap_sleep = RES_STATE_OFF },
561+ { .resource = RES_VDD2, .devgroup = DEV_GRP_P1,
562+ .type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
563+ { .resource = RES_REGEN, .devgroup = DEV_GRP_ALL, .type = 2,
564+ .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
565+ { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_ALL, .type = 0,
566+ .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
567+ { .resource = RES_CLKEN, .devgroup = DEV_GRP_ALL, .type = 3,
568+ .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
569+ { .resource = RES_SYSEN, .devgroup = DEV_GRP_ALL, .type = 6,
570+ .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
571+ { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
572+ .type = 0, .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
573+ { 0, 0},
574+};
575+
576+struct twl4030_power_data twl4030_generic_script __initdata = {
577+ .scripts = twl4030_scripts,
578+ .num = ARRAY_SIZE(twl4030_scripts),
579+ .resource_config = twl4030_rconfig,
580+};
581+
582+static int __init twl4030_script_probe(struct platform_device *pdev)
583+{
584+ return twl4030_power_init(&twl4030_generic_script);
585+}
586+
587+static int twl4030_script_remove(struct platform_device *pdev)
588+{
589+ return twl4030_remove_script(TWL4030_SLEEP_SCRIPT |
590+ TWL4030_WAKEUP12_SCRIPT | TWL4030_WAKEUP3_SCRIPT |
591+ TWL4030_WRST_SCRIPT);
592+}
593+
594+static struct platform_driver twl4030_script_driver = {
595+ .remove = twl4030_script_remove,
596+ .driver = {
597+ .name = "twl4030_script",
598+ .owner = THIS_MODULE,
599+ },
600+};
601+
602+static int __init twl4030_script_init(void)
603+{
604+ /* Register the TWL4030 script driver */
605+ return platform_driver_probe(&twl4030_script_driver,
606+ twl4030_script_probe);
607+}
608+
609+static void __exit twl4030_script_cleanup(void)
610+{
611+ /* Unregister TWL4030 script driver */
612+ platform_driver_unregister(&twl4030_script_driver);
613+}
614+
615+module_init(twl4030_script_init);
616+module_exit(twl4030_script_cleanup);
617+
618+MODULE_DESCRIPTION("OMAP TWL4030 script driver");
619+MODULE_LICENSE("GPL");
620+MODULE_AUTHOR("Texas Instruments Inc");
621diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
622index aee3a22..f343974 100644
623--- a/include/linux/i2c/twl.h
624+++ b/include/linux/i2c/twl.h
625@@ -205,6 +205,12 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
626 return -EIO;
627 }
628 #endif
629+
630+#ifdef CONFIG_TWL4030_POWER
631+extern struct twl4030_power_data twl4030_generic_script;
632+#else
633+#define twl4030_generic_script NULL;
634+#endif
635 /*----------------------------------------------------------------------*/
636
637 /*
638@@ -437,9 +443,23 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
639
640 /* Power bus message definitions */
641
642-/* The TWL4030/5030 splits its power-management resources (the various
643- * regulators, clock and reset lines) into 3 processor groups - P1, P2 and
644- * P3. These groups can then be configured to transition between sleep, wait-on
645+/*
646+ * The TWL4030/5030 splits its power-management resources (the various
647+ * regulators, clock and reset lines) into 3 processor groups - P1, P2 and P3.
648+ *
649+ * Resources attached to device group P1 is managed depending on the state of
650+ * NSLEEP1 pin of TWL4030, which is connected to sys_off signal from OMAP
651+ *
652+ * Resources attached to device group P2 is managed depending on the state of
653+ * NSLEEP2 pin of TWL4030, which is can be connected to a modem or
654+ * connectivity chip
655+ *
656+ * Resources attached to device group P3 is managed depending on the state of
657+ * CLKREQ pin of TWL4030, which is connected to clk request signal from OMAP
658+ *
659+ * If required these resources can be attached to combination of P1/P2/P3.
660+ *
661+ * These groups can then be configured to transition between sleep, wait-on
662 * and active states by sending messages to the power bus. See Section 5.4.2
663 * Power Resources of TWL4030 TRM
664 */
665@@ -449,7 +469,17 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
666 #define DEV_GRP_P1 0x1 /* P1: all OMAP devices */
667 #define DEV_GRP_P2 0x2 /* P2: all Modem devices */
668 #define DEV_GRP_P3 0x4 /* P3: all peripheral devices */
669+#define DEV_GRP_ALL 0x7 /* P1/P2/P3: all devices */
670
671+/*
672+ * The 27 power resources in TWL4030 is again divided into
673+ * analog resources:
674+ * Power Providers - LDO regulators, dc-to-dc regulators
675+ * Power Reference - analog reference
676+ *
677+ * and digital resources:
678+ * Reset & Clock - reset and clock signals.
679+ */
680 /* Resource groups */
681 #define RES_GRP_RES 0x0 /* Reserved */
682 #define RES_GRP_PP 0x1 /* Power providers */
683@@ -461,7 +491,10 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
684 #define RES_GRP_ALL 0x7 /* All resource groups */
685
686 #define RES_TYPE2_R0 0x0
687+#define RES_TYPE2_R1 0x1
688+#define RES_TYPE2_R2 0x2
689
690+#define RES_TYPE_R0 0x0
691 #define RES_TYPE_ALL 0x7
692
693 /* Resource states */
694@@ -636,7 +669,7 @@ struct twl4030_power_data {
695 #define TWL4030_RESCONFIG_UNDEF ((u8)-1)
696 };
697
698-extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
699+extern int twl4030_power_init(struct twl4030_power_data *triton2_scripts);
700 extern int twl4030_remove_script(u8 flags);
701
702 struct twl4030_codec_audio_data {
703--
7041.6.6.1
705