arm: aspeed: Add eSPI support
cover arm: aspeed: Add eSPI support
This patch series add the driver support for the eSPI controller of Aspeed 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.
Chia-Wei, Wang (6):
dt-bindings: aspeed: Add eSPI controller
MAINTAINER: Add ASPEED eSPI driver entry
clk: ast2600: Add eSPI reset bit irqchip/aspeed: Add Aspeed eSPI interrupt controller
soc: aspeed: Add eSPI driver
ARM: dts: aspeed: Add AST2600 eSPI nodes
.../devicetree/bindings/soc/aspeed/espi.yaml | 252 +++++++ MAINTAINERS | 14 + arch/arm/boot/dts/aspeed-g6.dtsi | 57 ++ drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-aspeed-espi-ic.c | 251 +++++++ drivers/soc/aspeed/Kconfig | 49 ++ drivers/soc/aspeed/Makefile | 5 + drivers/soc/aspeed/aspeed-espi-ctrl.c | 197 +++++ drivers/soc/aspeed/aspeed-espi-flash.c | 490 ++++++++++++ drivers/soc/aspeed/aspeed-espi-oob.c | 706 ++++++++++++++++++ drivers/soc/aspeed/aspeed-espi-peripheral.c | 613 +++++++++++++++ drivers/soc/aspeed/aspeed-espi-vw.c | 211 ++++++ include/dt-bindings/clock/ast2600-clock.h | 1 + .../interrupt-controller/aspeed-espi-ic.h | 15 + include/soc/aspeed/espi.h | 279 +++++++ include/uapi/linux/aspeed-espi.h | 160 ++++ 16 files changed, 3301 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml create mode 100644 drivers/irqchip/irq-aspeed-espi-ic.c create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c create mode 100644 drivers/soc/aspeed/aspeed-espi-peripheral.c create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.c create mode 100644 include/dt-bindings/interrupt-controller/aspeed-espi-ic.h create mode 100644 include/soc/aspeed/espi.h create mode 100644 include/uapi/linux/aspeed-espi.h
Signature · 1 line
2.17.1
PATCH 1/6 dt-bindings: aspeed: Add eSPI controller
Add dt-bindings and the inclusion header for Aspeed eSPI controller.
--- .../devicetree/bindings/soc/aspeed/espi.yaml | 252 ++++++++++++++++++ .../interrupt-controller/aspeed-espi-ic.h | 15 ++ 2 files changed, 267 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml create mode 100644 include/dt-bindings/interrupt-controller/aspeed-espi-ic.h
Documentation/devicetree/bindings/soc/aspeed/espi.yaml new file +252 -0
@@ -0,0 +1,252 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# # Copyright (c) 2020 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,ast2600-espi + - const: simple-mfd + - const: syscon + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + + ranges: true + + espi-ic: + type: object + + properties: + compatible: + const: aspeed,ast2600-espi-ic + + interrupts: + maxItems: 2 + + interrupt-controller: true + + "#interrupt-cells": + const: 1 + description: + The cell is a SW-encoded number for IRQ dispatching to eSPI channels + + required: + - compatible + - interrupts + - interrupt-controller + - "#interrupt-cells" + + espi-ctrl: + type: object + + properties: + compatible: + const: aspeed,ast2600-espi-ctrl + + interrupts: + maxItems: 2 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + required: + - compatible + - interrupts + - clocks + - resets + + espi-peripheral-channel: + type: object + + properties: + compatible: + const: aspeed,ast2600-espi-peripheral + + interrupts: + maxItems: 2 + + dma-mode: + type: boolean + + memcyc,map-src-addr: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: The host side address to be decoded into the memory cycle over eSPI peripheral channel + + memcyc,map-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 + + required: + - compatible + - interrupts + - memcyc,map-src-addr + - memcyc,map-size + + espi-vw-channel: + type: object + + properties: + compatible: + const: aspeed,ast2600-espi-vw + + interrupts: + maxItems: 2 + + required: + - compatible + - interrupts + + espi-oob-channel: + type: object + + properties: + compatible: + const: aspeed,ast2600-espi-oob + + interrupts: + maxItems: 2 + + dma-mode: + type: boolean + + dma-tx-desc-num: + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 2 + maximum: 1023 + + dma-rx-desc-num: + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 2 + maximum: 1023 + + required: + - compatible + - interrupts + + espi-flash-channel: + type: object + + properties: + compatible: + const: aspeed,ast2600-espi-flash + + interrupts: + maxItems: 2 + + dma-mode: + type: boolean + + safs-mode: + description: Slave-Attached-Sharing-Flash mode, 0->Mix, 1->SW, 2->HW + enum: [ 0, 1, 2 ] + + required: + - compatible + - interrupts + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + - ranges + - espi-ic + - espi-ctrl + - espi-peripheral-channel + - espi-vw-channel + - espi-oob-channel + - espi-flash-channel + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/aspeed-espi-ic.h> + #include <dt-bindings/clock/ast2600-clock.h> + #include <dt-bindings/gpio/aspeed-gpio.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_ic: espi-ic { + #interrupt-cells = <1>; + compatible = "aspeed,ast2600-espi-ic"; + interrupts-extended = <&gic GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>, + <&gpio0 ASPEED_GPIO(W, 7) IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + }; + + espi_ctrl: espi-ctrl { + compatible = "aspeed,ast2600-espi-ctrl"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_CTRL_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CTRL_RESET>; + clocks = <&syscon ASPEED_CLK_GATE_ESPICLK>; + resets = <&syscon ASPEED_RESET_ESPI>; + }; + + espi_peripheral: espi-peripheral-channel { + compatible = "aspeed,ast2600-espi-peripheral"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_PERIF_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + dma-mode; + memcyc,map-src-addr = <0x98000000>; + memcyc,map-size = <0x10000>; + }; + + espi_vw: espi-vw-channel { + compatible = "aspeed,ast2600-espi-vw"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_VW_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + }; + + espi_oob: espi-oob-channel { + compatible = "aspeed,ast2600-espi-oob"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_OOB_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + dma-mode; + dma-tx-desc-num = <2>; + dma-rx-desc-num = <2>; + }; + + espi_flash: espi-flash-channel { + compatible = "aspeed,ast2600-espi-flash"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_FLASH_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + dma-mode; + safs-mode = <2>; + }; + }; + +...
include/dt-bindings/interrupt-controller/aspeed-espi-ic.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_ASPEED_ESPI_IC_H_ +#define _DT_BINDINGS_INTERRUPT_CONTROLLER_ASPEED_ESPI_IC_H_ + +/* SW-decoded IRQs for eSPI host HW reset and channel events */ +#define ASPEED_ESPI_IC_CTRL_RESET 0 +#define ASPEED_ESPI_IC_CHAN_RESET 1 +#define ASPEED_ESPI_IC_CTRL_EVENT 2 +#define ASPEED_ESPI_IC_PERIF_EVENT 3 +#define ASPEED_ESPI_IC_VW_EVENT 4 +#define ASPEED_ESPI_IC_OOB_EVENT 5 +#define ASPEED_ESPI_IC_FLASH_EVENT 6 + +#endif
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH 1/6] dt-bindings: aspeed: Add eSPI controller
Quoted 10 lines · Wang
Add dt-bindings and the inclusion header for Aspeed eSPI controller.
Signed-off-by Chia-Wei, Wang <[email protected]>--- .../devicetree/bindings/soc/aspeed/espi.yaml | 252 ++++++++++++++++++ .../interrupt-controller/aspeed-espi-ic.h | 15 ++ 2 files changed, 267 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml create mode 100644 include/dt-bindings/interrupt-controller/aspeed-espi-ic.h
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/soc/aspeed/espi.example.dts:45.35-36 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:344: Documentation/devicetree/bindings/soc/aspeed/espi.example.dt.yaml] Error 1
make: *** [Makefile:1370: dt_binding_check] Error 2
See https://patchwork.ozlabs.org/patch/1422809
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.
RE: [PATCH 1/6] dt-bindings: aspeed: Add eSPI controller
Hi Rob,
Quoted 38 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Wednesday, January 6, 2021 11:08 PM
To: ChiaWei Wang <[email protected]>
Subject: Re: [PATCH 1/6] dt-bindings: aspeed: Add eSPI controllerQuoted 5 lines · Wang
Add dt-bindings and the inclusion header for Aspeed eSPI controller.
Signed-off-by Chia-Wei, Wang <[email protected]>--- .../devicetree/bindings/soc/aspeed/espi.yaml | 252++++++++++++++++++
Quoted 7 lines
.../interrupt-controller/aspeed-espi-ic.h | 15 ++ 2 files changed, 267 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/aspeed/espi.yaml create mode 100644
include/dt-bindings/interrupt-controller/aspeed-espi-ic.hMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
dtschema/dtc warnings/errors:
Error:
Documentation/devicetree/bindings/soc/aspeed/espi.example.dts:45.35-36 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:344:Documentation/devicetree/bindings/soc/aspeed/espi.example.dt.yaml] Error 1
make: *** [Makefile:1370:dt_binding_check] Error 2See https://patchwork.ozlabs.org/patch/1422809
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
Quoted 7 lines
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.
My 'make dt_binding_check' did not show the error. I will update the tool as suggested to fix the error. Thanks.
PATCH 2/6 MAINTAINER: Add ASPEED eSPI driver entry
In reply to Chia-Wei, WangAdd myself and Ryan Chen as maintainer of the Aspeed eSPI driver and the associated eSPI interrupt controller. Joel Stanley is also added as the reviewer.
--- MAINTAINERS | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
MAINTAINERS +14 -0
@@ -1639,6 +1639,20 @@ 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 +F: drivers/irqchip/irq-aspeed-espi-ic.c +F: drivers/soc/aspeed/aspeed-espi* +F: include/dt-bindings/interrupt-controller/aspeed-espi-ic.h +F: include/soc/aspeed/espi.h +F: include/uapi/linux/aspeed-espi.h + ARM/ASPEED I2C DRIVER M: Brendan Higgins <[email protected]> R: Benjamin Herrenschmidt <[email protected]>
Signature · 1 line
2.17.1
PATCH 3/6 clk: ast2600: Add eSPI reset bit
In reply to Chia-Wei, WangAdd 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
@@ -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
PATCH 4/6 irqchip/aspeed: Add Aspeed eSPI interrupt controller
In reply to Chia-Wei, WangThe eSPI interrupt controller acts as a SW IRQ number decoder to correctly control/dispatch interrupts of the eSPI peripheral, virtual wire, out-of-band, and flash channels.
--- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-aspeed-espi-ic.c | 251 ++++++++++++++++++++++++ include/soc/aspeed/espi.h | 279 +++++++++++++++++++++++++++ 3 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-aspeed-espi-ic.c create mode 100644 include/soc/aspeed/espi.h
drivers/irqchip/Makefile +1 -1
@@ -86,7 +86,7 @@ obj-$(CONFIG_MVEBU_PIC) += irq-mvebu-pic.o obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o -obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o irq-aspeed-scu-ic.o +obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o irq-aspeed-scu-ic.o irq-aspeed-espi-ic.o obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.o
drivers/irqchip/irq-aspeed-espi-ic.c new file +251 -0
251 lines not on this page · raw message
include/soc/aspeed/espi.h new file +279 -0
279 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controller
Quoted 72 lines · Wang
The eSPI interrupt controller acts as a SW IRQ number decoder to correctly control/dispatch interrupts of the eSPI peripheral, virtual wire, out-of-band, and flash channels.
Signed-off-by Chia-Wei, Wang <[email protected]>--- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-aspeed-espi-ic.c | 251 ++++++++++++++++++++++++ include/soc/aspeed/espi.h | 279 +++++++++++++++++++++++++++ 3 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-aspeed-espi-ic.c create mode 100644 include/soc/aspeed/espi.hdrivers/irqchip/Makefile +0
-1@@ -86,7 +86,7 @@ obj-$(CONFIG_MVEBU_PIC) += irq-mvebu-pic.o obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o -obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.oirq-aspeed-scu-ic.o
+obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o
irq-aspeed-scu-ic.o irq-aspeed-espi-ic.o
obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o
obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.odrivers/irqchip/irq-aspeed-espi-ic.c new file +36
-0@@ -0,0 +1,251 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Aspeed Technology Inc. +*/ +#include <linux/bitops.h> +#include <linux/module.h> +#include <linux/irq.h> +#include <linux/irqchip.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/interrupt.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> +#include <linux/of.h> +#include <linux/of_platform.h> + +#include <soc/aspeed/espi.h> +#include <dt-bindings/interrupt-controller/aspeed-espi-ic.h> + +#define DEVICE_NAME "aspeed-espi-ic" +#define IRQCHIP_NAME "eSPI-IC" + +#define ESPI_IC_IRQ_NUM 7 + +struct aspeed_espi_ic { +struct regmap *map; +int irq; +int gpio_irq; +struct irq_domain *irq_domain; +}; + +static void aspeed_espi_ic_gpio_isr (struct irq_desc *desc) +{ +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc);
drivers/irqchip/irq-aspeed-espi-ic.c line 46
Quoted 10 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +10
-0+ +chained_irq_enter (chip, desc); + + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_RESET ); +generic_handle_irq (irq); + + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CHAN_RESET ); +generic_handle_irq (irq);
So for each mux interrupt, you generate two endpoints interrupt, without even checking whether they are pending? That's no good.
Quoted 34 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +34
-0+ +chained_irq_exit (chip, desc); +} + +static void aspeed_espi_ic_isr (struct irq_desc *desc) +{ +unsigned int sts; +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); + +chained_irq_enter (chip, desc); + +regmap_read (espi_ic->map,ESPI_INT_STS , &sts); + +if (sts &ESPI_INT_STS_PERIF_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_PERIF_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_VW_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_VW_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_OOB_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_OOB_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_FLASH_BITS ) {
drivers/irqchip/irq-aspeed-espi-ic.c line 90
Quoted 10 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +10
-0+ irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_FLASH_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_HW_RST_DEASSERT ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_EVENT ); +generic_handle_irq (irq); + }
This is horrible. Why can't you just use fls() in a loop?
Quoted 21 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +21
-0+ +chained_irq_exit (chip, desc); +} + +static void aspeed_espi_ic_irq_disable (struct irq_data *data) +{ +struct aspeed_espi_ic *espi_ic =irq_data_get_irq_chip_data (data); + +switch (data->hwirq) { +case ASPEED_ESPI_IC_CTRL_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_HW_RST_DEASSERT , +0 ); +break ; +case ASPEED_ESPI_IC_PERIF_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_PERIF_BITS ,0 ); +break ; +case ASPEED_ESPI_IC_VW_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_VW_BITS ,0 );
drivers/irqchip/irq-aspeed-espi-ic.c line 121
Quoted 10 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +10
-0+break ; +case ASPEED_ESPI_IC_OOB_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_OOB_BITS ,0 ); +break ; +case ASPEED_ESPI_IC_FLASH_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_FLASH_BITS ,0 ); +break ; + }
Most of these are masking multiple events at once, which makes me think that it really doesn't belong here...
Quoted 139 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +42
-0+} + +static void aspeed_espi_ic_irq_enable (struct irq_data *data) +{ +struct aspeed_espi_ic *espi_ic =irq_data_get_irq_chip_data (data); + +switch (data->hwirq) { +case ASPEED_ESPI_IC_CTRL_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_HW_RST_DEASSERT , +ESPI_INT_EN_HW_RST_DEASSERT ); +break ; +case ASPEED_ESPI_IC_PERIF_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_PERIF_BITS , +ESPI_INT_EN_PERIF_BITS ); +break ; +case ASPEED_ESPI_IC_VW_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_VW_BITS , +ESPI_INT_EN_VW_BITS ); +break ; +case ASPEED_ESPI_IC_OOB_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_OOB_BITS , +ESPI_INT_EN_OOB_BITS ); +break ; +case ASPEED_ESPI_IC_FLASH_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_FLASH_BITS , +ESPI_INT_EN_FLASH_BITS ); +break ; + } +} + +static struct irq_chip aspeed_espi_ic_chip = { + .name =IRQCHIP_NAME , + .irq_enable = aspeed_espi_ic_irq_enable, + .irq_disable = aspeed_espi_ic_irq_disable, +}; + +static int aspeed_espi_ic_map(struct irq_domain *domain, unsigned intirq,
drivers/irqchip/irq-aspeed-espi-ic.c new file +3
-0+ irq_hw_number_t hwirq) +{ + irq_set_chip_and_handler(irq, &aspeed_espi_ic_chip,
handle_simple_irq);drivers/irqchip/irq-aspeed-espi-ic.c new file +35
-0+irq_set_chip_data (irq, domain->host_data); + +return 0 ; +} + +static const struct irq_domain_ops aspeed_espi_ic_domain_ops = { + .map = aspeed_espi_ic_map, +}; + +static int aspeed_espi_ic_probe (struct platform_device *pdev) +{ +struct device *dev; +struct aspeed_espi_ic *espi_ic; + + dev = &pdev->dev; + + espi_ic =devm_kzalloc (dev,sizeof (*espi_ic),GFP_KERNEL ); +if (!espi_ic) +return -ENOMEM ; + + espi_ic->map =syscon_node_to_regmap (dev->parent->of_node); +if (IS_ERR (espi_ic->map)) { +dev_err (dev,"cannot get regmap\n" ); +return -ENODEV ; + } + + espi_ic->irq =platform_get_irq (pdev,0 ); +if (espi_ic->irq <0 ) +return espi_ic->irq; + + espi_ic->gpio_irq =platform_get_irq (pdev,1 ); +if (espi_ic->gpio_irq <0 ) +return espi_ic->gpio_irq; + + espi_ic->irq_domain = irq_domain_add_linear(dev->of_node,
ESPI_IC_IRQ_NUM,drivers/irqchip/irq-aspeed-espi-ic.c new file +50
-0+ &aspeed_espi_ic_domain_ops, + espi_ic); +if (!espi_ic->irq_domain) { +dev_err (dev,"cannot to add irq domain\n" ); +return -ENOMEM ; + } + +irq_set_chained_handler_and_data (espi_ic->irq, + aspeed_espi_ic_isr, + espi_ic); + +irq_set_chained_handler_and_data (espi_ic->gpio_irq, + aspeed_espi_ic_gpio_isr, + espi_ic); + +dev_set_drvdata (dev, espi_ic); + +dev_info (dev,"eSPI IRQ controller initialized\n" ); + +return 0 ; +} + +static int aspeed_espi_ic_remove (struct platform_device *pdev) +{ +struct aspeed_espi_ic *espi_ic =platform_get_drvdata (pdev); + +irq_domain_remove (espi_ic->irq_domain); +return 0 ; +} + +static const struct of_device_id aspeed_espi_ic_of_matches[] = { + { .compatible ="aspeed,ast2600-espi-ic" }, + { }, +}; + +static struct platform_driver aspeed_espi_ic_driver = { + .driver = { + .name =DEVICE_NAME , + .of_match_table = aspeed_espi_ic_of_matches, + }, + .probe = aspeed_espi_ic_probe, + .remove = aspeed_espi_ic_remove, +}; + +module_platform_driver (aspeed_espi_ic_driver); + +MODULE_AUTHOR ("Chia-Wei Wang <[email protected]>" ); +MODULE_AUTHOR ("Ryan Chen <[email protected]>" ); +MODULE_DESCRIPTION ("Aspeed eSPI interrupt controller" ); +MODULE_LICENSE ("GPL v2" );include/soc/aspeed/espi.h new file +0
-0
include/soc/aspeed/espi.h line 7
Quoted 7 lines
include/soc/aspeed/espi.h new file +7
-0@@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2020 Aspeed Technology Inc. +* Author: Chia-Wei Wang <[email protected]> +*/ +#ifndef _ASPEED_ESPI_H_ +#define _ASPEED_ESPI_H_
[...]
If nothing else uses the data here, move it to the irqchip driver.
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
RE: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controller
Hi Marc,
Quoted 80 lines
-----Original Message-----
From: Marc Zyngier <[email protected]>
Sent: Wednesday, January 6, 2021 6:59 PM
To: ChiaWei Wang <[email protected]>
Subject: Re: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controllerQuoted 9 lines · Wang
The eSPI interrupt controller acts as a SW IRQ number decoder to correctly control/dispatch interrupts of the eSPI peripheral, virtual wire, out-of-band, and flash channels.
Signed-off-by Chia-Wei, Wang <[email protected]>--- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-aspeed-espi-ic.c | 251 ++++++++++++++++++++++++ include/soc/aspeed/espi.h | 279+++++++++++++++++++++++++++
drivers/irqchip/Makefile obj-$(CONFIG_MVEBU_PIC) +=
Quoted 9 lines
3 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-aspeed-espi-ic.c create mode 100644 include/soc/aspeed/espi.hdrivers/irqchip/Makefile index renamed from drivers/irqchip/Makefile +0
-0
0ac93bfaec61..56da4a3123f8100644drivers/irqchip/Makefile +0
-0@@ -86,7 +86,7 @@ obj-$(CONFIG_MVEBU_PIC) +=irq-mvebu-pic.o
Quoted 53 lines
drivers/irqchip/Makefile +0
-1obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o -obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.oirq-aspeed-scu-ic.o
+obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o
irq-aspeed-scu-ic.o irq-aspeed-espi-ic.o
obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o
obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.odrivers/irqchip/irq-aspeed-espi-ic.c new file +36
-0@@ -0,0 +1,251 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Aspeed Technology Inc. +*/ +#include <linux/bitops.h> +#include <linux/module.h> +#include <linux/irq.h> +#include <linux/irqchip.h> +#include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h> +#include <linux/interrupt.h> #include <linux/mfd/syscon.h> #include +<linux/regmap.h> #include <linux/of.h> #include <linux/of_platform.h> + +#include <soc/aspeed/espi.h> +#include <dt-bindings/interrupt-controller/aspeed-espi-ic.h> + +#define DEVICE_NAME "aspeed-espi-ic" +#define IRQCHIP_NAME "eSPI-IC" + +#define ESPI_IC_IRQ_NUM 7 + +struct aspeed_espi_ic { +struct regmap *map; +int irq; +int gpio_irq; +struct irq_domain *irq_domain; +}; + +static void aspeed_espi_ic_gpio_isr (struct irq_desc *desc) { +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); + +chained_irq_enter (chip, desc); + + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_RESET );
Quoted 8 lines
drivers/irqchip/irq-aspeed-espi-ic.c line 46
Quoted 5 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +5
-0+generic_handle_irq (irq); + + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CHAN_RESET ); +generic_handle_irq (irq);So for each mux interrupt, you generate two endpoints interrupt, without even checking whether they are pending? That's no good.
As the eSPI IC driver is chained to Aspeed GPIO IC, the pending is checked in the gpio-aspeed.c
Quoted 37 lines
Quoted 37 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +37
-0+ +chained_irq_exit (chip, desc); +} + +static void aspeed_espi_ic_isr (struct irq_desc *desc) { +unsigned int sts; +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); + +chained_irq_enter (chip, desc); + +regmap_read (espi_ic->map,ESPI_INT_STS , &sts); + +if (sts &ESPI_INT_STS_PERIF_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_PERIF_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_VW_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_VW_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_OOB_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_OOB_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_FLASH_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_FLASH_EVENT ); +generic_handle_irq (irq); + }
Quoted 8 lines
drivers/irqchip/irq-aspeed-espi-ic.c line 90
Quoted 6 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +6
-0+ +if (sts &ESPI_INT_STS_HW_RST_DEASSERT ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_EVENT ); +generic_handle_irq (irq); + }This is horrible. Why can't you just use
fls()in a loop?
The bits in the interrupt status register for a eSPI channel are not sequentially arranged. Using fls() may invoke an eSPI channel ISR multiple times.
So I collected the bitmap for each channel, respectively, and call the ISR at once.
Quoted 177 lines
Quoted 21 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +20
-0+ +chained_irq_exit (chip, desc); +} + +static void aspeed_espi_ic_irq_disable (struct irq_data *data) { +struct aspeed_espi_ic *espi_ic =irq_data_get_irq_chip_data (data); + +switch (data->hwirq) { +case ASPEED_ESPI_IC_CTRL_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_HW_RST_DEASSERT , +0 ); +break ; +case ASPEED_ESPI_IC_PERIF_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_PERIF_BITS ,0 ); +break ; +case ASPEED_ESPI_IC_VW_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_VW_BITS ,0 );drivers/irqchip/irq-aspeed-espi-ic.c line 121
Quoted 10 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +10
-0+break ; +case ASPEED_ESPI_IC_OOB_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_OOB_BITS ,0 ); +break ; +case ASPEED_ESPI_IC_FLASH_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_FLASH_BITS ,0 ); +break ; + }Most of these are masking multiple events at once, which makes me think that it really doesn't belong here...
Quoted 139 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +40
-0+} + +static void aspeed_espi_ic_irq_enable (struct irq_data *data) { +struct aspeed_espi_ic *espi_ic =irq_data_get_irq_chip_data (data); + +switch (data->hwirq) { +case ASPEED_ESPI_IC_CTRL_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_HW_RST_DEASSERT , +ESPI_INT_EN_HW_RST_DEASSERT ); +break ; +case ASPEED_ESPI_IC_PERIF_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_PERIF_BITS , +ESPI_INT_EN_PERIF_BITS ); +break ; +case ASPEED_ESPI_IC_VW_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_VW_BITS , +ESPI_INT_EN_VW_BITS ); +break ; +case ASPEED_ESPI_IC_OOB_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_OOB_BITS , +ESPI_INT_EN_OOB_BITS ); +break ; +case ASPEED_ESPI_IC_FLASH_EVENT : +regmap_update_bits (espi_ic->map,ESPI_INT_EN , +ESPI_INT_EN_FLASH_BITS , +ESPI_INT_EN_FLASH_BITS ); +break ; + } +} + +static struct irq_chip aspeed_espi_ic_chip = { + .name =IRQCHIP_NAME , + .irq_enable = aspeed_espi_ic_irq_enable, + .irq_disable = aspeed_espi_ic_irq_disable, }; + +static int aspeed_espi_ic_map(struct irq_domain *domain, unsigned intirq,
drivers/irqchip/irq-aspeed-espi-ic.c new file +3
-0+ irq_hw_number_t hwirq) +{ + irq_set_chip_and_handler(irq, &aspeed_espi_ic_chip,
handle_simple_irq);drivers/irqchip/irq-aspeed-espi-ic.c new file +34
-0+irq_set_chip_data (irq, domain->host_data); + +return 0 ; +} + +static const struct irq_domain_ops aspeed_espi_ic_domain_ops = { + .map = aspeed_espi_ic_map, +}; + +static int aspeed_espi_ic_probe (struct platform_device *pdev) { +struct device *dev; +struct aspeed_espi_ic *espi_ic; + + dev = &pdev->dev; + + espi_ic =devm_kzalloc (dev,sizeof (*espi_ic),GFP_KERNEL ); +if (!espi_ic) +return -ENOMEM ; + + espi_ic->map =syscon_node_to_regmap (dev->parent->of_node); +if (IS_ERR (espi_ic->map)) { +dev_err (dev,"cannot get regmap\n" ); +return -ENODEV ; + } + + espi_ic->irq =platform_get_irq (pdev,0 ); +if (espi_ic->irq <0 ) +return espi_ic->irq; + + espi_ic->gpio_irq =platform_get_irq (pdev,1 ); +if (espi_ic->gpio_irq <0 ) +return espi_ic->gpio_irq; + + espi_ic->irq_domain = irq_domain_add_linear(dev->of_node,
ESPI_IC_IRQ_NUM,drivers/irqchip/irq-aspeed-espi-ic.c new file +49
-0+ &aspeed_espi_ic_domain_ops, + espi_ic); +if (!espi_ic->irq_domain) { +dev_err (dev,"cannot to add irq domain\n" ); +return -ENOMEM ; + } + +irq_set_chained_handler_and_data (espi_ic->irq, + aspeed_espi_ic_isr, + espi_ic); + +irq_set_chained_handler_and_data (espi_ic->gpio_irq, + aspeed_espi_ic_gpio_isr, + espi_ic); + +dev_set_drvdata (dev, espi_ic); + +dev_info (dev,"eSPI IRQ controller initialized\n" ); + +return 0 ; +} + +static int aspeed_espi_ic_remove (struct platform_device *pdev) { +struct aspeed_espi_ic *espi_ic =platform_get_drvdata (pdev); + +irq_domain_remove (espi_ic->irq_domain); +return 0 ; +} + +static const struct of_device_id aspeed_espi_ic_of_matches[] = { + { .compatible ="aspeed,ast2600-espi-ic" }, + { }, +}; + +static struct platform_driver aspeed_espi_ic_driver = { + .driver = { + .name =DEVICE_NAME , + .of_match_table = aspeed_espi_ic_of_matches, + }, + .probe = aspeed_espi_ic_probe, + .remove = aspeed_espi_ic_remove, +}; + +module_platform_driver (aspeed_espi_ic_driver); + +MODULE_AUTHOR ("Chia-Wei Wang <[email protected]>" ); +MODULE_AUTHOR ("Ryan Chen <[email protected]>" ); +MODULE_DESCRIPTION ("Aspeed eSPI interrupt controller" ); +MODULE_LICENSE ("GPL v2" );include/soc/aspeed/espi.h new renamed from include/soc/aspeed/espi.h +0
-0file mode 100644 index 000000000000..c9a4f51737ee
include/soc/aspeed/espi.h new file +5
-0@@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2020 Aspeed Technology Inc. +* Author: Chia-Wei Wang <[email protected]> */ #ifndef +_ASPEED_ESPI_H_#define _ASPEED_ESPI_H_[...]
Quoted 1 line
If nothing else uses the data here, move it to the irqchip driver.
The header will be used by other eSPI driver files.
Chiawei.
Re: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controller
Quoted 93 lines · ChiaWei Wang
Hi Marc,
Quoted 82 lines
-----Original Message-----
From: Marc Zyngier <[email protected]>
Sent: Wednesday, January 6, 2021 6:59 PM
To: ChiaWei Wang <[email protected]>
Subject: Re: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controllerQuoted 9 lines · Wang
The eSPI interrupt controller acts as a SW IRQ number decoder to correctly control/dispatch interrupts of the eSPI peripheral, virtual wire, out-of-band, and flash channels.
Signed-off-by Chia-Wei, Wang <[email protected]>--- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-aspeed-espi-ic.c | 251 ++++++++++++++++++++++++ include/soc/aspeed/espi.h | 279+++++++++++++++++++++++++++
drivers/irqchip/Makefile obj-$(CONFIG_MVEBU_PIC) +=
Quoted 9 lines
3 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-aspeed-espi-ic.c create mode 100644 include/soc/aspeed/espi.hdrivers/irqchip/Makefile index renamed from drivers/irqchip/Makefile +0
-0
0ac93bfaec61..56da4a3123f8100644drivers/irqchip/Makefile +0
-0@@ -86,7 +86,7 @@ obj-$(CONFIG_MVEBU_PIC) +=irq-mvebu-pic.o
Quoted 54 lines
drivers/irqchip/Makefile +0
-1obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o -obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.oirq-aspeed-scu-ic.o
+obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o
irq-aspeed-scu-ic.o irq-aspeed-espi-ic.o
obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o
obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.odrivers/irqchip/irq-aspeed-espi-ic.c new file +37
-0@@ -0,0 +1,251 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Aspeed Technology Inc. +*/ +#include <linux/bitops.h> +#include <linux/module.h> +#include <linux/irq.h> +#include <linux/irqchip.h> +#include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h> +#include <linux/interrupt.h> #include <linux/mfd/syscon.h> #include +<linux/regmap.h> #include <linux/of.h> #include <linux/of_platform.h> + +#include <soc/aspeed/espi.h> +#include <dt-bindings/interrupt-controller/aspeed-espi-ic.h> + +#define DEVICE_NAME "aspeed-espi-ic" +#define IRQCHIP_NAME "eSPI-IC" + +#define ESPI_IC_IRQ_NUM 7 + +struct aspeed_espi_ic { +struct regmap *map; +int irq; +int gpio_irq; +struct irq_domain *irq_domain; +}; + +static void aspeed_espi_ic_gpio_isr (struct irq_desc *desc) { +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); + +chained_irq_enter (chip, desc); + + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_RESET ); +generic_handle_irq (irq);Quoted 8 lines
drivers/irqchip/irq-aspeed-espi-ic.c line 46
Quoted 4 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +4
-0+ + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CHAN_RESET ); +generic_handle_irq (irq);So for each mux interrupt, you generate two endpoints interrupt, without even
checking whether they are pending? That's no good.
Quoted 2 lines
As the eSPI IC driver is chained to Aspeed GPIO IC, the pending is checked in the
gpio-aspeed.c
That's not the place to do that.
Quoted 47 lines
Quoted 38 lines
Quoted 38 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +37
-0+ +chained_irq_exit (chip, desc); +} + +static void aspeed_espi_ic_isr (struct irq_desc *desc) { +unsigned int sts; +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); + +chained_irq_enter (chip, desc); + +regmap_read (espi_ic->map,ESPI_INT_STS , &sts); + +if (sts &ESPI_INT_STS_PERIF_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_PERIF_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_VW_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_VW_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_OOB_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_OOB_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_FLASH_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_FLASH_EVENT ); +generic_handle_irq (irq); + }Quoted 8 lines
drivers/irqchip/irq-aspeed-espi-ic.c line 90
Quoted 6 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +6
-0+ +if (sts &ESPI_INT_STS_HW_RST_DEASSERT ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_EVENT ); +generic_handle_irq (irq); + }This is horrible. Why can't you just use
fls()in a loop?
Quoted 5 lines
The bits in the interrupt status register for a eSPI channel are not sequentially arranged.
Usingfls()may invoke an eSPI channel ISR multiple times. So I collected the bitmap for each channel, respectively, and call the ISR at once.
And that's equally wrong. You need to handle interrupts individually, as they are different signal. If you are to implement an interrupt controller, please do it properly.
Otherwise, get rid of it and move everything into your pet driver. There is no need to do a half-baked job.
As it is, there is no way this code can be merged.
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
RE: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controller
Hi Marc,
I will revise the patch as suggested.
Thanks for the feedback.
Chiawei
Quoted 174 lines
-----Original Message-----
From: Marc Zyngier <[email protected]>
Sent: Thursday, January 7, 2021 6:18 PM
To: ChiaWei Wang <[email protected]> <[email protected]>
Subject: Re: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controllerQuoted 35 lines · ChiaWei Wang
Hi Marc,
Quoted 33 lines
-----Original Message-----
From: Marc Zyngier <[email protected]>
Sent: Wednesday, January 6, 2021 6:59 PM
To: ChiaWei Wang <[email protected]>
Subject: Re: [PATCH 4/6] irqchip/aspeed: Add Aspeed eSPI interrupt controllerQuoted 9 lines · Wang
The eSPI interrupt controller acts as a SW IRQ number decoder to correctly control/dispatch interrupts of the eSPI peripheral, virtual wire, out-of-band, and flash channels.
Signed-off-by Chia-Wei, Wang <[email protected]>--- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-aspeed-espi-ic.c | 251 ++++++++++++++++++++++++ include/soc/aspeed/espi.h | 279+++++++++++++++++++++++++++
drivers/irqchip/Makefile obj-$(CONFIG_MVEBU_PIC) +=
Quoted 10 lines
3 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-aspeed-espi-ic.c create mode 100644 include/soc/aspeed/espi.hdrivers/irqchip/Makefile +0
-0index
0ac93bfaec61..56da4a3123f8100644drivers/irqchip/Makefile +0
-0@@ -86,7 +86,7 @@ obj-$(CONFIG_MVEBU_PIC) +=irq-mvebu-pic.o
Quoted 4 lines
drivers/irqchip/Makefile +0
-1obj-$(CONFIG_MVEBU_SEI) += irq-mvebu-sei.o obj-$(CONFIG_LS_EXTIRQ) += irq-ls-extirq.o obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o -obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.oirq-aspeed-i2c-ic.o
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
irq-aspeed-scu-ic.o
+obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.oirq-aspeed-i2c-ic.o
Quoted 57 lines
Quoted 48 lines
Quoted 48 lines
irq-aspeed-scu-ic.o irq-aspeed-espi-ic.o
obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o
obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.odrivers/irqchip/irq-aspeed-espi-ic.c new file +37
-0@@ -0,0 +1,251 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Aspeed Technology Inc. +*/ +#include <linux/bitops.h> +#include <linux/module.h> +#include <linux/irq.h> +#include <linux/irqchip.h> +#include <linux/irqchip/chained_irq.h> #include +<linux/irqdomain.h> #include <linux/interrupt.h> #include +<linux/mfd/syscon.h> #include <linux/regmap.h> #include +<linux/of.h> #include <linux/of_platform.h> + +#include <soc/aspeed/espi.h> +#include <dt-bindings/interrupt-controller/aspeed-espi-ic.h> + +#define DEVICE_NAME "aspeed-espi-ic" +#define IRQCHIP_NAME "eSPI-IC" + +#define ESPI_IC_IRQ_NUM 7 + +struct aspeed_espi_ic { +struct regmap *map; +int irq; +int gpio_irq; +struct irq_domain *irq_domain; +}; + +static void aspeed_espi_ic_gpio_isr (struct irq_desc *desc) { +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); + +chained_irq_enter (chip, desc); + + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_RESET );Quoted 8 lines
drivers/irqchip/irq-aspeed-espi-ic.c line 46
Quoted 5 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +5
-0+generic_handle_irq (irq); + + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CHAN_RESET ); +generic_handle_irq (irq);So for each mux interrupt, you generate two endpoints interrupt, without even checking whether they are pending? That's no good.
Quoted 2 lines
As the eSPI IC driver is chained to Aspeed GPIO IC, the pending is checked in the
gpio-aspeed.cThat's not the place to do that.
Quoted 47 lines
Quoted 38 lines
Quoted 38 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +37
-0+ +chained_irq_exit (chip, desc); +} + +static void aspeed_espi_ic_isr (struct irq_desc *desc) { +unsigned int sts; +unsigned int irq; +struct aspeed_espi_ic *espi_ic =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); + +chained_irq_enter (chip, desc); + +regmap_read (espi_ic->map,ESPI_INT_STS , &sts); + +if (sts &ESPI_INT_STS_PERIF_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_PERIF_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_VW_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_VW_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_OOB_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_OOB_EVENT ); +generic_handle_irq (irq); + } + +if (sts &ESPI_INT_STS_FLASH_BITS ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_FLASH_EVENT ); +generic_handle_irq (irq); + }Quoted 8 lines
drivers/irqchip/irq-aspeed-espi-ic.c line 90
Quoted 6 lines
drivers/irqchip/irq-aspeed-espi-ic.c new file +6
-0+ +if (sts &ESPI_INT_STS_HW_RST_DEASSERT ) { + irq =irq_find_mapping (espi_ic->irq_domain, +ASPEED_ESPI_IC_CTRL_EVENT ); +generic_handle_irq (irq); + }This is horrible. Why can't you just use
fls()in a loop?Quoted 5 lines
The bits in the interrupt status register for a eSPI channel are not sequentially arranged.
Usingfls()may invoke an eSPI channel ISR multiple times. So I collected the bitmap for each channel, respectively, and call the ISR at once.And that's equally wrong. You need to handle interrupts individually, as they are different signal. If you are to implement an interrupt controller, please do it properly.
Otherwise, get rid of it and move everything into your pet driver. There is no need to do a half-baked job.
As it is, there is no way this code can be merged.
M.--
Jazz is not dead. It just smells funny...
PATCH 5/6 soc: aspeed: Add eSPI driver
In reply to Chia-Wei, WangThe 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 | 49 ++ drivers/soc/aspeed/Makefile | 5 + drivers/soc/aspeed/aspeed-espi-ctrl.c | 197 ++++++ drivers/soc/aspeed/aspeed-espi-flash.c | 490 ++++++++++++++ drivers/soc/aspeed/aspeed-espi-oob.c | 706 ++++++++++++++++++++ drivers/soc/aspeed/aspeed-espi-peripheral.c | 613 +++++++++++++++++ drivers/soc/aspeed/aspeed-espi-vw.c | 211 ++++++ include/uapi/linux/aspeed-espi.h | 160 +++++ 8 files changed, 2431 insertions(+) create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c create mode 100644 drivers/soc/aspeed/aspeed-espi-peripheral.c create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.c create mode 100644 include/uapi/linux/aspeed-espi.h
drivers/soc/aspeed/Kconfig +49 -0
@@ -42,6 +42,55 @@ config ASPEED_SOCINFO help Say yes to support decoding of ASPEED BMC information. +config ASPEED_ESPI + tristate "Aspeed eSPI Engine Driver" + select REGMAP + select MFD_SYSON + select ASPEED_ESPI_PERIPHERAL + select ASPEED_ESPI_VW + select ASPEED_ESPI_OOB + select ASPEED_ESPI_FLASH + default n + help + Enable support for the Aspeed eSPI engine. The eSPI engine + plays as a slave device in BMC to communicate with the host + side master over the eSPI bus interface. + + eSPI and LPC are mutually execulisve features on Aspeed SoC. + If not sure, say N. + +config ASPEED_ESPI_PERIPHERAL + tristate "Aspeed eSPI peripheral channel driver" + depends on ASPEED_ESPI + help + Control Aspeed eSPI peripheral channel driver. The driver + also provides an eSPI packet put/get interface to communicate + with the eSPI host. + +config ASPEED_ESPI_VW + tristate "Aspeed eSPI virtual wire channel driver" + depends on ASPEED_ESPI + help + Control Aspeed eSPI virtual wire channel driver. The driver + also provides an eSPI packet put/get interface to communicate + with the eSPI host. + +config ASPEED_ESPI_OOB + tristate "Aspeed eSPI out-of-band channel driver" + depends on ASPEED_ESPI + help + Control Aspeed eSPI out-of-band channel driver. The driver + also provides an eSPI packet put/get interface to communicat + with the eSPI host. + +config ASPEED_ESPI_FLASH + tristate "Aspeed eSPI flash channel driver" + depends on ASPEED_ESPI + help + Control Aspeed eSPI flash channel driver. The driver + also provides an eSPI packet put/get interface to communicat + with the eSPI host. + endmenu endif
drivers/soc/aspeed/Makefile +5 -0
@@ -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-peripheral.o \ + aspeed-espi-vw.o \ + aspeed-espi-oob.o \ + aspeed-espi-flash.o
drivers/soc/aspeed/aspeed-espi-ctrl.c new file +197 -0
197 lines not on this page · raw message
drivers/soc/aspeed/aspeed-espi-flash.c new file +490 -0
490 lines not on this page · raw message
drivers/soc/aspeed/aspeed-espi-oob.c new file +706 -0
706 lines not on this page · raw message
drivers/soc/aspeed/aspeed-espi-peripheral.c new file +613 -0
613 lines not on this page · raw message
drivers/soc/aspeed/aspeed-espi-vw.c new file +211 -0
211 lines not on this page · raw message
include/uapi/linux/aspeed-espi.h new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH 5/6] soc: aspeed: Add eSPI driver
Thank you for the patch! Yet something to improve:
Hi Wang",
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.11-rc2 next-20210104]
[cannot apply to joel-aspeed/for-next robh/for-next tip/irq/core] [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/20210106-140337 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62 config: ia64-randconfig-m031-20210106 (attached as .config) compiler: ia64-linux-gcc (GCC) 9.3.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/4ee780938ea027aa22e3dbd0b9041477da033ee0
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/20210106-140337 git checkout 4ee780938ea027aa22e3dbd0b9041477da033ee0
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> error: include/uapi/linux/aspeed-espi.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier -- >> error: include/uapi/linux/aspeed-espi.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier
make[2]: *** [scripts/Makefile.headersinst:63: usr/include/linux/aspeed-espi.h] Error 1 make[2]: Target '__headers' not remade because of errors.
make[1]: *** [Makefile:1294: headers] Error 2
make[1]: Target 'headers_install' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'headers_install' not remade because of errors.
--
>> error: include/uapi/linux/aspeed-espi.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier
make[2]: *** [scripts/Makefile.headersinst:63: usr/include/linux/aspeed-espi.h] Error 1
make[2]: Target '__headers' not remade because of errors.
make[1]: *** [Makefile:1294: headers] Error 2
In file included from include/linux/kernel.h:16,
from include/asm-generic/bug.h:20,
from arch/ia64/include/asm/bug.h:17,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
include/linux/printk.h:219:5: error: static declaration of 'printk' follows non-static declaration
219 | int printk(const char *s, ...)
| ^~~~~~
In file included from arch/ia64/include/uapi/asm/intrinsics.h:22,
from arch/ia64/include/asm/intrinsics.h:11,
from arch/ia64/include/asm/bitops.h:19,
from include/linux/bitops.h:32,
from include/linux/kernel.h:11,
from include/asm-generic/bug.h:20,
from arch/ia64/include/asm/bug.h:17,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
arch/ia64/include/uapi/asm/cmpxchg.h:142:14: note: previous declaration of 'printk' was here
142 | extern int printk(const char *fmt, ...); \
| ^~~~~~
arch/ia64/include/asm/bitops.h:309:3: note: in expansion of macro 'CMPXCHG_BUGCHECK'
309 | CMPXCHG_BUGCHECK(m);
| ^~~~~~~~~~~~~~~~ make[2]: *** [scripts/Makefile.build:117: kernel/bounds.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1206: prepare0] Error 2
make[1]: Target 'modules_prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'modules_prepare' not remade because of errors.
--
cc1: warning: ./arch/ia64/include/generated: No such file or directory [-Wmissing-include-dirs]
cc1: warning: ./arch/ia64/include/generated/uapi: No such file or directory [-Wmissing-include-dirs]
cc1: warning: ./include/generated/uapi: No such file or directory [-Wmissing-include-dirs] arch/ia64/kernel/nr-irqs.c:15:6: warning: no previous prototype for 'foo' [-Wmissing-prototypes]
15 | void foo(void)
| ^~~
>> error: include/uapi/linux/aspeed-espi.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier
make[2]: *** [scripts/Makefile.headersinst:63: usr/include/linux/aspeed-espi.h] Error 1
make[2]: Target '__headers' not remade because of errors.
make[1]: *** [Makefile:1294: headers] Error 2
In file included from include/linux/kernel.h:16,
from include/asm-generic/bug.h:20,
from arch/ia64/include/asm/bug.h:17,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
include/linux/printk.h:219:5: error: static declaration of 'printk' follows non-static declaration
219 | int printk(const char *s, ...)
| ^~~~~~
In file included from arch/ia64/include/uapi/asm/intrinsics.h:22,
from arch/ia64/include/asm/intrinsics.h:11,
from arch/ia64/include/asm/bitops.h:19,
from include/linux/bitops.h:32,
from include/linux/kernel.h:11,
from include/asm-generic/bug.h:20,
from arch/ia64/include/asm/bug.h:17,
from include/linux/bug.h:5,
from include/linux/page-flags.h:10,
from kernel/bounds.c:10:
arch/ia64/include/uapi/asm/cmpxchg.h:142:14: note: previous declaration of 'printk' was here
142 | extern int printk(const char *fmt, ...); \
| ^~~~~~
arch/ia64/include/asm/bitops.h:309:3: note: in expansion of macro 'CMPXCHG_BUGCHECK'
309 | CMPXCHG_BUGCHECK(m);
| ^~~~~~~~~~~~~~~~ make[2]: *** [scripts/Makefile.build:117: kernel/bounds.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [Makefile:1206: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for FRAME_POINTER
Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
Selected by
- FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86
---
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: 33093 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linux-aspeed/attachments/20210106/3ef56c17/attachment-0001.gz>
Rob Herring
maintainerRe: [PATCH 5/6] soc: aspeed: Add eSPI driver
In reply to Chia-Wei, WangQuoted 6 lines · 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.
Signed-off-by Chia-Wei, Wang <[email protected]>
Quoted 15 lines
--- drivers/soc/aspeed/Kconfig | 49 ++ drivers/soc/aspeed/Makefile | 5 + drivers/soc/aspeed/aspeed-espi-ctrl.c | 197 ++++++ drivers/soc/aspeed/aspeed-espi-flash.c | 490 ++++++++++++++ drivers/soc/aspeed/aspeed-espi-oob.c | 706 ++++++++++++++++++++ drivers/soc/aspeed/aspeed-espi-peripheral.c | 613 +++++++++++++++++ drivers/soc/aspeed/aspeed-espi-vw.c | 211 ++++++ include/uapi/linux/aspeed-espi.h | 160 +++++ 8 files changed, 2431 insertions(+) create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c create mode 100644 drivers/soc/aspeed/aspeed-espi-peripheral.c create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.c
drivers/spi/ is the correct location for a SPI controller.
Quoted 1 line
create mode 100644 include/uapi/linux/aspeed-espi.h
This userspace interface is not going to be accepted upstream.
I'd suggest you look at similar SPI flash capable SPI controller drivers upstream and model your driver after them. This looks like it needs major reworking.
Rob
RE: [PATCH 5/6] soc: aspeed: Add eSPI driver
Hi Rob,
Quoted 30 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Wednesday, January 6, 2021 11:32 PM
To: ChiaWei Wang <[email protected]>
Subject: Re: [PATCH 5/6] soc: aspeed: Add eSPI driverQuoted 5 lines · 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.
Quoted 7 lines
Signed-off-by Chia-Wei, Wang <[email protected]>--- drivers/soc/aspeed/Kconfig | 49 ++ drivers/soc/aspeed/Makefile | 5 + drivers/soc/aspeed/aspeed-espi-ctrl.c | 197 ++++++ drivers/soc/aspeed/aspeed-espi-flash.c | 490 ++++++++++++++ drivers/soc/aspeed/aspeed-espi-oob.c | 706++++++++++++++++++++
Quoted 9 lines
drivers/soc/aspeed/aspeed-espi-peripheral.c | 613 +++++++++++++++++ drivers/soc/aspeed/aspeed-espi-vw.c | 211 ++++++ include/uapi/linux/aspeed-espi.h | 160 +++++ 8 files changed, 2431 insertions(+) create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c create mode 100644 drivers/soc/aspeed/aspeed-espi-peripheral.c create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.c
Quoted 9 lines
drivers/spi/is the correct location for a SPI controller.Quoted 1 line
create mode 100644 include/uapi/linux/aspeed-espi.hThis userspace interface is not going to be accepted upstream.
I'd suggest you look at similar SPI flash capable SPI controller drivers upstream and model your driver after them. This looks like it needs major reworking.
eSPI resues the timing and electrical specification of SPI but runs completely different protocol. Only the flash channel is related to SPI and the other 3 channels are for EC/BMC/SIO. Therefore, an eSPI driver might not fit into the SPI model.
Chiawei
Joel Stanley
maintainerRe: [PATCH 5/6] soc: aspeed: Add eSPI driver
Quoted 37 lines · ChiaWei Wang
Hi Rob,
Quoted 34 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Wednesday, January 6, 2021 11:32 PM
To: ChiaWei Wang <[email protected]>
Subject: Re: [PATCH 5/6] soc: aspeed: Add eSPI driverQuoted 5 lines · 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.
Quoted 7 lines
Signed-off-by Chia-Wei, Wang <[email protected]>--- drivers/soc/aspeed/Kconfig | 49 ++ drivers/soc/aspeed/Makefile | 5 + drivers/soc/aspeed/aspeed-espi-ctrl.c | 197 ++++++ drivers/soc/aspeed/aspeed-espi-flash.c | 490 ++++++++++++++ drivers/soc/aspeed/aspeed-espi-oob.c | 706++++++++++++++++++++
Quoted 9 lines
drivers/soc/aspeed/aspeed-espi-peripheral.c | 613 +++++++++++++++++ drivers/soc/aspeed/aspeed-espi-vw.c | 211 ++++++ include/uapi/linux/aspeed-espi.h | 160 +++++ 8 files changed, 2431 insertions(+) create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c create mode 100644 drivers/soc/aspeed/aspeed-espi-peripheral.c create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.c
drivers/spi/is the correct location for a SPI controller.Quoted 1 line
create mode 100644 include/uapi/linux/aspeed-espi.h
Quoted 8 lines
Quoted 5 lines
This userspace interface is not going to be accepted upstream.
I'd suggest you look at similar SPI flash capable SPI controller drivers upstream and model your driver after them. This looks like it needs major reworking.
eSPI resues the timing and electrical specification of SPI but runs completely different protocol. Only the flash channel is related to SPI and the other 3 channels are for EC/BMC/SIO. Therefore, an eSPI driver might not fit into the SPI model.
I agree, the naming is confusing but eSPI doesn't belong in drivers/spi.
As it is a bus that is common to more than just the Aspeed BMC, we may want to implement it as a new bus type that has devices hanging off it, similar to FSI.
Cheers,
Joel
Ryan Chen
reviewerRE: [PATCH 5/6] soc: aspeed: Add eSPI driver
Quoted 61 lines
-----Original Message-----
From: Joel Stanley <[email protected]>
Sent: Friday, January 8, 2021 10:59 AM
To: ChiaWei Wang <[email protected]>; Jeremy Kerr <[email protected]>
Cc: Rob Herring <[email protected]>; andrew at aj.id.au; tglx at linutronix.de; maz at kernel.org; p.zabel at pengutronix.de; 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; BMC-SW <[email protected]>
Subject: Re: [PATCH 5/6] soc: aspeed: Add eSPI driverQuoted 24 lines · ChiaWei Wang
Hi Rob,
Quoted 21 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Wednesday, January 6, 2021 11:32 PM
To: ChiaWei Wang <[email protected]>
Subject: Re: [PATCH 5/6] soc: aspeed: Add eSPI driverQuoted 5 lines · 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.
Quoted 7 lines
Signed-off-by Chia-Wei, Wang <[email protected]>--- drivers/soc/aspeed/Kconfig | 49 ++ drivers/soc/aspeed/Makefile | 5 + drivers/soc/aspeed/aspeed-espi-ctrl.c | 197 ++++++ drivers/soc/aspeed/aspeed-espi-flash.c | 490 ++++++++++++++ drivers/soc/aspeed/aspeed-espi-oob.c | 706++++++++++++++++++++
Quoted 1 line
drivers/soc/aspeed/aspeed-espi-peripheral.c | 613+++++++++++++++++
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/soc/aspeed/aspeed-espi-vw.c | 211 ++++++ include/uapi/linux/aspeed-espi.h | 160 +++++ 8 files changed, 2431 insertions(+) create mode 100644 drivers/soc/aspeed/aspeed-espi-ctrl.c create mode 100644 drivers/soc/aspeed/aspeed-espi-flash.c create mode 100644 drivers/soc/aspeed/aspeed-espi-oob.c create mode 100644 drivers/soc/aspeed/aspeed-espi-peripheral.c create mode 100644 drivers/soc/aspeed/aspeed-espi-vw.cQuoted 8 lines
Quoted 8 lines
drivers/spi/is the correct location for a SPI controller.Quoted 1 line
create mode 100644 include/uapi/linux/aspeed-espi.hThis userspace interface is not going to be accepted upstream.
I'd suggest you look at similar SPI flash capable SPI controller drivers upstream and model your driver after them. This looks like it needs
major reworking.
Quoted 2 lines
Quoted 1 line
eSPI resues the timing and electrical specification of SPI but runs completely
different protocol.
Quoted 1 line
Only the flash channel is related to SPI and the other 3 channels are for
Quoted 9 lines
EC/BMC/SIO.
Quoted 1 line
Therefore, an eSPI driver might not fit into the SPI model.
I agree, the naming is confusing but eSPI doesn't belong in
drivers/spi.As it is a bus that is common to more than just the Aspeed BMC, we may want to implement it as a new bus type that has devices hanging off it, similar to FSI.
The ASPEED eSPI controller driver is slave side device, not master side. I think it will be stay soc/aspeed first. Because is most SoC Chip related.
Cheers,
Ryan
PATCH 6/6 ARM: dts: aspeed: Add AST2600 eSPI nodes
In reply to Chia-Wei, WangAdd eSPI nodes for the device tree of Aspeed 6th generation SoCs.
--- arch/arm/boot/dts/aspeed-g6.dtsi | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
arch/arm/boot/dts/aspeed-g6.dtsi +57 -0
@@ -3,7 +3,9 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/interrupt-controller/aspeed-scu-ic.h> +#include <dt-bindings/interrupt-controller/aspeed-espi-ic.h> #include <dt-bindings/clock/ast2600-clock.h> +#include <dt-bindings/gpio/aspeed-gpio.h> / { model = "Aspeed BMC";
@@ -75,6 +77,61 @@ interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>; }; + 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_ic: espi-ic { + #interrupt-cells = <1>; + compatible = "aspeed,ast2600-espi-ic"; + interrupts-extended = <&gic GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>, + <&gpio0 ASPEED_GPIO(W, 7) IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + status = "disabled"; + }; + + espi_ctrl: espi-ctrl { + compatible = "aspeed,ast2600-espi-ctrl"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_CTRL_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CTRL_RESET>; + clocks = <&syscon ASPEED_CLK_GATE_ESPICLK>; + resets = <&syscon ASPEED_RESET_ESPI>; + status = "disabled"; + }; + + espi_peripheral: espi-peripheral-channel { + compatible = "aspeed,ast2600-espi-peripheral"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_PERIF_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + status = "disabled"; + }; + + espi_vw: espi-vw-channel { + compatible = "aspeed,ast2600-espi-vw"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_VW_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + status = "disabled"; + }; + + espi_oob: espi-oob-channel { + compatible = "aspeed,ast2600-espi-oob"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_OOB_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + status = "disabled"; + }; + + espi_flash: espi-flash-channel { + compatible = "aspeed,ast2600-espi-flash"; + interrupts-extended = <&espi_ic ASPEED_ESPI_IC_FLASH_EVENT>, + <&espi_ic ASPEED_ESPI_IC_CHAN_RESET>; + status = "disabled"; + }; + }; + ahb { compatible = "simple-bus"; #address-cells = <1>;
Signature · 1 line
2.17.1