Add SECO CEC driver for MEC Based boards
Subsystems (3)
ektor5
maintainercover Add SECO CEC driver for MEC Based boards
From: Ettore Chimenti <[email protected]>
Hi all,
This series adds the SECO CEC driver for MAC-based Boards. The boards have a Microchip MEC microcontroller as a general-purpose Embedded Controller, and they communicate through a mailbox interface.
The EC used is more powerful and enables management of several CEC lines at once (up to 4). The focus is on Intel-based SBC-D61 board and UDOO Vision (SBC-D02) in this version, as the UDOO BOLT firmware implementation is still ongoing. Moreover, there is no CEC Notifier functionality inside amdgpu yet.
Similarly to the previous implementation, there are several commands that can be issued, like WRITE and READ commands for sending and receiving CEC messages. The retrieval and send confirmation are triggered by a single GPIO interrupt connected directly to the SoC.
After every STATUS command, the MEC returns a data struct with all the channels status, and it automatically clears the interrupt state afterwards.
In this implementation, the driver sends also the physical address to the EC. This way it is possible to wake up the board upon receiving an SET_STREAM_PATH with the matching physical address when the CPU is in S3 or S5 (depending on BIOS settings). The only time that it seems to be already set is in the LA assignment (in the .enable callback it is not set yet).
The last patch adds missing newlines to debug prints in the previous driver seco-cec.
Best Regards,
Ettore
Ettore Chimenti (2):
media: cec: add SECO MEC-based cec driver
media: cec: seco: add newlines in debug messages
MAINTAINERS | 2 + drivers/media/cec/platform/Kconfig | 22 +- drivers/media/cec/platform/seco/Makefile | 3 +- drivers/media/cec/platform/seco/seco-cec.c | 54 +- drivers/media/cec/platform/seco/seco-meccec.c | 821 ++++++++++++++++++ drivers/media/cec/platform/seco/seco-meccec.h | 130 +++ 6 files changed, 1002 insertions(+), 30 deletions(-) create mode 100644 drivers/media/cec/platform/seco/seco-meccec.c create mode 100644 drivers/media/cec/platform/seco/seco-meccec.h
Signature · 1 line
2.17.1
ektor5
maintainerPATCH 1/2 media: cec: add SECO MEC-based cec driver
From: Ettore Chimenti <[email protected]>
This patch adds support to the CEC device implemented with a Microchip MEC microcontroller in SECO Boards, including UDOO BOLT and UDOO Vision.
The communication is achieved via Mailbox protocol.
The driver use direct access to the PCI addresses.
The firmware implementation also supports resuming from suspend by sending physical address to EC and waiting for a SET_STREAM_PATH command that matches the provided physical address.
The basic functionalities are tested with success with cec-ctl and cec-compliance.
Inspired by previous seco-cec implementation, attaches to i915 driver cec-notifier.
--- MAINTAINERS | 2 + drivers/media/cec/platform/Kconfig | 22 +- drivers/media/cec/platform/seco/Makefile | 3 +- drivers/media/cec/platform/seco/seco-meccec.c | 821 ++++++++++++++++++ drivers/media/cec/platform/seco/seco-meccec.h | 130 +++ 5 files changed, 975 insertions(+), 3 deletions(-) create mode 100644 drivers/media/cec/platform/seco/seco-meccec.c create mode 100644 drivers/media/cec/platform/seco/seco-meccec.h
MAINTAINERS +2 -0
@@ -17273,6 +17273,8 @@ M: Ettore Chimenti <[email protected]> S: Maintained F: drivers/media/cec/platform/seco/seco-cec.c F: drivers/media/cec/platform/seco/seco-cec.h +F: drivers/media/cec/platform/seco/seco-meccec.c +F: drivers/media/cec/platform/seco/seco-meccec.h SECURE COMPUTING M: Kees Cook <[email protected]>
drivers/media/cec/platform/Kconfig +20 -2
@@ -98,7 +98,11 @@ config CEC_TEGRA between compatible devices. config CEC_SECO - tristate "SECO Boards HDMI CEC driver" + bool "SECO Boards HDMI CEC drivers" + +config CEC_SECO_LEGACY + tristate "SECO Legacy Boards HDMI CEC driver" + depends on CEC_SECO depends on (X86 || IA64) || COMPILE_TEST depends on PCI && DMI select CEC_CORE
@@ -109,9 +113,23 @@ config CEC_SECO CEC bus is present in the HDMI connector and enables communication between compatible devices. +config CEC_SECO_MEC + tristate "SECO MEC-Based Boards HDMI CEC driver" + depends on CEC_SECO + depends on (X86 || IA64) || COMPILE_TEST + depends on PCI && DMI + select CEC_CORE + select CEC_NOTIFIER + help + This is a driver for SECO MEC-Based Boards integrated CEC interface. + Selecting it will enable support for this device. + CEC bus is present in the HDMI connectors and enables communication + between compatible devices. + + config CEC_SECO_RC bool "SECO Boards IR RC5 support" - depends on CEC_SECO + depends on CEC_SECO_LEGACY depends on RC_CORE=y || RC_CORE = CEC_SECO help If you say yes here you will get support for the
drivers/media/cec/platform/seco/Makefile +2 -1
@@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_CEC_SECO) += seco-cec.o +obj-$(CONFIG_CEC_SECO_LEGACY) += seco-cec.o +obj-$(CONFIG_CEC_SECO_MEC) += seco-meccec.o
drivers/media/cec/platform/seco/seco-meccec.c new file +821 -0
821 lines not on this page · raw message
drivers/media/cec/platform/seco/seco-meccec.h new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH 1/2] media: cec: add SECO MEC-based cec driver
I love your patch! Perhaps something to improve:
Hi ektor5,
I love your patch! Perhaps something to improve:
[auto build test WARNING on media-tree/master]
[also build test WARNING on linux/master linus/master v5.17-rc2 next-20220202] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/ektor5/Add-SECO-CEC-driver-for-MEC-Based-boards/20220202-023834 base: git://linuxtv.org/media_tree.git master config: x86_64-allmodconfig (https://download.01.org/0day-ci/archive/20220202/202202022216.MCt6c52g-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6b1e844b69f15bb7dffaf9365cd2b355d2eb7579)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/8960cb39808a004dee84a2f955ed949b1a4da7a8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review ektor5/Add-SECO-CEC-driver-for-MEC-Based-boards/20220202-023834
git checkout 8960cb39808a004dee84a2f955ed949b1a4da7a8
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/media/cec/platform/seco/ drivers/net/wireless/ath/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/media/cec/platform/seco/seco-meccec.c:735:8: warning: variable 'adaps' is uninitialized when used here [-Wuninitialized]
if (adaps--)
^~~~~
drivers/media/cec/platform/seco/seco-meccec.c:634:11: note: initialize the variable 'adaps' to silence this warning
int adaps, notifs = 0;
^
= 01 warning generated.
vim +/adaps +735 drivers/media/cec/platform/seco/seco-meccec.c
626
627 static int seco_meccec_probe(struct platform_device *pdev)
628 {
629 struct seco_meccec_data *meccec;
630 struct device *dev = &pdev->dev;
631 struct device *hdmi_dev;
632 const char * const *conn;
633 int ret, idx;
634 int adaps, notifs = 0;
635
636 meccec = devm_kzalloc(dev, sizeof(*meccec), GFP_KERNEL);
637 if (!meccec)
638 return -ENOMEM;
639
640 dev_set_drvdata(dev, meccec);
641
642 meccec->pdev = pdev;
643 meccec->dev = dev;
644
645 ret = ec_get_version(meccec);
646 if (ret) {
647 dev_err(dev, "Get version failed\n");
648 goto err;
649 }
650
651 if (!has_acpi_companion(dev)) {
652 dev_err(dev, "Cannot find any ACPI companion\n");
653 ret = -ENODEV;
654 goto err;
655 }
656
657 ret = seco_meccec_acpi_probe(meccec);
658 if (ret) {
659 dev_err(dev, "ACPI probe failed\n");
660 goto err;
661 }
662
663 ret = devm_request_threaded_irq(dev,
664 meccec->irq,
665 NULL,
666 seco_meccec_irq_handler,
667 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
668 dev_name(&pdev->dev), meccec);
669
670 if (ret) {
671 dev_err(dev, "Cannot request IRQ %d\n", meccec->irq);
672 ret = -EIO;
673 goto err;
674 }
675
676 hdmi_dev = seco_meccec_find_hdmi_dev(&pdev->dev, &conn);
677 if (IS_ERR(hdmi_dev)) {
678 dev_err(dev, "Cannot find HDMI Device\n");
679 return PTR_ERR(hdmi_dev);
680 }
681 dev_dbg(dev, "HDMI device found\n");
682
683 for (idx = 0; idx < MECCEC_MAX_CEC_ADAP; idx++) {
684 if (meccec->channels & BIT_MASK(idx)) {
685 ret = meccec_create_adapter(meccec, idx);
686 if (ret)
687 goto err_delete_adapter;
688 dev_dbg(dev, "CEC adapter #%d allocated\n", idx);
689 }
690 }
691
692 for (idx = 0; idx < MECCEC_MAX_CEC_ADAP; idx++) {
693 if (meccec->channels & BIT_MASK(idx)) {
694 struct cec_adapter *acec = meccec->cec_adap[idx];
695 struct cec_notifier *ncec;
696
697 if (!acec) {
698 ret = -EINVAL;
699 goto err_notifier;
700 }
701
702 ncec = cec_notifier_cec_adap_register(hdmi_dev,
703 conn[idx], acec);
704
705 dev_dbg(dev, "CEC notifier #%d allocated %s\n", idx, conn[idx]);
706
707 if (IS_ERR(ncec)) {
708 ret = PTR_ERR(ncec);
709 goto err_notifier;
710 }
711
712 meccec->notifier[idx] = ncec;
713 notifs++;
714 }
715 }
716
717 for (idx = 0; idx < MECCEC_MAX_CEC_ADAP; idx++) {
718 if (meccec->channels & BIT_MASK(idx)) {
719 ret = cec_register_adapter(meccec->cec_adap[idx], dev);
720 if (ret)
721 goto err_notifier;
722
723 dev_dbg(dev, "CEC adapter #%d registered\n", idx);
724 }
725 }
726
727 platform_set_drvdata(pdev, meccec);
728 dev_dbg(dev, "Device registered\n");
729
730 return ret;
731
732 err_notifier:
733 for (idx = 0; idx < MECCEC_MAX_CEC_ADAP; idx++) {
734 if (meccec->channels & BIT_MASK(idx)) {
> 735 if (adaps--)
736 return ret;
737
738 cec_notifier_cec_adap_unregister(meccec->notifier[idx],
739 meccec->cec_adap[idx]);
740 }
741 }
742 err_delete_adapter:
743 for (idx = 0; idx < MECCEC_MAX_CEC_ADAP; idx++) {
744 if (meccec->channels & BIT_MASK(idx)) {
745 if (notifs--)
746 return ret;
747
748 cec_delete_adapter(meccec->cec_adap[idx]);
749 }
750 }
751 err:
752 dev_err(dev, "%s device probe failed: %d\n", dev_name(dev), ret);
753
754 return ret;
755 }
756
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
ektor5
maintainerPATCH 2/2 media: cec: seco: add newlines in debug messages
In reply to ektor5From: Ettore Chimenti <[email protected]>
Newlines were missing in almost all regular and debug printk.
--- drivers/media/cec/platform/seco/seco-cec.c | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/media/cec/platform/seco/seco-cec.c +27 -27
@@ -129,7 +129,7 @@ static int secocec_adap_enable(struct cec_adapter *adap, bool enable)if (status) goto err; -dev_dbg (dev,"Device enabled" ); +dev_dbg (dev,"Device enabled\n" ); }else {/* Clear the status register */ status =smb_rd16 (SECOCEC_STATUS_REG_1 , &val);
@@ -141,7 +141,7 @@ static int secocec_adap_enable(struct cec_adapter *adap, bool enable) ~SECOCEC_ENABLE_REG_1_CEC & ~SECOCEC_ENABLE_REG_1_IR); -dev_dbg (dev,"Device disabled" ); +dev_dbg (dev,"Device disabled\n" ); }return 0 ;
@@ -264,12 +264,12 @@ static void secocec_rx_done(struct cec_adapter *adap, u16 status_val)if (status_val &SECOCEC_STATUS_RX_OVERFLOW_MASK ) {/* NOTE: Untested, it also might not be necessary */ -dev_warn (dev,"Received more than 16 bytes. Discarding" ); +dev_warn (dev,"Received more than 16 bytes. Discarding\n" ); flag_overflow = true; }if (status_val &SECOCEC_STATUS_RX_ERROR_MASK ) { -dev_warn (dev,"Message received with errors. Discarding" ); +dev_warn (dev,"Message received with errors. Discarding\n" ); status = -EIO ; goto rxerr; }
@@ -390,12 +390,12 @@ static int secocec_ir_probe(void *priv)if (status !=0 ) goto err; -dev_dbg (dev,"IR enabled" ); +dev_dbg (dev,"IR enabled\n" ); status =devm_rc_register_device (dev, cec->ir);if (status) { -dev_err (dev,"Failed to prepare input device" ); +dev_err (dev,"Failed to prepare input device\n" ); cec->ir =NULL ; goto err; }
@@ -408,7 +408,7 @@ static int secocec_ir_probe(void *priv)smb_wr16 (SECOCEC_ENABLE_REG_1 , val & ~SECOCEC_ENABLE_REG_1_IR ); -dev_dbg (dev,"IR disabled" ); +dev_dbg (dev,"IR disabled\n" );return status; }
@@ -431,13 +431,13 @@ static int secocec_ir_rx(struct secocec_data *priv)rc_keydown (cec->ir,RC_PROTO_RC5 ,RC_SCANCODE_RC5 (addr, key), toggle); -dev_dbg (dev,"IR key pressed: 0x%02x addr 0x%02x toggle 0x%02x" , key, +dev_dbg (dev,"IR key pressed: 0x%02x addr 0x%02x toggle 0x%02x\n" , key, addr, toggle);return 0 ; err: -dev_err (dev,"IR Receive message failed (%d)" , status); +dev_err (dev,"IR Receive message failed (%d)\n" , status); return -EIO; }#else
@@ -497,7 +497,7 @@ static irqreturn_t secocec_irq_handler(int irq, void *priv)return IRQ_HANDLED ; err: -dev_err_once (dev,"IRQ: R/W SMBus operation failed (%d)" , status); +dev_err_once (dev,"IRQ: R/W SMBus operation failed %d\n" , status);/* Reset status register */ val =SECOCEC_STATUS_REG_1_CEC |SECOCEC_STATUS_REG_1_IR ;
@@ -553,16 +553,16 @@ static int secocec_acpi_probe(struct secocec_data *sdev) gpio =devm_gpiod_get (dev,NULL ,GPIOF_IN );if (IS_ERR (gpio)) { -dev_err (dev,"Cannot request interrupt gpio" ); +dev_err (dev,"Cannot request interrupt gpio\n" );return PTR_ERR (gpio); } irq =gpiod_to_irq (gpio);if (irq <0 ) { -dev_err (dev,"Cannot find valid irq" ); +dev_err (dev,"Cannot find valid irq\n" );return -ENODEV ; } -dev_dbg (dev,"irq-gpio is bound to IRQ %d" , irq); +dev_dbg (dev,"irq-gpio is bound to IRQ %d\n" , irq); sdev->irq = irq;
@@ -590,7 +590,7 @@ static int secocec_probe(struct platform_device *pdev)/* Request SMBus regions */ if (!request_muxed_region (BRA_SMB_BASE_ADDR ,7 ,"CEC00001" )) { -dev_err (dev,"Request memory region failed" ); +dev_err (dev,"Request memory region failed\n" );return -ENXIO ; }
@@ -598,14 +598,14 @@ static int secocec_probe(struct platform_device *pdev) secocec->dev = dev;if (!has_acpi_companion (dev)) { -dev_dbg (dev,"Cannot find any ACPI companion" ); +dev_dbg (dev,"Cannot find any ACPI companion\n" ); ret = -ENODEV ; goto err; } ret =secocec_acpi_probe (secocec);if (ret) { -dev_err (dev,"Cannot assign gpio to IRQ" ); +dev_err (dev,"Cannot assign gpio to IRQ\n" ); ret = -ENODEV ; goto err; }
@@ -613,11 +613,11 @@ static int secocec_probe(struct platform_device *pdev)/* Firmware version check */ ret =smb_rd16 (SECOCEC_VERSION , &val);if (ret) { -dev_err (dev,"Cannot check fw version" ); +dev_err (dev,"Cannot check fw version\n" ); goto err; }if (val <SECOCEC_LATEST_FW ) { -dev_err (dev,"CEC Firmware not supported (v.%04x). Use ver > v.%04x" , +dev_err (dev,"CEC Firmware not supported (v.%04x). Use ver > v.%04x\n" , val,SECOCEC_LATEST_FW ); ret = -EINVAL ; goto err;
@@ -631,7 +631,7 @@ static int secocec_probe(struct platform_device *pdev) dev_name(&pdev->dev), secocec);if (ret) { -dev_err (dev,"Cannot request IRQ %d" , secocec->irq); +dev_err (dev,"Cannot request IRQ %d\n" , secocec->irq); ret = -EIO ; goto err; }
@@ -666,7 +666,7 @@ static int secocec_probe(struct platform_device *pdev)platform_set_drvdata (pdev, secocec); -dev_dbg (dev,"Device registered" ); +dev_dbg (dev,"Device registered\n" );return ret;
@@ -691,14 +691,14 @@ static int secocec_remove(struct platform_device *pdev)smb_wr16 (SECOCEC_ENABLE_REG_1 , val & ~SECOCEC_ENABLE_REG_1_IR ); -dev_dbg (&pdev->dev,"IR disabled" ); +dev_dbg (&pdev->dev,"IR disabled\n" ); }cec_notifier_cec_adap_unregister (secocec->notifier, secocec->cec_adap);cec_unregister_adapter (secocec->cec_adap);release_region (BRA_SMB_BASE_ADDR ,7 ); -dev_dbg (&pdev->dev,"CEC device removed" ); +dev_dbg (&pdev->dev,"CEC device removed\n" );return 0 ; }
@@ -709,7 +709,7 @@ static int secocec_suspend(struct device *dev)int status;u16 val; -dev_dbg (dev,"Device going to suspend, disabling" ); +dev_dbg (dev,"Device going to suspend, disabling\n" );/* Clear the status register */ status =smb_rd16 (SECOCEC_STATUS_REG_1 , &val);
@@ -733,7 +733,7 @@ static int secocec_suspend(struct device *dev)return 0 ; err: -dev_err (dev,"Suspend failed (err: %d)" , status); +dev_err (dev,"Suspend failed: %d\n" , status);return status; }
@@ -742,7 +742,7 @@ static int secocec_resume(struct device *dev)int status;u16 val; -dev_dbg (dev,"Resuming device from suspend" ); +dev_dbg (dev,"Resuming device from suspend\n" );/* Clear the status register */ status =smb_rd16 (SECOCEC_STATUS_REG_1 , &val);
@@ -762,12 +762,12 @@ static int secocec_resume(struct device *dev)if (status) goto err; -dev_dbg (dev,"Device resumed from suspend" ); +dev_dbg (dev,"Device resumed from suspend\n" );return 0 ; err: -dev_err (dev,"Resume failed (err: %d)" , status); +dev_err (dev,"Resume failed: %d\n" , status);return status; }
Signature · 1 line
2.17.1