Lines Matching +full:cec +full:- +full:irq
1 // SPDX-License-Identifier: GPL-2.0-only
3 * adv7511_cec.c - Analog Devices ADV7511/33 cec driver
13 #include <media/cec.h>
36 unsigned int offset = adv7511->info->reg_cec_offset; in adv_cec_tx_raw_status()
39 if (regmap_read(adv7511->regmap_cec, in adv_cec_tx_raw_status()
47 cec_transmit_attempt_done(adv7511->cec_adap, in adv_cec_tx_raw_status()
63 if (regmap_read(adv7511->regmap_cec, in adv_cec_tx_raw_status()
75 cec_transmit_done(adv7511->cec_adap, status, in adv_cec_tx_raw_status()
80 cec_transmit_attempt_done(adv7511->cec_adap, CEC_TX_STATUS_OK); in adv_cec_tx_raw_status()
87 unsigned int offset = adv7511->info->reg_cec_offset; in adv7511_cec_rx()
93 if (regmap_read(adv7511->regmap_cec, in adv7511_cec_rx()
106 regmap_read(adv7511->regmap_cec, in adv7511_cec_rx()
112 /* Toggle RX Ready Clear bit to re-enable this RX buffer */ in adv7511_cec_rx()
113 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_rx()
116 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_rx()
119 cec_received_msg(adv7511->cec_adap, &msg); in adv7511_cec_rx()
124 unsigned int offset = adv7511->info->reg_cec_offset; in adv7511_cec_irq_process()
132 int rx_order[3] = { -1, -1, -1 }; in adv7511_cec_irq_process()
144 if (regmap_read(adv7511->regmap_cec, in adv7511_cec_irq_process()
159 * read from in order, where -1 indicates that there are no in adv7511_cec_irq_process()
166 rx_order[timestamp - 1] = i; in adv7511_cec_irq_process()
169 /* Read CEC RX buffers in the appropriate order as prescribed above */ in adv7511_cec_irq_process()
185 unsigned int offset = adv7511->info->reg_cec_offset; in adv7511_cec_adap_enable()
187 if (adv7511->i2c_cec == NULL) in adv7511_cec_adap_enable()
188 return -EIO; in adv7511_cec_adap_enable()
190 if (!adv7511->cec_enabled_adap && enable) { in adv7511_cec_adap_enable()
191 /* power up cec section */ in adv7511_cec_adap_enable()
192 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_enable()
195 /* non-legacy mode and clear all rx buffers */ in adv7511_cec_adap_enable()
196 regmap_write(adv7511->regmap_cec, in adv7511_cec_adap_enable()
198 regmap_write(adv7511->regmap_cec, in adv7511_cec_adap_enable()
201 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_enable()
207 /* rx: ready 1-3 */ in adv7511_cec_adap_enable()
208 regmap_update_bits(adv7511->regmap, in adv7511_cec_adap_enable()
211 } else if (adv7511->cec_enabled_adap && !enable) { in adv7511_cec_adap_enable()
212 regmap_update_bits(adv7511->regmap, in adv7511_cec_adap_enable()
214 /* disable address mask 1-3 */ in adv7511_cec_adap_enable()
215 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_enable()
218 /* power down cec section */ in adv7511_cec_adap_enable()
219 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_enable()
222 adv7511->cec_valid_addrs = 0; in adv7511_cec_adap_enable()
224 adv7511->cec_enabled_adap = enable; in adv7511_cec_adap_enable()
231 unsigned int offset = adv7511->info->reg_cec_offset; in adv7511_cec_adap_log_addr()
234 if (!adv7511->cec_enabled_adap) in adv7511_cec_adap_log_addr()
235 return addr == CEC_LOG_ADDR_INVALID ? 0 : -EIO; in adv7511_cec_adap_log_addr()
238 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_log_addr()
241 adv7511->cec_valid_addrs = 0; in adv7511_cec_adap_log_addr()
246 bool is_valid = adv7511->cec_valid_addrs & (1 << i); in adv7511_cec_adap_log_addr()
250 if (is_valid && adv7511->cec_addr[i] == addr) in adv7511_cec_adap_log_addr()
256 return -ENXIO; in adv7511_cec_adap_log_addr()
258 adv7511->cec_addr[i] = addr; in adv7511_cec_adap_log_addr()
259 adv7511->cec_valid_addrs |= 1 << i; in adv7511_cec_adap_log_addr()
264 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_log_addr()
268 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_log_addr()
274 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_log_addr()
278 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_log_addr()
284 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_log_addr()
288 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_log_addr()
300 unsigned int offset = adv7511->info->reg_cec_offset; in adv7511_cec_adap_transmit()
301 u8 len = msg->len; in adv7511_cec_adap_transmit()
305 * The number of retries is the number of attempts - 1, but retry in adv7511_cec_adap_transmit()
309 regmap_update_bits(adv7511->regmap_cec, in adv7511_cec_adap_transmit()
311 0x70, max(1, attempts - 1) << 4); in adv7511_cec_adap_transmit()
313 /* blocking, clear cec tx irq status */ in adv7511_cec_adap_transmit()
314 regmap_update_bits(adv7511->regmap, ADV7511_REG_INT(1), 0x38, 0x38); in adv7511_cec_adap_transmit()
318 regmap_write(adv7511->regmap_cec, in adv7511_cec_adap_transmit()
320 msg->msg[i]); in adv7511_cec_adap_transmit()
323 regmap_write(adv7511->regmap_cec, in adv7511_cec_adap_transmit()
326 regmap_write(adv7511->regmap_cec, in adv7511_cec_adap_transmit()
339 adv7511->cec_clk = devm_clk_get(dev, "cec"); in adv7511_cec_parse_dt()
340 if (IS_ERR(adv7511->cec_clk)) { in adv7511_cec_parse_dt()
341 int ret = PTR_ERR(adv7511->cec_clk); in adv7511_cec_parse_dt()
343 adv7511->cec_clk = NULL; in adv7511_cec_parse_dt()
346 clk_prepare_enable(adv7511->cec_clk); in adv7511_cec_parse_dt()
347 adv7511->cec_clk_freq = clk_get_rate(adv7511->cec_clk); in adv7511_cec_parse_dt()
353 unsigned int offset = adv7511->info->reg_cec_offset; in adv7511_cec_init()
359 adv7511->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops, in adv7511_cec_init()
361 if (IS_ERR(adv7511->cec_adap)) { in adv7511_cec_init()
362 ret = PTR_ERR(adv7511->cec_adap); in adv7511_cec_init()
366 regmap_write(adv7511->regmap, ADV7511_REG_CEC_CTRL, 0); in adv7511_cec_init()
367 /* cec soft reset */ in adv7511_cec_init()
368 regmap_write(adv7511->regmap_cec, in adv7511_cec_init()
370 regmap_write(adv7511->regmap_cec, in adv7511_cec_init()
373 /* non-legacy mode - use all three RX buffers */ in adv7511_cec_init()
374 regmap_write(adv7511->regmap_cec, in adv7511_cec_init()
377 regmap_write(adv7511->regmap_cec, in adv7511_cec_init()
379 ((adv7511->cec_clk_freq / 750000) - 1) << 2); in adv7511_cec_init()
381 ret = cec_register_adapter(adv7511->cec_adap, dev); in adv7511_cec_init()
387 cec_delete_adapter(adv7511->cec_adap); in adv7511_cec_init()
388 adv7511->cec_adap = NULL; in adv7511_cec_init()
390 dev_info(dev, "Initializing CEC failed with error %d, disabling CEC\n", in adv7511_cec_init()
393 regmap_write(adv7511->regmap, ADV7511_REG_CEC_CTRL, in adv7511_cec_init()
395 return ret == -EPROBE_DEFER ? ret : 0; in adv7511_cec_init()