Re: [PATCH 5/9] platform/chrome: Add SpacemiT K3 eSPI EC transport

From: Tzung-Bi Shih

Date: Fri Nov 27 2026 - 06:56:28 EST


On Wed, Nov 18, 2026 at 04:57:38PM +0800, Wang Yang wrote:
> Add the K3-specific EC transport as a separate driver. Use a vendor-
> scoped Kconfig symbol, module name and compatible. The register mapping
> and recovery API are tied to the SpacemiT K3 controller, so this does
> not claim to be a generic eSPI EC transport.
>
> Preserve the original independent eSPI command and event logic. Existing
> EC core, LPC, protocol and keyboard implementations remain unchanged.

I haven't done a detailed review as some functions in this patch
(ec_response_timed_out, pkt_xfer, cmd_xfer, readmem) are based on (and
very similar to) cros_ec_lpc.c. Is it possible to refactor
cros_ec_lpc.c to extract the common logic first so that this driver can
reuse it?

E.g.:
- cros_ec_lpc_proto.c and cros_ec_lpc_proto.h for the common logic.
- cros_ec_lpc uses the common logic.
- This driver (consider renaming to cros_ec_espi_spacemit) reuses the
common logic.

Similarly, instead of handling ec->irq in the driver, refactor
cros_ec_register() first and reuse the logic in the driver.

E.g., only set it to IRQF_TRIGGER_LOW if it was unset:
unsigned long irqflags = IRQF_ONESHOT;
if (irq_get_trigger_type(ec_dev->irq) == IRQ_TYPE_NONE)
irqflags |= IRQF_TRIGGER_LOW;

Or introduce an ec_dev->irqflags field:
if (ec_dev->irqflags == 0)
ec_dev->irqflags = IRQF_TRIGGER_LOW | IRQF_ONESHOT;