aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2014-05-28 03:44:42 -0400
committerWolfram Sang <wsa@the-dreams.de>2014-06-01 16:22:42 -0400
commit3c95de674496e08d3b373f85af4aa59c23ddb8d6 (patch)
tree52b61accc660d2a0eed134564a52098df6241cd9
parent386babf8e2f7dd483f88e5c0c4c761346b750185 (diff)
i2c: rcar: refactor status bit handling
The old macros made it harder to see what was actually happening. Replace them with something more readable. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-rcar.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 42005ccd3254..07256a6b56fa 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -87,6 +87,9 @@
87#define RCAR_IRQ_RECV (MNRE | MALE | MSTE | MATE | MDRE) 87#define RCAR_IRQ_RECV (MNRE | MALE | MSTE | MATE | MDRE)
88#define RCAR_IRQ_STOP (MSTE) 88#define RCAR_IRQ_STOP (MSTE)
89 89
90#define RCAR_IRQ_ACK_SEND (~(MAT | MDE))
91#define RCAR_IRQ_ACK_RECV (~(MAT | MDR))
92
90/* 93/*
91 * flags 94 * flags
92 */ 95 */
@@ -268,27 +271,18 @@ scgd_find:
268 * status functions 271 * status functions
269 */ 272 */
270 273
271#define rcar_i2c_status_clear(priv) rcar_i2c_status_bit_clear(priv, 0xffffffff)
272static void rcar_i2c_status_bit_clear(struct rcar_i2c_priv *priv, u32 bit)
273{
274 rcar_i2c_write(priv, ICMSR, ~bit);
275}
276
277static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) 274static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
278{ 275{
279 int read = !!rcar_i2c_is_recv(priv); 276 int read = !!rcar_i2c_is_recv(priv);
280 277
281 rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read); 278 rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read);
282 rcar_i2c_status_clear(priv); 279 rcar_i2c_write(priv, ICMSR, 0);
283 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); 280 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
284 rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND); 281 rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND);
285 282
286 return 0; 283 return 0;
287} 284}
288 285
289#define rcar_i2c_send_restart(priv) rcar_i2c_status_bit_clear(priv, (MAT | MDE))
290#define rcar_i2c_recv_restart(priv) rcar_i2c_status_bit_clear(priv, (MAT | MDR))
291
292/* 286/*
293 * interrupt functions 287 * interrupt functions
294 */ 288 */
@@ -348,7 +342,7 @@ static int rcar_i2c_irq_send(struct rcar_i2c_priv *priv, u32 msr)
348 return ID_DONE; 342 return ID_DONE;
349 } 343 }
350 344
351 rcar_i2c_send_restart(priv); 345 rcar_i2c_write(priv, ICMSR, RCAR_IRQ_ACK_SEND);
352 346
353 return 0; 347 return 0;
354} 348}
@@ -389,7 +383,7 @@ static int rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
389 else 383 else
390 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA); 384 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
391 385
392 rcar_i2c_recv_restart(priv); 386 rcar_i2c_write(priv, ICMSR, RCAR_IRQ_ACK_RECV);
393 387
394 return 0; 388 return 0;
395} 389}
@@ -452,7 +446,7 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
452out: 446out:
453 if (rcar_i2c_flags_has(priv, ID_DONE)) { 447 if (rcar_i2c_flags_has(priv, ID_DONE)) {
454 rcar_i2c_write(priv, ICMIER, 0); 448 rcar_i2c_write(priv, ICMIER, 0);
455 rcar_i2c_status_clear(priv); 449 rcar_i2c_write(priv, ICMSR, 0);
456 wake_up(&priv->wait); 450 wake_up(&priv->wait);
457 } 451 }
458 452