Lines Matching refs:ao_cec
231 static inline int meson_ao_cec_wait_busy(struct meson_ao_cec_device *ao_cec) in meson_ao_cec_wait_busy() argument
235 while (readl_relaxed(ao_cec->base + CEC_RW_REG) & CEC_RW_BUS_BUSY) { in meson_ao_cec_wait_busy()
243 static void meson_ao_cec_read(struct meson_ao_cec_device *ao_cec, in meson_ao_cec_read() argument
254 spin_lock_irqsave(&ao_cec->cec_reg_lock, flags); in meson_ao_cec_read()
256 ret = meson_ao_cec_wait_busy(ao_cec); in meson_ao_cec_read()
260 writel_relaxed(reg, ao_cec->base + CEC_RW_REG); in meson_ao_cec_read()
262 ret = meson_ao_cec_wait_busy(ao_cec); in meson_ao_cec_read()
267 readl_relaxed(ao_cec->base + CEC_RW_REG)); in meson_ao_cec_read()
270 spin_unlock_irqrestore(&ao_cec->cec_reg_lock, flags); in meson_ao_cec_read()
276 static void meson_ao_cec_write(struct meson_ao_cec_device *ao_cec, in meson_ao_cec_write() argument
289 spin_lock_irqsave(&ao_cec->cec_reg_lock, flags); in meson_ao_cec_write()
291 ret = meson_ao_cec_wait_busy(ao_cec); in meson_ao_cec_write()
295 writel_relaxed(reg, ao_cec->base + CEC_RW_REG); in meson_ao_cec_write()
298 spin_unlock_irqrestore(&ao_cec->cec_reg_lock, flags); in meson_ao_cec_write()
304 static inline void meson_ao_cec_irq_setup(struct meson_ao_cec_device *ao_cec, in meson_ao_cec_irq_setup() argument
310 ao_cec->base + CEC_INTR_MASKN_REG); in meson_ao_cec_irq_setup()
313 static inline int meson_ao_cec_clear(struct meson_ao_cec_device *ao_cec) in meson_ao_cec_clear() argument
317 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_DISABLE, &ret); in meson_ao_cec_clear()
318 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_ABORT, &ret); in meson_ao_cec_clear()
319 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, 1, &ret); in meson_ao_cec_clear()
320 meson_ao_cec_write(ao_cec, CEC_TX_CLEAR_BUF, 1, &ret); in meson_ao_cec_clear()
326 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, 0, &ret); in meson_ao_cec_clear()
327 meson_ao_cec_write(ao_cec, CEC_TX_CLEAR_BUF, 0, &ret); in meson_ao_cec_clear()
333 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_NO_OP, &ret); in meson_ao_cec_clear()
334 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_NO_OP, &ret); in meson_ao_cec_clear()
339 static int meson_ao_cec_arbit_bit_time_set(struct meson_ao_cec_device *ao_cec, in meson_ao_cec_arbit_bit_time_set() argument
347 meson_ao_cec_write(ao_cec, CEC_TXTIME_4BIT_BIT7_0, in meson_ao_cec_arbit_bit_time_set()
349 meson_ao_cec_write(ao_cec, CEC_TXTIME_4BIT_BIT10_8, in meson_ao_cec_arbit_bit_time_set()
354 meson_ao_cec_write(ao_cec, CEC_TXTIME_2BIT_BIT7_0, in meson_ao_cec_arbit_bit_time_set()
356 meson_ao_cec_write(ao_cec, CEC_TXTIME_2BIT_BIT10_8, in meson_ao_cec_arbit_bit_time_set()
361 meson_ao_cec_write(ao_cec, CEC_TXTIME_17MS_BIT7_0, in meson_ao_cec_arbit_bit_time_set()
363 meson_ao_cec_write(ao_cec, CEC_TXTIME_17MS_BIT10_8, in meson_ao_cec_arbit_bit_time_set()
373 struct meson_ao_cec_device *ao_cec = data; in meson_ao_cec_irq() local
374 u32 stat = readl_relaxed(ao_cec->base + CEC_INTR_STAT_REG); in meson_ao_cec_irq()
382 static void meson_ao_cec_irq_tx(struct meson_ao_cec_device *ao_cec) in meson_ao_cec_irq_tx() argument
388 meson_ao_cec_read(ao_cec, CEC_TX_MSG_STATUS, &stat, &ret); in meson_ao_cec_irq_tx()
412 writel_relaxed(CEC_INTR_TX, ao_cec->base + CEC_INTR_CLR_REG); in meson_ao_cec_irq_tx()
415 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_NO_OP, &ret); in meson_ao_cec_irq_tx()
419 cec_transmit_attempt_done(ao_cec->adap, tx_status); in meson_ao_cec_irq_tx()
423 cec_transmit_attempt_done(ao_cec->adap, CEC_TX_STATUS_ERROR); in meson_ao_cec_irq_tx()
426 static void meson_ao_cec_irq_rx(struct meson_ao_cec_device *ao_cec) in meson_ao_cec_irq_rx() argument
431 meson_ao_cec_read(ao_cec, CEC_RX_MSG_STATUS, ®, &ret); in meson_ao_cec_irq_rx()
435 meson_ao_cec_read(ao_cec, CEC_RX_NUM_MSG, ®, &ret); in meson_ao_cec_irq_rx()
439 meson_ao_cec_read(ao_cec, CEC_RX_MSG_LENGTH, ®, &ret); in meson_ao_cec_irq_rx()
441 ao_cec->rx_msg.len = reg + 1; in meson_ao_cec_irq_rx()
442 if (ao_cec->rx_msg.len > CEC_MAX_MSG_SIZE) in meson_ao_cec_irq_rx()
443 ao_cec->rx_msg.len = CEC_MAX_MSG_SIZE; in meson_ao_cec_irq_rx()
445 for (i = 0; i < ao_cec->rx_msg.len; i++) { in meson_ao_cec_irq_rx()
448 meson_ao_cec_read(ao_cec, CEC_RX_MSG_0_HEADER + i, &byte, &ret); in meson_ao_cec_irq_rx()
450 ao_cec->rx_msg.msg[i] = byte; in meson_ao_cec_irq_rx()
456 cec_received_msg(ao_cec->adap, &ao_cec->rx_msg); in meson_ao_cec_irq_rx()
460 writel_relaxed(CEC_INTR_RX, ao_cec->base + CEC_INTR_CLR_REG); in meson_ao_cec_irq_rx()
463 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_ACK_CURRENT, &ret); in meson_ao_cec_irq_rx()
464 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_NO_OP, &ret); in meson_ao_cec_irq_rx()
467 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, CLEAR_START, &ret); in meson_ao_cec_irq_rx()
468 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, CLEAR_STOP, &ret); in meson_ao_cec_irq_rx()
473 struct meson_ao_cec_device *ao_cec = data; in meson_ao_cec_irq_thread() local
474 u32 stat = readl_relaxed(ao_cec->base + CEC_INTR_STAT_REG); in meson_ao_cec_irq_thread()
477 meson_ao_cec_irq_tx(ao_cec); in meson_ao_cec_irq_thread()
479 meson_ao_cec_irq_rx(ao_cec); in meson_ao_cec_irq_thread()
486 struct meson_ao_cec_device *ao_cec = adap->priv; in meson_ao_cec_set_log_addr() local
489 meson_ao_cec_write(ao_cec, CEC_LOGICAL_ADDR0, in meson_ao_cec_set_log_addr()
494 ret = meson_ao_cec_clear(ao_cec); in meson_ao_cec_set_log_addr()
501 meson_ao_cec_write(ao_cec, CEC_LOGICAL_ADDR0, in meson_ao_cec_set_log_addr()
508 meson_ao_cec_write(ao_cec, CEC_LOGICAL_ADDR0, in meson_ao_cec_set_log_addr()
518 struct meson_ao_cec_device *ao_cec = adap->priv; in meson_ao_cec_transmit() local
522 meson_ao_cec_read(ao_cec, CEC_TX_MSG_STATUS, ®, &ret); in meson_ao_cec_transmit()
527 dev_dbg(&ao_cec->pdev->dev, "%s: busy TX: aborting\n", in meson_ao_cec_transmit()
529 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_ABORT, &ret); in meson_ao_cec_transmit()
533 meson_ao_cec_write(ao_cec, CEC_TX_MSG_0_HEADER + i, in meson_ao_cec_transmit()
537 meson_ao_cec_write(ao_cec, CEC_TX_MSG_LENGTH, msg->len - 1, &ret); in meson_ao_cec_transmit()
538 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_REQ_CURRENT, &ret); in meson_ao_cec_transmit()
545 struct meson_ao_cec_device *ao_cec = adap->priv; in meson_ao_cec_adap_enable() local
548 meson_ao_cec_irq_setup(ao_cec, false); in meson_ao_cec_adap_enable()
551 ao_cec->base + CEC_GEN_CNTL_REG); in meson_ao_cec_adap_enable()
560 ao_cec->base + CEC_GEN_CNTL_REG); in meson_ao_cec_adap_enable()
566 ao_cec->base + CEC_GEN_CNTL_REG); in meson_ao_cec_adap_enable()
569 ret = meson_ao_cec_clear(ao_cec); in meson_ao_cec_adap_enable()
574 ret = meson_ao_cec_arbit_bit_time_set(ao_cec, in meson_ao_cec_adap_enable()
579 ret = meson_ao_cec_arbit_bit_time_set(ao_cec, in meson_ao_cec_adap_enable()
584 ret = meson_ao_cec_arbit_bit_time_set(ao_cec, in meson_ao_cec_adap_enable()
590 meson_ao_cec_irq_setup(ao_cec, true); in meson_ao_cec_adap_enable()
603 struct meson_ao_cec_device *ao_cec; in meson_ao_cec_probe() local
612 ao_cec = devm_kzalloc(&pdev->dev, sizeof(*ao_cec), GFP_KERNEL); in meson_ao_cec_probe()
613 if (!ao_cec) in meson_ao_cec_probe()
616 spin_lock_init(&ao_cec->cec_reg_lock); in meson_ao_cec_probe()
618 ao_cec->adap = cec_allocate_adapter(&meson_ao_cec_ops, ao_cec, in meson_ao_cec_probe()
623 if (IS_ERR(ao_cec->adap)) in meson_ao_cec_probe()
624 return PTR_ERR(ao_cec->adap); in meson_ao_cec_probe()
626 ao_cec->adap->owner = THIS_MODULE; in meson_ao_cec_probe()
628 ao_cec->base = devm_platform_ioremap_resource(pdev, 0); in meson_ao_cec_probe()
629 if (IS_ERR(ao_cec->base)) { in meson_ao_cec_probe()
630 ret = PTR_ERR(ao_cec->base); in meson_ao_cec_probe()
638 0, NULL, ao_cec); in meson_ao_cec_probe()
644 ao_cec->core = devm_clk_get(&pdev->dev, "core"); in meson_ao_cec_probe()
645 if (IS_ERR(ao_cec->core)) { in meson_ao_cec_probe()
647 ret = PTR_ERR(ao_cec->core); in meson_ao_cec_probe()
651 ret = clk_prepare_enable(ao_cec->core); in meson_ao_cec_probe()
657 ret = clk_set_rate(ao_cec->core, CEC_CLK_RATE); in meson_ao_cec_probe()
665 ao_cec->pdev = pdev; in meson_ao_cec_probe()
666 platform_set_drvdata(pdev, ao_cec); in meson_ao_cec_probe()
668 ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL, in meson_ao_cec_probe()
669 ao_cec->adap); in meson_ao_cec_probe()
670 if (!ao_cec->notify) { in meson_ao_cec_probe()
675 ret = cec_register_adapter(ao_cec->adap, &pdev->dev); in meson_ao_cec_probe()
681 ao_cec->base + CEC_GEN_CNTL_REG); in meson_ao_cec_probe()
686 cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap); in meson_ao_cec_probe()
689 clk_disable_unprepare(ao_cec->core); in meson_ao_cec_probe()
692 cec_delete_adapter(ao_cec->adap); in meson_ao_cec_probe()
701 struct meson_ao_cec_device *ao_cec = platform_get_drvdata(pdev); in meson_ao_cec_remove() local
703 clk_disable_unprepare(ao_cec->core); in meson_ao_cec_remove()
705 cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap); in meson_ao_cec_remove()
706 cec_unregister_adapter(ao_cec->adap); in meson_ao_cec_remove()