Add SpacemiT K3 FML13V05 EC keyboard support
Subsystems (5)
v2 cover Add SpacemiT K3 FML13V05 EC keyboard support
This series enables the built-in keyboard on the DeepComputing FML13V05. The SpacemiT K3 host exposes the EC command window through the eSPI Peripheral Channel. The EC implements the Chrome EC host protocol, and the existing Chrome EC keyboard driver reports input events.
Changes since v1:
- Share LPC-style polling, protocol v2/v3 transfers and readmem between the LPC and K3 transports. Keep the K3 window mapping and recovery in the K3 transport. A command that times out is not replayed.
- Let the EC core request the IRQ. Existing transports keep their low-level default and K3 uses the rising edge specified by the board.
- Add the EC binding before the controller binding that references it. Derive the CPU window from ranges and specify the link frequency in Hz. The second peripheral base retains the vendor board value, 0xcac8c000.
- Correct the pin pull settings, command status clearing and negotiated clock selection. Check packet bounds and EC readiness. On resume, check a pending recovery before enabling the EC event IRQ.
- Order the five RISC-V configuration entries using savedefconfig.
The AMD host RFC models chip-select targets and controller operations. K3 needs a CPU-mapped Peripheral Channel window and a way to recover the host link following a timeout. The Aspeed series covers the BMC side.
On next-20261202, an earlier revision booted on FML13V05 from NVMe with test-only PCIe and DT additions. After a mainboard reset with the EC still powered, the EC reported FML13V05-V01.06. The built-in keyboard reported a left Shift press and release, and the EC IRQ count rose from zero to two. The change since that test is confined to the K3 EC transport's link check at probe and resume.
OpenAI Codex assisted with refactoring, review of v1 feedback, commit messages and test preparation.
v1: https://lore.kernel.org/all/[email protected]/
AMD RFC: https://lore.kernel.org/all/[email protected]/
Aspeed: https://lore.kernel.org/all/[email protected]/
Wang Yang (13):
platform/chrome: Correct LPC EC readmem bounds platform/chrome: Extract LPC-style EC protocol helpers platform/chrome: Allow transport-specific LPC response timeouts platform/chrome: Allow transports to select EC IRQ flags
dt-bindings: embedded-controller: Add SpacemiT K3 EC window
dt-bindings: bus: Add SpacemiT K3 Intel eSPI controller
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 | 149 ++++ .../spacemit,k3-cros-ec.yaml | 77 ++ .../spacemit/k3-deepcomputing-fml13v05.dts | 137 +++ arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi | 24 + arch/riscv/boot/dts/spacemit/k3.dtsi | 30 + arch/riscv/configs/defconfig | 5 + drivers/bus/Kconfig | 10 + drivers/bus/Makefile | 1 + drivers/bus/spacemit-k3-espi.c | 799 ++++++++++++++++++ drivers/platform/chrome/Kconfig | 20 +- drivers/platform/chrome/Makefile | 4 +- drivers/platform/chrome/cros_ec.c | 3 +- .../platform/chrome/cros_ec_espi_spacemit.c | 568 +++++++++++++ drivers/platform/chrome/cros_ec_lpc.c | 239 +----- drivers/platform/chrome/cros_ec_lpc_proto.c | 246 ++++++ drivers/platform/chrome/cros_ec_lpc_proto.h | 36 + include/linux/platform_data/cros_ec_proto.h | 2 + include/linux/spacemit-k3-espi.h | 20 + 18 files changed, 2152 insertions(+), 218 deletions(-) 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_espi_spacemit.c create mode 100644 drivers/platform/chrome/cros_ec_lpc_proto.c create mode 100644 drivers/platform/chrome/cros_ec_lpc_proto.h create mode 100644 include/linux/spacemit-k3-espi.h
base-commit: 799dd936553182df5770dde7f38d94c8337df75a
Signature · 1 line
2.43.0
PATCH v2 1/13 platform/chrome: Correct LPC EC readmem bounds
Reject offsets outside the EC memory map before calculating the remaining space. Allow fixed-length reads ending exactly at the end of the map and reject oversized reads without underflow.
Prepared with OpenAI Codex assistance.
--- drivers/platform/chrome/cros_ec_lpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_lpc.c +1 -1
@@ -417,7 +417,7 @@ static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,int cnt =0 ;int ret; -if (offset >=EC_MEMMAP_SIZE - bytes) +if (offset >=EC_MEMMAP_SIZE || bytes >EC_MEMMAP_SIZE - offset)return -EINVAL ;/* fixed length */
Signature · 1 line
2.43.0
PATCH v2 2/13 platform/chrome: Extract LPC-style EC protocol helpers
In reply to Wang YangMove response polling, v2/v3 host commands and readmem into shared helpers. Keep LPC ACPI/DMI/MEC enumeration and hardware byte access in the LPC driver. Use a static byte-access table and pass the device specific memory-map base to the shared readmem helper. Link the helpers into the existing cros-ec-proto module so LPC keeps its existing module filename and protocol dependency.
Prepared with OpenAI Codex assistance.
--- drivers/platform/chrome/Kconfig | 6 + drivers/platform/chrome/Makefile | 3 +- drivers/platform/chrome/cros_ec_lpc.c | 239 ++----------------- drivers/platform/chrome/cros_ec_lpc_proto.c | 245 ++++++++++++++++++++ drivers/platform/chrome/cros_ec_lpc_proto.h | 32 +++ 5 files changed, 309 insertions(+), 216 deletions(-) create mode 100644 drivers/platform/chrome/cros_ec_lpc_proto.c create mode 100644 drivers/platform/chrome/cros_ec_lpc_proto.h
drivers/platform/chrome/Kconfig +6 -0
@@ -140,10 +140,16 @@ config CROS_EC_UART To compile this driver as a module, choose M here: the module will be called cros_ec_uart. +config CROS_EC_LPC_PROTO + bool + help + Include the LPC-style host command helpers in cros-ec-proto. + config CROS_EC_LPC tristate "ChromeOS Embedded Controller (LPC)" depends on CROS_EC && ACPI && (X86 || COMPILE_TEST) depends on HAS_IOPORT + select CROS_EC_LPC_PROTO help If you say Y here, you get support for talking to the ChromeOS EC over an LPC bus, including the LPC Microchip EC (MEC) variant.
drivers/platform/chrome/Makefile +2 -1
@@ -25,7 +25,8 @@ endif obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o -cros-ec-proto-objs := cros_ec_proto.o cros_ec_trace.o +cros-ec-proto-y := cros_ec_proto.o cros_ec_trace.o +cros-ec-proto-$(CONFIG_CROS_EC_LPC_PROTO) += cros_ec_lpc_proto.o obj-$(CONFIG_CROS_EC_PROTO) += cros-ec-proto.o obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o obj-$(CONFIG_CROS_EC_CHARDEV) += cros_ec_chardev.o
drivers/platform/chrome/cros_ec_lpc.c +24 -215
276 lines not on this page · raw message
drivers/platform/chrome/cros_ec_lpc_proto.c new file +245 -0
245 lines not on this page · raw message
drivers/platform/chrome/cros_ec_lpc_proto.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __CROS_EC_LPC_PROTO_H +#define __CROS_EC_LPC_PROTO_H + +#include <linux/types.h> + +struct cros_ec_device ; +struct cros_ec_command ; + +/** +* struct cros_ec_lpc_io - byte access to an LPC-style EC interface +* @read: Read bytes, returning their checksum or a negative error. +* @write: Write bytes, returning their checksum or a negative error. +*/ +struct cros_ec_lpc_io { +int (*read)(struct cros_ec_device *ec,unsigned int offset, +unsigned int length,u8 *dest); +int (*write)(struct cros_ec_device *ec,unsigned int offset, +unsigned int length,const u8 *src); +}; + +int cros_ec_lpc_pkt_xfer (struct cros_ec_device *ec, +const struct cros_ec_lpc_io *io, +struct cros_ec_command *msg); +int cros_ec_lpc_cmd_xfer (struct cros_ec_device *ec, +const struct cros_ec_lpc_io *io, +struct cros_ec_command *msg); +int cros_ec_lpc_readmem (struct cros_ec_device *ec, +const struct cros_ec_lpc_io *io,unsigned int memmap_base, +unsigned int offset,unsigned int bytes,void *dest); + +#endif /* __CROS_EC_LPC_PROTO_H */
Signature · 1 line
2.43.0
PATCH v2 3/13 platform/chrome: Allow transport-specific LPC response timeouts
In reply to Wang YangPreserve the LPC default of one second and -EIO. Let a transport supply a deadline and timeout error without copying the polling loop.
Prepared with OpenAI Codex assistance.
--- drivers/platform/chrome/cros_ec_lpc_proto.c | 9 +++++---- drivers/platform/chrome/cros_ec_lpc_proto.h | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec_lpc_proto.c +5 -4
@@ -13,7 +13,8 @@static int ec_response_timed_out (struct cros_ec_device *ec,const struct cros_ec_lpc_io *io) { -unsigned long one_second = jiffies +HZ ; +unsigned long timeout = jiffies + (io->response_timeout_ms ? +msecs_to_jiffies (io->response_timeout_ms) :HZ );u8 data;int ret;
@@ -25,7 +26,7 @@ static int ec_response_timed_out(struct cros_ec_device *ec,if (!(data &EC_LPC_STATUS_BUSY_MASK ))return 0 ;usleep_range (100 ,200 ); - }while (time_before (jiffies, one_second)); + }while (time_before (jiffies, timeout));return 1 ; }
@@ -59,7 +60,7 @@ int cros_ec_lpc_pkt_xfer(struct cros_ec_device *ec, goto done;if (ret) {dev_warn (ec->dev,"EC response timed out\n" ); - ret = -EIO ; + ret = io->timeout_error ?: -EIO ; goto done; }
@@ -158,7 +159,7 @@ int cros_ec_lpc_cmd_xfer(struct cros_ec_device *ec, goto done;if (ret) {dev_warn (ec->dev,"EC response timed out\n" ); - ret = -EIO ; + ret = io->timeout_error ?: -EIO ; goto done; }
drivers/platform/chrome/cros_ec_lpc_proto.h +4 -0
@@ -11,12 +11,16 @@ struct cros_ec_command;* struct cros_ec_lpc_io - byte access to an LPC-style EC interface * @read: Read bytes, returning their checksum or a negative error. * @write: Write bytes, returning their checksum or a negative error. +* @response_timeout_ms: Response timeout in milliseconds, or zero for one second. +* @timeout_error: Negative timeout error, or zero for the LPC default (-EIO). */ struct cros_ec_lpc_io {int (*read)(struct cros_ec_device *ec,unsigned int offset,unsigned int length,u8 *dest);int (*write)(struct cros_ec_device *ec,unsigned int offset,unsigned int length,const u8 *src); +unsigned int response_timeout_ms; +int timeout_error; }; int cros_ec_lpc_pkt_xfer(struct cros_ec_device *ec,
Signature · 1 line
2.43.0
PATCH v2 4/13 platform/chrome: Allow transports to select EC IRQ flags
In reply to Wang YangInitialize IRQ flags to IRQF_TRIGGER_LOW | IRQF_ONESHOT when the EC device is allocated. Use these flags when registering the interrupt so a transport can rely on the trigger type configured by its firmware.
Prepared with OpenAI Codex assistance.
--- drivers/platform/chrome/cros_ec.c | 3 ++- include/linux/platform_data/cros_ec_proto.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_ec.c +2 -1
@@ -63,6 +63,7 @@ struct cros_ec_device *cros_ec_device_alloc(struct device *dev)return NULL ; ec_dev->dev = dev; + ec_dev->irqflags =IRQF_TRIGGER_LOW |IRQF_ONESHOT ; ec_dev->max_response =sizeof (struct ec_response_get_protocol_info ); ec_dev->max_request =sizeof (struct ec_params_rwsig_action ); ec_dev->suspend_timeout_ms =EC_HOST_SLEEP_TIMEOUT_DEFAULT ;
@@ -247,7 +248,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) err =devm_request_threaded_irq (dev, ec_dev->irq, cros_ec_irq_handler, cros_ec_irq_thread, -IRQF_TRIGGER_LOW |IRQF_ONESHOT , + ec_dev->irqflags,"chromeos-ec" , ec_dev);if (err) goto exit;
include/linux/platform_data/cros_ec_proto.h +2 -0
@@ -111,6 +111,7 @@ struct cros_ec_command {* @proto_version: The protocol version used for this device. * @priv: Private data. * @irq: Interrupt to use. +* @irqflags: Interrupt request flags, defaulting to IRQF_TRIGGER_LOW | IRQF_ONESHOT. * @id: Device id. * @din: Input buffer (for data from EC). This buffer will always be * dword-aligned and include enough space for up to 7 word-alignment
@@ -181,6 +182,7 @@ struct cros_ec_device {u16 proto_version;void *priv;int irq; +unsigned long irqflags;u8 *din;u8 *dout;int din_size;
Signature · 1 line
2.43.0
PATCH v2 5/13 dt-bindings: embedded-controller: Add SpacemiT K3 EC window
In reply to Wang YangDescribe the K3 non-linear peripheral window before the controller binding references it. Reuse the existing keyboard and I2C tunnel schemas. Keep the Google EC binding unchanged.
Prepared with OpenAI Codex assistance.
--- .../spacemit,k3-cros-ec.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml
Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml new file +77 -0
@@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/embedded-controller/spacemit,k3-cros-ec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ChromeOS EC on the SpacemiT K3 peripheral window + +maintainers: + - Wang Yang <[email protected]> + +description: | + The embedded controller implements ChromeOS EC host commands through the + memory-mapped peripheral window of the SpacemiT K3 eSPI controller. The + window uses a non-linear LPC register layout. Offset 0x00 provides host + command writes and status reads; offset 0x01 provides host data/results. + Protocol v2 arguments and parameters are at 0x10 and 0x18, protocol v3 + packets at 0x100, and the EC memory map at 0x200. This programming interface + is distinct from an EC connected to an ordinary SPI controller. Child + functions use the common ChromeOS EC host-command interface. Devices on + an EC-controlled I2C bus are described below an I2C tunnel child. + +properties: + compatible: + const: spacemit,k3-cros-ec + + reg: + maxItems: 1 + description: EC peripheral memory window, at least 0x300 bytes. + + interrupts: + maxItems: 1 + + wakeup-source: true + + keyboard-controller: + $ref: /schemas/input/google,cros-ec-keyb.yaml# + +patternProperties: + "^i2c-tunnel[0-9]*$": + type: object + $ref: /schemas/i2c/google,cros-ec-i2c-tunnel.yaml# + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + bus { + #address-cells = <1>; + #size-cells = <1>; + + ec@0 { + compatible = "spacemit,k3-cros-ec"; + reg = <0x0 0x1000>; + interrupt-parent = <&gpio>; + interrupts = <1 11 IRQ_TYPE_EDGE_RISING>; + + i2c-tunnel { + compatible = "google,cros-ec-i2c-tunnel"; + #address-cells = <1>; + #size-cells = <0>; + google,remote-bus = <4>; + + battery@b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + }; + }; + }; + };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 05/13] dt-bindings: embedded-controller: Add SpacemiT K3 EC window
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] dt-bindings: spacemit,k3-cros-ec duplicates schema and blocks EC sub-devices - [Low] dt-bindings…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] dt-bindings: spacemit,k3-cros-ec duplicates schema and blocks EC sub-devices
- [Low] dt-bindings: commit message omits rationale for separate K3 EC schema
--
commit 4f4efb4e453c6a6ced3361059125c9028c2520f6
Author: Wang Yang <[email protected]>
Quoted 9 lines
dt-bindings: embedded-controller: Add SpacemiT K3 EC window
Describe the K3 non-linear peripheral window before the controller binding references it. Reuse the existing keyboard and I2C tunnel schemas. Keep the Google EC binding unchanged.
Prepared with OpenAI Codex assistance.
Signed-off-by Wang Yang <[email protected]>
[Severity: Low]
Could the commit message explain why google,cros-ec.yaml is kept unchanged instead of extending it or sharing a common schema?
Right now it only states what the patch does without explaining why a standalone schema is needed, why only keyboard-controller and i2c-tunnel children are permitted, or why a SoC-specific spacemit,k3-cros-ec compatible is used for the ChromeOS EC interface.
Quoted 6 lines
Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml new file +0
-0@@ -0,0 +1,77 @@
[ ... ]
Quoted 4 lines
Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml new file +4
-0+ keyboard-controller: + $ref: /schemas/input/google,cros-ec-keyb.yaml# + +patternProperties:
Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml line 49
Quoted 10 lines
Documentation/devicetree/bindings/embedded-controller/spacemit,k3-cros-ec.yaml new file +10
-0+ "^i2c-tunnel[0-9]*$": + type: object + $ref: /schemas/i2c/google,cros-ec-i2c-tunnel.yaml# + +required: + - compatible + - reg + - interrupts + +additionalProperties: false
[Severity: Low]
Does closing this standalone schema with additionalProperties: false block valid ChromeOS EC sub-devices that the driver populates?
cros_ec_register() populates all DT children via devm_of_platform_populate(), so dtbs_check will reject standard sub-nodes such as pwm, typec, extcon, regulator, or gpio-controller on boards using this binding.
Every property and requirement here is already a subset of google,cros-ec.yaml, whose allOf rules already require reg and interrupts while forbidding SPI-, RPMSG-, and FPMCU-only properties without new conditionals. Controller bindings like mtk,scp.yaml reference it directly.
Adding spacemit,k3-cros-ec to google,cros-ec.yaml, or factoring the shared ChromeOS EC properties and child nodes into a common schema referenced by both, would avoid duplicating the binding and keep all EC sub-devices valid.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v2 6/13 dt-bindings: bus: Add SpacemiT K3 Intel eSPI controller
In reply to Wang YangDescribe the Intel eSPI protocol replacing LPC and its CPU-accessible peripheral window. Reference the already-added K3 EC schema from the first commit. Use vendor properties and frequency units in Hz.
Prepared with OpenAI Codex assistance.
--- .../bindings/bus/spacemit,k3-espi.yaml | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +149 -0
@@ -0,0 +1,149 @@ +# 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 controller implements the Intel Enhanced Serial Peripheral Interface + (eSPI), which replaces LPC. This is a different protocol from the ordinary + SPI bus implemented by the Freescale/NXP controller called eSPI. + + The controller connects the application processor to an embedded controller. + It exposes a CPU-accessible peripheral-channel window, translated by ranges. + EC clients access command, response and memory-map registers through this + window. The controller manages clocks, resets, channel negotiation and 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 + + spacemit,pr-mem-base1: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Base address programmed into the controller's second peripheral-channel memory base register. + + max-frequency: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Maximum eSPI serial clock frequency in Hz. + enum: [20000000, 25000000, 33333333, 50000000, 66666666] + default: 20000000 + + spacemit,io-mode: + $ref: /schemas/types.yaml#/definitions/string + description: Requested number of eSPI data lines. + enum: [single, dual, quad] + default: single + + spacemit,alert-mode: + $ref: /schemas/types.yaml#/definitions/string + description: Use the shared IO1 line or the dedicated alert pin. + enum: [io1, pin] + default: io1 + + spacemit,alert-type: + $ref: /schemas/types.yaml#/definitions/string + description: Electrical mode of the dedicated alert pin. + enum: [open-drain, push-pull] + default: open-drain + + spacemit,watchdog-timeout: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Controller watchdog counter value. + maximum: 65535 + default: 65535 + + spacemit,crc-enable: + type: boolean + description: Enable link CRC checking. + + spacemit,auto-gating-enable: + type: boolean + description: Enable automatic controller clock gating. + + spacemit,peripheral-channel-enable: + type: boolean + description: Enable the peripheral channel. Required for an enabled EC child. + + spacemit,vwire-channel-enable: + type: boolean + description: Enable the virtual-wire channel. + + spacemit,oob-channel-enable: + type: boolean + description: Enable the out-of-band channel. + + spacemit,flash-channel-enable: + type: boolean + description: Enable the flash access channel. + +patternProperties: + '^ec@[0-9a-f]+$': + $ref: /schemas/embedded-controller/spacemit,k3-cros-ec.yaml# + +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + - ranges + - clocks + - clock-names + - resets + - spacemit,pr-mem-base1 + +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>; + 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>; + #address-cells = <1>; + #size-cells = <1>; + spacemit,pr-mem-base1 = <0xcac8c000>; + };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2 06/13] dt-bindings: bus: Add SpacemiT K3 Intel eSPI controller
Thank you for your contribution! Sashiko AI review found 8 potential issues to consider: - [Medium] dt-bindings: bus: raw uint32 spacemit,pr-mem-base1 instead of ranges/reg - [Medium] dt-bindings…
Thank you for your contribution! Sashiko AI review found 8 potential issues to consider:
- [Medium] dt-bindings: bus: raw uint32 spacemit,pr-mem-base1 instead of ranges/reg
- [Medium] dt-bindings: bus: unitless watchdog counter and policy toggles in DT ABI
- [Medium] dt-bindings: bus: patternProperties locks eSPI bus to single EC compatible
- [Medium] dt-bindings: bus: spacemit,k3-espi: exposes internal CCU mux in clocks
- [Low] dt-bindings: bus: unprefixed max-frequency property misnamed and misordered
- [Low] dt-bindings: bus: missing schema constraints for dependent eSPI properties
- [Low] dt-bindings: bus: multiple resets lack reset-names and invert clocks order
- [Low] dt-bindings: commit message has inaccurate series reference and revision notes
--
commit 622dd2b421fba8b4cbf3a78e0da3e8ce4dbb3c5d
Author: Wang Yang <[email protected]>
Quoted 9 lines
dt-bindings: bus: Add SpacemiT K3 Intel eSPI controller
Describe the Intel eSPI protocol replacing LPC and its CPU-accessible peripheral window. Reference the already-added K3 EC schema from the first commit. Use vendor properties and frequency units in Hz.
Prepared with OpenAI Codex assistance.
Signed-off-by Wang Yang <[email protected]>
[Severity: Low]
The commit message refers to "the already-added K3 EC schema from the first commit", but spacemit,k3-cros-ec.yaml was added in commit "dt-bindings:
embedded-controller: Add SpacemiT K3 EC window", not the first patch of the series. Permanent git history should name the schema directly rather than relying on series numbering.
The changelog also reads like revision notes rather than a standalone explanation of the new binding, and "Use vendor properties and frequency units in Hz" does not match the schema (max-frequency has neither a vendor prefix nor a -hz suffix, and spacemit,watchdog-timeout is a raw counter).
Quoted 5 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 49
Quoted 11 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +11
-0+ clocks: + items: + - description: Serial clock source + - description: Serial clock + - description: Bus clock + + clock-names: + items: + - const: sclk_src + - const: sclk + - const: mclk
[Severity: Medium]
Should sclk_src be required in clocks? In drivers/clk/spacemit/ccu-k3.c, APMU_ESPI_CLK_RES_CTRL has only two gated clock outputs to the eSPI block (espi_mclk and espi_sclk, matching the two reset domains), while espi_sclk_src is an ungated internal APMU parent mux feeding espi_sclk.
Exposing sclk_src bakes a Linux CCU driver limitation (espi_sclk lacking CLK_SET_RATE_PARENT and ccu_mix_calc_best_rate() not propagating rate rounding to parents) into the permanent DT ABI. Propagating CLK_SET_RATE_PARENT in the clock driver and using assigned-clocks in DT would let clocks list only sclk and mclk.
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 54
Quoted 4 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +4
-0+ resets: + items: + - description: Bus reset + - description: Serial clock reset
[Severity: Low]
Should this binding include a reset-names property for the two resets? Documentation/devicetree/bindings/writing-bindings.rst recommends reset-names when there is more than one reset entry, and listing bus before serial here inverts the order used by clocks, inviting positional mixups in DTS files.
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 58
Quoted 3 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +3
-0+ spacemit,pr-mem-base1: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Base address programmed into the controller's second peripheral-channel memory base register.
[Severity: Medium]
Why is a hardware memory base address modeled as a required uint32 vendor property instead of ranges or reg? Encoding an address as uint32 hardcodes 32-bit addressing on a 64-bit SoC (k3.dtsi uses 2-cell addresses under soc), bypasses DT address translation, and leaves the address space unspecified.
In the example, spacemit,pr-mem-base1 is set to 0xcac8c000, duplicating the controller's own MMIO reg base. If this register describes a second peripheral window it should use ranges or reg; if it only parks an unused window at the controller base, that address is already known from reg.
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 64
Quoted 5 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +5
-0+ max-frequency: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Maximum eSPI serial clock frequency in Hz. + enum: [20000000, 25000000, 33333333, 50000000, 66666666] + default: 20000000
[Severity: Low]
Is unprefixed max-frequency appropriate for a bus controller binding? Across the tree max-frequency is an MMC-specific property, whereas bus and controller bindings use the core clock-frequency property (ordered before vendor properties) or a vendor-prefixed property with a -hz unit suffix such as spacemit,max-frequency-hz.
[ ... ]
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 82
Quoted 11 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +11
-0+ spacemit,alert-mode: + $ref: /schemas/types.yaml#/definitions/string + description: Use the shared IO1 line or the dedicated alert pin. + enum: [io1, pin] + default: io1 + + spacemit,alert-type: + $ref: /schemas/types.yaml#/definitions/string + description: Electrical mode of the dedicated alert pin. + enum: [open-drain, push-pull] + default: open-drain
[Severity: Low]
Can spacemit,alert-type be restricted in the schema to when spacemit,alert-mode is "pin"? Without a constraint, contradictory nodes that set alert-mode to "io1" alongside alert-type pass dtbs_check silently.
Similarly, spacemit,peripheral-channel-enable states in prose that it is required for an enabled EC child, but no schema rule enforces it.
Quoted 19 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +19
-0+ spacemit,watchdog-timeout: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Controller watchdog counter value. + maximum: 65535 + default: 65535 + + spacemit,crc-enable: + type: boolean + description: Enable link CRC checking. + + spacemit,auto-gating-enable: + type: boolean + description: Enable automatic controller clock gating. + + spacemit,peripheral-channel-enable: + type: boolean + description: Enable the peripheral channel. Required for an enabled EC child. + + spacemit,vwire-channel-enable:
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 112
Quoted 10 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +10
-0+ type: boolean + description: Enable the virtual-wire channel. + + spacemit,oob-channel-enable: + type: boolean + description: Enable the out-of-band channel. + + spacemit,flash-channel-enable: + type: boolean + description: Enable the flash access channel.
[Severity: Medium]
Do these register-level and policy properties belong in the permanent DT ABI? spacemit,watchdog-timeout exposes a unitless 16-bit counter without a standard time unit suffix (such as -us or -ms) or documented tick rate.
spacemit,crc-enable and spacemit,auto-gating-enable are runtime controller policy rather than board hardware description, and the four *-channel-enable booleans duplicate Intel eSPI capability negotiation and child-node presence, forcing DTS files to mirror static driver defaults.
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml line 116
Quoted 3 lines
Documentation/devicetree/bindings/bus/spacemit,k3-espi.yaml new file +3
-0+patternProperties: + '^ec@[0-9a-f]+$': + $ref: /schemas/embedded-controller/spacemit,k3-cros-ec.yaml#
[Severity: Medium]
Does patternProperties lock this SoC eSPI bus controller to a single ChromeOS EC compatible? Combined with additionalProperties: false and the const compatible in spacemit,k3-cros-ec.yaml, no K3 board can attach a different eSPI peripheral or use the standard embedded-controller@ node name without modifying the controller schema.
Matching generic child nodes (such as '@[0-9a-f]+$' with type: object,
additionalProperties: true, and required: [reg]) lets each attached eSPI device be validated by its own compatible-matched schema.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
PATCH v2 7/13 bus: Add SpacemiT K3 eSPI controller support
In reply to Wang YangInitialize clocks, resets, link negotiation and windows before populating EC children. Preserve unrelated asynchronous status bits, clear completion before commands and use the negotiated clock source. The controller is vendor-derived from revision 29b78afb484b, originally authored by goumin <[email protected]>.
The AMD eSPI bus RFC ([email protected]) was reviewed. Target/channel APIs, DT enumeration, MMIO peripheral access and recovery integration remain discussion points; this series does not claim that the platform-parent model is approved.
Select an I/O width supported by the endpoint and wiring. For the peripheral channel, read its configuration at the negotiated rate and wait for READY before programming the CPU window.
Prepared with OpenAI Codex assistance.
--- drivers/bus/Kconfig | 10 + drivers/bus/Makefile | 1 + drivers/bus/spacemit-k3-espi.c | 799 +++++++++++++++++++++++++++++++ include/linux/spacemit-k3-espi.h | 20 + 4 files changed, 830 insertions(+) create mode 100644 drivers/bus/spacemit-k3-espi.c create mode 100644 include/linux/spacemit-k3-espi.h
drivers/bus/Kconfig +10 -0
@@ -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. + Register child devices described in the device tree so their + drivers can access the peripheral shared-memory window. + config STM32_FIREWALL bool "STM32 Firewall framework" depends on (ARCH_STM32 || COMPILE_TEST) && OF
drivers/bus/Makefile +1 -0
@@ -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 +799 -0
799 lines not on this page · raw message
include/linux/spacemit-k3-espi.h new file +20 -0
@@ -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
PATCH v2 8/13 platform/chrome: Allow ChromeOS platform support on RISC-V
In reply to Wang YangAllow RISC-V boards to enable ChromeOS EC and its child drivers without selecting COMPILE_TEST.
Prepared with OpenAI Codex assistance.
--- drivers/platform/chrome/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/Kconfig +1 -1
@@ -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
PATCH v2 9/13 platform/chrome: Add SpacemiT K3 eSPI EC transport
In reply to Wang YangMap the K3 non-linear window and reuse the common LPC-style protocol helpers. Keep K3 readiness, five-second timeout and link recovery in the vendor backend. Recover a timed-out link without replaying a command that may already have executed. Let the EC core request the firmware-configured event IRQ.
Use module cros_ec_espi_spacemit, CONFIG_CROS_EC_SPACEMIT_K3 and compatible spacemit,k3-cros-ec. This is a K3-specific interface.
Require the firmware event IRQ before accessing the EC. Serialize host commands and direct memory reads with link recovery. Retry transient negotiation failures, then wait for the EC ID on the established link. Give the already negotiated link time to publish its ID before resetting it at probe. Recover synchronously during protocol negotiation. Once the core installs the dedicated GPIO IRQ action, defer link recovery to a workqueue so the GPIO bank thread can service other pins. Prevent queued recovery from outliving a failed probe. Reject window accesses while recovery is active. Check request and response sizes against the K3 packet window.
Check a pending link recovery before enabling the event IRQ on resume. Prepared with OpenAI Codex assistance.
--- drivers/platform/chrome/Kconfig | 12 + drivers/platform/chrome/Makefile | 1 + .../platform/chrome/cros_ec_espi_spacemit.c | 568 ++++++++++++++++++ 3 files changed, 581 insertions(+) create mode 100644 drivers/platform/chrome/cros_ec_espi_spacemit.c
drivers/platform/chrome/Kconfig +12 -0
@@ -160,6 +160,18 @@ 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 + select CROS_EC_LPC_PROTO + 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_espi_spacemit. + config CROS_EC_PROTO tristate help
drivers/platform/chrome/Makefile +1 -0
@@ -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_espi_spacemit.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_espi_spacemit.c new file +568 -0
568 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 10/13 riscv: dts: spacemit: Add K3 eSPI pin group
In reply to Wang YangUse normal pull-up explicitly and describe 25 mA drive as DS10 at 1.8 V.
Prepared with OpenAI Codex assistance.
--- arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi +24 -0
@@ -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 = <0>; /* normal pull-up */ + drive-strength = <25>; /* DS10 at 1.8V */ + power-source = <1800>; + }; + + espi0-1-pins { + pinmux = <K3_PADCONF(96, 4)>; /* espi0 clk */ + + bias-pull-down; /* normal pull-down */ + drive-strength = <25>; /* DS10 at 1.8V */ + 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
[email protected]
AI reviewRe: [PATCH v2 10/13] riscv: dts: spacemit: Add K3 eSPI pin group
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] riscv: dts: spacemit: espi0_2_cfg missing /omit-if-no-ref/ in k3-pinctrl.dtsi - [Low] riscv: dts…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Low] riscv: dts: spacemit: espi0_2_cfg missing /omit-if-no-ref/ in k3-pinctrl.dtsi
- [Low] riscv: dts: spacemit: commit message omits hardware context for eSPI pin group
--
commit 573b76a43a83fcb0efa8f4f16e5cf89723836fe3
Author: Wang Yang <[email protected]>
Quoted 7 lines
riscv: dts: spacemit: Add K3 eSPI pin group
Use normal pull-up explicitly and describe 25 mA drive as DS10 at 1.8 V.
Prepared with OpenAI Codex assistance.
Signed-off-by Wang Yang <[email protected]>
[Severity: Low]
The commit message reads like a patch revision note rather than a standalone changelog. Should it describe the espi0_2_cfg group being added (pads 91-98 in alt function 4, pull-down on clk vs pull-up on the other pins, and why 1.8 V power-source is fixed at the SoC level)?
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi line 14
Quoted 9 lines
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi +1
-0@@ -11,6 +11,30 @@ #define K3_GPIO(x) (x / 32) (x % 32) &pinctrl { + espi0_2_cfg: espi0-2-cfg {
[Severity: Low]
Should espi0_2_cfg be marked with /omit-if-no-ref/ like the other optional peripheral pin groups in k3-pinctrl.dtsi? Without it, dtc emits espi0-2-cfg and both pin subnodes into every K3 board DTB, even on boards such as k3-pico-itx.dts that do not use eSPI.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
PATCH v2 11/13 riscv: dts: spacemit: Describe the K3 eSPI controller
In reply to Wang YangDescribe the controller resources and corrected link properties. Require explicit MEM1 configuration; retain the BSP value until vendor register documentation establishes a different interpretation.
Prepared with OpenAI Codex assistance.
--- arch/riscv/boot/dts/spacemit/k3.dtsi | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
arch/riscv/boot/dts/spacemit/k3.dtsi +30 -0
@@ -648,6 +648,36 @@ 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>; + 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>; + max-frequency = <20000000>; + spacemit,pr-mem-base1 = <0xcac8c000>; + spacemit,io-mode = "single"; + spacemit,alert-mode = "io1"; + spacemit,alert-type = "open-drain"; + spacemit,watchdog-timeout = <0xffff>; + spacemit,crc-enable; + spacemit,auto-gating-enable; + spacemit,peripheral-channel-enable; + spacemit,vwire-channel-enable; + spacemit,oob-channel-enable; + spacemit,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
[email protected]
AI reviewRe: [PATCH v2 11/13] riscv: dts: spacemit: Describe the K3 eSPI controller
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] riscv: dts: spacemit: espi0 sets spacemit,pr-mem-base1 to its own MMIO base - [Low] riscv: dts…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] riscv: dts: spacemit: espi0 sets spacemit,pr-mem-base1 to its own MMIO base
- [Low] riscv: dts: spacemit: commit message uses revision-delta phrasing
- [Low] riscv: dts: spacemit: board-level eSPI flags hardcoded in shared k3.dtsi
--
commit f467024ef82df1d6d6bcf1c8b90cb44fb44533de
Author: Wang Yang <[email protected]>
Quoted 9 lines
riscv: dts: spacemit: Describe the K3 eSPI controller
Describe the controller resources and corrected link properties. Require explicit MEM1 configuration; retain the BSP value until vendor register documentation establishes a different interpretation.
Prepared with OpenAI Codex assistance.
Signed-off-by Wang Yang <[email protected]>
[Severity: Low]
Can the commit message be rewritten to stand on its own? This patch adds the espi0 node to k3.dtsi for the first time, so "corrected link properties" reads like revision-changelog wording that belongs below the "---" separator.
Similarly, "Require explicit MEM1 configuration" describes a binding and driver policy from earlier patches in the series rather than what this DTS change does. Describing why the K3 eSPI node is added and how its resources are configured would make the permanent commit log clearer.
Quoted 12 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +4
-0@@ -648,6 +648,36 @@ gmac1_axi_setup: stmmac-axi-config { }; }; + espi0: espi@cac8c000 { + compatible = "spacemit,k3-espi"; + reg = <0x0 0xcac8c000 0x0 0x1000>; + ranges = <0x0 0x0 0x84000000 0x1000>;
[ ... ]
arch/riscv/boot/dts/spacemit/k3.dtsi gmac1_axi_setup: stmmac-axi-config { · line 666
Quoted 2 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +2
-0+ max-frequency = <20000000>; + spacemit,pr-mem-base1 = <0xcac8c000>;
[Severity: Medium]
Should spacemit,pr-mem-base1 point to the controller's own MMIO register base (0xcac8c000)? spacemit_espi_program_window() writes this value directly into ESPI_PR_BASE_ADDR_MEM1, which the binding documents as the second peripheral-channel memory base register.
If ESPI_PR_BASE_ADDR_MEM1 configures a second peripheral memory decode window, programming 0xcac8c000 aliases the eSPI controller's own control registers and omits the window from standard DT ranges translation. If the register has different hardware semantics, retaining an unverified BSP value bakes an inaccurate description into the stable Devicetree ABI.
arch/riscv/boot/dts/spacemit/k3.dtsi gmac1_axi_setup: stmmac-axi-config { · line 676
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +10
-0+ spacemit,io-mode = "single"; + spacemit,alert-mode = "io1"; + spacemit,alert-type = "open-drain"; + spacemit,watchdog-timeout = <0xffff>; + spacemit,crc-enable; + spacemit,auto-gating-enable; + spacemit,peripheral-channel-enable; + spacemit,vwire-channel-enable; + spacemit,oob-channel-enable; + spacemit,flash-channel-enable;
[Severity: Low]
Should these board-level link and channel properties live in the board DTS rather than k3.dtsi? Because spacemit_espi_parse_dt() reads the six boolean flags with of_property_read_bool(), placing them in the shared SoC file forces boards to inherit them or use /delete-property/ to disable them.
In particular, inheriting the vwire, OOB, and flash channel flags causes spacemit_espi_configure_channels() to enable those channels on any EC that advertises them, even though drivers/bus/spacemit-k3-espi.c has no IRQ handler or RX drain path for them.
In addition, spacemit,alert-type = "open-drain" is ignored when spacemit,alert-mode is "io1", and the five link value properties (max-frequency, io-mode, alert-mode, alert-type, and watchdog-timeout) all duplicate the binding and driver defaults.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
PATCH v2 12/13 riscv: dts: spacemit: Enable the FML13V05 EC keyboard
In reply to Wang YangEnable the EC window, GPIO event IRQ and existing EC keyboard driver.
Prepared with OpenAI Codex assistance.
--- .../spacemit/k3-deepcomputing-fml13v05.dts | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+)
arch/riscv/boot/dts/spacemit/k3-deepcomputing-fml13v05.dts +137 -0
@@ -3,6 +3,8 @@ * Copyright (C) 2026 DeepComputing (HK) Limited */ +#include <dt-bindings/input/input.h> + #include "k3.dtsi" #include "k3-pinctrl.dtsi"
@@ -32,6 +34,141 @@ reg_aux_vcc5v: regulator-aux-vcc5v { }; }; +&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 */ + >; + }; + }; +}; + &i2c8 { pinctrl-names = "default"; pinctrl-0 = <&i2c8_cfg>;
Signature · 1 line
2.43.0
PATCH v2 13/13 riscv: defconfig: Enable the FML13V05 EC keyboard modules
In reply to Wang YangEnable the K3 controller and build EC transport and keyboard as modules.
Prepared with OpenAI Codex assistance.
--- arch/riscv/configs/defconfig | 5 +++++ 1 file changed, 5 insertions(+)
arch/riscv/configs/defconfig +5 -0
@@ -112,6 +112,7 @@ CONFIG_PCIE_FU740=y CONFIG_PCIE_STARFIVE_HOST=m CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y +CONFIG_SPACEMIT_ESPI_BUS=y CONFIG_SIFIVE_CCACHE=y CONFIG_MTD=y CONFIG_MTD_BLOCK=y
@@ -149,6 +150,7 @@ CONFIG_INPUT_MOUSEDEV=y CONFIG_INPUT_EVDEV=y CONFIG_KEYBOARD_GPIO=y CONFIG_KEYBOARD_SUN4I_LRADC=m +CONFIG_KEYBOARD_CROS_EC=m CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_DW=y
@@ -260,6 +262,9 @@ CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_BALLOON=y CONFIG_VIRTIO_INPUT=y CONFIG_VIRTIO_MMIO=y +CONFIG_CHROME_PLATFORMS=y +CONFIG_CROS_EC=m +CONFIG_CROS_EC_SPACEMIT_K3=m CONFIG_CLK_SOPHGO_CV1800=y CONFIG_CLK_SOPHGO_SG2042_PLL=y CONFIG_CLK_SOPHGO_SG2042_CLKGEN=y
Signature · 1 line
2.43.0