Lines Matching +full:tegra124 +full:- +full:hdmi
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved.
11 * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
29 #include <media/cec-notifier.h>
33 #define TEGRA_CEC_NAME "tegra-cec"
54 return readl(cec->cec_base + reg); in cec_read()
59 writel(val, cec->cec_base + reg); in cec_write()
77 if (cec->tx_done) { in tegra_cec_irq_thread_handler()
78 cec_transmit_attempt_done(cec->adap, cec->tx_status); in tegra_cec_irq_thread_handler()
79 cec->tx_done = false; in tegra_cec_irq_thread_handler()
81 if (cec->rx_done) { in tegra_cec_irq_thread_handler()
84 msg.len = cec->rx_buf_cnt; in tegra_cec_irq_thread_handler()
85 memcpy(msg.msg, cec->rx_buf, msg.len); in tegra_cec_irq_thread_handler()
86 cec_received_msg(cec->adap, &msg); in tegra_cec_irq_thread_handler()
87 cec->rx_done = false; in tegra_cec_irq_thread_handler()
88 cec->rx_buf_cnt = 0; in tegra_cec_irq_thread_handler()
114 cec->tx_done = true; in tegra_cec_irq_handler()
115 cec->tx_status = CEC_TX_STATUS_ERROR; in tegra_cec_irq_handler()
125 cec->tx_done = true; in tegra_cec_irq_handler()
127 cec->tx_status = CEC_TX_STATUS_LOW_DRIVE; in tegra_cec_irq_handler()
129 cec->tx_status = CEC_TX_STATUS_ARB_LOST; in tegra_cec_irq_handler()
140 cec->tx_done = true; in tegra_cec_irq_handler()
141 cec->tx_status = CEC_TX_STATUS_NACK; in tegra_cec_irq_handler()
143 cec->tx_done = true; in tegra_cec_irq_handler()
144 cec->tx_status = CEC_TX_STATUS_OK; in tegra_cec_irq_handler()
153 if (cec->tx_buf_cur == cec->tx_buf_cnt) { in tegra_cec_irq_handler()
158 cec->tx_buf[cec->tx_buf_cur++]); in tegra_cec_irq_handler()
167 cec->rx_done = false; in tegra_cec_irq_handler()
168 cec->rx_buf_cnt = 0; in tegra_cec_irq_handler()
176 if (cec->rx_buf_cnt < CEC_MAX_MSG_SIZE) in tegra_cec_irq_handler()
177 cec->rx_buf[cec->rx_buf_cnt++] = v & 0xff; in tegra_cec_irq_handler()
179 cec->rx_done = true; in tegra_cec_irq_handler()
189 struct tegra_cec *cec = adap->priv; in tegra_cec_adap_enable()
191 cec->rx_buf_cnt = 0; in tegra_cec_adap_enable()
192 cec->tx_buf_cnt = 0; in tegra_cec_adap_enable()
193 cec->tx_buf_cur = 0; in tegra_cec_adap_enable()
252 struct tegra_cec *cec = adap->priv; in tegra_cec_adap_log_addr()
267 struct tegra_cec *cec = adap->priv; in tegra_cec_adap_monitor_all_enable()
282 struct tegra_cec *cec = adap->priv; in tegra_cec_adap_transmit()
290 cec->tx_buf_cur = 0; in tegra_cec_adap_transmit()
291 cec->tx_buf_cnt = msg->len; in tegra_cec_adap_transmit()
293 for (i = 0; i < msg->len; i++) { in tegra_cec_adap_transmit()
294 cec->tx_buf[i] = mode | msg->msg[i]; in tegra_cec_adap_transmit()
296 cec->tx_buf[i] |= TEGRA_CEC_TX_REG_START_BIT; in tegra_cec_adap_transmit()
297 if (i == msg->len - 1) in tegra_cec_adap_transmit()
298 cec->tx_buf[i] |= TEGRA_CEC_TX_REG_EOM; in tegra_cec_adap_transmit()
300 cec->tx_buf[i] |= TEGRA_CEC_TX_REG_RETRY; in tegra_cec_adap_transmit()
324 hdmi_dev = cec_notifier_parse_hdmi_phandle(&pdev->dev); in tegra_cec_probe()
329 cec = devm_kzalloc(&pdev->dev, sizeof(struct tegra_cec), GFP_KERNEL); in tegra_cec_probe()
332 return -ENOMEM; in tegra_cec_probe()
337 dev_err(&pdev->dev, in tegra_cec_probe()
339 return -EBUSY; in tegra_cec_probe()
342 if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), in tegra_cec_probe()
343 pdev->name)) { in tegra_cec_probe()
344 dev_err(&pdev->dev, in tegra_cec_probe()
346 return -EBUSY; in tegra_cec_probe()
349 cec->tegra_cec_irq = platform_get_irq(pdev, 0); in tegra_cec_probe()
351 if (cec->tegra_cec_irq < 0) in tegra_cec_probe()
352 return cec->tegra_cec_irq; in tegra_cec_probe()
354 cec->cec_base = devm_ioremap(&pdev->dev, res->start, in tegra_cec_probe()
357 if (!cec->cec_base) { in tegra_cec_probe()
358 dev_err(&pdev->dev, "Unable to grab IOs for device\n"); in tegra_cec_probe()
359 return -EBUSY; in tegra_cec_probe()
362 cec->clk = devm_clk_get(&pdev->dev, "cec"); in tegra_cec_probe()
364 if (IS_ERR_OR_NULL(cec->clk)) { in tegra_cec_probe()
365 dev_err(&pdev->dev, "Can't get clock for CEC\n"); in tegra_cec_probe()
366 return -ENOENT; in tegra_cec_probe()
369 ret = clk_prepare_enable(cec->clk); in tegra_cec_probe()
371 dev_err(&pdev->dev, "Unable to prepare clock for CEC\n"); in tegra_cec_probe()
376 cec->dev = &pdev->dev; in tegra_cec_probe()
380 ret = devm_request_threaded_irq(&pdev->dev, cec->tegra_cec_irq, in tegra_cec_probe()
382 0, "cec_irq", &pdev->dev); in tegra_cec_probe()
385 dev_err(&pdev->dev, in tegra_cec_probe()
390 cec->adap = cec_allocate_adapter(&tegra_cec_ops, cec, TEGRA_CEC_NAME, in tegra_cec_probe()
394 if (IS_ERR(cec->adap)) { in tegra_cec_probe()
395 ret = -ENOMEM; in tegra_cec_probe()
396 dev_err(&pdev->dev, "Couldn't create cec adapter\n"); in tegra_cec_probe()
400 cec->notifier = cec_notifier_cec_adap_register(hdmi_dev, NULL, in tegra_cec_probe()
401 cec->adap); in tegra_cec_probe()
402 if (!cec->notifier) { in tegra_cec_probe()
403 ret = -ENOMEM; in tegra_cec_probe()
407 ret = cec_register_adapter(cec->adap, &pdev->dev); in tegra_cec_probe()
409 dev_err(&pdev->dev, "Couldn't register device\n"); in tegra_cec_probe()
416 cec_notifier_cec_adap_unregister(cec->notifier, cec->adap); in tegra_cec_probe()
418 cec_delete_adapter(cec->adap); in tegra_cec_probe()
420 clk_disable_unprepare(cec->clk); in tegra_cec_probe()
428 clk_disable_unprepare(cec->clk); in tegra_cec_remove()
430 cec_notifier_cec_adap_unregister(cec->notifier, cec->adap); in tegra_cec_remove()
431 cec_unregister_adapter(cec->adap); in tegra_cec_remove()
439 clk_disable_unprepare(cec->clk); in tegra_cec_suspend()
441 dev_notice(&pdev->dev, "suspended\n"); in tegra_cec_suspend()
449 dev_notice(&pdev->dev, "Resuming\n"); in tegra_cec_resume()
451 return clk_prepare_enable(cec->clk); in tegra_cec_resume()
456 { .compatible = "nvidia,tegra114-cec", },
457 { .compatible = "nvidia,tegra124-cec", },
458 { .compatible = "nvidia,tegra210-cec", },
478 MODULE_DESCRIPTION("Tegra HDMI CEC driver");