Lines Matching +full:dw +full:- +full:hdmi
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Designware HDMI CEC driver
5 * Copyright (C) 2015-2017 Russell King.
17 #include <media/cec-notifier.h>
19 #include "dw-hdmi-cec.h"
55 struct dw_hdmi *hdmi; member
73 cec->ops->write(cec->hdmi, val, offset); in dw_hdmi_write()
78 return cec->ops->read(cec->hdmi, offset); in dw_hdmi_read()
86 cec->addresses = 0; in dw_hdmi_cec_log_addr()
88 cec->addresses |= BIT(logical_addr) | BIT(15); in dw_hdmi_cec_log_addr()
90 dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L); in dw_hdmi_cec_log_addr()
91 dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H); in dw_hdmi_cec_log_addr()
115 for (i = 0; i < msg->len; i++) in dw_hdmi_cec_transmit()
116 dw_hdmi_write(cec, msg->msg[i], HDMI_CEC_TX_DATA0 + i); in dw_hdmi_cec_transmit()
118 dw_hdmi_write(cec, msg->len, HDMI_CEC_TX_CNT); in dw_hdmi_cec_transmit()
137 cec->tx_status = CEC_TX_STATUS_ERROR; in dw_hdmi_cec_hardirq()
138 cec->tx_done = true; in dw_hdmi_cec_hardirq()
141 cec->tx_status = CEC_TX_STATUS_OK; in dw_hdmi_cec_hardirq()
142 cec->tx_done = true; in dw_hdmi_cec_hardirq()
145 cec->tx_status = CEC_TX_STATUS_NACK; in dw_hdmi_cec_hardirq()
146 cec->tx_done = true; in dw_hdmi_cec_hardirq()
149 cec->tx_status = CEC_TX_STATUS_ARB_LOST; in dw_hdmi_cec_hardirq()
150 cec->tx_done = true; in dw_hdmi_cec_hardirq()
158 if (len > sizeof(cec->rx_msg.msg)) in dw_hdmi_cec_hardirq()
159 len = sizeof(cec->rx_msg.msg); in dw_hdmi_cec_hardirq()
162 cec->rx_msg.msg[i] = in dw_hdmi_cec_hardirq()
167 cec->rx_msg.len = len; in dw_hdmi_cec_hardirq()
169 cec->rx_done = true; in dw_hdmi_cec_hardirq()
182 if (cec->tx_done) { in dw_hdmi_cec_thread()
183 cec->tx_done = false; in dw_hdmi_cec_thread()
184 cec_transmit_attempt_done(adap, cec->tx_status); in dw_hdmi_cec_thread()
186 if (cec->rx_done) { in dw_hdmi_cec_thread()
187 cec->rx_done = false; in dw_hdmi_cec_thread()
189 cec_received_msg(adap, &cec->rx_msg); in dw_hdmi_cec_thread()
203 cec->ops->disable(cec->hdmi); in dw_hdmi_cec_enable()
211 dw_hdmi_cec_log_addr(cec->adap, CEC_LOG_ADDR_INVALID); in dw_hdmi_cec_enable()
213 cec->ops->enable(cec->hdmi); in dw_hdmi_cec_enable()
234 cec_delete_adapter(cec->adap); in dw_hdmi_cec_del()
239 struct dw_hdmi_cec_data *data = dev_get_platdata(&pdev->dev); in dw_hdmi_cec_probe()
244 return -ENXIO; in dw_hdmi_cec_probe()
247 * Our device is just a convenience - we want to link to the real in dw_hdmi_cec_probe()
249 * between the HDMI hardware and its associated CEC chardev. in dw_hdmi_cec_probe()
251 cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL); in dw_hdmi_cec_probe()
253 return -ENOMEM; in dw_hdmi_cec_probe()
255 cec->irq = data->irq; in dw_hdmi_cec_probe()
256 cec->ops = data->ops; in dw_hdmi_cec_probe()
257 cec->hdmi = data->hdmi; in dw_hdmi_cec_probe()
266 cec->adap = cec_allocate_adapter(&dw_hdmi_cec_ops, cec, "dw_hdmi", in dw_hdmi_cec_probe()
270 if (IS_ERR(cec->adap)) in dw_hdmi_cec_probe()
271 return PTR_ERR(cec->adap); in dw_hdmi_cec_probe()
274 cec->adap->owner = THIS_MODULE; in dw_hdmi_cec_probe()
276 ret = devm_add_action_or_reset(&pdev->dev, dw_hdmi_cec_del, cec); in dw_hdmi_cec_probe()
280 ret = devm_request_threaded_irq(&pdev->dev, cec->irq, in dw_hdmi_cec_probe()
283 "dw-hdmi-cec", cec->adap); in dw_hdmi_cec_probe()
287 cec->notify = cec_notifier_cec_adap_register(pdev->dev.parent, in dw_hdmi_cec_probe()
288 NULL, cec->adap); in dw_hdmi_cec_probe()
289 if (!cec->notify) in dw_hdmi_cec_probe()
290 return -ENOMEM; in dw_hdmi_cec_probe()
292 ret = cec_register_adapter(cec->adap, pdev->dev.parent); in dw_hdmi_cec_probe()
294 cec_notifier_cec_adap_unregister(cec->notify, cec->adap); in dw_hdmi_cec_probe()
302 devm_remove_action(&pdev->dev, dw_hdmi_cec_del, cec); in dw_hdmi_cec_probe()
311 cec_notifier_cec_adap_unregister(cec->notify, cec->adap); in dw_hdmi_cec_remove()
312 cec_unregister_adapter(cec->adap); in dw_hdmi_cec_remove()
320 dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L); in dw_hdmi_cec_resume()
321 dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H); in dw_hdmi_cec_resume()
324 dw_hdmi_write(cec, cec->regs_polarity, HDMI_CEC_POLARITY); in dw_hdmi_cec_resume()
325 dw_hdmi_write(cec, cec->regs_mask, HDMI_CEC_MASK); in dw_hdmi_cec_resume()
326 dw_hdmi_write(cec, cec->regs_mute_stat0, HDMI_IH_MUTE_CEC_STAT0); in dw_hdmi_cec_resume()
336 cec->regs_polarity = dw_hdmi_read(cec, HDMI_CEC_POLARITY); in dw_hdmi_cec_suspend()
337 cec->regs_mask = dw_hdmi_read(cec, HDMI_CEC_MASK); in dw_hdmi_cec_suspend()
338 cec->regs_mute_stat0 = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0); in dw_hdmi_cec_suspend()
351 .name = "dw-hdmi-cec",
358 MODULE_DESCRIPTION("Synopsys Designware HDMI CEC driver for i.MX");
360 MODULE_ALIAS(PLATFORM_MODULE_PREFIX "dw-hdmi-cec");