Lines Matching defs:cec

29 #include <media/cec-notifier.h>
33 #define TEGRA_CEC_NAME "tegra-cec"
52 static inline u32 cec_read(struct tegra_cec *cec, u32 reg)
54 return readl(cec->cec_base + reg);
57 static inline void cec_write(struct tegra_cec *cec, u32 reg, u32 val)
59 writel(val, cec->cec_base + reg);
62 static void tegra_cec_error_recovery(struct tegra_cec *cec)
66 hw_ctrl = cec_read(cec, TEGRA_CEC_HW_CONTROL);
67 cec_write(cec, TEGRA_CEC_HW_CONTROL, 0);
68 cec_write(cec, TEGRA_CEC_INT_STAT, 0xffffffff);
69 cec_write(cec, TEGRA_CEC_HW_CONTROL, hw_ctrl);
75 struct tegra_cec *cec = dev_get_drvdata(dev);
77 if (cec->tx_done) {
78 cec_transmit_attempt_done(cec->adap, cec->tx_status);
79 cec->tx_done = false;
81 if (cec->rx_done) {
84 msg.len = cec->rx_buf_cnt;
85 memcpy(msg.msg, cec->rx_buf, msg.len);
86 cec_received_msg(cec->adap, &msg);
87 cec->rx_done = false;
88 cec->rx_buf_cnt = 0;
96 struct tegra_cec *cec = dev_get_drvdata(dev);
99 status = cec_read(cec, TEGRA_CEC_INT_STAT);
100 mask = cec_read(cec, TEGRA_CEC_INT_MASK);
110 tegra_cec_error_recovery(cec);
111 cec_write(cec, TEGRA_CEC_INT_MASK,
114 cec->tx_done = true;
115 cec->tx_status = CEC_TX_STATUS_ERROR;
121 tegra_cec_error_recovery(cec);
122 cec_write(cec, TEGRA_CEC_INT_MASK,
125 cec->tx_done = true;
127 cec->tx_status = CEC_TX_STATUS_LOW_DRIVE;
129 cec->tx_status = CEC_TX_STATUS_ARB_LOST;
134 cec_write(cec, TEGRA_CEC_INT_STAT,
138 tegra_cec_error_recovery(cec);
140 cec->tx_done = true;
141 cec->tx_status = CEC_TX_STATUS_NACK;
143 cec->tx_done = true;
144 cec->tx_status = CEC_TX_STATUS_OK;
153 if (cec->tx_buf_cur == cec->tx_buf_cnt) {
154 cec_write(cec, TEGRA_CEC_INT_MASK,
157 cec_write(cec, TEGRA_CEC_TX_REGISTER,
158 cec->tx_buf[cec->tx_buf_cur++]);
159 cec_write(cec, TEGRA_CEC_INT_STAT,
165 cec_write(cec, TEGRA_CEC_INT_STAT,
167 cec->rx_done = false;
168 cec->rx_buf_cnt = 0;
173 cec_write(cec, TEGRA_CEC_INT_STAT,
175 v = cec_read(cec, TEGRA_CEC_RX_REGISTER);
176 if (cec->rx_buf_cnt < CEC_MAX_MSG_SIZE)
177 cec->rx_buf[cec->rx_buf_cnt++] = v & 0xff;
179 cec->rx_done = true;
189 struct tegra_cec *cec = adap->priv;
191 cec->rx_buf_cnt = 0;
192 cec->tx_buf_cnt = 0;
193 cec->tx_buf_cur = 0;
195 cec_write(cec, TEGRA_CEC_HW_CONTROL, 0);
196 cec_write(cec, TEGRA_CEC_INT_MASK, 0);
197 cec_write(cec, TEGRA_CEC_INT_STAT, 0xffffffff);
198 cec_write(cec, TEGRA_CEC_SW_CONTROL, 0);
203 cec_write(cec, TEGRA_CEC_INPUT_FILTER, (1U << 31) | 0x20);
205 cec_write(cec, TEGRA_CEC_RX_TIMING_0,
211 cec_write(cec, TEGRA_CEC_RX_TIMING_1,
217 cec_write(cec, TEGRA_CEC_RX_TIMING_2,
220 cec_write(cec, TEGRA_CEC_TX_TIMING_0,
226 cec_write(cec, TEGRA_CEC_TX_TIMING_1,
232 cec_write(cec, TEGRA_CEC_TX_TIMING_2,
237 cec_write(cec, TEGRA_CEC_INT_MASK,
246 cec_write(cec, TEGRA_CEC_HW_CONTROL, TEGRA_CEC_HWCTRL_TX_RX_MODE);
252 struct tegra_cec *cec = adap->priv;
253 u32 state = cec_read(cec, TEGRA_CEC_HW_CONTROL);
260 cec_write(cec, TEGRA_CEC_HW_CONTROL, state);
267 struct tegra_cec *cec = adap->priv;
268 u32 reg = cec_read(cec, TEGRA_CEC_HW_CONTROL);
274 cec_write(cec, TEGRA_CEC_HW_CONTROL, reg);
282 struct tegra_cec *cec = adap->priv;
290 cec->tx_buf_cur = 0;
291 cec->tx_buf_cnt = msg->len;
294 cec->tx_buf[i] = mode | msg->msg[i];
296 cec->tx_buf[i] |= TEGRA_CEC_TX_REG_START_BIT;
298 cec->tx_buf[i] |= TEGRA_CEC_TX_REG_EOM;
300 cec->tx_buf[i] |= TEGRA_CEC_TX_REG_RETRY;
303 mask = cec_read(cec, TEGRA_CEC_INT_MASK);
304 cec_write(cec, TEGRA_CEC_INT_MASK,
320 struct tegra_cec *cec;
329 cec = devm_kzalloc(&pdev->dev, sizeof(struct tegra_cec), GFP_KERNEL);
331 if (!cec)
349 cec->tegra_cec_irq = platform_get_irq(pdev, 0);
351 if (cec->tegra_cec_irq < 0)
352 return cec->tegra_cec_irq;
354 cec->cec_base = devm_ioremap(&pdev->dev, res->start,
357 if (!cec->cec_base) {
362 cec->clk = devm_clk_get(&pdev->dev, "cec");
364 if (IS_ERR_OR_NULL(cec->clk)) {
369 ret = clk_prepare_enable(cec->clk);
376 cec->dev = &pdev->dev;
378 platform_set_drvdata(pdev, cec);
380 ret = devm_request_threaded_irq(&pdev->dev, cec->tegra_cec_irq,
390 cec->adap = cec_allocate_adapter(&tegra_cec_ops, cec, TEGRA_CEC_NAME,
394 if (IS_ERR(cec->adap)) {
396 dev_err(&pdev->dev, "Couldn't create cec adapter\n");
400 cec->notifier = cec_notifier_cec_adap_register(hdmi_dev, NULL,
401 cec->adap);
402 if (!cec->notifier) {
407 ret = cec_register_adapter(cec->adap, &pdev->dev);
416 cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
418 cec_delete_adapter(cec->adap);
420 clk_disable_unprepare(cec->clk);
426 struct tegra_cec *cec = platform_get_drvdata(pdev);
428 clk_disable_unprepare(cec->clk);
430 cec_notifier_cec_adap_unregister(cec->notifier, cec->adap);
431 cec_unregister_adapter(cec->adap);
437 struct tegra_cec *cec = platform_get_drvdata(pdev);
439 clk_disable_unprepare(cec->clk);
447 struct tegra_cec *cec = platform_get_drvdata(pdev);
451 return clk_prepare_enable(cec->clk);
456 { .compatible = "nvidia,tegra114-cec", },
457 { .compatible = "nvidia,tegra124-cec", },
458 { .compatible = "nvidia,tegra210-cec", },