Lines Matching refs:ao_cec
333 static int meson_ao_cec_g12a_setup_clk(struct meson_ao_cec_g12a_device *ao_cec) in meson_ao_cec_g12a_setup_clk() argument
336 struct device *dev = &ao_cec->pdev->dev; in meson_ao_cec_g12a_setup_clk()
350 parent_name = __clk_get_name(ao_cec->oscin); in meson_ao_cec_g12a_setup_clk()
357 dualdiv_clk->regmap = ao_cec->regmap; in meson_ao_cec_g12a_setup_clk()
367 ao_cec->core = clk; in meson_ao_cec_g12a_setup_clk()
375 struct meson_ao_cec_g12a_device *ao_cec = context; in meson_ao_cec_g12a_read() local
379 ret = regmap_write(ao_cec->regmap, CECB_RW_REG, reg); in meson_ao_cec_g12a_read()
383 ret = regmap_read_poll_timeout(ao_cec->regmap, CECB_RW_REG, reg, in meson_ao_cec_g12a_read()
389 ret = regmap_read(ao_cec->regmap, CECB_RW_REG, ®); in meson_ao_cec_g12a_read()
399 struct meson_ao_cec_g12a_device *ao_cec = context; in meson_ao_cec_g12a_write() local
404 return regmap_write(ao_cec->regmap, CECB_RW_REG, reg); in meson_ao_cec_g12a_write()
416 meson_ao_cec_g12a_irq_setup(struct meson_ao_cec_g12a_device *ao_cec, in meson_ao_cec_g12a_irq_setup() argument
423 regmap_write(ao_cec->regmap, CECB_INTR_MASKN_REG, in meson_ao_cec_g12a_irq_setup()
427 static void meson_ao_cec_g12a_irq_rx(struct meson_ao_cec_g12a_device *ao_cec) in meson_ao_cec_g12a_irq_rx() argument
432 ret = regmap_read(ao_cec->regmap_cec, CECB_RX_CNT, &val); in meson_ao_cec_g12a_irq_rx()
434 ao_cec->rx_msg.len = val; in meson_ao_cec_g12a_irq_rx()
435 if (ao_cec->rx_msg.len > CEC_MAX_MSG_SIZE) in meson_ao_cec_g12a_irq_rx()
436 ao_cec->rx_msg.len = CEC_MAX_MSG_SIZE; in meson_ao_cec_g12a_irq_rx()
438 for (i = 0; i < ao_cec->rx_msg.len; i++) { in meson_ao_cec_g12a_irq_rx()
439 ret |= regmap_read(ao_cec->regmap_cec, in meson_ao_cec_g12a_irq_rx()
442 ao_cec->rx_msg.msg[i] = val & 0xff; in meson_ao_cec_g12a_irq_rx()
445 ret |= regmap_write(ao_cec->regmap_cec, CECB_LOCK_BUF, 0); in meson_ao_cec_g12a_irq_rx()
449 cec_received_msg(ao_cec->adap, &ao_cec->rx_msg); in meson_ao_cec_g12a_irq_rx()
454 struct meson_ao_cec_g12a_device *ao_cec = data; in meson_ao_cec_g12a_irq() local
457 regmap_read(ao_cec->regmap, CECB_INTR_STAT_REG, &stat); in meson_ao_cec_g12a_irq()
466 struct meson_ao_cec_g12a_device *ao_cec = data; in meson_ao_cec_g12a_irq_thread() local
469 regmap_read(ao_cec->regmap, CECB_INTR_STAT_REG, &stat); in meson_ao_cec_g12a_irq_thread()
470 regmap_write(ao_cec->regmap, CECB_INTR_CLR_REG, stat); in meson_ao_cec_g12a_irq_thread()
473 cec_transmit_attempt_done(ao_cec->adap, CEC_TX_STATUS_OK); in meson_ao_cec_g12a_irq_thread()
476 meson_ao_cec_g12a_irq_rx(ao_cec); in meson_ao_cec_g12a_irq_thread()
479 cec_transmit_attempt_done(ao_cec->adap, CEC_TX_STATUS_NACK); in meson_ao_cec_g12a_irq_thread()
482 regmap_write(ao_cec->regmap_cec, CECB_TX_CNT, 0); in meson_ao_cec_g12a_irq_thread()
483 regmap_update_bits(ao_cec->regmap_cec, CECB_CTRL, in meson_ao_cec_g12a_irq_thread()
485 cec_transmit_attempt_done(ao_cec->adap, CEC_TX_STATUS_ARB_LOST); in meson_ao_cec_g12a_irq_thread()
490 cec_transmit_attempt_done(ao_cec->adap, CEC_TX_STATUS_ERROR); in meson_ao_cec_g12a_irq_thread()
494 regmap_write(ao_cec->regmap_cec, CECB_LOCK_BUF, 0); in meson_ao_cec_g12a_irq_thread()
502 struct meson_ao_cec_g12a_device *ao_cec = adap->priv; in meson_ao_cec_g12a_set_log_addr() local
507 regmap_write(ao_cec->regmap_cec, CECB_LADD_LOW, 0); in meson_ao_cec_g12a_set_log_addr()
508 regmap_write(ao_cec->regmap_cec, CECB_LADD_HIGH, 0); in meson_ao_cec_g12a_set_log_addr()
512 ret = regmap_update_bits(ao_cec->regmap_cec, CECB_LADD_LOW, in meson_ao_cec_g12a_set_log_addr()
516 ret = regmap_update_bits(ao_cec->regmap_cec, CECB_LADD_HIGH, in meson_ao_cec_g12a_set_log_addr()
522 ret |= regmap_update_bits(ao_cec->regmap_cec, CECB_LADD_HIGH, in meson_ao_cec_g12a_set_log_addr()
532 struct meson_ao_cec_g12a_device *ao_cec = adap->priv; in meson_ao_cec_g12a_transmit() local
539 ret = regmap_read(ao_cec->regmap_cec, CECB_LOCK_BUF, &val); in meson_ao_cec_g12a_transmit()
546 ret = regmap_read(ao_cec->regmap_cec, CECB_CTRL, &val); in meson_ao_cec_g12a_transmit()
566 ret |= regmap_write(ao_cec->regmap_cec, CECB_TX_DATA00 + i, in meson_ao_cec_g12a_transmit()
569 ret |= regmap_write(ao_cec->regmap_cec, CECB_TX_CNT, msg->len); in meson_ao_cec_g12a_transmit()
573 ret = regmap_update_bits(ao_cec->regmap_cec, CECB_CTRL, in meson_ao_cec_g12a_transmit()
584 struct meson_ao_cec_g12a_device *ao_cec = adap->priv; in meson_ao_cec_g12a_adap_enable() local
586 meson_ao_cec_g12a_irq_setup(ao_cec, false); in meson_ao_cec_g12a_adap_enable()
588 regmap_update_bits(ao_cec->regmap, CECB_GEN_CNTL_REG, in meson_ao_cec_g12a_adap_enable()
595 regmap_update_bits(ao_cec->regmap, CECB_GEN_CNTL_REG, in meson_ao_cec_g12a_adap_enable()
603 regmap_update_bits(ao_cec->regmap, CECB_GEN_CNTL_REG, in meson_ao_cec_g12a_adap_enable()
608 regmap_update_bits(ao_cec->regmap, CECB_GEN_CNTL_REG, in meson_ao_cec_g12a_adap_enable()
614 regmap_update_bits(ao_cec->regmap, CECB_GEN_CNTL_REG, in meson_ao_cec_g12a_adap_enable()
617 if (ao_cec->data->ctrl2_setup) in meson_ao_cec_g12a_adap_enable()
618 regmap_write(ao_cec->regmap_cec, CECB_CTRL2, in meson_ao_cec_g12a_adap_enable()
621 meson_ao_cec_g12a_irq_setup(ao_cec, true); in meson_ao_cec_g12a_adap_enable()
634 struct meson_ao_cec_g12a_device *ao_cec; in meson_ao_cec_g12a_probe() local
643 ao_cec = devm_kzalloc(&pdev->dev, sizeof(*ao_cec), GFP_KERNEL); in meson_ao_cec_g12a_probe()
644 if (!ao_cec) in meson_ao_cec_g12a_probe()
647 ao_cec->data = of_device_get_match_data(&pdev->dev); in meson_ao_cec_g12a_probe()
648 if (!ao_cec->data) { in meson_ao_cec_g12a_probe()
653 spin_lock_init(&ao_cec->cec_reg_lock); in meson_ao_cec_g12a_probe()
654 ao_cec->pdev = pdev; in meson_ao_cec_g12a_probe()
656 ao_cec->adap = cec_allocate_adapter(&meson_ao_cec_g12a_ops, ao_cec, in meson_ao_cec_g12a_probe()
661 if (IS_ERR(ao_cec->adap)) in meson_ao_cec_g12a_probe()
662 return PTR_ERR(ao_cec->adap); in meson_ao_cec_g12a_probe()
664 ao_cec->adap->owner = THIS_MODULE; in meson_ao_cec_g12a_probe()
672 ao_cec->regmap = devm_regmap_init_mmio(&pdev->dev, base, in meson_ao_cec_g12a_probe()
674 if (IS_ERR(ao_cec->regmap)) { in meson_ao_cec_g12a_probe()
675 ret = PTR_ERR(ao_cec->regmap); in meson_ao_cec_g12a_probe()
679 ao_cec->regmap_cec = devm_regmap_init(&pdev->dev, NULL, ao_cec, in meson_ao_cec_g12a_probe()
681 if (IS_ERR(ao_cec->regmap_cec)) { in meson_ao_cec_g12a_probe()
682 ret = PTR_ERR(ao_cec->regmap_cec); in meson_ao_cec_g12a_probe()
690 0, NULL, ao_cec); in meson_ao_cec_g12a_probe()
696 ao_cec->oscin = devm_clk_get(&pdev->dev, "oscin"); in meson_ao_cec_g12a_probe()
697 if (IS_ERR(ao_cec->oscin)) { in meson_ao_cec_g12a_probe()
699 ret = PTR_ERR(ao_cec->oscin); in meson_ao_cec_g12a_probe()
703 ret = meson_ao_cec_g12a_setup_clk(ao_cec); in meson_ao_cec_g12a_probe()
707 ret = clk_prepare_enable(ao_cec->core); in meson_ao_cec_g12a_probe()
715 platform_set_drvdata(pdev, ao_cec); in meson_ao_cec_g12a_probe()
717 ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL, in meson_ao_cec_g12a_probe()
718 ao_cec->adap); in meson_ao_cec_g12a_probe()
719 if (!ao_cec->notify) { in meson_ao_cec_g12a_probe()
724 ret = cec_register_adapter(ao_cec->adap, &pdev->dev); in meson_ao_cec_g12a_probe()
729 regmap_write(ao_cec->regmap, CECB_GEN_CNTL_REG, CECB_GEN_CNTL_RESET); in meson_ao_cec_g12a_probe()
734 cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap); in meson_ao_cec_g12a_probe()
737 clk_disable_unprepare(ao_cec->core); in meson_ao_cec_g12a_probe()
740 cec_delete_adapter(ao_cec->adap); in meson_ao_cec_g12a_probe()
749 struct meson_ao_cec_g12a_device *ao_cec = platform_get_drvdata(pdev); in meson_ao_cec_g12a_remove() local
751 clk_disable_unprepare(ao_cec->core); in meson_ao_cec_g12a_remove()
753 cec_notifier_cec_adap_unregister(ao_cec->notify, ao_cec->adap); in meson_ao_cec_g12a_remove()
755 cec_unregister_adapter(ao_cec->adap); in meson_ao_cec_g12a_remove()