[ar71xx] fix GPIO function select bit definitions (based on a patch by Jonas <jmajau...
[openwrt.git] / target / linux / s3c24xx / patches-2.6.26 / 1160-fix-glamo-mci-relationship-with-pcf50633-suspend-res.patch
1 From 7af35792e1165cb9258e192ddfcb03393eb76f86 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Fri, 25 Jul 2008 23:06:12 +0100
4 Subject: [PATCH] fix-glamo-mci-relationship-with-pcf50633-suspend-resume.patch
5
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)
14 the mci power call.
15
16 Signed-off-by: Andy Green <andy@openmoko.com>
17 ---
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(-)
22
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)
34 - msleep(10);
35 switch (power_mode) {
36 case MMC_POWER_ON:
37 case MMC_POWER_UP:
38 + /* depend on pcf50633 driver init + not suspended */
39 + while (pcf50633_ready(pcf50633_global))
40 + msleep(1);
41 /* select and set the voltage */
42 if (vdd > 7) {
43 mv += 300 + 100 * (vdd - 8);
44 @@ -1292,15 +1291,19 @@ gta02_glamo_mmc_set_power(unsigned char power_mode, unsigned short vdd)
45 }
46 pcf50633_voltage_set(pcf50633_global,
47 PCF50633_REGULATOR_HCLDO, mv);
48 - msleep(10);
49 pcf50633_onoff_set(pcf50633_global,
50 PCF50633_REGULATOR_HCLDO, 1);
51 - msleep(1);
52 break;
53 case MMC_POWER_OFF:
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
58 + */
59 + if (pcf50633_ready(pcf50633_global))
60 + return;
61 pcf50633_onoff_set(pcf50633_global,
62 PCF50633_REGULATOR_HCLDO, 0);
63 - msleep(1);
64 break;
65 }
66 break;
67 diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
68 index c148ea7..82ee2f0 100644
69 --- a/drivers/i2c/chips/pcf50633.c
70 +++ b/drivers/i2c/chips/pcf50633.c
71 @@ -2230,6 +2230,20 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state)
72 return 0;
73 }
74
75 +
76 +int pcf50633_ready(struct pcf50633_data *pcf)
77 +{
78 + if (!pcf)
79 + return -EBUSY;
80 +
81 + if (pcf->have_been_suspended)
82 + return -EBUSY;
83 +
84 + return 0;
85 +}
86 +EXPORT_SYMBOL_GPL(pcf50633_ready);
87 +
88 +
89 /*
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);
99
100 +/* 0 = initialized and resumed and ready to roll, !=0 = either not
101 + * initialized or not resumed yet
102 + */
103 +extern int
104 +pcf50633_ready(struct pcf50633_data *pcf);
105
106 #define PCF50633_FEAT_EXTON 0x00000001 /* not yet supported */
107 #define PCF50633_FEAT_MBC 0x00000002
108 --
109 1.5.6.3
110
This page took 0.072939 seconds and 5 git commands to generate.