Skip to contentSkip to conversation

arm: aspeed: Add eSPI support

PATCH Superseded Chia-Wei Wang 3 participants 10 messages Aug 19, 2021 – Aug 23, 2021

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 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.

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 (5):
dt-bindings: aspeed: Add eSPI controller
MAINTAINER: Add ASPEED eSPI driver entry
clk: aspeed: Add eSPI reset bit
soc: aspeed: Add eSPI driver
ARM: dts: aspeed: Add eSPI node

 .../devicetree/bindings/soc/aspeed/espi.yaml  | 158 +++++
 MAINTAINERS                                   |   9 +
 arch/arm/boot/dts/aspeed-g6.dtsi              |  17 +
 drivers/soc/aspeed/Kconfig                    |  11 +
 drivers/soc/aspeed/Makefile                   |   1 +
 drivers/soc/aspeed/aspeed-espi-ctrl.c         | 206 ++++++
 drivers/soc/aspeed/aspeed-espi-ctrl.h         | 304 +++++++++
 drivers/soc/aspeed/aspeed-espi-flash.h        | 380 +++++++++++
 drivers/soc/aspeed/aspeed-espi-ioc.h          | 153 +++++
 drivers/soc/aspeed/aspeed-espi-oob.h          | 611 ++++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-perif.h        | 512 +++++++++++++++
 drivers/soc/aspeed/aspeed-espi-vw.h           | 142 ++++
 include/dt-bindings/clock/ast2600-clock.h     |   1 +
 13 files changed, 2505 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.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ioc.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-perif.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/5 dt-bindings: aspeed: Add eSPI controller

Add dt-bindings for Aspeed eSPI controller

---
 .../devicetree/bindings/soc/aspeed/espi.yaml  | 158 ++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml
Documentation/devicetree/bindings/soc/aspeed/espi.yaml new file +158 -0
new file mode 100644
index 000000000000..fec3d37f3ffd
@@ -0,0 +1,158 @@
+# 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
+
+  espi-ctrl:
+    type: object
+
+    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:
+    type: object
+
+    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>;
+            resets = <&syscon ASPEED_RESET_ESPI>;
+        };
+
+        espi_mmbi: espi-flash-channel at 800 {
+            compatible = "aspeed,ast2600-espi-flash";
+            reg = <0x800 0x50>;
+            interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+        };
+    };
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v2 1/5] dt-bindings: aspeed: Add eSPI controller

Quoted 8 lines · Chia-Wei Wang

Add dt-bindings for Aspeed eSPI controller

---
 .../devicetree/bindings/soc/aspeed/espi.yaml  | 158 ++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/soc/aspeed/espi.example.dts:35.35-36 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:380: Documentation/devicetree/bindings/soc/aspeed/espi.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1419: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1518493

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

maintainer
#3 lore raw

Re: [PATCH v2 1/5] dt-bindings: aspeed: Add eSPI controller

In reply to Chia-Wei Wang
Quoted 30 lines · Chia-Wei Wang

Add dt-bindings for Aspeed eSPI controller

---
 .../devicetree/bindings/soc/aspeed/espi.yaml  | 158 ++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml
Documentation/devicetree/bindings/soc/aspeed/espi.yaml new file +16 -0
new file mode 100644
index 000000000000..fec3d37f3ffd
@@ -0,0 +1,158 @@
+# 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,

Documentation/devicetree/bindings/soc/aspeed/espi.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/soc/aspeed/espi.yaml new file +10 -0
+  out-of-band, and flash.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - aspeed,ast2500-espi
+          - aspeed,ast2600-espi
+      - const: simple-mfd
+      - const: syscon

Is this really 2 sub devices that could be used individually or in a different combination? If not, then I'd make all this 1 node.

Rob

#4 lore raw

RE: [PATCH v2 1/5] dt-bindings: aspeed: Add eSPI controller

Hi Rob,

Quoted 49 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Saturday, August 21, 2021 4:02 AM
To: ChiaWei Wang <[email protected]>
Cc: joel at jms.id.au; andrew at aj.id.au; linux-aspeed at lists.ozlabs.org; openbmc at lists.ozlabs.org; devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; Ryan Chen <[email protected]>
Subject: Re: [PATCH v2 1/5] dt-bindings: aspeed: Add eSPI controller

Quoted 38 lines · Chia-Wei Wang

Add dt-bindings for Aspeed eSPI controller

---
 .../devicetree/bindings/soc/aspeed/espi.yaml  | 158
++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/soc/aspeed/espi.yaml

Documentation/devicetree/bindings/soc/aspeed/espi.yaml new file +21 -0
new file mode 100644
index 000000000000..fec3d37f3ffd
@@ -0,0 +1,158 @@
+# 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:
Quoted 8 lines

Documentation/devicetree/bindings/soc/aspeed/espi.yaml line 26

Quoted 5 lines
Documentation/devicetree/bindings/soc/aspeed/espi.yaml new file +5 -0
+      - enum:
+          - aspeed,ast2500-espi
+          - aspeed,ast2600-espi
+      - const: simple-mfd
+      - const: syscon

Is this really 2 sub devices that could be used individually or in a different combination? If not, then I'd make all this 1 node.

espi-mmbi has individual function and control registers.
However, espi-mmbi is also a feature extended based on the memory cycle of eSPI peripheral channel. Thereby, it has dependency on the eSPI channel initialization conducted by espi-ctrl. The scenario is similar to the lpc-ctrl and other lpc-xxx drivers of Aspeed SoCs.

Chiawei

#5 lore raw

PATCH v2 2/5 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 fd25e4ecf0b9..b21bcb46692e 100644
@@ -1713,6 +1713,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
#6 lore raw

PATCH v2 3/5 clk: aspeed: Add eSPI reset bit

In reply to Chia-Wei Wang

Add bit field definition for the eSPI reset control

---
 include/dt-bindings/clock/ast2600-clock.h | 1 +
 1 file changed, 1 insertion(+)
include/dt-bindings/clock/ast2600-clock.h +1 -0
index 62b9520a00fd..964934b1caef 100644
@@ -89,6 +89,7 @@
 #define ASPEED_CLK_MAC4RCLK		70
 
 /* Only list resets here that are not part of a gate */
+#define ASPEED_RESET_ESPI		57
 #define ASPEED_RESET_ADC		55
 #define ASPEED_RESET_JTAG_MASTER2	54
 #define ASPEED_RESET_I3C_DMA		39
Signature · 1 line
2.17.1
#7 lore raw

PATCH v2 4/5 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            |   1 +
 drivers/soc/aspeed/aspeed-espi-ctrl.c  | 206 +++++++++
 drivers/soc/aspeed/aspeed-espi-ctrl.h  | 304 ++++++++++++
 drivers/soc/aspeed/aspeed-espi-flash.h | 380 +++++++++++++++
 drivers/soc/aspeed/aspeed-espi-ioc.h   | 153 +++++++
 drivers/soc/aspeed/aspeed-espi-oob.h   | 611 +++++++++++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-perif.h | 512 +++++++++++++++++++++
 drivers/soc/aspeed/aspeed-espi-vw.h    | 142 ++++++
 9 files changed, 2320 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.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-ioc.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.h
 create mode 100644 drivers/soc/aspeed/aspeed-espi-perif.h
 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 +1 -0
index fcab7192e1a4..650d8de2875d 100644
@@ -3,3 +3,4 @@ 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
drivers/soc/aspeed/aspeed-espi-ctrl.c new file +206 -0

206 lines not on this page · raw message

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

304 lines not on this page · raw message

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

380 lines not on this page · raw message

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

153 lines not on this page · raw message

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

611 lines not on this page · raw message

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

512 lines not on this page · raw message

drivers/soc/aspeed/aspeed-espi-vw.h new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
2.17.1
#8 lore raw

Re: [PATCH v2 4/5] soc: aspeed: Add eSPI driver

I love your patch! Yet something to improve:

Hi Chia-Wei,

I love your patch! Yet something to improve:

[auto build test ERROR on robh/for-next]
[also build test ERROR on arm/for-next keystone/next soc/for-next rockchip/for-next arm64/for-next/core linus/master joel-aspeed/for-next v5.14-rc6 next-20210819] [cannot apply to xlnx/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Chia-Wei-Wang/arm-aspeed-Add-eSPI-support/20210819-160303
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/cd398492dc8a9d27e1f7b546f1f4df371f058566
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Chia-Wei-Wang/arm-aspeed-Add-eSPI-support/20210819-160303 git checkout cd398492dc8a9d27e1f7b546f1f4df371f058566
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

In file included from drivers/soc/aspeed/aspeed-espi-ctrl.c:21:
drivers/soc/aspeed/aspeed-espi-perif.h: In function 'aspeed_espi_perif_pc_get_rx':

>> drivers/soc/aspeed/aspeed-espi-perif.h:106:15: error: implicit declaration of function 'vmalloc'; did you mean 'kvmalloc'? [-Werror=implicit-function-declaration]
     106 |         pkt = vmalloc(pkt_len);
         |               ^~~~~~~
         |               kvmalloc
>> drivers/soc/aspeed/aspeed-espi-perif.h:106:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     106 |         pkt = vmalloc(pkt_len);
         |             ^
   drivers/soc/aspeed/aspeed-espi-perif.h: In function 'aspeed_espi_perif_pc_put_tx':
   drivers/soc/aspeed/aspeed-espi-perif.h:163:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     163 |         pkt = vmalloc(ioc->pkt_len);
         |             ^
>> drivers/soc/aspeed/aspeed-espi-perif.h:202:9: error: implicit declaration of function 'vfree'; did you mean 'kfree'? [-Werror=implicit-function-declaration]
     202 |         vfree(pkt);
         |         ^~~~~
         |         kfree
   drivers/soc/aspeed/aspeed-espi-perif.h: In function 'aspeed_espi_perif_np_put_tx':
   drivers/soc/aspeed/aspeed-espi-perif.h:230:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     230 |         pkt = vmalloc(ioc->pkt_len);
         |             ^
   In file included from drivers/soc/aspeed/aspeed-espi-ctrl.c:23:
   drivers/soc/aspeed/aspeed-espi-oob.h: In function 'aspeed_espi_oob_dma_desc_get_rx':
>> drivers/soc/aspeed/aspeed-espi-oob.h:106:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     106 |         pkt = vmalloc(pkt_len);
         |             ^
   drivers/soc/aspeed/aspeed-espi-oob.h: In function 'aspeed_espi_oob_get_rx':
   drivers/soc/aspeed/aspeed-espi-oob.h:203:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     203 |         pkt = vmalloc(pkt_len);
         |             ^
   drivers/soc/aspeed/aspeed-espi-oob.h: In function 'aspeed_espi_oob_dma_desc_put_tx':
>> drivers/soc/aspeed/aspeed-espi-oob.h:262:15: error: implicit declaration of function 'vzalloc'; did you mean 'kvzalloc'? [-Werror=implicit-function-declaration]
     262 |         pkt = vzalloc(ioc->pkt_len);
         |               ^~~~~~~
         |               kvzalloc
   drivers/soc/aspeed/aspeed-espi-oob.h:262:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     262 |         pkt = vzalloc(ioc->pkt_len);
         |             ^
   drivers/soc/aspeed/aspeed-espi-oob.h: In function 'aspeed_espi_oob_put_tx':
   drivers/soc/aspeed/aspeed-espi-oob.h:334:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     334 |         pkt = vmalloc(ioc->pkt_len);
         |             ^
   In file included from drivers/soc/aspeed/aspeed-espi-ctrl.c:24:
   drivers/soc/aspeed/aspeed-espi-flash.h: In function 'aspeed_espi_flash_get_rx':
>> drivers/soc/aspeed/aspeed-espi-flash.h:119:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     119 |         pkt = vmalloc(pkt_len);
         |             ^
   drivers/soc/aspeed/aspeed-espi-flash.h: In function 'aspeed_espi_flash_put_tx':
   drivers/soc/aspeed/aspeed-espi-flash.h:186:13: warning: assignment to 'uint8_t *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     186 |         pkt = vmalloc(ioc->pkt_len);
         |             ^
   drivers/soc/aspeed/aspeed-espi-ctrl.c: In function 'aspeed_espi_ctrl_probe':
   drivers/soc/aspeed/aspeed-espi-ctrl.c:93:24: warning: unused variable 'scu' [-Wunused-variable]
      93 |         struct regmap *scu;
         |                        ^~~
   drivers/soc/aspeed/aspeed-espi-ctrl.c:90:18: warning: unused variable 'reg' [-Wunused-variable]
      90 |         uint32_t reg;
         |                  ^~~

cc1: some warnings being treated as errors

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SND_ATMEL_SOC_PDC
Depends on SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && HAS_DMA Selected by
- SND_ATMEL_SOC_SSC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC
- SND_ATMEL_SOC_SSC_PDC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && ATMEL_SSC

vim +106 drivers/soc/aspeed/aspeed-espi-perif.h

    46	
    47	static long aspeed_espi_perif_pc_get_rx(struct file *fp,
    48						struct aspeed_espi_ioc *ioc,
    49						struct aspeed_espi_perif *espi_perif)
    50	{
    51		int i, rc;
    52		uint32_t reg;
    53		uint32_t cyc, tag, len;
    54		uint8_t *pkt;
    55		uint32_t pkt_len;
    56		struct espi_comm_hdr *hdr;
    57		unsigned long flags;
    58		struct aspeed_espi_ctrl *espi_ctrl = espi_perif->ctrl;
    59	
    60		if (!espi_perif->rx_ready) {
    61			if (fp->f_flags & O_NONBLOCK)
    62				return -ENODATA;
    63	
    64			rc = wait_event_interruptible(espi_perif->wq, espi_perif->rx_ready);
    65			if (rc == -ERESTARTSYS)
    66				return -EINTR;
    67		}
    68	
    69		/* common header (i.e. cycle type, tag, and length) is taken by HW */
    70		regmap_read(espi_ctrl->map, ESPI_PERIF_PC_RX_CTRL, &reg);
    71		cyc = (reg & ESPI_PERIF_PC_RX_CTRL_CYC_MASK) >> ESPI_PERIF_PC_RX_CTRL_CYC_SHIFT;
    72		tag = (reg & ESPI_PERIF_PC_RX_CTRL_TAG_MASK) >> ESPI_PERIF_PC_RX_CTRL_TAG_SHIFT;
    73		len = (reg & ESPI_PERIF_PC_RX_CTRL_LEN_MASK) >> ESPI_PERIF_PC_RX_CTRL_LEN_SHIFT;
    74	
    75		/*
    76		 * calculate the length of the rest part of the
    77		 * eSPI packet to be read from HW and copied to
    78		 * user space.
    79		 */
    80		switch (cyc) {
    81		case ESPI_PERIF_MSG:
    82			pkt_len = len + sizeof(struct espi_perif_msg);
    83			break;
    84		case ESPI_PERIF_MSG_D:
    85			pkt_len = ((len) ? len : ESPI_PLD_LEN_MAX) +
    86				  sizeof(struct espi_perif_msg);
    87			break;
    88		case ESPI_PERIF_SUC_CMPLT_D_MIDDLE:
    89		case ESPI_PERIF_SUC_CMPLT_D_FIRST:
    90		case ESPI_PERIF_SUC_CMPLT_D_LAST:
    91		case ESPI_PERIF_SUC_CMPLT_D_ONLY:
    92			pkt_len = ((len) ? len : ESPI_PLD_LEN_MAX) +
    93				  sizeof(struct espi_perif_cmplt);
    94			break;
    95		case ESPI_PERIF_SUC_CMPLT:
    96		case ESPI_PERIF_UNSUC_CMPLT:
    97			pkt_len = len + sizeof(struct espi_perif_cmplt);
    98			break;
    99		default:
   100			return -EFAULT;
   101		}
   102	
   103		if (ioc->pkt_len < pkt_len)
   104			return -EINVAL;
   105	
 > 106		pkt = vmalloc(pkt_len);
   107		if (!pkt)
   108			return -ENOMEM;
   109	
   110		hdr = (struct espi_comm_hdr *)pkt;
   111		hdr->cyc = cyc;
   112		hdr->tag = tag;
   113		hdr->len_h = len >> 8;
   114		hdr->len_l = len & 0xff;
   115	
   116		if (espi_perif->dma_mode) {
   117			memcpy(hdr + 1, espi_perif->dma.pc_rx_virt,
   118			       pkt_len - sizeof(*hdr));
   119		} else {
   120			for (i = sizeof(*hdr); i < pkt_len; ++i) {
   121				regmap_read(espi_ctrl->map,
   122					    ESPI_PERIF_PC_RX_PORT, &reg);
   123				pkt[i] = reg & 0xff;
   124			}
   125		}
   126	
   127		if (copy_to_user((void __user *)ioc->pkt, pkt, pkt_len))
   128			return -EFAULT;
   129	
   130		spin_lock_irqsave(&espi_perif->rx_lock, flags);
   131	
   132		regmap_write_bits(espi_ctrl->map, ESPI_PERIF_PC_RX_CTRL,
   133				  ESPI_PERIF_PC_RX_CTRL_PEND_SERV,
   134				  ESPI_PERIF_PC_RX_CTRL_PEND_SERV);
   135	
   136		espi_perif->rx_ready = 0;
   137	
   138		spin_unlock_irqrestore(&espi_perif->rx_lock, flags);
   139	
   140		return pkt_len;
   141	}
   142	
   143	static long aspeed_espi_perif_pc_put_tx(struct file *fp,
   144						struct aspeed_espi_ioc *ioc,
   145						struct aspeed_espi_perif *espi_perif)
   146	{
   147		int i, rc = 0;
   148		uint32_t reg;
   149		uint32_t cyc, tag, len;
   150		uint8_t *pkt;
   151		struct espi_comm_hdr *hdr;
   152		struct aspeed_espi_ctrl *espi_ctrl = espi_perif->ctrl;
   153	
   154		if (!mutex_trylock(&espi_perif->pc_tx_lock))
   155			return -EAGAIN;
   156	
   157		regmap_read(espi_ctrl->map, ESPI_PERIF_PC_TX_CTRL, &reg);
   158		if (reg & ESPI_PERIF_PC_TX_CTRL_TRIGGER) {
   159			rc = -EBUSY;
   160			goto unlock_n_out;
   161		}
   162	
   163		pkt = vmalloc(ioc->pkt_len);
   164		if (!pkt) {
   165			rc = -ENOMEM;
   166			goto unlock_n_out;
   167		}
   168	
   169		hdr = (struct espi_comm_hdr *)pkt;
   170	
   171		if (copy_from_user(pkt, (void __user *)ioc->pkt, ioc->pkt_len)) {
   172			rc = -EFAULT;
   173			goto free_n_out;
   174		}
   175	
   176		/*
   177		 * common header (i.e. cycle type, tag, and length)
   178		 * part is written to HW registers
   179		 */
   180		if (espi_perif->dma_mode) {
   181			memcpy(espi_perif->dma.pc_tx_virt, hdr + 1,
   182			       ioc->pkt_len - sizeof(*hdr));
   183			dma_wmb();
   184		} else {
   185			for (i = sizeof(*hdr); i < ioc->pkt_len; ++i)
   186				regmap_write(espi_ctrl->map,
   187					     ESPI_PERIF_PC_TX_PORT, pkt[i]);
   188		}
   189	
   190		cyc = hdr->cyc;
   191		tag = hdr->tag;
   192		len = (hdr->len_h << 8) | (hdr->len_l & 0xff);
   193	
   194		reg = ((cyc << ESPI_PERIF_PC_TX_CTRL_CYC_SHIFT) & ESPI_PERIF_PC_TX_CTRL_CYC_MASK)
   195			| ((tag << ESPI_PERIF_PC_TX_CTRL_TAG_SHIFT) & ESPI_PERIF_PC_TX_CTRL_TAG_MASK)
   196			| ((len << ESPI_PERIF_PC_TX_CTRL_LEN_SHIFT) & ESPI_PERIF_PC_TX_CTRL_LEN_MASK)
   197			| ESPI_PERIF_PC_TX_CTRL_TRIGGER;
   198	
   199		regmap_write(espi_ctrl->map, ESPI_PERIF_PC_TX_CTRL, reg);
   200	
   201	free_n_out:
 > 202		vfree(pkt);

203
204 unlock_n_out:
205 mutex_unlock(&espi_perif->pc_tx_lock);
206
207 return rc;
208 }
209

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all at lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 55035 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linux-aspeed/attachments/20210820/76379540/attachment-0001.gz>

#9 lore raw

PATCH v2 5/5 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