changed Makefile and profiles, added patches for kernel 2.6.24
[openwrt/svn-archive/archive.git] / target / linux / s3c24xx / patches-2.6.26 / 0003-fix-i2c-s3c2410-resume-race.patch.patch
1 From eb5cadc7ff0e6c3aedfec3323146d7bb6bdfe0f0 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Wed, 16 Jul 2008 14:44:10 +0100
4 Subject: [PATCH] fix-i2c-s3c2410-resume-race.patch
5 fix-i2c-s3c2410-resume-race.patch
6
7 There is a nasty race between i2c-s3c2410 resume and resume of I2C
8 driver and the client drivers -- the watchdog device actually gets to
9 use the dead I2C bus before it is reinitialized by the I2C driver
10 resume! This patch makes sure any customers get turned away until
11 the shopkeeper has woken up.
12
13 Signed-off-by: Andy Green <andy@openmoko.com>
14 ---
15 drivers/i2c/busses/i2c-s3c2410.c | 33 +++++++++++++++++++++++++++++++++
16 1 files changed, 33 insertions(+), 0 deletions(-)
17
18 diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
19 index 9e8c875..02459d7 100644
20 --- a/drivers/i2c/busses/i2c-s3c2410.c
21 +++ b/drivers/i2c/busses/i2c-s3c2410.c
22 @@ -71,6 +71,8 @@ struct s3c24xx_i2c {
23 struct resource *irq;
24 struct resource *ioarea;
25 struct i2c_adapter adap;
26 +
27 + int suspended;
28 };
29
30 /* default platform data to use if not supplied in the platform_device
31 @@ -156,6 +158,14 @@ static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
32 unsigned long tmp;
33
34 tmp = readl(i2c->regs + S3C2410_IICCON);
35 +
36 +/* S3c2442 datasheet
37 + *
38 + * If the IICCON[5]=0, IICCON[4] does not operate correctly.
39 + * So, It is recommended that you should set IICCON[5]=1,
40 + * although you does not use the IIC interrupt.
41 + */
42 +
43 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
44 }
45
46 @@ -501,6 +511,14 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
47 unsigned long timeout;
48 int ret;
49
50 + if (i2c->suspended) {
51 + dev_err(i2c->dev,
52 + "Hey I am still asleep (suspended: %d), retry later\n",
53 + i2c->suspended);
54 + ret = -EAGAIN;
55 + goto out;
56 + }
57 +
58 ret = s3c24xx_i2c_set_master(i2c);
59 if (ret != 0) {
60 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret);
61 @@ -885,6 +903,17 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
62 }
63
64 #ifdef CONFIG_PM
65 +
66 +static int s3c24xx_i2c_suspend(struct platform_device *dev, pm_message_t state)
67 +{
68 + struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
69 +
70 + if (i2c != NULL)
71 + i2c->suspended++;
72 +
73 + return 0;
74 +}
75 +
76 static int s3c24xx_i2c_resume(struct platform_device *dev)
77 {
78 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
79 @@ -892,6 +921,8 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
80 if (i2c != NULL)
81 s3c24xx_i2c_init(i2c);
82
83 + i2c->suspended--;
84 +
85 return 0;
86 }
87
88 @@ -904,6 +935,7 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
89 static struct platform_driver s3c2410_i2c_driver = {
90 .probe = s3c24xx_i2c_probe,
91 .remove = s3c24xx_i2c_remove,
92 + .suspend = s3c24xx_i2c_suspend,
93 .resume = s3c24xx_i2c_resume,
94 .driver = {
95 .owner = THIS_MODULE,
96 @@ -914,6 +946,7 @@ static struct platform_driver s3c2410_i2c_driver = {
97 static struct platform_driver s3c2440_i2c_driver = {
98 .probe = s3c24xx_i2c_probe,
99 .remove = s3c24xx_i2c_remove,
100 + .suspend = s3c24xx_i2c_suspend,
101 .resume = s3c24xx_i2c_resume,
102 .driver = {
103 .owner = THIS_MODULE,
104 --
105 1.5.6.3
106