Skip to contentSkip to conversation

arm: aspeed: Add eSPI support

PATCH Superseded Chia-Wei Wang 3 participants 15 messages Sep 1, 2021 – Nov 11, 2021

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover arm: aspeed: Add eSPI support

This patch series add the driver support for the eSPI controller of Aspeed 5/6th generation SoCs. This controller is a slave device communicating with a master over Enhanced Serial Peripheral Interface (eSPI). It supports all of the 4 eSPI channels, namely peripheral, virtual wire, out-of-band, and flash, and operates at max frequency of 66MHz.

v4:
- fix dt-bindgins error with patternProperties
- fix data type warning for ARM64 compilation
- replace header based implementation with .c files
- add more description for the ioctl interface

v3:
- remove the redundant patch "clk: aspeed: Add eSPI reset bit"
- fix missing header inclusion reported by test bot
- fix dt-bindings error reported by yamllint

v2:
- remove irqchip implementation
- merge per-channel drivers into single one to avoid the racing issue among eSPI handshake process and driver probing.

Chia-Wei Wang (4):
dt-bindings: aspeed: Add eSPI controller
MAINTAINER: Add ASPEED eSPI driver entry
soc: aspeed: Add eSPI driver
ARM: dts: aspeed: Add eSPI node

 .../devicetree/bindings/soc/aspeed/espi.yaml  | 162 +++++
 MAINTAINERS                                   |   9 +
 arch/arm/boot/dts/aspeed-g6.dtsi              |  17 +
 drivers/soc/aspeed/Kconfig                    |  11 +
 drivers/soc/aspeed/Makefile                   |   5 +
 drivers/soc/aspeed/aspeed-espi-ctrl.c         | 214 +++++++
 drivers/soc/aspeed/aspeed-espi-ctrl.h         | 308 ++++++++++
 drivers/soc/aspeed/aspeed-espi-flash.c        | 352 +++++++++++
 drivers/soc/aspeed/aspeed-espi-flash.h        |  45 ++
 drivers/soc/aspeed/aspeed-espi-ioc.h          | 195 ++++++
 drivers/soc/aspeed/aspeed-espi-oob.c          | 558 ++++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-oob.h          |  70 +++
 drivers/soc/aspeed/aspeed-espi-perif.c        | 511 ++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-perif.h        |  45 ++
 drivers/soc/aspeed/aspeed-espi-vw.c           | 137 +++++
 drivers/soc/aspeed/aspeed-espi-vw.h           |  21 +
 16 files changed, 2660 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ioc.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-perif.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-perif.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v4 1/4 dt-bindings: aspeed: Add eSPI controller

Add dt-bindings for Aspeed eSPI controller

---
 .../devicetree/bindings/soc/aspeed/espi.yaml  | 162 ++++++++++++++++++
 1 file changed, 162 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml
Documentation/devicetree/bindings/soc/aspeed/espi.yaml new file +162 -0
new file mode 100644
index 000000000000..aa91ec8caf6a
@@ -0,0 +1,162 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# # Copyright (c) 2021 Aspeed Technology Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/soc/aspeed/espi.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Aspeed eSPI Controller
+
+maintainers:
+  - Chia-Wei Wang <[email protected]>
+  - Ryan Chen <[email protected]>
+
+description:
+  Aspeed eSPI controller implements a slave side eSPI endpoint device
+  supporting the four eSPI channels, namely peripheral, virtual wire,
+  out-of-band, and flash.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - aspeed,ast2500-espi
+          - aspeed,ast2600-espi
+      - const: simple-mfd
+      - const: syscon
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 1
+
+  ranges: true
+
+patternProperties:
+  "^espi-ctrl@[0-9a-f]+$":
+    type: object
+
+    description: Control of the four basic eSPI channels
+
+    properties:
+      compatible:
+        items:
+          - enum:
+              - aspeed,ast2500-espi-ctrl
+              - aspeed,ast2600-espi-ctrl
+
+      interrupts:
+        maxItems: 1
+
+      clocks:
+        maxItems: 1
+
+      perif,memcyc-enable:
+        type: boolean
+        description: Enable memory cycle over eSPI peripheral channel
+
+      perif,memcyc-src-addr:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: The Host side address to be decoded into the memory cycle over eSPI peripheral channel
+
+      perif,memcyc-size:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        description: The size of the memory region allocated for the memory cycle over eSPI peripheral channel
+        minimum: 65536
+
+      perif,dma-mode:
+        type: boolean
+        description: Enable DMA support for eSPI peripheral channel
+
+      oob,dma-mode:
+        type: boolean
+        description: Enable DMA support for eSPI out-of-band channel
+
+      oob,dma-tx-desc-num:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        minimum: 2
+        maximum: 1023
+        description: The number of TX descriptors available for eSPI OOB DMA engine
+
+      oob,dma-rx-desc-num:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        minimum: 2
+        maximum: 1023
+        description: The number of RX descriptors available for eSPI OOB DMA engine
+
+      flash,dma-mode:
+        type: boolean
+        description: Enable DMA support for eSPI flash channel
+
+      flash,safs-mode:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [ 0, 1, 2 ]
+        default: 0
+        description: Slave-Attached-Sharing-Flash mode, 0->Mix, 1->SW, 2->HW
+
+    dependencies:
+      perif,memcyc-src-addr: [ "perif,memcyc-enable" ]
+      perif,memcyc-size: [ "perif,memcyc-enable" ]
+      oob,dma-tx-desc-num: [ "oob,dma-mode" ]
+      oob,dma-rx-desc-num: [ "oob,dma-mode" ]
+
+    required:
+      - compatible
+      - interrupts
+      - clocks
+
+  "^espi-mmbi@[0-9a-f]+$":
+    type: object
+
+    description: Control of the PCH-BMC data exchange over eSPI peripheral memory cycle
+
+    properties:
+      compatible:
+        const: aspeed,ast2600-espi-mmbi
+
+      interrupts:
+        maxItems: 1
+
+    required:
+      - compatible
+      - interrupts
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - ranges
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/ast2600-clock.h>
+
+    espi: espi at 1e6ee000 {
+        compatible = "aspeed,ast2600-espi", "simple-mfd", "syscon";
+        reg = <0x1e6ee000 0x1000>;
+
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x0 0x1e6ee000 0x1000>;
+
+        espi_ctrl: espi-ctrl at 0 {
+            compatible = "aspeed,ast2600-espi-ctrl";
+            reg = <0x0 0x800>;
+            interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
+            clocks = <&syscon ASPEED_CLK_GATE_ESPICLK>;
+        };
+
+        espi_mmbi: espi-mmbi at 800 {
+            compatible = "aspeed,ast2600-espi-mmbi";
+            reg = <0x800 0x50>;
+            interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+        };
+    };
Signature · 1 line
2.17.1
#2 lore raw

PATCH v4 2/4 MAINTAINER: Add ASPEED eSPI driver entry

In reply to Chia-Wei Wang

Add Ryan Chen and myself as the maintainer of Aspeed eSPI driver. Joel Stanley is added as the reviewer.

---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
index f3267183e993..35c3164277ac 100644
@@ -1720,6 +1720,15 @@ F:	drivers/crypto/axis
 F:	drivers/mmc/host/usdhi6rol0.c
 F:	drivers/pinctrl/pinctrl-artpec*
 
+ARM/ASPEED ESPI DRIVER
+M:	Chia-Wei Wang <[email protected]>
+M:	Ryan Chen <[email protected]>
+R:	Joel Stanley <[email protected]>
+L:	linux-aspeed at lists.ozlabs.org (moderated for non-subscribers)
+L:	openbmc at lists.ozlabs.org (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/soc/aspeed/espi.yaml
+
 ARM/ASPEED I2C DRIVER
 M:	Brendan Higgins <[email protected]>
 R:	Benjamin Herrenschmidt <[email protected]>
Signature · 1 line
2.17.1
#3 lore raw

PATCH v4 3/4 soc: aspeed: Add eSPI driver

In reply to Chia-Wei Wang

The Aspeed eSPI controller is slave device to communicate with the master through the Enhanced Serial Peripheral Interface (eSPI). All of the four eSPI channels, namely peripheral, virtual wire, out-of-band, and flash are supported.

---
 drivers/soc/aspeed/Kconfig             |  11 +
 drivers/soc/aspeed/Makefile            |   5 +
 drivers/soc/aspeed/aspeed-espi-ctrl.c  | 214 ++++++++++
 drivers/soc/aspeed/aspeed-espi-ctrl.h  | 308 ++++++++++++++
 drivers/soc/aspeed/aspeed-espi-flash.c | 352 ++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-flash.h |  45 ++
 drivers/soc/aspeed/aspeed-espi-ioc.h   | 195 +++++++++
 drivers/soc/aspeed/aspeed-espi-oob.c   | 558 +++++++++++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-oob.h   |  70 ++++
 drivers/soc/aspeed/aspeed-espi-perif.c | 511 ++++++++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-perif.h |  45 ++
 drivers/soc/aspeed/aspeed-espi-vw.c    | 137 ++++++
 drivers/soc/aspeed/aspeed-espi-vw.h    |  21 +
 13 files changed, 2472 insertions(+)
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ioc.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-perif.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-perif.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.c
 create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.h
drivers/soc/aspeed/Kconfig +11 -0
index 243ca196e6ad..7617a02df5cf 100644
@@ -42,6 +42,17 @@ config ASPEED_SOCINFO
 	help
 	  Say yes to support decoding of ASPEED BMC information.
 
+config ASPEED_ESPI
+	bool "ASPEED eSPI slave driver"
+	select REGMAP
+	select MFD_SYSCON
+	default n
+	help
+	  Enable driver support for the Aspeed eSPI engine. The eSPI engine
+	  plays as a slave device in BMC to communicate with the Host over
+	  the eSPI interface. The four eSPI channels, namely peripheral,
+	  virtual wire, out-of-band, and flash are supported.
+
 endmenu
 
 endif
drivers/soc/aspeed/Makefile +5 -0
index fcab7192e1a4..27f05e8b69e1 100644
@@ -3,3 +3,8 @@ obj-$(CONFIG_ASPEED_LPC_CTRL)	+= aspeed-lpc-ctrl.o
 obj-$(CONFIG_ASPEED_LPC_SNOOP)	+= aspeed-lpc-snoop.o
 obj-$(CONFIG_ASPEED_P2A_CTRL)	+= aspeed-p2a-ctrl.o
 obj-$(CONFIG_ASPEED_SOCINFO)	+= aspeed-socinfo.o
+obj-$(CONFIG_ASPEED_ESPI)	+= aspeed-espi-ctrl.o \
+				   aspeed-espi-perif.o \
+				   aspeed-espi-vw.o \
+				   aspeed-espi-oob.o \
+				   aspeed-espi-flash.o
drivers/soc/aspeed/aspeed-espi-ctrl.c new file +214 -0

214 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-ctrl.h new file +308 -0

308 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-flash.c new file +352 -0

352 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-flash.h new file +45 -0

45 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-ioc.h new file +195 -0

195 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-oob.c new file +558 -0

558 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-oob.h new file +70 -0

70 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-perif.c new file +511 -0

511 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-perif.h new file +45 -0

45 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-vw.c new file +137 -0

137 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-vw.h new file +21 -0
new file mode 100644
index 000000000000..aba9c414ac1b
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 ASPEED Technology Inc.
+ */
+#ifndef _ASPEED_ESPI_VW_H_
+#define _ASPEED_ESPI_VW_H_
+
+struct aspeed_espi_vw {
+	int irq;
+	int irq_reset;
+
+	struct miscdevice mdev;
+	struct aspeed_espi_ctrl *ctrl;
+};
+
+void aspeed_espi_vw_event(uint32_t sts, struct aspeed_espi_vw *espi_vw);
+void aspeed_espi_vw_enable(struct aspeed_espi_vw *espi_vw);
+void *aspeed_espi_vw_alloc(struct device *dev, struct aspeed_espi_ctrl *espi_ctrl);
+void aspeed_espi_vw_free(struct device *dev, struct aspeed_espi_vw *espi_vw);
+
+#endif
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Chiawei,

Quoted 4 lines

The Aspeed eSPI controller is slave device to communicate with the master through the Enhanced Serial Peripheral Interface (eSPI). All of the four eSPI channels, namely peripheral, virtual wire, out-of-band, and flash are supported.

I'm still not confinced this raw packet user-ABI is the right approach for this. The four channels that you're exposing would be much more useful to use existing kernel subsystems.

Specifically:

1) The VW channel is essentially a GPIO interface, and we have a kernel subsystem to expose GPIOs. We might want to add additional support for in-kernel system event handlers, but that's a minor addition that can be done separately if we don't want that handled by a gpio consumer in userspace.

2) The out-of-band (OOB) channel provides a way to issue SMBus transactions, so could well provide an i2c controller interface. Additionally, the eSPI specs imply that this is intended to support MCTP - in which case, you'll *need* a kernel i2c controller device to be able to use the new kernel MCTP stack.

3) The flash channel exposes read/write/erase operations, which would be much more useful as an actual flash-type device, perhaps using the existing mtd interface? Or is there additional functionality expected for this?

4) The peripheral channel is the only one that would seem to require arbitrary cycle access, but we'll still need a proper uapi definition to support that. At the minimum, your ioctl definitions should go under include/uapi/ - you shouldn't need to duplicate the header into each userspace repo, as you've done for the test examples.

Cheers,

Jeremy

#5 lore raw

RE: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Jeremy,

Quoted 5 lines

From: Jeremy Kerr <[email protected]>
Sent: Thursday, September 2, 2021 11:30 AM

Hi Chiawei,

Quoted 8 lines
Quoted 4 lines

The Aspeed eSPI controller is slave device to communicate with the master through the Enhanced Serial Peripheral Interface (eSPI). All of the four eSPI channels, namely peripheral, virtual wire, out-of-band, and flash are supported.

I'm still not confinced this raw packet user-ABI is the right approach for this. The four channels that you're exposing would be much more useful to use existing kernel subsystems.

The eSPI on BMC side is a slave device. Most of time it listen to the Host requests and then react. This makes it not quite fit to interfaces that act as a master role.

Quoted 8 lines

Specifically:

1) The VW channel is essentially a GPIO interface, and we have a kernel subsystem to expose GPIOs. We might want to add additional support for in-kernel system event handlers, but that's a minor addition that can be done separately if we don't want that handled by a gpio consumer in userspace.

eSPI VW channel can be used to forward a byte value to/from GPIO. However, the targeted GPIO group and its direction are determined by the Host. This is different from usual GPIO devices as it supports very limited operations.

Quoted 6 lines

2) The out-of-band (OOB) channel provides a way to issue SMBus transactions, so could well provide an i2c controller interface. Additionally, the eSPI specs imply that this is intended to support MCTP - in which case, you'll *need* a kernel i2c controller device to be able to use the new kernel MCTP stack.

Could you share us more information about the i2c need of kernel MCTP kernel stack? To our understanding, the MCTP is a bus agnostic protocol.
A generic raw packet interface makes it more flexible to adapt to different interfaces.

Quoted 5 lines

3) The flash channel exposes read/write/erase operations, which would be much more useful as an actual flash-type device, perhaps using the existing mtd interface? Or is there additional functionality expected for this?

The flash channel works in either the Master Attached Flash Sharing (MAFS) or Slave Attached Flash Sharing (SAFS) mode.

For MAFS, BMC issues eSPI flash R/W/E packets to the Host. In this case, it may fit into the MTD interface.

For SAFS (mostly used), BMC needs to listen, parse and filter eSPI flash R/W/E packets from the Host. And then send replies in the eSPI success/unsuccess completion packet format.
This behaves differently from MTD.

To support both the two scenario, the MTD interface might not be suitable.

Quoted 6 lines

4) The peripheral channel is the only one that would seem to require arbitrary cycle access, but we'll still need a proper uapi definition to support that. At the minimum, your ioctl definitions should go under include/uapi/ - you shouldn't need to duplicate the header into each userspace repo, as you've done for the test examples.

In the first submission, I was told that the include/uapi patch is not going to be accepted. Thereby, I refer to other existing driver implementation which places IOCTL codes in their own driver files.

In summary, considering the various applications that might be constructed upon eSPI transaction, we thought that the raw packet paradigm might be the first step to start with.

Regards,
Chiawei

#6 lore raw

Re: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Chiawei,

Quoted 3 lines

The eSPI on BMC side is a slave device. Most of time it listen to the Host requests and then react.
This makes it not quite fit to interfaces that act as a master role.

That's a good point, but I don't think it precludes using existing interfaces.

Quoted 7 lines
Quoted 5 lines

1) The VW channel is essentially a GPIO interface, and we have a kernel ?? subsystem to expose GPIOs. We might want to add additional support ?? for in-kernel system event handlers, but that's a minor addition that ?? can be done separately if we don't want that handled by a gpio ?? consumer in userspace.

eSPI VW channel can be used to forward a byte value to/from GPIO.

I'm not referring to the hardware GPIOs that can be connected here, rather the logic values represented over the VW channel. The eSPI master is transferring IO states over the channel, and we could represnt those on the BMC side as "virtual" GPIOs.

If that model doesn't fit though, that's OK, but I think we need some rationale there.

Quoted 11 lines
Quoted 8 lines

2) The out-of-band (OOB) channel provides a way to issue SMBus ?? transactions, so could well provide an i2c controller interface. ?? Additionally, the eSPI specs imply that this is intended to support
?? MCTP - in which case, you'll *need* a kernel i2c controller device to
?? be able to use the new kernel MCTP stack.

Could you share us more information about the i2c need of kernel MCTP kernel stack?

The currently proposed mctp-i2c interface driver binds to a kernel i2c device. If you expose a kernel i2c device here, we can connect that as an MCTP interface.

With the packet interface proposed here, we can't do that, and would need a whole new driver for this, implemented in userspace. The same would apply to any other usage of the i2c bus (EEPROM access, etc).

Quoted 13 lines
Quoted 6 lines

3) The flash channel exposes read/write/erase operations, which would be
?? much more useful as an actual flash-type device, perhaps using the
?? existing mtd interface? Or is there additional functionality ?? expected for this?

The flash channel works in either the Master Attached Flash Sharing (MAFS) or Slave Attached Flash Sharing (SAFS) mode.

For MAFS, BMC issues eSPI flash R/W/E packets to the Host. In this case, it may fit into the MTD interface.

Quoted 8 lines

For SAFS (mostly used), BMC needs to listen, parse and filter eSPI flash R/W/E packets from the Host.
And then send replies in the eSPI success/unsuccess completion packet format.
This behaves differently from MTD.

To support both the two scenario, the MTD interface might not be suitable.

OK, that makes sense. In this case the BMC is acting as the virtual flash device, right?

Quoted 9 lines
Quoted 6 lines

4) The peripheral channel is the only one that would seem to require arbitrary cycle access, but we'll still need a proper uapi definition to support that. At the minimum, your ioctl definitions should go under include/uapi/ - you shouldn't need to duplicate the header into each userspace repo, as you've done for the test examples.

In the first submission, I was told that the include/uapi patch is not going to be accepted.

This is what you were told in the v1 submission:

Quoted 3 lines
Quoted 1 line
 create mode 100644 include/uapi/linux/aspeed-espi.h

This userspace interface is not going to be accepted upstream.

It sees like that was a comment about the API itself, not the location of the header (Rob, correct me if I'm wrong). Simply moving the header out of the uapi directory, while retaining the same API, is not a solution to this.

Quoted 4 lines

In summary, considering the various applications that might be constructed upon eSPI transaction,
we thought that the raw packet paradigm might be the first step to start with.

Keep in mind that you're creating a kernel ABI here, which has to stay in place forever - even if it's the first step to something else, we cannot break future compatibility.

Regards,

Jeremy

#7 lore raw

RE: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Jeremy,

Quoted 10 lines

From: Jeremy Kerr <[email protected]>
Sent: Thursday, September 2, 2021 3:05 PM

Hi Chiawei,

Quoted 3 lines

The eSPI on BMC side is a slave device. Most of time it listen to the Host requests and then react.
This makes it not quite fit to interfaces that act as a master role.

That's a good point, but I don't think it precludes using existing interfaces.

Agree.

Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

1) The VW channel is essentially a GPIO interface, and we have a kernel ?? subsystem to expose GPIOs. We might want to add additional support ?? for in-kernel system event handlers, but that's a minor addition that ?? can be done separately if we don't want that handled by a gpio ?? consumer in userspace.

eSPI VW channel can be used to forward a byte value to/from GPIO. However, the targeted GPIO group and its direction are determined by the Host. This is different from usual GPIO devices as it supports very limited operations.

Quoted 7 lines

I'm not referring to the hardware GPIOs that can be connected here, rather the logic values represented over the VW channel. The eSPI master is transferring IO states over the channel, and we could represnt those on the BMC side as "virtual" GPIOs.

If that model doesn't fit though, that's OK, but I think we need some rationale there.

After an internal discussion, we found that our eSPI VW device may not fit into existing GPIO model.

The reason is that GPIO direction changes through VW channel has no interrupts triggered.
And the direction is controlled by the Host as aforementioned.
Thus a busy polling on GPIO direction register is inevitable to reflect the state timely.
Even though, there is still a chance that BMC will miss GPIO direction changes in the time span of two polling read.

Regarding the current implementation, I should add an additional IOCTL code to read the current GPIO direction.

Quoted 14 lines
Quoted 10 lines
Quoted 9 lines

2) The out-of-band (OOB) channel provides a way to issue SMBus ?? transactions, so could well provide an i2c controller interface. ?? Additionally, the eSPI specs imply that this is intended to support
?? MCTP - in which case, you'll *need* a kernel i2c controller device to
?? be able to use the new kernel MCTP stack.

Quoted 3 lines

Could you share us more information about the i2c need of kernel MCTP kernel stack? To our understanding, the MCTP is a bus agnostic protocol.
A generic raw packet interface makes it more flexible to adapt to different interfaces.

Quoted 7 lines

The currently proposed mctp-i2c interface driver binds to a kernel i2c device. If you expose a kernel i2c device here, we can connect that as an MCTP interface.

With the packet interface proposed here, we can't do that, and would need a whole new driver for this, implemented in userspace. The same would apply to any other usage of the i2c bus (EEPROM access, etc).

Thanks for sharing the information.
However, as mentioned above, MCTP is bus agonistic.
A raw packet, primitive interface should have better flexibility to manage MCTP packets over the OOB channel.

If userspace implementation is reinventing the wheel, we could consider to refer to the IPMI KCS BMC driver of OpenBMC Linux. The driver has both the RAW and IPMI interfaces supported.

But we think this should be the next step.

Quoted 46 lines
Quoted 14 lines
Quoted 7 lines

3) The flash channel exposes read/write/erase operations, which would be
?? much more useful as an actual flash-type device, perhaps using the
?? existing mtd interface? Or is there additional functionality ?? expected for this?

The flash channel works in either the Master Attached Flash Sharing (MAFS) or Slave Attached Flash Sharing (SAFS) mode.

For MAFS, BMC issues eSPI flash R/W/E packets to the Host. In this case, it may fit into the MTD interface.

Quoted 8 lines

For SAFS (mostly used), BMC needs to listen, parse and filter eSPI flash R/W/E packets from the Host.
And then send replies in the eSPI success/unsuccess completion packet format.
This behaves differently from MTD.

To support both the two scenario, the MTD interface might not be suitable.

OK, that makes sense. In this case the BMC is acting as the virtual flash device, right?

Quoted 9 lines
Quoted 6 lines

4) The peripheral channel is the only one that would seem to require arbitrary cycle access, but we'll still need a proper uapi definition to support that. At the minimum, your ioctl definitions should go under include/uapi/ - you shouldn't need to duplicate the header into each userspace repo, as you've done for the test examples.

In the first submission, I was told that the include/uapi patch is not going to be accepted.

This is what you were told in the v1 submission:

Quoted 3 lines
Quoted 1 line
 create mode 100644 include/uapi/linux/aspeed-espi.h

This userspace interface is not going to be accepted upstream.

It sees like that was a comment about the API itself, not the location of the header (Rob, correct me if I'm wrong). Simply moving the header out of the uapi directory, while retaining the same API, is not a solution to this.

Quoted 7 lines
Quoted 3 lines

In summary, considering the various applications that might be constructed upon eSPI transaction, we thought that the raw packet paradigm might be the first step to start with.

Keep in mind that you're creating a kernel ABI here, which has to stay in place forever - even if it's the first step to something else, we cannot break future compatibility.

Understood.
Thanks for giving us these feedback and suggestions.

Regards,
Chiawei

#8 lore raw

Re: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Chiawei,

Quoted 10 lines
Quoted 3 lines

If that model doesn't fit though, that's OK, but I think we need some rationale
there.

After an internal discussion, we found that our eSPI VW device may not fit into existing GPIO model.

The reason is that GPIO direction changes through VW channel has no interrupts triggered.
And the direction is controlled by the Host as aforementioned.

This piqued my curiosity, so I had a look through the 2500 datasheet. It appears that the host has full control of both the direction *and* hardware GPIO assignment though the platform-specific eSPI configuration register set.

So, with VW GPIOs in hardware mode (ESPICTRL[9] = 0, the default), the host has arbitrary control of all hardware GPIO lines (except for the GPIOAC bank, I guess?).

There's a huge security implication there - for example, GPIOs that assert physical presence can now be set by the host, possibly remotely - so I'd *strongly* recommend that we always get ESPICTRL[9] to 1, to set software-only mode.

With than in mind, if we're disabling hardware mode - what does the direction control setting effect when we're in software mode (ESPICTRL[9] == 1)? Does it even matter?

For example, what happens when the host goes a GET_VW cycle for a GPIO that is marked as 'master-to-slave' mode? Is the state of the GPIO in ESPI09C still reported?

If that's the case, then we can just ignore the direction settings from ESPICFG800 completely, and have the BMC assign directions to standard gpiodevs as appropriate.

Separate from this: I'm also proposing that we represent the system event VWs as gpiodevs as well.

Quoted 2 lines

A raw packet, primitive interface should have better flexibility to manage MCTP packets over the OOB channel.

OK, let me phrase this differently: can the OOB channel be used for anything other than SMBus messaging? Is it useful to provide an interface that isn't a standard SMBus/i2c device?

If you need custom uapi definitions for this driver, that might be okay, but it's going to be more work for you (to define an interface that can be supported long-term), rather than using standard infrastructure that already exists.

Cheers,

Jeremy

#9 lore raw

RE: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Jeremy,

Quoted 19 lines

From: Jeremy Kerr <[email protected]>
Sent: Monday, September 6, 2021 11:17 AM

Hi Chiawei,

Quoted 9 lines
Quoted 2 lines

If that model doesn't fit though, that's OK, but I think we need some rationale there.

After an internal discussion, we found that our eSPI VW device may not fit into existing GPIO model.

The reason is that GPIO direction changes through VW channel has no interrupts triggered.
And the direction is controlled by the Host as aforementioned.

This piqued my curiosity, so I had a look through the 2500 datasheet. It appears that the host has full control of both the direction *and* hardware GPIO assignment though the platform-specific eSPI configuration register set.

Quoted 8 lines

So, with VW GPIOs in hardware mode (ESPICTRL[9] = 0, the default), the host has arbitrary control of all hardware GPIO lines (except for the GPIOAC bank, I guess?).

There's a huge security implication there - for example, GPIOs that assert physical presence can now be set by the host, possibly remotely - so I'd *strongly* recommend that we always get ESPICTRL[9] to 1, to set software-only mode.

Yes, there is security concern using HW mode.
Our designer is considering to remove the HW mode support in the next generation of Aspeed SoCs. So far we haven't encountered a scenario demanding HW mode.

Quoted 4 lines

With than in mind, if we're disabling hardware mode - what does the direction control setting effect when we're in software mode (ESPICTRL[9] == 1)? Does it even matter?

Yes, the direction matters even in SW mode.
When the direction is 'master-to-slave' and the GPIO value is updated by the Host through PUT_VW, a VW interrupt is trigger to notify BMC. For the 'slave-to-master' GPIO, a alert is generated to notify the Host to issue GET_VW for the GPIO value updated by the BMC by ESPI09C.

Quoted 4 lines

For example, what happens when the host goes a GET_VW cycle for a GPIO that is marked as 'master-to-slave' mode? Is the state of the GPIO in ESPI09C still reported?

The Host can only issue GET_VW when BMC update one of the 'slave-to-master' GPIO pins and have eSPI status VW_AVAIL set. And the eSPI slave will not report the value of GPIO marked as 'master-to-slave'.

Quoted 4 lines

If that's the case, then we can just ignore the direction settings from ESPICFG800 completely, and have the BMC assign directions to standard gpiodevs as appropriate.

If the direction setting from the Host is ignored, the presented virtual GPIO does not reflect the correct state. Plus that the direction change from the Host has no interrupt to notify BMC.
My concern is that if the gpiodevs way works partially, then it should not be adopted to avoid confusing users.

Quoted 10 lines

Separate from this: I'm also proposing that we represent the system event VWs as gpiodevs as well.

Quoted 2 lines

A raw packet, primitive interface should have better flexibility to manage MCTP packets over the OOB channel.

OK, let me phrase this differently: can the OOB channel be used for anything other than SMBus messaging? Is it useful to provide an interface that isn't a standard SMBus/i2c device?

Yes, the PCH spec. also defines two additional packet format for an eSPI slave to retrieve PCH Temperature Data and RTC time. It should be trivial to prepare a byte buffer in that format and send it through the raw packet interface. Aspeed also have demo APPs described in the header comment.

Quoted 4 lines

If you need custom uapi definitions for this driver, that might be okay, but it's going to be more work for you (to define an interface that can be supported long-term), rather than using standard infrastructure that already exists.

Thus I suggested that we can refer to the IPMI KCS BMC driver, which supports the selection of different user interfaces, RAW or IPMI. If any other interface is needed afterward, the driver can be enhanced in that fashion.
While the eSPI raw packet TX/RX handling is preserved as the primitive operations.

If IOCTL is considered to be not user friendly or magic code polluting, file-based read/write on the miscdevice node is also an option.

#10 lore raw

Re: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Chiawei,

Quoted 4 lines

Yes, there is security concern using HW mode.
Our designer is considering to remove the HW mode support in the next generation of Aspeed SoCs.
So far we haven't encountered a scenario demanding HW mode.

Great to hear :) can we unconditionally set ESPI000[9] in the driver then?

Quoted 10 lines
Quoted 3 lines

With than in mind, if we're disabling hardware mode - what does the direction control setting effect when we're in software mode (ESPICTRL[9] == 1)? Does it even matter?

Yes, the direction matters even in SW mode.
When the direction is 'master-to-slave' and the GPIO value is updated by the Host through PUT_VW, a VW interrupt is trigger to notify BMC. For the 'slave-to-master' GPIO, a alert is generated to notify the Host to issue GET_VW for the GPIO value updated by the BMC by ESPI09C.

OK, but the datasheet mentions that ESPICFG804 is only applicable when ESPI000[9] = 0, or is that not the case?

But based on what you've said: yes, it sounds like the generic gpiodev parts won't be useful for this.

Quoted 8 lines
Quoted 8 lines

Separate from this: I'm also proposing that we represent the system event VWs
as gpiodevs as well.

Quoted 3 lines

A raw packet, primitive interface should have better flexibility to
manage MCTP packets over the OOB channel.

Quoted 8 lines
Quoted 3 lines

OK, let me phrase this differently: can the OOB channel be used for anything other than SMBus messaging? Is it useful to provide an interface that isn't a standard SMBus/i2c device?

Yes, the PCH spec. also defines two additional packet format for an eSPI slave to retrieve PCH Temperature Data and RTC time. It should be trivial to prepare a byte buffer in that format and send it through the raw packet interface.

OK, understood.

Quoted 7 lines
Quoted 4 lines

If you need custom uapi definitions for this driver, that might be okay, but it's going to be more work for you (to define an interface that can be supported long-term), rather than using standard infrastructure that already exists.

Thus I suggested that we can refer to the IPMI KCS BMC driver, which supports the selection of different user interfaces, RAW or IPMI.

Yep, but the KCS "raw" register set is standardised as part of the IPMI spec too, which helps to define a stable user API. We don't have that in this case.

Overall though, if you want to start with the "low-level" API, then introduce "enhanced" functionality - like an actual SMBus driver - alongside that, then that sounds like an OK approach.

Quoted 3 lines

If IOCTL is considered to be not user friendly or magic code polluting, file-based read/write on the miscdevice node is also an option.

It's not really my decision to make, but a read/write event interface would seem to be more consistent to me. Is there an obvious event format that would be common across all channels, perhaps? We'd probably also need a poll too - to make use of incoming events, like master-to-slave VW changes, perhaps?

Cheers,

Jeremy

#11 lore raw

RE: [PATCH v4 3/4] soc: aspeed: Add eSPI driver

Hi Jeremy,

Quoted 9 lines

From: Jeremy Kerr <[email protected]>
Sent: Thursday, September 9, 2021 9:53 AM

Quoted 4 lines

Yes, there is security concern using HW mode.
Our designer is considering to remove the HW mode support in the next generation of Aspeed SoCs.
So far we haven't encountered a scenario demanding HW mode.

Great to hear :) can we unconditionally set ESPI000[9] in the driver then?

Yes for the v5 revision. As HW mode is going to be eliminated in the future. A brief explanation will also be added.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

With than in mind, if we're disabling hardware mode - what does the direction control setting effect when we're in software mode (ESPICTRL[9] == 1)? Does it even matter?

Quoted 8 lines
Quoted 5 lines

Yes, the direction matters even in SW mode.
When the direction is 'master-to-slave' and the GPIO value is updated by the Host through PUT_VW, a VW interrupt is trigger to notify BMC. For the 'slave-to-master' GPIO, a alert is generated to notify the Host to issue GET_VW for the GPIO value updated by the BMC by ESPI09C.

OK, but the datasheet mentions that ESPICFG804 is only applicable when ESPI000[9] = 0, or is that not the case?

Yes, ESPICFG804 is applicable only on HW mode (ESPI000[9]=0).
When the HW mode is selected, the eSPI slave forwards GPIO update in PUT_VW packet sent by the Host to the physical GPIO based on the ESPICFG804 mapping. This is purely done by HW. No interrupts will be generated to notify SW.

Quoted 36 lines

But based on what you've said: yes, it sounds like the generic gpiodev parts won't be useful for this.

Quoted 6 lines
Quoted 6 lines

Separate from this: I'm also proposing that we represent the system event VWs as gpiodevs as well.

Quoted 2 lines

A raw packet, primitive interface should have better flexibility to manage MCTP packets over the OOB channel.

Quoted 8 lines
Quoted 3 lines

OK, let me phrase this differently: can the OOB channel be used for anything other than SMBus messaging? Is it useful to provide an interface that isn't a standard SMBus/i2c device?

Yes, the PCH spec. also defines two additional packet format for an eSPI slave to retrieve PCH Temperature Data and RTC time. It should be trivial to prepare a byte buffer in that format and send it through the raw packet interface.

OK, understood.

Quoted 7 lines
Quoted 4 lines

If you need custom uapi definitions for this driver, that might be okay, but it's going to be more work for you (to define an interface that can be supported long-term), rather than using standard infrastructure that already exists.

Thus I suggested that we can refer to the IPMI KCS BMC driver, which supports the selection of different user interfaces, RAW or IPMI.

Yep, but the KCS "raw" register set is standardised as part of the IPMI spec too, which helps to define a stable user API. We don't have that in this case.

Overall though, if you want to start with the "low-level" API, then introduce "enhanced" functionality - like an actual SMBus driver - alongside that, then that sounds like an OK approach.

Quoted 8 lines
Quoted 3 lines

If IOCTL is considered to be not user friendly or magic code polluting, file-based read/write on the miscdevice node is also an option.

It's not really my decision to make, but a read/write event interface would seem to be more consistent to me. Is there an obvious event format that would be common across all channels, perhaps? We'd probably also need a poll too - to make use of incoming events, like master-to-slave VW changes, perhaps?

A file-based read/write/poll interface is OK to me as well. The main concern is about the peripheral and the VW channels. For the peripheral channel, it takes two miscdevice to export TX/RX interfaces for posted and non-posted packets, respectively. And for the VW channel, the settings GPIO direction is RO and that of GPIO value is RW. And these two should be exported individually.

#12 lore raw

PATCH v4 4/4 ARM: dts: aspeed: Add eSPI node

In reply to Chia-Wei Wang

Add eSPI to the device tree for Aspeed 5/6th generation SoCs.

---
 arch/arm/boot/dts/aspeed-g6.dtsi | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/boot/dts/aspeed-g6.dtsi +17 -0
index f96607b7b4e2..47dc0b3993d1 100644
@@ -364,6 +364,23 @@
 				status = "disabled";
 			};
 
+			espi: espi at 1e6ee000 {
+				compatible = "aspeed,ast2600-espi", "simple-mfd", "syscon";
+				reg = <0x1e6ee000 0x1000>;
+
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0x0 0x1e6ee000 0x1000>;
+
+				espi_ctrl: espi-ctrl at 0 {
+					compatible = "aspeed,ast2600-espi-ctrl";
+					reg = <0x0 0x800>;
+					interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
+					clocks = <&syscon ASPEED_CLK_GATE_ESPICLK>;
+					status = "disabled";
+				};
+			};
+
 			gpio0: gpio at 1e780000 {
 				#gpio-cells = <2>;
 				gpio-controller;
Signature · 1 line
2.17.1
#13 lore raw

Re: [PATCH v4 4/4] ARM: dts: aspeed: Add eSPI node

Hi Chia-Wei,

How is it about g5? Why did you add definition only for g6 here?

Quoted 40 lines · Chia-Wei Wang

Add eSPI to the device tree for Aspeed 5/6th generation SoCs.

---
?arch/arm/boot/dts/aspeed-g6.dtsi | 17 +++++++++++++++++ ?1 file changed, 17 insertions(+)

arch/arm/boot/dts/aspeed-g6.dtsi +0 -0
index f96607b7b4e2..47dc0b3993d1 100644
@@ -364,6 +364,23 @@
 ????????????????????????????????status = "disabled";
 ????????????????????????};

?
+???????????????????????espi: espi at 1e6ee000 { +???????????????????????????????compatible = "aspeed,ast2600-espi", "simple-mfd", "syscon"; +???????????????????????????????reg = <0x1e6ee000 0x1000>;

arch/arm/boot/dts/aspeed-g6.dtsi +7 -0
+
+???????????????????????????????#address-cells = <1>;
+???????????????????????????????#size-cells = <1>;
+???????????????????????????????ranges = <0x0 0x1e6ee000 0x1000>;
+
+???????????????????????????????espi_ctrl: espi-ctrl at 0 {
+???????????????????????????????????????compatible = "aspeed,ast2600-

espi-ctrl"; +???????????????????????????????????????reg = <0x0 0x800>; +???????????????????????????????????????interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>; +???????????????????????????????????????clocks = <&syscon ASPEED_CLK_GATE_ESPICLK>; +???????????????????????????????????????status = "disabled"; +???????????????????????????????}; +???????????????????????};
+
????????????????????????gpio0: gpio at 1e780000 { ????????????????????????????????#gpio-cells = <2>; ????????????????????????????????gpio-controller;

Signature · 2 lines
Best regards,
Andrei Kartashev
#14 lore raw

RE: [PATCH v4 4/4] ARM: dts: aspeed: Add eSPI node

Hi Andrei,

The patch misses the g5 part.
I will fix this in the next revision.

Regards,
Chiawei

Quoted 62 lines

From: Andrei Kartashev <[email protected]>
Sent: Wednesday, November 10, 2021 7:21 PM

Hi Chia-Wei,

How is it about g5? Why did you add definition only for g6 here?

Quoted 13 lines · Chia-Wei Wang

Add eSPI to the device tree for Aspeed 5/6th generation SoCs.

---
?arch/arm/boot/dts/aspeed-g6.dtsi | 17 +++++++++++++++++ ?1 file changed, 17 insertions(+)

arch/arm/boot/dts/aspeed-g6.dtsi +0 -0
index f96607b7b4e2..47dc0b3993d1 100644

arch/arm/boot/dts/aspeed-g6.dtsi line 368

Quoted 5 lines
arch/arm/boot/dts/aspeed-g6.dtsi +2 -0
@@ -364,6 +364,23 @@
 ????????????????????????????????status = "disabled";
 ????????????????????????};
 
+???????????????????????espi: espi at 1e6ee000 {
+???????????????????????????????compatible =

"aspeed,ast2600-espi",

arch/arm/boot/dts/aspeed-g6.dtsi line 370

Quoted 2 lines
arch/arm/boot/dts/aspeed-g6.dtsi +1 -0
 "simple-mfd", "syscon";
+???????????????????????????????reg = <0x1e6ee000

0x1000>;

arch/arm/boot/dts/aspeed-g6.dtsi line 374

Quoted 4 lines
arch/arm/boot/dts/aspeed-g6.dtsi +4 -0
+
+???????????????????????????????#address-cells = <1>;
+???????????????????????????????#size-cells = <1>;
+???????????????????????????????ranges = <0x0 0x1e6ee000

0x1000>;

arch/arm/boot/dts/aspeed-g6.dtsi line 377

Quoted 3 lines
arch/arm/boot/dts/aspeed-g6.dtsi +3 -0
+
+???????????????????????????????espi_ctrl: espi-ctrl at 0 {
+???????????????????????????????????????compatible =

"aspeed,ast2600-

arch/arm/boot/dts/aspeed-g6.dtsi line 379

Quoted 2 lines
arch/arm/boot/dts/aspeed-g6.dtsi +1 -0
 espi-ctrl";
+???????????????????????????????????????reg = <0x0

0x800>;

arch/arm/boot/dts/aspeed-g6.dtsi line 380

Quoted 1 line
arch/arm/boot/dts/aspeed-g6.dtsi +1 -0
+???????????????????????????????????????interrupts =

<GIC_SPI 42

arch/arm/boot/dts/aspeed-g6.dtsi line 382

Quoted 2 lines
arch/arm/boot/dts/aspeed-g6.dtsi +1 -0
 IRQ_TYPE_LEVEL_HIGH>;
+???????????????????????????????????????clocks =

<&syscon

Quoted 2 lines

ASPEED_CLK_GATE_ESPICLK>;
+???????????????????????????????????????status =

"disabled";

Quoted 6 lines

+???????????????????????????????}; +???????????????????????};
+
????????????????????????gpio0: gpio at 1e780000 { ????????????????????????????????#gpio-cells = <2>; ????????????????????????????????gpio-controller;

--
Best regards,
Andrei Kartashev