Lines Matching +full:i2c +full:- +full:fast +full:- +full:mode
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>
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()
263 * standard mode, min LOW and HIGH period are 4700 ns and 4000 ns in jz4780_i2c_set_speed()
264 * fast mode, min LOW and HIGH period are 1300 ns and 600 ns 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()
305 * Standard Mode: min=300ns, max=3450ns in jz4780_i2c_set_speed()
306 * Fast Mode: min=0ns, max=900ns in jz4780_i2c_set_speed()
308 * Standard Mode: min=250ns, max=infinite in jz4780_i2c_set_speed()
309 * Fast Mode: min=100(250ns is recommended), max=infinite in jz4780_i2c_set_speed()
317 * Length of setup time calculated using (SDASU - 1) * (ic_clk_period) in jz4780_i2c_set_speed()
320 if (i2c_clk <= 100) { /* standard mode */ in jz4780_i2c_set_speed()
328 hold_time = ((hold_time * dev_clk_khz) / 1000000) - 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
442 spin_lock_irqsave(&i2c->lock, flags); in jz4780_i2c_irq()
443 intmsk = jz4780_i2c_readw(i2c, JZ4780_I2C_INTM); in jz4780_i2c_irq()
444 intst = jz4780_i2c_readw(i2c, JZ4780_I2C_INTST); in jz4780_i2c_irq()
449 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
454 dev_dbg(&i2c->adap.dev, "received fifo overflow!\n"); in jz4780_i2c_irq()
455 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
463 if (i2c->is_write == 0) { in jz4780_i2c_irq()
466 while ((jz4780_i2c_readw(i2c, JZ4780_I2C_STA) in jz4780_i2c_irq()
468 *(i2c->rbuf++) = jz4780_i2c_readw(i2c, JZ4780_I2C_DC) in jz4780_i2c_irq()
470 i2c->rd_data_xfered++; in jz4780_i2c_irq()
471 if (i2c->rd_data_xfered == i2c->rd_total_len) { in jz4780_i2c_irq()
472 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
477 rd_left = i2c->rd_total_len - i2c->rd_data_xfered; in jz4780_i2c_irq()
479 if (rd_left <= i2c->cdata->fifosize) in jz4780_i2c_irq()
480 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, rd_left - 1); in jz4780_i2c_irq()
484 if (i2c->is_write == 0) { in jz4780_i2c_irq()
485 int cmd_left = i2c->rd_total_len - i2c->rd_cmd_xfered; in jz4780_i2c_irq()
486 int max_send = (i2c->cdata->fifosize - 1) in jz4780_i2c_irq()
487 - (i2c->rd_cmd_xfered in jz4780_i2c_irq()
488 - i2c->rd_data_xfered); in jz4780_i2c_irq()
491 if (i2c->rd_cmd_xfered != 0) in jz4780_i2c_irq()
493 i2c->cdata->fifosize in jz4780_i2c_irq()
494 - i2c->cdata->tx_level - 1); in jz4780_i2c_irq()
497 i2c->rd_cmd_xfered += cmd_to_send; in jz4780_i2c_irq()
498 cmd_left = i2c->rd_total_len - in jz4780_i2c_irq()
499 i2c->rd_cmd_xfered; in jz4780_i2c_irq()
500 jz4780_i2c_send_rcmd(i2c, in jz4780_i2c_irq()
506 intmsk = jz4780_i2c_readw(i2c, JZ4780_I2C_INTM); in jz4780_i2c_irq()
508 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, intmsk); in jz4780_i2c_irq()
510 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_irq()
511 tmp = jz4780_i2c_readw(i2c, in jz4780_i2c_irq()
514 jz4780_i2c_writew(i2c, in jz4780_i2c_irq()
522 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); in jz4780_i2c_irq()
525 (i2c->wt_len > 0)) { in jz4780_i2c_irq()
526 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); in jz4780_i2c_irq()
527 data = *i2c->wbuf; in jz4780_i2c_irq()
529 if ((!i2c->stop_hold) && (i2c->cdata->version >= in jz4780_i2c_irq()
532 jz4780_i2c_writew(i2c, JZ4780_I2C_DC, data); in jz4780_i2c_irq()
533 i2c->wbuf++; in jz4780_i2c_irq()
534 i2c->wt_len--; in jz4780_i2c_irq()
537 if (i2c->wt_len == 0) { in jz4780_i2c_irq()
538 if ((!i2c->stop_hold) && (i2c->cdata->version < in jz4780_i2c_irq()
540 tmp = jz4780_i2c_readw(i2c, in jz4780_i2c_irq()
543 jz4780_i2c_writew(i2c, in jz4780_i2c_irq()
547 jz4780_i2c_trans_done(i2c); in jz4780_i2c_irq()
554 spin_unlock_irqrestore(&i2c->lock, flags); in jz4780_i2c_irq()
558 static void jz4780_i2c_txabrt(struct jz4780_i2c *i2c, int src) in jz4780_i2c_txabrt() argument
560 dev_dbg(&i2c->adap.dev, "txabrt: 0x%08x, cmd: %d, send: %d, recv: %d\n", in jz4780_i2c_txabrt()
561 src, i2c->cmd, i2c->cmd_buf[i2c->cmd], i2c->data_buf[i2c->cmd]); in jz4780_i2c_txabrt()
564 static inline int jz4780_i2c_xfer_read(struct jz4780_i2c *i2c, in jz4780_i2c_xfer_read() argument
576 spin_lock_irqsave(&i2c->lock, flags); in jz4780_i2c_xfer_read()
578 i2c->stop_hold = 0; in jz4780_i2c_xfer_read()
579 i2c->is_write = 0; in jz4780_i2c_xfer_read()
580 i2c->rbuf = buf; in jz4780_i2c_xfer_read()
581 i2c->rd_total_len = len; in jz4780_i2c_xfer_read()
582 i2c->rd_data_xfered = 0; in jz4780_i2c_xfer_read()
583 i2c->rd_cmd_xfered = 0; in jz4780_i2c_xfer_read()
585 if (len <= i2c->cdata->fifosize) in jz4780_i2c_xfer_read()
586 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, len - 1); in jz4780_i2c_xfer_read()
588 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, i2c->cdata->rx_level); in jz4780_i2c_xfer_read()
590 jz4780_i2c_writew(i2c, JZ4780_I2C_TXTL, i2c->cdata->tx_level); in jz4780_i2c_xfer_read()
592 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, in jz4780_i2c_xfer_read()
596 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_xfer_read()
597 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_xfer_read()
599 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_xfer_read()
602 spin_unlock_irqrestore(&i2c->lock, flags); in jz4780_i2c_xfer_read()
604 timeout = wait_for_completion_timeout(&i2c->trans_waitq, in jz4780_i2c_xfer_read()
608 dev_err(&i2c->adap.dev, "irq read timeout\n"); in jz4780_i2c_xfer_read()
609 dev_dbg(&i2c->adap.dev, "send cmd count:%d %d\n", in jz4780_i2c_xfer_read()
610 i2c->cmd, i2c->cmd_buf[i2c->cmd]); in jz4780_i2c_xfer_read()
611 dev_dbg(&i2c->adap.dev, "receive data count:%d %d\n", in jz4780_i2c_xfer_read()
612 i2c->cmd, i2c->data_buf[i2c->cmd]); in jz4780_i2c_xfer_read()
613 ret = -EIO; in jz4780_i2c_xfer_read()
616 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_TXABRT); in jz4780_i2c_xfer_read()
618 jz4780_i2c_txabrt(i2c, tmp); in jz4780_i2c_xfer_read()
619 ret = -EIO; in jz4780_i2c_xfer_read()
625 static inline int jz4780_i2c_xfer_write(struct jz4780_i2c *i2c, in jz4780_i2c_xfer_write() argument
635 spin_lock_irqsave(&i2c->lock, flags); in jz4780_i2c_xfer_write()
637 if (idx < (cnt - 1)) in jz4780_i2c_xfer_write()
638 i2c->stop_hold = 1; in jz4780_i2c_xfer_write()
640 i2c->stop_hold = 0; in jz4780_i2c_xfer_write()
642 i2c->is_write = 1; in jz4780_i2c_xfer_write()
643 i2c->wbuf = buf; in jz4780_i2c_xfer_write()
644 i2c->wt_len = len; in jz4780_i2c_xfer_write()
646 jz4780_i2c_writew(i2c, JZ4780_I2C_TXTL, i2c->cdata->tx_level); in jz4780_i2c_xfer_write()
648 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, JZ4780_I2C_INTM_MTXEMP in jz4780_i2c_xfer_write()
651 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_xfer_write()
652 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_xfer_write()
654 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_xfer_write()
657 spin_unlock_irqrestore(&i2c->lock, flags); in jz4780_i2c_xfer_write()
659 timeout = wait_for_completion_timeout(&i2c->trans_waitq, in jz4780_i2c_xfer_write()
661 if (timeout && !i2c->stop_hold) { in jz4780_i2c_xfer_write()
666 for (; timeout > 0; timeout--) { in jz4780_i2c_xfer_write()
667 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); in jz4780_i2c_xfer_write()
678 dev_err(&i2c->adap.dev, "write wait timeout\n"); in jz4780_i2c_xfer_write()
679 ret = -EIO; in jz4780_i2c_xfer_write()
682 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_TXABRT); in jz4780_i2c_xfer_write()
684 jz4780_i2c_txabrt(i2c, tmp); in jz4780_i2c_xfer_write()
685 ret = -EIO; in jz4780_i2c_xfer_write()
694 int i = -EIO; in jz4780_i2c_xfer()
696 struct jz4780_i2c *i2c = adap->algo_data; in jz4780_i2c_xfer() local
698 ret = jz4780_i2c_prepare(i2c); in jz4780_i2c_xfer()
700 dev_err(&i2c->adap.dev, "I2C prepare failed\n"); in jz4780_i2c_xfer()
704 if (msg->addr != jz4780_i2c_readw(i2c, JZ4780_I2C_TAR)) { in jz4780_i2c_xfer()
705 ret = jz4780_i2c_set_target(i2c, msg->addr); in jz4780_i2c_xfer()
710 if (msg->flags & I2C_M_RD) in jz4780_i2c_xfer()
711 ret = jz4780_i2c_xfer_read(i2c, msg->buf, msg->len, in jz4780_i2c_xfer()
714 ret = jz4780_i2c_xfer_write(i2c, msg->buf, msg->len, in jz4780_i2c_xfer()
724 jz4780_i2c_cleanup(i2c); in jz4780_i2c_xfer()
743 .rx_level = JZ4780_I2C_FIFO_LEN / 2 - 1,
751 .rx_level = X1000_I2C_FIFO_LEN / 2 - 1,
755 { .compatible = "ingenic,jz4770-i2c", .data = &jz4780_i2c_config },
756 { .compatible = "ingenic,jz4780-i2c", .data = &jz4780_i2c_config },
757 { .compatible = "ingenic,x1000-i2c", .data = &x1000_i2c_config },
767 struct jz4780_i2c *i2c; in jz4780_i2c_probe() local
769 i2c = devm_kzalloc(&pdev->dev, sizeof(struct jz4780_i2c), GFP_KERNEL); in jz4780_i2c_probe()
770 if (!i2c) in jz4780_i2c_probe()
771 return -ENOMEM; in jz4780_i2c_probe()
773 i2c->cdata = device_get_match_data(&pdev->dev); in jz4780_i2c_probe()
774 if (!i2c->cdata) { in jz4780_i2c_probe()
775 dev_err(&pdev->dev, "Error: No device match found\n"); in jz4780_i2c_probe()
776 return -ENODEV; in jz4780_i2c_probe()
779 i2c->adap.owner = THIS_MODULE; in jz4780_i2c_probe()
780 i2c->adap.algo = &jz4780_i2c_algorithm; in jz4780_i2c_probe()
781 i2c->adap.algo_data = i2c; in jz4780_i2c_probe()
782 i2c->adap.retries = 5; in jz4780_i2c_probe()
783 i2c->adap.dev.parent = &pdev->dev; in jz4780_i2c_probe()
784 i2c->adap.dev.of_node = pdev->dev.of_node; in jz4780_i2c_probe()
785 sprintf(i2c->adap.name, "%s", pdev->name); in jz4780_i2c_probe()
787 init_completion(&i2c->trans_waitq); in jz4780_i2c_probe()
788 spin_lock_init(&i2c->lock); in jz4780_i2c_probe()
790 i2c->iomem = devm_platform_ioremap_resource(pdev, 0); in jz4780_i2c_probe()
791 if (IS_ERR(i2c->iomem)) in jz4780_i2c_probe()
792 return PTR_ERR(i2c->iomem); in jz4780_i2c_probe()
794 platform_set_drvdata(pdev, i2c); in jz4780_i2c_probe()
796 i2c->clk = devm_clk_get(&pdev->dev, NULL); in jz4780_i2c_probe()
797 if (IS_ERR(i2c->clk)) in jz4780_i2c_probe()
798 return PTR_ERR(i2c->clk); in jz4780_i2c_probe()
800 ret = clk_prepare_enable(i2c->clk); in jz4780_i2c_probe()
804 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", in jz4780_i2c_probe()
807 dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); in jz4780_i2c_probe()
811 i2c->speed = clk_freq / 1000; in jz4780_i2c_probe()
812 if (i2c->speed == 0) { in jz4780_i2c_probe()
813 ret = -EINVAL; in jz4780_i2c_probe()
814 dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); in jz4780_i2c_probe()
817 jz4780_i2c_set_speed(i2c); in jz4780_i2c_probe()
819 dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed); in jz4780_i2c_probe()
821 if (i2c->cdata->version < ID_X1000) { in jz4780_i2c_probe()
822 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); in jz4780_i2c_probe()
824 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); in jz4780_i2c_probe()
827 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0); in jz4780_i2c_probe()
829 i2c->irq = platform_get_irq(pdev, 0); in jz4780_i2c_probe()
830 ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, in jz4780_i2c_probe()
831 dev_name(&pdev->dev), i2c); in jz4780_i2c_probe()
835 ret = i2c_add_adapter(&i2c->adap); in jz4780_i2c_probe()
842 clk_disable_unprepare(i2c->clk); in jz4780_i2c_probe()
848 struct jz4780_i2c *i2c = platform_get_drvdata(pdev); in jz4780_i2c_remove() local
850 clk_disable_unprepare(i2c->clk); in jz4780_i2c_remove()
851 i2c_del_adapter(&i2c->adap); in jz4780_i2c_remove()
859 .name = "jz4780-i2c",
868 MODULE_DESCRIPTION("i2c driver for JZ4780 SoCs");