Lines Matching refs:priv
153 static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val) in rcar_i2c_write() argument
155 writel(val, priv->io + reg); in rcar_i2c_write()
158 static u32 rcar_i2c_read(struct rcar_i2c_priv *priv, int reg) in rcar_i2c_read() argument
160 return readl(priv->io + reg); in rcar_i2c_read()
165 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); in rcar_i2c_get_scl() local
167 return !!(rcar_i2c_read(priv, ICMCR) & FSCL); in rcar_i2c_get_scl()
173 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); in rcar_i2c_set_scl() local
176 priv->recovery_icmcr |= FSCL; in rcar_i2c_set_scl()
178 priv->recovery_icmcr &= ~FSCL; in rcar_i2c_set_scl()
180 rcar_i2c_write(priv, ICMCR, priv->recovery_icmcr); in rcar_i2c_set_scl()
185 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); in rcar_i2c_set_sda() local
188 priv->recovery_icmcr |= FSDA; in rcar_i2c_set_sda()
190 priv->recovery_icmcr &= ~FSDA; in rcar_i2c_set_sda()
192 rcar_i2c_write(priv, ICMCR, priv->recovery_icmcr); in rcar_i2c_set_sda()
197 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); in rcar_i2c_get_bus_free() local
199 return !(rcar_i2c_read(priv, ICMCR) & FSDA); in rcar_i2c_get_bus_free()
210 static void rcar_i2c_init(struct rcar_i2c_priv *priv) in rcar_i2c_init() argument
213 rcar_i2c_write(priv, ICMIER, 0); in rcar_i2c_init()
214 rcar_i2c_write(priv, ICMCR, MDBS); in rcar_i2c_init()
215 rcar_i2c_write(priv, ICMSR, 0); in rcar_i2c_init()
217 rcar_i2c_write(priv, ICCCR, priv->icccr); in rcar_i2c_init()
219 if (priv->devtype == I2C_RCAR_GEN3) in rcar_i2c_init()
220 rcar_i2c_write(priv, ICFBSCR, TCYC17); in rcar_i2c_init()
224 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) in rcar_i2c_bus_barrier() argument
229 ret = readl_poll_timeout(priv->io + ICMCR, val, !(val & FSDA), 10, in rcar_i2c_bus_barrier()
230 priv->adap.timeout); in rcar_i2c_bus_barrier()
233 priv->recovery_icmcr = MDBS | OBPC | FSDA | FSCL; in rcar_i2c_bus_barrier()
234 ret = i2c_recover_bus(&priv->adap); in rcar_i2c_bus_barrier()
240 static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv) in rcar_i2c_clock_calculate() argument
244 struct device *dev = rcar_i2c_priv_to_dev(priv); in rcar_i2c_clock_calculate()
255 switch (priv->devtype) { in rcar_i2c_clock_calculate()
283 rate = clk_get_rate(priv->clk); in rcar_i2c_clock_calculate()
328 priv->icccr = scgd << cdf_width | cdf; in rcar_i2c_clock_calculate()
333 static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) in rcar_i2c_prepare_msg() argument
335 int read = !!rcar_i2c_is_recv(priv); in rcar_i2c_prepare_msg()
337 priv->pos = 0; in rcar_i2c_prepare_msg()
338 if (priv->msgs_left == 1) in rcar_i2c_prepare_msg()
339 priv->flags |= ID_LAST_MSG; in rcar_i2c_prepare_msg()
341 rcar_i2c_write(priv, ICMAR, i2c_8bit_addr_from_msg(priv->msg)); in rcar_i2c_prepare_msg()
342 if (!priv->atomic_xfer) in rcar_i2c_prepare_msg()
343 rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND); in rcar_i2c_prepare_msg()
350 if (priv->flags & ID_FIRST_MSG) { in rcar_i2c_prepare_msg()
351 rcar_i2c_write(priv, ICMSR, 0); in rcar_i2c_prepare_msg()
352 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); in rcar_i2c_prepare_msg()
354 if (priv->flags & ID_P_REP_AFTER_RD) in rcar_i2c_prepare_msg()
355 priv->flags &= ~ID_P_REP_AFTER_RD; in rcar_i2c_prepare_msg()
357 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); in rcar_i2c_prepare_msg()
358 rcar_i2c_write(priv, ICMSR, 0); in rcar_i2c_prepare_msg()
362 static void rcar_i2c_next_msg(struct rcar_i2c_priv *priv) in rcar_i2c_next_msg() argument
364 priv->msg++; in rcar_i2c_next_msg()
365 priv->msgs_left--; in rcar_i2c_next_msg()
366 priv->flags &= ID_P_MASK; in rcar_i2c_next_msg()
367 rcar_i2c_prepare_msg(priv); in rcar_i2c_next_msg()
370 static void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv) in rcar_i2c_dma_unmap() argument
372 struct dma_chan *chan = priv->dma_direction == DMA_FROM_DEVICE in rcar_i2c_dma_unmap()
373 ? priv->dma_rx : priv->dma_tx; in rcar_i2c_dma_unmap()
375 dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg), in rcar_i2c_dma_unmap()
376 sg_dma_len(&priv->sg), priv->dma_direction); in rcar_i2c_dma_unmap()
379 if (priv->devtype == I2C_RCAR_GEN3 && in rcar_i2c_dma_unmap()
380 priv->dma_direction == DMA_FROM_DEVICE) in rcar_i2c_dma_unmap()
381 priv->flags |= ID_P_NO_RXDMA; in rcar_i2c_dma_unmap()
383 priv->dma_direction = DMA_NONE; in rcar_i2c_dma_unmap()
386 rcar_i2c_write(priv, ICDMAER, 0); in rcar_i2c_dma_unmap()
389 static void rcar_i2c_cleanup_dma(struct rcar_i2c_priv *priv) in rcar_i2c_cleanup_dma() argument
391 if (priv->dma_direction == DMA_NONE) in rcar_i2c_cleanup_dma()
393 else if (priv->dma_direction == DMA_FROM_DEVICE) in rcar_i2c_cleanup_dma()
394 dmaengine_terminate_all(priv->dma_rx); in rcar_i2c_cleanup_dma()
395 else if (priv->dma_direction == DMA_TO_DEVICE) in rcar_i2c_cleanup_dma()
396 dmaengine_terminate_all(priv->dma_tx); in rcar_i2c_cleanup_dma()
398 rcar_i2c_dma_unmap(priv); in rcar_i2c_cleanup_dma()
403 struct rcar_i2c_priv *priv = data; in rcar_i2c_dma_callback() local
405 priv->pos += sg_dma_len(&priv->sg); in rcar_i2c_dma_callback()
407 rcar_i2c_dma_unmap(priv); in rcar_i2c_dma_callback()
410 static bool rcar_i2c_dma(struct rcar_i2c_priv *priv) in rcar_i2c_dma() argument
412 struct device *dev = rcar_i2c_priv_to_dev(priv); in rcar_i2c_dma()
413 struct i2c_msg *msg = priv->msg; in rcar_i2c_dma()
416 struct dma_chan *chan = read ? priv->dma_rx : priv->dma_tx; in rcar_i2c_dma()
424 if (priv->atomic_xfer || IS_ERR(chan) || msg->len < RCAR_MIN_DMA_LEN || in rcar_i2c_dma()
425 !(msg->flags & I2C_M_DMA_SAFE) || (read && priv->flags & ID_P_NO_RXDMA)) in rcar_i2c_dma()
433 buf = priv->msg->buf; in rcar_i2c_dma()
434 len = priv->msg->len - 2; in rcar_i2c_dma()
439 buf = priv->msg->buf + 1; in rcar_i2c_dma()
440 len = priv->msg->len - 1; in rcar_i2c_dma()
449 sg_dma_len(&priv->sg) = len; in rcar_i2c_dma()
450 sg_dma_address(&priv->sg) = dma_addr; in rcar_i2c_dma()
452 priv->dma_direction = dir; in rcar_i2c_dma()
454 txdesc = dmaengine_prep_slave_sg(chan, &priv->sg, 1, in rcar_i2c_dma()
459 rcar_i2c_cleanup_dma(priv); in rcar_i2c_dma()
464 txdesc->callback_param = priv; in rcar_i2c_dma()
469 rcar_i2c_cleanup_dma(priv); in rcar_i2c_dma()
475 rcar_i2c_write(priv, ICDMAER, RMDMAE); in rcar_i2c_dma()
477 rcar_i2c_write(priv, ICDMAER, TMDMAE); in rcar_i2c_dma()
483 static void rcar_i2c_irq_send(struct rcar_i2c_priv *priv, u32 msr) in rcar_i2c_irq_send() argument
485 struct i2c_msg *msg = priv->msg; in rcar_i2c_irq_send()
492 if (priv->pos == 1 && rcar_i2c_dma(priv)) in rcar_i2c_irq_send()
495 if (priv->pos < msg->len) { in rcar_i2c_irq_send()
503 rcar_i2c_write(priv, ICRXTX, msg->buf[priv->pos]); in rcar_i2c_irq_send()
504 priv->pos++; in rcar_i2c_irq_send()
514 if (priv->flags & ID_LAST_MSG) { in rcar_i2c_irq_send()
520 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP); in rcar_i2c_irq_send()
522 rcar_i2c_next_msg(priv); in rcar_i2c_irq_send()
527 rcar_i2c_write(priv, ICMSR, RCAR_IRQ_ACK_SEND); in rcar_i2c_irq_send()
530 static void rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr) in rcar_i2c_irq_recv() argument
532 struct i2c_msg *msg = priv->msg; in rcar_i2c_irq_recv()
543 rcar_i2c_dma(priv); in rcar_i2c_irq_recv()
544 } else if (priv->pos < msg->len) { in rcar_i2c_irq_recv()
546 msg->buf[priv->pos] = rcar_i2c_read(priv, ICRXTX); in rcar_i2c_irq_recv()
547 priv->pos++; in rcar_i2c_irq_recv()
551 if (priv->pos + 1 == msg->len) { in rcar_i2c_irq_recv()
552 if (priv->flags & ID_LAST_MSG) { in rcar_i2c_irq_recv()
553 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP); in rcar_i2c_irq_recv()
555 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); in rcar_i2c_irq_recv()
556 priv->flags |= ID_P_REP_AFTER_RD; in rcar_i2c_irq_recv()
560 if (priv->pos == msg->len && !(priv->flags & ID_LAST_MSG)) in rcar_i2c_irq_recv()
561 rcar_i2c_next_msg(priv); in rcar_i2c_irq_recv()
563 rcar_i2c_write(priv, ICMSR, RCAR_IRQ_ACK_RECV); in rcar_i2c_irq_recv()
566 static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) in rcar_i2c_slave_irq() argument
571 ssr_raw = rcar_i2c_read(priv, ICSSR) & 0xff; in rcar_i2c_slave_irq()
572 ssr_filtered = ssr_raw & rcar_i2c_read(priv, ICSIER); in rcar_i2c_slave_irq()
581 i2c_slave_event(priv->slave, I2C_SLAVE_READ_REQUESTED, &value); in rcar_i2c_slave_irq()
582 rcar_i2c_write(priv, ICRXTX, value); in rcar_i2c_slave_irq()
583 rcar_i2c_write(priv, ICSIER, SDE | SSR | SAR); in rcar_i2c_slave_irq()
585 i2c_slave_event(priv->slave, I2C_SLAVE_WRITE_REQUESTED, &value); in rcar_i2c_slave_irq()
586 rcar_i2c_read(priv, ICRXTX); /* dummy read */ in rcar_i2c_slave_irq()
587 rcar_i2c_write(priv, ICSIER, SDR | SSR | SAR); in rcar_i2c_slave_irq()
591 rcar_i2c_write(priv, ICSSR, ~(SAR | SSR) & 0xff); in rcar_i2c_slave_irq()
596 i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value); in rcar_i2c_slave_irq()
597 rcar_i2c_write(priv, ICSCR, SIE | SDBS); /* clear our NACK */ in rcar_i2c_slave_irq()
598 rcar_i2c_write(priv, ICSIER, SAR); in rcar_i2c_slave_irq()
599 rcar_i2c_write(priv, ICSSR, ~SSR & 0xff); in rcar_i2c_slave_irq()
606 value = rcar_i2c_read(priv, ICRXTX); in rcar_i2c_slave_irq()
607 ret = i2c_slave_event(priv->slave, I2C_SLAVE_WRITE_RECEIVED, &value); in rcar_i2c_slave_irq()
609 rcar_i2c_write(priv, ICSCR, SIE | SDBS | (ret < 0 ? FNA : 0)); in rcar_i2c_slave_irq()
610 rcar_i2c_write(priv, ICSSR, ~SDR & 0xff); in rcar_i2c_slave_irq()
615 i2c_slave_event(priv->slave, I2C_SLAVE_READ_PROCESSED, &value); in rcar_i2c_slave_irq()
616 rcar_i2c_write(priv, ICRXTX, value); in rcar_i2c_slave_irq()
617 rcar_i2c_write(priv, ICSSR, ~SDE & 0xff); in rcar_i2c_slave_irq()
634 static irqreturn_t rcar_i2c_irq(int irq, struct rcar_i2c_priv *priv, u32 msr) in rcar_i2c_irq() argument
637 if (rcar_i2c_slave_irq(priv)) in rcar_i2c_irq()
645 priv->flags |= ID_DONE | ID_ARBLOST; in rcar_i2c_irq()
652 if (!priv->atomic_xfer) in rcar_i2c_irq()
653 rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP); in rcar_i2c_irq()
654 priv->flags |= ID_NACK; in rcar_i2c_irq()
660 priv->msgs_left--; /* The last message also made it */ in rcar_i2c_irq()
661 priv->flags |= ID_DONE; in rcar_i2c_irq()
665 if (rcar_i2c_is_recv(priv)) in rcar_i2c_irq()
666 rcar_i2c_irq_recv(priv, msr); in rcar_i2c_irq()
668 rcar_i2c_irq_send(priv, msr); in rcar_i2c_irq()
671 if (priv->flags & ID_DONE) { in rcar_i2c_irq()
672 rcar_i2c_write(priv, ICMIER, 0); in rcar_i2c_irq()
673 rcar_i2c_write(priv, ICMSR, 0); in rcar_i2c_irq()
674 if (!priv->atomic_xfer) in rcar_i2c_irq()
675 wake_up(&priv->wait); in rcar_i2c_irq()
683 struct rcar_i2c_priv *priv = ptr; in rcar_i2c_gen2_irq() local
687 if (likely(!(priv->flags & ID_P_REP_AFTER_RD))) in rcar_i2c_gen2_irq()
688 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA); in rcar_i2c_gen2_irq()
691 msr = rcar_i2c_read(priv, ICMSR); in rcar_i2c_gen2_irq()
692 if (!priv->atomic_xfer) in rcar_i2c_gen2_irq()
693 msr &= rcar_i2c_read(priv, ICMIER); in rcar_i2c_gen2_irq()
695 return rcar_i2c_irq(irq, priv, msr); in rcar_i2c_gen2_irq()
700 struct rcar_i2c_priv *priv = ptr; in rcar_i2c_gen3_irq() local
704 msr = rcar_i2c_read(priv, ICMSR); in rcar_i2c_gen3_irq()
705 if (!priv->atomic_xfer) in rcar_i2c_gen3_irq()
706 msr &= rcar_i2c_read(priv, ICMIER); in rcar_i2c_gen3_irq()
712 if (likely(!(priv->flags & ID_P_REP_AFTER_RD) && msr)) in rcar_i2c_gen3_irq()
713 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA); in rcar_i2c_gen3_irq()
715 return rcar_i2c_irq(irq, priv, msr); in rcar_i2c_gen3_irq()
756 static void rcar_i2c_request_dma(struct rcar_i2c_priv *priv, in rcar_i2c_request_dma() argument
759 struct device *dev = rcar_i2c_priv_to_dev(priv); in rcar_i2c_request_dma()
766 chan = read ? priv->dma_rx : priv->dma_tx; in rcar_i2c_request_dma()
771 chan = rcar_i2c_request_dma_chan(dev, dir, priv->res->start + ICRXTX); in rcar_i2c_request_dma()
774 priv->dma_rx = chan; in rcar_i2c_request_dma()
776 priv->dma_tx = chan; in rcar_i2c_request_dma()
779 static void rcar_i2c_release_dma(struct rcar_i2c_priv *priv) in rcar_i2c_release_dma() argument
781 if (!IS_ERR(priv->dma_tx)) { in rcar_i2c_release_dma()
782 dma_release_channel(priv->dma_tx); in rcar_i2c_release_dma()
783 priv->dma_tx = ERR_PTR(-EPROBE_DEFER); in rcar_i2c_release_dma()
786 if (!IS_ERR(priv->dma_rx)) { in rcar_i2c_release_dma()
787 dma_release_channel(priv->dma_rx); in rcar_i2c_release_dma()
788 priv->dma_rx = ERR_PTR(-EPROBE_DEFER); in rcar_i2c_release_dma()
793 static int rcar_i2c_do_reset(struct rcar_i2c_priv *priv) in rcar_i2c_do_reset() argument
797 ret = reset_control_reset(priv->rstc); in rcar_i2c_do_reset()
802 100, false, priv->rstc); in rcar_i2c_do_reset()
809 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); in rcar_i2c_master_xfer() local
810 struct device *dev = rcar_i2c_priv_to_dev(priv); in rcar_i2c_master_xfer()
814 priv->atomic_xfer = false; in rcar_i2c_master_xfer()
819 ret = rcar_i2c_bus_barrier(priv); in rcar_i2c_master_xfer()
824 if (priv->devtype == I2C_RCAR_GEN3) { in rcar_i2c_master_xfer()
825 priv->flags |= ID_P_NO_RXDMA; in rcar_i2c_master_xfer()
826 if (!IS_ERR(priv->rstc)) { in rcar_i2c_master_xfer()
827 ret = rcar_i2c_do_reset(priv); in rcar_i2c_master_xfer()
829 priv->flags &= ~ID_P_NO_RXDMA; in rcar_i2c_master_xfer()
833 rcar_i2c_init(priv); in rcar_i2c_master_xfer()
836 rcar_i2c_request_dma(priv, msgs + i); in rcar_i2c_master_xfer()
839 priv->msg = msgs; in rcar_i2c_master_xfer()
840 priv->msgs_left = num; in rcar_i2c_master_xfer()
841 priv->flags = (priv->flags & ID_P_MASK) | ID_FIRST_MSG; in rcar_i2c_master_xfer()
842 rcar_i2c_prepare_msg(priv); in rcar_i2c_master_xfer()
844 time_left = wait_event_timeout(priv->wait, priv->flags & ID_DONE, in rcar_i2c_master_xfer()
848 if (priv->dma_direction != DMA_NONE) in rcar_i2c_master_xfer()
849 rcar_i2c_cleanup_dma(priv); in rcar_i2c_master_xfer()
852 rcar_i2c_init(priv); in rcar_i2c_master_xfer()
854 } else if (priv->flags & ID_NACK) { in rcar_i2c_master_xfer()
856 } else if (priv->flags & ID_ARBLOST) { in rcar_i2c_master_xfer()
859 ret = num - priv->msgs_left; /* The number of transfer */ in rcar_i2c_master_xfer()
865 dev_err(dev, "error %d : %x\n", ret, priv->flags); in rcar_i2c_master_xfer()
874 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); in rcar_i2c_master_xfer_atomic() local
875 struct device *dev = rcar_i2c_priv_to_dev(priv); in rcar_i2c_master_xfer_atomic()
880 priv->atomic_xfer = true; in rcar_i2c_master_xfer_atomic()
885 ret = rcar_i2c_bus_barrier(priv); in rcar_i2c_master_xfer_atomic()
889 rcar_i2c_init(priv); in rcar_i2c_master_xfer_atomic()
892 priv->msg = msgs; in rcar_i2c_master_xfer_atomic()
893 priv->msgs_left = num; in rcar_i2c_master_xfer_atomic()
894 priv->flags = (priv->flags & ID_P_MASK) | ID_FIRST_MSG; in rcar_i2c_master_xfer_atomic()
895 rcar_i2c_prepare_msg(priv); in rcar_i2c_master_xfer_atomic()
899 u32 msr = rcar_i2c_read(priv, ICMSR); in rcar_i2c_master_xfer_atomic()
901 msr &= (rcar_i2c_is_recv(priv) ? RCAR_IRQ_RECV : RCAR_IRQ_SEND) | RCAR_IRQ_STOP; in rcar_i2c_master_xfer_atomic()
904 if (priv->devtype < I2C_RCAR_GEN3) in rcar_i2c_master_xfer_atomic()
905 rcar_i2c_gen2_irq(0, priv); in rcar_i2c_master_xfer_atomic()
907 rcar_i2c_gen3_irq(0, priv); in rcar_i2c_master_xfer_atomic()
911 } while (!(priv->flags & ID_DONE) && time_left); in rcar_i2c_master_xfer_atomic()
914 rcar_i2c_init(priv); in rcar_i2c_master_xfer_atomic()
916 } else if (priv->flags & ID_NACK) { in rcar_i2c_master_xfer_atomic()
918 } else if (priv->flags & ID_ARBLOST) { in rcar_i2c_master_xfer_atomic()
921 ret = num - priv->msgs_left; /* The number of transfer */ in rcar_i2c_master_xfer_atomic()
927 dev_err(dev, "error %d : %x\n", ret, priv->flags); in rcar_i2c_master_xfer_atomic()
934 struct rcar_i2c_priv *priv = i2c_get_adapdata(slave->adapter); in rcar_reg_slave() local
936 if (priv->slave) in rcar_reg_slave()
943 pm_runtime_get_sync(rcar_i2c_priv_to_dev(priv)); in rcar_reg_slave()
945 priv->slave = slave; in rcar_reg_slave()
946 rcar_i2c_write(priv, ICSAR, slave->addr); in rcar_reg_slave()
947 rcar_i2c_write(priv, ICSSR, 0); in rcar_reg_slave()
948 rcar_i2c_write(priv, ICSIER, SAR); in rcar_reg_slave()
949 rcar_i2c_write(priv, ICSCR, SIE | SDBS); in rcar_reg_slave()
956 struct rcar_i2c_priv *priv = i2c_get_adapdata(slave->adapter); in rcar_unreg_slave() local
958 WARN_ON(!priv->slave); in rcar_unreg_slave()
961 disable_irq(priv->irq); in rcar_unreg_slave()
962 rcar_i2c_write(priv, ICSIER, 0); in rcar_unreg_slave()
963 rcar_i2c_write(priv, ICSSR, 0); in rcar_unreg_slave()
964 enable_irq(priv->irq); in rcar_unreg_slave()
965 rcar_i2c_write(priv, ICSCR, SDBS); in rcar_unreg_slave()
966 rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ in rcar_unreg_slave()
968 priv->slave = NULL; in rcar_unreg_slave()
970 pm_runtime_put(rcar_i2c_priv_to_dev(priv)); in rcar_unreg_slave()
977 struct rcar_i2c_priv *priv = i2c_get_adapdata(adap); in rcar_i2c_func() local
988 if (priv->flags & ID_P_HOST_NOTIFY) in rcar_i2c_func()
1025 struct rcar_i2c_priv *priv; in rcar_i2c_probe() local
1035 priv = devm_kzalloc(dev, sizeof(struct rcar_i2c_priv), GFP_KERNEL); in rcar_i2c_probe()
1036 if (!priv) in rcar_i2c_probe()
1039 priv->clk = devm_clk_get(dev, NULL); in rcar_i2c_probe()
1040 if (IS_ERR(priv->clk)) { in rcar_i2c_probe()
1042 return PTR_ERR(priv->clk); in rcar_i2c_probe()
1045 priv->io = devm_platform_get_and_ioremap_resource(pdev, 0, &priv->res); in rcar_i2c_probe()
1046 if (IS_ERR(priv->io)) in rcar_i2c_probe()
1047 return PTR_ERR(priv->io); in rcar_i2c_probe()
1049 priv->devtype = (enum rcar_i2c_type)of_device_get_match_data(dev); in rcar_i2c_probe()
1050 init_waitqueue_head(&priv->wait); in rcar_i2c_probe()
1052 adap = &priv->adap; in rcar_i2c_probe()
1061 i2c_set_adapdata(adap, priv); in rcar_i2c_probe()
1065 sg_init_table(&priv->sg, 1); in rcar_i2c_probe()
1066 priv->dma_direction = DMA_NONE; in rcar_i2c_probe()
1067 priv->dma_rx = priv->dma_tx = ERR_PTR(-EPROBE_DEFER); in rcar_i2c_probe()
1072 ret = rcar_i2c_clock_calculate(priv); in rcar_i2c_probe()
1076 rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */ in rcar_i2c_probe()
1078 if (priv->devtype < I2C_RCAR_GEN3) { in rcar_i2c_probe()
1083 if (priv->devtype == I2C_RCAR_GEN3) { in rcar_i2c_probe()
1084 priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); in rcar_i2c_probe()
1085 if (!IS_ERR(priv->rstc)) { in rcar_i2c_probe()
1086 ret = reset_control_status(priv->rstc); in rcar_i2c_probe()
1088 priv->rstc = ERR_PTR(-ENOTSUPP); in rcar_i2c_probe()
1094 priv->flags |= ID_P_PM_BLOCKED; in rcar_i2c_probe()
1099 priv->flags |= ID_P_HOST_NOTIFY; in rcar_i2c_probe()
1104 priv->irq = ret; in rcar_i2c_probe()
1105 ret = devm_request_irq(dev, priv->irq, irqhandler, irqflags, dev_name(dev), priv); in rcar_i2c_probe()
1107 dev_err(dev, "cannot get irq %d\n", priv->irq); in rcar_i2c_probe()
1111 platform_set_drvdata(pdev, priv); in rcar_i2c_probe()
1117 if (priv->flags & ID_P_HOST_NOTIFY) { in rcar_i2c_probe()
1118 priv->host_notify_client = i2c_new_slave_host_notify_device(adap); in rcar_i2c_probe()
1119 if (IS_ERR(priv->host_notify_client)) { in rcar_i2c_probe()
1120 ret = PTR_ERR(priv->host_notify_client); in rcar_i2c_probe()
1130 i2c_del_adapter(&priv->adap); in rcar_i2c_probe()
1140 struct rcar_i2c_priv *priv = platform_get_drvdata(pdev); in rcar_i2c_remove() local
1143 if (priv->host_notify_client) in rcar_i2c_remove()
1144 i2c_free_slave_host_notify_device(priv->host_notify_client); in rcar_i2c_remove()
1145 i2c_del_adapter(&priv->adap); in rcar_i2c_remove()
1146 rcar_i2c_release_dma(priv); in rcar_i2c_remove()
1147 if (priv->flags & ID_P_PM_BLOCKED) in rcar_i2c_remove()
1157 struct rcar_i2c_priv *priv = dev_get_drvdata(dev); in rcar_i2c_suspend() local
1159 i2c_mark_adapter_suspended(&priv->adap); in rcar_i2c_suspend()
1165 struct rcar_i2c_priv *priv = dev_get_drvdata(dev); in rcar_i2c_resume() local
1167 i2c_mark_adapter_resumed(&priv->adap); in rcar_i2c_resume()