1 From ecb5c96f7da9b081efe3c731a0c7b052c2411536 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Wed, 2 Jul 2008 22:39:17 +0100
4 Subject: [PATCH] fix-glamo-mci-relationship-with-pcf50633-suspend-resume.patch
6 After protecting pcf50633 read and write primitives against
7 operation after suspend or before resume (by blowing a
8 stack_trace()) I saw glamo-mci was trying to use pcf50633
9 at these bad times on its own suspend and resume. Since that
10 part was already done via platform callback, I added an
11 export in pcf50633 that tells you if it is ready or busy,
12 and used it to defer (resume power on case) or ignore
13 (suspend power off case, since pcf50633 already did it)
16 Signed-off-by: Andy Green <andy@openmoko.com>
18 arch/arm/mach-s3c2440/mach-gta02.c | 17 ++++++++++-------
19 drivers/i2c/chips/pcf50633.c | 14 ++++++++++++++
20 include/linux/pcf50633.h | 5 +++++
21 3 files changed, 29 insertions(+), 7 deletions(-)
23 diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
24 index 22de181..5980ea9 100644
25 --- a/arch/arm/mach-s3c2440/mach-gta02.c
26 +++ b/arch/arm/mach-s3c2440/mach-gta02.c
27 @@ -1277,13 +1277,12 @@ gta02_glamo_mmc_set_power(unsigned char power_mode, unsigned short vdd)
28 case GTA02v4_SYSTEM_REV:
29 case GTA02v5_SYSTEM_REV:
30 case GTA02v6_SYSTEM_REV:
31 - /* depend on pcf50633 driver init */
32 - if (!pcf50633_global)
33 - while (!pcf50633_global)
38 + /* depend on pcf50633 driver init + not suspended */
39 + while (pcf50633_ready(pcf50633_global))
41 /* select and set the voltage */
43 mv += 300 + 100 * (vdd - 8);
44 @@ -1292,15 +1291,19 @@ gta02_glamo_mmc_set_power(unsigned char power_mode, unsigned short vdd)
46 pcf50633_voltage_set(pcf50633_global,
47 PCF50633_REGULATOR_HCLDO, mv);
49 pcf50633_onoff_set(pcf50633_global,
50 PCF50633_REGULATOR_HCLDO, 1);
54 + /* power off happens during suspend, when pcf50633 can
55 + * be already gone and not coming back... just forget
56 + * the action then because pcf50633 suspend already
57 + * dealt with it, otherwise we spin forever
59 + if (pcf50633_ready(pcf50633_global))
61 pcf50633_onoff_set(pcf50633_global,
62 PCF50633_REGULATOR_HCLDO, 0);
67 diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
68 index 8cb6156..4d92c84 100644
69 --- a/drivers/i2c/chips/pcf50633.c
70 +++ b/drivers/i2c/chips/pcf50633.c
71 @@ -2240,6 +2240,20 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state)
76 +int pcf50633_ready(struct pcf50633_data *pcf)
81 + if (pcf->have_been_suspended)
86 +EXPORT_SYMBOL_GPL(pcf50633_ready);
90 * if backlight resume is selected to be deferred by platform, then it
91 * can call this to finally reset backlight status (after LCM is resumed
92 diff --git a/include/linux/pcf50633.h b/include/linux/pcf50633.h
93 index 8a75b28..0522d92 100644
94 --- a/include/linux/pcf50633.h
95 +++ b/include/linux/pcf50633.h
96 @@ -129,6 +129,11 @@ extern void
97 pcf50633_register_resume_dependency(struct pcf50633_data *pcf,
98 struct resume_dependency *dep);
100 +/* 0 = initialized and resumed and ready to roll, !=0 = either not
101 + * initialized or not resumed yet
104 +pcf50633_ready(struct pcf50633_data *pcf);
106 #define PCF50633_FEAT_EXTON 0x00000001 /* not yet supported */
107 #define PCF50633_FEAT_MBC 0x00000002