Skip to contentSkip to conversation

soc: add NPCM BPC driver support

PATCH In review Tomer Maimon 4 participants 13 messages Dec 13, 2023 – Dec 14, 2023

Subsystems (3)
lore
Share & tools
lore

Tomer Maimon

author maintainer
#0 lore raw

v3 cover soc: add NPCM BPC driver support

This patch set adds BIOS Post code (BPC) support for the Nuvoton NPCM Baseboard Management Controller (BMC).

Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O addresses written by the host on the bus, the capture data stored in 128-word FIFO.

NPCM BPC can support capture double words.

The NPCM BPC driver tested on NPCM750 Olympus board.

Addressed comments from:
- Krzysztof Kozlowski : https://www.spinics.net/lists/kernel/msg5035188.html
- Conor Dooley : https://www.spinics.net/lists/kernel/msg5034239.html
- kernel test robot : https://www.spinics.net/lists/kernel/msg5034970.html

Changes since version 2:
- Modify compatible bindings.
- Add more details to nuvoton,bpc-en-dwcapture parameter.
- Using _is_visible() function to support NPCM8XX.
- add __poll_t custom.

Changes since version 1:
- Remove LPC present from the BPC driver.
- Modify dt-bindings message header.
- Add vendor to the file name.
- Modify incorrect spelling.

Tomer Maimon (3):
dt-bindings: soc: nuvoton: Add NPCM BPC
soc: nuvoton: add configuration menu
soc: nuvoton: add NPCM BPC driver

 .../soc/nuvoton/nuvoton,npcm-bpc.yaml         |  65 +++
 drivers/soc/nuvoton/Kconfig                   |  16 +-
 drivers/soc/nuvoton/Makefile                  |   1 +
 drivers/soc/nuvoton/npcm-bpc.c                | 387 ++++++++++++++++++
 4 files changed, 468 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml
 create mode 100644 drivers/soc/nuvoton/npcm-bpc.c
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v3 1/3 dt-bindings: soc: nuvoton: Add NPCM BPC

Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post Code (BPC).

The NPCM BPC monitoring two configurable I/O addresses written by the host on the bus.

---
 .../soc/nuvoton/nuvoton,npcm-bpc.yaml         | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +65 -0
new file mode 100644
index 000000000000..c04302a1d52b
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton BMC NPCM BIOS Post Code (BPC) controller
+
+maintainers:
+  - Tomer Maimon <[email protected]>
+
+description:
+  Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O
+  addresses written by the host on the bus, the capture data stored in
+  128-word FIFO.
+
+  NPCM BPC supports capture double words, when using capture
+  double word only I/O address 1 is monitored.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - nuvoton,npcm845-bpc
+          - nuvoton,npcm750-bpc
+      - const: nuvoton,npcm-bpc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  nuvoton,monitor-ports:
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    description:
+      Contain monitor I/O addresses on the bus, at least one monitor I/O
+      address required.
+
+  nuvoton,bpc-en-dwcapture:
+    description:
+      Set DWCAPTURE bit in BPCFEN register that enable double words capture
+      according to the first address setting.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - nuvoton,monitor-ports
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    bpc: bpc@f0007040 {
+        compatible = "nuvoton,npcm750-bpc", "nuvoton,npcm-bpc";
+        reg = <0xf0007040 0x20>;
+        interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
+        nuvoton,monitor-ports = <0x80>;
+    };
+...
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v3 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC

Quoted 34 lines · Tomer Maimon

Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post Code (BPC).

The NPCM BPC monitoring two configurable I/O addresses written by the host on the bus.

---
 .../soc/nuvoton/nuvoton,npcm-bpc.yaml         | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +16 -0
new file mode 100644
index 000000000000..c04302a1d52b
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton BMC NPCM BIOS Post Code (BPC) controller
+
+maintainers:
+  - Tomer Maimon <[email protected]>
+
+description:
+  Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O
+  addresses written by the host on the bus, the capture data stored in
+  128-word FIFO.
+

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +10 -0
+  NPCM BPC supports capture double words, when using capture
+  double word only I/O address 1 is monitored.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - nuvoton,npcm845-bpc
+          - nuvoton,npcm750-bpc
+      - const: nuvoton,npcm-bpc

That's not what I suggested. I asked to make 845 compatible with 750. This works, but I want to be sure you really, really understand the consequences of this.

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 35

Quoted 9 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +9 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  nuvoton,monitor-ports:
+    $ref: /schemas/types.yaml#/definitions/uint32-array

Missing constraints, like min/maxItems and maybe values.

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 40

Quoted 5 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +5 -0
+    description:
+      Contain monitor I/O addresses on the bus, at least one monitor I/O
+      address required.
+
+  nuvoton,bpc-en-dwcapture:

nuvoton,double-word-capture?

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 50

Quoted 10 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +10 -0
+    description:
+      Set DWCAPTURE bit in BPCFEN register that enable double words capture
+      according to the first address setting.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - nuvoton,monitor-ports

Best regards,
Krzysztof

author maintainer
#3 lore raw

Re: [PATCH v3 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC

Hi Krzysztof,

Thanks for your comments.

Quoted 42 lines · Krzysztof Kozlowski
Quoted 40 lines · Tomer Maimon

Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post Code (BPC).

The NPCM BPC monitoring two configurable I/O addresses written by the host on the bus.

---
 .../soc/nuvoton/nuvoton,npcm-bpc.yaml         | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +22 -0
new file mode 100644
index 000000000000..c04302a1d52b
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton BMC NPCM BIOS Post Code (BPC) controller
+
+maintainers:
+  - Tomer Maimon <[email protected]>
+
+description:
+  Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O
+  addresses written by the host on the bus, the capture data stored in
+  128-word FIFO.
+
+  NPCM BPC supports capture double words, when using capture
+  double word only I/O address 1 is monitored.
+
+properties:
+  compatible:
+    items:
Quoted 8 lines

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 26

Quoted 4 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +4 -0
+      - enum:
+          - nuvoton,npcm845-bpc
+          - nuvoton,npcm750-bpc
+      - const: nuvoton,npcm-bpc

That's not what I suggested. I asked to make 845 compatible with 750. This works, but I want to be sure you really, really understand the consequences of this.

Did you mean to do the compatible as follows?
properties:
compatible:
items:
- enum:
- nuvoton,npcm845-bpc
- const: nuvoton,npcm750-bpc

Appreciate it if you could explain what is the difference between the compatibility suggested in V3?

Quoted 12 lines

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 35

Quoted 10 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +9 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  nuvoton,monitor-ports:
+    $ref: /schemas/types.yaml#/definitions/uint32-array

Missing constraints, like min/maxItems and maybe values.

O.K.

Quoted 8 lines

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 40

Quoted 6 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +5 -0
+    description:
+      Contain monitor I/O addresses on the bus, at least one monitor I/O
+      address required.
+
+  nuvoton,bpc-en-dwcapture:

nuvoton,double-word-capture?

Modify in V4

Quoted 15 lines

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 50

Quoted 11 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +10 -0
+    description:
+      Set DWCAPTURE bit in BPCFEN register that enables double word capture
+      according to the first address setting.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - nuvoton,monitor-ports

Best regards,
Krzysztof

Thanks,

Tomer

#4 lore raw

Re: [PATCH v3 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC

Quoted 19 lines · Tomer Maimon
Quoted 11 lines

Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml line 26

Quoted 7 lines
Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file +7 -0
+properties:
+  compatible:
+    items:
+      - enum:
+          - nuvoton,npcm845-bpc
+          - nuvoton,npcm750-bpc
+      - const: nuvoton,npcm-bpc

That's not what I suggested. I asked to make 845 compatible with 750. This works, but I want to be sure you really, really understand the consequences of this.

Did you mean to do the compatible as follows?
properties:
compatible:
items:
- enum:
- nuvoton,npcm845-bpc
- const: nuvoton,npcm750-bpc

Quoted 2 lines

Appreciate it if you could explain what is the difference between the compatibility suggested in V3?

Your v3 says there is a generic, common to all current and future SoCs, interface to BPC.

Best regards,
Krzysztof

author maintainer
#5 lore raw

PATCH v3 2/3 soc: nuvoton: add configuration menu

In reply to Tomer Maimon

Add menu configuration to Nuvoton SoC drivers.

---
 drivers/soc/nuvoton/Kconfig | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/soc/nuvoton/Kconfig +6 -1
index df46182088ec..d5102f5f0c28 100644
@@ -1,5 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
-menuconfig WPCM450_SOC
+
+menu "NUVOTON SoC drivers"
+
+config WPCM450_SOC
 	tristate "Nuvoton WPCM450 SoC driver"
 	default y if ARCH_WPCM450
 	select SOC_BUS
@@ -9,3 +12,5 @@ menuconfig WPCM450_SOC
 
 	  This driver provides information such as the SoC model and
 	  revision.
+
+endmenu
Signature · 1 line
2.34.1
author maintainer
#6 lore raw

PATCH v3 3/3 soc: nuvoton: add NPCM BPC driver

In reply to Tomer Maimon

Add Nuvoton BMC NPCM BIOS post code (BPC) driver.

The NPCM BPC monitoring two configurable I/O address written by the host on the bus.

---
 drivers/soc/nuvoton/Kconfig    |   9 +
 drivers/soc/nuvoton/Makefile   |   1 +
 drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++
 3 files changed, 397 insertions(+)
 create mode 100644 drivers/soc/nuvoton/npcm-bpc.c
drivers/soc/nuvoton/Kconfig +9 -0
index d5102f5f0c28..ebd162633942 100644
@@ -2,6 +2,15 @@
 
 menu "NUVOTON SoC drivers"
 
+config NPCM_BPC
+	tristate "NPCM BIOS Post Code support"
+	depends on (ARCH_NPCM || COMPILE_TEST)
+	help
+	  Provides NPCM driver to control the BIOS Post Code
+	  interface which allows the BMC to monitor and save
+	  the data written by the host to an arbitrary I/O port,
+	  the BPC is connected to the host thourgh LPC or eSPI bus.
+
 config WPCM450_SOC
 	tristate "Nuvoton WPCM450 SoC driver"
 	default y if ARCH_WPCM450
drivers/soc/nuvoton/Makefile +1 -0
index e30317b4e829..c6c96079c6e9 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_NPCM_BPC)		+= npcm-bpc.o
 obj-$(CONFIG_WPCM450_SOC)	+= wpcm450-soc.o
drivers/soc/nuvoton/npcm-bpc.c new file +387 -0

387 lines not on this page · raw message

Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver

Quoted 20 lines · Tomer Maimon

Add Nuvoton BMC NPCM BIOS post code (BPC) driver.

The NPCM BPC monitoring two configurable I/O address written by the host on the bus.

---
 drivers/soc/nuvoton/Kconfig    |   9 +
 drivers/soc/nuvoton/Makefile   |   1 +
 drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++
 3 files changed, 397 insertions(+)
 create mode 100644 drivers/soc/nuvoton/npcm-bpc.c
drivers/soc/nuvoton/Kconfig +0 -0
index d5102f5f0c28..ebd162633942 100644
@@ -2,6 +2,15 @@
 
 menu "NUVOTON SoC drivers"

...

drivers/soc/nuvoton/Kconfig

Quoted 11 lines
drivers/soc/nuvoton/Kconfig +11 -0
+
+static int npcm_bpc_config_irq(struct npcm_bpc *bpc,
+			       struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	int rc;
+
+	bpc->irq = platform_get_irq(pdev, 0);
+	if (bpc->irq < 0) {
+		dev_err(dev, "get IRQ failed\n");
+		return bpc->irq;

return dev_err_probe

drivers/soc/nuvoton/Kconfig

Quoted 7 lines
drivers/soc/nuvoton/Kconfig +7 -0
+	}
+
+	rc = devm_request_irq(dev, bpc->irq,
+			      npcm_bpc_irq, IRQF_SHARED,
+			      DEVICE_NAME, bpc);
+	if (rc < 0) {
+		dev_warn(dev, "Unable to request IRQ %d\n", bpc->irq);

return dev_err_probe

Quoted 105 lines
drivers/soc/nuvoton/Kconfig +105 -0
+		return rc;
+	}
+
+	return 0;
+}
+
+static int npcm_enable_bpc(struct npcm_bpc *bpc, struct device *dev,
+			   int channel, u16 host_port)
+{
+	u8 addr_en, reg_en;
+	int err;
+
+	init_waitqueue_head(&bpc->ch[channel].wq);
+
+	err = kfifo_alloc(&bpc->ch[channel].fifo, BPC_KFIFO_SIZE,
+			  GFP_KERNEL);
+	if (err)
+		return err;
+
+	bpc->ch[channel].miscdev.minor = MISC_DYNAMIC_MINOR;
+	bpc->ch[channel].miscdev.name =
+		devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME, channel);
+	bpc->ch[channel].miscdev.fops = &npcm_bpc_fops;
+	bpc->ch[channel].miscdev.parent = dev;
+	err = misc_register(&bpc->ch[channel].miscdev);
+	if (err)
+		return err;
+
+	bpc->ch[channel].data = bpc;
+	bpc->ch[channel].host_reset = false;
+
+	/* Enable host snoop channel at requested port */
+	switch (channel) {
+	case 0:
+		addr_en = FIFO_IOADDR1_ENABLE;
+		iowrite8((u8)host_port & 0xFF,
+			 bpc->base + NPCM_BPCFA1L_REG);
+		iowrite8((u8)(host_port >> 8),
+			 bpc->base + NPCM_BPCFA1M_REG);
+		break;
+	case 1:
+		addr_en = FIFO_IOADDR2_ENABLE;
+		iowrite8((u8)host_port & 0xFF,
+			 bpc->base + NPCM_BPCFA2L_REG);
+		iowrite8((u8)(host_port >> 8),
+			 bpc->base + NPCM_BPCFA2M_REG);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (bpc->en_dwcap)
+		addr_en = FIFO_DWCAPTURE;
+
+	/*
+	 * Enable FIFO Ready Interrupt, FIFO Capture of I/O addr,
+	 * and Host Reset
+	 */
+	reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG);
+	iowrite8(reg_en | addr_en | FIFO_READY_INT_ENABLE |
+		 HOST_RESET_INT_ENABLE, bpc->base + NPCM_BPCFEN_REG);
+
+	return 0;
+}
+
+static void npcm_disable_bpc(struct npcm_bpc *bpc, int channel)
+{
+	u8 reg_en;
+
+	switch (channel) {
+	case 0:
+		reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG);
+		if (bpc->en_dwcap)
+			iowrite8(reg_en & ~FIFO_DWCAPTURE,
+				 bpc->base + NPCM_BPCFEN_REG);
+		else
+			iowrite8(reg_en & ~FIFO_IOADDR1_ENABLE,
+				 bpc->base + NPCM_BPCFEN_REG);
+		break;
+	case 1:
+		reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG);
+		iowrite8(reg_en & ~FIFO_IOADDR2_ENABLE,
+			 bpc->base + NPCM_BPCFEN_REG);
+		break;
+	default:
+		return;
+	}
+
+	if (!(reg_en & (FIFO_IOADDR1_ENABLE | FIFO_IOADDR2_ENABLE)))
+		iowrite8(reg_en &
+			 ~(FIFO_READY_INT_ENABLE | HOST_RESET_INT_ENABLE),
+			 bpc->base + NPCM_BPCFEN_REG);
+
+	kfifo_free(&bpc->ch[channel].fifo);
+	misc_deregister(&bpc->ch[channel].miscdev);
+}
+
+static int npcm_bpc_probe(struct platform_device *pdev)
+{
+	struct npcm_bpc *bpc;
+	struct device *dev;
+	u32 port;
+	int err;
+
+	dev = &pdev->dev;

drivers/soc/nuvoton/Kconfig

Quoted 10 lines
drivers/soc/nuvoton/Kconfig +10 -0
+
+	bpc = devm_kzalloc(dev, sizeof(*bpc), GFP_KERNEL);
+	if (!bpc)
+		return -ENOMEM;
+
+	bpc->base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(bpc->base))
+		return PTR_ERR(bpc->base);
+
+	dev_set_drvdata(&pdev->dev, bpc);

Why do you use pdev again? Look earlier, you have local variable for this.

Quoted 31 lines
drivers/soc/nuvoton/Kconfig +31 -0
+
+	err = of_property_read_u32_index(dev->of_node, "nuvoton,monitor-ports",
+					 0, &port);
+	if (err) {
+		dev_err(dev, "no monitor ports configured\n");
+		return -ENODEV;
+	}
+
+	bpc->en_dwcap =
+		of_property_read_bool(dev->of_node, "nuvoton,bpc-en-dwcapture");
+
+	bpc->dev = dev;
+
+	err = npcm_bpc_config_irq(bpc, pdev);
+	if (err)
+		return err;
+
+	err = npcm_enable_bpc(bpc, dev, 0, port);
+	if (err) {
+		dev_err(dev, "Enable BIOS post code I/O port 0 failed\n");
+		return err;
+	}
+
+	/*
+	 * Configuration of second BPC channel port is optional
+	 * Double-Word Capture ignoring address 2
+	 */
+	if (!bpc->en_dwcap) {
+		if (of_property_read_u32_index(dev->of_node,
+					       "nuvoton,monitor-ports", 1,
+					       &port) == 0) {

drivers/soc/nuvoton/Kconfig

Quoted 10 lines
drivers/soc/nuvoton/Kconfig +10 -0
+			err = npcm_enable_bpc(bpc, dev, 1, port);
+			if (err) {
+				dev_err(dev, "Enable BIOS post code I/O port 1 failed, disable I/O port 0\n");
+				npcm_disable_bpc(bpc, 0);
+				return err;
+			}
+		}
+	}
+
+	pr_info("NPCM BIOS Post Code probe\n");

Drop

Quoted 6 lines
drivers/soc/nuvoton/Kconfig +6 -0
+
+	return err;
+}
+
+static int npcm_bpc_remove(struct platform_device *pdev)
+{

drivers/soc/nuvoton/Kconfig

Quoted 10 lines
drivers/soc/nuvoton/Kconfig +10 -0
+	struct npcm_bpc *bpc = dev_get_drvdata(&pdev->dev);
+	u8 reg_en;
+
+	reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG);
+
+	if (reg_en & FIFO_IOADDR1_ENABLE)
+		npcm_disable_bpc(bpc, 0);
+	if (reg_en & FIFO_IOADDR2_ENABLE)
+		npcm_disable_bpc(bpc, 1);
+

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver

In reply to Tomer Maimon
Quoted 5 lines · Tomer Maimon

Add Nuvoton BMC NPCM BIOS post code (BPC) driver.

The NPCM BPC monitoring two configurable I/O address written by the host on the bus.

Quoted 7 lines
---
 drivers/soc/nuvoton/Kconfig    |   9 +
 drivers/soc/nuvoton/Makefile   |   1 +
 drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++
 3 files changed, 397 insertions(+)
 create mode 100644 drivers/soc/nuvoton/npcm-bpc.c

I try hard to avoid having user interfaces in drivers/soc/, that subsystem should primarily be used for things that don't have an existing subsystem in the kernel and are used by other in-kernel drivers but don't export hteir own misc device.

Quoted 7 lines
drivers/soc/nuvoton/Kconfig +0 -0
index d5102f5f0c28..ebd162633942 100644
@@ -2,6 +2,15 @@
 
 menu "NUVOTON SoC drivers"

drivers/soc/nuvoton/Kconfig line 13

Quoted 10 lines
drivers/soc/nuvoton/Kconfig +9 -0
 
+config NPCM_BPC
+	tristate "NPCM BIOS Post Code support"
+	depends on (ARCH_NPCM || COMPILE_TEST)
+	help
+	  Provides NPCM driver to control the BIOS Post Code
+	  interface which allows the BMC to monitor and save
+	  the data written by the host to an arbitrary I/O port,
+	  the BPC is connected to the host thourgh LPC or eSPI bus.
+

This one in particular looks like this might be implemented by more than one BMC type, it's a fairly generic functionality.

Have you talked to the other maintainers of SoCs used in OpenBMC about coming up with a common interface?

drivers/soc/nuvoton/Kconfig line 14

Quoted 1 line
drivers/soc/nuvoton/Kconfig +1 -0
+#define DEVICE_NAME	"npcm-bpc"

[nitpicking] No need for macros like this one, open-coding the string is usually more readable.

Arnd

author maintainer
#9 lore raw

Re: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver

Hi Arnd,

Thanks for your comments.

Quoted 41 lines · Arnd Bergmann
Quoted 5 lines · Tomer Maimon

Add Nuvoton BMC NPCM BIOS post code (BPC) driver.

The NPCM BPC monitoring two configurable I/O address written by the host on the bus.

Quoted 7 lines
---
 drivers/soc/nuvoton/Kconfig    |   9 +
 drivers/soc/nuvoton/Makefile   |   1 +
 drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++
 3 files changed, 397 insertions(+)
 create mode 100644 drivers/soc/nuvoton/npcm-bpc.c

I try hard to avoid having user interfaces in drivers/soc/, that subsystem should primarily be used for things that don't have an existing subsystem in the kernel and are used by other in-kernel drivers but don't export hteir own misc device.

Quoted 7 lines
drivers/soc/nuvoton/Kconfig +0 -0
index d5102f5f0c28..ebd162633942 100644
@@ -2,6 +2,15 @@
 
 menu "NUVOTON SoC drivers"

drivers/soc/nuvoton/Kconfig line 13

Quoted 10 lines
drivers/soc/nuvoton/Kconfig +9 -0
 
+config NPCM_BPC
+     tristate "NPCM BIOS Post Code support"
+     depends on (ARCH_NPCM || COMPILE_TEST)
+     help
+       Provides NPCM driver to control the BIOS Post Code
+       interface which allows the BMC to monitor and save
+       the data written by the host to an arbitrary I/O port,
+       the BPC is connected to the host thourgh LPC or eSPI bus.
+

This one in particular looks like this might be implemented by more than one BMC type, it's a fairly generic functionality.

Quoted 2 lines

Have you talked to the other maintainers of SoCs used in OpenBMC about coming up with a common interface?

Yes, Both Nuvoton and Aspeed use the same user-facing code to manage the host snooping.
https://github.com/openbmc/phosphor-host-postd

Quoted 2 lines

drivers/soc/nuvoton/Kconfig line 14

Quoted 2 lines
drivers/soc/nuvoton/Kconfig +1 -0
+#define DEVICE_NAME  "npcm-bpc"

Will do.

Quoted 5 lines

[nitpicking] No need for macros like this one, open-coding the string is usually more readable.

Arnd

Thanks,

Tomer

#10 lore raw

Re: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver

Quoted 15 lines · Tomer Maimon
Quoted 14 lines · Arnd Bergmann

drivers/soc/nuvoton/Kconfig line 13

Quoted 10 lines
drivers/soc/nuvoton/Kconfig +9 -0
+config NPCM_BPC
+     tristate "NPCM BIOS Post Code support"
+     depends on (ARCH_NPCM || COMPILE_TEST)
+     help
+       Provides NPCM driver to control the BIOS Post Code
+       interface which allows the BMC to monitor and save
+       the data written by the host to an arbitrary I/O port,
+       the BPC is connected to the host thourgh LPC or eSPI bus.
+

This one in particular looks like this might be implemented by more than one BMC type, it's a fairly generic functionality.

Quoted 5 lines
Quoted 2 lines

Have you talked to the other maintainers of SoCs used in OpenBMC about coming up with a common interface?

Yes, Both Nuvoton and Aspeed use the same user-facing code to manage the host snooping.
https://github.com/openbmc/phosphor-host-postd

Ok, that's good. I found the driver in drivers/soc/aspeed/aspeed-lpc-snoop.c now and see that the implementation looks very similar.

I think we should do two things here:

- split out the common code into a shared module that exports the symbols to be used by either one

- find a better place for both drivers outside of drivers/soc. I would suggest drivers/misc/bmc/ but am open to other suggestions.

Arnd

author maintainer
#11 lore raw

Re: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver

Hi Arnd,

Thanks for your suggestion.

Appreciate it if Joel, OpenBMC Linux kernel maintainer, could share his thoughts about it.

Quoted 28 lines · Arnd Bergmann
Quoted 15 lines · Tomer Maimon
Quoted 14 lines · Arnd Bergmann

drivers/soc/nuvoton/Kconfig line 13

Quoted 10 lines
drivers/soc/nuvoton/Kconfig +9 -0
+config NPCM_BP
+     tristate "NPCM BIOS Post Code support"
+     depends on (ARCH_NPCM || COMPILE_TEST)
+     help
+       Provides NPCM driver to control the BIOS Post Code
+       interface which allows the BMC to monitor and save
+       the data written by the host to an arbitrary I/O port,
+       the BPC is connected to the host thourgh LPC or eSPI bus.
+

This one in particular looks like this might be implemented by more than one BMC type, it's a fairly generic functionality.

Quoted 5 lines
Quoted 2 lines

Have you talked to the other maintainers of SoCs used in OpenBMC about coming up with a common interface?

Yes, Both Nuvoton and Aspeed use the same user-facing code to manage the host snooping.
https://github.com/openbmc/phosphor-host-postd

Ok, that's good. I found the driver in drivers/soc/aspeed/aspeed-lpc-snoop.c now and see that the implementation looks very similar.

I think we should do two things here:

Quoted 7 lines

- split out the common code into a shared module that exports the symbols to be used by either one

- find a better place for both drivers outside of drivers/soc. I would suggest drivers/misc/bmc/ but am open to other suggestions.

Arnd

Best regards,

Tomer

#12 lore raw

Re: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver

In reply to Tomer Maimon
kernel test robot noticed the following build warnings:

Hi Tomer,

kernel test robot noticed the following build warnings:

[auto build test WARNING on soc/for-next]
[also build test WARNING on robh/for-next linus/master v6.7-rc5 next-20231214] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tomer-Maimon/dt-bindings-soc-nuvoton-Add-NPCM-BPC/20231214-030714
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
patch link:    https://lore.kernel.org/r/20231213190528.3751583-4-tmaimon77%40gmail.com
patch subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver
config: arm64-randconfig-r123-20231215 (https://download.01.org/0day-ci/archive/20231215/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20231215/[email protected]/reproduce)

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

sparse warnings: (new ones prefixed by >>)

>> drivers/soc/nuvoton/npcm-bpc.c:105:25: sparse: sparse: cast to restricted __poll_t

drivers/soc/nuvoton/npcm-bpc.c:108:26: sparse: sparse: cast to restricted __poll_t

vim +105 drivers/soc/nuvoton/npcm-bpc.c

    97	
    98	static __poll_t npcm_bpc_poll(struct file *file, struct poll_table_struct *pt)
    99	{
   100		struct npcm_bpc_channel *chan = npcm_file_to_ch(file);
   101		__poll_t mask = 0;
   102	
   103		poll_wait(file, &chan->wq, pt);
   104		if (!kfifo_is_empty(&chan->fifo))
 > 105			mask = (__poll_t)POLLIN;

106
107 if (chan->host_reset) {
108 mask |= (__poll_t)POLLHUP;
109 chan->host_reset = false;
110 }
111
112 return mask;
113 }
114

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