Skip to contentSkip to conversation

i2c: s3c2410 : Add polling mode support

PATCH Superseded Yuvaraj Kumar C D 2 participants 2 messages Oct 1, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: s3c2410 : Add polling mode support

From: Vasanth Ananthan <[email protected]>

This patch adds polling mode support for i2c-s3c2410 driver.The SATA PHY controller's CMU and TRSV block's are of I2C register map in exynos5250.These blocks can be configured using i2c.

But i2c controller instance on which these block's sits lacks an interrupt line.Also the current i2c-s3c2410 driver is only interrupt driven, thus a polling mode support is required in the driver for supporting this controller. This patch adds this support to the driver.

---
 .../devicetree/bindings/i2c/i2c-s3c2410.txt        |    2 +
 drivers/i2c/busses/i2c-s3c2410.c                   |   68 ++++++++++++++++----
 2 files changed, 59 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/i2c/i2c-s3c2410.txt +2 -0
index 296eb45..bc928a0 100644
@@ -10,6 +10,8 @@ Required properties:
           inside HDMIPHY block found on several samsung SoCs
       (d) "samsung, exynos5440-i2c", for s3c2440-like i2c used
 	   on EXYNOS5440 which does not need GPIO configuration.
+      (e) "samsung,exynos5-sata-phy-i2c", for s3c2440-like i2c used as
+	   a host to SATA PHY controller on an internal bus.
   - reg: physical base address of the controller and length of memory mapped
     region.
   - interrupts: interrupt number to the cpu.
drivers/i2c/busses/i2c-s3c2410.c +57 -11

124 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 i2c: s3c2410 : Add polling mode support

Quoted 5 lines · Yuvaraj Kumar C D
drivers/i2c/busses/i2c-s3c2410.c +5 -0
+static bool is_ack(struct s3c24xx_i2c *i2c)
+{
+	u32 time_out = i2c->tx_setup;
+
+	while (--time_out) {

drivers/i2c/busses/i2c-s3c2410.c static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c) · line 247

Quoted 10 lines
drivers/i2c/busses/i2c-s3c2410.c +10 -0
+		if (readl(i2c->regs + S3C2410_IICCON)
+			& S3C2410_IICCON_IRQPEND) {
+			if (!(readl(i2c->regs + S3C2410_IICSTAT)
+				& S3C2410_IICSTAT_LASTBIT))
+				return true;
+		}
+		udelay(time_out);
+	}
+
+	return false;

This is a bit weird - the amount of time the driver waits between polls shrinks as the timeout approaches. It'd be more normal to see either an even period between polls or (ideally if the delay is non-trivial) a dead reckoning sleep based on the expected time to complete followed by polling at even intervals.

Also consider usleep_range() for the delay, it's a bit nicer to the rest
of the system than udelay().
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131001/5722264d/attachment.sig>