Skip to contentSkip to conversation

soc: aspeed: Add AST2600 eSPI controller support

PATCH In review aspeedyh 11 participants 45 messages Mar 13 – Jun 30

Subsystems (2)
lore
Share & tools
lore

aspeedyh

author
#0 lore raw

cover soc: aspeed: Add AST2600 eSPI controller support

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

The driver is intended to support host-BMC communication over the BMC-side eSPI slave controller present on AST2600 systems.

Patch summary:
1. dt-bindings: soc: aspeed: Add AST2600 eSPI controller
2. soc: aspeed: Introduce core eSPI controller support
3. soc: aspeed: Add AST2600 peripheral channel port I/O support
4. soc: aspeed: Add eSPI TAFS backend support
5. soc: aspeed: Add espi flash channel support
6. soc: aspeed: Add sysfs controls for flash LUN selection
7. arm: dts: aspeed: Add eSPI node for AST2600

This series has been tested on AST2600 platform with Intel's host eSPI controller.

---
aspeedyh (7):
dt-bindings: soc: aspeed: Add AST2600 eSPI controller
soc: aspeed: Introduce core eSPI controller support
soc: aspeed: Add AST2600 peripheral channel port I/O support
soc: aspeed: Add eSPI TAFS backend support
soc: aspeed: Add eSPI flash channel support
soc: aspeed: Add sysfs controls for flash backend selection
arm: dts: aspeed: Add eSPI node for AST2600

 .../bindings/soc/aspeed/aspeed,ast2600-espi.yaml   |  74 +++
 arch/arm/boot/dts/aspeed/aspeed-g6.dtsi            |  11 +
 drivers/soc/aspeed/Kconfig                         |   7 +
 drivers/soc/aspeed/Makefile                        |   1 +
 drivers/soc/aspeed/espi/Makefile                   |   1 +
 drivers/soc/aspeed/espi/aspeed-espi-comm.h         |  62 +++
 drivers/soc/aspeed/espi/aspeed-espi.c              | 618 +++++++++++++++++++++
 drivers/soc/aspeed/espi/aspeed-espi.h              |  63 +++
 drivers/soc/aspeed/espi/ast2600-espi.c             | 304 ++++++++++
 drivers/soc/aspeed/espi/ast2600-espi.h             | 302 ++++++++++
 drivers/soc/aspeed/espi/espi_storage.c             | 322 +++++++++++
 drivers/soc/aspeed/espi/espi_storage.h             |  32 ++
 12 files changed, 1797 insertions(+)

---
base-commit: 0257f64bdac7fdca30fa3cae0df8b9ecbec7733a
change-id: 20260313-upstream_espi-d9fea66d1772

Best regards,

Signature · 1 line
aspeedyh <[email protected]>
author
#1 lore raw

PATCH 1/7 dt-bindings: soc: aspeed: Add AST2600 eSPI controller

Introduce the device-tree bindings for the Enhanced Serial Peripheral Interface (eSPI) controller found on AST2600 BMC SoCs.

The controller operates as the BMC-side eSPI slave and provides the peripheral, virtual wire, out-of-band, and flash channels used for host-BMC communication.

---
 .../bindings/soc/aspeed/aspeed,ast2600-espi.yaml   | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
Documentation/devicetree/bindings/soc/aspeed/aspeed,ast2600-espi.yaml new file +74 -0
new file mode 100644
index 000000000000..e22a10111138
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (c) 2026 Aspeed Technology Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/aspeed/aspeed,ast2600-espi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED AST2600 eSPI Controller
+
+maintainers:
+  - Yun-Hsuan Chung <[email protected]>
+  - Ryan Chen <[email protected]>
+
+description: |
+  The ASPEED AST2600 BMC SoC provides an Enhanced Serial Peripheral
+  Interface (eSPI) controller used for host-BMC communication.
+
+  The controller supports the eSPI channels used for peripheral,
+  virtual wire, out-of-band, and flash communication.
+
+properties:
+  compatible:
+    const: aspeed,ast2600-espi
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+    description:
+      Interrupt from the GIC for the eSPI controller.
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  pinctrl-names:
+    const: default
+
+  pinctrl-0:
+    maxItems: 1
+
+  aspeed,flash-dma-mode:
+    type: boolean
+    description:
+      Enable DMA support for eSPI flash channel
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - resets
+  - pinctrl-names
+  - pinctrl-0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/aspeed-clock.h>
+    espi: espi@1e6ee000 {
+        compatible = "aspeed,ast2600-espi";
+        reg = <0x1e6ee000 0x1000>;
+        interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&syscon ASPEED_CLK_GATE_ESPICLK>;
+        resets = <&syscon 57>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_espi_default>;
+        aspeed,flash-dma-mode;
+    };
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/7] dt-bindings: soc: aspeed: Add AST2600 eSPI controller

Quoted 9 lines · aspeedyh

Introduce the device-tree bindings for the Enhanced Serial Peripheral Interface (eSPI) controller found on AST2600 BMC SoCs.

The controller operates as the BMC-side eSPI slave and provides the peripheral, virtual wire, out-of-band, and flash channels used for host-BMC communication.

Please use your full name. Semi-anonymous contributions are not accepted.

Best regards,
Krzysztof

author
#3 lore raw

RE: [PATCH 1/7] dt-bindings: soc: aspeed: Add AST2600 eSPI controller

Hi Krzysztof,

Quoted 9 lines · aspeedyh
Quoted 8 lines

Introduce the device-tree bindings for the Enhanced Serial Peripheral Interface (eSPI) controller found on AST2600 BMC SoCs.

The controller operates as the BMC-side eSPI slave and provides the peripheral, virtual wire, out-of-band, and flash channels used for host-BMC communication.

Quoted 6 lines
Quoted 1 line

Please use your full name. Semi-anonymous contributions are not accepted.

Best regards,
Krzysztof

Thanks for the reminder.
Would you prefer that I resend this series with the corrected sign-off, or would it be fine to update it in the next version?

Thanks,
YunHsuan

#4 lore raw

Re: [PATCH 1/7] dt-bindings: soc: aspeed: Add AST2600 eSPI controller

Quoted 13 lines · YH Chung

Hi Krzysztof,

Quoted 11 lines · aspeedyh
Quoted 9 lines

Introduce the device-tree bindings for the Enhanced Serial Peripheral Interface (eSPI) controller found on AST2600 BMC SoCs.

The controller operates as the BMC-side eSPI slave and provides the peripheral, virtual wire, out-of-band, and flash channels used for host-BMC communication.

Quoted 7 lines
Quoted 4 lines

Please use your full name. Semi-anonymous contributions are not accepted.

Best regards,
Krzysztof

Thanks for the reminder.
Would you prefer that I resend this series with the corrected sign-off, or would it be fine to update it in the next version?

Next version, when the discussion on the cover letter concludes, please.

author
#5 lore raw

RE: [PATCH 1/7] dt-bindings: soc: aspeed: Add AST2600 eSPI controller

Hi Conor,

Quoted 17 lines · YH Chung
Quoted 15 lines

Hi Krzysztof,

Quoted 13 lines · aspeedyh
Quoted 9 lines

Introduce the device-tree bindings for the Enhanced Serial Peripheral Interface (eSPI) controller found on AST2600 BMC SoCs.

The controller operates as the BMC-side eSPI slave and provides the peripheral, virtual wire, out-of-band, and flash channels used for host-BMC communication.

Please use your full name. Semi-anonymous contributions are not accepted.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Best regards,
Krzysztof

Thanks for the reminder.
Would you prefer that I resend this series with the corrected sign-off, or would it

be fine to update it in the next version?

Next version, when the discussion on the cover letter concludes, please.

Got it, thanks for the guidance.

Thanks,
Yun Hsuan

author
#6 lore raw

PATCH 2/7 soc: aspeed: Introduce core eSPI controller support

In reply to aspeedyh

Add core eSPI controller support and common code for ASPEED SoCs. The eSPI engine is a slave device in BMC to communicate with the Host over the eSPI interface.

The initial support includes basic eSPI driver probe/remove operations, and provides operators for ASPEED SoCs to implement their own eSPI slave device drivers that are different among SoC models.

---
 drivers/soc/aspeed/Kconfig            |   7 ++
 drivers/soc/aspeed/Makefile           |   1 +
 drivers/soc/aspeed/espi/Makefile      |   1 +
 drivers/soc/aspeed/espi/aspeed-espi.c | 143 ++++++++++++++++++++++++++++++++++
 drivers/soc/aspeed/espi/aspeed-espi.h |  27 +++++++
 5 files changed, 179 insertions(+)
drivers/soc/aspeed/Kconfig +7 -0
index f579ee0b5afa..677812fab11a 100644
@@ -52,6 +52,13 @@ config ASPEED_SOCINFO
 	help
 	  Say yes to support decoding of ASPEED BMC information.
 
+config ASPEED_ESPI
+	tristate "ASPEED eSPI slave driver"
+	help
+	  Enable driver support for Aspeed eSPI controller. The eSPI controller
+	  plays as a slave device in BMC to communicate with the Host over the
+	  eSPI interface using peripheral, virtual wire, out of band, and flash
+	  channels.
 endmenu
 
 endif
drivers/soc/aspeed/Makefile +1 -0
index b35d74592964..79d794de428a 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)		+= aspeed-lpc-snoop.o
 obj-$(CONFIG_ASPEED_UART_ROUTING)	+= aspeed-uart-routing.o
 obj-$(CONFIG_ASPEED_P2A_CTRL)		+= aspeed-p2a-ctrl.o
 obj-$(CONFIG_ASPEED_SOCINFO)		+= aspeed-socinfo.o
+obj-$(CONFIG_ASPEED_ESPI)		+= espi/
drivers/soc/aspeed/espi/Makefile new file +1 -0
new file mode 100644
index 000000000000..d96dc030e23b
@@ -0,0 +1 @@
+obj-y += aspeed-espi.o
drivers/soc/aspeed/espi/aspeed-espi.c new file +143 -0

143 lines not on this page · raw message

drivers/soc/aspeed/espi/aspeed-espi.h new file +27 -0
new file mode 100644
index 000000000000..f4ad7f61fef6
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Unified eSPI driver header file and data structures
+ * Copyright 2026 Aspeed Technology Inc.
+ */
+#ifndef ASPEED_ESPI_H
+#define ASPEED_ESPI_H
+
+#include <linux/irqreturn.h>
+#include <linux/miscdevice.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#define DEVICE_NAME		"aspeed-espi"
+
+struct aspeed_espi {
+	struct platform_device *pdev;
+	struct device *dev;
+	void __iomem *regs;
+	struct reset_control *rst;
+	struct clk *clk;
+	int dev_id;
+	int irq;
+	const struct aspeed_espi_ops *ops;
+};
+
+#endif
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH 2/7] soc: aspeed: Introduce core eSPI controller support

Quoted 17 lines · aspeedyh

Add core eSPI controller support and common code for ASPEED SoCs. The eSPI engine is a slave device in BMC to communicate with the Host over the eSPI interface.

The initial support includes basic eSPI driver probe/remove operations, and provides operators for ASPEED SoCs to implement their own eSPI slave device drivers that are different among SoC models.

---
 drivers/soc/aspeed/Kconfig            |   7 ++
 drivers/soc/aspeed/Makefile           |   1 +
 drivers/soc/aspeed/espi/Makefile      |   1 +
 drivers/soc/aspeed/espi/aspeed-espi.c | 143 ++++++++++++++++++++++++++++++++++
 drivers/soc/aspeed/espi/aspeed-espi.h |  27 +++++++
 5 files changed, 179 insertions(+)

[...]

Quoted 47 lines
drivers/soc/aspeed/espi/aspeed-espi.c new file +41 -0
new file mode 100644
index 000000000000..15d58b38bbe4
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Unified Aspeed eSPI driver framework for different generation SoCs
+ */
+
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/reset.h>
+
+#include "aspeed-espi.h"
+
+struct aspeed_espi_ops {
+	void (*espi_pre_init)(struct aspeed_espi *espi);
+	void (*espi_post_init)(struct aspeed_espi *espi);
+	void (*espi_deinit)(struct aspeed_espi *espi);
+	irqreturn_t (*espi_isr)(int irq, void *espi);
+};
+
+static const struct of_device_id aspeed_espi_of_matches[] = {
+	{ }
+};
+MODULE_DEVICE_TABLE(of, aspeed_espi_of_matches);
+
+static int aspeed_espi_probe(struct platform_device *pdev)
+{
+	const struct of_device_id *match;
+	struct aspeed_espi *espi;
+	struct resource *res;
+	struct device *dev;
+	int rc;
+
+	dev = &pdev->dev;
+	espi = devm_kzalloc(dev, sizeof(*espi), GFP_KERNEL);
+	if (!espi)
+		return -ENOMEM;
+

[...]

drivers/soc/aspeed/espi/aspeed-espi.c line 70

Quoted 8 lines
drivers/soc/aspeed/espi/aspeed-espi.c new file +8 -0
+
+	espi->irq = platform_get_irq(pdev, 0);
+	if (espi->irq < 0) {
+		dev_err(dev, "cannot get IRQ number\n");
+		return espi->irq;
+	}
+
+	espi->rst = devm_reset_control_get_optional(dev, NULL);

Please use devm_reset_control_get_optional_exclusive() directly.

drivers/soc/aspeed/espi/aspeed-espi.c line 73

Quoted 3 lines
drivers/soc/aspeed/espi/aspeed-espi.c new file +3 -0
+	if (IS_ERR(espi->rst)) {
+		dev_err(dev, "cannot get reset control\n");
+		return PTR_ERR(espi->rst);

Consider using dev_err_probe, same for the other errors. That way the driver won't print incorrect error messages on -EPROBE_DEFER.

[...]

Quoted 14 lines
drivers/soc/aspeed/espi/aspeed-espi.h new file +8 -0
new file mode 100644
index 000000000000..f4ad7f61fef6
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Unified eSPI driver header file and data structures
+ * Copyright 2026 Aspeed Technology Inc.
+ */
+#ifndef ASPEED_ESPI_H
+#define ASPEED_ESPI_H
+

drivers/soc/aspeed/espi/aspeed-espi.h line 18

Quoted 10 lines
drivers/soc/aspeed/espi/aspeed-espi.h new file +10 -0
+#include <linux/irqreturn.h>
+#include <linux/miscdevice.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#define DEVICE_NAME		"aspeed-espi"
+
+struct aspeed_espi {
+	struct platform_device *pdev;
+	struct device *dev;

Storing both pdev and &pdev->dev seems unnecessary. Is pdev used at all?

drivers/soc/aspeed/espi/aspeed-espi.h line 20

Quoted 2 lines
drivers/soc/aspeed/espi/aspeed-espi.h new file +2 -0
+	void __iomem *regs;
+	struct reset_control *rst;

This is missing a forward declaration for struct reset_control.

regards
Philipp

author
#8 lore raw

RE: [PATCH 2/7] soc: aspeed: Introduce core eSPI controller support

Hi Philipp,

Thanks for the review.

Quoted 69 lines · aspeedyh
Quoted 8 lines

Add core eSPI controller support and common code for ASPEED SoCs. The eSPI engine is a slave device in BMC to communicate with the Host over the eSPI interface.

The initial support includes basic eSPI driver probe/remove operations, and provides operators for ASPEED SoCs to implement their own eSPI slave device drivers that are different among SoC models.

Quoted 6 lines
---
 drivers/soc/aspeed/Kconfig            |   7 ++
 drivers/soc/aspeed/Makefile           |   1 +
 drivers/soc/aspeed/espi/Makefile      |   1 +
 drivers/soc/aspeed/espi/aspeed-espi.c | 143

++++++++++++++++++++++++++++++++++

Quoted 3 lines
 drivers/soc/aspeed/espi/aspeed-espi.h |  27 +++++++
 5 files changed, 179 insertions(+)

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/soc/aspeed/espi/aspeed-espi.c

Quoted 46 lines

new file mode 100644
index 000000000000..15d58b38bbe4

drivers/soc/aspeed/espi/aspeed-espi.c new file +41 -0
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Unified Aspeed eSPI driver framework for different generation SoCs
+ */
+
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/reset.h>
+
+#include "aspeed-espi.h"
+
+struct aspeed_espi_ops {
+	void (*espi_pre_init)(struct aspeed_espi *espi);
+	void (*espi_post_init)(struct aspeed_espi *espi);
+	void (*espi_deinit)(struct aspeed_espi *espi);
+	irqreturn_t (*espi_isr)(int irq, void *espi);
+};
+
+static const struct of_device_id aspeed_espi_of_matches[] = {
+	{ }
+};
+MODULE_DEVICE_TABLE(of, aspeed_espi_of_matches);
+
+static int aspeed_espi_probe(struct platform_device *pdev)
+{
+	const struct of_device_id *match;
+	struct aspeed_espi *espi;
+	struct resource *res;
+	struct device *dev;
+	int rc;
+
+	dev = &pdev->dev;
+	espi = devm_kzalloc(dev, sizeof(*espi), GFP_KERNEL);
+	if (!espi)
+		return -ENOMEM;
+

[...]

Quoted 11 lines

drivers/soc/aspeed/espi/aspeed-espi.c line 70

Quoted 8 lines
drivers/soc/aspeed/espi/aspeed-espi.c new file +8 -0
+
+	espi->irq = platform_get_irq(pdev, 0);
+	if (espi->irq < 0) {
+		dev_err(dev, "cannot get IRQ number\n");
+		return espi->irq;
+	}
+
+	espi->rst = devm_reset_control_get_optional(dev, NULL);

Please use devm_reset_control_get_optional_exclusive() directly.

I will update this to use devm_reset_control_get_optional_exclusive()

Quoted 7 lines

drivers/soc/aspeed/espi/aspeed-espi.c line 73

Quoted 3 lines
drivers/soc/aspeed/espi/aspeed-espi.c new file +3 -0
+	if (IS_ERR(espi->rst)) {
+		dev_err(dev, "cannot get reset control\n");
+		return PTR_ERR(espi->rst);

Consider using dev_err_probe, same for the other errors. That way the driver won't print incorrect error messages on -EPROBE_DEFER.

I will switch these error paths to dev_err_probe() so that -EPROBE_DEFER can be handled correctly.

Quoted 22 lines

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/soc/aspeed/espi/aspeed-espi.h

Quoted 18 lines

new file mode 100644
index 000000000000..f4ad7f61fef6

drivers/soc/aspeed/espi/aspeed-espi.h new file +13 -0
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Unified eSPI driver header file and data structures
+ * Copyright 2026 Aspeed Technology Inc.
+ */
+#ifndef ASPEED_ESPI_H
+#define ASPEED_ESPI_H
+
+#include <linux/irqreturn.h>
+#include <linux/miscdevice.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
Quoted 9 lines

drivers/soc/aspeed/espi/aspeed-espi.h line 18

Quoted 5 lines
drivers/soc/aspeed/espi/aspeed-espi.h new file +5 -0
+#define DEVICE_NAME		"aspeed-espi"
+
+struct aspeed_espi {
+	struct platform_device *pdev;
+	struct device *dev;

Storing both pdev and &pdev->dev seems unnecessary. Is pdev used at all?

Agreed, pdev is not used in the subsequent patches. I will remove it in the next revision.

Quoted 5 lines

drivers/soc/aspeed/espi/aspeed-espi.h line 20

Quoted 2 lines
drivers/soc/aspeed/espi/aspeed-espi.h new file +2 -0
+	void __iomem *regs;
+	struct reset_control *rst;

This is missing a forward declaration for struct reset_control.

Will update to add <linux/reset.h> in the next revision to provide declaration for struct reset_control

Quoted 3 lines

regards
Philipp

Thanks,
Yun Hsuan.

author
#9 lore raw

PATCH 3/7 soc: aspeed: Add AST2600 peripheral channel port I/O support

In reply to aspeedyh

Add initial support for the AST2600 eSPI peripheral channel handling of port I/O transactions used for LPC-style accesses.

This patch does not yet implement peripheral memory read or write cycles. Support for those transactions will be added in a follow-up patch once the remaining transport and buffer handling pieces are in place.

---
 drivers/soc/aspeed/espi/Makefile       |   2 +-
 drivers/soc/aspeed/espi/aspeed-espi.c  |  24 +++
 drivers/soc/aspeed/espi/ast2600-espi.c | 139 ++++++++++++++++
 drivers/soc/aspeed/espi/ast2600-espi.h | 291 +++++++++++++++++++++++++++++++++
 4 files changed, 455 insertions(+), 1 deletion(-)
drivers/soc/aspeed/espi/Makefile +1 -1
index d96dc030e23b..30f9dbf92a0f 100644
@@ -1 +1 @@
-obj-y += aspeed-espi.o
+obj-y += aspeed-espi.o ast2600-espi.o
drivers/soc/aspeed/espi/aspeed-espi.c +24 -0
index 15d58b38bbe4..e369738119bc 100644
@@ -13,15 +13,28 @@
 #include <linux/reset.h>
 
 #include "aspeed-espi.h"
+#include "ast2600-espi.h"
 
 struct aspeed_espi_ops {
 	void (*espi_pre_init)(struct aspeed_espi *espi);
 	void (*espi_post_init)(struct aspeed_espi *espi);
 	void (*espi_deinit)(struct aspeed_espi *espi);
+	int (*espi_perif_probe)(struct aspeed_espi *espi);
+	int (*espi_perif_remove)(struct aspeed_espi *espi);
 	irqreturn_t (*espi_isr)(int irq, void *espi);
 };
 
+static const struct aspeed_espi_ops aspeed_espi_ast2600_ops = {
+	.espi_pre_init = ast2600_espi_pre_init,
+	.espi_post_init = ast2600_espi_post_init,
+	.espi_deinit = ast2600_espi_deinit,
+	.espi_perif_probe = ast2600_espi_perif_probe,
+	.espi_perif_remove = ast2600_espi_perif_remove,
+	.espi_isr = ast2600_espi_isr,
+};
+
 static const struct of_device_id aspeed_espi_of_matches[] = {
+	{ .compatible = "aspeed,ast2600-espi", .data = &aspeed_espi_ast2600_ops },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, aspeed_espi_of_matches);
@@ -88,6 +101,14 @@ static int aspeed_espi_probe(struct platform_device *pdev)
 	if (espi->ops->espi_pre_init)
 		espi->ops->espi_pre_init(espi);
 
+	if (espi->ops->espi_perif_probe) {
+		rc = espi->ops->espi_perif_probe(espi);
+		if (rc) {
+			dev_err(dev, "cannot init peripheral channel, rc=%d\n", rc);
+			goto err_deinit;
+		}
+	}
+
 	rc = devm_request_irq(dev, espi->irq, espi->ops->espi_isr, 0,
 			      dev_name(dev), espi);
 	if (rc) {
@@ -121,6 +142,9 @@ static void aspeed_espi_remove(struct platform_device *pdev)
 	if (!espi)
 		return;
 
+	if (espi->ops->espi_perif_remove)
+		espi->ops->espi_perif_remove(espi);
+
 	if (espi->ops->espi_deinit)
 		espi->ops->espi_deinit(espi);
 
drivers/soc/aspeed/espi/ast2600-espi.c new file +139 -0

139 lines not on this page · raw message

drivers/soc/aspeed/espi/ast2600-espi.h new file +291 -0

291 lines not on this page · raw message

Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH 3/7] soc: aspeed: Add AST2600 peripheral channel port I/O support

Quoted 29 lines · aspeedyh

Add initial support for the AST2600 eSPI peripheral channel handling of port I/O transactions used for LPC-style accesses.

This patch does not yet implement peripheral memory read or write cycles. Support for those transactions will be added in a follow-up patch once the remaining transport and buffer handling pieces are in place.

---
  drivers/soc/aspeed/espi/Makefile       |   2 +-
  drivers/soc/aspeed/espi/aspeed-espi.c  |  24 +++
  drivers/soc/aspeed/espi/ast2600-espi.c | 139 ++++++++++++++++
  drivers/soc/aspeed/espi/ast2600-espi.h | 291 +++++++++++++++++++++++++++++++++
  4 files changed, 455 insertions(+), 1 deletion(-)
drivers/soc/aspeed/espi/Makefile +1 -1
index d96dc030e23b..30f9dbf92a0f 100644
@@ -1 +1 @@
-obj-y += aspeed-espi.o
+obj-y += aspeed-espi.o ast2600-espi.o
drivers/soc/aspeed/espi/aspeed-espi.c +0 -0
index 15d58b38bbe4..e369738119bc 100644
@@ -13,15 +13,28 @@
  #include <linux/reset.h>

drivers/soc/aspeed/espi/aspeed-espi.c line 23

Quoted 10 lines
drivers/soc/aspeed/espi/aspeed-espi.c +3 -0
 
  #include "aspeed-espi.h"
+#include "ast2600-espi.h"
 
  struct aspeed_espi_ops {
  	void (*espi_pre_init)(struct aspeed_espi *espi);
  	void (*espi_post_init)(struct aspeed_espi *espi);
  	void (*espi_deinit)(struct aspeed_espi *espi);
+	int (*espi_perif_probe)(struct aspeed_espi *espi);
+	int (*espi_perif_remove)(struct aspeed_espi *espi);

Should it be int? I don't see any error condition returned

Quoted 485 lines
drivers/soc/aspeed/espi/aspeed-espi.c +21 -0
  	irqreturn_t (*espi_isr)(int irq, void *espi);
  };
 
+static const struct aspeed_espi_ops aspeed_espi_ast2600_ops = {
+	.espi_pre_init = ast2600_espi_pre_init,
+	.espi_post_init = ast2600_espi_post_init,
+	.espi_deinit = ast2600_espi_deinit,
+	.espi_perif_probe = ast2600_espi_perif_probe,
+	.espi_perif_remove = ast2600_espi_perif_remove,
+	.espi_isr = ast2600_espi_isr,
+};
+
  static const struct of_device_id aspeed_espi_of_matches[] = {
+	{ .compatible = "aspeed,ast2600-espi", .data = &aspeed_espi_ast2600_ops },
  	{ }
  };
  MODULE_DEVICE_TABLE(of, aspeed_espi_of_matches);
@@ -88,6 +101,14 @@ static int aspeed_espi_probe(struct platform_device *pdev)
  	if (espi->ops->espi_pre_init)
  		espi->ops->espi_pre_init(espi);
 
+	if (espi->ops->espi_perif_probe) {
+		rc = espi->ops->espi_perif_probe(espi);
+		if (rc) {
+			dev_err(dev, "cannot init peripheral channel, rc=%d\n", rc);
+			goto err_deinit;
+		}
+	}
+
  	rc = devm_request_irq(dev, espi->irq, espi->ops->espi_isr, 0,
  			      dev_name(dev), espi);
  	if (rc) {
@@ -121,6 +142,9 @@ static void aspeed_espi_remove(struct platform_device *pdev)
  	if (!espi)
  		return;
 
+	if (espi->ops->espi_perif_remove)
+		espi->ops->espi_perif_remove(espi);
+
  	if (espi->ops->espi_deinit)
  		espi->ops->espi_deinit(espi);
 
drivers/soc/aspeed/espi/ast2600-espi.c new file +139 -0
new file mode 100644
index 000000000000..8effd0404d1f
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright Aspeed Technology Inc.
+ */
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/reset.h>
+
+#include "aspeed-espi.h"
+#include "ast2600-espi.h"
+
+static void ast2600_espi_perif_isr(struct aspeed_espi *espi)
+{
+	u32 sts;
+
+	sts = readl(espi->regs + ESPI_INT_STS);
+
+	if (sts & ESPI_INT_STS_PERIF_PC_RX_CMPLT)
+		writel(ESPI_INT_STS_PERIF_PC_RX_CMPLT, espi->regs + ESPI_INT_STS);
+}
+
+static void ast2600_espi_perif_sw_reset(struct aspeed_espi *espi)
+{
+	u32 reg;
+
+	reg = readl(espi->regs + ESPI_CTRL);
+	reg &= ~(ESPI_CTRL_PERIF_NP_TX_SW_RST
+		 | ESPI_CTRL_PERIF_NP_RX_SW_RST
+		 | ESPI_CTRL_PERIF_PC_TX_SW_RST
+		 | ESPI_CTRL_PERIF_PC_RX_SW_RST
+		 | ESPI_CTRL_PERIF_NP_TX_DMA_EN
+		 | ESPI_CTRL_PERIF_PC_TX_DMA_EN
+		 | ESPI_CTRL_PERIF_PC_RX_DMA_EN
+		 | ESPI_CTRL_PERIF_SW_RDY);
+	writel(reg, espi->regs + ESPI_CTRL);
+
+	udelay(1);
+
+	reg |= (ESPI_CTRL_PERIF_NP_TX_SW_RST
+		| ESPI_CTRL_PERIF_NP_RX_SW_RST
+		| ESPI_CTRL_PERIF_PC_TX_SW_RST
+		| ESPI_CTRL_PERIF_PC_RX_SW_RST);
+	writel(reg, espi->regs + ESPI_CTRL);
+}
+
+static void ast2600_espi_perif_reset(struct aspeed_espi *espi)
+{
+	u32 reg;
+
+	writel(ESPI_INT_EN_PERIF, espi->regs + ESPI_INT_EN_CLR);
+	writel(ESPI_INT_STS_PERIF, espi->regs + ESPI_INT_STS);
+
+	writel(0x0, espi->regs + ESPI_MMBI_INT_EN);
+	writel(0xffffffff, espi->regs + ESPI_MMBI_INT_STS);
+
+	reg = readl(espi->regs + ESPI_CTRL2);
+	reg &= ~(ESPI_CTRL2_MCYC_RD_DIS_WDT | ESPI_CTRL2_MCYC_WR_DIS_WDT);
+	writel(reg, espi->regs + ESPI_CTRL2);
+
+	reg = readl(espi->regs + ESPI_CTRL);
+	reg &= ~(ESPI_CTRL_PERIF_NP_TX_DMA_EN
+		 | ESPI_CTRL_PERIF_PC_TX_DMA_EN
+		 | ESPI_CTRL_PERIF_PC_RX_DMA_EN
+		 | ESPI_CTRL_PERIF_SW_RDY);
+	writel(reg, espi->regs + ESPI_CTRL);
+
+	reg = readl(espi->regs + ESPI_CTRL) | ESPI_CTRL_PERIF_SW_RDY;
+	writel(reg, espi->regs + ESPI_CTRL);
+}
+
+int ast2600_espi_perif_probe(struct aspeed_espi *espi)
+{
+	ast2600_espi_perif_reset(espi);
+	return 0;
+}
+
+int ast2600_espi_perif_remove(struct aspeed_espi *espi)
+{
+	u32 reg;
+
+	writel(ESPI_INT_EN_PERIF, espi->regs + ESPI_INT_EN_CLR);
+
+	reg = readl(espi->regs + ESPI_CTRL2);
+	reg |= (ESPI_CTRL2_MCYC_RD_DIS | ESPI_CTRL2_MCYC_WR_DIS);
+	writel(reg, espi->regs + ESPI_CTRL2);
+
+	reg = readl(espi->regs + ESPI_CTRL);
+	reg &= ~(ESPI_CTRL_PERIF_NP_TX_DMA_EN
+		 | ESPI_CTRL_PERIF_PC_TX_DMA_EN
+		 | ESPI_CTRL_PERIF_PC_RX_DMA_EN
+		 | ESPI_CTRL_PERIF_SW_RDY);
+	writel(reg, espi->regs + ESPI_CTRL);
+	return 0;
+}
+
+/* global control */
+irqreturn_t ast2600_espi_isr(int irq, void *arg)
+{
+	struct aspeed_espi *espi;
+	u32 sts;
+
+	espi = (struct aspeed_espi *)arg;
+	sts = readl(espi->regs + ESPI_INT_STS);
+
+	if (!sts)
+		return IRQ_NONE;
+
+	if (sts & ESPI_INT_STS_PERIF)
+		ast2600_espi_perif_isr(espi);
+
+	if (sts & ESPI_INT_STS_RST_DEASSERT) {
+		/* this will clear all interrupt enable and status */
+		reset_control_assert(espi->rst);
+		reset_control_deassert(espi->rst);
+
+		ast2600_espi_perif_sw_reset(espi);
+		ast2600_espi_perif_reset(espi);
+
+		/* re-enable eSPI_RESET# interrupt */
+		writel(ESPI_INT_EN_RST_DEASSERT, espi->regs + ESPI_INT_EN);
+	}
+
+	return IRQ_HANDLED;
+}
+
+void ast2600_espi_pre_init(struct aspeed_espi *espi)
+{
+	writel(ESPI_INT_EN_RST_DEASSERT, espi->regs + ESPI_INT_EN_CLR);
+}
+
+void ast2600_espi_post_init(struct aspeed_espi *espi)
+{
+	writel(ESPI_INT_EN_RST_DEASSERT, espi->regs + ESPI_INT_EN);
+}
+
+void ast2600_espi_deinit(struct aspeed_espi *espi)
+{
+	writel(ESPI_INT_EN_RST_DEASSERT, espi->regs + ESPI_INT_EN_CLR);
+}
drivers/soc/aspeed/espi/ast2600-espi.h new file +291 -0
new file mode 100644
index 000000000000..309479ee1187
@@ -0,0 +1,291 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Register definitions for Aspeed AST2600 eSPI controller
+ * Copyright 2026 Aspeed Technology Inc.
+ */
+#ifndef AST2600_ESPI_H
+#define AST2600_ESPI_H
+
+#include <linux/bits.h>
+#include <linux/irqreturn.h>
+#include "aspeed-espi.h"
+
+/* registers */
+#define ESPI_CTRL				0x000
+#define   ESPI_CTRL_FLASH_TX_SW_RST		BIT(31)
+#define   ESPI_CTRL_FLASH_RX_SW_RST		BIT(30)
+#define   ESPI_CTRL_OOB_TX_SW_RST		BIT(29)
+#define   ESPI_CTRL_OOB_RX_SW_RST		BIT(28)
+#define   ESPI_CTRL_PERIF_NP_TX_SW_RST		BIT(27)
+#define   ESPI_CTRL_PERIF_NP_RX_SW_RST		BIT(26)
+#define   ESPI_CTRL_PERIF_PC_TX_SW_RST		BIT(25)
+#define   ESPI_CTRL_PERIF_PC_RX_SW_RST		BIT(24)
+#define   ESPI_CTRL_FLASH_TX_DMA_EN		BIT(23)
+#define   ESPI_CTRL_FLASH_RX_DMA_EN		BIT(22)
+#define   ESPI_CTRL_OOB_TX_DMA_EN		BIT(21)
+#define   ESPI_CTRL_OOB_RX_DMA_EN		BIT(20)
+#define   ESPI_CTRL_PERIF_NP_TX_DMA_EN		BIT(19)
+#define   ESPI_CTRL_PERIF_PC_TX_DMA_EN		BIT(17)
+#define   ESPI_CTRL_PERIF_PC_RX_DMA_EN		BIT(16)
+#define   ESPI_CTRL_FLASH_EDAF_MODE		GENMASK(11, 10)
+#define   ESPI_CTRL_VW_GPIO_SW			BIT(9)
+#define   ESPI_CTRL_FLASH_SW_RDY		BIT(7)
+#define   ESPI_CTRL_OOB_SW_RDY			BIT(4)
+#define   ESPI_CTRL_VW_SW_RDY			BIT(3)
+#define   ESPI_CTRL_PERIF_SW_RDY		BIT(1)
+#define ESPI_STS				0x004
+#define ESPI_INT_STS				0x008
+#define   ESPI_INT_STS_RST_DEASSERT		BIT(31)
+#define   ESPI_INT_STS_OOB_RX_TMOUT		BIT(23)
+#define   ESPI_INT_STS_VW_SYSEVT1		BIT(22)
+#define   ESPI_INT_STS_FLASH_TX_ERR		BIT(21)
+#define   ESPI_INT_STS_OOB_TX_ERR		BIT(20)
+#define   ESPI_INT_STS_FLASH_TX_ABT		BIT(19)
+#define   ESPI_INT_STS_OOB_TX_ABT		BIT(18)
+#define   ESPI_INT_STS_PERIF_NP_TX_ABT		BIT(17)
+#define   ESPI_INT_STS_PERIF_PC_TX_ABT		BIT(16)
+#define   ESPI_INT_STS_FLASH_RX_ABT		BIT(15)
+#define   ESPI_INT_STS_OOB_RX_ABT		BIT(14)
+#define   ESPI_INT_STS_PERIF_NP_RX_ABT		BIT(13)
+#define   ESPI_INT_STS_PERIF_PC_RX_ABT		BIT(12)
+#define   ESPI_INT_STS_PERIF_NP_TX_ERR		BIT(11)
+#define   ESPI_INT_STS_PERIF_PC_TX_ERR		BIT(10)
+#define   ESPI_INT_STS_VW_GPIO			BIT(9)
+#define   ESPI_INT_STS_VW_SYSEVT		BIT(8)
+#define   ESPI_INT_STS_FLASH_TX_CMPLT		BIT(7)
+#define   ESPI_INT_STS_FLASH_RX_CMPLT		BIT(6)
+#define   ESPI_INT_STS_OOB_TX_CMPLT		BIT(5)
+#define   ESPI_INT_STS_OOB_RX_CMPLT		BIT(4)
+#define   ESPI_INT_STS_PERIF_NP_TX_CMPLT	BIT(3)
+#define   ESPI_INT_STS_PERIF_PC_TX_CMPLT	BIT(1)
+#define   ESPI_INT_STS_PERIF_PC_RX_CMPLT	BIT(0)
+#define ESPI_INT_EN				0x00c
+#define   ESPI_INT_EN_RST_DEASSERT		BIT(31)
+#define   ESPI_INT_EN_OOB_RX_TMOUT		BIT(23)
+#define   ESPI_INT_EN_VW_SYSEVT1		BIT(22)
+#define   ESPI_INT_EN_FLASH_TX_ERR		BIT(21)
+#define   ESPI_INT_EN_OOB_TX_ERR		BIT(20)
+#define   ESPI_INT_EN_FLASH_TX_ABT		BIT(19)
+#define   ESPI_INT_EN_OOB_TX_ABT		BIT(18)
+#define   ESPI_INT_EN_PERIF_NP_TX_ABT		BIT(17)
+#define   ESPI_INT_EN_PERIF_PC_TX_ABT		BIT(16)
+#define   ESPI_INT_EN_FLASH_RX_ABT		BIT(15)
+#define   ESPI_INT_EN_OOB_RX_ABT		BIT(14)
+#define   ESPI_INT_EN_PERIF_NP_RX_ABT		BIT(13)
+#define   ESPI_INT_EN_PERIF_PC_RX_ABT		BIT(12)
+#define   ESPI_INT_EN_PERIF_NP_TX_ERR		BIT(11)
+#define   ESPI_INT_EN_PERIF_PC_TX_ERR		BIT(10)
+#define   ESPI_INT_EN_VW_GPIO			BIT(9)
+#define   ESPI_INT_EN_VW_SYSEVT			BIT(8)
+#define   ESPI_INT_EN_FLASH_TX_CMPLT		BIT(7)
+#define   ESPI_INT_EN_FLASH_RX_CMPLT		BIT(6)
+#define   ESPI_INT_EN_OOB_TX_CMPLT		BIT(5)
+#define   ESPI_INT_EN_OOB_RX_CMPLT		BIT(4)
+#define   ESPI_INT_EN_PERIF_NP_TX_CMPLT		BIT(3)
+#define   ESPI_INT_EN_PERIF_PC_TX_CMPLT		BIT(1)
+#define   ESPI_INT_EN_PERIF_PC_RX_CMPLT		BIT(0)
+#define ESPI_PERIF_PC_RX_DMA			0x010
+#define ESPI_PERIF_PC_RX_CTRL			0x014
+#define   ESPI_PERIF_PC_RX_CTRL_SERV_PEND	BIT(31)
+#define   ESPI_PERIF_PC_RX_CTRL_LEN		GENMASK(23, 12)
+#define   ESPI_PERIF_PC_RX_CTRL_TAG		GENMASK(11, 8)
+#define   ESPI_PERIF_PC_RX_CTRL_CYC		GENMASK(7, 0)
+#define ESPI_PERIF_PC_RX_DATA			0x018
+#define ESPI_PERIF_PC_TX_DMA			0x020
+#define ESPI_PERIF_PC_TX_CTRL			0x024
+#define	  ESPI_PERIF_PC_TX_CTRL_TRIG_PEND	BIT(31)
+#define	  ESPI_PERIF_PC_TX_CTRL_LEN		GENMASK(23, 12)
+#define	  ESPI_PERIF_PC_TX_CTRL_TAG		GENMASK(11, 8)
+#define	  ESPI_PERIF_PC_TX_CTRL_CYC		GENMASK(7, 0)
+#define ESPI_PERIF_PC_TX_DATA			0x028
+#define ESPI_PERIF_NP_TX_DMA			0x030
+#define ESPI_PERIF_NP_TX_CTRL			0x034
+#define   ESPI_PERIF_NP_TX_CTRL_TRIG_PEND	BIT(31)
+#define	  ESPI_PERIF_NP_TX_CTRL_LEN		GENMASK(23, 12)
+#define	  ESPI_PERIF_NP_TX_CTRL_TAG		GENMASK(11, 8)
+#define	  ESPI_PERIF_NP_TX_CTRL_CYC		GENMASK(7, 0)
+#define ESPI_PERIF_NP_TX_DATA			0x038
+#define ESPI_OOB_RX_DMA				0x040
+#define ESPI_OOB_RX_CTRL			0x044
+#define	  ESPI_OOB_RX_CTRL_SERV_PEND		BIT(31)
+#define	  ESPI_OOB_RX_CTRL_LEN			GENMASK(23, 12)
+#define	  ESPI_OOB_RX_CTRL_TAG			GENMASK(11, 8)
+#define	  ESPI_OOB_RX_CTRL_CYC			GENMASK(7, 0)
+#define ESPI_OOB_RX_DATA			0x048
+#define ESPI_OOB_TX_DMA				0x050
+#define ESPI_OOB_TX_CTRL			0x054
+#define	  ESPI_OOB_TX_CTRL_TRIG_PEND		BIT(31)
+#define	  ESPI_OOB_TX_CTRL_LEN			GENMASK(23, 12)
+#define	  ESPI_OOB_TX_CTRL_TAG			GENMASK(11, 8)
+#define	  ESPI_OOB_TX_CTRL_CYC			GENMASK(7, 0)
+#define ESPI_OOB_TX_DATA			0x058
+#define ESPI_FLASH_RX_DMA			0x060
+#define ESPI_FLASH_RX_CTRL			0x064
+#define	  ESPI_FLASH_RX_CTRL_SERV_PEND		BIT(31)
+#define	  ESPI_FLASH_RX_CTRL_LEN		GENMASK(23, 12)
+#define	  ESPI_FLASH_RX_CTRL_TAG		GENMASK(11, 8)
+#define	  ESPI_FLASH_RX_CTRL_CYC		GENMASK(7, 0)
+#define ESPI_FLASH_RX_DATA			0x068
+#define ESPI_FLASH_TX_DMA			0x070
+#define ESPI_FLASH_TX_CTRL			0x074
+#define	  ESPI_FLASH_TX_CTRL_TRIG_PEND		BIT(31)
+#define	  ESPI_FLASH_TX_CTRL_LEN		GENMASK(23, 12)
+#define	  ESPI_FLASH_TX_CTRL_TAG		GENMASK(11, 8)
+#define	  ESPI_FLASH_TX_CTRL_CYC		GENMASK(7, 0)
+#define ESPI_FLASH_TX_DATA			0x078
+#define ESPI_CTRL2				0x080
+#define   ESPI_CTRL2_VW_TX_SORT			BIT(30)
+#define   ESPI_CTRL2_MCYC_RD_DIS_WDT		BIT(11)
+#define   ESPI_CTRL2_MCYC_WR_DIS_WDT		BIT(10)
+#define   ESPI_CTRL2_MCYC_RD_DIS		BIT(6)
+#define   ESPI_CTRL2_MMBI_RD_DIS		ESPI_CTRL2_MCYC_RD_DIS
+#define   ESPI_CTRL2_MCYC_WR_DIS		BIT(4)
+#define   ESPI_CTRL2_MMBI_WR_DIS		ESPI_CTRL2_MCYC_WR_DIS
+#define ESPI_PERIF_MCYC_SADDR			0x084
+#define ESPI_PERIF_MMBI_SADDR			ESPI_PERIF_MCYC_SADDR
+#define ESPI_PERIF_MCYC_TADDR			0x088
+#define ESPI_PERIF_MMBI_TADDR			ESPI_PERIF_MCYC_TADDR
+#define ESPI_PERIF_MCYC_MASK			0x08c
+#define ESPI_PERIF_MMBI_MASK			ESPI_PERIF_MCYC_MASK
+#define ESPI_FLASH_EDAF_TADDR			0x090
+#define   ESPI_FLASH_EDAF_TADDR_BASE		GENMASK(31, 24)
+#define   ESPI_FLASH_EDAF_TADDR_MASK		GENMASK(15, 8)
+#define ESPI_VW_SYSEVT_INT_EN			0x094
+#define ESPI_VW_SYSEVT				0x098
+#define   ESPI_VW_SYSEVT_HOST_RST_ACK		BIT(27)
+#define   ESPI_VW_SYSEVT_RST_CPU_INIT		BIT(26)
+#define   ESPI_VW_SYSEVT_SLV_BOOT_STS		BIT(23)
+#define   ESPI_VW_SYSEVT_NON_FATAL_ERR		BIT(22)
+#define   ESPI_VW_SYSEVT_FATAL_ERR		BIT(21)
+#define   ESPI_VW_SYSEVT_SLV_BOOT_DONE		BIT(20)
+#define   ESPI_VW_SYSEVT_OOB_RST_ACK		BIT(16)
+#define   ESPI_VW_SYSEVT_NMI_OUT		BIT(10)
+#define   ESPI_VW_SYSEVT_SMI_OUT		BIT(9)
+#define   ESPI_VW_SYSEVT_HOST_RST_WARN		BIT(8)
+#define   ESPI_VW_SYSEVT_OOB_RST_WARN		BIT(6)
+#define   ESPI_VW_SYSEVT_PLTRSTN		BIT(5)
+#define   ESPI_VW_SYSEVT_SUSPEND		BIT(4)
+#define   ESPI_VW_SYSEVT_S5_SLEEP		BIT(2)
+#define   ESPI_VW_SYSEVT_S4_SLEEP		BIT(1)
+#define   ESPI_VW_SYSEVT_S3_SLEEP		BIT(0)
+#define ESPI_VW_GPIO_VAL			0x09c
+#define ESPI_GEN_CAP_N_CONF			0x0a0
+#define ESPI_CH0_CAP_N_CONF			0x0a4
+#define ESPI_CH1_CAP_N_CONF			0x0a8
+#define ESPI_CH2_CAP_N_CONF			0x0ac
+#define ESPI_CH3_CAP_N_CONF			0x0b0
+#define ESPI_CH3_CAP_N_CONF2			0x0b4
+#define ESPI_VW_GPIO_DIR			0x0c0
+#define ESPI_VW_GPIO_GRP			0x0c4
+#define ESPI_INT_EN_CLR				0x0fc
+#define ESPI_VW_SYSEVT1_INT_EN			0x100
+#define ESPI_VW_SYSEVT1				0x104
+#define   ESPI_VW_SYSEVT1_SUSPEND_ACK		BIT(20)
+#define   ESPI_VW_SYSEVT1_SUSPEND_WARN		BIT(0)
+#define ESPI_VW_SYSEVT_INT_T0			0x110
+#define ESPI_VW_SYSEVT_INT_T1			0x114
+#define ESPI_VW_SYSEVT_INT_T2			0x118
+#define ESPI_VW_SYSEVT_INT_STS			0x11c
+#define ESPI_VW_SYSEVT1_INT_T0			0x120
+#define ESPI_VW_SYSEVT1_INT_T1			0x124
+#define ESPI_VW_SYSEVT1_INT_T2			0x128
+#define ESPI_VW_SYSEVT1_INT_STS			0x12c
+#define ESPI_OOB_RX_DESC_NUM			0x130
+#define ESPI_OOB_RX_DESC_RPTR			0x134
+#define	  ESPI_OOB_RX_DESC_RPTR_UPDATE		BIT(31)
+#define   ESPI_OOB_RX_DESC_RPTR_RP		GENMASK(11, 0)
+#define ESPI_OOB_RX_DESC_WPTR			0x138
+#define   ESPI_OOB_RX_DESC_WPTR_RECV_EN		BIT(31)
+#define   ESPI_OOB_RX_DESC_WPTR_SP		GENMASK(27, 16)
+#define   ESPI_OOB_RX_DESC_WPTR_WP		GENMASK(11, 0)
+#define ESPI_OOB_TX_DESC_NUM			0x140
+#define ESPI_OOB_TX_DESC_RPTR			0x144
+#define	  ESPI_OOB_TX_DESC_RPTR_UPDATE		BIT(31)
+#define ESPI_OOB_TX_DESC_WPTR			0x148
+#define	  ESPI_OOB_TX_DESC_WPTR_SEND_EN		BIT(31)
+#define ESPI_MMBI_CTRL				0x800
+#define   ESPI_MMBI_CTRL_INST_SZ		GENMASK(10, 8)
+#define   ESPI_MMBI_CTRL_TOTAL_SZ		GENMASK(6, 4)
+#define   ESPI_MMBI_CTRL_EN			BIT(0)
+#define ESPI_MMBI_INT_STS			0x808
+#define ESPI_MMBI_INT_EN			0x80c
+#define ESPI_MMBI_HOST_RWP(x)			(0x810 + ((x) << 3))
+
+/* collect ESPI_INT_EN bits for convenience */
+#define ESPI_INT_EN_PERIF			\
+	(ESPI_INT_EN_PERIF_NP_TX_ABT |		\
+	 ESPI_INT_EN_PERIF_PC_TX_ABT |		\
+	 ESPI_INT_EN_PERIF_NP_RX_ABT |		\
+	 ESPI_INT_EN_PERIF_PC_RX_ABT |		\
+	 ESPI_INT_EN_PERIF_NP_TX_ERR |		\
+	 ESPI_INT_EN_PERIF_PC_TX_ERR |		\
+	 ESPI_INT_EN_PERIF_NP_TX_CMPLT |	\
+	 ESPI_INT_EN_PERIF_PC_TX_CMPLT |	\
+	 ESPI_INT_EN_PERIF_PC_RX_CMPLT)
+
+#define ESPI_INT_EN_VW			\
+	(ESPI_INT_EN_VW_SYSEVT1 |	\
+	 ESPI_INT_EN_VW_GPIO    |	\
+	 ESPI_INT_EN_VW_SYSEVT)
+
+#define ESPI_INT_EN_OOB		\
+	(ESPI_INT_EN_OOB_RX_TMOUT |	\
+	 ESPI_INT_EN_OOB_TX_ERR |	\
+	 ESPI_INT_EN_OOB_TX_ABT |	\
+	 ESPI_INT_EN_OOB_RX_ABT |	\
+	 ESPI_INT_EN_OOB_TX_CMPLT |	\
+	 ESPI_INT_EN_OOB_RX_CMPLT)
+
+#define ESPI_INT_EN_FLASH		\
+	(ESPI_INT_EN_FLASH_TX_ERR |	\
+	 ESPI_INT_EN_FLASH_TX_ABT |	\
+	 ESPI_INT_EN_FLASH_RX_ABT |	\
+	 ESPI_INT_EN_FLASH_TX_CMPLT |	\
+	 ESPI_INT_EN_FLASH_RX_CMPLT)
+
+/* collect ESPI_INT_STS bits for convenience */
+#define ESPI_INT_STS_PERIF			\
+	(ESPI_INT_STS_PERIF_NP_TX_ABT |		\
+	 ESPI_INT_STS_PERIF_PC_TX_ABT |		\
+	 ESPI_INT_STS_PERIF_NP_RX_ABT |		\
+	 ESPI_INT_STS_PERIF_PC_RX_ABT |		\
+	 ESPI_INT_STS_PERIF_NP_TX_ERR |		\
+	 ESPI_INT_STS_PERIF_PC_TX_ERR |		\
+	 ESPI_INT_STS_PERIF_NP_TX_CMPLT |	\
+	 ESPI_INT_STS_PERIF_PC_TX_CMPLT |	\
+	 ESPI_INT_STS_PERIF_PC_RX_CMPLT)
+
+#define ESPI_INT_STS_VW			\
+	(ESPI_INT_STS_VW_SYSEVT1 |	\
+	 ESPI_INT_STS_VW_GPIO    |	\
+	 ESPI_INT_STS_VW_SYSEVT)
+
+#define ESPI_INT_STS_OOB		\
+	(ESPI_INT_STS_OOB_RX_TMOUT |	\
+	 ESPI_INT_STS_OOB_TX_ERR |	\
+	 ESPI_INT_STS_OOB_TX_ABT |	\
+	 ESPI_INT_STS_OOB_RX_ABT |	\
+	 ESPI_INT_STS_OOB_TX_CMPLT |	\
+	 ESPI_INT_STS_OOB_RX_CMPLT)
+
+#define ESPI_INT_STS_FLASH		\
+	(ESPI_INT_STS_FLASH_TX_ERR |	\
+	 ESPI_INT_STS_FLASH_TX_ABT |	\
+	 ESPI_INT_STS_FLASH_RX_ABT |	\
+	 ESPI_INT_STS_FLASH_TX_CMPLT |	\
+	 ESPI_INT_STS_FLASH_RX_CMPLT)
+
+/* function operators */
+void ast2600_espi_pre_init(struct aspeed_espi *espi);
+void ast2600_espi_post_init(struct aspeed_espi *espi);
+void ast2600_espi_deinit(struct aspeed_espi *espi);
+int ast2600_espi_perif_probe(struct aspeed_espi *espi);
+int ast2600_espi_perif_remove(struct aspeed_espi *espi);
+int ast2600_espi_vw_probe(struct aspeed_espi *espi);
+int ast2600_espi_vw_remove(struct aspeed_espi *espi);
+int ast2600_espi_oob_probe(struct aspeed_espi *espi);
+int ast2600_espi_oob_remove(struct aspeed_espi *espi);
+int ast2600_espi_flash_probe(struct aspeed_espi *espi);
+int ast2600_espi_flash_remove(struct aspeed_espi *espi);
+irqreturn_t ast2600_espi_isr(int irq, void *arg);
+#endif
author
#11 lore raw

PATCH 4/7 soc: aspeed: Add eSPI TAFS backend support

In reply to aspeedyh

eSPI Target Attached Flash Sharing (TAFS) refers to sharing the storage mounted on eSPI devices to host via eSPI Flash Channel.

Add support for TAFS storage handling by creating a storage read/write interface conceptually like Logical Unit Number (LUN) for driver to route storage requests to the specified TAFS backend.

---
 drivers/soc/aspeed/espi/espi_storage.c | 322 +++++++++++++++++++++++++++++++++
 drivers/soc/aspeed/espi/espi_storage.h |  32 ++++
 2 files changed, 354 insertions(+)
drivers/soc/aspeed/espi/espi_storage.c new file +322 -0
new file mode 100644
index 000000000000..71038e9bdd52
@@ -0,0 +1,322 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * eSPI TAFS back storage interface
+ */
+
+#include <linux/blkdev.h>
+#include <linux/errno.h>
+#include <linux/file.h>
+#include <linux/fs.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#include "espi_storage.h"
+
+/*
+ * aspeed_espi_lun: use an existing block device or file as backend storage for eSPI flash channel.
+ *
+ * Typical path:
+ *   host <-> eSPI bus <-> eSPI slave protocol
+ *        <-> aspeed_espi_lun_*() helpers
+ *        <-> backend block device (e.g., /dev/mmcblk0p3)
+ */
+
+int aspeed_espi_lun_open(struct aspeed_espi_lun *lun, const char *path,
+			 bool initially_ro, bool cdrom)
+{
+	unsigned int blksize, blkbits;
+	loff_t size, num_sectors;
+	struct inode *inode;
+	struct file *filp;
+	int ro;
+	int rc;
+
+	filp = NULL;
+	ro = initially_ro;
+
+	if (!lun || !path) {
+		pr_err("espi_lun_open: invalid args lun=%p path=%p\n", lun,
+		       path);
+		return -EINVAL;
+	}
+
+	pr_info("espi_lun_open: path=%s ro=%d cdrom=%d\n", path, ro, cdrom);
+
+	/* Try R/W first, fallback to R/O if failed */
+	if (!ro) {
+		filp = filp_open(path, O_RDWR | O_LARGEFILE, 0);
+		if (PTR_ERR(filp) == -EROFS || PTR_ERR(filp) == -EACCES) {
+			pr_err("espi_lun_open: open rw failed rc=%ld, back to ro\n",
+			       PTR_ERR(filp));
+			ro = 1;
+		}
+	}
+
+	if (ro) {
+		filp = filp_open(path, O_RDONLY | O_LARGEFILE, 0);
+		if (IS_ERR_OR_NULL(filp)) {
+			rc = filp ? PTR_ERR(filp) : -ENODEV;
+			pr_err("espi_lun_open: open ro failed rc=%d\n", rc);
+			return rc;
+		}
+		pr_info("espi_lun_open: open ro ok filp=%p\n", filp);
+	}
+
+	if (!(filp->f_mode & FMODE_WRITE))
+		ro = 1;
+
+	pr_info("espi_lun_open: filp=%p f_inode=%p f_mode=0x%x\n", filp,
+		filp ? filp->f_inode : NULL, filp ? filp->f_mode : 0);
+
+	inode = filp->f_mapping->host;
+
+	pr_info("espi_lun_open: inode=%p mode=0%o\n", inode,
+		inode ? inode->i_mode : 0);
+	if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) {
+		rc = -EINVAL;
+		goto out_put;
+	}
+
+	if (!(filp->f_mode & FMODE_CAN_READ)) {
+		rc = -EACCES;
+		goto out_put;
+	}
+	if (!(filp->f_mode & FMODE_CAN_WRITE))
+		ro = true;
+
+	size = i_size_read(inode);
+	if (size < 0) {
+		pr_info("unable to find file size: %s\n", path);
+		rc = (int)size;
+		goto out_put;
+	}
+
+	pr_info("espi_lun_open: size=%lld\n", size);
+
+	if (cdrom) {
+		blksize = 2048;
+		blkbits = 11;
+	} else if (S_ISBLK(inode->i_mode)) {
+		blksize = bdev_logical_block_size(I_BDEV(inode));
+		pr_info("espi_lun_open: blksize=%d\n", blksize);
+		blkbits = blksize_bits(blksize);
+		pr_info("espi_lun_open: bdev=%d\n", blkbits);
+	} else {
+		blksize = 512;
+		blkbits = 9;
+	}
+
+	pr_info("espi_lun_open: blksize=%u blkbits=%u\n", blksize, blkbits);
+	num_sectors = size >> blkbits;
+	if (num_sectors < 1) {
+		pr_info("file too small: %s\n", path);
+		rc = -ETOOSMALL;
+		goto out_put;
+	}
+
+	lun->blksize = blksize;
+	lun->blkbits = blkbits;
+	lun->ro = ro;
+	lun->filp = filp;
+	lun->file_length = size;
+	lun->num_sectors = num_sectors;
+
+	lun->cdrom = cdrom;
+
+	return 0;
+
+out_put:
+	fput(filp);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(aspeed_espi_lun_open);
+
+void aspeed_espi_lun_close(struct aspeed_espi_lun *lun)
+{
+	if (!lun)
+		return;
+
+	if (lun->filp) {
+		fput(lun->filp);
+		lun->filp = NULL;
+	}
+}
+EXPORT_SYMBOL_GPL(aspeed_espi_lun_close);
+
+int aspeed_espi_lun_rw(struct aspeed_espi_lun *lun, bool write, sector_t sector,
+		       unsigned int nsect, void *buf)
+{
+	ssize_t done;
+	loff_t pos;
+	size_t len;
+
+	if (!lun || !lun->filp || !buf)
+		return -EINVAL;
+
+	if (write && lun->ro)
+		return -EROFS;
+
+	if (sector >= lun->num_sectors || nsect > lun->num_sectors - sector)
+		return -EINVAL;
+
+	pos = (loff_t)sector << lun->blkbits;
+	len = (size_t)nsect << lun->blkbits;
+
+	if (write)
+		done = kernel_write(lun->filp, buf, len, &pos);
+	else
+		done = kernel_read(lun->filp, buf, len, &pos);
+
+	if (done != len)
+		return done < 0 ? (int)done : -EIO;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(aspeed_espi_lun_rw);
+
+int aspeed_espi_lun_read(struct aspeed_espi_lun *lun, sector_t sector,
+			 unsigned int nsect, void *buf)
+{
+	return aspeed_espi_lun_rw(lun, false, sector, nsect, buf);
+}
+EXPORT_SYMBOL_GPL(aspeed_espi_lun_read);
+
+int aspeed_espi_lun_write(struct aspeed_espi_lun *lun, sector_t sector,
+			  unsigned int nsect, void *buf)
+{
+	return aspeed_espi_lun_rw(lun, true, sector, nsect, buf);
+}
+EXPORT_SYMBOL_GPL(aspeed_espi_lun_write);
+
+/*
+ * Byte-granular R/W, for eSPI protocol handler use:
+ *  - addr/len are in bytes, allowing arbitrary unaligned access
+ *  - internally handles sector alignment and RMW
+ */
+int aspeed_espi_lun_rw_bytes(struct aspeed_espi_lun *lun, bool write, u32 addr,
+			     u32 len, u8 *buf)
+{
+	u32 blk_mask;
+	u32 blksize;
+	u8 *bounce;
+	u32 done;
+	int rc;
+
+	done = 0;
+	rc = 0;
+
+	if (!lun || !lun->filp || !buf)
+		return -EINVAL;
+
+	if (!len)
+		return 0;
+
+	if (write && lun->ro)
+		return -EROFS;
+
+	blksize = lun->blksize;
+	blk_mask = blksize - 1;
+
+	bounce = kmalloc(blksize, GFP_KERNEL);
+	if (!bounce)
+		return -ENOMEM;
+
+	while (done < len) {
+		u32 cur_addr = addr + done;
+		u32 off_in_blk = cur_addr & blk_mask;
+		sector_t sector = cur_addr >> lun->blkbits;
+		u32 bytes_this;
+		u8 *p = buf + done;
+
+		/* Process up to the end of this sector */
+		bytes_this = blksize - off_in_blk;
+		if (bytes_this > (len - done))
+			bytes_this = len - done;
+
+		if (!off_in_blk && bytes_this == blksize) {
+			/* Fully aligned sector, use sector API directly */
+			if (write)
+				rc = aspeed_espi_lun_write(lun, sector, 1, p);
+			else
+				rc = aspeed_espi_lun_read(lun, sector, 1, p);
+		} else {
+			/* partial sector: read one sector first, then overwrite/extract part */
+			rc = aspeed_espi_lun_read(lun, sector, 1, bounce);
+			if (rc)
+				break;
+
+			if (write) {
+				memcpy(bounce + off_in_blk, p, bytes_this);
+				rc = aspeed_espi_lun_write(lun, sector, 1,
+							   bounce);
+			} else {
+				memcpy(p, bounce + off_in_blk, bytes_this);
+			}
+		}
+
+		if (rc)
+			break;
+
+		done += bytes_this;
+	}
+
+	kfree(bounce);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(aspeed_espi_lun_rw_bytes);
+
+/*
+ * Erase: specify range in bytes, implemented as writing 0xFF pattern.
+ * For eSPI ERASE command use.
+ */
+int aspeed_espi_lun_erase_bytes(struct aspeed_espi_lun *lun, u32 addr, u32 len)
+{
+	u8 *pattern;
+	u32 chunk;
+	u32 done;
+	int rc;
+
+	done = 0;
+	rc = 0;
+
+	if (!lun || !lun->filp)
+		return -EINVAL;
+
+	if (!len)
+		return 0;
+
+	if (lun->ro)
+		return -EROFS;
+
+	chunk = lun->blksize;
+	if (chunk > len)
+		chunk = len;
+
+	pattern = kmalloc(chunk, GFP_KERNEL);
+	if (!pattern)
+		return -ENOMEM;
+
+	while (done < len) {
+		u32 this_len = len - done;
+
+		if (this_len > chunk)
+			this_len = chunk;
+
+		memset(pattern, 0xff, this_len);
+
+		rc = aspeed_espi_lun_rw_bytes(lun, true, addr + done, this_len,
+					      pattern);
+		if (rc)
+			break;
+
+		done += this_len;
+	}
+
+	kfree(pattern);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(aspeed_espi_lun_erase_bytes);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("ASPEED eSPI slave storage backend helpers");
+MODULE_AUTHOR("ASPEED");
drivers/soc/aspeed/espi/espi_storage.h new file +32 -0
new file mode 100644
index 000000000000..f0711328b03e
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef ASPEED_ESPI_STORAGE_H
+#define ASPEED_ESPI_STORAGE_H
+
+#include <linux/fs.h>
+#include <linux/types.h>
+
+struct aspeed_espi_lun {
+	struct file	*filp;
+	loff_t		 file_length;
+	loff_t		 num_sectors;
+	unsigned int	 blksize;
+	unsigned int	 blkbits;
+	bool		 ro;
+	bool		 cdrom;
+};
+
+int aspeed_espi_lun_open(struct aspeed_espi_lun *lun, const char *path,
+			 bool initially_ro, bool cdrom);
+void aspeed_espi_lun_close(struct aspeed_espi_lun *lun);
+int aspeed_espi_lun_rw(struct aspeed_espi_lun *lun, bool write,
+		       sector_t sector, unsigned int nsect, void *buf);
+int aspeed_espi_lun_read(struct aspeed_espi_lun *lun, sector_t sector,
+			 unsigned int nsect, void *buf);
+int aspeed_espi_lun_write(struct aspeed_espi_lun *lun, sector_t sector,
+			  unsigned int nsect, void *buf);
+int aspeed_espi_lun_rw_bytes(struct aspeed_espi_lun *lun, bool write,
+			     u32 addr, u32 len, u8 *buf);
+int aspeed_espi_lun_erase_bytes(struct aspeed_espi_lun *lun,
+				u32 addr, u32 len);
+
+#endif /* _ASPEED_ESPI_STORAGE_H_ */
Signature · 1 line
2.34.1
author
#12 lore raw

PATCH 5/7 soc: aspeed: Add eSPI flash channel support

In reply to aspeedyh

Add flash channel probe/remove and function operators for core to receive/send eSPI flash request packets. Flash channel packets are handled in core to address storage requests via the LUN-like interface.

Note eSPI Flash channel may start transaction prior than kernel boots due to host might accesses BIOS image in early stage. Busy checkings are added to avoid resetting the Flash channel during probe if transaction already begun.

---
 drivers/soc/aspeed/espi/Makefile           |   2 +-
 drivers/soc/aspeed/espi/aspeed-espi-comm.h |  62 ++++++++
 drivers/soc/aspeed/espi/aspeed-espi.c      | 239 ++++++++++++++++++++++++++++-
 drivers/soc/aspeed/espi/aspeed-espi.h      |  36 +++++
 drivers/soc/aspeed/espi/ast2600-espi.c     | 165 ++++++++++++++++++++
 drivers/soc/aspeed/espi/ast2600-espi.h     |  19 ++-
 6 files changed, 515 insertions(+), 8 deletions(-)
drivers/soc/aspeed/espi/Makefile +1 -1
index 30f9dbf92a0f..44f2adc4d358 100644
@@ -1 +1 @@
-obj-y += aspeed-espi.o ast2600-espi.o
+obj-y += aspeed-espi.o ast2600-espi.o espi_storage.o
drivers/soc/aspeed/espi/aspeed-espi-comm.h new file +62 -0

62 lines not on this page · raw message

drivers/soc/aspeed/espi/aspeed-espi.c +236 -3

296 lines not on this page · raw message

drivers/soc/aspeed/espi/aspeed-espi.h +36 -0
index f4ad7f61fef6..7598bc622b95 100644
@@ -9,9 +9,44 @@
 #include <linux/irqreturn.h>
 #include <linux/miscdevice.h>
 #include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/mutex.h>
 #include <linux/types.h>
+#include <linux/workqueue.h>
 
 #define DEVICE_NAME		"aspeed-espi"
+#define ASPEED_ESPI_LUN_PATH_MAX	256
+
+enum aspeed_tafs_mode {
+	TAFS_MODE_SW = 1,
+};
+
+struct aspeed_espi_lun;
+
+struct aspeed_espi_flash {
+	struct {
+		enum aspeed_tafs_mode mode;
+		phys_addr_t taddr;
+		resource_size_t size;
+	} tafs;
+
+	struct {
+		bool enable;
+		void *tx_virt;
+		dma_addr_t tx_addr;
+		void *rx_virt;
+		dma_addr_t rx_addr;
+	} dma;
+
+	struct mutex tx_mtx; /* protects tx virt/addr */
+
+	struct work_struct rx_work;
+
+	struct mutex lun_mtx; /* protects lun metadata r/w */
+	struct aspeed_espi_lun *lun;
+	char lun_path[ASPEED_ESPI_LUN_PATH_MAX];
+	bool lun_ro;
+};
 
 struct aspeed_espi {
 	struct platform_device *pdev;
@@ -21,6 +56,7 @@ struct aspeed_espi {
 	struct clk *clk;
 	int dev_id;
 	int irq;
+	struct aspeed_espi_flash flash;
 	const struct aspeed_espi_ops *ops;
 };
 
drivers/soc/aspeed/espi/ast2600-espi.c +165 -0

189 lines not on this page · raw message

drivers/soc/aspeed/espi/ast2600-espi.h +15 -4
index 309479ee1187..251999dba73f 100644
@@ -9,6 +9,7 @@
 #include <linux/bits.h>
 #include <linux/irqreturn.h>
 #include "aspeed-espi.h"
+#include "aspeed-espi-comm.h"
 
 /* registers */
 #define ESPI_CTRL				0x000
@@ -27,13 +28,15 @@
 #define   ESPI_CTRL_PERIF_NP_TX_DMA_EN		BIT(19)
 #define   ESPI_CTRL_PERIF_PC_TX_DMA_EN		BIT(17)
 #define   ESPI_CTRL_PERIF_PC_RX_DMA_EN		BIT(16)
-#define   ESPI_CTRL_FLASH_EDAF_MODE		GENMASK(11, 10)
+#define   ESPI_CTRL_FLASH_TAFS_MODE		GENMASK(11, 10)
 #define   ESPI_CTRL_VW_GPIO_SW			BIT(9)
 #define   ESPI_CTRL_FLASH_SW_RDY		BIT(7)
 #define   ESPI_CTRL_OOB_SW_RDY			BIT(4)
 #define   ESPI_CTRL_VW_SW_RDY			BIT(3)
 #define   ESPI_CTRL_PERIF_SW_RDY		BIT(1)
 #define ESPI_STS				0x004
+#define   ESPI_STS_FLASH_TX_BUSY		BIT(23)
+#define   ESPI_STS_FLASH_RX_BUSY		BIT(22)
 #define ESPI_INT_STS				0x008
 #define   ESPI_INT_STS_RST_DEASSERT		BIT(31)
 #define   ESPI_INT_STS_OOB_RX_TMOUT		BIT(23)
@@ -147,9 +150,9 @@
 #define ESPI_PERIF_MMBI_TADDR			ESPI_PERIF_MCYC_TADDR
 #define ESPI_PERIF_MCYC_MASK			0x08c
 #define ESPI_PERIF_MMBI_MASK			ESPI_PERIF_MCYC_MASK
-#define ESPI_FLASH_EDAF_TADDR			0x090
-#define   ESPI_FLASH_EDAF_TADDR_BASE		GENMASK(31, 24)
-#define   ESPI_FLASH_EDAF_TADDR_MASK		GENMASK(15, 8)
+#define ESPI_FLASH_TAFS_TADDR			0x090
+#define   ESPI_FLASH_TAFS_TADDR_BASE		GENMASK(31, 24)
+#define   ESPI_FLASH_TAFS_TADDR_MASK		GENMASK(15, 8)
 #define ESPI_VW_SYSEVT_INT_EN			0x094
 #define ESPI_VW_SYSEVT				0x098
 #define   ESPI_VW_SYSEVT_HOST_RST_ACK		BIT(27)
@@ -287,5 +290,13 @@ int ast2600_espi_oob_probe(struct aspeed_espi *espi);
 int ast2600_espi_oob_remove(struct aspeed_espi *espi);
 int ast2600_espi_flash_probe(struct aspeed_espi *espi);
 int ast2600_espi_flash_remove(struct aspeed_espi *espi);
+int ast2600_espi_flash_get_hdr(struct aspeed_espi *espi,
+			       struct espi_comm_hdr *hdr);
+int ast2600_espi_flash_get_pkt(struct aspeed_espi *espi, void *pkt_buf,
+			       size_t pkt_size);
+int ast2600_espi_flash_put_pkt(struct aspeed_espi *espi,
+			       struct espi_flash_cmplt hdr, void *pkt_buf,
+			       size_t pkt_size);
+void ast2600_espi_flash_clr_pkt(struct aspeed_espi *espi);
 irqreturn_t ast2600_espi_isr(int irq, void *arg);
 #endif
Signature · 1 line
2.34.1
#13 lore raw

Re: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support

kernel test robot noticed the following build warnings:

Hi aspeedyh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 0257f64bdac7fdca30fa3cae0df8b9ecbec7733a]

url:    https://github.com/intel-lab-lkp/linux/commits/aspeedyh/dt-bindings-soc-aspeed-Add-AST2600-eSPI-controller/20260315-101647
base:   0257f64bdac7fdca30fa3cae0df8b9ecbec7733a
patch link:    https://lore.kernel.org/r/20260313-upstream_espi-v1-5-9504428e1f43%40aspeedtech.com
patch subject: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20260320/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260320/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/soc/aspeed/espi/ast2600-espi.c: In function 'ast2600_espi_flash_reset':
drivers/soc/aspeed/espi/ast2600-espi.c:137:16: error: implicit declaration of function 'FIELD_PREP' [-Wimplicit-function-declaration]

     137 |         reg |= FIELD_PREP(ESPI_CTRL_FLASH_TAFS_MODE, flash->tafs.mode);
         |                ^~~~~~~~~~
   drivers/soc/aspeed/espi/ast2600-espi.c: In function 'ast2600_espi_flash_remove':
>> drivers/soc/aspeed/espi/ast2600-espi.c:172:35: warning: variable 'flash' set but not used [-Wunused-but-set-variable]
     172 |         struct aspeed_espi_flash *flash;
         |                                   ^~~~~
   drivers/soc/aspeed/espi/ast2600-espi.c: In function 'ast2600_espi_flash_get_hdr':
   drivers/soc/aspeed/espi/ast2600-espi.c:194:20: error: implicit declaration of function 'FIELD_GET' [-Wimplicit-function-declaration]
     194 |         hdr->cyc = FIELD_GET(ESPI_FLASH_RX_CTRL_CYC, reg);
         |                    ^~~~~~~~~

vim +/flash +172 drivers/soc/aspeed/espi/ast2600-espi.c

169
170 int ast2600_espi_flash_remove(struct aspeed_espi *espi)
171 {

 > 172		struct aspeed_espi_flash *flash;

173 u32 reg;
174
175 flash = &espi->flash;
176
177 writel(ESPI_INT_EN_FLASH, espi->regs + ESPI_INT_EN_CLR);
178
179 reg = readl(espi->regs + ESPI_CTRL);
180 reg &= ~(ESPI_CTRL_FLASH_TX_DMA_EN
181 | ESPI_CTRL_FLASH_RX_DMA_EN
182 | ESPI_CTRL_FLASH_SW_RDY);
183 writel(reg, espi->regs + ESPI_CTRL);
184
185 return 0;
186 }
187

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#14 lore raw

Re: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support

In reply to aspeedyh
kernel test robot noticed the following build errors:

Hi aspeedyh,

kernel test robot noticed the following build errors:

[auto build test ERROR on 0257f64bdac7fdca30fa3cae0df8b9ecbec7733a]

url:    https://github.com/intel-lab-lkp/linux/commits/aspeedyh/dt-bindings-soc-aspeed-Add-AST2600-eSPI-controller/20260315-101647
base:   0257f64bdac7fdca30fa3cae0df8b9ecbec7733a
patch link:    https://lore.kernel.org/r/20260313-upstream_espi-v1-5-9504428e1f43%40aspeedtech.com
patch subject: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20260320/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260320/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/soc/aspeed/espi/ast2600-espi.c: In function 'ast2600_espi_flash_reset':

>> drivers/soc/aspeed/espi/ast2600-espi.c:137:16: error: implicit declaration of function 'FIELD_PREP' [-Wimplicit-function-declaration]
     137 |         reg |= FIELD_PREP(ESPI_CTRL_FLASH_TAFS_MODE, flash->tafs.mode);
         |                ^~~~~~~~~~
   drivers/soc/aspeed/espi/ast2600-espi.c: In function 'ast2600_espi_flash_remove':
   drivers/soc/aspeed/espi/ast2600-espi.c:172:35: warning: variable 'flash' set but not used [-Wunused-but-set-variable]
     172 |         struct aspeed_espi_flash *flash;
         |                                   ^~~~~
   drivers/soc/aspeed/espi/ast2600-espi.c: In function 'ast2600_espi_flash_get_hdr':
>> drivers/soc/aspeed/espi/ast2600-espi.c:194:20: error: implicit declaration of function 'FIELD_GET' [-Wimplicit-function-declaration]
     194 |         hdr->cyc = FIELD_GET(ESPI_FLASH_RX_CTRL_CYC, reg);
         |                    ^~~~~~~~~

vim +/FIELD_PREP +137 drivers/soc/aspeed/espi/ast2600-espi.c

111
112 static void ast2600_espi_flash_reset(struct aspeed_espi *espi)
113 {
114 struct aspeed_espi_flash *flash;
115 u32 reg;
116
117 flash = &espi->flash;
118
119 writel(ESPI_INT_EN_FLASH, espi->regs + ESPI_INT_EN_CLR);
120 writel(ESPI_INT_STS_FLASH, espi->regs + ESPI_INT_STS);
121
122 reg = readl(espi->regs + ESPI_CTRL);
123 reg &= ~(ESPI_CTRL_FLASH_TX_SW_RST

   124			 | ESPI_CTRL_FLASH_RX_SW_RST
   125			 | ESPI_CTRL_FLASH_TX_DMA_EN
   126			 | ESPI_CTRL_FLASH_RX_DMA_EN
   127			 | ESPI_CTRL_FLASH_SW_RDY);
   128		writel(reg, espi->regs + ESPI_CTRL);
   129	
   130		udelay(1);
   131	
   132		reg |= (ESPI_CTRL_FLASH_TX_SW_RST | ESPI_CTRL_FLASH_RX_SW_RST);
   133		writel(reg, espi->regs + ESPI_CTRL);
   134	
   135		flash->tafs.mode = TAFS_MODE_SW;
   136		reg = readl(espi->regs + ESPI_CTRL) & ~ESPI_CTRL_FLASH_TAFS_MODE;
 > 137		reg |= FIELD_PREP(ESPI_CTRL_FLASH_TAFS_MODE, flash->tafs.mode);
   138		writel(reg, espi->regs + ESPI_CTRL);
   139	
   140		if (flash->dma.enable) {
   141			writel(flash->dma.tx_addr, espi->regs + ESPI_FLASH_TX_DMA);
   142			writel(flash->dma.rx_addr, espi->regs + ESPI_FLASH_RX_DMA);
   143	
   144			reg = readl(espi->regs + ESPI_CTRL)
   145			      | ESPI_CTRL_FLASH_TX_DMA_EN
   146			      | ESPI_CTRL_FLASH_RX_DMA_EN;
   147			writel(reg, espi->regs + ESPI_CTRL);
   148		}
   149	
   150		writel(ESPI_INT_EN_FLASH_RX_CMPLT, espi->regs + ESPI_INT_EN);
   151	
   152		reg = readl(espi->regs + ESPI_CTRL) | ESPI_CTRL_FLASH_SW_RDY;
   153		writel(reg, espi->regs + ESPI_CTRL);
   154	}
   155	
   156	int ast2600_espi_flash_probe(struct aspeed_espi *espi)
   157	{
   158		u32 regs;
   159	
   160		regs = readl(espi->regs + ESPI_STS);
   161		if (regs & (ESPI_STS_FLASH_TX_BUSY | ESPI_STS_FLASH_RX_BUSY)) {
   162			dev_warn(espi->dev, "eSPI flash channel is busy, deferring...\n");
   163			return -EPROBE_DEFER;
   164		}
   165	
   166		ast2600_espi_flash_reset(espi);
   167		return 0;
   168	}
   169	
   170	int ast2600_espi_flash_remove(struct aspeed_espi *espi)
   171	{
   172		struct aspeed_espi_flash *flash;
   173		u32 reg;
   174	
   175		flash = &espi->flash;
   176	
   177		writel(ESPI_INT_EN_FLASH, espi->regs + ESPI_INT_EN_CLR);
   178	
   179		reg = readl(espi->regs + ESPI_CTRL);
   180		reg &= ~(ESPI_CTRL_FLASH_TX_DMA_EN
   181			 | ESPI_CTRL_FLASH_RX_DMA_EN
   182			 | ESPI_CTRL_FLASH_SW_RDY);
   183		writel(reg, espi->regs + ESPI_CTRL);
   184	
   185		return 0;
   186	}
   187	
   188	int ast2600_espi_flash_get_hdr(struct aspeed_espi *espi,
   189				       struct espi_comm_hdr *hdr)
   190	{
   191		u32 reg, len;
   192	
   193		reg = readl(espi->regs + ESPI_FLASH_RX_CTRL);
 > 194		hdr->cyc = FIELD_GET(ESPI_FLASH_RX_CTRL_CYC, reg);

195 hdr->tag = FIELD_GET(ESPI_FLASH_RX_CTRL_TAG, reg);
196 len = FIELD_GET(ESPI_FLASH_RX_CTRL_LEN, reg);
197 hdr->len_h = (len >> 8) & 0xff;
198 hdr->len_l = len & 0xff;
199
200 return 0;
201 }
202

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#15 lore raw

Re: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support

In reply to aspeedyh
kernel test robot noticed the following build errors:

Hi aspeedyh,

kernel test robot noticed the following build errors:

[auto build test ERROR on 0257f64bdac7fdca30fa3cae0df8b9ecbec7733a]

url:    https://github.com/intel-lab-lkp/linux/commits/aspeedyh/dt-bindings-soc-aspeed-Add-AST2600-eSPI-controller/20260315-101647
base:   0257f64bdac7fdca30fa3cae0df8b9ecbec7733a
patch link:    https://lore.kernel.org/r/20260313-upstream_espi-v1-5-9504428e1f43%40aspeedtech.com
patch subject: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support
config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20260320/[email protected]/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260320/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/soc/aspeed/espi/ast2600-espi.c:137:9: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           reg |= FIELD_PREP(ESPI_CTRL_FLASH_TAFS_MODE, flash->tafs.mode);
                  ^
   drivers/soc/aspeed/espi/ast2600-espi.c:172:28: warning: variable 'flash' set but not used [-Wunused-but-set-variable]
           struct aspeed_espi_flash *flash;
                                     ^
>> drivers/soc/aspeed/espi/ast2600-espi.c:194:13: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           hdr->cyc = FIELD_GET(ESPI_FLASH_RX_CTRL_CYC, reg);
                      ^

drivers/soc/aspeed/espi/ast2600-espi.c:243:8: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
reg = FIELD_PREP(ESPI_FLASH_TX_CTRL_CYC, cyc) |
^
1 warning and 3 errors generated.

vim +/FIELD_PREP +137 drivers/soc/aspeed/espi/ast2600-espi.c

111
112 static void ast2600_espi_flash_reset(struct aspeed_espi *espi)
113 {
114 struct aspeed_espi_flash *flash;
115 u32 reg;
116
117 flash = &espi->flash;
118
119 writel(ESPI_INT_EN_FLASH, espi->regs + ESPI_INT_EN_CLR);
120 writel(ESPI_INT_STS_FLASH, espi->regs + ESPI_INT_STS);
121
122 reg = readl(espi->regs + ESPI_CTRL);
123 reg &= ~(ESPI_CTRL_FLASH_TX_SW_RST

   124			 | ESPI_CTRL_FLASH_RX_SW_RST
   125			 | ESPI_CTRL_FLASH_TX_DMA_EN
   126			 | ESPI_CTRL_FLASH_RX_DMA_EN
   127			 | ESPI_CTRL_FLASH_SW_RDY);
   128		writel(reg, espi->regs + ESPI_CTRL);
   129	
   130		udelay(1);
   131	
   132		reg |= (ESPI_CTRL_FLASH_TX_SW_RST | ESPI_CTRL_FLASH_RX_SW_RST);
   133		writel(reg, espi->regs + ESPI_CTRL);
   134	
   135		flash->tafs.mode = TAFS_MODE_SW;
   136		reg = readl(espi->regs + ESPI_CTRL) & ~ESPI_CTRL_FLASH_TAFS_MODE;
 > 137		reg |= FIELD_PREP(ESPI_CTRL_FLASH_TAFS_MODE, flash->tafs.mode);
   138		writel(reg, espi->regs + ESPI_CTRL);
   139	
   140		if (flash->dma.enable) {
   141			writel(flash->dma.tx_addr, espi->regs + ESPI_FLASH_TX_DMA);
   142			writel(flash->dma.rx_addr, espi->regs + ESPI_FLASH_RX_DMA);
   143	
   144			reg = readl(espi->regs + ESPI_CTRL)
   145			      | ESPI_CTRL_FLASH_TX_DMA_EN
   146			      | ESPI_CTRL_FLASH_RX_DMA_EN;
   147			writel(reg, espi->regs + ESPI_CTRL);
   148		}
   149	
   150		writel(ESPI_INT_EN_FLASH_RX_CMPLT, espi->regs + ESPI_INT_EN);
   151	
   152		reg = readl(espi->regs + ESPI_CTRL) | ESPI_CTRL_FLASH_SW_RDY;
   153		writel(reg, espi->regs + ESPI_CTRL);
   154	}
   155	
   156	int ast2600_espi_flash_probe(struct aspeed_espi *espi)
   157	{
   158		u32 regs;
   159	
   160		regs = readl(espi->regs + ESPI_STS);
   161		if (regs & (ESPI_STS_FLASH_TX_BUSY | ESPI_STS_FLASH_RX_BUSY)) {
   162			dev_warn(espi->dev, "eSPI flash channel is busy, deferring...\n");
   163			return -EPROBE_DEFER;
   164		}
   165	
   166		ast2600_espi_flash_reset(espi);
   167		return 0;
   168	}
   169	
   170	int ast2600_espi_flash_remove(struct aspeed_espi *espi)
   171	{
   172		struct aspeed_espi_flash *flash;
   173		u32 reg;
   174	
   175		flash = &espi->flash;
   176	
   177		writel(ESPI_INT_EN_FLASH, espi->regs + ESPI_INT_EN_CLR);
   178	
   179		reg = readl(espi->regs + ESPI_CTRL);
   180		reg &= ~(ESPI_CTRL_FLASH_TX_DMA_EN
   181			 | ESPI_CTRL_FLASH_RX_DMA_EN
   182			 | ESPI_CTRL_FLASH_SW_RDY);
   183		writel(reg, espi->regs + ESPI_CTRL);
   184	
   185		return 0;
   186	}
   187	
   188	int ast2600_espi_flash_get_hdr(struct aspeed_espi *espi,
   189				       struct espi_comm_hdr *hdr)
   190	{
   191		u32 reg, len;
   192	
   193		reg = readl(espi->regs + ESPI_FLASH_RX_CTRL);
 > 194		hdr->cyc = FIELD_GET(ESPI_FLASH_RX_CTRL_CYC, reg);

195 hdr->tag = FIELD_GET(ESPI_FLASH_RX_CTRL_TAG, reg);
196 len = FIELD_GET(ESPI_FLASH_RX_CTRL_LEN, reg);
197 hdr->len_h = (len >> 8) & 0xff;
198 hdr->len_l = len & 0xff;
199
200 return 0;
201 }
202

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#16 lore raw

Re: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support

In reply to aspeedyh

…

Quoted 2 lines

+++ b/drivers/soc/aspeed/espi/aspeed-espi-comm.h

(quoted diff) +0 -0
@@ -0,0 +1,62 @@

…

drivers/soc/aspeed/espi/aspeed-espi-comm.h line 21

Quoted 9 lines
drivers/soc/aspeed/espi/aspeed-espi-comm.h new file +9 -0
+/*
+ * eSPI cycle type encoding
+ *
+ * Section 5.1 Cycle Types and Packet Format,
+ * Intel eSPI Interface Base Specification, Rev 1.0, Jan. 2016.
+ */
+#define ESPI_FLASH_READ			0x00
+#define ESPI_FLASH_WRITE		0x01
+#define ESPI_FLASH_ERASE		0x02

…

How do you think about to use an enumeration for such data?
https://en.wikipedia.org/wiki/Enumerated_type#C_and_syntactically_similar_languages

Regards,
Markus

author
#17 lore raw

RE: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support

Hi Markus,

Quoted 14 lines
Quoted 2 lines

+++ b/drivers/soc/aspeed/espi/aspeed-espi-comm.h

(quoted diff) +0 -0
@@ -0,0 +1,62 @@

…

Quoted 9 lines
drivers/soc/aspeed/espi/aspeed-espi-comm.h new file +9 -0
+/*
+ * eSPI cycle type encoding
+ *
+ * Section 5.1 Cycle Types and Packet Format,
+ * Intel eSPI Interface Base Specification, Rev 1.0, Jan. 2016.
+ */
+#define ESPI_FLASH_READ			0x00
+#define ESPI_FLASH_WRITE		0x01
+#define ESPI_FLASH_ERASE		0x02

…

Quoted 3 lines

How do you think about to use an enumeration for such data?
https://en.wikipedia.org/wiki/Enumerated_type#C_and_syntactically_similar_lan
guages

Thanks for the feedback. Yes, these values are related cycle type encodings, so using an enum makes sense. I will update them, as well as other specification-defined encodings, to enums in the next revision, while still using fixed-width types such as u8 for the actual packet/register fields.

Thanks,
Yun-Hsuan

#18 lore raw

Re: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support

In reply to aspeedyh

…

Quoted 1 line

+++ b/drivers/soc/aspeed/espi/aspeed-espi.c

…

drivers/soc/aspeed/espi/aspeed-espi.c static const struct of_device_id aspeed_espi_of_matches[] = { · line 201

Quoted 9 lines
drivers/soc/aspeed/espi/aspeed-espi.c +9 -0
+static void aspeed_espi_flash_rx_work(struct work_struct *work)
+{
+	struct aspeed_espi_flash *flash = container_of(work, struct aspeed_espi_flash, rx_work);
+	struct aspeed_espi *espi = container_of(flash, struct aspeed_espi, flash);
+
+	mutex_lock(&flash->tx_mtx);
+	aspeed_espi_flash_handle_lun(espi);
+	mutex_unlock(&flash->tx_mtx);
+}

…

Under which circumstances would you become interested to apply a statement like “guard(mutex)(&flash->tx_mtx);”?
https://elixir.bootlin.com/linux/v7.1.1/source/include/linux/mutex.h#L253

Regards,
Markus

author
#19 lore raw

RE: [PATCH 5/7] soc: aspeed: Add eSPI flash channel support

Hi Markus,

Quoted 14 lines
Quoted 1 line

+++ b/drivers/soc/aspeed/espi/aspeed-espi.c

…

Review

Quoted 2 lines
(quoted diff) +2 -0
+static void aspeed_espi_flash_rx_work(struct work_struct *work) {
+	struct aspeed_espi_flash *flash = container_of(work, struct

aspeed_espi_flash, rx_work);

Quoted 7 lines
drivers/soc/aspeed/espi/aspeed-espi.c +7 -0
+	struct aspeed_espi *espi = container_of(flash, struct aspeed_espi,
+flash);
+
+	mutex_lock(&flash->tx_mtx);
+	aspeed_espi_flash_handle_lun(espi);
+	mutex_unlock(&flash->tx_mtx);
+}

…

Quoted 4 lines

Under which circumstances would you become interested to apply a statement like “guard(mutex)(&flash->tx_mtx);”?
https://elixir.bootlin.com/linux/v7.1.1/source/include/linux/mutex.h#L253

Thanks for the suggestion. I agree that guard(mutex) is helpful when a locked section has multiple exit paths. Since this worker currently has a single simple path, I would prefer to keep the explicit mutex_lock()/mutex_unlock() pair for readability. I can switch to guard(mutex) if you think it would be better in this case.

Thanks,
Yun Hsuan

#20 lore raw

Re: [5/7] soc: aspeed: Add eSPI flash channel support

…

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+++ b/drivers/soc/aspeed/espi/aspeed-espi.c

…

Quoted 1 line

+static void aspeed_espi_flash_rx_work(struct work_struct *work) {

…

Quoted 5 lines

Thanks for the suggestion. I agree that guard(mutex) is helpful when a locked section has multiple exit paths. Since this worker currently has a single simple path, I would prefer to keep the explicit mutex_lock()/mutex_unlock() pair for readability. I can switch to guard(mutex) if you think it would be better in this case.

I hope that development interests can increase more also for the application of scope-based resource management.

Regards,
Markus

author
#21 lore raw

RE: [5/7] soc: aspeed: Add eSPI flash channel support

Hi Markus,

Quoted 12 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+++ b/drivers/soc/aspeed/espi/aspeed-espi.c

…

Quoted 1 line

+static void aspeed_espi_flash_rx_work(struct work_struct *work) {

…

Quoted 5 lines

Thanks for the suggestion. I agree that guard(mutex) is helpful when a locked section has multiple exit paths. Since this worker currently has a single simple path, I would prefer to keep the explicit mutex_lock()/mutex_unlock() pair for readability. I can switch to guard(mutex) if you think it would be better in this case.

I hope that development interests can increase more also for the application of scope-based resource management.

Thanks for the clarification. I will switch this worker to use guard(mutex) so that the code follows the scope-based resource management style.

Best regards,
Yun Hsuan

author
#22 lore raw

PATCH 6/7 soc: aspeed: Add sysfs controls for flash backend selection

In reply to aspeedyh

add following attributes to select backend storage for eSPI TAFS LUN interface:
- flash_lun_path: specify path of backend storage for eSPI TAFS to share with host.
- flash_lun_readonly: set flash LUN to read-only or read-write mode to block host write operations.
- flash_lun_enable: open storage according to flash_lun_path as file for eSPI TAFS access.

Example usage:
- Select /dev/mtdblock8 as backend storage for eSPI TAFS LUN interface

  echo /dev/mtdblock8 > \
    /sys/bus/platform/devices/1e6ee000.espi/flash_lun_path

- Set LUN to read-only mode to block host write operations echo 1 > /sys/bus/platform/devices/1e6ee000.espi/flash_lun_readonly
- Enable flash LUN for eSPI TAFS access
echo 1 > /sys/bus/platform/devices/1e6ee000.espi/flash_lun_enable

---
 drivers/soc/aspeed/espi/aspeed-espi.c | 218 ++++++++++++++++++++++++++++++++++
 1 file changed, 218 insertions(+)
drivers/soc/aspeed/espi/aspeed-espi.c +218 -0
index 7d58c78ed397..2c8f9641174d 100644
@@ -12,12 +12,224 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
+#include <linux/kstrtox.h>
+#include <linux/slab.h>
+#include <linux/string.h>
 
 #include "aspeed-espi.h"
 #include "aspeed-espi-comm.h"
 #include "ast2600-espi.h"
 #include "espi_storage.h"
 
+static ssize_t flash_lun_path_show(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	struct aspeed_espi_flash *flash;
+	struct aspeed_espi *espi;
+	ssize_t rc;
+
+	espi = dev_get_drvdata(dev);
+
+	if (!espi)
+		return -ENODEV;
+
+	flash = &espi->flash;
+
+	mutex_lock(&flash->lun_mtx);
+	rc = scnprintf(buf, PAGE_SIZE, "%s\n", flash->lun_path);
+	mutex_unlock(&flash->lun_mtx);
+
+	return rc;
+}
+
+static ssize_t flash_lun_path_store(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	char tmp[ASPEED_ESPI_LUN_PATH_MAX];
+	struct aspeed_espi_flash *flash;
+	struct aspeed_espi *espi;
+	size_t len;
+
+	espi = dev_get_drvdata(dev);
+	if (!espi)
+		return -ENODEV;
+
+	flash = &espi->flash;
+
+	len = strnlen(buf, count);
+	if (len && buf[len - 1] == '\n')
+		len--;
+
+	if (len >= sizeof(tmp))
+		return -ENAMETOOLONG;
+
+	memcpy(tmp, buf, len);
+	tmp[len] = '\0';
+
+	mutex_lock(&flash->lun_mtx);
+	if (flash->lun && flash->lun->filp) {
+		mutex_unlock(&flash->lun_mtx);
+		return -EBUSY;
+	}
+
+	strscpy(flash->lun_path, tmp, sizeof(flash->lun_path));
+	dev_info(dev, "flash lun path set to %s\n", flash->lun_path);
+	mutex_unlock(&flash->lun_mtx);
+
+	return count;
+}
+
+static ssize_t flash_lun_readonly_show(struct device *dev,
+				       struct device_attribute *attr, char *buf)
+{
+	struct aspeed_espi_flash *flash;
+	struct aspeed_espi *espi;
+	ssize_t rc;
+
+	espi = dev_get_drvdata(dev);
+	if (!espi)
+		return -ENODEV;
+
+	flash = &espi->flash;
+
+	mutex_lock(&flash->lun_mtx);
+	rc = scnprintf(buf, PAGE_SIZE, "%u\n", flash->lun_ro);
+	mutex_unlock(&flash->lun_mtx);
+
+	return rc;
+}
+
+static ssize_t flash_lun_readonly_store(struct device *dev,
+					struct device_attribute *attr,
+					const char *buf, size_t count)
+{
+	struct aspeed_espi_flash *flash;
+	struct aspeed_espi *espi;
+	bool ro;
+	int rc;
+
+	espi = dev_get_drvdata(dev);
+	if (!espi)
+		return -ENODEV;
+
+	flash = &espi->flash;
+
+	rc = kstrtobool(buf, &ro);
+	if (rc)
+		return rc;
+
+	mutex_lock(&flash->lun_mtx);
+	if (flash->lun && flash->lun->filp) {
+		mutex_unlock(&flash->lun_mtx);
+		return -EBUSY;
+	}
+
+	flash->lun_ro = ro;
+	dev_info(dev, "flash lun readonly set to %u\n", flash->lun_ro);
+	mutex_unlock(&flash->lun_mtx);
+
+	return count;
+}
+
+static ssize_t flash_lun_enable_show(struct device *dev,
+				     struct device_attribute *attr, char *buf)
+{
+	struct aspeed_espi_flash *flash;
+	struct aspeed_espi *espi;
+	bool enabled;
+	ssize_t rc;
+
+	espi = dev_get_drvdata(dev);
+	if (!espi)
+		return -ENODEV;
+
+	flash = &espi->flash;
+
+	mutex_lock(&flash->lun_mtx);
+	enabled = flash->lun && flash->lun->filp;
+	mutex_unlock(&flash->lun_mtx);
+
+	rc = scnprintf(buf, PAGE_SIZE, "%u\n", enabled);
+	return rc;
+}
+
+static ssize_t flash_lun_enable_store(struct device *dev,
+				      struct device_attribute *attr,
+				      const char *buf, size_t count)
+{
+	struct aspeed_espi_flash *flash;
+	struct aspeed_espi *espi;
+	bool enable;
+	int rc = 0;
+
+	espi = dev_get_drvdata(dev);
+	if (!espi)
+		return -ENODEV;
+
+	flash = &espi->flash;
+
+	rc = kstrtobool(buf, &enable);
+	if (rc)
+		return rc;
+
+	mutex_lock(&flash->lun_mtx);
+	if (!flash->lun) {
+		flash->lun = devm_kzalloc(dev, sizeof(*flash->lun), GFP_KERNEL);
+		if (!flash->lun) {
+			rc = -ENOMEM;
+			goto out_unlock;
+		}
+	}
+
+	if (enable) {
+		if (flash->lun->filp)
+			goto out_unlock;
+		if (!flash->lun_path[0]) {
+			rc = -EINVAL;
+			goto out_unlock;
+		}
+
+		dev_info(dev, "flash lun enable: path=%s ro=%u\n",
+			 flash->lun_path, flash->lun_ro);
+		mutex_lock(&flash->tx_mtx);
+		rc = aspeed_espi_lun_open(flash->lun, flash->lun_path,
+					  flash->lun_ro, false);
+		mutex_unlock(&flash->tx_mtx);
+	} else {
+		if (!flash->lun->filp)
+			goto out_unlock;
+
+		dev_info(dev, "flash lun disable\n");
+		mutex_lock(&flash->tx_mtx);
+		aspeed_espi_lun_close(flash->lun);
+		mutex_unlock(&flash->tx_mtx);
+	}
+
+out_unlock:
+	mutex_unlock(&flash->lun_mtx);
+	if (rc) {
+		dev_err(dev, "flash lun enable=%u failed: %d\n", enable, rc);
+		return rc;
+	}
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(flash_lun_path);
+static DEVICE_ATTR_RW(flash_lun_readonly);
+static DEVICE_ATTR_RW(flash_lun_enable);
+
+static struct attribute *aspeed_espi_flash_attrs[] = {
+	&dev_attr_flash_lun_path.attr,
+	&dev_attr_flash_lun_readonly.attr,
+	&dev_attr_flash_lun_enable.attr,
+	NULL,
+};
+
+static const struct attribute_group aspeed_espi_flash_attr_group = {
+	.attrs = aspeed_espi_flash_attrs,
+};
 
 struct aspeed_espi_ops {
 	void (*espi_pre_init)(struct aspeed_espi *espi);
@@ -336,6 +548,12 @@ static int aspeed_espi_probe(struct platform_device *pdev)
 		goto err_remove_perif;
 	}
 
+	rc = devm_device_add_group(dev, &aspeed_espi_flash_attr_group);
+	if (rc) {
+		dev_err(dev, "cannot add flash LUN sysfs group, rc=%d\n", rc);
+		goto err_remove_flash;
+	}
+
 	rc = devm_request_irq(dev, espi->irq, espi->ops->espi_isr, 0,
 			      dev_name(dev), espi);
 	if (rc) {
Signature · 1 line
2.34.1
author
#23 lore raw

PATCH 7/7 arm: dts: aspeed: Add eSPI node for AST2600

In reply to aspeedyh

Add the AST2600 eSPI controller node with the register region, interrupt, clock, reset and pinctrl properties.

---
 arch/arm/boot/dts/aspeed/aspeed-g6.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/boot/dts/aspeed/aspeed-g6.dtsi +11 -0
index 189bc3bbb47c..84aec45f39e7 100644
@@ -408,6 +408,17 @@ adc1: adc@1e6e9100 {
 				status = "disabled";
 			};
 
+			espi: espi@1e6ee000 {
+				compatible = "aspeed,ast2600-espi";
+				reg = <0x1e6ee000 0x1000>;
+				interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&syscon ASPEED_CLK_GATE_ESPICLK>;
+				resets = <&syscon 57>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&pinctrl_espi_default>;
+				status = "disabled";
+			};
+
 			sbc: secure-boot-controller@1e6f2000 {
 				compatible = "aspeed,ast2600-sbc";
 				reg = <0x1e6f2000 0x1000>;
Signature · 1 line
2.34.1
#24 lore raw
In reply to aspeedyh
Quoted 10 lines · aspeedyh

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

The driver is intended to support host-BMC communication over the BMC-side eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI driver and bindings go in the spi subsystem? FSL's appears to be there. Mark?

Quoted 10 lines

Patch summary:
1. dt-bindings: soc: aspeed: Add AST2600 eSPI controller
2. soc: aspeed: Introduce core eSPI controller support
3. soc: aspeed: Add AST2600 peripheral channel port I/O support
4. soc: aspeed: Add eSPI TAFS backend support
5. soc: aspeed: Add espi flash channel support
6. soc: aspeed: Add sysfs controls for flash LUN selection
7. arm: dts: aspeed: Add eSPI node for AST2600

Quoted 4 lines

This series has been tested on AST2600 platform with Intel's host eSPI controller.

Unless you're an fanatical employee of Aspeed, I doubt that this signoff reflects your actual name!

Quoted 31 lines

---
aspeedyh (7):
dt-bindings: soc: aspeed: Add AST2600 eSPI controller
soc: aspeed: Introduce core eSPI controller support
soc: aspeed: Add AST2600 peripheral channel port I/O support
soc: aspeed: Add eSPI TAFS backend support
soc: aspeed: Add eSPI flash channel support
soc: aspeed: Add sysfs controls for flash backend selection
arm: dts: aspeed: Add eSPI node for AST2600

 .../bindings/soc/aspeed/aspeed,ast2600-espi.yaml   |  74 +++
 arch/arm/boot/dts/aspeed/aspeed-g6.dtsi            |  11 +
 drivers/soc/aspeed/Kconfig                         |   7 +
 drivers/soc/aspeed/Makefile                        |   1 +
 drivers/soc/aspeed/espi/Makefile                   |   1 +
 drivers/soc/aspeed/espi/aspeed-espi-comm.h         |  62 +++
 drivers/soc/aspeed/espi/aspeed-espi.c              | 618 +++++++++++++++++++++
 drivers/soc/aspeed/espi/aspeed-espi.h              |  63 +++
 drivers/soc/aspeed/espi/ast2600-espi.c             | 304 ++++++++++
 drivers/soc/aspeed/espi/ast2600-espi.h             | 302 ++++++++++
 drivers/soc/aspeed/espi/espi_storage.c             | 322 +++++++++++
 drivers/soc/aspeed/espi/espi_storage.h             |  32 ++
 12 files changed, 1797 insertions(+)

---
base-commit: 0257f64bdac7fdca30fa3cae0df8b9ecbec7733a
change-id: 20260313-upstream_espi-d9fea66d1772

Best regards,

Signature · 1 line
aspeedyh <[email protected]>
#25 lore raw
Quoted 9 lines · Conor Dooley
Quoted 8 lines · aspeedyh

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

Quoted 6 lines
Quoted 2 lines

The driver is intended to support host-BMC communication over the BMC-side eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI driver and bindings go in the spi subsystem? FSL's appears to be there. Mark?

As documented in submitting-patches.rst please send patches to the maintainers for the code you would like to change. The normal kernel workflow is that people apply patches from their inboxes, if they aren't copied they are likely to not see the patch at all and it is much more difficult to apply patches.

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

#26 lore raw
Quoted 23 lines · Mark Brown
Quoted 9 lines · Conor Dooley
Quoted 8 lines · aspeedyh

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

Quoted 6 lines
Quoted 2 lines

The driver is intended to support host-BMC communication over the BMC-side eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI driver and bindings go in the spi subsystem? FSL's appears to be there. Mark?

As documented in submitting-patches.rst please send patches to the maintainers for the code you would like to change. The normal kernel workflow is that people apply patches from their inboxes, if they aren't copied they are likely to not see the patch at all and it is much more difficult to apply patches.

Quoted 5 lines

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

If this is a driver for SPI hardware it should be under drivers/spi and use the framework there.

author
#27 lore raw

Hi Mark, Conor,

Quoted 24 lines · Mark Brown
Quoted 23 lines · Conor Dooley
Quoted 9 lines · aspeedyh
Quoted 8 lines

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

Quoted 6 lines
Quoted 2 lines

The driver is intended to support host-BMC communication over the BMC-side eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI driver and bindings go in the spi subsystem? FSL's appears to be there. Mark?

As documented in submitting-patches.rst please send patches to the maintainers for the code you would like to change. The normal kernel workflow is that people apply patches from their inboxes, if they aren't copied they are likely to not see the patch at all and it is much more difficult to apply patches.

Quoted 8 lines
Quoted 5 lines

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

If this is a driver for SPI hardware it should be under drivers/spi and use the framework there.

Thanks for the kind guidance.

This driver is for the Intel eSPI interface used by the AST2600 BMC, for functions such as Super I/O that were previously handled over the LPC interface.
As there does not appear to be an in-tree eSPI subsystem at present, our initial thought was to place it under drivers/soc/aspeed/. If that is not the preferred upstream location, we are happy to restructure the series accordingly.

#28 lore raw
In reply to Conor Dooley
Quoted 9 lines · Conor Dooley
Quoted 8 lines · aspeedyh

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

Quoted 5 lines
Quoted 2 lines

The driver is intended to support host-BMC communication over the BMC-side eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI driver and bindings go in the spi subsystem?

From an initial reading, my impression is that patches 1, 2, 3 and 7 should be modified to use the normal SPI interfaces to implement an spi target driver, possibly a combined host/target driver. Reworking this should be fairly straightforward because the interfaces to the SPI core are well documented.

It is possible that the hardware can only be used to provide espi device emulation. From what I could see in the code, there is not much special in there, but I'm not that familiar with SPI

Patches 4, 5 and 6 in consequently would need to be reworked so these can implement the TAFS spec independent of the SPI controller, and can be shared e.g. with other OpenBMC targets using the same module and the same user interface. None of this should be aspeed specific.

There is a good chance that both the user interface and the placing of the code will need a more debate, but I would suggest first trying to move everything over to use the SPI subsystem but leave other parts untouched for the moment.

Quoted 1 line

FSL's appears to be there.

I think this is just a similarly named device: Freescale/NXP's eSPI device driver is unrelated to the Intel eSPI spec but rather implements a normal SPI driver the same way that eDMA and eSDHC are Freescale's implementation of dmaengine and SDHCI drivers.

Arnd

#29 lore raw
Quoted 8 lines · Arnd Bergmann
Quoted 1 line · Conor Dooley

FSL's appears to be there.

I think this is just a similarly named device: Freescale/NXP's eSPI device driver is unrelated to the Intel eSPI spec but rather implements a normal SPI driver the same way that eDMA and eSDHC are Freescale's implementation of dmaengine and SDHCI drivers.

Yeah, SPI with a random letter or string in front of it is usually just someone made a new controller for some reason (often a new feature, like all the QuadSPI devices) and wants to differentiate it from their old ones or connect it to other branding.

#30 lore raw
In reply to Arnd Bergmann
Quoted 22 lines · Arnd Bergmann
Quoted 13 lines · Conor Dooley
Quoted 12 lines · aspeedyh

This series adds initial support for the eSPI controller found on ASPEED
AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under
drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree
binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

Quoted 7 lines
Quoted 3 lines

The driver is intended to support host-BMC communication over the BMC-side
eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI
driver and bindings go in the spi subsystem?

Quoted 6 lines

From an initial reading, my impression is that patches 1, 2, 3 and 7 should be modified to use the normal SPI interfaces to implement an spi target driver, possibly a combined host/target driver. Reworking this should be fairly straightforward because the interfaces
to the SPI core are well documented.

Arnd, that's would be nice if it would be standard SPI device. But what if eSPI would be a bus? So, I assume all other which lying underneath eSPI would be much easier to implement as standard driver data set SPI/GPIO/I2C with something like devm_regmap_init_espi(like for i2c/spi or anything else) for example as common part for these drivers.

Thanks.

maintainer
#31 lore raw
In reply to Arnd Bergmann
Quoted 32 lines · Arnd Bergmann
Quoted 9 lines · Conor Dooley
Quoted 8 lines · aspeedyh

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

Quoted 5 lines
Quoted 2 lines

The driver is intended to support host-BMC communication over the BMC-side eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI driver and bindings go in the spi subsystem?

From an initial reading, my impression is that patches 1, 2, 3 and 7 should be modified to use the normal SPI interfaces to implement an spi target driver, possibly a combined host/target driver. Reworking this should be fairly straightforward because the interfaces to the SPI core are well documented.

It is possible that the hardware can only be used to provide espi device emulation. From what I could see in the code, there is not much special in there, but I'm not that familiar with SPI

Patches 4, 5 and 6 in consequently would need to be reworked so these can implement the TAFS spec independent of the SPI controller, and can be shared e.g. with other OpenBMC targets using the same module and the same user interface. None of this should be aspeed specific.

Quoted 4 lines

There is a good chance that both the user interface and the placing of the code will need a more debate, but I would suggest first trying to move everything over to use the SPI subsystem but leave other parts untouched for the moment.

To extend Arnd's points here, some previous attempts were made to support Intel's eSPI protocol on Aspeed's SoCs which aren't discussed in this cover letter. I think it would be helpful to cover the history and why we now have a third approach:

- https://lore.kernel.org/linux-aspeed/[email protected]/
- https://lore.kernel.org/openbmc/[email protected]/

Previously, Jeremy had some suggestions covering the various channels:

https://lore.kernel.org/linux-aspeed/20c13b9bb023091758cac3a07fb4037b7d796578.camel@codeconstruct.com.au/

Andrew

author
#32 lore raw
Quoted 51 lines · Arnd Bergmann
Quoted 11 lines · Conor Dooley
Quoted 10 lines · aspeedyh
Quoted 9 lines

This series adds initial support for the eSPI controller found on ASPEED AST2600 BMC SoCs.

The series introduces a eSPI controller framework for ASPEED SoCs under drivers/soc/aspeed/, adds AST2600-specific controller support for peripheral and flash channels, defines the corresponding devicetree binding, and adds the AST2600 eSPI controller node to the SoC dtsi.

The driver is intended to support host-BMC communication over the

BMC-side

Quoted 21 lines
Quoted 4 lines
Quoted 1 line

eSPI slave controller present on AST2600 systems.

This all seems to be in the wrong places entirely, shouldn't an eSPI driver and bindings go in the spi subsystem?

From an initial reading, my impression is that patches 1, 2, 3 and 7 should be modified to use the normal SPI interfaces to implement an spi target driver, possibly a combined host/target driver. Reworking this should be fairly straightforward because the interfaces to the SPI core are well documented.

It is possible that the hardware can only be used to provide espi device emulation. From what I could see in the code, there is not much special in there, but I'm not that familiar with SPI

Patches 4, 5 and 6 in consequently would need to be reworked so these can implement the TAFS spec independent of the SPI controller, and can be shared e.g. with other OpenBMC targets using the same module and the same user interface. None of this should be aspeed specific.

Quoted 4 lines

There is a good chance that both the user interface and the placing of the code will need a more debate, but I would suggest first trying to move everything over to use the SPI subsystem but leave other parts untouched for the moment.

To extend Arnd's points here, some previous attempts were made to support Intel's eSPI protocol on Aspeed's SoCs which aren't discussed in this cover letter. I think it would be helpful to cover the history and why we now have a third approach:

-
https://lore.kernel.org/linux-aspeed/20240319093405.39833-1-manojkiran.eda@g
mail.com/
-
https://lore.kernel.org/openbmc/20220516005412.4844-1-chiawei_wang@aspeedt
ech.com/

Quoted 6 lines

Previously, Jeremy had some suggestions covering the various channels:

https://lore.kernel.org/linux-aspeed/20c13b9bb023091758cac3a07fb4037b7d7965
[email protected]/

Andrew

Hi Andrew, Ivan, Arnd,

Thanks for the additional context and the review links. It was my mistake not to reference the previous discussions in the cover letter.

This series is intended to support the Intel eSPI interface on AST2600, specifically the parts corresponding to LPC-style accesses and Target Flash Access Sharing (TAFS), which are defined in the peripheral and flash channels of the eSPI specification.

Because the earlier OpenBMC work from Chia-Wei dates back to 2021, and because the code structure and overall approach in this series differs substantially from that earlier work, I chose to post this as a new series rather than as a revision of the earlier one.

I agree that the cover letter should explain this history more clearly, including the definition of eSPI, how this series differs from the previous attempts and how it relates to the earlier feedback on the channel split. I will revise the cover letter accordingly in the next version.

In the meantime, my understanding is that this driver is for the Intel eSPI interface used by the AST2600 BMC, rather than fitting a conventional SPI controller/device model. That was the reason for initially placing it under drivers/soc/aspeed/, since there does not appear to be an in-tree eSPI subsystem at present. However, if that is not the preferred upstream direction, we are happy to restructure the series accordingly. It would be very helpful if you could advise on the preferred placement.

Thanks,
Yun Hsuan

#33 lore raw
Quoted 10 lines · YH Chung

In the meantime, my understanding is that this driver is for the Intel eSPI interface used by the AST2600 BMC,
rather than fitting a conventional SPI controller/device model. That was the reason for initially placing it under drivers/soc/aspeed/, since there does not appear to be an in-tree eSPI subsystem at present.
However, if that is not the preferred upstream direction, we are happy to restructure the series accordingly.
It would be very helpful if you could advise on the preferred placement.

I think we need to make sure everyone understands what the options are here based on what the hardware can do, and what your use cases require.

From reading the old comments that Andrew linked to at

https://lore.kernel.org/linux-aspeed/HK0PR06MB377924CFCBFE9BD40E1C4A5D91D49@HK0PR06MB3779.apcprd06.prod.outlook.com/

I understand that the SoC has a "hardware mode" in which eSPI is directly implemented by redirecting upper-level eSPI transactions into functional blocks of the chip, while the software mode behaves like a regular SPI endpoint controller and your driver implements the same interfaces in a mix of kernel and userspace components. Can you confirm that this is a correct understanding of what the hardware does, or where I misunderstand parts?

If I understood this correctly, I think there is a general agreement upstream that the low-level device access should indeed be in a drivers/spi driver, with no ports of it in drivers/soc/aspeed. Using a portable driver subsystem is always better than a custom solution if it works at all.

For the higher-level interfaces (flash, gpio, ...), I don't think there is any consensus yet about how this should be done, but again I think this won't be drivers/soc but instead something more generic.

One option here would be to sidestep this problem entirely by moving all of the eSPI implementation out of the kernel but instead have a hardware-independent userspace implementation that uses the spidev ioctl interface. This is always going to be slower than an in-kernel implementation, but also much easier to implement and debug.

An in-kernel implementation of the eSPI backend (on top of the SPI layer) is certainly a realistic option for the higher layers, but requires finding consensus both on the the logistics (subsystem, code ownership, interfaces to other subsystems) and more importantly the user space interfaces that look like they will require several revisions on top of what you have today.

Arnd

author
#34 lore raw

Hi Arnd,

Quoted 12 lines · YH Chung
Quoted 10 lines

In the meantime, my understanding is that this driver is for the Intel eSPI interface used by the AST2600 BMC,
rather than fitting a conventional SPI controller/device model. That was the reason for initially placing it under drivers/soc/aspeed/, since there does not appear to be an in-tree eSPI subsystem at present.
However, if that is not the preferred upstream direction, we are happy to restructure the series accordingly.
It would be very helpful if you could advise on the preferred placement.

Quoted 3 lines

I think we need to make sure everyone understands what the options are here based on what the hardware can do, and what your use cases require.

For reference, Intel's eSPI base specification is defined here:
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

Although eSPI physically reuses some SPI pins, it is not used as a conventional SPI controller/device interface. It also adds RESET# and ALERT# beyond the usual SPI signals.

The spec also defines two roles in eSPI transaction model: Controller and Target Device. ASPEED SoCs act as the Target Device side to interact with the host. In this case, the hardware is not exposed in a form that maps naturally onto the existing SPI subsystem model.

Quoted 5 lines

If I understood this correctly, I think there is a general agreement upstream that the low-level device access should indeed be in a drivers/spi driver, with no ports of it in drivers/soc/aspeed. Using a portable driver subsystem is always better than a custom solution if it works at all.

We understand the preference for using a generic subsystem where possible. Our hesitation is that the eSPI functionality appears to software primarily in terms of the eSPI Peripherals, Virtual Wires, OOB (SMBus), and Flash channel semantics and backend routing, rather than low-level bus signaling.

Since this driver is responsible for configuring those Aspeed-specific backend interfaces so they can service host requests, we initially placed it under drivers/soc/aspeed.

Quoted 5 lines

From reading the old comments that Andrew linked to at

https://lore.kernel.org/linux-aspeed/HK0PR06MB377924CFCBFE9BD40E1C4A5D91
[email protected]/

Quoted 7 lines

I understand that the SoC has a "hardware mode" in which eSPI is directly implemented by redirecting upper-level eSPI transactions into functional blocks of the chip, while the software mode behaves like a regular SPI endpoint controller and your driver implements the same interfaces in a mix of kernel and userspace components. Can you confirm that this is a correct understanding of what the hardware does, or where I misunderstand parts?

Broadly yes, except that the AST2600 does not operate in a single global "hardware mode" or "software mode". Instead, some backends in the eSPI target controller support per-function HW/SW mode selection.

Depending on that function-specific setting, the controller either forwards a received transaction directly to the corresponding hardware block or traps it for software handling instead.

This mechanism exists because some backend blocks include their own hardware filtering, but not all request types could be validated generically in hardware. For example, the LPC bridge can reject illegal requests. In some cases, blindly forwarding host requests to the target block would also have security implications.

The channel/backend mapping on AST2600 can be summarized as:

eSPI

├── Peripheral
│ ├── Memory (HW mode only)
│ └── LPC bridge (HW mode only)
├── Virtual Wire
│ └── GPIO (HW/SW mode selection)
├── Out-of-Band (SW mode only)
└── Flash
   └── Storage controller (HW/SW mode selection)

From the link thread, what Jeremy mentioned is the GPIO HW/SW mode for CH1, which determines whether the host can directly control the corresponding BMC GPIO output, or whether BMC software can inspect and decide whether to act on that request.

Another example is the Target Attached Flash Sharing (TAFS) defined by the eSPI specification that allows BMC to share its storage with the host.

In hardware mode, the eSPI Target Device controller routes the request directly to a predefined storage controller on AST2600.
In software mode, it raises an interrupt and lets software handle the transaction instead.

So I would not describe the AST2600 eSPI block as being globally in either "hardware mode" or "software mode".
That choice is made per backend function, and some backend functions do not implement such a switch at all.

So far, this series only covers the LPC bridge and flash channel parts.

Quoted 4 lines

For the higher-level interfaces (flash, gpio, ...), I don't think there is any consensus yet about how this should be done, but again I think this won't be drivers/soc but instead something more generic.

For the flash-related interface, would it make sense to follow the configuration model used by the USB gadget mass-storage function, and expose the backing storage selection through configfs?

For the attributes, perhaps the only backing storage object and read-only flag would be required in our case.

For the Virtual Wire GPIO, we think GPIO subsystem may be leveraged here, though some corner cases may not map cleanly to a typical GPIO controller model.

For the Out-of-band channel, since the eSPI spec models it for tunneled SMBus packets, we may want to integrate it with the kernel's MCTP stack if that is a suitable fit.

Thanks,
Yun Hsuan

#35 lore raw
Quoted 53 lines · YH Chung
Quoted 6 lines · YH Chung

From reading the old comments that Andrew linked to at

https://lore.kernel.org/linux-aspeed/HK0PR06MB377924CFCBFE9BD40E1C4A5D91
[email protected]/

Quoted 7 lines

I understand that the SoC has a "hardware mode" in which eSPI is directly implemented by redirecting upper-level eSPI transactions into functional blocks of the chip, while the software mode behaves like a regular SPI endpoint controller and your driver implements the same interfaces in a mix of kernel and userspace components. Can you confirm that this is a correct understanding of what the hardware does, or where I misunderstand parts?

Broadly yes, except that the AST2600 does not operate in a single global "hardware mode" or "software mode". Instead, some backends in the eSPI target controller support per-function HW/SW mode selection.

Depending on that function-specific setting, the controller either forwards a received transaction directly to the corresponding hardware block or traps it for software handling instead.

This mechanism exists because some backend blocks include their own hardware filtering, but not all request types could be validated generically in hardware. For example, the LPC bridge can reject illegal requests. In some cases, blindly forwarding host requests to the target block would also have security implications.

The channel/backend mapping on AST2600 can be summarized as:

eSPI

├── Peripheral
│ ├── Memory (HW mode only)
│ └── LPC bridge (HW mode only)
├── Virtual Wire
│ └── GPIO (HW/SW mode selection)
├── Out-of-Band (SW mode only)
└── Flash
   └── Storage controller (HW/SW mode selection)

From the link thread, what Jeremy mentioned is the GPIO HW/SW mode for CH1, which determines whether the host can directly control the corresponding BMC GPIO output, or whether BMC software can inspect and decide whether to act on that request.

Another example is the Target Attached Flash Sharing (TAFS) defined by the eSPI specification that allows BMC to share its storage with the host.

In hardware mode, the eSPI Target Device controller routes the request directly to a predefined storage controller on AST2600.
In software mode, it raises an interrupt and lets software handle the transaction instead.

Quoted 4 lines

So I would not describe the AST2600 eSPI block as being globally in either "hardware mode" or "software mode".
That choice is made per backend function, and some backend functions do not implement such a switch at all.

I see, thanks for the detailed explanation! Two follow-up questions:

- For the HW-mode-only peripherals (memory, LPC), is there any driver interaction at all for setting it up, or is this completely transparent to Linux running on the BMC?

- For the other devices running in SW mode, is the interface that the driver sees abstract in the sense that the same low-level code is shared for all of them, or are these still separate functional blocks that each need their own register-level interface?

Quoted 12 lines
Quoted 4 lines

For the higher-level interfaces (flash, gpio, ...), I don't think there is any consensus yet about how this should be done, but again I think this won't be drivers/soc but instead something more generic.

For the flash-related interface, would it make sense to follow the configuration model used by the USB gadget mass-storage function, and expose the backing storage selection through configfs?

For the attributes, perhaps the only backing storage object and read-only flag would be required in our case.

Quoted 7 lines

For the Virtual Wire GPIO, we think GPIO subsystem may be leveraged here, though some corner cases may not map cleanly to a typical GPIO controller model.

For the Out-of-band channel, since the eSPI spec models it for tunneled SMBus packets, we may want to integrate it with the kernel's MCTP stack if that is a suitable fit.

These all seem to be viable options, but I still think we should focus on agreeing on a design for the low-level hardware interface and whether this can or should be abstracted between SoC vendor specific drivers before trying to solve the user interface side.

Arnd

author
#36 lore raw

Hi Arnd,

Quoted 3 lines

- For the HW-mode-only peripherals (memory, LPC), is there any driver interaction at all for setting it up, or is this completely transparent to Linux running on the BMC?

For LPC-style IO accesses like Post Code Capture (PCC), the accesses are completely transparent to Linux.

For memory accesses, they are also transparent to Linux on the BMC. It just requires configuring the translation from the bus address to a reserved memory region on the BMC during driver probe.

Quoted 4 lines

- For the other devices running in SW mode, is the interface that the driver sees abstract in the sense that the same low-level code is shared for all of them, or are these still separate functional blocks that each need their own register-level interface?

The channels are distinct functional blocks within the eSPI controller, each using its own channel-specific registers regardless of whether they operate in HW or SW mode. There is no common message flow or registers for the software modes. The eSPI controller dispatches eSPI messages to the relevant channel's hardware function block, which then takes action according to its mode configuration.

Some low-level framework code may be shareable, for example a unified ISR entry that checks interrupt status register and routes to channel-specific handlers, but the corresponding handling will be channel-specific.

Thanks,
Yun Hsuan

author
#37 lore raw

Hi Arnd,

Thanks for the comments and questions.

Quoted 4 lines

These all seem to be viable options, but I still think we should focus on agreeing on a design for the low-level hardware interface and whether this can or should be abstracted between SoC vendor specific drivers before trying to solve the user interface side.

Could you share your thoughts on whether it would make sense to accept our eSPI driver as is, and whether it should live under the SoC vendor-specific directories? Any comment would be greatly appreciated.

Thanks,
YunHsuan

#38 lore raw
Quoted 9 lines · YH Chung

Hi Arnd,

Thanks for the comments and questions.

Quoted 4 lines

These all seem to be viable options, but I still think we should focus on agreeing on a design for the low-level hardware interface and whether this can or should be abstracted between SoC vendor specific drivers before trying to solve the user interface side.

Quoted 6 lines

Could you share your thoughts on whether it would make sense to accept our eSPI driver as is, and whether it should live under the SoC vendor-specific directories? Any comment would be greatly appreciated.

Thanks,
YunHsuan

Hi YunHsuan,

Let me add my 5 cents on this matter.

Integrating this driver into the SPI subsystem may allow reusing some existing definitions, e.g.|spi_controller|,|spi_message|, and perhaps parts related to single/dual/quad I/O handling. At the same time, parts such as the Flash channel (included in the current series), and OOB / Virtual Wire support (I would expect to come later), appear to be specific to the Intel eSPI protocol. Modeling all of that as just another SPI IP driver may introduce some awkward layering and overhead.

Also, the current series already seems to separate common eSPI logic from AST2600-specific pieces, assuming that 2700 driver is also coming at some point.

This makes me wonder whether a dedicated eSPI layer/subsystem could be a better fit — either under the SPI or as something separate (but not SoC driver).

Given my limited experience with SPI/eSPI, could you help clarify a few points for me (and probably others as well)?

* How much of the SPI subsystem can be reused for this implementation, both for the current patchset and for likely future extensions?
* Are there any pitfalls or abstraction mismatches in trying to reuse the SPI core here?

I think this would help make the subsystem placement discussion much clearer.

author
#39 lore raw

Hi Shulzhenko,

Thanks for the follow-up.

Quoted 7 lines

Integrating this driver into the SPI subsystem may allow reusing some existing definitions, e.g.|spi_controller|,|spi_message|, and perhaps parts related to single/dual/quad I/O handling. At the same time, parts such as the Flash channel (included in the current series), and OOB / Virtual Wire support (I would expect to come later), appear to be specific to the Intel eSPI protocol. Modeling all of that as just another SPI IP driver may introduce some awkward layering and overhead.

Agreed. eSPI introduces two additional pins, RESET# and ALERT#, beyond the standard SPI signals. More importantly, eSPI functionality is described primarily in terms of four logical channels, rather than generic low-level bus signaling or pure data transfers.

Quoted 11 lines

Also, the current series already seems to separate common eSPI logic from AST2600-specific pieces, assuming that 2700 driver is also coming at some point.

This makes me wonder whether a dedicated eSPI layer/subsystem could be a better fit — either under the SPI or as something separate (but not SoC driver).

Given my limited experience with SPI/eSPI, could you help clarify a few points for me (and probably others as well)?

* How much of the SPI subsystem can be reused for this implementation, both for the current patchset and for likely future extensions?

I believe only a limited portion of the SPI subsystem can be reused. Some generic framework elements, such as controller registration and basic scaffolding, may be useful initially. But this reuse appears to be mostly mechanical rather than semantic. Once eSPI-specific features like Flash channels, OOB messaging, and Virtual Wire semantics are involved, the SPI transaction model does not seem to map very naturally.

Quoted 2 lines

* Are there any pitfalls or abstraction mismatches in trying to reuse the SPI core here?

Our main concern is an abstraction mismatch. SPI is designed as a generic peripheral bus, while eSPI is more of a system-management interface with explicit host-BMC-specific semantics. Reusing the SPI core would likely require treating eSPI packets as generic bus-level transfers in the kernel.

However, some eSPI transactions and protocol handling, such as LPC bridge accesses, are performed autonomously by the hardware rather than being fully driven as low-level bus operations by the driver. This makes the eSPI driver somewhat different from a conventional serial bus controller driver maintained under the SPI core.

#40 lore raw
Quoted 41 lines · YH Chung

Hi Shulzhenko,

Thanks for the follow-up.

Quoted 7 lines

Integrating this driver into the SPI subsystem may allow reusing some existing definitions, e.g.|spi_controller|,|spi_message|, and perhaps parts related to single/dual/quad I/O handling. At the same time, parts such as the Flash channel (included in the current series), and OOB / Virtual Wire support (I would expect to come later), appear to be specific to the Intel eSPI protocol. Modeling all of that as just another SPI IP driver may introduce some awkward layering and overhead.

Agreed. eSPI introduces two additional pins, RESET# and ALERT#, beyond the standard SPI signals. More importantly, eSPI functionality is described primarily in terms of four logical channels, rather than generic low-level bus signaling or pure data transfers.

Quoted 11 lines

Also, the current series already seems to separate common eSPI logic from AST2600-specific pieces, assuming that 2700 driver is also coming at some point.

This makes me wonder whether a dedicated eSPI layer/subsystem could be a better fit — either under the SPI or as something separate (but not SoC driver).

Given my limited experience with SPI/eSPI, could you help clarify a few points for me (and probably others as well)?

* How much of the SPI subsystem can be reused for this implementation, both for the current patchset and for likely future extensions?

I believe only a limited portion of the SPI subsystem can be reused. Some generic framework elements, such as controller registration and basic scaffolding, may be useful initially. But this reuse appears to be mostly mechanical rather than semantic. Once eSPI-specific features like Flash channels, OOB messaging, and Virtual Wire semantics are involved, the SPI transaction model does not seem to map very naturally.

Quoted 2 lines

* Are there any pitfalls or abstraction mismatches in trying to reuse the SPI core here?

Our main concern is an abstraction mismatch. SPI is designed as a generic peripheral bus, while eSPI is more of a system-management interface with explicit host-BMC-specific semantics. Reusing the SPI core would likely require treating eSPI packets as generic bus-level transfers in the kernel.

Quoted 6 lines

However, some eSPI transactions and protocol handling, such as LPC bridge accesses, are performed autonomously by the hardware rather than being fully driven as low-level bus operations by the driver. This makes the eSPI driver somewhat different from a conventional serial bus controller driver maintained under the SPI core.

Hi YH,

My main concern is trying to understand whether it is completely impossible (or introduces too much effort that we'd better not to take) integrating this to SPI subsystem.

From your reply I understand there are two potential blockers:

a) Treating eSPI transfers as bus-level transfers (meaning that it will be necessary probably making separate driver for OOB/VW/Flash channels as they essentially use eSPI as a transport);

b) Some logic being done by the hardware (i.e. LPC bridge).

Please confirm my understanding:

(a) is feasible, but requires many effort to re-define architecture

(b) If something is done by the hardware - what is the driver impact? I recall eDAF use case when the driver wasn't involved at all - and flash access was fully done by the hardware (unless the controller is configured to handle it in SW mode).

P.S. I guess we can talk about host-BMC communication only when talking about hardware-dependent stuff (i.e. ast2600-espi files). eSPI core should be (it seems to be already is) at least BMC agnostic and this is the reason not having it under SOC/aspeed (ast2600-espi.* may stay here though).

author
#41 lore raw

Hi Shulzhenko,

Quoted 10 lines

My main concern is trying to understand whether it is completely impossible (or introduces too much effort that we'd better not to take) integrating this to SPI subsystem.

From your reply I understand there are two potential blockers:

a) Treating eSPI transfers as bus-level transfers (meaning that it will be necessary probably making separate driver for OOB/VW/Flash channels as they essentially use eSPI as a transport);

Quoted 5 lines

b) Some logic being done by the hardware (i.e. LPC bridge).

Please confirm my understanding:

(a) is feasible, but requires many effort to re-define architecture

I think it may not be a good choice for our hardware, since eSPI has clearly defined channel semantics and our hardware exposes different subsets of registers for each channel accordingly. Therefore, it would not fit well with the general messaging flow required by the SPI subsystem, because we would have to re-serialize the packets and plumb them through the SPI subsystem to a consumer that can handle the packet and perform the corresponding register operations.

Quoted 4 lines

(b) If something is done by the hardware - what is the driver impact? I recall eDAF use case when the driver wasn't involved at all - and flash access was fully done by the hardware (unless the controller is configured to handle it in SW mode).

For hardware mode, I do not think there is much direct driver implementation impact. If the hardware handles the transaction completely, the driver may only need to configure the controller during initialization.

Our concern is more about the design semantics. Integrating this into the SPI subsystem would imply that eSPI packets are treated as low-level SPI-like bus transfers. However, our hardware handles some channel packets automatically, so exposing them as normal SPI transfers may not accurately represent how the hardware operates.

author
#42 lore raw

Hi Shulzhenko, Arnd, Andrew

Please allow me to summarize the potential approaches we have discussed so far for upstreaming the eSPI driver:

(1) Reuse the existing SPI subsystem and treat eSPI packets as pure signals.
(2) Maintain the driver under the SoC subsystem, since there is currently no eSPI subsystem.
(3) Create a new eSPI subsystem and rewrite the eSPI driver accordingly.

For option 1, we do not think this would be a good fit, because eSPI has clearly defined semantics for each channel, and our hardware exposes different sets of registers for each of them.

For option 2, we think this would be a practical short-term solution, and we can expose the per-channel functionality through the existing GPIO, MCTP, and MTD subsystems for the VW, OOB, and flash channels, respectively. However, this may need to be revisited once an eSPI subsystem becomes available in-tree.

For option 3, our concern is that there is currently no other eSPI hardware or driver in-tree that could serve as a reference for defining a more generic interface. Creating a new subsystem at this stage may therefore be somewhat over-engineered, since it would only have one user.

We understand that Nuvoton may be the next likely vendor to support eSPI in their BMC SoCs. Since drivers/soc patches for Nuvoton BMCs also go through the BMC tree, we expect there would be an opportunity to reconsider whether an independent eSPI subsystem is needed once another user appears.

Based on the above, we would like to prepare and submit the next revision with the driver located under drivers/soc.

Could you please let us know if there are any concerns or suggestions that we have not covered, or whether we could send the next revision for review?

author
#43 lore raw
In reply to YH Chung

Hi Shulzhenko, Arnd, Andrew

Please allow me to summarize the potential approaches we have discussed so far for upstreaming the eSPI driver:

(1) Reuse the existing SPI subsystem and treat eSPI packets as pure signals.
(2) Maintain the driver under the SoC subsystem, since there is currently no eSPI subsystem.
(3) Create a new eSPI subsystem and rewrite the eSPI driver accordingly.

For option 1, we do not think this would be a good fit, because eSPI has clearly defined semantics for each channel, and our hardware exposes different sets of registers for each of them.

For option 2, we think this would be a practical short-term solution, and we can expose the per-channel functionality through the existing GPIO, MCTP, and MTD subsystems for the VW, OOB, and flash channels, respectively. However, this may need to be revisited once an eSPI subsystem becomes available in-tree.

For option 3, our concern is that there is currently no other eSPI hardware or driver in-tree that could serve as a reference for defining a more generic interface. Creating a new subsystem at this stage may therefore be somewhat over-engineered, since it would only have one user.

We understand that Nuvoton may be the next likely vendor to support eSPI in their BMC SoCs. Since drivers/soc patches for Nuvoton BMCs also go through the BMC tree, we expect there would be an opportunity to reconsider whether an independent eSPI subsystem is needed once another user appears.

Based on the above, we would like to prepare and submit the next revision with the driver located under drivers/soc.

Could you please let us know if there are any concerns or suggestions that we have not covered, or whether we could send the next revision for review?

author
#44 lore raw

Hi Mark,

Quoted 8 lines

(1) Reuse the existing SPI subsystem and treat eSPI packets as pure signals.
(2) Maintain the driver under the SoC subsystem, since there is currently no eSPI subsystem.
(3) Create a new eSPI subsystem and rewrite the eSPI driver accordingly.

For option 1, we do not think this would be a good fit, because eSPI has clearly defined semantics for each channel, and our hardware exposes different sets of registers for each of them.

Regarding option 1, could you kindly share your feedback on whether this patch set should be modified to fit under the SPI subsystem, or whether a new eSPI subsystem would be more appropriate?

For option 2, Arnd has indicated that he does not want to take this through the SoC subsystem. Therefore, if the SPI subsystem is also not a good fit, we think a new eSPI subsystem may be needed to provide a common home for channel handling, even though the individual channels are relatively independent.

For example, the VW and OOB channel handling could potentially be integrated with existing subsystems such as GPIO or net/mctp. However, the Flash channel would still need an eSPI-specific interface to configure the backing store. Placing that code under MTD feels awkward, since the driver is not really an MTD device or a flash controller.

If this direction sounds reasonable, we would like to explore introducing a new drivers/espi subsystem and moving the eSPI driver there. Please let us know if you think we should take a different approach.

Thanks,
Yun Hsuan.