2022-02-02 10:21:07

by Ettore Chimenti

[permalink] [raw]
Subject: [PATCH 0/2] 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

--
2.17.1


2022-02-02 19:55:29

by Ettore Chimenti

[permalink] [raw]
Subject: [PATCH 2/2] media: cec: seco: add newlines in debug messages

From: Ettore Chimenti <[email protected]>

Newlines were missing in almost all regular and debug printk.

Signed-off-by: Ettore Chimenti <[email protected]>
---
drivers/media/cec/platform/seco/seco-cec.c | 54 +++++++++++-----------
1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/media/cec/platform/seco/seco-cec.c b/drivers/media/cec/platform/seco/seco-cec.c
index ae138cc253fd..78856a55e637 100644
--- a/drivers/media/cec/platform/seco/seco-cec.c
+++ b/drivers/media/cec/platform/seco/seco-cec.c
@@ -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;
}

--
2.17.1