Skip to contentSkip to conversation

Add SpacemiT K3 FML13V05 EC keyboard support

PATCH In review Wang Yang 4 participants 23 messages Nov 18 – Nov 19

Subsystems (6)
lore
Share & tools
lore

Wang Yang

author
#0 lore raw

cover Add SpacemiT K3 FML13V05 EC keyboard support

The DeepComputing FML13V05 uses a ChromeOS-compatible embedded controller connected through the SpacemiT K3 eSPI peripheral channel. Its internal keyboard is not available on linux-next without the controller and EC transport support described in this series.

The EC host command registers are exposed through a memory-mapped, non-linear peripheral window. This interface cannot use the ordinary cros_ec_spi message transport directly. Add a K3-specific controller and EC transport, and reuse the existing ChromeOS EC protocol, MFD and keyboard drivers. Existing EC core, LPC, SPI, protocol and keyboard C files and the google,cros-ec binding are unchanged.

The series is based on next-20261116. Patches 1-2 document the controller and EC bindings; patch 3 adds the controller; patches 4-5 enable Chrome platform support on RISC-V and add the EC transport; patches 6-8 describe the pins, controller and board keyboard; patch 9 enables the drivers in riscv defconfig, with the EC transport and keyboard built as modules.

The controller implementation is ported from the SpacemiT vendor BSP (revision 29b78afb484b, originally authored by goumin <[email protected]>). Controller programming and recovery remain separate from the EC client. The EC transport and compatible are scoped to K3 because the window layout and controller recovery API are specific to this hardware. Feedback on the transport split and recovery interface is welcome.

Validation on an FML13V05 with its internal keyboard, 2026-11-18:
- W=1 cross-build of Image, modules and the board DTB completed. No new warnings came from the added drivers.
- Both new bindings and their compiled examples passed schema validation; the new examples passed strict DT style checks. The new EC, controller and keyboard nodes in the board DTB also passed validation.
- Cold boot and module autoload passed all 20 automatic checks.
- 153 read-only EC queries and three EC module unload/reload cycles succeeded. EC firmware was FML13V05-V01.06.
- A/B/C/1/2/Enter, all four arrows and Fn+F1/F2/F7/F8 produced the expected 28 paired press/release events, with no dropped or held keys and no new EC/eSPI errors in the kernel log.

The running test kernel was 7.4.0-rc3-next-20261116-fml13v05-k3-espi+.
Booting the test system required a separate K3 PCIe test module and USB/NVMe DT additions, which are outside this EC series. Suspend/resume, EC restart fault injection, full-keymap coverage and long-duration stability were not tested. A previously observed UEFI reset_system() failure was not addressed or retested by this series.

Checkpatch reports no errors or CHECK findings. Its four new-file MAINTAINERS reminders were reviewed: the existing SpacemiT N: pattern and Chrome EC/DT entries already cover the new paths, so no MAINTAINERS change is included.

OpenAI Codex assisted the port, patch preparation, review analysis and test tooling. The work was developed through an iterative session to port the existing DC-linux/BSP support, keep the common EC implementation unchanged, use K3-specific naming and bindings, and verify the result on hardware. Human review was completed before submission; the numbered patches retain the submitter's existing DCO sign-offs.

Wang Yang (9):
dt-bindings: bus: Add SpacemiT K3 eSPI controller
dt-bindings: embedded-controller: Add SpacemiT K3 EC window
bus: Add SpacemiT K3 eSPI controller support platform/chrome: Allow ChromeOS platform support on RISC-V platform/chrome: Add SpacemiT K3 eSPI EC transport
riscv: dts: spacemit: Add K3 eSPI pin group
riscv: dts: spacemit: Describe the K3 eSPI controller
riscv: dts: spacemit: Enable the FML13V05 EC keyboard
riscv: defconfig: Enable the FML13V05 EC keyboard modules

 .../bindings/bus/spacemit,k3-espi.yaml        | 146 ++++
 .../spacemit,k3-cros-ec.yaml                  |  58 ++
 .../spacemit/k3-deepcomputing-fml13v05.dts    | 137 +++
 arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi  |  24 +
 arch/riscv/boot/dts/spacemit/k3.dtsi          |  31 +
 arch/riscv/configs/defconfig                  |   5 +
 drivers/bus/Kconfig                           |  10 +
 drivers/bus/Makefile                          |   1 +
 drivers/bus/spacemit-k3-espi.c                | 804 ++++++++++++++++++
 drivers/platform/chrome/Kconfig               |  13 +-
 drivers/platform/chrome/Makefile              |   1 +
 drivers/platform/chrome/cros_ec_spacemit_k3.c | 739 ++++++++++++++++
 include/linux/spacemit-k3-espi.h              |  20 +
 13 files changed, 1988 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml
 create mode 100644 drivers/bus/spacemit-k3-espi.c
 create mode 100644 drivers/platform/chrome/cros_ec_spacemit_k3.c
 create mode 100644 include/linux/spacemit-k3-espi.h

base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4

Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/9 dt-bindings: bus: Add SpacemiT K3 eSPI controller

Describe the K3 eSPI controller and its peripheral memory translation window, clocks, resets and link configuration. The EC uses this memory window rather than the ordinary SPI transfer interface.

The controller implementation is carried as a separate prerequisite so that the hardware vendor can review it independently.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 .../bindings/bus/spacemit,k3-espi.yaml        | 146 ++++++++++++++++++
 1 file changed, 146 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +146 -0
new file mode 100644
index 000000000..30985ee0a
@@ -0,0 +1,146 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bus/spacemit,k3-espi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SpacemiT K3 eSPI controller
+
+maintainers:
+  - Yixun Lan <[email protected]>
+
+description: |
+  The K3 eSPI controller connects the application processor to an embedded
+  controller. Child registers are accessed through a peripheral shared-memory
+  window, translated by ranges. The controller manages clocks, resets and
+  channel negotiation, including link recovery after an EC reboot.
+
+properties:
+  compatible:
+    const: spacemit,k3-espi
+
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Serial clock source
+      - description: Serial clock
+      - description: Bus clock
+
+  clock-names:
+    items:
+      - const: sclk_src
+      - const: sclk
+      - const: mclk
+
+  resets:
+    items:
+      - description: Bus reset
+      - description: Serial clock reset
+
+  pr-mem-base0:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: First peripheral memory translation base.
+
+  pr-mem-base1:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Second peripheral memory translation base.
+
+  operating-frequency:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Requested link clock frequency in MHz.
+    enum: [20, 25, 33, 50, 66]
+    default: 20
+
+  io-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Requested number of eSPI data lines.
+    enum: [single, dual, quad]
+    default: single
+
+  alert-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Use the shared IO1 line or the dedicated alert pin.
+    enum: [io1, pin]
+    default: io1
+
+  alert-type:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Electrical mode of the dedicated alert pin.
+    enum: [open-drain, push-pull]
+    default: open-drain
+
+  watchdog-timeout:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Controller watchdog counter value.
+    maximum: 65535
+    default: 65535
+
+  crc-enable:
+    type: boolean
+    description: Enable link CRC checking.
+
+  auto-gating-enable:
+    type: boolean
+    description: Enable automatic controller clock gating.
+
+  peripheral-channel-enable:
+    type: boolean
+    description: Enable the peripheral channel.
+
+  vwire-channel-enable:
+    type: boolean
+    description: Enable the virtual-wire channel.
+
+  oob-channel-enable:
+    type: boolean
+    description: Enable the out-of-band channel.
+
+  flash-channel-enable:
+    type: boolean
+    description: Enable the flash access channel.
+
+patternProperties:
+  '^ec@[0-9a-f]+$':
+    $ref: /schemas/embedded-controller/google,cros-ec.yaml#
+
+required:
+  - compatible
+  - reg
+  - '#address-cells'
+  - '#size-cells'
+  - ranges
+  - clocks
+  - clock-names
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/spacemit,k3-clocks.h>
+    #include <dt-bindings/reset/spacemit,k3-resets.h>
+
+    espi@cac8c000 {
+        compatible = "spacemit,k3-espi";
+        reg = <0xcac8c000 0x1000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0 0x84000000 0x1000>;
+        clocks = <&syscon_apmu CLK_APMU_ESPI_SCLK_SRC>,
+                 <&syscon_apmu CLK_APMU_ESPI_SCLK>,
+                 <&syscon_apmu CLK_APMU_ESPI_MCLK>;
+        clock-names = "sclk_src", "sclk", "mclk";
+        resets = <&syscon_apmu RESET_APMU_ESPI_MCLK>,
+                 <&syscon_apmu RESET_APMU_ESPI_SCLK>;
+    };

base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4

Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/9] dt-bindings: bus: Add SpacemiT K3 eSPI controller

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] dt-bindings: bus: spacemit,k3-espi: unprefixed vendor properties and MHz units --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] dt-bindings: bus: spacemit,k3-espi: unprefixed vendor properties and MHz units
--

commit d42a1666765549829c0c9df0a5e923d2f92c4eb4
Author: Wang Yang <[email protected]>

dt-bindings: bus: Add SpacemiT K3 eSPI controller

This commit adds the Devicetree binding schema for the SpacemiT K3 eSPI controller, describing its peripheral memory translation window, clocks, resets, and link configuration properties.

Quoted 6 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +0 -0
new file mode 100644
index 0000000000000..30985ee0a61a1
@@ -0,0 +1,146 @@

[ ... ]

Quoted 51 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +51 -0
+  pr-mem-base0:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: First peripheral memory translation base.
+
+  pr-mem-base1:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Second peripheral memory translation base.
+
+  operating-frequency:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Requested link clock frequency in MHz.
+    enum: [20, 25, 33, 50, 66]
+    default: 20
+
+  io-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Requested number of eSPI data lines.
+    enum: [single, dual, quad]
+    default: single
+
+  alert-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Use the shared IO1 line or the dedicated alert pin.
+    enum: [io1, pin]
+    default: io1
+
+  alert-type:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Electrical mode of the dedicated alert pin.
+    enum: [open-drain, push-pull]
+    default: open-drain
+
+  watchdog-timeout:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Controller watchdog counter value.
+    maximum: 65535
+    default: 65535
+
+  crc-enable:
+    type: boolean
+    description: Enable link CRC checking.
+
+  auto-gating-enable:
+    type: boolean
+    description: Enable automatic controller clock gating.
+
+  peripheral-channel-enable:
+    type: boolean
+    description: Enable the peripheral channel.
+
+  vwire-channel-enable:

Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 111

Quoted 10 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +10 -0
+    type: boolean
+    description: Enable the virtual-wire channel.
+
+  oob-channel-enable:
+    type: boolean
+    description: Enable the out-of-band channel.
+
+  flash-channel-enable:
+    type: boolean
+    description: Enable the flash access channel.

[Severity: Low]
Should these controller-specific properties use the spacemit, vendor prefix or standard Devicetree properties and unit suffixes?

Defining pr-mem-base0 through flash-channel-enable without a vendor prefix puts 13 device-specific property names into the global DT property namespace, contrary to Documentation/devicetree/bindings/writing-bindings.rst. In addition, operating-frequency uses bare MHz numbers instead of a standard frequency property in Hz (such as max-frequency or a -hz suffix), and pr-mem-base0 and pr-mem-base1 encode raw peripheral memory base addresses that duplicate the address translation already described by ranges.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH 1/9] dt-bindings: bus: Add SpacemiT K3 eSPI controller

In reply to Wang Yang

+CC Mark, spi,

Quoted 20 lines · Wang Yang

window, clocks, resets and link configuration. The EC uses this memory window rather than the ordinary SPI transfer interface.

The controller implementation is carried as a separate prerequisite so that the hardware vendor can review it independently.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 .../bindings/bus/spacemit,k3-espi.yaml        | 146 ++++++++++++++++++
 1 file changed, 146 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +0 -0
new file mode 100644
index 000000000..30985ee0a

Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +7 -0
@@ -0,0 +1,146 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bus/spacemit,k3-espi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SpacemiT K3 eSPI controller

How is this "eSPI" different to the eSPI described in fsl,espi.yaml and implemented by a driver in drivers/spi?

Cheers,
Conor.

Quoted 143 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +139 -0
+
+maintainers:
+  - Yixun Lan <[email protected]>
+
+description: |
+  The K3 eSPI controller connects the application processor to an embedded
+  controller. Child registers are accessed through a peripheral shared-memory
+  window, translated by ranges. The controller manages clocks, resets and
+  channel negotiation, including link recovery after an EC reboot.
+
+properties:
+  compatible:
+    const: spacemit,k3-espi
+
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Serial clock source
+      - description: Serial clock
+      - description: Bus clock
+
+  clock-names:
+    items:
+      - const: sclk_src
+      - const: sclk
+      - const: mclk
+
+  resets:
+    items:
+      - description: Bus reset
+      - description: Serial clock reset
+
+  pr-mem-base0:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: First peripheral memory translation base.
+
+  pr-mem-base1:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Second peripheral memory translation base.
+
+  operating-frequency:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Requested link clock frequency in MHz.
+    enum: [20, 25, 33, 50, 66]
+    default: 20
+
+  io-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Requested number of eSPI data lines.
+    enum: [single, dual, quad]
+    default: single
+
+  alert-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Use the shared IO1 line or the dedicated alert pin.
+    enum: [io1, pin]
+    default: io1
+
+  alert-type:
+    $ref: /schemas/types.yaml#/definitions/string
+    description: Electrical mode of the dedicated alert pin.
+    enum: [open-drain, push-pull]
+    default: open-drain
+
+  watchdog-timeout:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Controller watchdog counter value.
+    maximum: 65535
+    default: 65535
+
+  crc-enable:
+    type: boolean
+    description: Enable link CRC checking.
+
+  auto-gating-enable:
+    type: boolean
+    description: Enable automatic controller clock gating.
+
+  peripheral-channel-enable:
+    type: boolean
+    description: Enable the peripheral channel.
+
+  vwire-channel-enable:
+    type: boolean
+    description: Enable the virtual-wire channel.
+
+  oob-channel-enable:
+    type: boolean
+    description: Enable the out-of-band channel.
+
+  flash-channel-enable:
+    type: boolean
+    description: Enable the flash access channel.
+
+patternProperties:
+  '^ec@[0-9a-f]+$':
+    $ref: /schemas/embedded-controller/google,cros-ec.yaml#
+
+required:
+  - compatible
+  - reg
+  - '#address-cells'
+  - '#size-cells'
+  - ranges
+  - clocks
+  - clock-names
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/spacemit,k3-clocks.h>
+    #include <dt-bindings/reset/spacemit,k3-resets.h>
+
+    espi@cac8c000 {
+        compatible = "spacemit,k3-espi";
+        reg = <0xcac8c000 0x1000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0 0x84000000 0x1000>;
+        clocks = <&syscon_apmu CLK_APMU_ESPI_SCLK_SRC>,
+                 <&syscon_apmu CLK_APMU_ESPI_SCLK>,
+                 <&syscon_apmu CLK_APMU_ESPI_MCLK>;
+        clock-names = "sclk_src", "sclk", "mclk";
+        resets = <&syscon_apmu RESET_APMU_ESPI_MCLK>,
+                 <&syscon_apmu RESET_APMU_ESPI_SCLK>;
+    };

base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4

Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH 1/9] dt-bindings: bus: Add SpacemiT K3 eSPI controller

Hi Conor,

Quoted 17 lines · Conor Dooley

+CC Mark, spi,

Quoted 14 lines · Wang Yang

window, clocks, resets and link configuration. The EC uses this memory window rather than the ordinary SPI transfer interface.

The controller implementation is carried as a separate prerequisite so that the hardware vendor can review it independently.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 .../bindings/bus/spacemit,k3-espi.yaml        | 146 ++++++++++++++++++
 1 file changed, 146 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml
Quoted 16 lines

Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 7

Quoted 13 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +7 -0
new file mode 100644
index 000000000..30985ee0a
@@ -0,0 +1,146 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bus/spacemit,k3-espi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SpacemiT K3 eSPI controller

How is this "eSPI" different to the eSPI described in fsl,espi.yaml and implemented by a driver in drivers/spi?

eSPI in fsl,espi.yaml is a Freescale (now NXP) SPI controller, it implements a SPI bus.

Here eSPI is a bus, replacing the LPC bus, as defined by Intel:
https://www.intel.com/content/www/us/en/content-details/841685/enhanced-serial-peripheral-interface-espi-interface-base-specification-for-client-and-server-platforms.html

Regards
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                     http://aurel32.net
author
#5 lore raw

Re: [PATCH 1/9] dt-bindings: bus: Add SpacemiT K3 eSPI controller

Hi Conor, Aurelien,

Quoted 2 lines

How is this "eSPI" different to the eSPI described in fsl,espi.yaml and implemented by a driver in drivers/spi?

Thank you, Aurelien, for clarifying this. K3 uses the Intel-defined eSPI interface intended to replace LPC. It is a different protocol from the Freescale/NXP SPI controller described by fsl,espi.yaml.

On K3, the controller exposes a CPU-accessible window for the eSPI Peripheral Channel. The EC client accesses its command, response and memory-map regions through this window, rather than exchanging ordinary SPI messages.

The proposed controller driver handles clocks, resets, link configuration and window setup. The EC transport handles the EC register mapping and host commands. The distinction is therefore the protocol and access model, rather than the use of MMIO itself.

I will make the Intel eSPI terminology and this access model explicit in the binding description.

Regards,
Wang Yang

#6 lore raw

Re: [PATCH 1/9] dt-bindings: bus: Add SpacemiT K3 eSPI controller

Quoted 8 lines · Wang Yang

Hi Conor, Aurelien,

Quoted 2 lines

How is this "eSPI" different to the eSPI described in fsl,espi.yaml and implemented by a driver in drivers/spi?

Thank you, Aurelien, for clarifying this. K3 uses the Intel-defined eSPI interface intended to replace LPC. It is a different protocol from the Freescale/NXP SPI controller described by fsl,espi.yaml.

Ah I think this might be confusing af, because that device also supports what it calls "eLBC"...

Quoted 5 lines

On K3, the controller exposes a CPU-accessible window for the eSPI Peripheral Channel. The EC client accesses its command, response and memory-map regions through this window, rather than exchanging ordinary SPI messages.

Quoted 7 lines

The proposed controller driver handles clocks, resets, link configuration and window setup. The EC transport handles the EC register mapping and host commands. The distinction is therefore the protocol and access model, rather than the use of MMIO itself.

I will make the Intel eSPI terminology and this access model explicit in the binding description.

Please take a look at a similar series from Aspeed and see if you can cooperate on creating something common between you:
https://lore.kernel.org/all/[email protected]/

Thanks,
Conor.

#7 lore raw

Re: [PATCH 1/9] dt-bindings: bus: Add SpacemiT K3 eSPI controller

Quoted 6 lines · Conor Dooley
Quoted 5 lines · Wang Yang

Hi Conor, Aurelien,

Quoted 2 lines

How is this "eSPI" different to the eSPI described in fsl,espi.yaml and implemented by a driver in drivers/spi?

Quoted 6 lines
Quoted 3 lines

Thank you, Aurelien, for clarifying this. K3 uses the Intel-defined eSPI interface intended to replace LPC. It is a different protocol from the Freescale/NXP SPI controller described by fsl,espi.yaml.

Ah I think this might be confusing af, because that device also supports what it calls "eLBC"...

As in, I got confused while looking at the documentation for the fsl device between what they were calling eSPI and eLBC, and also didn't realised that it was lBc not lPc.. Too many similar-ish terms...

Quoted 17 lines
Quoted 6 lines

On K3, the controller exposes a CPU-accessible window for the eSPI Peripheral Channel. The EC client accesses its command, response and memory-map regions through this window, rather than exchanging ordinary SPI messages.

Quoted 7 lines

The proposed controller driver handles clocks, resets, link configuration and window setup. The EC transport handles the EC register mapping and host commands. The distinction is therefore the protocol and access model, rather than the use of MMIO itself.

I will make the Intel eSPI terminology and this access model explicit in the binding description.

Please take a look at a similar series from Aspeed and see if you can cooperate on creating something common between you:
https://lore.kernel.org/all/[email protected]/

author
#8 lore raw

PATCH 2/9 dt-bindings: embedded-controller: Add SpacemiT K3 EC window

In reply to Wang Yang

Describe the K3-specific non-linear peripheral window in a vendor binding. Reuse the existing EC keyboard schema and keep the Google EC binding unchanged. Point the vendor controller child schema at this binding.

---
 .../bindings/bus/spacemit,k3-espi.yaml        |  2 +-
 .../spacemit,k3-cros-ec.yaml                  | 58 +++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml +1 -1
index 30985ee0a..545cc2609 100644
@@ -112,7 +112,7 @@ properties:
 
 patternProperties:
   '^ec@[0-9a-f]+$':
-    $ref: /schemas/embedded-controller/google,cros-ec.yaml#
+    $ref: /schemas/embedded-controller/spacemit,k3-cros-ec.yaml#
 
 required:
   - compatible
Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.43.0
author
#9 lore raw

PATCH 3/9 bus: Add SpacemiT K3 eSPI controller support

In reply to Wang Yang

Initialize and recover the K3 eSPI peripheral channel before populating its children. Keep controller register programming, clock and reset handling in the controller driver rather than in the EC transport.

Port the existing vendor-derived implementation separately from the EC client. The controller logic comes from the vendor BSP at revision 29b78afb484b, authored by goumin <[email protected]>. Preserve its register programming and link-recovery behavior.

No matching SpacemiT eSPI submission was found in the archived SPI, RISC-V and Chrome platform searches used for this port.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 drivers/bus/Kconfig              |  10 +
 drivers/bus/Makefile             |   1 +
 drivers/bus/spacemit-k3-espi.c   | 804 +++++++++++++++++++++++++++++++
 include/linux/spacemit-k3-espi.h |  20 +
 4 files changed, 835 insertions(+)
 create mode 100644 drivers/bus/spacemit-k3-espi.c
 create mode 100644 include/linux/spacemit-k3-espi.h
drivers/bus/Kconfig +10 -0
index e4b1db809..35b00c9ba 100644
@@ -149,6 +149,16 @@ config STM32_DBG_BUS
 	  platforms when the debug configuration is not accessible by the
 	  normal world.
 
+config SPACEMIT_ESPI_BUS
+	bool "SpacemiT K3 eSPI controller"
+	depends on OF && HAS_IOMEM
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	help
+	  Enable the SpacemiT K3 eSPI controller, including clock and reset
+	  management, link initialization and recovery after an EC reboot.
+	  Child devices can use its peripheral shared-memory window.
+	  Say Y here to use the EC keyboard on DeepComputing FML13V05.
+
 config STM32_FIREWALL
 	bool "STM32 Firewall framework"
 	depends on (ARCH_STM32 || COMPILE_TEST) && OF
drivers/bus/Makefile +1 -0
index a01f97fef..cc46cfc68 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_OMAP_OCP2SCP)	+= omap-ocp2scp.o
 obj-$(CONFIG_QCOM_EBI2)		+= qcom-ebi2.o
 obj-$(CONFIG_QCOM_SSC_BLOCK_BUS)	+= qcom-ssc-block-bus.o
 obj-$(CONFIG_STM32_DBG_BUS)	+= stm32_dbg_bus.o
+obj-$(CONFIG_SPACEMIT_ESPI_BUS) += spacemit-k3-espi.o
 obj-$(CONFIG_STM32_FIREWALL)	+= stm32_firewall.o stm32_rifsc.o stm32_etzpc.o
 obj-$(CONFIG_SUN50I_DE2_BUS)	+= sun50i-de2.o
 obj-$(CONFIG_SUNXI_RSB)		+= sunxi-rsb.o
drivers/bus/spacemit-k3-espi.c new file +804 -0

804 lines not on this page · raw message

include/linux/spacemit-k3-espi.h new file +20 -0
new file mode 100644
index 000000000..a2a75e2b7
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _LINUX_SPACEMIT_K3_ESPI_H
+#define _LINUX_SPACEMIT_K3_ESPI_H
+
+#include <linux/errno.h>
+#include <linux/kconfig.h>
+
+struct device;
+
+#if IS_ENABLED(CONFIG_SPACEMIT_ESPI_BUS)
+int spacemit_k3_espi_recover(struct device *dev);
+#else
+static inline int spacemit_k3_espi_recover(struct device *dev)
+{
+	return -EOPNOTSUPP;
+}
+#endif
+
+#endif /* _LINUX_SPACEMIT_K3_ESPI_H */
Signature · 1 line
2.43.0
#10 lore raw

Re: [PATCH 3/9] bus: Add SpacemiT K3 eSPI controller support

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] bus: spacemit-k3-espi: boolean DT properties always evaluate to true - [Medium] bus…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] bus: spacemit-k3-espi: boolean DT properties always evaluate to true
- [Medium] bus: spacemit-k3-espi: status clear race and error masking in poll
- [Medium] bus: spacemit-k3-espi: sclk rate set on wrong clock before negotiation
--

commit 725541204887e2363d68e7147b0b1af23aa4f9a3
Author: Wang Yang <[email protected]>

bus: Add SpacemiT K3 eSPI controller support

This commit adds a bus driver for the SpacemiT K3 eSPI controller to handle clock and reset management, channel configuration, and link recovery for child devices.

Quoted 5 lines
drivers/bus/spacemit-k3-espi.c new file +0 -0
new file mode 100644
index 0000000000000..b511b164b3cfc

[ ... ]

drivers/bus/spacemit-k3-espi.c line 186

Quoted 8 lines
drivers/bus/spacemit-k3-espi.c new file +8 -0
+static bool spacemit_espi_property_enabled(struct device_node *np,
+					   const char *name, bool default_value)
+{
+	if (of_find_property(np, name, NULL))
+		return of_property_read_bool(np, name);
+
+	return default_value;
+}

[Severity: Medium]
Can spacemit_espi_property_enabled() ever return false when default_value is true?

of_property_read_bool() tests whether the property exists via of_find_property(), so it always returns true once the if condition passes. Because spacemit_espi_parse_dt() passes default_value = true for all six boolean properties (crc-enable, peripheral-channel-enable, vwire-channel-enable, oob-channel-enable, flash-channel-enable, and auto-gating-enable), all six flags evaluate to true whether the properties are present in the Device Tree or omitted, making it impossible for a board DT to disable any of these features or channels.

[ ... ]

Quoted 28 lines
drivers/bus/spacemit-k3-espi.c new file +28 -0
+static int spacemit_espi_poll_status(struct spacemit_espi *espi, u32 expected)
+{
+	unsigned int timeout = ESPI_CFG_TIMEOUT_US / 10;
+	u32 status;
+
+	writel(expected, espi->regs + ESPI_SLAVE0_INT_STS);
+
+	do {
+		status = readl(espi->regs + ESPI_SLAVE0_INT_STS);
+		if (!status) {
+			fsleep(10);
+			continue;
+		}
+
+		writel(status, espi->regs + ESPI_SLAVE0_INT_STS);
+
+		if (status & expected)
+			return 0;
+
+		if (status & (ESPI_PROTOCOL_INT | ESPI_RESPONSE_INT))
+			return -EIO;
+
+		fsleep(10);
+	} while (--timeout);
+
+	return -ETIMEDOUT;
+}
+

drivers/bus/spacemit-k3-espi.c line 281

Quoted 10 lines
drivers/bus/spacemit-k3-espi.c new file +10 -0
+static int spacemit_espi_cmd_get_config(struct spacemit_espi *espi, u16 addr, u32 *value)
+{
+	int ret;
+
+	spacemit_espi_write_hdr(espi, 0, 0);
+	spacemit_espi_write_hdr(espi, 1, addr >> 8);
+	spacemit_espi_write_hdr(espi, 2, addr);
+	spacemit_espi_trigger_cmd(espi, ESPI_DNCMD_GET_CONFIGURATION);
+
+	ret = spacemit_espi_poll_status(espi, ESPI_DNCMD_INT);

[Severity: Medium]
Does clearing expected in ESPI_SLAVE0_INT_STS inside spacemit_espi_poll_status() race with command completion after spacemit_espi_trigger_cmd() has already started the hardware transfer?

A short GET_CONFIGURATION or SET_CONFIGURATION transfer can finish and set ESPI_DNCMD_INT before spacemit_espi_poll_status() executes its initial write-1-to-clear writel(), wiping out the completion bit and causing a 50 ms -ETIMEDOUT failure.

In addition, spacemit_espi_send_inband_reset() does not clear ESPI_SLAVE0_INT_STS after ESPI_DNCMD_IN_BAND_RESET, and spacemit_espi_poll_status() only clears expected before the loop, leaving any stale error bits pending. Inside the loop, checking status & expected before status & (ESPI_PROTOCOL_INT | ESPI_RESPONSE_INT) also masks bus or protocol errors whenever ESPI_DNCMD_INT asserts alongside an error bit, allowing spacemit_espi_cmd_get_config() to read invalid response bytes.

[ ... ]

Quoted 5 lines
drivers/bus/spacemit-k3-espi.c new file +5 -0
+static int spacemit_espi_init_locked(struct spacemit_espi *espi)
+{
+	u32 slave_caps = 0;
+	u32 cfg;
+	int ret;

[ ... ]

drivers/bus/spacemit-k3-espi.c line 622

Quoted 5 lines
drivers/bus/spacemit-k3-espi.c new file +5 -0
+	if (espi->sclk && !IS_ERR(espi->sclk) && espi->op_freq_mhz) {
+		ret = clk_set_rate(espi->sclk, espi->op_freq_mhz * 1000000UL);
+		if (ret)
+			dev_dbg(espi->dev, "failed to set sclk rate: %d\n", ret);
+	}

[Severity: Medium]
Does calling clk_set_rate() on espi->sclk before capability negotiation actually configure the K3 eSPI serial clock frequency?

In the K3 clock controller, espi_sclk_src owns the 20/25/33/50/66 MHz parent mux while espi_sclk is defined without CLK_SET_RATE_PARENT:

drivers/clk/spacemit/ccu-k3.c:

    static const struct clk_parent_data espi_sclk_src_parents[] = {
    	CCU_PARENT_HW(pll2_20),
    	CCU_PARENT_HW(pll2_25),
    	CCU_PARENT_HW(pll2_33),
    	CCU_PARENT_HW(pll2_50),
    	CCU_PARENT_HW(pll2_66),
    };
    CCU_MUX_DEFINE(espi_sclk_src, espi_sclk_src_parents, APMU_ESPI_CLK_RES_CTRL, 4, 3, 0);

    static const struct clk_parent_data espi_sclk_parents[] = {
    	CCU_PARENT_NAME(external_clk),
    	CCU_PARENT_HW(espi_sclk_src),
    };
    CCU_MUX_GATE_DEFINE(espi_sclk, espi_sclk_parents, APMU_ESPI_CLK_RES_CTRL, 7, 1, BIT(3), 0);

Because spacemit_espi_probe() only acquires "sclk" and never "sclk_src", clk_set_rate(espi->sclk, ...) only evaluates the current rate of its immediate parents and never switches espi_sclk_src to the requested divider. Furthermore, setting the clock rate to espi->op_freq_mhz before in-band reset and spacemit_espi_build_negotiated_config() leaves the serial clock unaligned with ESPI_SLAVE0_CONFIG and ESPI_SLAVE_GEN_CFG if the slave negotiates a lower operating frequency.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#11 lore raw

Re: [PATCH 3/9] bus: Add SpacemiT K3 eSPI controller support

In reply to Wang Yang

Hi,

Quoted 11 lines · Wang Yang

Initialize and recover the K3 eSPI peripheral channel before populating its children. Keep controller register programming, clock and reset handling in the controller driver rather than in the EC transport.

Port the existing vendor-derived implementation separately from the EC client. The controller logic comes from the vendor BSP at revision 29b78afb484b, authored by goumin <[email protected]>. Preserve its register programming and link-recovery behavior.

No matching SpacemiT eSPI submission was found in the archived SPI, RISC-V and Chrome platform searches used for this port.

While this is correct, please note that there was a try from AMD to define a eSPI bus framework back in August [1]. However I haven't spotted any further progress.

Anyway thanks for your work, I guess this can also be useful for the EC controller on the K3 Pico-ITX boards, which drives among other things the fan PWM.

Regards
Aurelien

[1] https://lore.kernel.org/all/[email protected]/

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                     http://aurel32.net
author
#12 lore raw

Re: [PATCH 3/9] bus: Add SpacemiT K3 eSPI controller support

Hi Aurelien,

Thank you for pointing out the AMD RFC. I missed it during the initial search.

I have now looked through the RFC and its follow-up discussion. I am still checking how K3's CPU-mapped Peripheral Channel window, device enumeration and link recovery could fit into that framework. I will take this work into account before posting the next revision.

Thanks also for pointing out the EC on SpacemiT's K3 Pico-ITX development board. I understand that its EC uses the same eSPI hardware interface as the EC on FML13V05. Keeping the controller separate from the EC transport should allow the support to be shared between the two boards. My validation so far has been limited to FML13V05.

Regards,
Wang Yang

author
#13 lore raw

PATCH 4/9 platform/chrome: Allow ChromeOS platform support on RISC-V

In reply to Wang Yang

Expose the ChromeOS EC configuration menu on RISC-V so boards using an EC over a supported transport can select the common protocol and input drivers. Individual transport dependencies remain in effect.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 drivers/platform/chrome/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/Kconfig +1 -1
index ca2e84420..6beda4655 100644
@@ -5,7 +5,7 @@
 
 menuconfig CHROME_PLATFORMS
 	bool "Platform support for Chrome hardware"
-	depends on X86 || ARM || ARM64 || COMPILE_TEST
+	depends on X86 || ARM || ARM64 || RISCV || COMPILE_TEST
 	depends on !CPU_BIG_ENDIAN || COMPILE_TEST
 	help
 	  Say Y here to get to see options for platform support for
Signature · 1 line
2.43.0
author
#14 lore raw

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

In reply to Wang Yang

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.

---
 drivers/platform/chrome/Kconfig               |  11 +
 drivers/platform/chrome/Makefile              |   1 +
 drivers/platform/chrome/cros_ec_spacemit_k3.c | 739 ++++++++++++++++++
 3 files changed, 751 insertions(+)
 create mode 100644 drivers/platform/chrome/cros_ec_spacemit_k3.c
drivers/platform/chrome/Kconfig +11 -0
index 6beda4655..10933f7af 100644
@@ -154,6 +154,17 @@ config CROS_EC_LPC
 	  To compile this driver as a module, choose M here: the
 	  module will be called cros_ec_lpcs.
 
+config CROS_EC_SPACEMIT_K3
+	tristate "SpacemiT K3 ChromeOS EC over eSPI"
+	depends on CROS_EC && SPACEMIT_ESPI_BUS
+	help
+	  Support a ChromeOS EC connected through the SpacemiT K3 eSPI
+	  peripheral shared-memory window. The transport supports host
+	  command protocol versions 2 and 3 and EC event interrupts.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called cros_ec_spacemit_k3.
+
 config CROS_EC_PROTO
 	tristate
 	help
drivers/platform/chrome/Makefile +1 -0
index b981a1bb5..e3357a6bc 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_CROS_EC_I2C)		+= cros_ec_i2c.o
 obj-$(CONFIG_CROS_EC_ISHTP)		+= cros_ec_ishtp.o
 obj-$(CONFIG_CROS_TYPEC_SWITCH)		+= cros_typec_switch.o
 obj-$(CONFIG_CROS_EC_RPMSG)		+= cros_ec_rpmsg.o
+obj-$(CONFIG_CROS_EC_SPACEMIT_K3)		+= cros_ec_spacemit_k3.o
 obj-$(CONFIG_CROS_EC_SPI)		+= cros_ec_spi.o
 obj-$(CONFIG_CROS_EC_UART)		+= cros_ec_uart.o
 cros_ec_lpcs-objs			:= cros_ec_lpc.o cros_ec_lpc_mec.o
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +739 -0

739 lines not on this page · raw message

Signature · 1 line
2.43.0
#15 lore raw

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

Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] platform/chrome: missing wakeup init in cros_ec_espi_probe() - [Medium] platform/chrome: missing…

Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [Medium] platform/chrome: missing wakeup init in cros_ec_espi_probe()
- [Medium] platform/chrome: missing eSPI window bounds checks in lpc_to_espi_offset()
- [Medium] platform/chrome: race on event_data in cros_ec_espi_probe() IRQ drain
- [Medium] platform/chrome: missing post-ID delay in cros_ec_espi_wait_ready()
- [Low] platform/chrome: spurious error log on -EAGAIN in cros_ec_spacemit_k3
--

commit b0c80322a90e8c8d2c53ee26b39169afce373af6
Author: Wang Yang <[email protected]>

platform/chrome: Add SpacemiT K3 eSPI EC transport

This commit adds a ChromeOS EC transport driver for the SpacemiT K3 eSPI peripheral shared-memory window, supporting host command protocol versions 2 and 3, controller link recovery, and EC event interrupts.

Quoted 5 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +0 -0
new file mode 100644
index 0000000000000..b3010e2bff6a5

[ ... ]

Quoted 7 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +7 -0
+/* eSPI shared memory offsets */
+#define ESPI_HOST_CMD_OFFSET 0x000 /* EC_LPC_ADDR_HOST_CMD -> 0x000 */
+#define ESPI_HOST_DATA_OFFSET 0x001 /* EC_LPC_ADDR_HOST_DATA -> 0x001 */
+#define ESPI_HOST_ARGS_OFFSET 0x010 /* EC_LPC_ADDR_HOST_ARGS -> 0x010 */
+#define ESPI_HOST_PARAM_OFFSET 0x018 /* EC_LPC_ADDR_HOST_PARAM -> 0x018 */
+#define ESPI_HOST_PACKET_OFFSET 0x100 /* EC_LPC_ADDR_HOST_PACKET -> 0x100 */
+#define ESPI_MEMMAP_OFFSET 0x200 /* EC_LPC_ADDR_MEMMAP -> 0x200 */

[ ... ]

Quoted 22 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +22 -0
+/* Convert LPC address to eSPI shared memory offset */
+static inline u32 lpc_to_espi_offset(struct cros_ec_device *ec, u32 lpc_addr)
+{
+	switch (lpc_addr & 0xFF00) {
+	case 0x200: /* HOST_CMD/DATA region */
+		if (lpc_addr == EC_LPC_ADDR_HOST_CMD)
+			return ESPI_HOST_CMD_OFFSET;
+		else if (lpc_addr == EC_LPC_ADDR_HOST_DATA)
+			return ESPI_HOST_DATA_OFFSET;
+		break;
+	case 0x800: /* HOST_ARGS/PARAM/PACKET region */
+		/* Protocols 2 and 3 use the same LPC addresses. */
+		if (ec->proto_version > 2)
+			return ESPI_HOST_PACKET_OFFSET +
+			       (lpc_addr - EC_LPC_ADDR_HOST_PACKET);
+		else if (lpc_addr >= EC_LPC_ADDR_HOST_ARGS &&
+			 lpc_addr < EC_LPC_ADDR_HOST_PARAM)
+			return ESPI_HOST_ARGS_OFFSET +
+			       (lpc_addr - EC_LPC_ADDR_HOST_ARGS);
+		else if (lpc_addr >= EC_LPC_ADDR_HOST_PARAM)
+			return ESPI_HOST_PARAM_OFFSET +
+			       (lpc_addr - EC_LPC_ADDR_HOST_PARAM);

drivers/platform/chrome/cros_ec_spacemit_k3.c line 118

Quoted 10 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +10 -0
+		break;
+	case 0x900: /* MEMMAP region */
+		return ESPI_MEMMAP_OFFSET + (lpc_addr - EC_LPC_ADDR_MEMMAP);
+	}
+
+	/* Default mapping for unknown addresses */
+	pr_warn_once("Unknown LPC address 0x%x, using direct offset\n",
+		     lpc_addr);
+	return lpc_addr & 0xFF;
+}

[Severity: Medium]
Can lpc_to_espi_offset() read and write past the parameter and packet sub-windows into adjacent regions of espi_shared_mem_base?

For protocol v2, ESPI_HOST_PARAM_OFFSET starts at 0x018 and only has 232 bytes before ESPI_HOST_PACKET_OFFSET at 0x100, but cros_ec_cmd_xfer_espi_once() allows msg->outsize and msg->insize up to EC_PROTO2_MAX_PARAM_SIZE (252 bytes). A transfer of 233..252 bytes maps EC_LPC_ADDR_HOST_PARAM + i to 0x100..0x113, overflowing into the packet window.

Similarly, for protocol v3, cros_ec_pkt_xfer_espi_once() does not check that the request length returned by cros_ec_prepare_tx() or sizeof(response) + response.data_len fits within the 256-byte packet window (EC_LPC_HOST_PACKET_SIZE). When a packet exceeds 256 bytes, EC_LPC_ADDR_HOST_PACKET + i reaches 0x900 and lpc_to_espi_offset() translates it into ESPI_MEMMAP_OFFSET (0x200..0x2ff) and then wraps via the default (lpc_addr & 0xff) fallback to 0x000, overwriting ESPI_HOST_CMD_OFFSET and ESPI_HOST_DATA_OFFSET.

[ ... ]

drivers/platform/chrome/cros_ec_spacemit_k3.c line 244

Quoted 13 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +13 -0
+static int cros_ec_espi_wait_ready(struct cros_ec_device *ec, const char *reason)
+{
+	struct device *dev = ec->dev;
+	unsigned long timeout = jiffies + msecs_to_jiffies(ESPI_READY_TIMEOUT_MS);
+	unsigned long next_recover =
+		jiffies + msecs_to_jiffies(ESPI_RECOVERY_RETRY_INTERVAL_MS);
+	u8 buf[2] = {};
+	int ret = 0;
+
+	do {
+		ret = cros_ec_espi_read_id(ec, buf);
+		if (ret >= 0 && cros_ec_espi_valid_id(buf))
+			return 0;

[Severity: Medium]
Does cros_ec_espi_wait_ready() return before the EC has finished initializing its command window?

In cros_ec_espi_probe(), the driver sleeps for 100 ms after seeing the EC ID because the EC still initializes its command window after publishing EC_MEMMAP_ID. During runtime recovery, cros_ec_espi_xfer_retry() calls cros_ec_espi_recover_controller() -> cros_ec_espi_wait_ready(), which returns 0 as soon as 'E' and 'C' appear without that 100 ms delay, so the single command retry in cros_ec_espi_xfer_retry() is sent immediately while the command window may still be initializing.

[ ... ]

Quoted 3 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +3 -0
+static int cros_ec_pkt_xfer_espi_once(struct cros_ec_device *ec,
+				      struct cros_ec_command *msg)
+{

[ ... ]

drivers/platform/chrome/cros_ec_spacemit_k3.c line 352

Quoted 13 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +13 -0
+	/* Check result */
+	ret = cros_ec_espi_read_bytes(ec, EC_LPC_ADDR_HOST_DATA, 1, &sum);
+	if (ret < 0) {
+		dev_err(ec->dev, "Read from HOST_DATA failed: %d\n", ret);
+		goto done;
+	}
+
+	msg->result = sum;
+	ret = cros_ec_check_result(ec, msg);
+	if (ret) {
+		dev_err(ec->dev, "cros_ec_check_result failed: %d\n", ret);
+		goto done;
+	}

[Severity: Low]
Should cros_ec_pkt_xfer_espi_once() and cros_ec_cmd_xfer_espi_once() avoid logging dev_err() when cros_ec_check_result() returns non-zero?

cros_ec_check_result() only returns non-zero (-EAGAIN) when msg->result is EC_RES_IN_PROGRESS, which is normal for slow commands that cros_ec_send_command() polls until completion via cros_ec_wait_until_complete(). Logging dev_err() here prints an error on every status poll while a command is in progress.

[ ... ]

Quoted 2 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +2 -0
+static int cros_ec_espi_probe(struct platform_device *pdev)
+{

[ ... ]

Quoted 7 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +7 -0
+	if (irq > 0) {
+		ec->irq = irq;
+		ret = devm_request_threaded_irq(dev, irq, cros_ec_espi_irq_handler,
+						cros_ec_irq_thread, IRQF_ONESHOT,
+						"chromeos-ec", ec);
+		if (ret) {
+			cros_ec_unregister(ec);

drivers/platform/chrome/cros_ec_spacemit_k3.c line 663

Quoted 10 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +10 -0
+			return dev_err_probe(dev, ret, "failed to request EC IRQ\n");
+		}
+
+		/* Drain events queued before the edge-triggered IRQ was ready. */
+		if (ec->mkbp_event_supported)
+			cros_ec_irq_thread(irq, ec);
+	}
+
+	return 0;
+}

[Severity: Medium]
Can calling cros_ec_irq_thread() directly here race with the newly enabled threaded IRQ handler on ec->event_data and ec->event_size?

devm_request_threaded_irq() enables the interrupt before the probe thread calls cros_ec_irq_thread(irq, ec):

CPU0 (probe) CPU1 (irq/<irq>-chromeos-ec)
cros_ec_espi_probe()
devm_request_threaded_irq()
cros_ec_irq_thread()

    cros_ec_handle_event()
      cros_ec_get_next_event()
        get_next_event_xfer()
          ec_dev->event_data = ...
                                  cros_ec_irq_thread()
                                    ...
                                      get_next_event_xfer()
                                        ec_dev->event_data = ...
        ec_dev->event_data.event_type &= ...
      blocking_notifier_call_chain()  <-- reads overwritten event_data

In get_next_event_xfer() and cros_ec_get_next_event(), ec_dev->lock only protects cros_ec_cmd_xfer_status(); updates to ec_dev->event_size and ec_dev->event_data and the subsequent notifier callbacks run unlocked. Waking the IRQ thread with irq_wake_thread(irq, ec) instead of calling cros_ec_irq_thread() directly would serialize the initial drain with IRQ delivery.

[ ... ]

drivers/platform/chrome/cros_ec_spacemit_k3.c line 700

Quoted 6 lines
drivers/platform/chrome/cros_ec_spacemit_k3.c new file +6 -0
+static int cros_ec_espi_suspend_late(struct device *dev)
+{
+	struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
+
+	return cros_ec_suspend_late(ec_dev);
+}

[Severity: Medium]
Does EC wakeup from suspend work without calling device_init_wakeup() in cros_ec_espi_probe()?

cros_ec_suspend_late() -> cros_ec_disable_irq() and cros_ec_handle_event() check device_may_wakeup(ec_dev->dev) before calling enable_irq_wake() and pm_wakeup_event():

drivers/platform/chrome/cros_ec.c:cros_ec_disable_irq() {
    ...
	if (device_may_wakeup(dev))
		ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq);
	else
		ec_dev->wake_enabled = false;

	disable_irq(ec_dev->irq);
}

Unlike the I2C core, the platform bus does not automatically initialize wakeup capability from the devicetree wakeup-source property, so device_may_wakeup(ec->dev) is always false and the EC IRQ is disabled during suspend without wake enabled.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
author
#16 lore raw

PATCH 6/9 riscv: dts: spacemit: Add K3 eSPI pin group

In reply to Wang Yang

Describe the eSPI0 pin function on pads 91 through 98, including the separate clock pull configuration. The group is only applied when a board references it.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi | 24 ++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi +24 -0
index cb4f4f4e3..5bae382fa 100644
@@ -11,6 +11,30 @@
 #define K3_GPIO(x)	(x / 32) (x % 32)
 
 &pinctrl {
+	espi0_2_cfg: espi0-2-cfg {
+		espi0-0-pins {
+			pinmux = <K3_PADCONF(91, 4)>,	/* espi0 d0 */
+				 <K3_PADCONF(92, 4)>,	/* espi0 d1 */
+				 <K3_PADCONF(93, 4)>,	/* espi0 d2 */
+				 <K3_PADCONF(94, 4)>,	/* espi0 d3 */
+				 <K3_PADCONF(95, 4)>,	/* espi0 cs */
+				 <K3_PADCONF(97, 4)>,	/* espi0 reset */
+				 <K3_PADCONF(98, 4)>;	/* espi0 alert */
+
+			bias-pull-up;			/* normal pull-up */
+			drive-strength = <25>;		/* DS8 */
+			power-source = <1800>;
+		};
+
+		espi0-1-pins {
+			pinmux = <K3_PADCONF(96, 4)>;	/* espi0 clk */
+
+			bias-pull-down;			/* normal pull-down */
+			drive-strength = <25>;		/* DS8 */
+			power-source = <1800>;
+		};
+	};
+
 	gmac0_rgmii_0_cfg: gmac0-rgmii-0-cfg {
 		gmac0-rgmii-0-pins {
 			pinmux = <K3_PADCONF(0, 1)>,	/* gmac0_rxdv */
Signature · 1 line
2.43.0
#17 lore raw

Re: [PATCH 6/9] riscv: dts: spacemit: Add K3 eSPI pin group

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] riscv: dts: spacemit: boolean bias-pull-up in espi0_2_cfg selects strong pull - [Low] riscv: dts…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] riscv: dts: spacemit: boolean bias-pull-up in espi0_2_cfg selects strong pull
- [Low] riscv: dts: spacemit: espi0_2_cfg drive-strength 25 mA at 1.8V selects DS10
--

commit 4a5d2c0bc1f2695686ef3889084fb07b26b11220
Author: Wang Yang <[email protected]>

riscv: dts: spacemit: Add K3 eSPI pin group

This commit adds the espi0_2_cfg pin configuration group for eSPI0 on pads 91 through 98 in the SpacemiT K3 pinctrl device tree.

Quoted 9 lines
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi +1 -0
index cb4f4f4e33aff..5bae382fa7e15 100644
@@ -11,6 +11,30 @@
 #define K3_GPIO(x)	(x / 32) (x % 32)
 
 &pinctrl {
+	espi0_2_cfg: espi0-2-cfg {

arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi line 24

Quoted 10 lines
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi +10 -0
+		espi0-0-pins {
+			pinmux = <K3_PADCONF(91, 4)>,	/* espi0 d0 */
+				 <K3_PADCONF(92, 4)>,	/* espi0 d1 */
+				 <K3_PADCONF(93, 4)>,	/* espi0 d2 */
+				 <K3_PADCONF(94, 4)>,	/* espi0 d3 */
+				 <K3_PADCONF(95, 4)>,	/* espi0 cs */
+				 <K3_PADCONF(97, 4)>,	/* espi0 reset */
+				 <K3_PADCONF(98, 4)>;	/* espi0 alert */
+
+			bias-pull-up;			/* normal pull-up */

[Severity: Medium]
Should this be bias-pull-up = <0> instead of a boolean property?

Documentation/devicetree/bindings/pinctrl/spacemit,k1-pinctrl.yaml requires an integer argument (0 for normal pull-up, 1 for strong pull-up), so a bare bias-pull-up fails dtbs_check. At runtime, generic pinconf supplies a default argument of 1 when no cell value is given, causing spacemit_pinconf_generate_config() to set PAD_STRONG_PULL instead of normal pull-up.

arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi line 36

Quoted 12 lines
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi +12 -0
+			drive-strength = <25>;		/* DS8 */
+			power-source = <1800>;
+		};
+
+		espi0-1-pins {
+			pinmux = <K3_PADCONF(96, 4)>;	/* espi0 clk */
+
+			bias-pull-down;			/* normal pull-down */
+			drive-strength = <25>;		/* DS8 */
+			power-source = <1800>;
+		};
+	};

[Severity: Low]
Does drive-strength = <25> with power-source = <1800> select DS10 rather than the DS8 noted in the comments?

In drivers/pinctrl/spacemit/pinctrl-k1.c, k3_drive_conf maps 25 mA to register value 8 (DS8) only at 3.3V (ds_3v3_tbl). For 1.8V pads (ds_1v8_tbl), 25 mA maps to register value 10 (DS10), while DS8 corresponds to 21 mA.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
author
#18 lore raw

PATCH 7/9 riscv: dts: spacemit: Describe the K3 eSPI controller

In reply to Wang Yang

Add the disabled eSPI controller with its memory window, clock and reset connections. Keep the board-specific EC child out of the common SoC description. Other K3 boards remain disabled by default.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 arch/riscv/boot/dts/spacemit/k3.dtsi | 31 ++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
arch/riscv/boot/dts/spacemit/k3.dtsi +31 -0
index e89d2cc5c..d859c84bb 100644
@@ -648,6 +648,37 @@ gmac1_axi_setup: stmmac-axi-config {
 			};
 		};
 
+		espi0: espi@cac8c000 {
+			compatible = "spacemit,k3-espi";
+			reg = <0x0 0xcac8c000 0x0 0x1000>;
+			ranges = <0x0 0x0 0x84000000 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			pr-mem-base0 = <0x84000000>;
+			pr-mem-base1 = <0xcac8c000>;
+			clocks = <&syscon_apmu CLK_APMU_ESPI_SCLK_SRC>,
+				 <&syscon_apmu CLK_APMU_ESPI_SCLK>,
+				 <&syscon_apmu CLK_APMU_ESPI_MCLK>;
+			clock-names = "sclk_src", "sclk", "mclk";
+			resets = <&syscon_apmu RESET_APMU_ESPI_MCLK>,
+				 <&syscon_apmu RESET_APMU_ESPI_SCLK>;
+			assigned-clocks = <&syscon_apmu CLK_APMU_ESPI_SCLK>;
+			assigned-clock-parents = <&syscon_apmu CLK_APMU_ESPI_SCLK_SRC>;
+			operating-frequency = <20>;
+			io-mode = "single";
+			alert-mode = "io1";
+			alert-type = "open-drain";
+			watchdog-timeout = <0xffff>;
+			crc-enable;
+			auto-gating-enable;
+			peripheral-channel-enable;
+			vwire-channel-enable;
+			oob-channel-enable;
+			flash-channel-enable;
+
+			status = "disabled";
+		};
+
 		eth2: ethernet@cac8e000 {
 			compatible = "spacemit,k3-dwmac", "snps,dwmac-5.40a";
 			reg = <0x0 0xcac8e000 0x0 0x2000>;
Signature · 1 line
2.43.0
#19 lore raw

Re: [PATCH 7/9] riscv: dts: spacemit: Describe the K3 eSPI controller

Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] riscv: dts: spacemit: espi0 sets pr-mem-base1 to MMIO base in k3.dtsi - [Medium] bus…

Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [Medium] riscv: dts: spacemit: espi0 sets pr-mem-base1 to MMIO base in k3.dtsi
- [Medium] bus: spacemit-k3-espi: spacemit_espi_property_enabled() always returns true
- [Medium] bus: spacemit-k3-espi: spacemit_espi_init_locked() sets rate on sclk mux
- [Medium] riscv: dts: spacemit: espi0-0-pins uses bare bias-pull-up in k3-pinctrl.dtsi
--

commit 39603178b0636a387372665a38106a9b79fae1a8
Author: Wang Yang <[email protected]>

riscv: dts: spacemit: Describe the K3 eSPI controller

This commit adds the disabled eSPI controller device node to the SpacemiT K3 SoC devicetree.

Quoted 6 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0 -0
index e89d2cc5ca8cc..d859c84bbaa1d 100644
@@ -648,6 +648,37 @@ gmac1_axi_setup: stmmac-axi-config {
 			};

arch/riscv/boot/dts/spacemit/k3.dtsi gmac1_axi_setup: stmmac-axi-config { · line 658

Quoted 10 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +8 -0
 		};
 
+		espi0: espi@cac8c000 {
+			compatible = "spacemit,k3-espi";
+			reg = <0x0 0xcac8c000 0x0 0x1000>;
+			ranges = <0x0 0x0 0x84000000 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			pr-mem-base0 = <0x84000000>;
+			pr-mem-base1 = <0xcac8c000>;

[Severity: Medium]
Should pr-mem-base1 be 0x85000000 (or omitted so the driver defaults to pr-mem-base0 + SZ_16M) instead of 0xcac8c000?

0xcac8c000 is the eSPI controller's own MMIO control register block, and spacemit_espi_program_window() writes pr-mem-base1 into ESPI_PR_BASE_ADDR_MEM1 as the second peripheral memory translation window base. Setting it to 0xcac8c000 breaks peripheral channel accesses that use the second memory translation window and points them at the controller's own registers.

arch/riscv/boot/dts/spacemit/k3.dtsi gmac1_axi_setup: stmmac-axi-config { · line 662

Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +4 -0
+			clocks = <&syscon_apmu CLK_APMU_ESPI_SCLK_SRC>,
+				 <&syscon_apmu CLK_APMU_ESPI_SCLK>,
+				 <&syscon_apmu CLK_APMU_ESPI_MCLK>;
+			clock-names = "sclk_src", "sclk", "mclk";

[Severity: Medium]
Does setting the serial clock rate via espi->sclk work when operating-frequency differs from the initial parent clock rate?

In commit "bus: Add SpacemiT K3 eSPI controller support", spacemit_espi_probe() only acquires "sclk", and spacemit_espi_init_locked() calls clk_set_rate() on espi->sclk before link frequency negotiation:

drivers/bus/spacemit-k3-espi.c:spacemit_espi_init_locked() {
    ...
	if (espi->sclk && !IS_ERR(espi->sclk) && espi->op_freq_mhz) {
		ret = clk_set_rate(espi->sclk, espi->op_freq_mhz * 1000000UL);
		if (ret)
			dev_dbg(espi->dev, "failed to set sclk rate: %d\n", ret);
	}
    ...
}

In drivers/clk/spacemit/ccu-k3.c, espi_sclk is defined without CLK_SET_RATE_PARENT, while espi_sclk_src holds the 20/25/33/50/66 MHz parent mux. Calling clk_set_rate() on espi->sclk does not switch espi_sclk_src, and if slave negotiation lowers the frequency, the controller and slave are configured for a rate that does not match the actual serial clock.

Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +5 -0
+			resets = <&syscon_apmu RESET_APMU_ESPI_MCLK>,
+				 <&syscon_apmu RESET_APMU_ESPI_SCLK>;
+			assigned-clocks = <&syscon_apmu CLK_APMU_ESPI_SCLK>;
+			assigned-clock-parents = <&syscon_apmu CLK_APMU_ESPI_SCLK_SRC>;
+			operating-frequency = <20>;

arch/riscv/boot/dts/spacemit/k3.dtsi gmac1_axi_setup: stmmac-axi-config { · line 677

Quoted 10 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +10 -0
+			io-mode = "single";
+			alert-mode = "io1";
+			alert-type = "open-drain";
+			watchdog-timeout = <0xffff>;
+			crc-enable;
+			auto-gating-enable;
+			peripheral-channel-enable;
+			vwire-channel-enable;
+			oob-channel-enable;
+			flash-channel-enable;

[Severity: Medium]
Can a board devicetree disable any of these six boolean properties?

In commit "bus: Add SpacemiT K3 eSPI controller support", spacemit_espi_parse_dt() parses these properties with default_value = true:

drivers/bus/spacemit-k3-espi.c:spacemit_espi_property_enabled() {
	if (of_find_property(np, name, NULL))
		return of_property_read_bool(np, name);

	return default_value;
}

When a boolean property is present, of_property_read_bool() returns true; when it is omitted or removed with /delete-property/ in a board dts, of_find_property() is NULL and spacemit_espi_property_enabled() returns default_value, which is also true.

[Severity: Medium]
Also, in commit "riscv: dts: spacemit: Add K3 eSPI pin group", does espi0-0-pins configure a strong pull-up instead of the intended normal pull-up?

arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi:

		espi0-0-pins {
			pinctrl-single,pins = <
				K3_PADCONF(GPIO_115, MUX_MODE2)	/* espi_dat0 */
				...
			>;
			bias-pull-up;			/* normal pull-up */
			drive-strength = <25>;		/* DS8 */
			power-source = <1800>;
		};

The spacemit,k1-pinctrl binding requires a u32 argument (0 for normal pull-up, 1 for strong pull-up), as used elsewhere in k3-pinctrl.dtsi with bias-pull-up = <0>. With a bare bias-pull-up property, pinconf-generic passes the default argument of 1, causing spacemit_pinconf_generate_config() to set PAD_STRONG_PULL and failing dtbs_check.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
author
#20 lore raw

PATCH 8/9 riscv: dts: spacemit: Enable the FML13V05 EC keyboard

In reply to Wang Yang

Connect the board EC to the eSPI peripheral window and GPIO43 rising- edge interrupt. Describe the vendor 8 by 16 keyboard matrix and its Fn mappings for the existing google,cros-ec-keyb driver.

Preserve the upstream model and compatible strings and keep the EC child local to this board.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 .../spacemit/k3-deepcomputing-fml13v05.dts    | 137 ++++++++++++++++++
 1 file changed, 137 insertions(+)
arch/riscv/boot/dts/spacemit/k3-deepcomputing-fml13v05.dts +137 -0
index b5d5112de..214c8bbb5 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2026 DeepComputing (HK) Limited
  */
 
+#include <dt-bindings/input/input.h>
+
 #include "k3.dtsi"
 #include "k3-pinctrl.dtsi"
 
@@ -29,3 +31,138 @@ &uart0 {
 	pinctrl-0 = <&uart0_0_cfg>;
 	status = "okay";
 };
+
+&espi0 {
+	pinctrl-0 = <&espi0_2_cfg>;
+	pinctrl-names = "default";
+
+	status = "okay";
+
+	ec: ec@0 {
+		compatible = "spacemit,k3-cros-ec";
+		reg = <0x0 0x1000>;
+		interrupt-parent = <&gpio>;
+		interrupts = <1 11 IRQ_TYPE_EDGE_RISING>;
+
+		keyboard-controller {
+			compatible = "google,cros-ec-keyb";
+			keypad,num-rows = <8>;
+			keypad,num-columns = <16>;
+			linux,keymap = <
+					/* Row 0 */
+					MATRIX_KEY(0x00, 0x00, KEY_C)
+					MATRIX_KEY(0x00, 0x01, KEY_DELETE)
+					MATRIX_KEY(0x00, 0x02, KEY_Q)
+					MATRIX_KEY(0x00, 0x03, KEY_RIGHTALT)
+					MATRIX_KEY(0x00, 0x05, KEY_X)
+					MATRIX_KEY(0x00, 0x06, KEY_V)
+					MATRIX_KEY(0x00, 0x07, KEY_M)
+					MATRIX_KEY(0x00, 0x08, KEY_DOT)
+					MATRIX_KEY(0x00, 0x09, KEY_RIGHTSHIFT)
+					MATRIX_KEY(0x00, 0x0a, KEY_COMMA)
+					MATRIX_KEY(0x00, 0x0c, KEY_RIGHTCTRL)
+					MATRIX_KEY(0x00, 0x0d, KEY_SLASH)
+					MATRIX_KEY(0x00, 0x0e, KEY_APOSTROPHE)
+
+					/* Row 1 */
+					MATRIX_KEY(0x01, 0x03, KEY_LEFTALT)
+					MATRIX_KEY(0x01, 0x04, KEY_SPACE)
+					MATRIX_KEY(0x01, 0x05, KEY_Z)
+					MATRIX_KEY(0x01, 0x06, KEY_B)
+					MATRIX_KEY(0x01, 0x07, KEY_N)
+					MATRIX_KEY(0x01, 0x08, KEY_DOWN)
+					MATRIX_KEY(0x01, 0x09, KEY_LEFTSHIFT)
+					MATRIX_KEY(0x01, 0x0c, KEY_LEFTCTRL)
+					MATRIX_KEY(0x01, 0x0d, KEY_UP)
+					MATRIX_KEY(0x01, 0x0e, KEY_ENTER)
+					MATRIX_KEY(0x01, 0x0f, KEY_F8)
+
+					/* Row 2 */
+					MATRIX_KEY(0x02, 0x02, KEY_FN)
+					MATRIX_KEY(0x02, 0x04, KEY_E)
+					MATRIX_KEY(0x02, 0x05, KEY_F2)
+					MATRIX_KEY(0x02, 0x06, KEY_G)
+					MATRIX_KEY(0x02, 0x07, KEY_H)
+					MATRIX_KEY(0x02, 0x08, KEY_BACKSLASH)
+					MATRIX_KEY(0x02, 0x0a, KEY_F7)
+					MATRIX_KEY(0x02, 0x0d, KEY_MINUS)
+					MATRIX_KEY(0x02, 0x0f, KEY_RIGHT)
+
+					/* Row 3 */
+					MATRIX_KEY(0x03, 0x01, KEY_LEFTMETA)
+					MATRIX_KEY(0x03, 0x02, KEY_TAB)
+					MATRIX_KEY(0x03, 0x04, KEY_F4)
+					MATRIX_KEY(0x03, 0x05, KEY_F1)
+					MATRIX_KEY(0x03, 0x06, KEY_T)
+					MATRIX_KEY(0x03, 0x07, KEY_Y)
+					MATRIX_KEY(0x03, 0x08, KEY_O)
+					MATRIX_KEY(0x03, 0x0a, KEY_F6)
+					MATRIX_KEY(0x03, 0x0b, KEY_F9)
+					MATRIX_KEY(0x03, 0x0d, KEY_F12)
+
+					/* Row 4 */
+					MATRIX_KEY(0x04, 0x02, KEY_GRAVE)
+					MATRIX_KEY(0x04, 0x04, KEY_CAPSLOCK)
+					MATRIX_KEY(0x04, 0x05, KEY_S)
+					MATRIX_KEY(0x04, 0x06, KEY_5)
+					MATRIX_KEY(0x04, 0x07, KEY_6)
+					MATRIX_KEY(0x04, 0x08, KEY_F10)
+					MATRIX_KEY(0x04, 0x0a, KEY_F5)
+					MATRIX_KEY(0x04, 0x0d, KEY_0)
+					MATRIX_KEY(0x04, 0x0e, KEY_EQUAL)
+
+					/* Row 5 */
+					MATRIX_KEY(0x05, 0x02, KEY_1)
+					MATRIX_KEY(0x05, 0x04, KEY_3)
+					MATRIX_KEY(0x05, 0x05, KEY_2)
+					MATRIX_KEY(0x05, 0x06, KEY_4)
+					MATRIX_KEY(0x05, 0x07, KEY_7)
+					MATRIX_KEY(0x05, 0x08, KEY_9)
+					MATRIX_KEY(0x05, 0x0a, KEY_8)
+					MATRIX_KEY(0x05, 0x0b, KEY_102ND)
+					MATRIX_KEY(0x05, 0x0d, KEY_P)
+					MATRIX_KEY(0x05, 0x0e, KEY_BACKSPACE)
+
+					/* Row 6 */
+					MATRIX_KEY(0x06, 0x04, KEY_F3)
+					MATRIX_KEY(0x06, 0x05, KEY_W)
+					MATRIX_KEY(0x06, 0x06, KEY_R)
+					MATRIX_KEY(0x06, 0x07, KEY_U)
+					MATRIX_KEY(0x06, 0x08, KEY_F11)
+					MATRIX_KEY(0x06, 0x0a, KEY_I)
+					MATRIX_KEY(0x06, 0x0b, KEY_LEFT)
+					MATRIX_KEY(0x06, 0x0d, KEY_LEFTBRACE)
+					MATRIX_KEY(0x06, 0x0e, KEY_RIGHTBRACE)
+
+					/* Row 7 */
+					MATRIX_KEY(0x07, 0x02, KEY_A)
+					MATRIX_KEY(0x07, 0x05, KEY_ESC)
+					MATRIX_KEY(0x07, 0x06, KEY_F)
+					MATRIX_KEY(0x07, 0x07, KEY_J)
+					MATRIX_KEY(0x07, 0x08, KEY_L)
+					MATRIX_KEY(0x07, 0x0a, KEY_K)
+					MATRIX_KEY(0x07, 0x0d, KEY_SEMICOLON)
+					MATRIX_KEY(0x07, 0x0e, KEY_D)
+
+					/* Fn layer (row + 8). */
+					MATRIX_KEY(0x08, 0x01, KEY_INSERT)        /* Fn+Delete */
+					MATRIX_KEY(0x09, 0x08, KEY_PAGEDOWN)      /* Fn+Down */
+					MATRIX_KEY(0x09, 0x0d, KEY_PAGEUP)        /* Fn+Up */
+					MATRIX_KEY(0x09, 0x0f, KEY_BRIGHTNESSUP)  /* Fn+F8 */
+					MATRIX_KEY(0x0a, 0x05, KEY_VOLUMEDOWN)    /* Fn+F2 */
+					MATRIX_KEY(0x0a, 0x0a, KEY_BRIGHTNESSDOWN) /* Fn+F7 */
+					MATRIX_KEY(0x0a, 0x0f, KEY_END)           /* Fn+Right */
+					MATRIX_KEY(0x0b, 0x04, KEY_PREVIOUSSONG)  /* Fn+F4 */
+					MATRIX_KEY(0x0b, 0x05, KEY_MUTE)          /* Fn+F1 */
+					MATRIX_KEY(0x0b, 0x0a, KEY_NEXTSONG)      /* Fn+F6 */
+					MATRIX_KEY(0x0b, 0x0b, KEY_SWITCHVIDEOMODE) /* Fn+F9 */
+					MATRIX_KEY(0x0b, 0x0d, KEY_CONFIG)        /* Fn+F12 */
+					MATRIX_KEY(0x0c, 0x08, KEY_RFKILL)        /* Fn+F10 */
+					MATRIX_KEY(0x0c, 0x0a, KEY_PLAYPAUSE)     /* Fn+F5 */
+					MATRIX_KEY(0x0e, 0x04, KEY_VOLUMEUP)      /* Fn+F3 */
+					MATRIX_KEY(0x0e, 0x08, KEY_SYSRQ)         /* Fn+F11 */
+					MATRIX_KEY(0x0e, 0x0b, KEY_HOME)          /* Fn+Left */
+					>;
+		};
+	};
+};
Signature · 1 line
2.43.0
#21 lore raw

Re: [PATCH 8/9] riscv: dts: spacemit: Enable the FML13V05 EC keyboard

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] riscv: dts: spacemit: espi0_2_cfg uses bare bias-pull-up instead of <0> --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] riscv: dts: spacemit: espi0_2_cfg uses bare bias-pull-up instead of <0>
--

commit 032746cb10950441af76e89d1f8e24310fb7d057
Author: Wang Yang <[email protected]>

riscv: dts: spacemit: Enable the FML13V05 EC keyboard

This commit enables the eSPI controller and adds the embedded controller and keyboard matrix node to the DeepComputing FML13V05 board device tree.

Quoted 14 lines
arch/riscv/boot/dts/spacemit/k3-deepcomputing-fml13v05.dts +2 -0
index b5d5112de3581..214c8bbb52f06 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2026 DeepComputing (HK) Limited
  */
 
+#include <dt-bindings/input/input.h>
+
 #include "k3.dtsi"
 #include "k3-pinctrl.dtsi"
 

arch/riscv/boot/dts/spacemit/k3-deepcomputing-fml13v05.dts &uart0 { · line 36

Quoted 6 lines
arch/riscv/boot/dts/spacemit/k3-deepcomputing-fml13v05.dts +3 -0
@@ -29,3 +31,138 @@ &uart0 {
 	pinctrl-0 = <&uart0_0_cfg>;
 	status = "okay";
 };
+
+&espi0 {
+	pinctrl-0 = <&espi0_2_cfg>;

[Severity: Medium]
Does selecting espi0_2_cfg program a strong pull-up on the eSPI pins instead of the intended normal pull-up?

arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi:

	espi0_2_cfg: espi0-2-cfg {
		espi0-0-pins {
			...
			bias-pull-up;			/* normal pull-up */

Unlike the other normal pull-up groups in k3-pinctrl.dtsi that specify bias-pull-up = <0>, espi0-0-pins omits the cell value. When no value is given, parse_fw_cfg() supplies the default argument 1 for PIN_CONFIG_BIAS_PULL_UP, which causes spacemit_pinconf_generate_config() in drivers/pinctrl/spacemit/pinctrl-k1.c to set PAD_STRONG_PULL (and fails dtbs_check against spacemit,k1-pinctrl.yaml, which requires 0 or 1).

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
author
#22 lore raw

PATCH 9/9 riscv: defconfig: Enable the FML13V05 EC keyboard modules

In reply to Wang Yang

Enable the eSPI controller and Chrome platform configuration menu. Build the EC core, memory transport and keyboard driver as modules so OF modaliases can load them on boards that describe this hardware.

Keep all configuration choices in this final standalone patch.

Prepared with Codex assistance from the existing DC-linux EC support.

---
 arch/riscv/configs/defconfig | 5 +++++
 1 file changed, 5 insertions(+)
arch/riscv/configs/defconfig +5 -0
index 383fdd07a..1ddb8cd5f 100644
@@ -145,7 +145,9 @@ CONFIG_MICREL_PHY=y
 CONFIG_MICROSEMI_PHY=y
 CONFIG_MOTORCOMM_PHY=y
 CONFIG_INPUT_MOUSEDEV=y
+CONFIG_SPACEMIT_ESPI_BUS=y
 CONFIG_INPUT_EVDEV=y
+CONFIG_KEYBOARD_CROS_EC=m
 CONFIG_KEYBOARD_GPIO=y
 CONFIG_KEYBOARD_SUN4I_LRADC=m
 CONFIG_SERIAL_8250=y
@@ -277,6 +279,9 @@ CONFIG_PHY_SUN4I_USB=m
 CONFIG_PHY_STARFIVE_JH7110_DPHY_RX=m
 CONFIG_PHY_STARFIVE_JH7110_PCIE=m
 CONFIG_PHY_STARFIVE_JH7110_USB=m
+CONFIG_CHROME_PLATFORMS=y
+CONFIG_CROS_EC=m
+CONFIG_CROS_EC_SPACEMIT_K3=m
 CONFIG_LIBNVDIMM=y
 CONFIG_NVMEM_SUNXI_SID=y
 CONFIG_EXT4_FS=y
Signature · 1 line
2.43.0