Lines Matching +full:cec +full:- +full:irq
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * CEC driver for SECO X86 Boards
19 /* CEC Framework */
20 #include <media/cec-notifier.h>
22 #include "seco-cec.h"
31 int irq; member
75 status = -EBUSY; in smb_word_op()
80 status = -EIO; in smb_word_op()
94 struct secocec_data *cec = cec_get_drvdata(adap); in secocec_adap_enable() local
95 struct device *dev = cec->dev; in secocec_adap_enable()
161 /* Re-enable device */ in secocec_adap_log_addr()
179 payload_id_len = msg->len - 1; in secocec_adap_transmit()
188 status = smb_wr16(SECOCEC_WRITE_OPERATION_ID, msg->msg[1]); in secocec_adap_transmit()
195 payload_len = msg->len - 2; in secocec_adap_transmit()
196 payload_msg = &msg->msg[2]; in secocec_adap_transmit()
212 destination = msg->msg[0]; in secocec_adap_transmit()
243 struct secocec_data *cec = cec_get_drvdata(adap); in secocec_rx_done() local
244 struct device *dev = cec->dev; in secocec_rx_done()
260 status = -EIO; in secocec_rx_done()
289 payload_len = msg.len - 2; in secocec_rx_done()
292 /* device stores 2 bytes in every 16-bit val */ in secocec_rx_done()
306 cec_received_msg(cec->cec_adap, &msg); in secocec_rx_done()
327 /* Low-level callbacks */
336 struct secocec_data *cec = priv; in secocec_ir_probe() local
337 struct device *dev = cec->dev; in secocec_ir_probe()
342 cec->ir = devm_rc_allocate_device(dev, RC_DRIVER_SCANCODE); in secocec_ir_probe()
343 if (!cec->ir) in secocec_ir_probe()
344 return -ENOMEM; in secocec_ir_probe()
346 snprintf(cec->ir_input_phys, sizeof(cec->ir_input_phys), in secocec_ir_probe()
349 cec->ir->device_name = dev_name(dev); in secocec_ir_probe()
350 cec->ir->input_phys = cec->ir_input_phys; in secocec_ir_probe()
351 cec->ir->input_id.bustype = BUS_HOST; in secocec_ir_probe()
352 cec->ir->input_id.vendor = 0; in secocec_ir_probe()
353 cec->ir->input_id.product = 0; in secocec_ir_probe()
354 cec->ir->input_id.version = 1; in secocec_ir_probe()
355 cec->ir->driver_name = SECOCEC_DEV_NAME; in secocec_ir_probe()
356 cec->ir->allowed_protocols = RC_PROTO_BIT_RC5; in secocec_ir_probe()
357 cec->ir->priv = cec; in secocec_ir_probe()
358 cec->ir->map_name = RC_MAP_HAUPPAUGE; in secocec_ir_probe()
359 cec->ir->timeout = MS_TO_US(100); in secocec_ir_probe()
382 status = devm_rc_register_device(dev, cec->ir); in secocec_ir_probe()
386 cec->ir = NULL; in secocec_ir_probe()
404 struct secocec_data *cec = priv; in secocec_ir_rx() local
405 struct device *dev = cec->dev; in secocec_ir_rx()
408 if (!cec->ir) in secocec_ir_rx()
409 return -ENODEV; in secocec_ir_rx()
419 rc_keydown(cec->ir, RC_PROTO_RC5, RC_SCANCODE_RC5(addr, key), toggle); in secocec_ir_rx()
428 return -EIO; in secocec_ir_rx()
441 static irqreturn_t secocec_irq_handler(int irq, void *priv) in secocec_irq_handler() argument
443 struct secocec_data *cec = priv; in secocec_irq_handler() local
444 struct device *dev = cec->dev; in secocec_irq_handler()
454 /* Read CEC status register */ in secocec_irq_handler()
460 secocec_rx_done(cec->cec_adap, cec_val); in secocec_irq_handler()
463 secocec_tx_done(cec->cec_adap, cec_val); in secocec_irq_handler()
476 secocec_ir_rx(cec); in secocec_irq_handler()
487 dev_err_once(dev, "IRQ: R/W SMBus operation failed %d\n", status); in secocec_irq_handler()
516 if (dmi_match(DMI_SYS_VENDOR, m->sys_vendor) && in secocec_cec_find_hdmi_dev()
517 dmi_match(DMI_PRODUCT_NAME, m->product_name)) { in secocec_cec_find_hdmi_dev()
522 m->devname); in secocec_cec_find_hdmi_dev()
524 return ERR_PTR(-EPROBE_DEFER); in secocec_cec_find_hdmi_dev()
527 *conn = m->conn; in secocec_cec_find_hdmi_dev()
532 return ERR_PTR(-EINVAL); in secocec_cec_find_hdmi_dev()
537 struct device *dev = sdev->dev; in secocec_acpi_probe()
539 int irq = 0; in secocec_acpi_probe() local
547 irq = gpiod_to_irq(gpio); in secocec_acpi_probe()
548 if (irq < 0) { in secocec_acpi_probe()
549 dev_err(dev, "Cannot find valid irq\n"); in secocec_acpi_probe()
550 return -ENODEV; in secocec_acpi_probe()
552 dev_dbg(dev, "irq-gpio is bound to IRQ %d\n", irq); in secocec_acpi_probe()
554 sdev->irq = irq; in secocec_acpi_probe()
562 struct device *dev = &pdev->dev; in secocec_probe()
568 hdmi_dev = secocec_cec_find_hdmi_dev(&pdev->dev, &conn); in secocec_probe()
574 return -ENOMEM; in secocec_probe()
581 return -ENXIO; in secocec_probe()
584 secocec->pdev = pdev; in secocec_probe()
585 secocec->dev = dev; in secocec_probe()
589 ret = -ENODEV; in secocec_probe()
595 dev_err(dev, "Cannot assign gpio to IRQ\n"); in secocec_probe()
596 ret = -ENODEV; in secocec_probe()
607 dev_err(dev, "CEC Firmware not supported (v.%04x). Use ver > v.%04x\n", in secocec_probe()
609 ret = -EINVAL; in secocec_probe()
614 secocec->irq, in secocec_probe()
618 dev_name(&pdev->dev), secocec); in secocec_probe()
621 dev_err(dev, "Cannot request IRQ %d\n", secocec->irq); in secocec_probe()
622 ret = -EIO; in secocec_probe()
626 /* Allocate CEC adapter */ in secocec_probe()
627 secocec->cec_adap = cec_allocate_adapter(&secocec_cec_adap_ops, in secocec_probe()
634 if (IS_ERR(secocec->cec_adap)) { in secocec_probe()
635 ret = PTR_ERR(secocec->cec_adap); in secocec_probe()
639 secocec->notifier = cec_notifier_cec_adap_register(hdmi_dev, conn, in secocec_probe()
640 secocec->cec_adap); in secocec_probe()
641 if (!secocec->notifier) { in secocec_probe()
642 ret = -ENOMEM; in secocec_probe()
646 ret = cec_register_adapter(secocec->cec_adap, dev); in secocec_probe()
661 cec_notifier_cec_adap_unregister(secocec->notifier, secocec->cec_adap); in secocec_probe()
663 cec_delete_adapter(secocec->cec_adap); in secocec_probe()
676 if (secocec->ir) { in secocec_remove()
681 dev_dbg(&pdev->dev, "IR disabled\n"); in secocec_remove()
683 cec_notifier_cec_adap_unregister(secocec->notifier, secocec->cec_adap); in secocec_remove()
684 cec_unregister_adapter(secocec->cec_adap); in secocec_remove()
688 dev_dbg(&pdev->dev, "CEC device removed\n"); in secocec_remove()
786 MODULE_DESCRIPTION("SECO CEC X86 Driver");