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
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.
13 Signed-off-by: Andy Green <andy@openmoko.com>
15 drivers/i2c/busses/i2c-s3c2410.c | 33 +++++++++++++++++++++++++++++++++
16 1 files changed, 33 insertions(+), 0 deletions(-)
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 {
24 struct resource *ioarea;
25 struct i2c_adapter adap;
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)
34 tmp = readl(i2c->regs + S3C2410_IICCON);
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.
43 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
46 @@ -501,6 +511,14 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
47 unsigned long timeout;
50 + if (i2c->suspended) {
52 + "Hey I am still asleep (suspended: %d), retry later\n",
58 ret = s3c24xx_i2c_set_master(i2c);
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)
66 +static int s3c24xx_i2c_suspend(struct platform_device *dev, pm_message_t state)
68 + struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
76 static int s3c24xx_i2c_resume(struct platform_device *dev)
78 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
79 @@ -892,6 +921,8 @@ static int s3c24xx_i2c_resume(struct platform_device *dev)
81 s3c24xx_i2c_init(i2c);
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,
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,
103 .owner = THIS_MODULE,