Lines Matching +full:i2c +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Ingenic JZ4780 I2C bus driver
5 * Copyright (C) 2006 - 2009 Ingenic Semiconductor Inc.
15 #include <linux/i2c.h>
68 #define JZ4780_I2C_CTRL_SPDS BIT(1)
76 #define JZ4780_I2C_STA_TFNF BIT(1)
91 #define JZ4780_I2C_INTST_RXOF BIT(1)
104 #define JZ4780_I2C_INTM_MRXOF BIT(1)
113 #define JZ4780_I2CSHCNT_ADJUST(n) (((n) - 8) < 6 ? 6 : ((n) - 8))
114 #define JZ4780_I2CSLCNT_ADJUST(n) (((n) - 1) < 8 ? 8 : ((n) - 1))
115 #define JZ4780_I2CFHCNT_ADJUST(n) (((n) - 8) < 6 ? 6 : ((n) - 8))
116 #define JZ4780_I2CFLCNT_ADJUST(n) (((n) - 1) < 8 ? 8 : ((n) - 1))
171 static inline unsigned short jz4780_i2c_readw(struct jz4780_i2c *i2c, in jz4780_i2c_readw() argument
174 return readw(i2c->iomem + offset); in jz4780_i2c_readw()
177 static inline void jz4780_i2c_writew(struct jz4780_i2c *i2c, in jz4780_i2c_writew() argument
180 writew(val, i2c->iomem + offset); in jz4780_i2c_writew()
183 static int jz4780_i2c_disable(struct jz4780_i2c *i2c) in jz4780_i2c_disable() argument
188 jz4780_i2c_writew(i2c, JZ4780_I2C_ENB, 0); in jz4780_i2c_disable()
191 regval = jz4780_i2c_readw(i2c, JZ4780_I2C_ENSTA); in jz4780_i2c_disable()
196 } while (--loops); in jz4780_i2c_disable()
198 dev_err(&i2c->adap.dev, "disable failed: ENSTA=0x%04x\n", regval); in jz4780_i2c_disable()
199 return -ETIMEDOUT; in jz4780_i2c_disable()
202 static int jz4780_i2c_enable(struct jz4780_i2c *i2c) in jz4780_i2c_enable() argument
207 jz4780_i2c_writew(i2c, JZ4780_I2C_ENB, 1); in jz4780_i2c_enable()
210 regval = jz4780_i2c_readw(i2c, JZ4780_I2C_ENSTA); in jz4780_i2c_enable()
215 } while (--loops); in jz4780_i2c_enable()
217 dev_err(&i2c->adap.dev, "enable failed: ENSTA=0x%04x\n", regval); in jz4780_i2c_enable()
218 return -ETIMEDOUT; in jz4780_i2c_enable()
221 static int jz4780_i2c_set_target(struct jz4780_i2c *i2c, unsigned char address) in jz4780_i2c_set_target() argument
227 regval = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); in jz4780_i2c_set_target()
233 } while (--loops); in jz4780_i2c_set_target()
236 jz4780_i2c_writew(i2c, JZ4780_I2C_TAR, address); in jz4780_i2c_set_target()
240 dev_err(&i2c->adap.dev, in jz4780_i2c_set_target()
244 return -ENXIO; in jz4780_i2c_set_target()
247 static int jz4780_i2c_set_speed(struct jz4780_i2c *i2c) in jz4780_i2c_set_speed() argument
249 int dev_clk_khz = clk_get_rate(i2c->clk) / 1000; in jz4780_i2c_set_speed()
256 int i2c_clk = i2c->speed; in jz4780_i2c_set_speed()
258 if (jz4780_i2c_disable(i2c)) in jz4780_i2c_set_speed()
259 dev_dbg(&i2c->adap.dev, "i2c not disabled\n"); in jz4780_i2c_set_speed()
262 * 1 JZ4780_I2C cycle equals to cnt_period PCLK(i2c_clk) in jz4780_i2c_set_speed()
273 cnt_low = cnt_period - cnt_high; in jz4780_i2c_set_speed()
276 * NOTE: JZ4780_I2C_CTRL_REST can't set when i2c enabled, because in jz4780_i2c_set_speed()
277 * normal read are 2 messages, we cannot disable i2c controller in jz4780_i2c_set_speed()
285 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_set_speed()
287 jz4780_i2c_writew(i2c, JZ4780_I2C_SHCNT, in jz4780_i2c_set_speed()
289 jz4780_i2c_writew(i2c, JZ4780_I2C_SLCNT, in jz4780_i2c_set_speed()
294 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_set_speed()
296 jz4780_i2c_writew(i2c, JZ4780_I2C_FHCNT, in jz4780_i2c_set_speed()
298 jz4780_i2c_writew(i2c, JZ4780_I2C_FLCNT, in jz4780_i2c_set_speed()
303 * a i2c device must internally provide a hold time at least 300ns in jz4780_i2c_set_speed()
311 * 1i2c_clk = 10^6 / dev_clk_khz in jz4780_i2c_set_speed()
312 * on FPGA, dev_clk_khz = 12000, so 1i2c_clk = 1000/12 = 83ns in jz4780_i2c_set_speed()
313 * on Pisces(1008M), dev_clk_khz=126000, so 1i2c_clk = 1000 / 126 = 8ns in jz4780_i2c_set_speed()
315 * The actual hold time is (SDAHD + 1) * (i2c_clk period). in jz4780_i2c_set_speed()
317 * Length of setup time calculated using (SDASU - 1) * (ic_clk_period) in jz4780_i2c_set_speed()
328 hold_time = ((hold_time * dev_clk_khz) / 1000000) - 1; in jz4780_i2c_set_speed()
329 setup_time = ((setup_time * dev_clk_khz) / 1000000) + 1; in jz4780_i2c_set_speed()
335 setup_time = 1; in jz4780_i2c_set_speed()
337 jz4780_i2c_writew(i2c, JZ4780_I2C_SDASU, setup_time); in jz4780_i2c_set_speed()
343 /*i2c hold time enable */ in jz4780_i2c_set_speed()
344 if (i2c->cdata->version >= ID_X1000) { in jz4780_i2c_set_speed()
345 jz4780_i2c_writew(i2c, X1000_I2C_SDAHD, hold_time); in jz4780_i2c_set_speed()
348 jz4780_i2c_writew(i2c, JZ4780_I2C_SDAHD, hold_time); in jz4780_i2c_set_speed()
352 if (i2c->cdata->version >= ID_X1000) in jz4780_i2c_set_speed()
353 jz4780_i2c_writew(i2c, X1000_I2C_SDAHD, 0); in jz4780_i2c_set_speed()
355 jz4780_i2c_writew(i2c, JZ4780_I2C_SDAHD, 0); in jz4780_i2c_set_speed()
361 static int jz4780_i2c_cleanup(struct jz4780_i2c *i2c) in jz4780_i2c_cleanup() argument
367 spin_lock_irqsave(&i2c->lock, flags); in jz4780_i2c_cleanup()
370 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_cleanup()
371 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_cleanup()
373 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_cleanup()
377 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0); in jz4780_i2c_cleanup()
380 jz4780_i2c_readw(i2c, JZ4780_I2C_CTXABRT); in jz4780_i2c_cleanup()
381 jz4780_i2c_readw(i2c, JZ4780_I2C_CINTR); in jz4780_i2c_cleanup()
384 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_cleanup()
386 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_cleanup()
389 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_cleanup()
391 spin_unlock_irqrestore(&i2c->lock, flags); in jz4780_i2c_cleanup()
393 ret = jz4780_i2c_disable(i2c); in jz4780_i2c_cleanup()
395 dev_err(&i2c->adap.dev, in jz4780_i2c_cleanup()
398 if (unlikely(jz4780_i2c_readw(i2c, JZ4780_I2C_INTM) in jz4780_i2c_cleanup()
399 & jz4780_i2c_readw(i2c, JZ4780_I2C_INTST))) in jz4780_i2c_cleanup()
400 dev_err(&i2c->adap.dev, in jz4780_i2c_cleanup()
406 static int jz4780_i2c_prepare(struct jz4780_i2c *i2c) in jz4780_i2c_prepare() argument
408 jz4780_i2c_set_speed(i2c); in jz4780_i2c_prepare()
409 return jz4780_i2c_enable(i2c); in jz4780_i2c_prepare()
412 static void jz4780_i2c_send_rcmd(struct jz4780_i2c *i2c, in jz4780_i2c_send_rcmd() argument
418 for (i = 0; i < cmd_count - 1; i++) in jz4780_i2c_send_rcmd()
419 jz4780_i2c_writew(i2c, JZ4780_I2C_DC, JZ4780_I2C_DC_READ); in jz4780_i2c_send_rcmd()
421 if ((cmd_left == 0) && (i2c->cdata->version >= ID_X1000)) in jz4780_i2c_send_rcmd()
422 jz4780_i2c_writew(i2c, JZ4780_I2C_DC, in jz4780_i2c_send_rcmd()
425 jz4780_i2c_writew(i2c, JZ4780_I2C_DC, JZ4780_I2C_DC_READ); in jz4780_i2c_send_rcmd()
428 static void jz4780_i2c_trans_done(struct jz4780_i2c *i2c) in jz4780_i2c_trans_done() argument
430 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0); in jz4780_i2c_trans_done()
431 complete(&i2c->trans_waitq); in jz4780_i2c_trans_done()
439 struct jz4780_i2c *i2c = dev_id; in jz4780_i2c_irq() local
441 spin_lock(&i2c->lock); in jz4780_i2c_irq()
442 intmsk = jz4780_i2c_readw(i2c, JZ4780_I2C_INTM); in jz4780_i2c_irq()
443 intst = jz4780_i2c_readw(i2c, JZ4780_I2C_INTST); in jz4780_i2c_irq()
448 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
453 dev_dbg(&i2c->adap.dev, "received fifo overflow!\n"); in jz4780_i2c_irq()
454 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
462 if (i2c->is_write == 0) { in jz4780_i2c_irq()
465 while ((jz4780_i2c_readw(i2c, JZ4780_I2C_STA) in jz4780_i2c_irq()
467 *(i2c->rbuf++) = jz4780_i2c_readw(i2c, JZ4780_I2C_DC) in jz4780_i2c_irq()
469 i2c->rd_data_xfered++; in jz4780_i2c_irq()
470 if (i2c->rd_data_xfered == i2c->rd_total_len) { in jz4780_i2c_irq()
471 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
476 rd_left = i2c->rd_total_len - i2c->rd_data_xfered; in jz4780_i2c_irq()
478 if (rd_left <= i2c->cdata->fifosize) in jz4780_i2c_irq()
479 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, rd_left - 1); in jz4780_i2c_irq()
483 if (i2c->is_write == 0) { in jz4780_i2c_irq()
484 int cmd_left = i2c->rd_total_len - i2c->rd_cmd_xfered; in jz4780_i2c_irq()
485 int max_send = (i2c->cdata->fifosize - 1) in jz4780_i2c_irq()
486 - (i2c->rd_cmd_xfered in jz4780_i2c_irq()
487 - i2c->rd_data_xfered); in jz4780_i2c_irq()
490 if (i2c->rd_cmd_xfered != 0) in jz4780_i2c_irq()
492 i2c->cdata->fifosize in jz4780_i2c_irq()
493 - i2c->cdata->tx_level - 1); in jz4780_i2c_irq()
496 i2c->rd_cmd_xfered += cmd_to_send; in jz4780_i2c_irq()
497 cmd_left = i2c->rd_total_len - in jz4780_i2c_irq()
498 i2c->rd_cmd_xfered; in jz4780_i2c_irq()
499 jz4780_i2c_send_rcmd(i2c, in jz4780_i2c_irq()
505 intmsk = jz4780_i2c_readw(i2c, JZ4780_I2C_INTM); in jz4780_i2c_irq()
507 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, intmsk); in jz4780_i2c_irq()
509 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_irq()
510 tmp = jz4780_i2c_readw(i2c, in jz4780_i2c_irq()
513 jz4780_i2c_writew(i2c, in jz4780_i2c_irq()
521 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); in jz4780_i2c_irq()
524 (i2c->wt_len > 0)) { in jz4780_i2c_irq()
525 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); in jz4780_i2c_irq()
526 data = *i2c->wbuf; in jz4780_i2c_irq()
528 if ((i2c->wt_len == 1) && (!i2c->stop_hold) && in jz4780_i2c_irq()
529 (i2c->cdata->version >= ID_X1000)) in jz4780_i2c_irq()
531 jz4780_i2c_writew(i2c, JZ4780_I2C_DC, data); in jz4780_i2c_irq()
532 i2c->wbuf++; in jz4780_i2c_irq()
533 i2c->wt_len--; in jz4780_i2c_irq()
536 if (i2c->wt_len == 0) { in jz4780_i2c_irq()
537 if ((!i2c->stop_hold) && (i2c->cdata->version < in jz4780_i2c_irq()
539 tmp = jz4780_i2c_readw(i2c, in jz4780_i2c_irq()
542 jz4780_i2c_writew(i2c, in jz4780_i2c_irq()
546 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
553 spin_unlock(&i2c->lock); in jz4780_i2c_irq()
557 static void jz4780_i2c_txabrt(struct jz4780_i2c *i2c, int src) in jz4780_i2c_txabrt() argument
559 dev_dbg(&i2c->adap.dev, "txabrt: 0x%08x, cmd: %d, send: %d, recv: %d\n", in jz4780_i2c_txabrt()
560 src, i2c->cmd, i2c->cmd_buf[i2c->cmd], i2c->data_buf[i2c->cmd]); in jz4780_i2c_txabrt()
563 static inline int jz4780_i2c_xfer_read(struct jz4780_i2c *i2c, in jz4780_i2c_xfer_read() argument
575 spin_lock_irqsave(&i2c->lock, flags); in jz4780_i2c_xfer_read()
577 i2c->stop_hold = 0; in jz4780_i2c_xfer_read()
578 i2c->is_write = 0; in jz4780_i2c_xfer_read()
579 i2c->rbuf = buf; in jz4780_i2c_xfer_read()
580 i2c->rd_total_len = len; in jz4780_i2c_xfer_read()
581 i2c->rd_data_xfered = 0; in jz4780_i2c_xfer_read()
582 i2c->rd_cmd_xfered = 0; in jz4780_i2c_xfer_read()
584 if (len <= i2c->cdata->fifosize) in jz4780_i2c_xfer_read()
585 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, len - 1); in jz4780_i2c_xfer_read()
587 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, i2c->cdata->rx_level); in jz4780_i2c_xfer_read()
589 jz4780_i2c_writew(i2c, JZ4780_I2C_TXTL, i2c->cdata->tx_level); in jz4780_i2c_xfer_read()
591 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, in jz4780_i2c_xfer_read()
595 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_xfer_read()
596 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_xfer_read()
598 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_xfer_read()
601 spin_unlock_irqrestore(&i2c->lock, flags); in jz4780_i2c_xfer_read()
603 time_left = wait_for_completion_timeout(&i2c->trans_waitq, in jz4780_i2c_xfer_read()
607 dev_err(&i2c->adap.dev, "irq read timeout\n"); in jz4780_i2c_xfer_read()
608 dev_dbg(&i2c->adap.dev, "send cmd count:%d %d\n", in jz4780_i2c_xfer_read()
609 i2c->cmd, i2c->cmd_buf[i2c->cmd]); in jz4780_i2c_xfer_read()
610 dev_dbg(&i2c->adap.dev, "receive data count:%d %d\n", in jz4780_i2c_xfer_read()
611 i2c->cmd, i2c->data_buf[i2c->cmd]); in jz4780_i2c_xfer_read()
612 ret = -EIO; in jz4780_i2c_xfer_read()
615 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_TXABRT); in jz4780_i2c_xfer_read()
617 jz4780_i2c_txabrt(i2c, tmp); in jz4780_i2c_xfer_read()
618 ret = -EIO; in jz4780_i2c_xfer_read()
624 static inline int jz4780_i2c_xfer_write(struct jz4780_i2c *i2c, in jz4780_i2c_xfer_write() argument
634 spin_lock_irqsave(&i2c->lock, flags); in jz4780_i2c_xfer_write()
636 if (idx < (cnt - 1)) in jz4780_i2c_xfer_write()
637 i2c->stop_hold = 1; in jz4780_i2c_xfer_write()
639 i2c->stop_hold = 0; in jz4780_i2c_xfer_write()
641 i2c->is_write = 1; in jz4780_i2c_xfer_write()
642 i2c->wbuf = buf; in jz4780_i2c_xfer_write()
643 i2c->wt_len = len; in jz4780_i2c_xfer_write()
645 jz4780_i2c_writew(i2c, JZ4780_I2C_TXTL, i2c->cdata->tx_level); in jz4780_i2c_xfer_write()
647 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, JZ4780_I2C_INTM_MTXEMP in jz4780_i2c_xfer_write()
650 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_xfer_write()
651 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_xfer_write()
653 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_xfer_write()
656 spin_unlock_irqrestore(&i2c->lock, flags); in jz4780_i2c_xfer_write()
658 time_left = wait_for_completion_timeout(&i2c->trans_waitq, in jz4780_i2c_xfer_write()
660 if (time_left && !i2c->stop_hold) { in jz4780_i2c_xfer_write()
665 for (; time_left > 0; time_left--) { in jz4780_i2c_xfer_write()
666 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); in jz4780_i2c_xfer_write()
677 dev_err(&i2c->adap.dev, "write wait timeout\n"); in jz4780_i2c_xfer_write()
678 ret = -EIO; in jz4780_i2c_xfer_write()
681 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_TXABRT); in jz4780_i2c_xfer_write()
683 jz4780_i2c_txabrt(i2c, tmp); in jz4780_i2c_xfer_write()
684 ret = -EIO; in jz4780_i2c_xfer_write()
693 int i = -EIO; in jz4780_i2c_xfer()
695 struct jz4780_i2c *i2c = adap->algo_data; in jz4780_i2c_xfer() local
697 ret = jz4780_i2c_prepare(i2c); in jz4780_i2c_xfer()
699 dev_err(&i2c->adap.dev, "I2C prepare failed\n"); in jz4780_i2c_xfer()
703 if (msg->addr != jz4780_i2c_readw(i2c, JZ4780_I2C_TAR)) { in jz4780_i2c_xfer()
704 ret = jz4780_i2c_set_target(i2c, msg->addr); in jz4780_i2c_xfer()
709 if (msg->flags & I2C_M_RD) in jz4780_i2c_xfer()
710 ret = jz4780_i2c_xfer_read(i2c, msg->buf, msg->len, in jz4780_i2c_xfer()
713 ret = jz4780_i2c_xfer_write(i2c, msg->buf, msg->len, in jz4780_i2c_xfer()
723 jz4780_i2c_cleanup(i2c); in jz4780_i2c_xfer()
742 .rx_level = JZ4780_I2C_FIFO_LEN / 2 - 1,
750 .rx_level = X1000_I2C_FIFO_LEN / 2 - 1,
754 { .compatible = "ingenic,jz4770-i2c", .data = &jz4780_i2c_config },
755 { .compatible = "ingenic,jz4780-i2c", .data = &jz4780_i2c_config },
756 { .compatible = "ingenic,x1000-i2c", .data = &x1000_i2c_config },
766 struct jz4780_i2c *i2c; in jz4780_i2c_probe() local
768 i2c = devm_kzalloc(&pdev->dev, sizeof(struct jz4780_i2c), GFP_KERNEL); in jz4780_i2c_probe()
769 if (!i2c) in jz4780_i2c_probe()
770 return -ENOMEM; in jz4780_i2c_probe()
772 i2c->cdata = device_get_match_data(&pdev->dev); in jz4780_i2c_probe()
773 if (!i2c->cdata) { in jz4780_i2c_probe()
774 dev_err(&pdev->dev, "Error: No device match found\n"); in jz4780_i2c_probe()
775 return -ENODEV; in jz4780_i2c_probe()
778 i2c->adap.owner = THIS_MODULE; in jz4780_i2c_probe()
779 i2c->adap.algo = &jz4780_i2c_algorithm; in jz4780_i2c_probe()
780 i2c->adap.algo_data = i2c; in jz4780_i2c_probe()
781 i2c->adap.retries = 5; in jz4780_i2c_probe()
782 i2c->adap.dev.parent = &pdev->dev; in jz4780_i2c_probe()
783 i2c->adap.dev.of_node = pdev->dev.of_node; in jz4780_i2c_probe()
784 sprintf(i2c->adap.name, "%s", pdev->name); in jz4780_i2c_probe()
786 init_completion(&i2c->trans_waitq); in jz4780_i2c_probe()
787 spin_lock_init(&i2c->lock); in jz4780_i2c_probe()
789 i2c->iomem = devm_platform_ioremap_resource(pdev, 0); in jz4780_i2c_probe()
790 if (IS_ERR(i2c->iomem)) in jz4780_i2c_probe()
791 return PTR_ERR(i2c->iomem); in jz4780_i2c_probe()
793 platform_set_drvdata(pdev, i2c); in jz4780_i2c_probe()
795 i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL); in jz4780_i2c_probe()
796 if (IS_ERR(i2c->clk)) in jz4780_i2c_probe()
797 return PTR_ERR(i2c->clk); in jz4780_i2c_probe()
799 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", in jz4780_i2c_probe()
802 dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); in jz4780_i2c_probe()
806 i2c->speed = clk_freq / 1000; in jz4780_i2c_probe()
807 if (i2c->speed == 0) { in jz4780_i2c_probe()
808 ret = -EINVAL; in jz4780_i2c_probe()
809 dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); in jz4780_i2c_probe()
812 jz4780_i2c_set_speed(i2c); in jz4780_i2c_probe()
814 dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed); in jz4780_i2c_probe()
816 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_probe()
817 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_probe()
819 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_probe()
822 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0); in jz4780_i2c_probe()
827 i2c->irq = ret; in jz4780_i2c_probe()
829 ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, in jz4780_i2c_probe()
830 dev_name(&pdev->dev), i2c); in jz4780_i2c_probe()
834 ret = i2c_add_adapter(&i2c->adap); in jz4780_i2c_probe()
843 struct jz4780_i2c *i2c = platform_get_drvdata(pdev); in jz4780_i2c_remove() local
845 i2c_del_adapter(&i2c->adap); in jz4780_i2c_remove()
852 .name = "jz4780-i2c",
861 MODULE_DESCRIPTION("i2c driver for JZ4780 SoCs");