Skip to contentSkip to conversation

Add Nuvoton NPCM845 support

PATCH In review Stanley Chu 5 participants 31 messages Dec 15, 2021 – Mar 11, 2022 2 messages not in the archive

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover Add Nuvoton NPCM845 support

The patch series add basic supoorts for NPCM845, which is Nuvoton's 4th-generation BMC (Baseboard Management Controller).
Add drivers to support Clock,Timer,Uart,GPIO, Pinctrl, SPI Flash Access for NPCM8xx SoC.

Stanley Chu (9):
arm: nuvoton: Add support for Nuvoton NPCM845 BMC
clk: nuvoton: Add support for NPCM845
timer: npcm: Add NPCM timer support
serial: npcm: Add support for Nuvoton NPCM SoCs
gpio: npcm: Add support for Nuvoton NPCM SoCs
pinctrl: nuvoton: Add NPCM8xx pinctrl driver
spi: npcm-fiu: add NPCM8xx FIU controller driver
ARM: dts: Add Nuvoton NPCM845 device tree
ARM: configs: Add defconfig for Nuvoton NPCM845

 arch/arm/Kconfig                          |    9 +
 arch/arm/Makefile                         |    1 +
 arch/arm/dts/Makefile                     |    2 +
 arch/arm/dts/nuvoton-common-npcm8xx.dtsi  |  598 ++++++
 arch/arm/dts/nuvoton-npcm845-evb.dts      |  264 +++
 arch/arm/dts/nuvoton-npcm845-pincfg.dtsi  | 2007 ++++++++++++++++++++
 arch/arm/dts/nuvoton-npcm8xx-pinctrl.dtsi |  623 +++++++
 arch/arm/include/asm/arch-npcm8xx/clock.h |  164 ++
 arch/arm/include/asm/arch-npcm8xx/espi.h  |   23 +
 arch/arm/include/asm/arch-npcm8xx/fiu.h   |   61 +
 arch/arm/include/asm/arch-npcm8xx/gcr.h   |  313 ++++
 arch/arm/include/asm/arch-npcm8xx/gpio.h  |   11 +
 arch/arm/include/asm/arch-npcm8xx/rst.h   |   32 +
 arch/arm/include/asm/arch-npcm8xx/uart.h  |   82 +
 arch/arm/mach-nuvoton/Kconfig             |   24 +
 arch/arm/mach-nuvoton/Makefile            |    1 +
 arch/arm/mach-nuvoton/npcm8xx/Kconfig     |   18 +
 arch/arm/mach-nuvoton/npcm8xx/Makefile    |    1 +
 arch/arm/mach-nuvoton/npcm8xx/cpu.c       |  170 ++
 arch/arm/mach-nuvoton/npcm8xx/reset.c     |   51 +
 board/nuvoton/arbel/Kconfig               |   18 +
 board/nuvoton/arbel/MAINTAINERS           |    7 +
 board/nuvoton/arbel/Makefile              |    1 +
 board/nuvoton/arbel/arbel.c               |   33 +
 configs/arbel_evb_defconfig               |   77 +
 drivers/clk/Makefile                      |    1 +
 drivers/clk/nuvoton/Makefile              |    1 +
 drivers/clk/nuvoton/clk_npcm8xx.c         |  213 +++
 drivers/gpio/Kconfig                      |    7 +
 drivers/gpio/Makefile                     |    1 +
 drivers/gpio/npcm_gpio.c                  |  133 ++
 drivers/pinctrl/Kconfig                   |    1 +
 drivers/pinctrl/Makefile                  |    1 +
 drivers/pinctrl/nuvoton/Kconfig           |    6 +
 drivers/pinctrl/nuvoton/Makefile          |    1 +
 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 2042 +++++++++++++++++++++
 drivers/serial/Kconfig                    |    7 +
 drivers/serial/Makefile                   |    1 +
 drivers/serial/serial_npcm.c              |  137 ++
 drivers/spi/Kconfig                       |    6 +
 drivers/spi/Makefile                      |    1 +
 drivers/spi/npcm_fiu_spi.c                |  311 ++++
 drivers/timer/Kconfig                     |    7 +
 drivers/timer/Makefile                    |    1 +
 drivers/timer/npcm_timer.c                |   82 +
 include/configs/arbel.h                   |   54 +
 include/dt-bindings/clock/npcm845-clock.h |   17 +
 47 files changed, 7622 insertions(+)
 create mode 100644 arch/arm/dts/nuvoton-common-npcm8xx.dtsi
 create mode 100644 arch/arm/dts/nuvoton-npcm845-evb.dts
 create mode 100644 arch/arm/dts/nuvoton-npcm845-pincfg.dtsi
 create mode 100644 arch/arm/dts/nuvoton-npcm8xx-pinctrl.dtsi
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/clock.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/espi.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/fiu.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/gcr.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/gpio.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/rst.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/uart.h
 create mode 100644 arch/arm/mach-nuvoton/Kconfig
 create mode 100644 arch/arm/mach-nuvoton/Makefile
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Kconfig
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Makefile
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/cpu.c
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/reset.c
 create mode 100644 board/nuvoton/arbel/Kconfig
 create mode 100644 board/nuvoton/arbel/MAINTAINERS
 create mode 100644 board/nuvoton/arbel/Makefile
 create mode 100644 board/nuvoton/arbel/arbel.c
 create mode 100644 configs/arbel_evb_defconfig
 create mode 100644 drivers/clk/nuvoton/Makefile
 create mode 100644 drivers/clk/nuvoton/clk_npcm8xx.c
 create mode 100644 drivers/gpio/npcm_gpio.c
 create mode 100644 drivers/pinctrl/nuvoton/Kconfig
 create mode 100644 drivers/pinctrl/nuvoton/Makefile
 create mode 100644 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
 create mode 100644 drivers/serial/serial_npcm.c
 create mode 100644 drivers/spi/npcm_fiu_spi.c
 create mode 100644 drivers/timer/npcm_timer.c
 create mode 100644 include/configs/arbel.h
 create mode 100644 include/dt-bindings/clock/npcm845-clock.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/9 arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Add basic support for the Nuvoton NPCM845 BMC.

---
 arch/arm/Kconfig                          |   9 +
 arch/arm/Makefile                         |   1 +
 arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
 arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
 arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
 arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
 arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
 arch/arm/mach-nuvoton/Kconfig             |  24 ++
 arch/arm/mach-nuvoton/Makefile            |   1 +
 arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
 arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
 arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++
 arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++
 board/nuvoton/arbel/Kconfig               |  18 ++
 board/nuvoton/arbel/Makefile              |   1 +
 board/nuvoton/arbel/arbel.c               |  33 +++
 include/configs/arbel.h                   |  54 ++++
 17 files changed, 924 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/clock.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/espi.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/gcr.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/gpio.h
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/rst.h
 create mode 100644 arch/arm/mach-nuvoton/Kconfig
 create mode 100644 arch/arm/mach-nuvoton/Makefile
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Kconfig
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Makefile
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/cpu.c
 create mode 100644 arch/arm/mach-nuvoton/npcm8xx/reset.c
 create mode 100644 board/nuvoton/arbel/Kconfig
 create mode 100644 board/nuvoton/arbel/Makefile
 create mode 100644 board/nuvoton/arbel/arbel.c
 create mode 100644 include/configs/arbel.h
arch/arm/Kconfig +9 -0
index f7f03837fe..80ec42f6be 100644
@@ -1952,6 +1952,13 @@ config TARGET_XENGUEST_ARM64
 	select LINUX_KERNEL_IMAGE_HEADER
 	select XEN_SERIAL
 	select SSCANF
+
+config ARCH_NPCM
+	bool "Support Nuvoton SoCs"
+	select DM
+	select OF_CONTROL
+	imply CMD_DM
+
 endchoice
 
 config SUPPORT_PASSING_ATAGS
@@ -2150,6 +2157,8 @@ source "arch/arm/mach-imx/Kconfig"
 
 source "arch/arm/mach-nexell/Kconfig"
 
+source "arch/arm/mach-nuvoton/Kconfig"
+
 source "board/armltd/total_compute/Kconfig"
 
 source "board/bosch/shc/Kconfig"
arch/arm/Makefile +1 -0
index ad757e982e..29a0250ab6 100644
@@ -92,6 +92,7 @@ machine-$(CONFIG_ARCH_VERSAL)		+= versal
 machine-$(CONFIG_ARCH_ZYNQ)		+= zynq
 machine-$(CONFIG_ARCH_ZYNQMP)		+= zynqmp
 machine-$(CONFIG_ARCH_ZYNQMP_R5)	+= zynqmp-r5
+machine-$(CONFIG_ARCH_NPCM)		+= nuvoton
 
 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
arch/arm/include/asm/arch-npcm8xx/clock.h new file +164 -0

164 lines not on this page · raw message

arch/arm/include/asm/arch-npcm8xx/espi.h new file +23 -0
new file mode 100644
index 0000000000..d4de012b02
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_ESPI_H_
+#define _NPCM_ESPI_H_
+
+#define NPCM_ESPI_BA		0xF009F000
+/* Register offsets */
+#define ESPICFG			0x04
+#define ESPIHINDP		0x80
+
+/* Channel Supported */
+#define ESPICFG_CHNSUPP_MASK	0x0F
+#define ESPICFG_CHNSUPP_SHFT	24
+
+/* I/O Mode Supported */
+#define ESPICFG_IOMODE_SHIFT		8
+#define ESPI_IO_MODE_SINGLE_DUAL_QUAD	3
+
+/* Maximum Frequency Supported */
+#define ESPICFG_MAXFREQ_SHIFT		10
+#define ESPI_MAX_33_MHZ			2
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gcr.h new file +313 -0

313 lines not on this page · raw message

arch/arm/include/asm/arch-npcm8xx/gpio.h new file +11 -0
new file mode 100644
index 0000000000..234a1d3de9
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GPIO_H_
+#define _NPCM_GPIO_H_
+
+#define NPCM_GPIO_BA		0xF0010000
+
+#endif
arch/arm/include/asm/arch-npcm8xx/rst.h new file +32 -0
new file mode 100644
index 0000000000..ffaff50fe2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_RST_H_
+#define _NPCM_RST_H_
+
+enum reset_type {
+	PORST_TYPE    = 0x01,
+	CORST_TYPE    = 0x02,
+	WD0RST_TYPE   = 0x03,
+	SWR1ST_TYPE   = 0x04,
+	SWR2ST_TYPE   = 0x05,
+	SWR3ST_TYPE   = 0x06,
+	SWR4ST_TYPE   = 0x07,
+	WD1RST_TYPE   = 0x08,
+	WD2RST_TYPE   = 0x09,
+	UNKNOWN_TYPE  = 0x10,
+};
+
+#define PORST 0x80000000
+#define CORST 0x40000000
+#define WD0RST 0x20000000
+#define SWR1ST 0x10000000
+#define SWR2ST 0x08000000
+#define SWR3ST 0x04000000
+#define SWR4ST 0x02000000
+#define WD1RST 0x01000000
+#define WD2RST 0x00800000
+#define RESSR_MASK 0xff800000
+
+enum reset_type npcm8xx_reset_reason(void);
+
+#endif
arch/arm/mach-nuvoton/Kconfig new file +24 -0
new file mode 100644
index 0000000000..e014dd4b79
@@ -0,0 +1,24 @@
+if ARCH_NPCM
+
+config SYS_ARCH
+	default "arm"
+
+config SYS_TEXT_BASE
+	default 0x8000
+
+choice
+	prompt "Nuvoton SoC select"
+	default ARCH_NPCM8XX
+
+config ARCH_NPCM8XX
+	bool "Support Nuvoton NPCM8xx SoC"
+	select ARM64
+	help
+	  General support for NPCM8xx BMC (Arbel).
+	  Nuvoton NPCM8xx BMC is based on the Cortex A35.
+
+endchoice
+
+source "arch/arm/mach-nuvoton/npcm8xx/Kconfig"
+
+endif
arch/arm/mach-nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..e75689a1a0
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += npcm8xx/
arch/arm/mach-nuvoton/npcm8xx/Kconfig new file +18 -0
new file mode 100644
index 0000000000..478a046ad5
@@ -0,0 +1,18 @@
+if ARCH_NPCM8XX
+
+config SYS_CPU
+	default "armv8"
+
+config SYS_SOC
+	default "npcm8xx"
+
+config TARGET_ARBEL_EVB
+	bool "Arbel-EVB"
+	help
+	  ARBEL_EVB is Nuvoton evaluation board for NPCM845 SoC,
+	  supports general functions of Basebase Management Controller
+	  (BMC).
+
+source "board/nuvoton/arbel/Kconfig"
+
+endif
arch/arm/mach-nuvoton/npcm8xx/Makefile new file +1 -0
new file mode 100644
index 0000000000..c62a4aa20a
@@ -0,0 +1 @@
+obj-y += reset.o cpu.o
arch/arm/mach-nuvoton/npcm8xx/cpu.c new file +170 -0

170 lines not on this page · raw message

arch/arm/mach-nuvoton/npcm8xx/reset.c new file +51 -0

51 lines not on this page · raw message

board/nuvoton/arbel/Kconfig new file +18 -0
new file mode 100644
index 0000000000..4a03ea1abf
@@ -0,0 +1,18 @@
+if TARGET_ARBEL_EVB
+
+config SYS_BOARD
+	default "arbel"
+
+config SYS_VENDOR
+	default "nuvoton"
+
+config SYS_CONFIG_NAME
+	default "arbel"
+
+config SYS_MEM_TOP_HIDE
+	hex "Reserved TOP memory"
+	default 0xB000000
+	help
+	  Reserve memory for ECC/GFX/VCD/ECE.
+
+endif
board/nuvoton/arbel/Makefile new file +1 -0
new file mode 100644
index 0000000000..f9ad1dea34
@@ -0,0 +1 @@
+obj-y	+= arbel.o
board/nuvoton/arbel/arbel.c new file +33 -0
new file mode 100644
index 0000000000..86cef98c5f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/mach-types.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+	gd->bd->bi_arch_number = MACH_TYPE_NPCMX50;
+	gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100UL);
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+	/*
+	 * get dram active size value from bootblock.
+	 * Value sent using scrpad_02 register.
+	 */
+	gd->ram_size = readl(&gcr->scrpad_b);
+
+	return 0;
+}
include/configs/arbel.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Hi Stanley,

Quoted 16 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

---
  arch/arm/Kconfig                          |   9 +
  arch/arm/Makefile                         |   1 +
  arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
  arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
  arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
  arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
  arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
  arch/arm/mach-nuvoton/Kconfig             |  24 ++
  arch/arm/mach-nuvoton/Makefile            |   1 +
  arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
  arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
  arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++

Here ^^^ you setup timer, but it should be a separate driver IMHO. At least this is what I've done for imxrt.
Same goes for clock, there is no clock driver and you setup spi clock directly inside the same file with npcm_sysintf_init() while that should be part of the clock driver.

Also all defines regarding to clocks and peripherals should go into their driver.

Quoted 1 line
  arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++

Here you've mixed up the architecture(above) and the board(below) in a single patch.

Quoted 4 lines
  board/nuvoton/arbel/Kconfig               |  18 ++
  board/nuvoton/arbel/Makefile              |   1 +
  board/nuvoton/arbel/arbel.c               |  33 +++
  include/configs/arbel.h                   |  54 ++++

arbel should be arbel-evk

I stop here, because there could be big changes if others agree.

Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 1,061 lines
  17 files changed, 924 insertions(+)

create mode 100644 arch/arm/include/asm/arch-npcm8xx/clock.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/espi.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gcr.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gpio.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/rst.h create mode 100644 arch/arm/mach-nuvoton/Kconfig create mode 100644 arch/arm/mach-nuvoton/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Kconfig create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/cpu.c create mode 100644 arch/arm/mach-nuvoton/npcm8xx/reset.c create mode 100644 board/nuvoton/arbel/Kconfig create mode 100644 board/nuvoton/arbel/Makefile create mode 100644 board/nuvoton/arbel/arbel.c create mode 100644 include/configs/arbel.h

arch/arm/Kconfig +9 -0
index f7f03837fe..80ec42f6be 100644
@@ -1952,6 +1952,13 @@ config TARGET_XENGUEST_ARM64
  	select LINUX_KERNEL_IMAGE_HEADER
  	select XEN_SERIAL
  	select SSCANF
+
+config ARCH_NPCM
+	bool "Support Nuvoton SoCs"
+	select DM
+	select OF_CONTROL
+	imply CMD_DM
+
  endchoice
 
  config SUPPORT_PASSING_ATAGS
@@ -2150,6 +2157,8 @@ source "arch/arm/mach-imx/Kconfig"
 
  source "arch/arm/mach-nexell/Kconfig"
 
+source "arch/arm/mach-nuvoton/Kconfig"
+
  source "board/armltd/total_compute/Kconfig"
 
  source "board/bosch/shc/Kconfig"
arch/arm/Makefile +1 -0
index ad757e982e..29a0250ab6 100644
@@ -92,6 +92,7 @@ machine-$(CONFIG_ARCH_VERSAL)		+= versal
  machine-$(CONFIG_ARCH_ZYNQ)		+= zynq
  machine-$(CONFIG_ARCH_ZYNQMP)		+= zynqmp
  machine-$(CONFIG_ARCH_ZYNQMP_R5)	+= zynqmp-r5
+machine-$(CONFIG_ARCH_NPCM)		+= nuvoton
 
  machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
arch/arm/include/asm/arch-npcm8xx/clock.h new file +164 -0
new file mode 100644
index 0000000000..088b536b7b
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_CLOCK_H_
+#define _NPCM_CLOCK_H_
+
+#define NPCM_CLK_BA		0xF0801000
+enum {
+	APB1  = 1,
+	APB2  = 2,
+	APB3  = 3,
+	APB4  = 4,
+	APB5  = 5,
+	SPI0  = 10,
+	SPI1  = 11,
+	SPI3  = 13,
+	SPIX  = 14,
+};
+
+/* Clock Select Register (CLKSEL) */
+#define CLKSEL_RCPCKSEL             27
+#define CLKSEL_RGSEL                25
+#define CLKSEL_GFXMSEL              21
+#define CLKSEL_CLKOUTSEL            18
+#define CLKSEL_PCICKSEL             16
+#define CLKSEL_ADCCKSEL             14
+#define CLKSEL_MCCKSEL              12
+#define CLKSEL_SUCKSEL              10
+#define CLKSEL_UARTCKSEL            8
+#define CLKSEL_SDCKSEL              6
+#define CLKSEL_PIXCKSEL             4
+#define CLKSEL_CPUCKSEL             0
+
+/* Clock Divider Control Register 1 (CLKDIV1) */
+#define CLKDIV1_ADCCKDIV            28
+#define CLKDIV1_CLK4DIV             26
+#define CLKDIV1_PRE_ADCCKDIV        21
+#define CLKDIV1_UARTDIV             16
+#define CLKDIV1_MMCCKDIV            11
+#define CLKDIV1_SPI3CKDIV           6
+#define CLKDIV1_PCICKDIV            2
+
+/* Clock Divider Control Register 2 (CLKDIV2) */
+#define CLKDIV2_APB4CKDIV           30
+#define CLKDIV2_APB3CKDIV           28
+#define CLKDIV2_APB2CKDIV           26
+#define CLKDIV2_APB1CKDIV           24
+#define CLKDIV2_APB5CKDIV           22
+#define CLKDIV2_CLKOUTDIV           16
+#define CLKDIV2_GFXCKDIV            13
+#define CLKDIV2_SUCKDIV             8
+#define CLKDIV2_SU48CKDIV           4
+
+/* PLL Control Register 2 (PLLCON2) */
+#define PLLCON_LOKI                31
+#define PLLCON_LOKS                30
+#define PLLCON_FBDV                16
+#define PLLCON_OTDV2               13
+#define PLLCON_PWDEN               12
+#define PLLCON_OTDV1               8
+#define PLLCON_INDV                0
+
+/* CPUCKSEL (CPU/AMBA/MC Clock Source Select Bit) */
+#define CLKSEL_CPUCKSEL_PLL0        0x00   /* 0 0: PLL0 clock*/
+#define CLKSEL_CPUCKSEL_PLL1        0x01   /* 0 1: PLL1 clock */
+#define CLKSEL_CPUCKSEL_CLKREF      0x02   /* 1 0: CLKREF input (25 MHZ, default) */
+#define CLKSEL_CPUCKSEL_SYSBPCK     0x03   /* 1 1: Bypass clock from pin SYSBPCK */
+
+/* UARTCKSEL (Core and Host UART Clock Source Select Bit). */
+#define CLKSEL_UARTCKSEL_PLL0       0x00  /* 0 0: PLL0    clock. */
+#define CLKSEL_UARTCKSEL_PLL1       0x01  /* 0 1: PLL1    clock. */
+#define CLKSEL_UARTCKSEL_CLKREF     0x02  /* 1 0: CLKREF  clock (25 MHZ, default). */
+#define CLKSEL_UARTCKSEL_PLL2       0x03  /* 1 1: PLL2    clock divided by 2. */
+
+/* SDCKSEL (SDHC Clock Source Select Bit). */
+#define CLKSEL_SDCKSEL_PLL0         0x00   /* 0 0: PLL0    clock.  */
+#define CLKSEL_SDCKSEL_PLL1         0x01   /* 0 1: PLL1    clock.  */
+#define CLKSEL_SDCKSEL_CLKREF       0x02   /* 1 0: CLKREF clock (25 MHZ, default).  */
+#define CLKSEL_SDCKSEL_PLL2         0x03   /* 1 1: PLL2    clock divided by 2.  */
+
+/* IP Software Reset Register 1 (IPSRST1), offset 0x20 */
+#define IPSRST1_USBDEV1             5
+#define IPSRST1_USBDEV2             8
+#define IPSRST1_USBDEV3             25
+#define IPSRST1_USBDEV4             22
+#define IPSRST1_USBDEV5             23
+#define IPSRST1_USBDEV6             24
+#define IPSRST1_GMAC4               21
+#define IPSRST1_GMAC3               6
+
+/* IP Software Reset Register 2 (IPSRST2), offset 0x24 */
+#define IPSRST2_GMAC1               28
+#define IPSRST2_GMAC2               25
+#define IPSRST2_USBHOST1            26
+#define IPSRST2_SDHC                9
+#define IPSRST2_MMC                 8
+
+/* IP Software Reset Register 3 (IPSRST3), offset 0x34 */
+#define IPSRST3_USBPHY1             24
+#define IPSRST3_USBPHY2             25
+#define IPSRST3_USBHUB              8
+#define IPSRST3_USBDEV9             7
+#define IPSRST3_USBDEV8             6
+#define IPSRST3_USBDEV7             5
+#define IPSRST3_USBDEV0             4
+
+/* IP Software Reset Register 4 (IPSRST4), offset 0x74 */
+#define IPSRST4_USBHOST2            31
+#define IPSRST4_USBPHY3             25
+
+#define EXT_CLOCK_FREQUENCY_KHZ	    25 * 1000 * 1UL
+#define EXT_CLOCK_FREQUENCY_MHZ	    25
+
+struct clk_ctl {
+	unsigned int  clken1;
+	unsigned int  clksel;
+	unsigned int  clkdiv1;
+	unsigned int  pllcon0;
+	unsigned int  pllcon1;
+	unsigned int  swrstr;
+	unsigned char res1[0x8];
+	unsigned int  ipsrst1;
+	unsigned int  ipsrst2;
+	unsigned int  clken2;
+	unsigned int  clkdiv2;
+	unsigned int  clken3;
+	unsigned int  ipsrst3;
+	unsigned int  wd0rcr;
+	unsigned int  wd1rcr;
+	unsigned int  wd2rcr;
+	unsigned int  swrstc1;
+	unsigned int  swrstc2;
+	unsigned int  swrstc3;
+	unsigned int  tiprstc;
+	unsigned int  pllcon2;
+	unsigned int  clkdiv3;
+	unsigned int  corstc;
+	unsigned int  pllcong;
+	unsigned int  ahbckfi;
+	unsigned int  seccnt;
+	unsigned int  cntr25m;
+	unsigned int  clken4;
+	unsigned int  ipsrst4;
+	unsigned int  busto;
+	unsigned int  clkdiv4;
+	unsigned int  wd0rcrb;
+	unsigned int  wd1rcrb;
+	unsigned int  wd2rcrb;
+	unsigned int  swrstc1b;
+	unsigned int  swrstc2b;
+	unsigned int  swrstc3b;
+	unsigned int  tiprstcb;
+	unsigned int  corstcb;
+	unsigned int  ipsrstdis1;
+	unsigned int  ipsrstdis2;
+	unsigned int  ipsrstdis3;
+	unsigned int  ipsrstdis4;
+	unsigned char res2[0x10];
+	unsigned int  thrtl_cnt;
+};
+
+#endif
arch/arm/include/asm/arch-npcm8xx/espi.h new file +23 -0
new file mode 100644
index 0000000000..d4de012b02
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_ESPI_H_
+#define _NPCM_ESPI_H_
+
+#define NPCM_ESPI_BA		0xF009F000
+/* Register offsets */
+#define ESPICFG			0x04
+#define ESPIHINDP		0x80
+
+/* Channel Supported */
+#define ESPICFG_CHNSUPP_MASK	0x0F
+#define ESPICFG_CHNSUPP_SHFT	24
+
+/* I/O Mode Supported */
+#define ESPICFG_IOMODE_SHIFT		8
+#define ESPI_IO_MODE_SINGLE_DUAL_QUAD	3
+
+/* Maximum Frequency Supported */
+#define ESPICFG_MAXFREQ_SHIFT		10
+#define ESPI_MAX_33_MHZ			2
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gcr.h new file +313 -0
new file mode 100644
index 0000000000..14a4b2dbfb
@@ -0,0 +1,313 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GCR_H_
+#define _NPCM_GCR_H_
+
+#define NPCM_GCR_BA		0xF0800000
+/* On-Chip ARBEL NPCM8XX VERSIONS */
+
+#define ARBEL_Z1			0x00A35850
+#define ARBEL_A1			0x04a35850
+#define ARBEL_NPCM845			0x00000000
+#define ARBEL_NPCM830			0x00300395
+#define ARBEL_NPCM810			0x00000220
+
+/* Function Lock Register 2 (FLOCKR2) */
+#define FLOCKR2_MMCRST               12
+#define FLOCKR2_MMCRSTLK             13
+#define FLOCKR2_G35DA2P              18
+
+/* Power-On Setting Register (PWRON) */
+#define PWRON_BSPA			4         /* STRAP5 */
+#define PWRON_SECEN			7         /* STRAP8 */
+
+/* Multiple Function Pin Select Register 1 (MFSEL1) */
+#define MFSEL1_SIRQSE               31
+#define MFSEL1_IOX1SEL              30
+#define MFSEL1_HSI2BSEL             29
+#define MFSEL1_HSI1BSEL             28
+#define MFSEL1_DVH1SEL              27
+#define MFSEL1_LPCSEL               26
+#define MFSEL1_PECIB                25
+#define MFSEL1_GSPISEL              24
+#define MFSEL1_SMISEL               22
+#define MFSEL1_CLKOSEL              21
+#define MFSEL1_DVOSEL               18
+#define MFSEL1_KBCICSEL             17
+#define MFSEL1_R2MDSEL              16
+#define MFSEL1_R2ERRSEL             15
+#define MFSEL1_RMII2SEL             14
+#define MFSEL1_R1MDSEL              13
+#define MFSEL1_R1ERRSEL             12
+#define MFSEL1_HSI2ASEL             11
+#define MFSEL1_HSI1ASEL             10
+#define MFSEL1_BSPSEL               9
+#define MFSEL1_SMB2SEL              8
+#define MFSEL1_SMB1SEL              7
+#define MFSEL1_SMB0SEL              6
+#define MFSEL1_HSI2CSEL             5
+#define MFSEL1_HSI1CSEL             4
+#define MFSEL1_S0CS1SEL             3
+#define MFSEL1_SMB5SEL              2
+#define MFSEL1_SMB4SEL              1
+#define MFSEL1_SMB3SEL              0
+
+/* Multiple Function Pin Select Register 3 (MFSEL3) */
+#define MFSEL3_DVODEDLY             27
+#define MFSEL3_DDRDVOSEL            26
+#define MFSEL3_MMCCDSEL             25
+#define MFSEL3_BU1SEL               24
+#define MFSEL3_I3C5SEL              22
+#define MFSEL3_WDO2SEL              20
+#define MFSEL3_WDO1SEL              19
+#define MFSEL3_IOXHSEL              18
+#define MFSEL3_PCIEPUSE             17
+#define MFSEL3_CLKRUNSEL            16
+#define MFSEL3_IOX2SEL              14
+#define MFSEL3_PSPISEL              13
+#define MFSEL3_MMC8SEL              11
+#define MFSEL3_MMCSEL               10
+#define MFSEL3_RMII1SEL             9
+#define MFSEL3_SMB15SEL             8
+#define MFSEL3_SMB14SEL             7
+#define MFSEL3_SMB13SEL             6
+#define MFSEL3_SMB12SEL             5
+#define MFSEL3_SPI1SEL              4
+#define MFSEL3_FIN1916SELB          3
+#define MFSEL3_SMB7SEL              2
+#define MFSEL3_SMB6SEL              1
+#define MFSEL3_SCISEL               0
+
+/* Multiple Function Pin Select Register 4 (MFSEL4) */
+#define MFSEL4_SMB11DDC             29
+#define MFSEL4_SXCS1SEL             28
+#define MFSEL4_SPXSEL               27
+#define MFSEL4_RG2SEL               24
+#define MFSEL4_RG2MSEL              23
+#define MFSEL4_BU2SELB              22
+#define MFSEL4_SG1MSEL              21
+#define MFSEL4_SP3QSEL              20
+#define MFSEL4_S3CS3SEL             19
+#define MFSEL4_S3CS2SEL             18
+#define MFSEL4_S3CS1SEL             17
+#define MFSEL4_SP3SEL               16
+#define MFSEL4_SP0QSEL              15
+#define MFSEL4_SMB11SEL             14
+#define MFSEL4_SMB10SEL             13
+#define MFSEL4_SMB9SEL              12
+#define MFSEL4_SMB8SEL              11
+#define MFSEL4_DBGTRSEL             10
+#define MFSEL4_CKRQSEL              9
+#define MFSEL4_ESPISEL              8
+#define MFSEL4_MMCRSEL              6
+#define MFSEL4_SD1PSEL              5
+#define MFSEL4_ROSEL                4
+#define MFSEL4_ESPIPMESEL           2
+#define MFSEL4_BSPASEL              1
+#define MFSEL4_JTAG2SEL             0
+
+/* Multiple Function Pin Select Register 5 (MFSEL5) */
+#define MFSEL5_R3OENSEL             14
+#define MFSEL5_RMII3SEL             11
+#define MFSEL5_R2OENSEL             10
+#define MFSEL5_R1OENSEL             9
+#define MFSEL5_NSPI1CS3SEL          5
+#define MFSEL5_NSPI1CS2SEL          4
+#define MFSEL5_SPI1D23SEL           3
+#define MFSEL5_NSPI1CS1SEL          0
+
+/* Multiple Function Pin Select Register 6 (MFSEL6) */
+#define MFSEL6_GPIO1836SEL          19
+#define MFSEL6_FM1SEL               17
+
+/* Multiple Function Pin Select Register 7 (MFSEL7) */
+#define MFSEL7_SMB15SELB            27
+#define MFSEL7_GPIO1889SEL          25
+
+/* USB PHY1 Control Register (USB1PHYCTL) */
+#define USB1PHYCTL_RS				28
+/* USB PHY2 Control Register (USB2PHYCTL) */
+#define USB2PHYCTL_RS				28
+/* USB PHY2 Control Register (USB3PHYCTL) */
+#define USB3PHYCTL_RS				28
+
+/* Integration Control Register (INTCR) */
+#define  INTCR_DUDKSMOD             30
+#define  INTCR_DDC3I                29
+#define  INTCR_KVMSI                28
+#define  INTCR_DEHS                 27
+#define  INTCR_GGPCT2_0             24
+#define  INTCR_SGC2                 23
+#define  INTCR_DSNS_TRIG            21
+#define  INTCR_DAC_SNS              20
+#define  INTCR_SGC1                 19
+#define  INTCR_LDDRB                18
+#define  INTCR_GIRST                17
+#define  INTCR_DUDKSEN              16
+#define  INTCR_DACOFF               15
+#define  INTCR_DACSEL               14
+#define  INTCR_GFXINT               12
+#define  INTCR_DACOSOVR             10
+#define  INTCR_GFXIFDIS             8
+#define  INTCR_H2RQDIS              9
+#define  INTCR_H2DISPOFF            8
+#define  INTCR_GFXINT2              7
+#define  INTCR_VGAIOEN              6
+#define  INTCR_PSPIFEN              4
+#define  INTCR_HIFEN                3
+#define  INTCR_SMBFEN               2
+#define  INTCR_MFTFEN               1
+#define  INTCR_KCSRST_MODE          0
+
+/* Integration Control Register (INTCR2) */
+#define  INTCR2_WDC                   21
+
+/* Integration Control Register (INTCR3) */
+#define  INTCR3_USBLPBK2              31          /* USB loop-backed HOST 1/2 */
+#define  INTCR3_USBLPBK               24          /* USB loop-backed mode on/off */
+#define  INTCR3_USBPHY3SW             14          /* 2 bits */
+#define  INTCR3_USBPHY2SW             12          /* 2 bits */
+#define  INTCR3_USBPPS                6
+#define  INTCR3_UHUB_RWUD             5
+
+/* Integration Control Register (INTCR4) */
+#define  INTCR4_GMMAP1                24
+#define  INTCR4_GMMAP0                16
+#define  INTCR4_R3EN                  14
+#define  INTCR4_R2EN                  13
+#define  INTCR4_R1EN                  12
+#define  INTCR4_RGMIIREF              6
+
+/* I2C Segment Pin Select Register (I2CSEGSEL) */
+#define I2CSEGSEL_S0DECFG			3
+#define I2CSEGSEL_S4DECFG			17
+
+/* I2C Segment Control Register (I2CSEGCTL) */
+#define I2CSEGCTL_S0DEN				20
+#define I2CSEGCTL_S0DWE				21
+#define I2CSEGCTL_S4DEN				24
+#define I2CSEGCTL_S4DWE				25
+#define I2CSEGCTL_INIT_VAL		0x9333F000
+
+struct npcm_gcr {
+	unsigned int  pdid;
+	unsigned int  pwron;
+	unsigned int  swstrps;
+	unsigned int  rsvd1[2];
+	unsigned int  miscpe;
+	unsigned int  spldcnt;
+	unsigned int  rsvd2[1];
+	unsigned int  flockr2;
+	unsigned int  flockr3;
+	unsigned int  rsvd3[3];
+	unsigned int  a35_mode;
+	unsigned int  spswc;
+	unsigned int  intcr;
+	unsigned int  intsr;
+	unsigned int  obscr1;
+	unsigned int  obsdr1;
+	unsigned int  rsvd4[1];
+	unsigned int  hifcr;
+	unsigned int  rsvd5[3];
+	unsigned int  intcr2;
+	unsigned int  rsvd6[1];
+	unsigned int  srcnt;
+	unsigned int  ressr;
+	unsigned int  rlockr1;
+	unsigned int  flockr1;
+	unsigned int  dscnt;
+	unsigned int  mdlr;
+	unsigned int  scrpad_c;
+	/* scrpad_b: holds the active dram size (value set by bootblock) */
+	unsigned int  scrpad_b;
+	unsigned int  rsvd7[4];
+	unsigned int  daclvlr;
+	unsigned int  intcr3;
+	unsigned int  pcirctl;
+	unsigned int  rsvd8[2];
+	unsigned int  vsintr;
+	unsigned int  rsvd9[1];
+	unsigned int  sd2sur1;
+	unsigned int  sd2sur2;
+	unsigned int  sd2irv3;
+	unsigned int  intcr4;
+	unsigned int  obscr2;
+	unsigned int  obsdr2;
+	unsigned int  rsvd10[5];
+	unsigned int  i2csegsel;
+	unsigned int  i2csegctl;
+	unsigned int  vsrcr;
+	unsigned int  mlockr;
+	unsigned int  rsvd11[8];
+	unsigned int  etsr;
+	unsigned int  dft1r;
+	unsigned int  dft2r;
+	unsigned int  dft3r;
+	unsigned int  edffsr;
+	unsigned int  rsvd12[1];
+	unsigned int  intcrpce3;
+	unsigned int  intcrpce2;
+	unsigned int  intcrpce0;
+	unsigned int  intcrpce1;
+	unsigned int  dactest;
+	unsigned int  scrpad;
+	unsigned int  usb1phyctl;
+	unsigned int  usb2phyctl;
+	unsigned int  usb3phyctl;
+	unsigned int  intsr2;
+	unsigned int  intcrpce2b;
+	unsigned int  intcrpce0b;
+	unsigned int  intcrpce1b;
+	unsigned int  intcrpce3b;
+	unsigned int  rsvd13[4];
+	unsigned int  intcrpce2c;
+	unsigned int  intcrpce0c;
+	unsigned int  intcrpce1c;
+	unsigned int  intcrpce3c;
+	unsigned int  rsvd14[40];
+	unsigned int  sd2irv4;
+	unsigned int  sd2irv5;
+	unsigned int  sd2irv6;
+	unsigned int  sd2irv7;
+	unsigned int  sd2irv8;
+	unsigned int  sd2irv9;
+	unsigned int  sd2irv10;
+	unsigned int  sd2irv11;
+	unsigned int  rsvd15[8];
+	unsigned int  mfsel1;
+	unsigned int  mfsel2;
+	unsigned int  mfsel3;
+	unsigned int  mfsel4;
+	unsigned int  mfsel5;
+	unsigned int  mfsel6;
+	unsigned int  mfsel7;
+	unsigned int  rsvd16[1];
+	unsigned int  mfsel_lk1;
+	unsigned int  mfsel_lk2;
+	unsigned int  mfsel_lk3;
+	unsigned int  mfsel_lk4;
+	unsigned int  mfsel_lk5;
+	unsigned int  mfsel_lk6;
+	unsigned int  mfsel_lk7;
+	unsigned int  rsvd17[1];
+	unsigned int  mfsel_set1;
+	unsigned int  mfsel_set2;
+	unsigned int  mfsel_set3;
+	unsigned int  mfsel_set4;
+	unsigned int  mfsel_set5;
+	unsigned int  mfsel_set6;
+	unsigned int  mfsel_set7;
+	unsigned int  rsvd18[1];
+	unsigned int  mfsel_clr1;
+	unsigned int  mfsel_clr2;
+	unsigned int  mfsel_clr3;
+	unsigned int  mfsel_clr4;
+	unsigned int  mfsel_clr5;
+	unsigned int  mfsel_clr6;
+	unsigned int  mfsel_clr7;
+	};
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gpio.h new file +11 -0
new file mode 100644
index 0000000000..234a1d3de9
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GPIO_H_
+#define _NPCM_GPIO_H_
+
+#define NPCM_GPIO_BA		0xF0010000
+
+#endif
arch/arm/include/asm/arch-npcm8xx/rst.h new file +32 -0
new file mode 100644
index 0000000000..ffaff50fe2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_RST_H_
+#define _NPCM_RST_H_
+
+enum reset_type {
+	PORST_TYPE    = 0x01,
+	CORST_TYPE    = 0x02,
+	WD0RST_TYPE   = 0x03,
+	SWR1ST_TYPE   = 0x04,
+	SWR2ST_TYPE   = 0x05,
+	SWR3ST_TYPE   = 0x06,
+	SWR4ST_TYPE   = 0x07,
+	WD1RST_TYPE   = 0x08,
+	WD2RST_TYPE   = 0x09,
+	UNKNOWN_TYPE  = 0x10,
+};
+
+#define PORST 0x80000000
+#define CORST 0x40000000
+#define WD0RST 0x20000000
+#define SWR1ST 0x10000000
+#define SWR2ST 0x08000000
+#define SWR3ST 0x04000000
+#define SWR4ST 0x02000000
+#define WD1RST 0x01000000
+#define WD2RST 0x00800000
+#define RESSR_MASK 0xff800000
+
+enum reset_type npcm8xx_reset_reason(void);
+
+#endif
arch/arm/mach-nuvoton/Kconfig new file +24 -0
new file mode 100644
index 0000000000..e014dd4b79
@@ -0,0 +1,24 @@
+if ARCH_NPCM
+
+config SYS_ARCH
+	default "arm"
+
+config SYS_TEXT_BASE
+	default 0x8000
+
+choice
+	prompt "Nuvoton SoC select"
+	default ARCH_NPCM8XX
+
+config ARCH_NPCM8XX
+	bool "Support Nuvoton NPCM8xx SoC"
+	select ARM64
+	help
+	  General support for NPCM8xx BMC (Arbel).
+	  Nuvoton NPCM8xx BMC is based on the Cortex A35.
+
+endchoice
+
+source "arch/arm/mach-nuvoton/npcm8xx/Kconfig"
+
+endif
arch/arm/mach-nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..e75689a1a0
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += npcm8xx/
arch/arm/mach-nuvoton/npcm8xx/Kconfig new file +18 -0
new file mode 100644
index 0000000000..478a046ad5
@@ -0,0 +1,18 @@
+if ARCH_NPCM8XX
+
+config SYS_CPU
+	default "armv8"
+
+config SYS_SOC
+	default "npcm8xx"
+
+config TARGET_ARBEL_EVB
+	bool "Arbel-EVB"
+	help
+	  ARBEL_EVB is Nuvoton evaluation board for NPCM845 SoC,
+	  supports general functions of Basebase Management Controller
+	  (BMC).
+
+source "board/nuvoton/arbel/Kconfig"
+
+endif
arch/arm/mach-nuvoton/npcm8xx/Makefile new file +1 -0
new file mode 100644
index 0000000000..c62a4aa20a
@@ -0,0 +1 @@
+obj-y += reset.o cpu.o
arch/arm/mach-nuvoton/npcm8xx/cpu.c new file +170 -0
new file mode 100644
index 0000000000..8a7315d535
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <cpu_func.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/arch/espi.h>
+#include <asm/armv8/mmu.h>
+#include <asm/system.h>
+#include <asm/global_data.h>
+
+/* System Counter */
+struct sctr_regs {
+	u32 cntcr;
+	u32 cntsr;
+	u32 cntcv1;
+	u32 cntcv2;
+	u32 resv1[4];
+	u32 cntfid0;
+	u32 cntfid1;
+	u32 cntfid2;
+	u32 resv2[1001];
+	u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE		BIT(0)
+#define SC_CNTCR_HDBG		BIT(1)
+#define SC_CNTCR_FREQ0		BIT(8)
+#define SC_CNTCR_FREQ1		BIT(9)
+
+#define SYSCNT_CTRL_BASE_ADDR   0xF07FC000
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int print_cpuinfo(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+	unsigned int id = 0;
+	unsigned long mpidr_val = 0;
+	unsigned int mdlr = 0;
+
+	asm volatile("mrs %0, mpidr_el1" : "=r" (mpidr_val));
+
+	mdlr = readl(&gcr->mdlr);
+
+	printf("CPU-%d: ", (unsigned int)(mpidr_val & 0x3));
+
+	switch (mdlr) {
+	case ARBEL_NPCM845:
+		printf("NPCM845 ");
+		break;
+	case ARBEL_NPCM830:
+		printf("NPCM830 ");
+		break;
+	case ARBEL_NPCM810:
+		printf("NPCM810 ");
+		break;
+	default:
+		printf("NPCM8XX ");
+		break;
+	}
+
+	id = readl(&gcr->pdid);
+	switch (id) {
+	case ARBEL_Z1:
+		printf("Z1 @ ");
+		break;
+	case ARBEL_A1:
+		printf("A1 @ ");
+		break;
+	default:
+		printf("Unknown\n");
+		break;
+	}
+
+	return 0;
+}
+
+static void npcm_sysintf_init(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+	u32 espi_ch_supp, val;
+
+	espi_ch_supp = ofnode_conf_read_int("espi-channel-support", 0);
+
+	if (espi_ch_supp) {
+		/* Use eSPI function and initialize ESPICFG */
+		u32 hindp = 0x00011110 | espi_ch_supp;
+
+		writel((readl(&gcr->mfsel4) | (1 << MFSEL4_ESPISEL)), &gcr->mfsel4);
+		writel(hindp, NPCM_ESPI_BA + ESPIHINDP);
+		val = readl(NPCM_ESPI_BA + ESPICFG);
+		val |= ESPI_IO_MODE_SINGLE_DUAL_QUAD << ESPICFG_IOMODE_SHIFT;
+		val |= ESPI_MAX_33_MHZ << ESPICFG_MAXFREQ_SHIFT;
+		val |= ((espi_ch_supp & ESPICFG_CHNSUPP_MASK) << ESPICFG_CHNSUPP_SHFT);
+		writel(val, NPCM_ESPI_BA + ESPICFG);
+	} else {
+		/* Use LPC function */
+		writel((readl(&gcr->mfsel1) | (1 << MFSEL1_LPCSEL)), &gcr->mfsel1);
+	}
+}
+
+int arch_cpu_init(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+	if (!IS_ENABLED(CONFIG_SYS_DCACHE_OFF)) {
+		/* enable cache to speed up system running */
+		if (get_sctlr() & CR_M)
+			return 0;
+
+		icache_enable();
+		__asm_invalidate_dcache_all();
+		__asm_invalidate_tlb_all();
+		set_sctlr(get_sctlr() | CR_C);
+	}
+
+	/* Power voltage select setup */
+	setbits_le32(&gcr->vsrcr, BIT(30));
+
+	npcm_sysintf_init();
+
+	return 0;
+}
+
+static struct mm_region npcm_mem_map[1 + CONFIG_NR_DRAM_BANKS + 1] = {
+	{
+		/* DRAM */
+		.phys = 0x0UL,
+		.virt = 0x0UL,
+		.size = 0x80000000UL,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+			 PTE_BLOCK_INNER_SHARE
+	},
+	{
+		.phys = 0x80000000UL,
+		.virt = 0x80000000UL,
+		.size = 0x80000000UL,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	},
+	{
+		/* List terminator */
+		0,
+	}
+};
+
+struct mm_region *mem_map = npcm_mem_map;
+
+int timer_init(void)
+{
+	struct sctr_regs *sctr = (struct sctr_regs *)SYSCNT_CTRL_BASE_ADDR;
+	unsigned int cntfrq_el0;
+
+	__asm__ __volatile__("mrs %0, CNTFRQ_EL0\n\t" : "=r" (cntfrq_el0) : : "memory");
+	writel(cntfrq_el0, &sctr->cntfid0);
+
+	clrsetbits_le32(&sctr->cntcr, SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1,
+			SC_CNTCR_ENABLE | SC_CNTCR_HDBG);
+
+	gd->arch.tbl = 0;
+	gd->arch.tbu = 0;
+
+	return 0;
+}
arch/arm/mach-nuvoton/npcm8xx/reset.c new file +51 -0
new file mode 100644
index 0000000000..7fbed7ba76
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/rst.h>
+#include <asm/arch/gcr.h>
+
+void reset_cpu(void)
+{
+	/* Watcdog reset - WTCR register set  WTE-BIT7 WTRE-BIT1 WTR-BIT0 */
+	writel(0x83, 0xf000801c);
+
+	while (1)
+		;
+}
+
+void reset_misc(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+	/* clear WDC */
+	writel(readl(&gcr->intcr2) & ~(1 << INTCR2_WDC), &gcr->intcr2);
+}
+
+enum reset_type npcm8xx_reset_reason(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+	enum reset_type type = UNKNOWN_TYPE;
+	u32 value = readl(&gcr->ressr);
+
+	if (value == 0)
+		value = ~readl(&gcr->intcr2);
+
+	value &= RESSR_MASK;
+
+	if (value & CORST)
+		type = CORST;
+	if (value & WD0RST)
+		type = WD0RST;
+	if (value & WD1RST)
+		type = WD1RST;
+	if (value & WD2RST)
+		type = WD2RST;
+	if (value & PORST)
+		type = PORST;
+
+	return type;
+}
board/nuvoton/arbel/Kconfig new file +18 -0
new file mode 100644
index 0000000000..4a03ea1abf
@@ -0,0 +1,18 @@
+if TARGET_ARBEL_EVB
+
+config SYS_BOARD
+	default "arbel"
+
+config SYS_VENDOR
+	default "nuvoton"
+
+config SYS_CONFIG_NAME
+	default "arbel"
+
+config SYS_MEM_TOP_HIDE
+	hex "Reserved TOP memory"
+	default 0xB000000
+	help
+	  Reserve memory for ECC/GFX/VCD/ECE.
+
+endif
board/nuvoton/arbel/Makefile new file +1 -0
new file mode 100644
index 0000000000..f9ad1dea34
@@ -0,0 +1 @@
+obj-y	+= arbel.o
board/nuvoton/arbel/arbel.c new file +33 -0
new file mode 100644
index 0000000000..86cef98c5f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/mach-types.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+	gd->bd->bi_arch_number = MACH_TYPE_NPCMX50;
+	gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100UL);
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+	/*
+	 * get dram active size value from bootblock.
+	 * Value sent using scrpad_02 register.
+	 */
+	gd->ram_size = readl(&gcr->scrpad_b);
+
+	return 0;
+}
include/configs/arbel.h new file +54 -0
new file mode 100644
index 0000000000..2cb658c3e6
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef __CONFIG_ARBEL_H
+#define __CONFIG_ARBEL_H
+
+#define CONFIG_GICV2
+#define GICD_BASE			(0xDFFF9000)
+#define GICC_BASE			(0xDFFFA000)
+
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS   1
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG
+#define CONFIG_SYS_MAXARGS              32
+#define CONFIG_SYS_CBSIZE               256
+#define CONFIG_SYS_PBSIZE               (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_PROMPT_HUSH_PS2	    "> "
+#define CONFIG_SYS_BOOTM_LEN            (20 << 20)
+#define CONFIG_SYS_BOOTMAPSZ            (20 << 20)
+#define CONFIG_SYS_SDRAM_BASE           0x0
+#define CONFIG_SYS_INIT_SP_ADDR         (0x00008000 - GENERATED_GBL_DATA_SIZE)
+#define CONFIG_SYS_MONITOR_LEN          (256 << 10)
+#define CONFIG_SYS_MONITOR_BASE	        CONFIG_SYS_TEXT_BASE
+#define CONFIG_BAUDRATE                 115200
+#define CONFIG_SYS_HZ                   1000
+#define CONFIG_BITBANGMII_MULTI
+
+/* Default environemnt variables */
+#define CONFIG_BOOTCOMMAND "run common_bootargs; run romboot"
+#define CONFIG_EXTRA_ENV_SETTINGS   "uimage_flash_addr=80200000\0"   \
+		"stdin=serial\0"   \
+		"stdout=serial\0"   \
+		"stderr=serial\0"    \
+		"ethact=gmac1\0"   \
+		"autostart=no\0"   \
+		"ethaddr=00:00:F7:A0:00:FC\0"    \
+		"eth1addr=00:00:F7:A0:00:FD\0"   \
+		"eth2addr=00:00:F7:A0:00:FE\0"    \
+		"eth3addr=00:00:F7:A0:00:FF\0"    \
+		"gatewayip=192.168.0.17\0"    \
+		"serverip=192.168.0.17\0"    \
+		"ipaddr=192.168.0.15\0"    \
+		"romboot=echo Booting Kernel from flash at 0x${uimage_flash_addr}; " \
+		"echo Using bootargs: ${bootargs};bootm ${uimage_flash_addr}\0" \
+		"earlycon=uart8250,mmio32,0xf0000000\0" \
+		"console=ttyS0,115200n8\0" \
+		"common_bootargs=setenv bootargs earlycon=${earlycon} root=/dev/ram " \
+		"console=${console} ramdisk_size=48000\0" \
+		"\0"
+
+#endif
#3 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Hi Giulio,

Thank you for your comment, I've submitted a clk driver patch to address this.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

--
Stanley

Quoted 1,111 lines · Giulio Benetti

Hi Stanley,

Quoted 16 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

---
  arch/arm/Kconfig                          |   9 +
  arch/arm/Makefile                         |   1 +
  arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
  arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
  arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
  arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
  arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
  arch/arm/mach-nuvoton/Kconfig             |  24 ++
  arch/arm/mach-nuvoton/Makefile            |   1 +
  arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
  arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
  arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++

Here ^^^ you setup timer, but it should be a separate driver IMHO. At least this is what I've done for imxrt.
Same goes for clock, there is no clock driver and you setup spi clock directly inside the same file with npcm_sysintf_init() while that should be part of the clock driver.

Also all defines regarding to clocks and peripherals should go into their driver.

Quoted 1 line
  arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++

Here you've mixed up the architecture(above) and the board(below) in a single patch.

Quoted 4 lines
  board/nuvoton/arbel/Kconfig               |  18 ++
  board/nuvoton/arbel/Makefile              |   1 +
  board/nuvoton/arbel/arbel.c               |  33 +++
  include/configs/arbel.h                   |  54 ++++

arbel should be arbel-evk

I stop here, because there could be big changes if others agree.

Best regards
--
Giulio Benetti
Benetti Engineering sas

Quoted 1,061 lines
  17 files changed, 924 insertions(+)

create mode 100644 arch/arm/include/asm/arch-npcm8xx/clock.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/espi.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gcr.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gpio.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/rst.h create mode 100644 arch/arm/mach-nuvoton/Kconfig create mode 100644 arch/arm/mach-nuvoton/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Kconfig create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/cpu.c create mode 100644 arch/arm/mach-nuvoton/npcm8xx/reset.c create mode 100644 board/nuvoton/arbel/Kconfig create mode 100644 board/nuvoton/arbel/Makefile create mode 100644 board/nuvoton/arbel/arbel.c create mode 100644 include/configs/arbel.h

arch/arm/Kconfig +9 -0
index f7f03837fe..80ec42f6be 100644
@@ -1952,6 +1952,13 @@ config TARGET_XENGUEST_ARM64
      select LINUX_KERNEL_IMAGE_HEADER
      select XEN_SERIAL
      select SSCANF
+
+config ARCH_NPCM
+     bool "Support Nuvoton SoCs"
+     select DM
+     select OF_CONTROL
+     imply CMD_DM
+
  endchoice
 
  config SUPPORT_PASSING_ATAGS
@@ -2150,6 +2157,8 @@ source "arch/arm/mach-imx/Kconfig"
 
  source "arch/arm/mach-nexell/Kconfig"
 
+source "arch/arm/mach-nuvoton/Kconfig"
+
  source "board/armltd/total_compute/Kconfig"
 
  source "board/bosch/shc/Kconfig"
arch/arm/Makefile +1 -0
index ad757e982e..29a0250ab6 100644
@@ -92,6 +92,7 @@ machine-$(CONFIG_ARCH_VERSAL)               += versal
  machine-$(CONFIG_ARCH_ZYNQ)         += zynq
  machine-$(CONFIG_ARCH_ZYNQMP)               += zynqmp
  machine-$(CONFIG_ARCH_ZYNQMP_R5)    += zynqmp-r5
+machine-$(CONFIG_ARCH_NPCM)          += nuvoton
 
  machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
arch/arm/include/asm/arch-npcm8xx/clock.h new file +164 -0
new file mode 100644
index 0000000000..088b536b7b
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_CLOCK_H_
+#define _NPCM_CLOCK_H_
+
+#define NPCM_CLK_BA          0xF0801000
+enum {
+     APB1  = 1,
+     APB2  = 2,
+     APB3  = 3,
+     APB4  = 4,
+     APB5  = 5,
+     SPI0  = 10,
+     SPI1  = 11,
+     SPI3  = 13,
+     SPIX  = 14,
+};
+
+/* Clock Select Register (CLKSEL) */
+#define CLKSEL_RCPCKSEL             27
+#define CLKSEL_RGSEL                25
+#define CLKSEL_GFXMSEL              21
+#define CLKSEL_CLKOUTSEL            18
+#define CLKSEL_PCICKSEL             16
+#define CLKSEL_ADCCKSEL             14
+#define CLKSEL_MCCKSEL              12
+#define CLKSEL_SUCKSEL              10
+#define CLKSEL_UARTCKSEL            8
+#define CLKSEL_SDCKSEL              6
+#define CLKSEL_PIXCKSEL             4
+#define CLKSEL_CPUCKSEL             0
+
+/* Clock Divider Control Register 1 (CLKDIV1) */
+#define CLKDIV1_ADCCKDIV            28
+#define CLKDIV1_CLK4DIV             26
+#define CLKDIV1_PRE_ADCCKDIV        21
+#define CLKDIV1_UARTDIV             16
+#define CLKDIV1_MMCCKDIV            11
+#define CLKDIV1_SPI3CKDIV           6
+#define CLKDIV1_PCICKDIV            2
+
+/* Clock Divider Control Register 2 (CLKDIV2) */
+#define CLKDIV2_APB4CKDIV           30
+#define CLKDIV2_APB3CKDIV           28
+#define CLKDIV2_APB2CKDIV           26
+#define CLKDIV2_APB1CKDIV           24
+#define CLKDIV2_APB5CKDIV           22
+#define CLKDIV2_CLKOUTDIV           16
+#define CLKDIV2_GFXCKDIV            13
+#define CLKDIV2_SUCKDIV             8
+#define CLKDIV2_SU48CKDIV           4
+
+/* PLL Control Register 2 (PLLCON2) */
+#define PLLCON_LOKI                31
+#define PLLCON_LOKS                30
+#define PLLCON_FBDV                16
+#define PLLCON_OTDV2               13
+#define PLLCON_PWDEN               12
+#define PLLCON_OTDV1               8
+#define PLLCON_INDV                0
+
+/* CPUCKSEL (CPU/AMBA/MC Clock Source Select Bit) */
+#define CLKSEL_CPUCKSEL_PLL0        0x00   /* 0 0: PLL0 clock*/
+#define CLKSEL_CPUCKSEL_PLL1        0x01   /* 0 1: PLL1 clock */
+#define CLKSEL_CPUCKSEL_CLKREF      0x02   /* 1 0: CLKREF input (25 MHZ, default) */
+#define CLKSEL_CPUCKSEL_SYSBPCK     0x03   /* 1 1: Bypass clock from pin SYSBPCK */
+
+/* UARTCKSEL (Core and Host UART Clock Source Select Bit). */
+#define CLKSEL_UARTCKSEL_PLL0       0x00  /* 0 0: PLL0    clock. */
+#define CLKSEL_UARTCKSEL_PLL1       0x01  /* 0 1: PLL1    clock. */
+#define CLKSEL_UARTCKSEL_CLKREF     0x02  /* 1 0: CLKREF  clock (25 MHZ, default). */
+#define CLKSEL_UARTCKSEL_PLL2       0x03  /* 1 1: PLL2    clock divided by 2. */
+
+/* SDCKSEL (SDHC Clock Source Select Bit). */
+#define CLKSEL_SDCKSEL_PLL0         0x00   /* 0 0: PLL0    clock.  */
+#define CLKSEL_SDCKSEL_PLL1         0x01   /* 0 1: PLL1    clock.  */
+#define CLKSEL_SDCKSEL_CLKREF       0x02   /* 1 0: CLKREF clock (25 MHZ, default).  */
+#define CLKSEL_SDCKSEL_PLL2         0x03   /* 1 1: PLL2    clock divided by 2.  */
+
+/* IP Software Reset Register 1 (IPSRST1), offset 0x20 */
+#define IPSRST1_USBDEV1             5
+#define IPSRST1_USBDEV2             8
+#define IPSRST1_USBDEV3             25
+#define IPSRST1_USBDEV4             22
+#define IPSRST1_USBDEV5             23
+#define IPSRST1_USBDEV6             24
+#define IPSRST1_GMAC4               21
+#define IPSRST1_GMAC3               6
+
+/* IP Software Reset Register 2 (IPSRST2), offset 0x24 */
+#define IPSRST2_GMAC1               28
+#define IPSRST2_GMAC2               25
+#define IPSRST2_USBHOST1            26
+#define IPSRST2_SDHC                9
+#define IPSRST2_MMC                 8
+
+/* IP Software Reset Register 3 (IPSRST3), offset 0x34 */
+#define IPSRST3_USBPHY1             24
+#define IPSRST3_USBPHY2             25
+#define IPSRST3_USBHUB              8
+#define IPSRST3_USBDEV9             7
+#define IPSRST3_USBDEV8             6
+#define IPSRST3_USBDEV7             5
+#define IPSRST3_USBDEV0             4
+
+/* IP Software Reset Register 4 (IPSRST4), offset 0x74 */
+#define IPSRST4_USBHOST2            31
+#define IPSRST4_USBPHY3             25
+
+#define EXT_CLOCK_FREQUENCY_KHZ          25 * 1000 * 1UL
+#define EXT_CLOCK_FREQUENCY_MHZ          25
+
+struct clk_ctl {
+     unsigned int  clken1;
+     unsigned int  clksel;
+     unsigned int  clkdiv1;
+     unsigned int  pllcon0;
+     unsigned int  pllcon1;
+     unsigned int  swrstr;
+     unsigned char res1[0x8];
+     unsigned int  ipsrst1;
+     unsigned int  ipsrst2;
+     unsigned int  clken2;
+     unsigned int  clkdiv2;
+     unsigned int  clken3;
+     unsigned int  ipsrst3;
+     unsigned int  wd0rcr;
+     unsigned int  wd1rcr;
+     unsigned int  wd2rcr;
+     unsigned int  swrstc1;
+     unsigned int  swrstc2;
+     unsigned int  swrstc3;
+     unsigned int  tiprstc;
+     unsigned int  pllcon2;
+     unsigned int  clkdiv3;
+     unsigned int  corstc;
+     unsigned int  pllcong;
+     unsigned int  ahbckfi;
+     unsigned int  seccnt;
+     unsigned int  cntr25m;
+     unsigned int  clken4;
+     unsigned int  ipsrst4;
+     unsigned int  busto;
+     unsigned int  clkdiv4;
+     unsigned int  wd0rcrb;
+     unsigned int  wd1rcrb;
+     unsigned int  wd2rcrb;
+     unsigned int  swrstc1b;
+     unsigned int  swrstc2b;
+     unsigned int  swrstc3b;
+     unsigned int  tiprstcb;
+     unsigned int  corstcb;
+     unsigned int  ipsrstdis1;
+     unsigned int  ipsrstdis2;
+     unsigned int  ipsrstdis3;
+     unsigned int  ipsrstdis4;
+     unsigned char res2[0x10];
+     unsigned int  thrtl_cnt;
+};
+
+#endif
arch/arm/include/asm/arch-npcm8xx/espi.h new file +23 -0
new file mode 100644
index 0000000000..d4de012b02
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_ESPI_H_
+#define _NPCM_ESPI_H_
+
+#define NPCM_ESPI_BA         0xF009F000
+/* Register offsets */
+#define ESPICFG                      0x04
+#define ESPIHINDP            0x80
+
+/* Channel Supported */
+#define ESPICFG_CHNSUPP_MASK 0x0F
+#define ESPICFG_CHNSUPP_SHFT 24
+
+/* I/O Mode Supported */
+#define ESPICFG_IOMODE_SHIFT         8
+#define ESPI_IO_MODE_SINGLE_DUAL_QUAD        3
+
+/* Maximum Frequency Supported */
+#define ESPICFG_MAXFREQ_SHIFT                10
+#define ESPI_MAX_33_MHZ                      2
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gcr.h new file +313 -0
new file mode 100644
index 0000000000..14a4b2dbfb
@@ -0,0 +1,313 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GCR_H_
+#define _NPCM_GCR_H_
+
+#define NPCM_GCR_BA          0xF0800000
+/* On-Chip ARBEL NPCM8XX VERSIONS */
+
+#define ARBEL_Z1                     0x00A35850
+#define ARBEL_A1                     0x04a35850
+#define ARBEL_NPCM845                        0x00000000
+#define ARBEL_NPCM830                        0x00300395
+#define ARBEL_NPCM810                        0x00000220
+
+/* Function Lock Register 2 (FLOCKR2) */
+#define FLOCKR2_MMCRST               12
+#define FLOCKR2_MMCRSTLK             13
+#define FLOCKR2_G35DA2P              18
+
+/* Power-On Setting Register (PWRON) */
+#define PWRON_BSPA                   4         /* STRAP5 */
+#define PWRON_SECEN                  7         /* STRAP8 */
+
+/* Multiple Function Pin Select Register 1 (MFSEL1) */
+#define MFSEL1_SIRQSE               31
+#define MFSEL1_IOX1SEL              30
+#define MFSEL1_HSI2BSEL             29
+#define MFSEL1_HSI1BSEL             28
+#define MFSEL1_DVH1SEL              27
+#define MFSEL1_LPCSEL               26
+#define MFSEL1_PECIB                25
+#define MFSEL1_GSPISEL              24
+#define MFSEL1_SMISEL               22
+#define MFSEL1_CLKOSEL              21
+#define MFSEL1_DVOSEL               18
+#define MFSEL1_KBCICSEL             17
+#define MFSEL1_R2MDSEL              16
+#define MFSEL1_R2ERRSEL             15
+#define MFSEL1_RMII2SEL             14
+#define MFSEL1_R1MDSEL              13
+#define MFSEL1_R1ERRSEL             12
+#define MFSEL1_HSI2ASEL             11
+#define MFSEL1_HSI1ASEL             10
+#define MFSEL1_BSPSEL               9
+#define MFSEL1_SMB2SEL              8
+#define MFSEL1_SMB1SEL              7
+#define MFSEL1_SMB0SEL              6
+#define MFSEL1_HSI2CSEL             5
+#define MFSEL1_HSI1CSEL             4
+#define MFSEL1_S0CS1SEL             3
+#define MFSEL1_SMB5SEL              2
+#define MFSEL1_SMB4SEL              1
+#define MFSEL1_SMB3SEL              0
+
+/* Multiple Function Pin Select Register 3 (MFSEL3) */
+#define MFSEL3_DVODEDLY             27
+#define MFSEL3_DDRDVOSEL            26
+#define MFSEL3_MMCCDSEL             25
+#define MFSEL3_BU1SEL               24
+#define MFSEL3_I3C5SEL              22
+#define MFSEL3_WDO2SEL              20
+#define MFSEL3_WDO1SEL              19
+#define MFSEL3_IOXHSEL              18
+#define MFSEL3_PCIEPUSE             17
+#define MFSEL3_CLKRUNSEL            16
+#define MFSEL3_IOX2SEL              14
+#define MFSEL3_PSPISEL              13
+#define MFSEL3_MMC8SEL              11
+#define MFSEL3_MMCSEL               10
+#define MFSEL3_RMII1SEL             9
+#define MFSEL3_SMB15SEL             8
+#define MFSEL3_SMB14SEL             7
+#define MFSEL3_SMB13SEL             6
+#define MFSEL3_SMB12SEL             5
+#define MFSEL3_SPI1SEL              4
+#define MFSEL3_FIN1916SELB          3
+#define MFSEL3_SMB7SEL              2
+#define MFSEL3_SMB6SEL              1
+#define MFSEL3_SCISEL               0
+
+/* Multiple Function Pin Select Register 4 (MFSEL4) */
+#define MFSEL4_SMB11DDC             29
+#define MFSEL4_SXCS1SEL             28
+#define MFSEL4_SPXSEL               27
+#define MFSEL4_RG2SEL               24
+#define MFSEL4_RG2MSEL              23
+#define MFSEL4_BU2SELB              22
+#define MFSEL4_SG1MSEL              21
+#define MFSEL4_SP3QSEL              20
+#define MFSEL4_S3CS3SEL             19
+#define MFSEL4_S3CS2SEL             18
+#define MFSEL4_S3CS1SEL             17
+#define MFSEL4_SP3SEL               16
+#define MFSEL4_SP0QSEL              15
+#define MFSEL4_SMB11SEL             14
+#define MFSEL4_SMB10SEL             13
+#define MFSEL4_SMB9SEL              12
+#define MFSEL4_SMB8SEL              11
+#define MFSEL4_DBGTRSEL             10
+#define MFSEL4_CKRQSEL              9
+#define MFSEL4_ESPISEL              8
+#define MFSEL4_MMCRSEL              6
+#define MFSEL4_SD1PSEL              5
+#define MFSEL4_ROSEL                4
+#define MFSEL4_ESPIPMESEL           2
+#define MFSEL4_BSPASEL              1
+#define MFSEL4_JTAG2SEL             0
+
+/* Multiple Function Pin Select Register 5 (MFSEL5) */
+#define MFSEL5_R3OENSEL             14
+#define MFSEL5_RMII3SEL             11
+#define MFSEL5_R2OENSEL             10
+#define MFSEL5_R1OENSEL             9
+#define MFSEL5_NSPI1CS3SEL          5
+#define MFSEL5_NSPI1CS2SEL          4
+#define MFSEL5_SPI1D23SEL           3
+#define MFSEL5_NSPI1CS1SEL          0
+
+/* Multiple Function Pin Select Register 6 (MFSEL6) */
+#define MFSEL6_GPIO1836SEL          19
+#define MFSEL6_FM1SEL               17
+
+/* Multiple Function Pin Select Register 7 (MFSEL7) */
+#define MFSEL7_SMB15SELB            27
+#define MFSEL7_GPIO1889SEL          25
+
+/* USB PHY1 Control Register (USB1PHYCTL) */
+#define USB1PHYCTL_RS                                28
+/* USB PHY2 Control Register (USB2PHYCTL) */
+#define USB2PHYCTL_RS                                28
+/* USB PHY2 Control Register (USB3PHYCTL) */
+#define USB3PHYCTL_RS                                28
+
+/* Integration Control Register (INTCR) */
+#define  INTCR_DUDKSMOD             30
+#define  INTCR_DDC3I                29
+#define  INTCR_KVMSI                28
+#define  INTCR_DEHS                 27
+#define  INTCR_GGPCT2_0             24
+#define  INTCR_SGC2                 23
+#define  INTCR_DSNS_TRIG            21
+#define  INTCR_DAC_SNS              20
+#define  INTCR_SGC1                 19
+#define  INTCR_LDDRB                18
+#define  INTCR_GIRST                17
+#define  INTCR_DUDKSEN              16
+#define  INTCR_DACOFF               15
+#define  INTCR_DACSEL               14
+#define  INTCR_GFXINT               12
+#define  INTCR_DACOSOVR             10
+#define  INTCR_GFXIFDIS             8
+#define  INTCR_H2RQDIS              9
+#define  INTCR_H2DISPOFF            8
+#define  INTCR_GFXINT2              7
+#define  INTCR_VGAIOEN              6
+#define  INTCR_PSPIFEN              4
+#define  INTCR_HIFEN                3
+#define  INTCR_SMBFEN               2
+#define  INTCR_MFTFEN               1
+#define  INTCR_KCSRST_MODE          0
+
+/* Integration Control Register (INTCR2) */
+#define  INTCR2_WDC                   21
+
+/* Integration Control Register (INTCR3) */
+#define  INTCR3_USBLPBK2              31          /* USB loop-backed HOST 1/2 */
+#define  INTCR3_USBLPBK               24          /* USB loop-backed mode on/off */
+#define  INTCR3_USBPHY3SW             14          /* 2 bits */
+#define  INTCR3_USBPHY2SW             12          /* 2 bits */
+#define  INTCR3_USBPPS                6
+#define  INTCR3_UHUB_RWUD             5
+
+/* Integration Control Register (INTCR4) */
+#define  INTCR4_GMMAP1                24
+#define  INTCR4_GMMAP0                16
+#define  INTCR4_R3EN                  14
+#define  INTCR4_R2EN                  13
+#define  INTCR4_R1EN                  12
+#define  INTCR4_RGMIIREF              6
+
+/* I2C Segment Pin Select Register (I2CSEGSEL) */
+#define I2CSEGSEL_S0DECFG                    3
+#define I2CSEGSEL_S4DECFG                    17
+
+/* I2C Segment Control Register (I2CSEGCTL) */
+#define I2CSEGCTL_S0DEN                              20
+#define I2CSEGCTL_S0DWE                              21
+#define I2CSEGCTL_S4DEN                              24
+#define I2CSEGCTL_S4DWE                              25
+#define I2CSEGCTL_INIT_VAL           0x9333F000
+
+struct npcm_gcr {
+     unsigned int  pdid;
+     unsigned int  pwron;
+     unsigned int  swstrps;
+     unsigned int  rsvd1[2];
+     unsigned int  miscpe;
+     unsigned int  spldcnt;
+     unsigned int  rsvd2[1];
+     unsigned int  flockr2;
+     unsigned int  flockr3;
+     unsigned int  rsvd3[3];
+     unsigned int  a35_mode;
+     unsigned int  spswc;
+     unsigned int  intcr;
+     unsigned int  intsr;
+     unsigned int  obscr1;
+     unsigned int  obsdr1;
+     unsigned int  rsvd4[1];
+     unsigned int  hifcr;
+     unsigned int  rsvd5[3];
+     unsigned int  intcr2;
+     unsigned int  rsvd6[1];
+     unsigned int  srcnt;
+     unsigned int  ressr;
+     unsigned int  rlockr1;
+     unsigned int  flockr1;
+     unsigned int  dscnt;
+     unsigned int  mdlr;
+     unsigned int  scrpad_c;
+     /* scrpad_b: holds the active dram size (value set by bootblock) */
+     unsigned int  scrpad_b;
+     unsigned int  rsvd7[4];
+     unsigned int  daclvlr;
+     unsigned int  intcr3;
+     unsigned int  pcirctl;
+     unsigned int  rsvd8[2];
+     unsigned int  vsintr;
+     unsigned int  rsvd9[1];
+     unsigned int  sd2sur1;
+     unsigned int  sd2sur2;
+     unsigned int  sd2irv3;
+     unsigned int  intcr4;
+     unsigned int  obscr2;
+     unsigned int  obsdr2;
+     unsigned int  rsvd10[5];
+     unsigned int  i2csegsel;
+     unsigned int  i2csegctl;
+     unsigned int  vsrcr;
+     unsigned int  mlockr;
+     unsigned int  rsvd11[8];
+     unsigned int  etsr;
+     unsigned int  dft1r;
+     unsigned int  dft2r;
+     unsigned int  dft3r;
+     unsigned int  edffsr;
+     unsigned int  rsvd12[1];
+     unsigned int  intcrpce3;
+     unsigned int  intcrpce2;
+     unsigned int  intcrpce0;
+     unsigned int  intcrpce1;
+     unsigned int  dactest;
+     unsigned int  scrpad;
+     unsigned int  usb1phyctl;
+     unsigned int  usb2phyctl;
+     unsigned int  usb3phyctl;
+     unsigned int  intsr2;
+     unsigned int  intcrpce2b;
+     unsigned int  intcrpce0b;
+     unsigned int  intcrpce1b;
+     unsigned int  intcrpce3b;
+     unsigned int  rsvd13[4];
+     unsigned int  intcrpce2c;
+     unsigned int  intcrpce0c;
+     unsigned int  intcrpce1c;
+     unsigned int  intcrpce3c;
+     unsigned int  rsvd14[40];
+     unsigned int  sd2irv4;
+     unsigned int  sd2irv5;
+     unsigned int  sd2irv6;
+     unsigned int  sd2irv7;
+     unsigned int  sd2irv8;
+     unsigned int  sd2irv9;
+     unsigned int  sd2irv10;
+     unsigned int  sd2irv11;
+     unsigned int  rsvd15[8];
+     unsigned int  mfsel1;
+     unsigned int  mfsel2;
+     unsigned int  mfsel3;
+     unsigned int  mfsel4;
+     unsigned int  mfsel5;
+     unsigned int  mfsel6;
+     unsigned int  mfsel7;
+     unsigned int  rsvd16[1];
+     unsigned int  mfsel_lk1;
+     unsigned int  mfsel_lk2;
+     unsigned int  mfsel_lk3;
+     unsigned int  mfsel_lk4;
+     unsigned int  mfsel_lk5;
+     unsigned int  mfsel_lk6;
+     unsigned int  mfsel_lk7;
+     unsigned int  rsvd17[1];
+     unsigned int  mfsel_set1;
+     unsigned int  mfsel_set2;
+     unsigned int  mfsel_set3;
+     unsigned int  mfsel_set4;
+     unsigned int  mfsel_set5;
+     unsigned int  mfsel_set6;
+     unsigned int  mfsel_set7;
+     unsigned int  rsvd18[1];
+     unsigned int  mfsel_clr1;
+     unsigned int  mfsel_clr2;
+     unsigned int  mfsel_clr3;
+     unsigned int  mfsel_clr4;
+     unsigned int  mfsel_clr5;
+     unsigned int  mfsel_clr6;
+     unsigned int  mfsel_clr7;
+     };
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gpio.h new file +11 -0
new file mode 100644
index 0000000000..234a1d3de9
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GPIO_H_
+#define _NPCM_GPIO_H_
+
+#define NPCM_GPIO_BA         0xF0010000
+
+#endif
arch/arm/include/asm/arch-npcm8xx/rst.h new file +32 -0
new file mode 100644
index 0000000000..ffaff50fe2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_RST_H_
+#define _NPCM_RST_H_
+
+enum reset_type {
+     PORST_TYPE    = 0x01,
+     CORST_TYPE    = 0x02,
+     WD0RST_TYPE   = 0x03,
+     SWR1ST_TYPE   = 0x04,
+     SWR2ST_TYPE   = 0x05,
+     SWR3ST_TYPE   = 0x06,
+     SWR4ST_TYPE   = 0x07,
+     WD1RST_TYPE   = 0x08,
+     WD2RST_TYPE   = 0x09,
+     UNKNOWN_TYPE  = 0x10,
+};
+
+#define PORST 0x80000000
+#define CORST 0x40000000
+#define WD0RST 0x20000000
+#define SWR1ST 0x10000000
+#define SWR2ST 0x08000000
+#define SWR3ST 0x04000000
+#define SWR4ST 0x02000000
+#define WD1RST 0x01000000
+#define WD2RST 0x00800000
+#define RESSR_MASK 0xff800000
+
+enum reset_type npcm8xx_reset_reason(void);
+
+#endif
arch/arm/mach-nuvoton/Kconfig new file +24 -0
new file mode 100644
index 0000000000..e014dd4b79
@@ -0,0 +1,24 @@
+if ARCH_NPCM
+
+config SYS_ARCH
+     default "arm"
+
+config SYS_TEXT_BASE
+     default 0x8000
+
+choice
+     prompt "Nuvoton SoC select"
+     default ARCH_NPCM8XX
+
+config ARCH_NPCM8XX
+     bool "Support Nuvoton NPCM8xx SoC"
+     select ARM64
+     help
+       General support for NPCM8xx BMC (Arbel).
+       Nuvoton NPCM8xx BMC is based on the Cortex A35.
+
+endchoice
+
+source "arch/arm/mach-nuvoton/npcm8xx/Kconfig"
+
+endif
arch/arm/mach-nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..e75689a1a0
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += npcm8xx/
arch/arm/mach-nuvoton/npcm8xx/Kconfig new file +18 -0
new file mode 100644
index 0000000000..478a046ad5
@@ -0,0 +1,18 @@
+if ARCH_NPCM8XX
+
+config SYS_CPU
+     default "armv8"
+
+config SYS_SOC
+     default "npcm8xx"
+
+config TARGET_ARBEL_EVB
+     bool "Arbel-EVB"
+     help
+       ARBEL_EVB is Nuvoton evaluation board for NPCM845 SoC,
+       supports general functions of Basebase Management Controller
+       (BMC).
+
+source "board/nuvoton/arbel/Kconfig"
+
+endif
arch/arm/mach-nuvoton/npcm8xx/Makefile new file +1 -0
new file mode 100644
index 0000000000..c62a4aa20a
@@ -0,0 +1 @@
+obj-y += reset.o cpu.o
arch/arm/mach-nuvoton/npcm8xx/cpu.c new file +170 -0
new file mode 100644
index 0000000000..8a7315d535
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <cpu_func.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/arch/espi.h>
+#include <asm/armv8/mmu.h>
+#include <asm/system.h>
+#include <asm/global_data.h>
+
+/* System Counter */
+struct sctr_regs {
+     u32 cntcr;
+     u32 cntsr;
+     u32 cntcv1;
+     u32 cntcv2;
+     u32 resv1[4];
+     u32 cntfid0;
+     u32 cntfid1;
+     u32 cntfid2;
+     u32 resv2[1001];
+     u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE              BIT(0)
+#define SC_CNTCR_HDBG                BIT(1)
+#define SC_CNTCR_FREQ0               BIT(8)
+#define SC_CNTCR_FREQ1               BIT(9)
+
+#define SYSCNT_CTRL_BASE_ADDR   0xF07FC000
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int print_cpuinfo(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     unsigned int id = 0;
+     unsigned long mpidr_val = 0;
+     unsigned int mdlr = 0;
+
+     asm volatile("mrs %0, mpidr_el1" : "=r" (mpidr_val));
+
+     mdlr = readl(&gcr->mdlr);
+
+     printf("CPU-%d: ", (unsigned int)(mpidr_val & 0x3));
+
+     switch (mdlr) {
+     case ARBEL_NPCM845:
+             printf("NPCM845 ");
+             break;
+     case ARBEL_NPCM830:
+             printf("NPCM830 ");
+             break;
+     case ARBEL_NPCM810:
+             printf("NPCM810 ");
+             break;
+     default:
+             printf("NPCM8XX ");
+             break;
+     }
+
+     id = readl(&gcr->pdid);
+     switch (id) {
+     case ARBEL_Z1:
+             printf("Z1 @ ");
+             break;
+     case ARBEL_A1:
+             printf("A1 @ ");
+             break;
+     default:
+             printf("Unknown\n");
+             break;
+     }
+
+     return 0;
+}
+
+static void npcm_sysintf_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     u32 espi_ch_supp, val;
+
+     espi_ch_supp = ofnode_conf_read_int("espi-channel-support", 0);
+
+     if (espi_ch_supp) {
+             /* Use eSPI function and initialize ESPICFG */
+             u32 hindp = 0x00011110 | espi_ch_supp;
+
+             writel((readl(&gcr->mfsel4) | (1 << MFSEL4_ESPISEL)), &gcr->mfsel4);
+             writel(hindp, NPCM_ESPI_BA + ESPIHINDP);
+             val = readl(NPCM_ESPI_BA + ESPICFG);
+             val |= ESPI_IO_MODE_SINGLE_DUAL_QUAD << ESPICFG_IOMODE_SHIFT;
+             val |= ESPI_MAX_33_MHZ << ESPICFG_MAXFREQ_SHIFT;
+             val |= ((espi_ch_supp & ESPICFG_CHNSUPP_MASK) << ESPICFG_CHNSUPP_SHFT);
+             writel(val, NPCM_ESPI_BA + ESPICFG);
+     } else {
+             /* Use LPC function */
+             writel((readl(&gcr->mfsel1) | (1 << MFSEL1_LPCSEL)), &gcr->mfsel1);
+     }
+}
+
+int arch_cpu_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     if (!IS_ENABLED(CONFIG_SYS_DCACHE_OFF)) {
+             /* enable cache to speed up system running */
+             if (get_sctlr() & CR_M)
+                     return 0;
+
+             icache_enable();
+             __asm_invalidate_dcache_all();
+             __asm_invalidate_tlb_all();
+             set_sctlr(get_sctlr() | CR_C);
+     }
+
+     /* Power voltage select setup */
+     setbits_le32(&gcr->vsrcr, BIT(30));
+
+     npcm_sysintf_init();
+
+     return 0;
+}
+
+static struct mm_region npcm_mem_map[1 + CONFIG_NR_DRAM_BANKS + 1] = {
+     {
+             /* DRAM */
+             .phys = 0x0UL,
+             .virt = 0x0UL,
+             .size = 0x80000000UL,
+             .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+                      PTE_BLOCK_INNER_SHARE
+     },
+     {
+             .phys = 0x80000000UL,
+             .virt = 0x80000000UL,
+             .size = 0x80000000UL,
+             .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                      PTE_BLOCK_NON_SHARE |
+                      PTE_BLOCK_PXN | PTE_BLOCK_UXN
+     },
+     {
+             /* List terminator */
+             0,
+     }
+};
+
+struct mm_region *mem_map = npcm_mem_map;
+
+int timer_init(void)
+{
+     struct sctr_regs *sctr = (struct sctr_regs *)SYSCNT_CTRL_BASE_ADDR;
+     unsigned int cntfrq_el0;
+
+     __asm__ __volatile__("mrs %0, CNTFRQ_EL0\n\t" : "=r" (cntfrq_el0) : : "memory");
+     writel(cntfrq_el0, &sctr->cntfid0);
+
+     clrsetbits_le32(&sctr->cntcr, SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1,
+                     SC_CNTCR_ENABLE | SC_CNTCR_HDBG);
+
+     gd->arch.tbl = 0;
+     gd->arch.tbu = 0;
+
+     return 0;
+}
arch/arm/mach-nuvoton/npcm8xx/reset.c new file +51 -0
new file mode 100644
index 0000000000..7fbed7ba76
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/rst.h>
+#include <asm/arch/gcr.h>
+
+void reset_cpu(void)
+{
+     /* Watcdog reset - WTCR register set  WTE-BIT7 WTRE-BIT1 WTR-BIT0 */
+     writel(0x83, 0xf000801c);
+
+     while (1)
+             ;
+}
+
+void reset_misc(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     /* clear WDC */
+     writel(readl(&gcr->intcr2) & ~(1 << INTCR2_WDC), &gcr->intcr2);
+}
+
+enum reset_type npcm8xx_reset_reason(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     enum reset_type type = UNKNOWN_TYPE;
+     u32 value = readl(&gcr->ressr);
+
+     if (value == 0)
+             value = ~readl(&gcr->intcr2);
+
+     value &= RESSR_MASK;
+
+     if (value & CORST)
+             type = CORST;
+     if (value & WD0RST)
+             type = WD0RST;
+     if (value & WD1RST)
+             type = WD1RST;
+     if (value & WD2RST)
+             type = WD2RST;
+     if (value & PORST)
+             type = PORST;
+
+     return type;
+}
board/nuvoton/arbel/Kconfig new file +18 -0
new file mode 100644
index 0000000000..4a03ea1abf
@@ -0,0 +1,18 @@
+if TARGET_ARBEL_EVB
+
+config SYS_BOARD
+     default "arbel"
+
+config SYS_VENDOR
+     default "nuvoton"
+
+config SYS_CONFIG_NAME
+     default "arbel"
+
+config SYS_MEM_TOP_HIDE
+     hex "Reserved TOP memory"
+     default 0xB000000
+     help
+       Reserve memory for ECC/GFX/VCD/ECE.
+
+endif
board/nuvoton/arbel/Makefile new file +1 -0
new file mode 100644
index 0000000000..f9ad1dea34
@@ -0,0 +1 @@
+obj-y        += arbel.o
board/nuvoton/arbel/arbel.c new file +33 -0
new file mode 100644
index 0000000000..86cef98c5f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/mach-types.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+     gd->bd->bi_arch_number = MACH_TYPE_NPCMX50;
+     gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100UL);
+
+     return 0;
+}
+
+int dram_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     /*
+      * get dram active size value from bootblock.
+      * Value sent using scrpad_02 register.
+      */
+     gd->ram_size = readl(&gcr->scrpad_b);
+
+     return 0;
+}
include/configs/arbel.h new file +54 -0
new file mode 100644
index 0000000000..2cb658c3e6
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef __CONFIG_ARBEL_H
+#define __CONFIG_ARBEL_H
+
+#define CONFIG_GICV2
+#define GICD_BASE                    (0xDFFF9000)
+#define GICC_BASE                    (0xDFFFA000)
+
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS   1
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG
+#define CONFIG_SYS_MAXARGS              32
+#define CONFIG_SYS_CBSIZE               256
+#define CONFIG_SYS_PBSIZE               (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_PROMPT_HUSH_PS2       "> "
+#define CONFIG_SYS_BOOTM_LEN            (20 << 20)
+#define CONFIG_SYS_BOOTMAPSZ            (20 << 20)
+#define CONFIG_SYS_SDRAM_BASE           0x0
+#define CONFIG_SYS_INIT_SP_ADDR         (0x00008000 - GENERATED_GBL_DATA_SIZE)
+#define CONFIG_SYS_MONITOR_LEN          (256 << 10)
+#define CONFIG_SYS_MONITOR_BASE              CONFIG_SYS_TEXT_BASE
+#define CONFIG_BAUDRATE                 115200
+#define CONFIG_SYS_HZ                   1000
+#define CONFIG_BITBANGMII_MULTI
+
+/* Default environemnt variables */
+#define CONFIG_BOOTCOMMAND "run common_bootargs; run romboot"
+#define CONFIG_EXTRA_ENV_SETTINGS   "uimage_flash_addr=80200000\0"   \
+             "stdin=serial\0"   \
+             "stdout=serial\0"   \
+             "stderr=serial\0"    \
+             "ethact=gmac1\0"   \
+             "autostart=no\0"   \
+             "ethaddr=00:00:F7:A0:00:FC\0"    \
+             "eth1addr=00:00:F7:A0:00:FD\0"   \
+             "eth2addr=00:00:F7:A0:00:FE\0"    \
+             "eth3addr=00:00:F7:A0:00:FF\0"    \
+             "gatewayip=192.168.0.17\0"    \
+             "serverip=192.168.0.17\0"    \
+             "ipaddr=192.168.0.15\0"    \
+             "romboot=echo Booting Kernel from flash at 0x${uimage_flash_addr}; " \
+             "echo Using bootargs: ${bootargs};bootm ${uimage_flash_addr}\0" \
+             "earlycon=uart8250,mmio32,0xf0000000\0" \
+             "console=ttyS0,115200n8\0" \
+             "common_bootargs=setenv bootargs earlycon=${earlycon} root=/dev/ram " \
+             "console=${console} ramdisk_size=48000\0" \
+             "\0"
+
+#endif
#4 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Hi Stanley,

Quoted 4 lines · Stanley Chu

Hi Giulio,

Thank you for your comment, I've submitted a clk driver patch to address this.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Good to see that!

But I think you should submit the entire patchset:
https://patchwork.ozlabs.org/project/uboot/list/?series=276836&state=%2A&archive=both

including this patch as V2. Otherwise it's difficult to test it.

As you see in Patchwork you have superseded and changes requested on other patches. So you should modify them accordingly and send V2 series. If other patches have been applied then send only the ones not applied.
But as I can see here they are still not applied.

Kind regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 1,116 lines

--
Stanley

Quoted 1,111 lines · Giulio Benetti

Hi Stanley,

Quoted 16 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

---
   arch/arm/Kconfig                          |   9 +
   arch/arm/Makefile                         |   1 +
   arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
   arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
   arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
   arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
   arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
   arch/arm/mach-nuvoton/Kconfig             |  24 ++
   arch/arm/mach-nuvoton/Makefile            |   1 +
   arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
   arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
   arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++

Here ^^^ you setup timer, but it should be a separate driver IMHO. At least this is what I've done for imxrt.
Same goes for clock, there is no clock driver and you setup spi clock directly inside the same file with npcm_sysintf_init() while that should be part of the clock driver.

Also all defines regarding to clocks and peripherals should go into their driver.

Quoted 1 line
   arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++

Here you've mixed up the architecture(above) and the board(below) in a single patch.

Quoted 4 lines
   board/nuvoton/arbel/Kconfig               |  18 ++
   board/nuvoton/arbel/Makefile              |   1 +
   board/nuvoton/arbel/arbel.c               |  33 +++
   include/configs/arbel.h                   |  54 ++++

arbel should be arbel-evk

I stop here, because there could be big changes if others agree.

Best regards
--
Giulio Benetti
Benetti Engineering sas

Quoted 1,061 lines
   17 files changed, 924 insertions(+)

create mode 100644 arch/arm/include/asm/arch-npcm8xx/clock.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/espi.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gcr.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gpio.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/rst.h create mode 100644 arch/arm/mach-nuvoton/Kconfig create mode 100644 arch/arm/mach-nuvoton/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Kconfig create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/cpu.c create mode 100644 arch/arm/mach-nuvoton/npcm8xx/reset.c create mode 100644 board/nuvoton/arbel/Kconfig create mode 100644 board/nuvoton/arbel/Makefile create mode 100644 board/nuvoton/arbel/arbel.c create mode 100644 include/configs/arbel.h

arch/arm/Kconfig +9 -0
index f7f03837fe..80ec42f6be 100644
@@ -1952,6 +1952,13 @@ config TARGET_XENGUEST_ARM64
       select LINUX_KERNEL_IMAGE_HEADER
       select XEN_SERIAL
       select SSCANF
+
+config ARCH_NPCM
+     bool "Support Nuvoton SoCs"
+     select DM
+     select OF_CONTROL
+     imply CMD_DM
+
   endchoice
 
   config SUPPORT_PASSING_ATAGS
@@ -2150,6 +2157,8 @@ source "arch/arm/mach-imx/Kconfig"
 
   source "arch/arm/mach-nexell/Kconfig"
 
+source "arch/arm/mach-nuvoton/Kconfig"
+
   source "board/armltd/total_compute/Kconfig"
 
   source "board/bosch/shc/Kconfig"
arch/arm/Makefile +1 -0
index ad757e982e..29a0250ab6 100644
@@ -92,6 +92,7 @@ machine-$(CONFIG_ARCH_VERSAL)               += versal
   machine-$(CONFIG_ARCH_ZYNQ)         += zynq
   machine-$(CONFIG_ARCH_ZYNQMP)               += zynqmp
   machine-$(CONFIG_ARCH_ZYNQMP_R5)    += zynqmp-r5
+machine-$(CONFIG_ARCH_NPCM)          += nuvoton
 
   machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
arch/arm/include/asm/arch-npcm8xx/clock.h new file +164 -0
new file mode 100644
index 0000000000..088b536b7b
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_CLOCK_H_
+#define _NPCM_CLOCK_H_
+
+#define NPCM_CLK_BA          0xF0801000
+enum {
+     APB1  = 1,
+     APB2  = 2,
+     APB3  = 3,
+     APB4  = 4,
+     APB5  = 5,
+     SPI0  = 10,
+     SPI1  = 11,
+     SPI3  = 13,
+     SPIX  = 14,
+};
+
+/* Clock Select Register (CLKSEL) */
+#define CLKSEL_RCPCKSEL             27
+#define CLKSEL_RGSEL                25
+#define CLKSEL_GFXMSEL              21
+#define CLKSEL_CLKOUTSEL            18
+#define CLKSEL_PCICKSEL             16
+#define CLKSEL_ADCCKSEL             14
+#define CLKSEL_MCCKSEL              12
+#define CLKSEL_SUCKSEL              10
+#define CLKSEL_UARTCKSEL            8
+#define CLKSEL_SDCKSEL              6
+#define CLKSEL_PIXCKSEL             4
+#define CLKSEL_CPUCKSEL             0
+
+/* Clock Divider Control Register 1 (CLKDIV1) */
+#define CLKDIV1_ADCCKDIV            28
+#define CLKDIV1_CLK4DIV             26
+#define CLKDIV1_PRE_ADCCKDIV        21
+#define CLKDIV1_UARTDIV             16
+#define CLKDIV1_MMCCKDIV            11
+#define CLKDIV1_SPI3CKDIV           6
+#define CLKDIV1_PCICKDIV            2
+
+/* Clock Divider Control Register 2 (CLKDIV2) */
+#define CLKDIV2_APB4CKDIV           30
+#define CLKDIV2_APB3CKDIV           28
+#define CLKDIV2_APB2CKDIV           26
+#define CLKDIV2_APB1CKDIV           24
+#define CLKDIV2_APB5CKDIV           22
+#define CLKDIV2_CLKOUTDIV           16
+#define CLKDIV2_GFXCKDIV            13
+#define CLKDIV2_SUCKDIV             8
+#define CLKDIV2_SU48CKDIV           4
+
+/* PLL Control Register 2 (PLLCON2) */
+#define PLLCON_LOKI                31
+#define PLLCON_LOKS                30
+#define PLLCON_FBDV                16
+#define PLLCON_OTDV2               13
+#define PLLCON_PWDEN               12
+#define PLLCON_OTDV1               8
+#define PLLCON_INDV                0
+
+/* CPUCKSEL (CPU/AMBA/MC Clock Source Select Bit) */
+#define CLKSEL_CPUCKSEL_PLL0        0x00   /* 0 0: PLL0 clock*/
+#define CLKSEL_CPUCKSEL_PLL1        0x01   /* 0 1: PLL1 clock */
+#define CLKSEL_CPUCKSEL_CLKREF      0x02   /* 1 0: CLKREF input (25 MHZ, default) */
+#define CLKSEL_CPUCKSEL_SYSBPCK     0x03   /* 1 1: Bypass clock from pin SYSBPCK */
+
+/* UARTCKSEL (Core and Host UART Clock Source Select Bit). */
+#define CLKSEL_UARTCKSEL_PLL0       0x00  /* 0 0: PLL0    clock. */
+#define CLKSEL_UARTCKSEL_PLL1       0x01  /* 0 1: PLL1    clock. */
+#define CLKSEL_UARTCKSEL_CLKREF     0x02  /* 1 0: CLKREF  clock (25 MHZ, default). */
+#define CLKSEL_UARTCKSEL_PLL2       0x03  /* 1 1: PLL2    clock divided by 2. */
+
+/* SDCKSEL (SDHC Clock Source Select Bit). */
+#define CLKSEL_SDCKSEL_PLL0         0x00   /* 0 0: PLL0    clock.  */
+#define CLKSEL_SDCKSEL_PLL1         0x01   /* 0 1: PLL1    clock.  */
+#define CLKSEL_SDCKSEL_CLKREF       0x02   /* 1 0: CLKREF clock (25 MHZ, default).  */
+#define CLKSEL_SDCKSEL_PLL2         0x03   /* 1 1: PLL2    clock divided by 2.  */
+
+/* IP Software Reset Register 1 (IPSRST1), offset 0x20 */
+#define IPSRST1_USBDEV1             5
+#define IPSRST1_USBDEV2             8
+#define IPSRST1_USBDEV3             25
+#define IPSRST1_USBDEV4             22
+#define IPSRST1_USBDEV5             23
+#define IPSRST1_USBDEV6             24
+#define IPSRST1_GMAC4               21
+#define IPSRST1_GMAC3               6
+
+/* IP Software Reset Register 2 (IPSRST2), offset 0x24 */
+#define IPSRST2_GMAC1               28
+#define IPSRST2_GMAC2               25
+#define IPSRST2_USBHOST1            26
+#define IPSRST2_SDHC                9
+#define IPSRST2_MMC                 8
+
+/* IP Software Reset Register 3 (IPSRST3), offset 0x34 */
+#define IPSRST3_USBPHY1             24
+#define IPSRST3_USBPHY2             25
+#define IPSRST3_USBHUB              8
+#define IPSRST3_USBDEV9             7
+#define IPSRST3_USBDEV8             6
+#define IPSRST3_USBDEV7             5
+#define IPSRST3_USBDEV0             4
+
+/* IP Software Reset Register 4 (IPSRST4), offset 0x74 */
+#define IPSRST4_USBHOST2            31
+#define IPSRST4_USBPHY3             25
+
+#define EXT_CLOCK_FREQUENCY_KHZ          25 * 1000 * 1UL
+#define EXT_CLOCK_FREQUENCY_MHZ          25
+
+struct clk_ctl {
+     unsigned int  clken1;
+     unsigned int  clksel;
+     unsigned int  clkdiv1;
+     unsigned int  pllcon0;
+     unsigned int  pllcon1;
+     unsigned int  swrstr;
+     unsigned char res1[0x8];
+     unsigned int  ipsrst1;
+     unsigned int  ipsrst2;
+     unsigned int  clken2;
+     unsigned int  clkdiv2;
+     unsigned int  clken3;
+     unsigned int  ipsrst3;
+     unsigned int  wd0rcr;
+     unsigned int  wd1rcr;
+     unsigned int  wd2rcr;
+     unsigned int  swrstc1;
+     unsigned int  swrstc2;
+     unsigned int  swrstc3;
+     unsigned int  tiprstc;
+     unsigned int  pllcon2;
+     unsigned int  clkdiv3;
+     unsigned int  corstc;
+     unsigned int  pllcong;
+     unsigned int  ahbckfi;
+     unsigned int  seccnt;
+     unsigned int  cntr25m;
+     unsigned int  clken4;
+     unsigned int  ipsrst4;
+     unsigned int  busto;
+     unsigned int  clkdiv4;
+     unsigned int  wd0rcrb;
+     unsigned int  wd1rcrb;
+     unsigned int  wd2rcrb;
+     unsigned int  swrstc1b;
+     unsigned int  swrstc2b;
+     unsigned int  swrstc3b;
+     unsigned int  tiprstcb;
+     unsigned int  corstcb;
+     unsigned int  ipsrstdis1;
+     unsigned int  ipsrstdis2;
+     unsigned int  ipsrstdis3;
+     unsigned int  ipsrstdis4;
+     unsigned char res2[0x10];
+     unsigned int  thrtl_cnt;
+};
+
+#endif
arch/arm/include/asm/arch-npcm8xx/espi.h new file +23 -0
new file mode 100644
index 0000000000..d4de012b02
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_ESPI_H_
+#define _NPCM_ESPI_H_
+
+#define NPCM_ESPI_BA         0xF009F000
+/* Register offsets */
+#define ESPICFG                      0x04
+#define ESPIHINDP            0x80
+
+/* Channel Supported */
+#define ESPICFG_CHNSUPP_MASK 0x0F
+#define ESPICFG_CHNSUPP_SHFT 24
+
+/* I/O Mode Supported */
+#define ESPICFG_IOMODE_SHIFT         8
+#define ESPI_IO_MODE_SINGLE_DUAL_QUAD        3
+
+/* Maximum Frequency Supported */
+#define ESPICFG_MAXFREQ_SHIFT                10
+#define ESPI_MAX_33_MHZ                      2
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gcr.h new file +313 -0
new file mode 100644
index 0000000000..14a4b2dbfb
@@ -0,0 +1,313 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GCR_H_
+#define _NPCM_GCR_H_
+
+#define NPCM_GCR_BA          0xF0800000
+/* On-Chip ARBEL NPCM8XX VERSIONS */
+
+#define ARBEL_Z1                     0x00A35850
+#define ARBEL_A1                     0x04a35850
+#define ARBEL_NPCM845                        0x00000000
+#define ARBEL_NPCM830                        0x00300395
+#define ARBEL_NPCM810                        0x00000220
+
+/* Function Lock Register 2 (FLOCKR2) */
+#define FLOCKR2_MMCRST               12
+#define FLOCKR2_MMCRSTLK             13
+#define FLOCKR2_G35DA2P              18
+
+/* Power-On Setting Register (PWRON) */
+#define PWRON_BSPA                   4         /* STRAP5 */
+#define PWRON_SECEN                  7         /* STRAP8 */
+
+/* Multiple Function Pin Select Register 1 (MFSEL1) */
+#define MFSEL1_SIRQSE               31
+#define MFSEL1_IOX1SEL              30
+#define MFSEL1_HSI2BSEL             29
+#define MFSEL1_HSI1BSEL             28
+#define MFSEL1_DVH1SEL              27
+#define MFSEL1_LPCSEL               26
+#define MFSEL1_PECIB                25
+#define MFSEL1_GSPISEL              24
+#define MFSEL1_SMISEL               22
+#define MFSEL1_CLKOSEL              21
+#define MFSEL1_DVOSEL               18
+#define MFSEL1_KBCICSEL             17
+#define MFSEL1_R2MDSEL              16
+#define MFSEL1_R2ERRSEL             15
+#define MFSEL1_RMII2SEL             14
+#define MFSEL1_R1MDSEL              13
+#define MFSEL1_R1ERRSEL             12
+#define MFSEL1_HSI2ASEL             11
+#define MFSEL1_HSI1ASEL             10
+#define MFSEL1_BSPSEL               9
+#define MFSEL1_SMB2SEL              8
+#define MFSEL1_SMB1SEL              7
+#define MFSEL1_SMB0SEL              6
+#define MFSEL1_HSI2CSEL             5
+#define MFSEL1_HSI1CSEL             4
+#define MFSEL1_S0CS1SEL             3
+#define MFSEL1_SMB5SEL              2
+#define MFSEL1_SMB4SEL              1
+#define MFSEL1_SMB3SEL              0
+
+/* Multiple Function Pin Select Register 3 (MFSEL3) */
+#define MFSEL3_DVODEDLY             27
+#define MFSEL3_DDRDVOSEL            26
+#define MFSEL3_MMCCDSEL             25
+#define MFSEL3_BU1SEL               24
+#define MFSEL3_I3C5SEL              22
+#define MFSEL3_WDO2SEL              20
+#define MFSEL3_WDO1SEL              19
+#define MFSEL3_IOXHSEL              18
+#define MFSEL3_PCIEPUSE             17
+#define MFSEL3_CLKRUNSEL            16
+#define MFSEL3_IOX2SEL              14
+#define MFSEL3_PSPISEL              13
+#define MFSEL3_MMC8SEL              11
+#define MFSEL3_MMCSEL               10
+#define MFSEL3_RMII1SEL             9
+#define MFSEL3_SMB15SEL             8
+#define MFSEL3_SMB14SEL             7
+#define MFSEL3_SMB13SEL             6
+#define MFSEL3_SMB12SEL             5
+#define MFSEL3_SPI1SEL              4
+#define MFSEL3_FIN1916SELB          3
+#define MFSEL3_SMB7SEL              2
+#define MFSEL3_SMB6SEL              1
+#define MFSEL3_SCISEL               0
+
+/* Multiple Function Pin Select Register 4 (MFSEL4) */
+#define MFSEL4_SMB11DDC             29
+#define MFSEL4_SXCS1SEL             28
+#define MFSEL4_SPXSEL               27
+#define MFSEL4_RG2SEL               24
+#define MFSEL4_RG2MSEL              23
+#define MFSEL4_BU2SELB              22
+#define MFSEL4_SG1MSEL              21
+#define MFSEL4_SP3QSEL              20
+#define MFSEL4_S3CS3SEL             19
+#define MFSEL4_S3CS2SEL             18
+#define MFSEL4_S3CS1SEL             17
+#define MFSEL4_SP3SEL               16
+#define MFSEL4_SP0QSEL              15
+#define MFSEL4_SMB11SEL             14
+#define MFSEL4_SMB10SEL             13
+#define MFSEL4_SMB9SEL              12
+#define MFSEL4_SMB8SEL              11
+#define MFSEL4_DBGTRSEL             10
+#define MFSEL4_CKRQSEL              9
+#define MFSEL4_ESPISEL              8
+#define MFSEL4_MMCRSEL              6
+#define MFSEL4_SD1PSEL              5
+#define MFSEL4_ROSEL                4
+#define MFSEL4_ESPIPMESEL           2
+#define MFSEL4_BSPASEL              1
+#define MFSEL4_JTAG2SEL             0
+
+/* Multiple Function Pin Select Register 5 (MFSEL5) */
+#define MFSEL5_R3OENSEL             14
+#define MFSEL5_RMII3SEL             11
+#define MFSEL5_R2OENSEL             10
+#define MFSEL5_R1OENSEL             9
+#define MFSEL5_NSPI1CS3SEL          5
+#define MFSEL5_NSPI1CS2SEL          4
+#define MFSEL5_SPI1D23SEL           3
+#define MFSEL5_NSPI1CS1SEL          0
+
+/* Multiple Function Pin Select Register 6 (MFSEL6) */
+#define MFSEL6_GPIO1836SEL          19
+#define MFSEL6_FM1SEL               17
+
+/* Multiple Function Pin Select Register 7 (MFSEL7) */
+#define MFSEL7_SMB15SELB            27
+#define MFSEL7_GPIO1889SEL          25
+
+/* USB PHY1 Control Register (USB1PHYCTL) */
+#define USB1PHYCTL_RS                                28
+/* USB PHY2 Control Register (USB2PHYCTL) */
+#define USB2PHYCTL_RS                                28
+/* USB PHY2 Control Register (USB3PHYCTL) */
+#define USB3PHYCTL_RS                                28
+
+/* Integration Control Register (INTCR) */
+#define  INTCR_DUDKSMOD             30
+#define  INTCR_DDC3I                29
+#define  INTCR_KVMSI                28
+#define  INTCR_DEHS                 27
+#define  INTCR_GGPCT2_0             24
+#define  INTCR_SGC2                 23
+#define  INTCR_DSNS_TRIG            21
+#define  INTCR_DAC_SNS              20
+#define  INTCR_SGC1                 19
+#define  INTCR_LDDRB                18
+#define  INTCR_GIRST                17
+#define  INTCR_DUDKSEN              16
+#define  INTCR_DACOFF               15
+#define  INTCR_DACSEL               14
+#define  INTCR_GFXINT               12
+#define  INTCR_DACOSOVR             10
+#define  INTCR_GFXIFDIS             8
+#define  INTCR_H2RQDIS              9
+#define  INTCR_H2DISPOFF            8
+#define  INTCR_GFXINT2              7
+#define  INTCR_VGAIOEN              6
+#define  INTCR_PSPIFEN              4
+#define  INTCR_HIFEN                3
+#define  INTCR_SMBFEN               2
+#define  INTCR_MFTFEN               1
+#define  INTCR_KCSRST_MODE          0
+
+/* Integration Control Register (INTCR2) */
+#define  INTCR2_WDC                   21
+
+/* Integration Control Register (INTCR3) */
+#define  INTCR3_USBLPBK2              31          /* USB loop-backed HOST 1/2 */
+#define  INTCR3_USBLPBK               24          /* USB loop-backed mode on/off */
+#define  INTCR3_USBPHY3SW             14          /* 2 bits */
+#define  INTCR3_USBPHY2SW             12          /* 2 bits */
+#define  INTCR3_USBPPS                6
+#define  INTCR3_UHUB_RWUD             5
+
+/* Integration Control Register (INTCR4) */
+#define  INTCR4_GMMAP1                24
+#define  INTCR4_GMMAP0                16
+#define  INTCR4_R3EN                  14
+#define  INTCR4_R2EN                  13
+#define  INTCR4_R1EN                  12
+#define  INTCR4_RGMIIREF              6
+
+/* I2C Segment Pin Select Register (I2CSEGSEL) */
+#define I2CSEGSEL_S0DECFG                    3
+#define I2CSEGSEL_S4DECFG                    17
+
+/* I2C Segment Control Register (I2CSEGCTL) */
+#define I2CSEGCTL_S0DEN                              20
+#define I2CSEGCTL_S0DWE                              21
+#define I2CSEGCTL_S4DEN                              24
+#define I2CSEGCTL_S4DWE                              25
+#define I2CSEGCTL_INIT_VAL           0x9333F000
+
+struct npcm_gcr {
+     unsigned int  pdid;
+     unsigned int  pwron;
+     unsigned int  swstrps;
+     unsigned int  rsvd1[2];
+     unsigned int  miscpe;
+     unsigned int  spldcnt;
+     unsigned int  rsvd2[1];
+     unsigned int  flockr2;
+     unsigned int  flockr3;
+     unsigned int  rsvd3[3];
+     unsigned int  a35_mode;
+     unsigned int  spswc;
+     unsigned int  intcr;
+     unsigned int  intsr;
+     unsigned int  obscr1;
+     unsigned int  obsdr1;
+     unsigned int  rsvd4[1];
+     unsigned int  hifcr;
+     unsigned int  rsvd5[3];
+     unsigned int  intcr2;
+     unsigned int  rsvd6[1];
+     unsigned int  srcnt;
+     unsigned int  ressr;
+     unsigned int  rlockr1;
+     unsigned int  flockr1;
+     unsigned int  dscnt;
+     unsigned int  mdlr;
+     unsigned int  scrpad_c;
+     /* scrpad_b: holds the active dram size (value set by bootblock) */
+     unsigned int  scrpad_b;
+     unsigned int  rsvd7[4];
+     unsigned int  daclvlr;
+     unsigned int  intcr3;
+     unsigned int  pcirctl;
+     unsigned int  rsvd8[2];
+     unsigned int  vsintr;
+     unsigned int  rsvd9[1];
+     unsigned int  sd2sur1;
+     unsigned int  sd2sur2;
+     unsigned int  sd2irv3;
+     unsigned int  intcr4;
+     unsigned int  obscr2;
+     unsigned int  obsdr2;
+     unsigned int  rsvd10[5];
+     unsigned int  i2csegsel;
+     unsigned int  i2csegctl;
+     unsigned int  vsrcr;
+     unsigned int  mlockr;
+     unsigned int  rsvd11[8];
+     unsigned int  etsr;
+     unsigned int  dft1r;
+     unsigned int  dft2r;
+     unsigned int  dft3r;
+     unsigned int  edffsr;
+     unsigned int  rsvd12[1];
+     unsigned int  intcrpce3;
+     unsigned int  intcrpce2;
+     unsigned int  intcrpce0;
+     unsigned int  intcrpce1;
+     unsigned int  dactest;
+     unsigned int  scrpad;
+     unsigned int  usb1phyctl;
+     unsigned int  usb2phyctl;
+     unsigned int  usb3phyctl;
+     unsigned int  intsr2;
+     unsigned int  intcrpce2b;
+     unsigned int  intcrpce0b;
+     unsigned int  intcrpce1b;
+     unsigned int  intcrpce3b;
+     unsigned int  rsvd13[4];
+     unsigned int  intcrpce2c;
+     unsigned int  intcrpce0c;
+     unsigned int  intcrpce1c;
+     unsigned int  intcrpce3c;
+     unsigned int  rsvd14[40];
+     unsigned int  sd2irv4;
+     unsigned int  sd2irv5;
+     unsigned int  sd2irv6;
+     unsigned int  sd2irv7;
+     unsigned int  sd2irv8;
+     unsigned int  sd2irv9;
+     unsigned int  sd2irv10;
+     unsigned int  sd2irv11;
+     unsigned int  rsvd15[8];
+     unsigned int  mfsel1;
+     unsigned int  mfsel2;
+     unsigned int  mfsel3;
+     unsigned int  mfsel4;
+     unsigned int  mfsel5;
+     unsigned int  mfsel6;
+     unsigned int  mfsel7;
+     unsigned int  rsvd16[1];
+     unsigned int  mfsel_lk1;
+     unsigned int  mfsel_lk2;
+     unsigned int  mfsel_lk3;
+     unsigned int  mfsel_lk4;
+     unsigned int  mfsel_lk5;
+     unsigned int  mfsel_lk6;
+     unsigned int  mfsel_lk7;
+     unsigned int  rsvd17[1];
+     unsigned int  mfsel_set1;
+     unsigned int  mfsel_set2;
+     unsigned int  mfsel_set3;
+     unsigned int  mfsel_set4;
+     unsigned int  mfsel_set5;
+     unsigned int  mfsel_set6;
+     unsigned int  mfsel_set7;
+     unsigned int  rsvd18[1];
+     unsigned int  mfsel_clr1;
+     unsigned int  mfsel_clr2;
+     unsigned int  mfsel_clr3;
+     unsigned int  mfsel_clr4;
+     unsigned int  mfsel_clr5;
+     unsigned int  mfsel_clr6;
+     unsigned int  mfsel_clr7;
+     };
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gpio.h new file +11 -0
new file mode 100644
index 0000000000..234a1d3de9
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GPIO_H_
+#define _NPCM_GPIO_H_
+
+#define NPCM_GPIO_BA         0xF0010000
+
+#endif
arch/arm/include/asm/arch-npcm8xx/rst.h new file +32 -0
new file mode 100644
index 0000000000..ffaff50fe2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_RST_H_
+#define _NPCM_RST_H_
+
+enum reset_type {
+     PORST_TYPE    = 0x01,
+     CORST_TYPE    = 0x02,
+     WD0RST_TYPE   = 0x03,
+     SWR1ST_TYPE   = 0x04,
+     SWR2ST_TYPE   = 0x05,
+     SWR3ST_TYPE   = 0x06,
+     SWR4ST_TYPE   = 0x07,
+     WD1RST_TYPE   = 0x08,
+     WD2RST_TYPE   = 0x09,
+     UNKNOWN_TYPE  = 0x10,
+};
+
+#define PORST 0x80000000
+#define CORST 0x40000000
+#define WD0RST 0x20000000
+#define SWR1ST 0x10000000
+#define SWR2ST 0x08000000
+#define SWR3ST 0x04000000
+#define SWR4ST 0x02000000
+#define WD1RST 0x01000000
+#define WD2RST 0x00800000
+#define RESSR_MASK 0xff800000
+
+enum reset_type npcm8xx_reset_reason(void);
+
+#endif
arch/arm/mach-nuvoton/Kconfig new file +24 -0
new file mode 100644
index 0000000000..e014dd4b79
@@ -0,0 +1,24 @@
+if ARCH_NPCM
+
+config SYS_ARCH
+     default "arm"
+
+config SYS_TEXT_BASE
+     default 0x8000
+
+choice
+     prompt "Nuvoton SoC select"
+     default ARCH_NPCM8XX
+
+config ARCH_NPCM8XX
+     bool "Support Nuvoton NPCM8xx SoC"
+     select ARM64
+     help
+       General support for NPCM8xx BMC (Arbel).
+       Nuvoton NPCM8xx BMC is based on the Cortex A35.
+
+endchoice
+
+source "arch/arm/mach-nuvoton/npcm8xx/Kconfig"
+
+endif
arch/arm/mach-nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..e75689a1a0
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += npcm8xx/
arch/arm/mach-nuvoton/npcm8xx/Kconfig new file +18 -0
new file mode 100644
index 0000000000..478a046ad5
@@ -0,0 +1,18 @@
+if ARCH_NPCM8XX
+
+config SYS_CPU
+     default "armv8"
+
+config SYS_SOC
+     default "npcm8xx"
+
+config TARGET_ARBEL_EVB
+     bool "Arbel-EVB"
+     help
+       ARBEL_EVB is Nuvoton evaluation board for NPCM845 SoC,
+       supports general functions of Basebase Management Controller
+       (BMC).
+
+source "board/nuvoton/arbel/Kconfig"
+
+endif
arch/arm/mach-nuvoton/npcm8xx/Makefile new file +1 -0
new file mode 100644
index 0000000000..c62a4aa20a
@@ -0,0 +1 @@
+obj-y += reset.o cpu.o
arch/arm/mach-nuvoton/npcm8xx/cpu.c new file +170 -0
new file mode 100644
index 0000000000..8a7315d535
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <cpu_func.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/arch/espi.h>
+#include <asm/armv8/mmu.h>
+#include <asm/system.h>
+#include <asm/global_data.h>
+
+/* System Counter */
+struct sctr_regs {
+     u32 cntcr;
+     u32 cntsr;
+     u32 cntcv1;
+     u32 cntcv2;
+     u32 resv1[4];
+     u32 cntfid0;
+     u32 cntfid1;
+     u32 cntfid2;
+     u32 resv2[1001];
+     u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE              BIT(0)
+#define SC_CNTCR_HDBG                BIT(1)
+#define SC_CNTCR_FREQ0               BIT(8)
+#define SC_CNTCR_FREQ1               BIT(9)
+
+#define SYSCNT_CTRL_BASE_ADDR   0xF07FC000
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int print_cpuinfo(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     unsigned int id = 0;
+     unsigned long mpidr_val = 0;
+     unsigned int mdlr = 0;
+
+     asm volatile("mrs %0, mpidr_el1" : "=r" (mpidr_val));
+
+     mdlr = readl(&gcr->mdlr);
+
+     printf("CPU-%d: ", (unsigned int)(mpidr_val & 0x3));
+
+     switch (mdlr) {
+     case ARBEL_NPCM845:
+             printf("NPCM845 ");
+             break;
+     case ARBEL_NPCM830:
+             printf("NPCM830 ");
+             break;
+     case ARBEL_NPCM810:
+             printf("NPCM810 ");
+             break;
+     default:
+             printf("NPCM8XX ");
+             break;
+     }
+
+     id = readl(&gcr->pdid);
+     switch (id) {
+     case ARBEL_Z1:
+             printf("Z1 @ ");
+             break;
+     case ARBEL_A1:
+             printf("A1 @ ");
+             break;
+     default:
+             printf("Unknown\n");
+             break;
+     }
+
+     return 0;
+}
+
+static void npcm_sysintf_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     u32 espi_ch_supp, val;
+
+     espi_ch_supp = ofnode_conf_read_int("espi-channel-support", 0);
+
+     if (espi_ch_supp) {
+             /* Use eSPI function and initialize ESPICFG */
+             u32 hindp = 0x00011110 | espi_ch_supp;
+
+             writel((readl(&gcr->mfsel4) | (1 << MFSEL4_ESPISEL)), &gcr->mfsel4);
+             writel(hindp, NPCM_ESPI_BA + ESPIHINDP);
+             val = readl(NPCM_ESPI_BA + ESPICFG);
+             val |= ESPI_IO_MODE_SINGLE_DUAL_QUAD << ESPICFG_IOMODE_SHIFT;
+             val |= ESPI_MAX_33_MHZ << ESPICFG_MAXFREQ_SHIFT;
+             val |= ((espi_ch_supp & ESPICFG_CHNSUPP_MASK) << ESPICFG_CHNSUPP_SHFT);
+             writel(val, NPCM_ESPI_BA + ESPICFG);
+     } else {
+             /* Use LPC function */
+             writel((readl(&gcr->mfsel1) | (1 << MFSEL1_LPCSEL)), &gcr->mfsel1);
+     }
+}
+
+int arch_cpu_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     if (!IS_ENABLED(CONFIG_SYS_DCACHE_OFF)) {
+             /* enable cache to speed up system running */
+             if (get_sctlr() & CR_M)
+                     return 0;
+
+             icache_enable();
+             __asm_invalidate_dcache_all();
+             __asm_invalidate_tlb_all();
+             set_sctlr(get_sctlr() | CR_C);
+     }
+
+     /* Power voltage select setup */
+     setbits_le32(&gcr->vsrcr, BIT(30));
+
+     npcm_sysintf_init();
+
+     return 0;
+}
+
+static struct mm_region npcm_mem_map[1 + CONFIG_NR_DRAM_BANKS + 1] = {
+     {
+             /* DRAM */
+             .phys = 0x0UL,
+             .virt = 0x0UL,
+             .size = 0x80000000UL,
+             .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+                      PTE_BLOCK_INNER_SHARE
+     },
+     {
+             .phys = 0x80000000UL,
+             .virt = 0x80000000UL,
+             .size = 0x80000000UL,
+             .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                      PTE_BLOCK_NON_SHARE |
+                      PTE_BLOCK_PXN | PTE_BLOCK_UXN
+     },
+     {
+             /* List terminator */
+             0,
+     }
+};
+
+struct mm_region *mem_map = npcm_mem_map;
+
+int timer_init(void)
+{
+     struct sctr_regs *sctr = (struct sctr_regs *)SYSCNT_CTRL_BASE_ADDR;
+     unsigned int cntfrq_el0;
+
+     __asm__ __volatile__("mrs %0, CNTFRQ_EL0\n\t" : "=r" (cntfrq_el0) : : "memory");
+     writel(cntfrq_el0, &sctr->cntfid0);
+
+     clrsetbits_le32(&sctr->cntcr, SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1,
+                     SC_CNTCR_ENABLE | SC_CNTCR_HDBG);
+
+     gd->arch.tbl = 0;
+     gd->arch.tbu = 0;
+
+     return 0;
+}
arch/arm/mach-nuvoton/npcm8xx/reset.c new file +51 -0
new file mode 100644
index 0000000000..7fbed7ba76
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/rst.h>
+#include <asm/arch/gcr.h>
+
+void reset_cpu(void)
+{
+     /* Watcdog reset - WTCR register set  WTE-BIT7 WTRE-BIT1 WTR-BIT0 */
+     writel(0x83, 0xf000801c);
+
+     while (1)
+             ;
+}
+
+void reset_misc(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     /* clear WDC */
+     writel(readl(&gcr->intcr2) & ~(1 << INTCR2_WDC), &gcr->intcr2);
+}
+
+enum reset_type npcm8xx_reset_reason(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     enum reset_type type = UNKNOWN_TYPE;
+     u32 value = readl(&gcr->ressr);
+
+     if (value == 0)
+             value = ~readl(&gcr->intcr2);
+
+     value &= RESSR_MASK;
+
+     if (value & CORST)
+             type = CORST;
+     if (value & WD0RST)
+             type = WD0RST;
+     if (value & WD1RST)
+             type = WD1RST;
+     if (value & WD2RST)
+             type = WD2RST;
+     if (value & PORST)
+             type = PORST;
+
+     return type;
+}
board/nuvoton/arbel/Kconfig new file +18 -0
new file mode 100644
index 0000000000..4a03ea1abf
@@ -0,0 +1,18 @@
+if TARGET_ARBEL_EVB
+
+config SYS_BOARD
+     default "arbel"
+
+config SYS_VENDOR
+     default "nuvoton"
+
+config SYS_CONFIG_NAME
+     default "arbel"
+
+config SYS_MEM_TOP_HIDE
+     hex "Reserved TOP memory"
+     default 0xB000000
+     help
+       Reserve memory for ECC/GFX/VCD/ECE.
+
+endif
board/nuvoton/arbel/Makefile new file +1 -0
new file mode 100644
index 0000000000..f9ad1dea34
@@ -0,0 +1 @@
+obj-y        += arbel.o
board/nuvoton/arbel/arbel.c new file +33 -0
new file mode 100644
index 0000000000..86cef98c5f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/mach-types.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+     gd->bd->bi_arch_number = MACH_TYPE_NPCMX50;
+     gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100UL);
+
+     return 0;
+}
+
+int dram_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     /*
+      * get dram active size value from bootblock.
+      * Value sent using scrpad_02 register.
+      */
+     gd->ram_size = readl(&gcr->scrpad_b);
+
+     return 0;
+}
include/configs/arbel.h new file +54 -0
new file mode 100644
index 0000000000..2cb658c3e6
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef __CONFIG_ARBEL_H
+#define __CONFIG_ARBEL_H
+
+#define CONFIG_GICV2
+#define GICD_BASE                    (0xDFFF9000)
+#define GICC_BASE                    (0xDFFFA000)
+
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS   1
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG
+#define CONFIG_SYS_MAXARGS              32
+#define CONFIG_SYS_CBSIZE               256
+#define CONFIG_SYS_PBSIZE               (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_PROMPT_HUSH_PS2       "> "
+#define CONFIG_SYS_BOOTM_LEN            (20 << 20)
+#define CONFIG_SYS_BOOTMAPSZ            (20 << 20)
+#define CONFIG_SYS_SDRAM_BASE           0x0
+#define CONFIG_SYS_INIT_SP_ADDR         (0x00008000 - GENERATED_GBL_DATA_SIZE)
+#define CONFIG_SYS_MONITOR_LEN          (256 << 10)
+#define CONFIG_SYS_MONITOR_BASE              CONFIG_SYS_TEXT_BASE
+#define CONFIG_BAUDRATE                 115200
+#define CONFIG_SYS_HZ                   1000
+#define CONFIG_BITBANGMII_MULTI
+
+/* Default environemnt variables */
+#define CONFIG_BOOTCOMMAND "run common_bootargs; run romboot"
+#define CONFIG_EXTRA_ENV_SETTINGS   "uimage_flash_addr=80200000\0"   \
+             "stdin=serial\0"   \
+             "stdout=serial\0"   \
+             "stderr=serial\0"    \
+             "ethact=gmac1\0"   \
+             "autostart=no\0"   \
+             "ethaddr=00:00:F7:A0:00:FC\0"    \
+             "eth1addr=00:00:F7:A0:00:FD\0"   \
+             "eth2addr=00:00:F7:A0:00:FE\0"    \
+             "eth3addr=00:00:F7:A0:00:FF\0"    \
+             "gatewayip=192.168.0.17\0"    \
+             "serverip=192.168.0.17\0"    \
+             "ipaddr=192.168.0.15\0"    \
+             "romboot=echo Booting Kernel from flash at 0x${uimage_flash_addr}; " \
+             "echo Using bootargs: ${bootargs};bootm ${uimage_flash_addr}\0" \
+             "earlycon=uart8250,mmio32,0xf0000000\0" \
+             "console=ttyS0,115200n8\0" \
+             "common_bootargs=setenv bootargs earlycon=${earlycon} root=/dev/ram " \
+             "console=${console} ramdisk_size=48000\0" \
+             "\0"
+
+#endif
#5 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Quoted 13 lines · Giulio Benetti

Hi Stanley,

Quoted 4 lines · Stanley Chu

Hi Giulio,

Thank you for your comment, I've submitted a clk driver patch to address this.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Good to see that!

But I think you should submit the entire patchset:
https://patchwork.ozlabs.org/project/uboot/list/?series=276836&state=%2A&archive=both

Quoted 6 lines

including this patch as V2. Otherwise it's difficult to test it.

As you see in Patchwork you have superseded and changes requested on other patches. So you should modify them accordingly and send V2 series. If other patches have been applied then send only the ones not applied. But as I can see here they are still not applied.

Ah, forgotten to mention, please add me and other people involved in reviewing in Cc for V2.

Thank you!

Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
#6 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

In reply to Stanley Chu

arch/arm/include/asm/arch-npcm8xx/clock.h

Quoted 82 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

---
  arch/arm/Kconfig                          |   9 +
  arch/arm/Makefile                         |   1 +
  arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
  arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
  arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
  arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
  arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
  arch/arm/mach-nuvoton/Kconfig             |  24 ++
  arch/arm/mach-nuvoton/Makefile            |   1 +
  arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
  arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
  arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++
  arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++
  board/nuvoton/arbel/Kconfig               |  18 ++
  board/nuvoton/arbel/Makefile              |   1 +
  board/nuvoton/arbel/arbel.c               |  33 +++
  include/configs/arbel.h                   |  54 ++++
  17 files changed, 924 insertions(+)

create mode 100644 arch/arm/include/asm/arch-npcm8xx/clock.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/espi.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gcr.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gpio.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/rst.h create mode 100644 arch/arm/mach-nuvoton/Kconfig create mode 100644 arch/arm/mach-nuvoton/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Kconfig create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/cpu.c create mode 100644 arch/arm/mach-nuvoton/npcm8xx/reset.c create mode 100644 board/nuvoton/arbel/Kconfig create mode 100644 board/nuvoton/arbel/Makefile create mode 100644 board/nuvoton/arbel/arbel.c create mode 100644 include/configs/arbel.h

arch/arm/Kconfig +9 -0
index f7f03837fe..80ec42f6be 100644
@@ -1952,6 +1952,13 @@ config TARGET_XENGUEST_ARM64
  	select LINUX_KERNEL_IMAGE_HEADER
  	select XEN_SERIAL
  	select SSCANF
+
+config ARCH_NPCM
+	bool "Support Nuvoton SoCs"
+	select DM
+	select OF_CONTROL
+	imply CMD_DM
+
  endchoice
 
  config SUPPORT_PASSING_ATAGS
@@ -2150,6 +2157,8 @@ source "arch/arm/mach-imx/Kconfig"
 
  source "arch/arm/mach-nexell/Kconfig"
 
+source "arch/arm/mach-nuvoton/Kconfig"
+
  source "board/armltd/total_compute/Kconfig"
 
  source "board/bosch/shc/Kconfig"
arch/arm/Makefile +1 -0
index ad757e982e..29a0250ab6 100644
@@ -92,6 +92,7 @@ machine-$(CONFIG_ARCH_VERSAL)		+= versal
  machine-$(CONFIG_ARCH_ZYNQ)		+= zynq
  machine-$(CONFIG_ARCH_ZYNQMP)		+= zynqmp
  machine-$(CONFIG_ARCH_ZYNQMP_R5)	+= zynqmp-r5
+machine-$(CONFIG_ARCH_NPCM)		+= nuvoton
 
  machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
arch/arm/include/asm/arch-npcm8xx/clock.h new file +0 -0
new file mode 100644
index 0000000000..088b536b7b

Please add this (and all the other includes) in the patches adding the drivers which use them. This makes it much easier to review.

Additionally, if these defines are not used elsewhere, they can be included at the beginning of the clock driver itself.

arch/arm/include/asm/arch-npcm8xx/clock.h line 10

Quoted 11 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_CLOCK_H_
+#define _NPCM_CLOCK_H_
+
+#define NPCM_CLK_BA		0xF0801000
+enum {

Don't redefine these. Just use include/dt-bindings/clock/npcm845-clock.h

Quoted 14 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +14 -0
+	APB1  = 1,
+	APB2  = 2,
+	APB3  = 3,
+	APB4  = 4,
+	APB5  = 5,
+	SPI0  = 10,
+	SPI1  = 11,
+	SPI3  = 13,
+	SPIX  = 14,
+};
+
+/* Clock Select Register (CLKSEL) */
+#define CLKSEL_RCPCKSEL             27
+#define CLKSEL_RGSEL                25

arch/arm/include/asm/arch-npcm8xx/clock.h line 34

Quoted 10 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
+#define CLKSEL_GFXMSEL              21
+#define CLKSEL_CLKOUTSEL            18
+#define CLKSEL_PCICKSEL             16
+#define CLKSEL_ADCCKSEL             14
+#define CLKSEL_MCCKSEL              12
+#define CLKSEL_SUCKSEL              10
+#define CLKSEL_UARTCKSEL            8
+#define CLKSEL_SDCKSEL              6
+#define CLKSEL_PIXCKSEL             4
+#define CLKSEL_CPUCKSEL             0

Please use GENMASK for this. For example,

	#define CLKSEL_CPUCKSEL GENMASK(1, 0)

This allows you to do things like

u32 clksel = readl(&regs->clksel);

	switch (FIELD_GET(CLKSEL_CPUCKSEL, clksel)) {

	}

later on, instead of having magic masks everywhere.

Quoted 39 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +39 -0
+
+/* Clock Divider Control Register 1 (CLKDIV1) */
+#define CLKDIV1_ADCCKDIV            28
+#define CLKDIV1_CLK4DIV             26
+#define CLKDIV1_PRE_ADCCKDIV        21
+#define CLKDIV1_UARTDIV             16
+#define CLKDIV1_MMCCKDIV            11
+#define CLKDIV1_SPI3CKDIV           6
+#define CLKDIV1_PCICKDIV            2
+
+/* Clock Divider Control Register 2 (CLKDIV2) */
+#define CLKDIV2_APB4CKDIV           30
+#define CLKDIV2_APB3CKDIV           28
+#define CLKDIV2_APB2CKDIV           26
+#define CLKDIV2_APB1CKDIV           24
+#define CLKDIV2_APB5CKDIV           22
+#define CLKDIV2_CLKOUTDIV           16
+#define CLKDIV2_GFXCKDIV            13
+#define CLKDIV2_SUCKDIV             8
+#define CLKDIV2_SU48CKDIV           4
+
+/* PLL Control Register 2 (PLLCON2) */
+#define PLLCON_LOKI                31
+#define PLLCON_LOKS                30
+#define PLLCON_FBDV                16
+#define PLLCON_OTDV2               13
+#define PLLCON_PWDEN               12
+#define PLLCON_OTDV1               8
+#define PLLCON_INDV                0
+
+/* CPUCKSEL (CPU/AMBA/MC Clock Source Select Bit) */
+#define CLKSEL_CPUCKSEL_PLL0        0x00   /* 0 0: PLL0 clock*/
+#define CLKSEL_CPUCKSEL_PLL1        0x01   /* 0 1: PLL1 clock */
+#define CLKSEL_CPUCKSEL_CLKREF      0x02   /* 1 0: CLKREF input (25 MHZ, default) */
+#define CLKSEL_CPUCKSEL_SYSBPCK     0x03   /* 1 1: Bypass clock from pin SYSBPCK */
+
+/* UARTCKSEL (Core and Host UART Clock Source Select Bit). */
+#define CLKSEL_UARTCKSEL_PLL0       0x00  /* 0 0: PLL0    clock. */
+#define CLKSEL_UARTCKSEL_PLL1       0x01  /* 0 1: PLL1    clock. */

arch/arm/include/asm/arch-npcm8xx/clock.h line 83

Quoted 10 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
+#define CLKSEL_UARTCKSEL_CLKREF     0x02  /* 1 0: CLKREF  clock (25 MHZ, default). */
+#define CLKSEL_UARTCKSEL_PLL2       0x03  /* 1 1: PLL2    clock divided by 2. */
+
+/* SDCKSEL (SDHC Clock Source Select Bit). */
+#define CLKSEL_SDCKSEL_PLL0         0x00   /* 0 0: PLL0    clock.  */
+#define CLKSEL_SDCKSEL_PLL1         0x01   /* 0 1: PLL1    clock.  */
+#define CLKSEL_SDCKSEL_CLKREF       0x02   /* 1 0: CLKREF clock (25 MHZ, default).  */
+#define CLKSEL_SDCKSEL_PLL2         0x03   /* 1 1: PLL2    clock divided by 2.  */
+
+/* IP Software Reset Register 1 (IPSRST1), offset 0x20 */

If you have multiple logical devices in one group of registers, you should look into organizing your bindings like

	syscon@0xf0801000 {
		compatible = "simple-mfd";
		reg = <0x0 0xf0801000 0x0 0x70>;

		clks: clock-controller {
			compatible = "nuvoton,npcm845-clock";
			#clock-cells = <1>;
			clocks = <&some_oscillator>;
			clock-names = "extclk";
			u-boot,dm-pre-reloc;
		};

		rsts: reset-controller {
			compatible = "nuvoton,npcm845-reset";
			#reset-cells = <1>;
		}
	}
Quoted 21 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +21 -0
+#define IPSRST1_USBDEV1             5
+#define IPSRST1_USBDEV2             8
+#define IPSRST1_USBDEV3             25
+#define IPSRST1_USBDEV4             22
+#define IPSRST1_USBDEV5             23
+#define IPSRST1_USBDEV6             24
+#define IPSRST1_GMAC4               21
+#define IPSRST1_GMAC3               6
+
+/* IP Software Reset Register 2 (IPSRST2), offset 0x24 */
+#define IPSRST2_GMAC1               28
+#define IPSRST2_GMAC2               25
+#define IPSRST2_USBHOST1            26
+#define IPSRST2_SDHC                9
+#define IPSRST2_MMC                 8
+
+/* IP Software Reset Register 3 (IPSRST3), offset 0x34 */
+#define IPSRST3_USBPHY1             24
+#define IPSRST3_USBPHY2             25
+#define IPSRST3_USBHUB              8
+#define IPSRST3_USBDEV9             7

arch/arm/include/asm/arch-npcm8xx/clock.h line 114

Quoted 10 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
+#define IPSRST3_USBDEV8             6
+#define IPSRST3_USBDEV7             5
+#define IPSRST3_USBDEV0             4
+
+/* IP Software Reset Register 4 (IPSRST4), offset 0x74 */
+#define IPSRST4_USBHOST2            31
+#define IPSRST4_USBPHY3             25
+
+#define EXT_CLOCK_FREQUENCY_KHZ	    25 * 1000 * 1UL
+#define EXT_CLOCK_FREQUENCY_MHZ	    25

Just define it in HZ and divide it as needed. The compiler will optimize it. But see also my comments on your other patch.

arch/arm/include/asm/arch-npcm8xx/clock.h line 116

Quoted 2 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +2 -0
+
+struct clk_ctl {

Please name this npcm_clk_ctl or similar.

arch/arm/include/asm/arch-npcm8xx/clock.h line 117

Quoted 1 line
arch/arm/include/asm/arch-npcm8xx/clock.h new file +1 -0
+	unsigned int  clken1;

Please use u32/u64 as the case may be.

--Sean

Quoted 882 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +47 -0
+	unsigned int  clksel;
+	unsigned int  clkdiv1;
+	unsigned int  pllcon0;
+	unsigned int  pllcon1;
+	unsigned int  swrstr;
+	unsigned char res1[0x8];
+	unsigned int  ipsrst1;
+	unsigned int  ipsrst2;
+	unsigned int  clken2;
+	unsigned int  clkdiv2;
+	unsigned int  clken3;
+	unsigned int  ipsrst3;
+	unsigned int  wd0rcr;
+	unsigned int  wd1rcr;
+	unsigned int  wd2rcr;
+	unsigned int  swrstc1;
+	unsigned int  swrstc2;
+	unsigned int  swrstc3;
+	unsigned int  tiprstc;
+	unsigned int  pllcon2;
+	unsigned int  clkdiv3;
+	unsigned int  corstc;
+	unsigned int  pllcong;
+	unsigned int  ahbckfi;
+	unsigned int  seccnt;
+	unsigned int  cntr25m;
+	unsigned int  clken4;
+	unsigned int  ipsrst4;
+	unsigned int  busto;
+	unsigned int  clkdiv4;
+	unsigned int  wd0rcrb;
+	unsigned int  wd1rcrb;
+	unsigned int  wd2rcrb;
+	unsigned int  swrstc1b;
+	unsigned int  swrstc2b;
+	unsigned int  swrstc3b;
+	unsigned int  tiprstcb;
+	unsigned int  corstcb;
+	unsigned int  ipsrstdis1;
+	unsigned int  ipsrstdis2;
+	unsigned int  ipsrstdis3;
+	unsigned int  ipsrstdis4;
+	unsigned char res2[0x10];
+	unsigned int  thrtl_cnt;
+};
+
+#endif
arch/arm/include/asm/arch-npcm8xx/espi.h new file +23 -0
new file mode 100644
index 0000000000..d4de012b02
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_ESPI_H_
+#define _NPCM_ESPI_H_
+
+#define NPCM_ESPI_BA		0xF009F000
+/* Register offsets */
+#define ESPICFG			0x04
+#define ESPIHINDP		0x80
+
+/* Channel Supported */
+#define ESPICFG_CHNSUPP_MASK	0x0F
+#define ESPICFG_CHNSUPP_SHFT	24
+
+/* I/O Mode Supported */
+#define ESPICFG_IOMODE_SHIFT		8
+#define ESPI_IO_MODE_SINGLE_DUAL_QUAD	3
+
+/* Maximum Frequency Supported */
+#define ESPICFG_MAXFREQ_SHIFT		10
+#define ESPI_MAX_33_MHZ			2
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gcr.h new file +313 -0
new file mode 100644
index 0000000000..14a4b2dbfb
@@ -0,0 +1,313 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GCR_H_
+#define _NPCM_GCR_H_
+
+#define NPCM_GCR_BA		0xF0800000
+/* On-Chip ARBEL NPCM8XX VERSIONS */
+
+#define ARBEL_Z1			0x00A35850
+#define ARBEL_A1			0x04a35850
+#define ARBEL_NPCM845			0x00000000
+#define ARBEL_NPCM830			0x00300395
+#define ARBEL_NPCM810			0x00000220
+
+/* Function Lock Register 2 (FLOCKR2) */
+#define FLOCKR2_MMCRST               12
+#define FLOCKR2_MMCRSTLK             13
+#define FLOCKR2_G35DA2P              18
+
+/* Power-On Setting Register (PWRON) */
+#define PWRON_BSPA			4         /* STRAP5 */
+#define PWRON_SECEN			7         /* STRAP8 */
+
+/* Multiple Function Pin Select Register 1 (MFSEL1) */
+#define MFSEL1_SIRQSE               31
+#define MFSEL1_IOX1SEL              30
+#define MFSEL1_HSI2BSEL             29
+#define MFSEL1_HSI1BSEL             28
+#define MFSEL1_DVH1SEL              27
+#define MFSEL1_LPCSEL               26
+#define MFSEL1_PECIB                25
+#define MFSEL1_GSPISEL              24
+#define MFSEL1_SMISEL               22
+#define MFSEL1_CLKOSEL              21
+#define MFSEL1_DVOSEL               18
+#define MFSEL1_KBCICSEL             17
+#define MFSEL1_R2MDSEL              16
+#define MFSEL1_R2ERRSEL             15
+#define MFSEL1_RMII2SEL             14
+#define MFSEL1_R1MDSEL              13
+#define MFSEL1_R1ERRSEL             12
+#define MFSEL1_HSI2ASEL             11
+#define MFSEL1_HSI1ASEL             10
+#define MFSEL1_BSPSEL               9
+#define MFSEL1_SMB2SEL              8
+#define MFSEL1_SMB1SEL              7
+#define MFSEL1_SMB0SEL              6
+#define MFSEL1_HSI2CSEL             5
+#define MFSEL1_HSI1CSEL             4
+#define MFSEL1_S0CS1SEL             3
+#define MFSEL1_SMB5SEL              2
+#define MFSEL1_SMB4SEL              1
+#define MFSEL1_SMB3SEL              0
+
+/* Multiple Function Pin Select Register 3 (MFSEL3) */
+#define MFSEL3_DVODEDLY             27
+#define MFSEL3_DDRDVOSEL            26
+#define MFSEL3_MMCCDSEL             25
+#define MFSEL3_BU1SEL               24
+#define MFSEL3_I3C5SEL              22
+#define MFSEL3_WDO2SEL              20
+#define MFSEL3_WDO1SEL              19
+#define MFSEL3_IOXHSEL              18
+#define MFSEL3_PCIEPUSE             17
+#define MFSEL3_CLKRUNSEL            16
+#define MFSEL3_IOX2SEL              14
+#define MFSEL3_PSPISEL              13
+#define MFSEL3_MMC8SEL              11
+#define MFSEL3_MMCSEL               10
+#define MFSEL3_RMII1SEL             9
+#define MFSEL3_SMB15SEL             8
+#define MFSEL3_SMB14SEL             7
+#define MFSEL3_SMB13SEL             6
+#define MFSEL3_SMB12SEL             5
+#define MFSEL3_SPI1SEL              4
+#define MFSEL3_FIN1916SELB          3
+#define MFSEL3_SMB7SEL              2
+#define MFSEL3_SMB6SEL              1
+#define MFSEL3_SCISEL               0
+
+/* Multiple Function Pin Select Register 4 (MFSEL4) */
+#define MFSEL4_SMB11DDC             29
+#define MFSEL4_SXCS1SEL             28
+#define MFSEL4_SPXSEL               27
+#define MFSEL4_RG2SEL               24
+#define MFSEL4_RG2MSEL              23
+#define MFSEL4_BU2SELB              22
+#define MFSEL4_SG1MSEL              21
+#define MFSEL4_SP3QSEL              20
+#define MFSEL4_S3CS3SEL             19
+#define MFSEL4_S3CS2SEL             18
+#define MFSEL4_S3CS1SEL             17
+#define MFSEL4_SP3SEL               16
+#define MFSEL4_SP0QSEL              15
+#define MFSEL4_SMB11SEL             14
+#define MFSEL4_SMB10SEL             13
+#define MFSEL4_SMB9SEL              12
+#define MFSEL4_SMB8SEL              11
+#define MFSEL4_DBGTRSEL             10
+#define MFSEL4_CKRQSEL              9
+#define MFSEL4_ESPISEL              8
+#define MFSEL4_MMCRSEL              6
+#define MFSEL4_SD1PSEL              5
+#define MFSEL4_ROSEL                4
+#define MFSEL4_ESPIPMESEL           2
+#define MFSEL4_BSPASEL              1
+#define MFSEL4_JTAG2SEL             0
+
+/* Multiple Function Pin Select Register 5 (MFSEL5) */
+#define MFSEL5_R3OENSEL             14
+#define MFSEL5_RMII3SEL             11
+#define MFSEL5_R2OENSEL             10
+#define MFSEL5_R1OENSEL             9
+#define MFSEL5_NSPI1CS3SEL          5
+#define MFSEL5_NSPI1CS2SEL          4
+#define MFSEL5_SPI1D23SEL           3
+#define MFSEL5_NSPI1CS1SEL          0
+
+/* Multiple Function Pin Select Register 6 (MFSEL6) */
+#define MFSEL6_GPIO1836SEL          19
+#define MFSEL6_FM1SEL               17
+
+/* Multiple Function Pin Select Register 7 (MFSEL7) */
+#define MFSEL7_SMB15SELB            27
+#define MFSEL7_GPIO1889SEL          25
+
+/* USB PHY1 Control Register (USB1PHYCTL) */
+#define USB1PHYCTL_RS				28
+/* USB PHY2 Control Register (USB2PHYCTL) */
+#define USB2PHYCTL_RS				28
+/* USB PHY2 Control Register (USB3PHYCTL) */
+#define USB3PHYCTL_RS				28
+
+/* Integration Control Register (INTCR) */
+#define  INTCR_DUDKSMOD             30
+#define  INTCR_DDC3I                29
+#define  INTCR_KVMSI                28
+#define  INTCR_DEHS                 27
+#define  INTCR_GGPCT2_0             24
+#define  INTCR_SGC2                 23
+#define  INTCR_DSNS_TRIG            21
+#define  INTCR_DAC_SNS              20
+#define  INTCR_SGC1                 19
+#define  INTCR_LDDRB                18
+#define  INTCR_GIRST                17
+#define  INTCR_DUDKSEN              16
+#define  INTCR_DACOFF               15
+#define  INTCR_DACSEL               14
+#define  INTCR_GFXINT               12
+#define  INTCR_DACOSOVR             10
+#define  INTCR_GFXIFDIS             8
+#define  INTCR_H2RQDIS              9
+#define  INTCR_H2DISPOFF            8
+#define  INTCR_GFXINT2              7
+#define  INTCR_VGAIOEN              6
+#define  INTCR_PSPIFEN              4
+#define  INTCR_HIFEN                3
+#define  INTCR_SMBFEN               2
+#define  INTCR_MFTFEN               1
+#define  INTCR_KCSRST_MODE          0
+
+/* Integration Control Register (INTCR2) */
+#define  INTCR2_WDC                   21
+
+/* Integration Control Register (INTCR3) */
+#define  INTCR3_USBLPBK2              31          /* USB loop-backed HOST 1/2 */
+#define  INTCR3_USBLPBK               24          /* USB loop-backed mode on/off */
+#define  INTCR3_USBPHY3SW             14          /* 2 bits */
+#define  INTCR3_USBPHY2SW             12          /* 2 bits */
+#define  INTCR3_USBPPS                6
+#define  INTCR3_UHUB_RWUD             5
+
+/* Integration Control Register (INTCR4) */
+#define  INTCR4_GMMAP1                24
+#define  INTCR4_GMMAP0                16
+#define  INTCR4_R3EN                  14
+#define  INTCR4_R2EN                  13
+#define  INTCR4_R1EN                  12
+#define  INTCR4_RGMIIREF              6
+
+/* I2C Segment Pin Select Register (I2CSEGSEL) */
+#define I2CSEGSEL_S0DECFG			3
+#define I2CSEGSEL_S4DECFG			17
+
+/* I2C Segment Control Register (I2CSEGCTL) */
+#define I2CSEGCTL_S0DEN				20
+#define I2CSEGCTL_S0DWE				21
+#define I2CSEGCTL_S4DEN				24
+#define I2CSEGCTL_S4DWE				25
+#define I2CSEGCTL_INIT_VAL		0x9333F000
+
+struct npcm_gcr {
+	unsigned int  pdid;
+	unsigned int  pwron;
+	unsigned int  swstrps;
+	unsigned int  rsvd1[2];
+	unsigned int  miscpe;
+	unsigned int  spldcnt;
+	unsigned int  rsvd2[1];
+	unsigned int  flockr2;
+	unsigned int  flockr3;
+	unsigned int  rsvd3[3];
+	unsigned int  a35_mode;
+	unsigned int  spswc;
+	unsigned int  intcr;
+	unsigned int  intsr;
+	unsigned int  obscr1;
+	unsigned int  obsdr1;
+	unsigned int  rsvd4[1];
+	unsigned int  hifcr;
+	unsigned int  rsvd5[3];
+	unsigned int  intcr2;
+	unsigned int  rsvd6[1];
+	unsigned int  srcnt;
+	unsigned int  ressr;
+	unsigned int  rlockr1;
+	unsigned int  flockr1;
+	unsigned int  dscnt;
+	unsigned int  mdlr;
+	unsigned int  scrpad_c;
+	/* scrpad_b: holds the active dram size (value set by bootblock) */
+	unsigned int  scrpad_b;
+	unsigned int  rsvd7[4];
+	unsigned int  daclvlr;
+	unsigned int  intcr3;
+	unsigned int  pcirctl;
+	unsigned int  rsvd8[2];
+	unsigned int  vsintr;
+	unsigned int  rsvd9[1];
+	unsigned int  sd2sur1;
+	unsigned int  sd2sur2;
+	unsigned int  sd2irv3;
+	unsigned int  intcr4;
+	unsigned int  obscr2;
+	unsigned int  obsdr2;
+	unsigned int  rsvd10[5];
+	unsigned int  i2csegsel;
+	unsigned int  i2csegctl;
+	unsigned int  vsrcr;
+	unsigned int  mlockr;
+	unsigned int  rsvd11[8];
+	unsigned int  etsr;
+	unsigned int  dft1r;
+	unsigned int  dft2r;
+	unsigned int  dft3r;
+	unsigned int  edffsr;
+	unsigned int  rsvd12[1];
+	unsigned int  intcrpce3;
+	unsigned int  intcrpce2;
+	unsigned int  intcrpce0;
+	unsigned int  intcrpce1;
+	unsigned int  dactest;
+	unsigned int  scrpad;
+	unsigned int  usb1phyctl;
+	unsigned int  usb2phyctl;
+	unsigned int  usb3phyctl;
+	unsigned int  intsr2;
+	unsigned int  intcrpce2b;
+	unsigned int  intcrpce0b;
+	unsigned int  intcrpce1b;
+	unsigned int  intcrpce3b;
+	unsigned int  rsvd13[4];
+	unsigned int  intcrpce2c;
+	unsigned int  intcrpce0c;
+	unsigned int  intcrpce1c;
+	unsigned int  intcrpce3c;
+	unsigned int  rsvd14[40];
+	unsigned int  sd2irv4;
+	unsigned int  sd2irv5;
+	unsigned int  sd2irv6;
+	unsigned int  sd2irv7;
+	unsigned int  sd2irv8;
+	unsigned int  sd2irv9;
+	unsigned int  sd2irv10;
+	unsigned int  sd2irv11;
+	unsigned int  rsvd15[8];
+	unsigned int  mfsel1;
+	unsigned int  mfsel2;
+	unsigned int  mfsel3;
+	unsigned int  mfsel4;
+	unsigned int  mfsel5;
+	unsigned int  mfsel6;
+	unsigned int  mfsel7;
+	unsigned int  rsvd16[1];
+	unsigned int  mfsel_lk1;
+	unsigned int  mfsel_lk2;
+	unsigned int  mfsel_lk3;
+	unsigned int  mfsel_lk4;
+	unsigned int  mfsel_lk5;
+	unsigned int  mfsel_lk6;
+	unsigned int  mfsel_lk7;
+	unsigned int  rsvd17[1];
+	unsigned int  mfsel_set1;
+	unsigned int  mfsel_set2;
+	unsigned int  mfsel_set3;
+	unsigned int  mfsel_set4;
+	unsigned int  mfsel_set5;
+	unsigned int  mfsel_set6;
+	unsigned int  mfsel_set7;
+	unsigned int  rsvd18[1];
+	unsigned int  mfsel_clr1;
+	unsigned int  mfsel_clr2;
+	unsigned int  mfsel_clr3;
+	unsigned int  mfsel_clr4;
+	unsigned int  mfsel_clr5;
+	unsigned int  mfsel_clr6;
+	unsigned int  mfsel_clr7;
+	};
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gpio.h new file +11 -0
new file mode 100644
index 0000000000..234a1d3de9
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GPIO_H_
+#define _NPCM_GPIO_H_
+
+#define NPCM_GPIO_BA		0xF0010000
+
+#endif
arch/arm/include/asm/arch-npcm8xx/rst.h new file +32 -0
new file mode 100644
index 0000000000..ffaff50fe2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_RST_H_
+#define _NPCM_RST_H_
+
+enum reset_type {
+	PORST_TYPE    = 0x01,
+	CORST_TYPE    = 0x02,
+	WD0RST_TYPE   = 0x03,
+	SWR1ST_TYPE   = 0x04,
+	SWR2ST_TYPE   = 0x05,
+	SWR3ST_TYPE   = 0x06,
+	SWR4ST_TYPE   = 0x07,
+	WD1RST_TYPE   = 0x08,
+	WD2RST_TYPE   = 0x09,
+	UNKNOWN_TYPE  = 0x10,
+};
+
+#define PORST 0x80000000
+#define CORST 0x40000000
+#define WD0RST 0x20000000
+#define SWR1ST 0x10000000
+#define SWR2ST 0x08000000
+#define SWR3ST 0x04000000
+#define SWR4ST 0x02000000
+#define WD1RST 0x01000000
+#define WD2RST 0x00800000
+#define RESSR_MASK 0xff800000
+
+enum reset_type npcm8xx_reset_reason(void);
+
+#endif
arch/arm/mach-nuvoton/Kconfig new file +24 -0
new file mode 100644
index 0000000000..e014dd4b79
@@ -0,0 +1,24 @@
+if ARCH_NPCM
+
+config SYS_ARCH
+	default "arm"
+
+config SYS_TEXT_BASE
+	default 0x8000
+
+choice
+	prompt "Nuvoton SoC select"
+	default ARCH_NPCM8XX
+
+config ARCH_NPCM8XX
+	bool "Support Nuvoton NPCM8xx SoC"
+	select ARM64
+	help
+	  General support for NPCM8xx BMC (Arbel).
+	  Nuvoton NPCM8xx BMC is based on the Cortex A35.
+
+endchoice
+
+source "arch/arm/mach-nuvoton/npcm8xx/Kconfig"
+
+endif
arch/arm/mach-nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..e75689a1a0
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += npcm8xx/
arch/arm/mach-nuvoton/npcm8xx/Kconfig new file +18 -0
new file mode 100644
index 0000000000..478a046ad5
@@ -0,0 +1,18 @@
+if ARCH_NPCM8XX
+
+config SYS_CPU
+	default "armv8"
+
+config SYS_SOC
+	default "npcm8xx"
+
+config TARGET_ARBEL_EVB
+	bool "Arbel-EVB"
+	help
+	  ARBEL_EVB is Nuvoton evaluation board for NPCM845 SoC,
+	  supports general functions of Basebase Management Controller
+	  (BMC).
+
+source "board/nuvoton/arbel/Kconfig"
+
+endif
arch/arm/mach-nuvoton/npcm8xx/Makefile new file +1 -0
new file mode 100644
index 0000000000..c62a4aa20a
@@ -0,0 +1 @@
+obj-y += reset.o cpu.o
arch/arm/mach-nuvoton/npcm8xx/cpu.c new file +170 -0
new file mode 100644
index 0000000000..8a7315d535
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <cpu_func.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/arch/espi.h>
+#include <asm/armv8/mmu.h>
+#include <asm/system.h>
+#include <asm/global_data.h>
+
+/* System Counter */
+struct sctr_regs {
+	u32 cntcr;
+	u32 cntsr;
+	u32 cntcv1;
+	u32 cntcv2;
+	u32 resv1[4];
+	u32 cntfid0;
+	u32 cntfid1;
+	u32 cntfid2;
+	u32 resv2[1001];
+	u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE		BIT(0)
+#define SC_CNTCR_HDBG		BIT(1)
+#define SC_CNTCR_FREQ0		BIT(8)
+#define SC_CNTCR_FREQ1		BIT(9)
+
+#define SYSCNT_CTRL_BASE_ADDR   0xF07FC000
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int print_cpuinfo(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+	unsigned int id = 0;
+	unsigned long mpidr_val = 0;
+	unsigned int mdlr = 0;
+
+	asm volatile("mrs %0, mpidr_el1" : "=r" (mpidr_val));
+
+	mdlr = readl(&gcr->mdlr);
+
+	printf("CPU-%d: ", (unsigned int)(mpidr_val & 0x3));
+
+	switch (mdlr) {
+	case ARBEL_NPCM845:
+		printf("NPCM845 ");
+		break;
+	case ARBEL_NPCM830:
+		printf("NPCM830 ");
+		break;
+	case ARBEL_NPCM810:
+		printf("NPCM810 ");
+		break;
+	default:
+		printf("NPCM8XX ");
+		break;
+	}
+
+	id = readl(&gcr->pdid);
+	switch (id) {
+	case ARBEL_Z1:
+		printf("Z1 @ ");
+		break;
+	case ARBEL_A1:
+		printf("A1 @ ");
+		break;
+	default:
+		printf("Unknown\n");
+		break;
+	}
+
+	return 0;
+}
+
+static void npcm_sysintf_init(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+	u32 espi_ch_supp, val;
+
+	espi_ch_supp = ofnode_conf_read_int("espi-channel-support", 0);
+
+	if (espi_ch_supp) {
+		/* Use eSPI function and initialize ESPICFG */
+		u32 hindp = 0x00011110 | espi_ch_supp;
+
+		writel((readl(&gcr->mfsel4) | (1 << MFSEL4_ESPISEL)), &gcr->mfsel4);
+		writel(hindp, NPCM_ESPI_BA + ESPIHINDP);
+		val = readl(NPCM_ESPI_BA + ESPICFG);
+		val |= ESPI_IO_MODE_SINGLE_DUAL_QUAD << ESPICFG_IOMODE_SHIFT;
+		val |= ESPI_MAX_33_MHZ << ESPICFG_MAXFREQ_SHIFT;
+		val |= ((espi_ch_supp & ESPICFG_CHNSUPP_MASK) << ESPICFG_CHNSUPP_SHFT);
+		writel(val, NPCM_ESPI_BA + ESPICFG);
+	} else {
+		/* Use LPC function */
+		writel((readl(&gcr->mfsel1) | (1 << MFSEL1_LPCSEL)), &gcr->mfsel1);
+	}
+}
+
+int arch_cpu_init(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+	if (!IS_ENABLED(CONFIG_SYS_DCACHE_OFF)) {
+		/* enable cache to speed up system running */
+		if (get_sctlr() & CR_M)
+			return 0;
+
+		icache_enable();
+		__asm_invalidate_dcache_all();
+		__asm_invalidate_tlb_all();
+		set_sctlr(get_sctlr() | CR_C);
+	}
+
+	/* Power voltage select setup */
+	setbits_le32(&gcr->vsrcr, BIT(30));
+
+	npcm_sysintf_init();
+
+	return 0;
+}
+
+static struct mm_region npcm_mem_map[1 + CONFIG_NR_DRAM_BANKS + 1] = {
+	{
+		/* DRAM */
+		.phys = 0x0UL,
+		.virt = 0x0UL,
+		.size = 0x80000000UL,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+			 PTE_BLOCK_INNER_SHARE
+	},
+	{
+		.phys = 0x80000000UL,
+		.virt = 0x80000000UL,
+		.size = 0x80000000UL,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	},
+	{
+		/* List terminator */
+		0,
+	}
+};
+
+struct mm_region *mem_map = npcm_mem_map;
+
+int timer_init(void)
+{
+	struct sctr_regs *sctr = (struct sctr_regs *)SYSCNT_CTRL_BASE_ADDR;
+	unsigned int cntfrq_el0;
+
+	__asm__ __volatile__("mrs %0, CNTFRQ_EL0\n\t" : "=r" (cntfrq_el0) : : "memory");
+	writel(cntfrq_el0, &sctr->cntfid0);
+
+	clrsetbits_le32(&sctr->cntcr, SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1,
+			SC_CNTCR_ENABLE | SC_CNTCR_HDBG);
+
+	gd->arch.tbl = 0;
+	gd->arch.tbu = 0;
+
+	return 0;
+}
arch/arm/mach-nuvoton/npcm8xx/reset.c new file +51 -0
new file mode 100644
index 0000000000..7fbed7ba76
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/rst.h>
+#include <asm/arch/gcr.h>
+
+void reset_cpu(void)
+{
+	/* Watcdog reset - WTCR register set  WTE-BIT7 WTRE-BIT1 WTR-BIT0 */
+	writel(0x83, 0xf000801c);
+
+	while (1)
+		;
+}
+
+void reset_misc(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+	/* clear WDC */
+	writel(readl(&gcr->intcr2) & ~(1 << INTCR2_WDC), &gcr->intcr2);
+}
+
+enum reset_type npcm8xx_reset_reason(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+	enum reset_type type = UNKNOWN_TYPE;
+	u32 value = readl(&gcr->ressr);
+
+	if (value == 0)
+		value = ~readl(&gcr->intcr2);
+
+	value &= RESSR_MASK;
+
+	if (value & CORST)
+		type = CORST;
+	if (value & WD0RST)
+		type = WD0RST;
+	if (value & WD1RST)
+		type = WD1RST;
+	if (value & WD2RST)
+		type = WD2RST;
+	if (value & PORST)
+		type = PORST;
+
+	return type;
+}
board/nuvoton/arbel/Kconfig new file +18 -0
new file mode 100644
index 0000000000..4a03ea1abf
@@ -0,0 +1,18 @@
+if TARGET_ARBEL_EVB
+
+config SYS_BOARD
+	default "arbel"
+
+config SYS_VENDOR
+	default "nuvoton"
+
+config SYS_CONFIG_NAME
+	default "arbel"
+
+config SYS_MEM_TOP_HIDE
+	hex "Reserved TOP memory"
+	default 0xB000000
+	help
+	  Reserve memory for ECC/GFX/VCD/ECE.
+
+endif
board/nuvoton/arbel/Makefile new file +1 -0
new file mode 100644
index 0000000000..f9ad1dea34
@@ -0,0 +1 @@
+obj-y	+= arbel.o
board/nuvoton/arbel/arbel.c new file +33 -0
new file mode 100644
index 0000000000..86cef98c5f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/mach-types.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+	gd->bd->bi_arch_number = MACH_TYPE_NPCMX50;
+	gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100UL);
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+	/*
+	 * get dram active size value from bootblock.
+	 * Value sent using scrpad_02 register.
+	 */
+	gd->ram_size = readl(&gcr->scrpad_b);
+
+	return 0;
+}
include/configs/arbel.h new file +54 -0
new file mode 100644
index 0000000000..2cb658c3e6
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef __CONFIG_ARBEL_H
+#define __CONFIG_ARBEL_H
+
+#define CONFIG_GICV2
+#define GICD_BASE			(0xDFFF9000)
+#define GICC_BASE			(0xDFFFA000)
+
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS   1
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG
+#define CONFIG_SYS_MAXARGS              32
+#define CONFIG_SYS_CBSIZE               256
+#define CONFIG_SYS_PBSIZE               (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_PROMPT_HUSH_PS2	    "> "
+#define CONFIG_SYS_BOOTM_LEN            (20 << 20)
+#define CONFIG_SYS_BOOTMAPSZ            (20 << 20)
+#define CONFIG_SYS_SDRAM_BASE           0x0
+#define CONFIG_SYS_INIT_SP_ADDR         (0x00008000 - GENERATED_GBL_DATA_SIZE)
+#define CONFIG_SYS_MONITOR_LEN          (256 << 10)
+#define CONFIG_SYS_MONITOR_BASE	        CONFIG_SYS_TEXT_BASE
+#define CONFIG_BAUDRATE                 115200
+#define CONFIG_SYS_HZ                   1000
+#define CONFIG_BITBANGMII_MULTI
+
+/* Default environemnt variables */
+#define CONFIG_BOOTCOMMAND "run common_bootargs; run romboot"
+#define CONFIG_EXTRA_ENV_SETTINGS   "uimage_flash_addr=80200000\0"   \
+		"stdin=serial\0"   \
+		"stdout=serial\0"   \
+		"stderr=serial\0"    \
+		"ethact=gmac1\0"   \
+		"autostart=no\0"   \
+		"ethaddr=00:00:F7:A0:00:FC\0"    \
+		"eth1addr=00:00:F7:A0:00:FD\0"   \
+		"eth2addr=00:00:F7:A0:00:FE\0"    \
+		"eth3addr=00:00:F7:A0:00:FF\0"    \
+		"gatewayip=192.168.0.17\0"    \
+		"serverip=192.168.0.17\0"    \
+		"ipaddr=192.168.0.15\0"    \
+		"romboot=echo Booting Kernel from flash at 0x${uimage_flash_addr}; " \
+		"echo Using bootargs: ${bootargs};bootm ${uimage_flash_addr}\0" \
+		"earlycon=uart8250,mmio32,0xf0000000\0" \
+		"console=ttyS0,115200n8\0" \
+		"common_bootargs=setenv bootargs earlycon=${earlycon} root=/dev/ram " \
+		"console=${console} ramdisk_size=48000\0" \
+		"\0"
+
+#endif

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Hi Sean,
Thanks for the review.
It is addressed in the gpio driver patch as below.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

--
Stanley

Quoted 47 lines · Sean Anderson
Quoted 28 lines · Jesse Taube
Quoted 15 lines · Sean Anderson
Quoted 14 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

---
   arch/arm/Kconfig                          |   9 +
   arch/arm/Makefile                         |   1 +
   arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
   arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
   arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
   arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
   arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
   arch/arm/mach-nuvoton/Kconfig             |  24 ++
   arch/arm/mach-nuvoton/Makefile            |   1 +
   arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
Quoted 8 lines
Quoted 8 lines
   arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
   arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++
   arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++
   board/nuvoton/arbel/Kconfig               |  18 ++
   board/nuvoton/arbel/Makefile              |   1 +
   board/nuvoton/arbel/arbel.c               |  33 +++
   include/configs/arbel.h                   |  54 ++++
   17 files changed, 924 insertions(+)

Hello World!

Quoted 9 lines

Because I was CC'ed I guess I will keep myself up-to date. This commit has 17 files changed and almost 1k insertions, That is a relatively large commit. Would it be better to split /arch/arm/include/asm
/arch/arm/mach-nuvoton
/board
/include/configs
into different commits.
I ask this because I split them for a patch I'm working on

Please submit the relevant headers with their drivers.

For example, arch/arm/include/asm/arch-npcm8xx/gpio.h should go in "[PATCH v1 5/9] gpio: npcm: Add support for Nuvoton NPCM SoCs"

--Sean

#10 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

In reply to a message not in the archive

Hi Jesse,
Thanks for the comment, this will be addressed in the next patches.

--
Stanley

Quoted 38 lines · Jesse Taube
Quoted 15 lines · Sean Anderson
Quoted 14 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

---
   arch/arm/Kconfig                          |   9 +
   arch/arm/Makefile                         |   1 +
   arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
   arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
   arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
   arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
   arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
   arch/arm/mach-nuvoton/Kconfig             |  24 ++
   arch/arm/mach-nuvoton/Makefile            |   1 +
   arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
Quoted 8 lines
Quoted 8 lines
   arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
   arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++
   arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++
   board/nuvoton/arbel/Kconfig               |  18 ++
   board/nuvoton/arbel/Makefile              |   1 +
   board/nuvoton/arbel/arbel.c               |  33 +++
   include/configs/arbel.h                   |  54 ++++
   17 files changed, 924 insertions(+)

Hello World!

Because I was CC'ed I guess I will keep myself up-to date. This commit has 17 files changed and almost 1k insertions, That is a relatively large commit. Would it be better to split /arch/arm/include/asm
/arch/arm/mach-nuvoton
/board
/include/configs
into different commits.
I ask this because I split them for a patch I'm working on

#11 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

In reply to Sean Anderson

Hi Sean,

Thank you for your comment, I've submitted a clk driver patch to address this.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

As for the reset controller, I will take reset-syscon driver for that.

--
Stanley

Quoted 1,144 lines · Sean Anderson

arch/arm/include/asm/arch-npcm8xx/clock.h

Quoted 82 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

---
  arch/arm/Kconfig                          |   9 +
  arch/arm/Makefile                         |   1 +
  arch/arm/include/asm/arch-npcm8xx/clock.h | 164 ++++++++++++
  arch/arm/include/asm/arch-npcm8xx/espi.h  |  23 ++
  arch/arm/include/asm/arch-npcm8xx/gcr.h   | 313 ++++++++++++++++++++++
  arch/arm/include/asm/arch-npcm8xx/gpio.h  |  11 +
  arch/arm/include/asm/arch-npcm8xx/rst.h   |  32 +++
  arch/arm/mach-nuvoton/Kconfig             |  24 ++
  arch/arm/mach-nuvoton/Makefile            |   1 +
  arch/arm/mach-nuvoton/npcm8xx/Kconfig     |  18 ++
  arch/arm/mach-nuvoton/npcm8xx/Makefile    |   1 +
  arch/arm/mach-nuvoton/npcm8xx/cpu.c       | 170 ++++++++++++
  arch/arm/mach-nuvoton/npcm8xx/reset.c     |  51 ++++
  board/nuvoton/arbel/Kconfig               |  18 ++
  board/nuvoton/arbel/Makefile              |   1 +
  board/nuvoton/arbel/arbel.c               |  33 +++
  include/configs/arbel.h                   |  54 ++++
  17 files changed, 924 insertions(+)

create mode 100644 arch/arm/include/asm/arch-npcm8xx/clock.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/espi.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gcr.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/gpio.h create mode 100644 arch/arm/include/asm/arch-npcm8xx/rst.h create mode 100644 arch/arm/mach-nuvoton/Kconfig create mode 100644 arch/arm/mach-nuvoton/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Kconfig create mode 100644 arch/arm/mach-nuvoton/npcm8xx/Makefile create mode 100644 arch/arm/mach-nuvoton/npcm8xx/cpu.c create mode 100644 arch/arm/mach-nuvoton/npcm8xx/reset.c create mode 100644 board/nuvoton/arbel/Kconfig create mode 100644 board/nuvoton/arbel/Makefile create mode 100644 board/nuvoton/arbel/arbel.c create mode 100644 include/configs/arbel.h

arch/arm/Kconfig +9 -0
index f7f03837fe..80ec42f6be 100644
@@ -1952,6 +1952,13 @@ config TARGET_XENGUEST_ARM64
      select LINUX_KERNEL_IMAGE_HEADER
      select XEN_SERIAL
      select SSCANF
+
+config ARCH_NPCM
+     bool "Support Nuvoton SoCs"
+     select DM
+     select OF_CONTROL
+     imply CMD_DM
+
  endchoice
 
  config SUPPORT_PASSING_ATAGS
@@ -2150,6 +2157,8 @@ source "arch/arm/mach-imx/Kconfig"
 
  source "arch/arm/mach-nexell/Kconfig"
 
+source "arch/arm/mach-nuvoton/Kconfig"
+
  source "board/armltd/total_compute/Kconfig"
 
  source "board/bosch/shc/Kconfig"
arch/arm/Makefile +1 -0
index ad757e982e..29a0250ab6 100644
@@ -92,6 +92,7 @@ machine-$(CONFIG_ARCH_VERSAL)               += versal
  machine-$(CONFIG_ARCH_ZYNQ)         += zynq
  machine-$(CONFIG_ARCH_ZYNQMP)               += zynqmp
  machine-$(CONFIG_ARCH_ZYNQMP_R5)    += zynqmp-r5
+machine-$(CONFIG_ARCH_NPCM)          += nuvoton
 
  machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
arch/arm/include/asm/arch-npcm8xx/clock.h new file +0 -0
new file mode 100644
index 0000000000..088b536b7b

Please add this (and all the other includes) in the patches adding the drivers which use them. This makes it much easier to review.

Additionally, if these defines are not used elsewhere, they can be included at the beginning of the clock driver itself.

arch/arm/include/asm/arch-npcm8xx/clock.h line 10

Quoted 11 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_CLOCK_H_
+#define _NPCM_CLOCK_H_
+
+#define NPCM_CLK_BA          0xF0801000
+enum {

Don't redefine these. Just use include/dt-bindings/clock/npcm845-clock.h

Quoted 14 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +14 -0
+     APB1  = 1,
+     APB2  = 2,
+     APB3  = 3,
+     APB4  = 4,
+     APB5  = 5,
+     SPI0  = 10,
+     SPI1  = 11,
+     SPI3  = 13,
+     SPIX  = 14,
+};
+
+/* Clock Select Register (CLKSEL) */
+#define CLKSEL_RCPCKSEL             27
+#define CLKSEL_RGSEL                25

arch/arm/include/asm/arch-npcm8xx/clock.h line 34

Quoted 10 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
+#define CLKSEL_GFXMSEL              21
+#define CLKSEL_CLKOUTSEL            18
+#define CLKSEL_PCICKSEL             16
+#define CLKSEL_ADCCKSEL             14
+#define CLKSEL_MCCKSEL              12
+#define CLKSEL_SUCKSEL              10
+#define CLKSEL_UARTCKSEL            8
+#define CLKSEL_SDCKSEL              6
+#define CLKSEL_PIXCKSEL             4
+#define CLKSEL_CPUCKSEL             0

Please use GENMASK for this. For example,

        #define CLKSEL_CPUCKSEL GENMASK(1, 0)

This allows you to do things like

u32 clksel = readl(&regs->clksel);

        switch (FIELD_GET(CLKSEL_CPUCKSEL, clksel)) {

        }

later on, instead of having magic masks everywhere.

Quoted 39 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +39 -0
+
+/* Clock Divider Control Register 1 (CLKDIV1) */
+#define CLKDIV1_ADCCKDIV            28
+#define CLKDIV1_CLK4DIV             26
+#define CLKDIV1_PRE_ADCCKDIV        21
+#define CLKDIV1_UARTDIV             16
+#define CLKDIV1_MMCCKDIV            11
+#define CLKDIV1_SPI3CKDIV           6
+#define CLKDIV1_PCICKDIV            2
+
+/* Clock Divider Control Register 2 (CLKDIV2) */
+#define CLKDIV2_APB4CKDIV           30
+#define CLKDIV2_APB3CKDIV           28
+#define CLKDIV2_APB2CKDIV           26
+#define CLKDIV2_APB1CKDIV           24
+#define CLKDIV2_APB5CKDIV           22
+#define CLKDIV2_CLKOUTDIV           16
+#define CLKDIV2_GFXCKDIV            13
+#define CLKDIV2_SUCKDIV             8
+#define CLKDIV2_SU48CKDIV           4
+
+/* PLL Control Register 2 (PLLCON2) */
+#define PLLCON_LOKI                31
+#define PLLCON_LOKS                30
+#define PLLCON_FBDV                16
+#define PLLCON_OTDV2               13
+#define PLLCON_PWDEN               12
+#define PLLCON_OTDV1               8
+#define PLLCON_INDV                0
+
+/* CPUCKSEL (CPU/AMBA/MC Clock Source Select Bit) */
+#define CLKSEL_CPUCKSEL_PLL0        0x00   /* 0 0: PLL0 clock*/
+#define CLKSEL_CPUCKSEL_PLL1        0x01   /* 0 1: PLL1 clock */
+#define CLKSEL_CPUCKSEL_CLKREF      0x02   /* 1 0: CLKREF input (25 MHZ, default) */
+#define CLKSEL_CPUCKSEL_SYSBPCK     0x03   /* 1 1: Bypass clock from pin SYSBPCK */
+
+/* UARTCKSEL (Core and Host UART Clock Source Select Bit). */
+#define CLKSEL_UARTCKSEL_PLL0       0x00  /* 0 0: PLL0    clock. */
+#define CLKSEL_UARTCKSEL_PLL1       0x01  /* 0 1: PLL1    clock. */

arch/arm/include/asm/arch-npcm8xx/clock.h line 83

Quoted 10 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
+#define CLKSEL_UARTCKSEL_CLKREF     0x02  /* 1 0: CLKREF  clock (25 MHZ, default). */
+#define CLKSEL_UARTCKSEL_PLL2       0x03  /* 1 1: PLL2    clock divided by 2. */
+
+/* SDCKSEL (SDHC Clock Source Select Bit). */
+#define CLKSEL_SDCKSEL_PLL0         0x00   /* 0 0: PLL0    clock.  */
+#define CLKSEL_SDCKSEL_PLL1         0x01   /* 0 1: PLL1    clock.  */
+#define CLKSEL_SDCKSEL_CLKREF       0x02   /* 1 0: CLKREF clock (25 MHZ, default).  */
+#define CLKSEL_SDCKSEL_PLL2         0x03   /* 1 1: PLL2    clock divided by 2.  */
+
+/* IP Software Reset Register 1 (IPSRST1), offset 0x20 */

If you have multiple logical devices in one group of registers, you should look into organizing your bindings like

        syscon@0xf0801000 {
                compatible = "simple-mfd";
                reg = <0x0 0xf0801000 0x0 0x70>;

                clks: clock-controller {
                        compatible = "nuvoton,npcm845-clock";
                        #clock-cells = <1>;
                        clocks = <&some_oscillator>;
                        clock-names = "extclk";
                        u-boot,dm-pre-reloc;
                };

                rsts: reset-controller {
                        compatible = "nuvoton,npcm845-reset";
                        #reset-cells = <1>;
                }
        }
Quoted 21 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +21 -0
+#define IPSRST1_USBDEV1             5
+#define IPSRST1_USBDEV2             8
+#define IPSRST1_USBDEV3             25
+#define IPSRST1_USBDEV4             22
+#define IPSRST1_USBDEV5             23
+#define IPSRST1_USBDEV6             24
+#define IPSRST1_GMAC4               21
+#define IPSRST1_GMAC3               6
+
+/* IP Software Reset Register 2 (IPSRST2), offset 0x24 */
+#define IPSRST2_GMAC1               28
+#define IPSRST2_GMAC2               25
+#define IPSRST2_USBHOST1            26
+#define IPSRST2_SDHC                9
+#define IPSRST2_MMC                 8
+
+/* IP Software Reset Register 3 (IPSRST3), offset 0x34 */
+#define IPSRST3_USBPHY1             24
+#define IPSRST3_USBPHY2             25
+#define IPSRST3_USBHUB              8
+#define IPSRST3_USBDEV9             7

arch/arm/include/asm/arch-npcm8xx/clock.h line 114

Quoted 10 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +10 -0
+#define IPSRST3_USBDEV8             6
+#define IPSRST3_USBDEV7             5
+#define IPSRST3_USBDEV0             4
+
+/* IP Software Reset Register 4 (IPSRST4), offset 0x74 */
+#define IPSRST4_USBHOST2            31
+#define IPSRST4_USBPHY3             25
+
+#define EXT_CLOCK_FREQUENCY_KHZ          25 * 1000 * 1UL
+#define EXT_CLOCK_FREQUENCY_MHZ          25

Just define it in HZ and divide it as needed. The compiler will optimize it. But see also my comments on your other patch.

arch/arm/include/asm/arch-npcm8xx/clock.h line 116

Quoted 2 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +2 -0
+
+struct clk_ctl {

Please name this npcm_clk_ctl or similar.

arch/arm/include/asm/arch-npcm8xx/clock.h line 117

Quoted 1 line
arch/arm/include/asm/arch-npcm8xx/clock.h new file +1 -0
+     unsigned int  clken1;

Please use u32/u64 as the case may be.

--Sean

Quoted 882 lines
arch/arm/include/asm/arch-npcm8xx/clock.h new file +47 -0
+     unsigned int  clksel;
+     unsigned int  clkdiv1;
+     unsigned int  pllcon0;
+     unsigned int  pllcon1;
+     unsigned int  swrstr;
+     unsigned char res1[0x8];
+     unsigned int  ipsrst1;
+     unsigned int  ipsrst2;
+     unsigned int  clken2;
+     unsigned int  clkdiv2;
+     unsigned int  clken3;
+     unsigned int  ipsrst3;
+     unsigned int  wd0rcr;
+     unsigned int  wd1rcr;
+     unsigned int  wd2rcr;
+     unsigned int  swrstc1;
+     unsigned int  swrstc2;
+     unsigned int  swrstc3;
+     unsigned int  tiprstc;
+     unsigned int  pllcon2;
+     unsigned int  clkdiv3;
+     unsigned int  corstc;
+     unsigned int  pllcong;
+     unsigned int  ahbckfi;
+     unsigned int  seccnt;
+     unsigned int  cntr25m;
+     unsigned int  clken4;
+     unsigned int  ipsrst4;
+     unsigned int  busto;
+     unsigned int  clkdiv4;
+     unsigned int  wd0rcrb;
+     unsigned int  wd1rcrb;
+     unsigned int  wd2rcrb;
+     unsigned int  swrstc1b;
+     unsigned int  swrstc2b;
+     unsigned int  swrstc3b;
+     unsigned int  tiprstcb;
+     unsigned int  corstcb;
+     unsigned int  ipsrstdis1;
+     unsigned int  ipsrstdis2;
+     unsigned int  ipsrstdis3;
+     unsigned int  ipsrstdis4;
+     unsigned char res2[0x10];
+     unsigned int  thrtl_cnt;
+};
+
+#endif
arch/arm/include/asm/arch-npcm8xx/espi.h new file +23 -0
new file mode 100644
index 0000000000..d4de012b02
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_ESPI_H_
+#define _NPCM_ESPI_H_
+
+#define NPCM_ESPI_BA         0xF009F000
+/* Register offsets */
+#define ESPICFG                      0x04
+#define ESPIHINDP            0x80
+
+/* Channel Supported */
+#define ESPICFG_CHNSUPP_MASK 0x0F
+#define ESPICFG_CHNSUPP_SHFT 24
+
+/* I/O Mode Supported */
+#define ESPICFG_IOMODE_SHIFT         8
+#define ESPI_IO_MODE_SINGLE_DUAL_QUAD        3
+
+/* Maximum Frequency Supported */
+#define ESPICFG_MAXFREQ_SHIFT                10
+#define ESPI_MAX_33_MHZ                      2
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gcr.h new file +313 -0
new file mode 100644
index 0000000000..14a4b2dbfb
@@ -0,0 +1,313 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GCR_H_
+#define _NPCM_GCR_H_
+
+#define NPCM_GCR_BA          0xF0800000
+/* On-Chip ARBEL NPCM8XX VERSIONS */
+
+#define ARBEL_Z1                     0x00A35850
+#define ARBEL_A1                     0x04a35850
+#define ARBEL_NPCM845                        0x00000000
+#define ARBEL_NPCM830                        0x00300395
+#define ARBEL_NPCM810                        0x00000220
+
+/* Function Lock Register 2 (FLOCKR2) */
+#define FLOCKR2_MMCRST               12
+#define FLOCKR2_MMCRSTLK             13
+#define FLOCKR2_G35DA2P              18
+
+/* Power-On Setting Register (PWRON) */
+#define PWRON_BSPA                   4         /* STRAP5 */
+#define PWRON_SECEN                  7         /* STRAP8 */
+
+/* Multiple Function Pin Select Register 1 (MFSEL1) */
+#define MFSEL1_SIRQSE               31
+#define MFSEL1_IOX1SEL              30
+#define MFSEL1_HSI2BSEL             29
+#define MFSEL1_HSI1BSEL             28
+#define MFSEL1_DVH1SEL              27
+#define MFSEL1_LPCSEL               26
+#define MFSEL1_PECIB                25
+#define MFSEL1_GSPISEL              24
+#define MFSEL1_SMISEL               22
+#define MFSEL1_CLKOSEL              21
+#define MFSEL1_DVOSEL               18
+#define MFSEL1_KBCICSEL             17
+#define MFSEL1_R2MDSEL              16
+#define MFSEL1_R2ERRSEL             15
+#define MFSEL1_RMII2SEL             14
+#define MFSEL1_R1MDSEL              13
+#define MFSEL1_R1ERRSEL             12
+#define MFSEL1_HSI2ASEL             11
+#define MFSEL1_HSI1ASEL             10
+#define MFSEL1_BSPSEL               9
+#define MFSEL1_SMB2SEL              8
+#define MFSEL1_SMB1SEL              7
+#define MFSEL1_SMB0SEL              6
+#define MFSEL1_HSI2CSEL             5
+#define MFSEL1_HSI1CSEL             4
+#define MFSEL1_S0CS1SEL             3
+#define MFSEL1_SMB5SEL              2
+#define MFSEL1_SMB4SEL              1
+#define MFSEL1_SMB3SEL              0
+
+/* Multiple Function Pin Select Register 3 (MFSEL3) */
+#define MFSEL3_DVODEDLY             27
+#define MFSEL3_DDRDVOSEL            26
+#define MFSEL3_MMCCDSEL             25
+#define MFSEL3_BU1SEL               24
+#define MFSEL3_I3C5SEL              22
+#define MFSEL3_WDO2SEL              20
+#define MFSEL3_WDO1SEL              19
+#define MFSEL3_IOXHSEL              18
+#define MFSEL3_PCIEPUSE             17
+#define MFSEL3_CLKRUNSEL            16
+#define MFSEL3_IOX2SEL              14
+#define MFSEL3_PSPISEL              13
+#define MFSEL3_MMC8SEL              11
+#define MFSEL3_MMCSEL               10
+#define MFSEL3_RMII1SEL             9
+#define MFSEL3_SMB15SEL             8
+#define MFSEL3_SMB14SEL             7
+#define MFSEL3_SMB13SEL             6
+#define MFSEL3_SMB12SEL             5
+#define MFSEL3_SPI1SEL              4
+#define MFSEL3_FIN1916SELB          3
+#define MFSEL3_SMB7SEL              2
+#define MFSEL3_SMB6SEL              1
+#define MFSEL3_SCISEL               0
+
+/* Multiple Function Pin Select Register 4 (MFSEL4) */
+#define MFSEL4_SMB11DDC             29
+#define MFSEL4_SXCS1SEL             28
+#define MFSEL4_SPXSEL               27
+#define MFSEL4_RG2SEL               24
+#define MFSEL4_RG2MSEL              23
+#define MFSEL4_BU2SELB              22
+#define MFSEL4_SG1MSEL              21
+#define MFSEL4_SP3QSEL              20
+#define MFSEL4_S3CS3SEL             19
+#define MFSEL4_S3CS2SEL             18
+#define MFSEL4_S3CS1SEL             17
+#define MFSEL4_SP3SEL               16
+#define MFSEL4_SP0QSEL              15
+#define MFSEL4_SMB11SEL             14
+#define MFSEL4_SMB10SEL             13
+#define MFSEL4_SMB9SEL              12
+#define MFSEL4_SMB8SEL              11
+#define MFSEL4_DBGTRSEL             10
+#define MFSEL4_CKRQSEL              9
+#define MFSEL4_ESPISEL              8
+#define MFSEL4_MMCRSEL              6
+#define MFSEL4_SD1PSEL              5
+#define MFSEL4_ROSEL                4
+#define MFSEL4_ESPIPMESEL           2
+#define MFSEL4_BSPASEL              1
+#define MFSEL4_JTAG2SEL             0
+
+/* Multiple Function Pin Select Register 5 (MFSEL5) */
+#define MFSEL5_R3OENSEL             14
+#define MFSEL5_RMII3SEL             11
+#define MFSEL5_R2OENSEL             10
+#define MFSEL5_R1OENSEL             9
+#define MFSEL5_NSPI1CS3SEL          5
+#define MFSEL5_NSPI1CS2SEL          4
+#define MFSEL5_SPI1D23SEL           3
+#define MFSEL5_NSPI1CS1SEL          0
+
+/* Multiple Function Pin Select Register 6 (MFSEL6) */
+#define MFSEL6_GPIO1836SEL          19
+#define MFSEL6_FM1SEL               17
+
+/* Multiple Function Pin Select Register 7 (MFSEL7) */
+#define MFSEL7_SMB15SELB            27
+#define MFSEL7_GPIO1889SEL          25
+
+/* USB PHY1 Control Register (USB1PHYCTL) */
+#define USB1PHYCTL_RS                                28
+/* USB PHY2 Control Register (USB2PHYCTL) */
+#define USB2PHYCTL_RS                                28
+/* USB PHY2 Control Register (USB3PHYCTL) */
+#define USB3PHYCTL_RS                                28
+
+/* Integration Control Register (INTCR) */
+#define  INTCR_DUDKSMOD             30
+#define  INTCR_DDC3I                29
+#define  INTCR_KVMSI                28
+#define  INTCR_DEHS                 27
+#define  INTCR_GGPCT2_0             24
+#define  INTCR_SGC2                 23
+#define  INTCR_DSNS_TRIG            21
+#define  INTCR_DAC_SNS              20
+#define  INTCR_SGC1                 19
+#define  INTCR_LDDRB                18
+#define  INTCR_GIRST                17
+#define  INTCR_DUDKSEN              16
+#define  INTCR_DACOFF               15
+#define  INTCR_DACSEL               14
+#define  INTCR_GFXINT               12
+#define  INTCR_DACOSOVR             10
+#define  INTCR_GFXIFDIS             8
+#define  INTCR_H2RQDIS              9
+#define  INTCR_H2DISPOFF            8
+#define  INTCR_GFXINT2              7
+#define  INTCR_VGAIOEN              6
+#define  INTCR_PSPIFEN              4
+#define  INTCR_HIFEN                3
+#define  INTCR_SMBFEN               2
+#define  INTCR_MFTFEN               1
+#define  INTCR_KCSRST_MODE          0
+
+/* Integration Control Register (INTCR2) */
+#define  INTCR2_WDC                   21
+
+/* Integration Control Register (INTCR3) */
+#define  INTCR3_USBLPBK2              31          /* USB loop-backed HOST 1/2 */
+#define  INTCR3_USBLPBK               24          /* USB loop-backed mode on/off */
+#define  INTCR3_USBPHY3SW             14          /* 2 bits */
+#define  INTCR3_USBPHY2SW             12          /* 2 bits */
+#define  INTCR3_USBPPS                6
+#define  INTCR3_UHUB_RWUD             5
+
+/* Integration Control Register (INTCR4) */
+#define  INTCR4_GMMAP1                24
+#define  INTCR4_GMMAP0                16
+#define  INTCR4_R3EN                  14
+#define  INTCR4_R2EN                  13
+#define  INTCR4_R1EN                  12
+#define  INTCR4_RGMIIREF              6
+
+/* I2C Segment Pin Select Register (I2CSEGSEL) */
+#define I2CSEGSEL_S0DECFG                    3
+#define I2CSEGSEL_S4DECFG                    17
+
+/* I2C Segment Control Register (I2CSEGCTL) */
+#define I2CSEGCTL_S0DEN                              20
+#define I2CSEGCTL_S0DWE                              21
+#define I2CSEGCTL_S4DEN                              24
+#define I2CSEGCTL_S4DWE                              25
+#define I2CSEGCTL_INIT_VAL           0x9333F000
+
+struct npcm_gcr {
+     unsigned int  pdid;
+     unsigned int  pwron;
+     unsigned int  swstrps;
+     unsigned int  rsvd1[2];
+     unsigned int  miscpe;
+     unsigned int  spldcnt;
+     unsigned int  rsvd2[1];
+     unsigned int  flockr2;
+     unsigned int  flockr3;
+     unsigned int  rsvd3[3];
+     unsigned int  a35_mode;
+     unsigned int  spswc;
+     unsigned int  intcr;
+     unsigned int  intsr;
+     unsigned int  obscr1;
+     unsigned int  obsdr1;
+     unsigned int  rsvd4[1];
+     unsigned int  hifcr;
+     unsigned int  rsvd5[3];
+     unsigned int  intcr2;
+     unsigned int  rsvd6[1];
+     unsigned int  srcnt;
+     unsigned int  ressr;
+     unsigned int  rlockr1;
+     unsigned int  flockr1;
+     unsigned int  dscnt;
+     unsigned int  mdlr;
+     unsigned int  scrpad_c;
+     /* scrpad_b: holds the active dram size (value set by bootblock) */
+     unsigned int  scrpad_b;
+     unsigned int  rsvd7[4];
+     unsigned int  daclvlr;
+     unsigned int  intcr3;
+     unsigned int  pcirctl;
+     unsigned int  rsvd8[2];
+     unsigned int  vsintr;
+     unsigned int  rsvd9[1];
+     unsigned int  sd2sur1;
+     unsigned int  sd2sur2;
+     unsigned int  sd2irv3;
+     unsigned int  intcr4;
+     unsigned int  obscr2;
+     unsigned int  obsdr2;
+     unsigned int  rsvd10[5];
+     unsigned int  i2csegsel;
+     unsigned int  i2csegctl;
+     unsigned int  vsrcr;
+     unsigned int  mlockr;
+     unsigned int  rsvd11[8];
+     unsigned int  etsr;
+     unsigned int  dft1r;
+     unsigned int  dft2r;
+     unsigned int  dft3r;
+     unsigned int  edffsr;
+     unsigned int  rsvd12[1];
+     unsigned int  intcrpce3;
+     unsigned int  intcrpce2;
+     unsigned int  intcrpce0;
+     unsigned int  intcrpce1;
+     unsigned int  dactest;
+     unsigned int  scrpad;
+     unsigned int  usb1phyctl;
+     unsigned int  usb2phyctl;
+     unsigned int  usb3phyctl;
+     unsigned int  intsr2;
+     unsigned int  intcrpce2b;
+     unsigned int  intcrpce0b;
+     unsigned int  intcrpce1b;
+     unsigned int  intcrpce3b;
+     unsigned int  rsvd13[4];
+     unsigned int  intcrpce2c;
+     unsigned int  intcrpce0c;
+     unsigned int  intcrpce1c;
+     unsigned int  intcrpce3c;
+     unsigned int  rsvd14[40];
+     unsigned int  sd2irv4;
+     unsigned int  sd2irv5;
+     unsigned int  sd2irv6;
+     unsigned int  sd2irv7;
+     unsigned int  sd2irv8;
+     unsigned int  sd2irv9;
+     unsigned int  sd2irv10;
+     unsigned int  sd2irv11;
+     unsigned int  rsvd15[8];
+     unsigned int  mfsel1;
+     unsigned int  mfsel2;
+     unsigned int  mfsel3;
+     unsigned int  mfsel4;
+     unsigned int  mfsel5;
+     unsigned int  mfsel6;
+     unsigned int  mfsel7;
+     unsigned int  rsvd16[1];
+     unsigned int  mfsel_lk1;
+     unsigned int  mfsel_lk2;
+     unsigned int  mfsel_lk3;
+     unsigned int  mfsel_lk4;
+     unsigned int  mfsel_lk5;
+     unsigned int  mfsel_lk6;
+     unsigned int  mfsel_lk7;
+     unsigned int  rsvd17[1];
+     unsigned int  mfsel_set1;
+     unsigned int  mfsel_set2;
+     unsigned int  mfsel_set3;
+     unsigned int  mfsel_set4;
+     unsigned int  mfsel_set5;
+     unsigned int  mfsel_set6;
+     unsigned int  mfsel_set7;
+     unsigned int  rsvd18[1];
+     unsigned int  mfsel_clr1;
+     unsigned int  mfsel_clr2;
+     unsigned int  mfsel_clr3;
+     unsigned int  mfsel_clr4;
+     unsigned int  mfsel_clr5;
+     unsigned int  mfsel_clr6;
+     unsigned int  mfsel_clr7;
+     };
+
+#endif
arch/arm/include/asm/arch-npcm8xx/gpio.h new file +11 -0
new file mode 100644
index 0000000000..234a1d3de9
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_GPIO_H_
+#define _NPCM_GPIO_H_
+
+#define NPCM_GPIO_BA         0xF0010000
+
+#endif
arch/arm/include/asm/arch-npcm8xx/rst.h new file +32 -0
new file mode 100644
index 0000000000..ffaff50fe2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_RST_H_
+#define _NPCM_RST_H_
+
+enum reset_type {
+     PORST_TYPE    = 0x01,
+     CORST_TYPE    = 0x02,
+     WD0RST_TYPE   = 0x03,
+     SWR1ST_TYPE   = 0x04,
+     SWR2ST_TYPE   = 0x05,
+     SWR3ST_TYPE   = 0x06,
+     SWR4ST_TYPE   = 0x07,
+     WD1RST_TYPE   = 0x08,
+     WD2RST_TYPE   = 0x09,
+     UNKNOWN_TYPE  = 0x10,
+};
+
+#define PORST 0x80000000
+#define CORST 0x40000000
+#define WD0RST 0x20000000
+#define SWR1ST 0x10000000
+#define SWR2ST 0x08000000
+#define SWR3ST 0x04000000
+#define SWR4ST 0x02000000
+#define WD1RST 0x01000000
+#define WD2RST 0x00800000
+#define RESSR_MASK 0xff800000
+
+enum reset_type npcm8xx_reset_reason(void);
+
+#endif
arch/arm/mach-nuvoton/Kconfig new file +24 -0
new file mode 100644
index 0000000000..e014dd4b79
@@ -0,0 +1,24 @@
+if ARCH_NPCM
+
+config SYS_ARCH
+     default "arm"
+
+config SYS_TEXT_BASE
+     default 0x8000
+
+choice
+     prompt "Nuvoton SoC select"
+     default ARCH_NPCM8XX
+
+config ARCH_NPCM8XX
+     bool "Support Nuvoton NPCM8xx SoC"
+     select ARM64
+     help
+       General support for NPCM8xx BMC (Arbel).
+       Nuvoton NPCM8xx BMC is based on the Cortex A35.
+
+endchoice
+
+source "arch/arm/mach-nuvoton/npcm8xx/Kconfig"
+
+endif
arch/arm/mach-nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..e75689a1a0
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += npcm8xx/
arch/arm/mach-nuvoton/npcm8xx/Kconfig new file +18 -0
new file mode 100644
index 0000000000..478a046ad5
@@ -0,0 +1,18 @@
+if ARCH_NPCM8XX
+
+config SYS_CPU
+     default "armv8"
+
+config SYS_SOC
+     default "npcm8xx"
+
+config TARGET_ARBEL_EVB
+     bool "Arbel-EVB"
+     help
+       ARBEL_EVB is Nuvoton evaluation board for NPCM845 SoC,
+       supports general functions of Basebase Management Controller
+       (BMC).
+
+source "board/nuvoton/arbel/Kconfig"
+
+endif
arch/arm/mach-nuvoton/npcm8xx/Makefile new file +1 -0
new file mode 100644
index 0000000000..c62a4aa20a
@@ -0,0 +1 @@
+obj-y += reset.o cpu.o
arch/arm/mach-nuvoton/npcm8xx/cpu.c new file +170 -0
new file mode 100644
index 0000000000..8a7315d535
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <cpu_func.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/arch/espi.h>
+#include <asm/armv8/mmu.h>
+#include <asm/system.h>
+#include <asm/global_data.h>
+
+/* System Counter */
+struct sctr_regs {
+     u32 cntcr;
+     u32 cntsr;
+     u32 cntcv1;
+     u32 cntcv2;
+     u32 resv1[4];
+     u32 cntfid0;
+     u32 cntfid1;
+     u32 cntfid2;
+     u32 resv2[1001];
+     u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE              BIT(0)
+#define SC_CNTCR_HDBG                BIT(1)
+#define SC_CNTCR_FREQ0               BIT(8)
+#define SC_CNTCR_FREQ1               BIT(9)
+
+#define SYSCNT_CTRL_BASE_ADDR   0xF07FC000
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int print_cpuinfo(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     unsigned int id = 0;
+     unsigned long mpidr_val = 0;
+     unsigned int mdlr = 0;
+
+     asm volatile("mrs %0, mpidr_el1" : "=r" (mpidr_val));
+
+     mdlr = readl(&gcr->mdlr);
+
+     printf("CPU-%d: ", (unsigned int)(mpidr_val & 0x3));
+
+     switch (mdlr) {
+     case ARBEL_NPCM845:
+             printf("NPCM845 ");
+             break;
+     case ARBEL_NPCM830:
+             printf("NPCM830 ");
+             break;
+     case ARBEL_NPCM810:
+             printf("NPCM810 ");
+             break;
+     default:
+             printf("NPCM8XX ");
+             break;
+     }
+
+     id = readl(&gcr->pdid);
+     switch (id) {
+     case ARBEL_Z1:
+             printf("Z1 @ ");
+             break;
+     case ARBEL_A1:
+             printf("A1 @ ");
+             break;
+     default:
+             printf("Unknown\n");
+             break;
+     }
+
+     return 0;
+}
+
+static void npcm_sysintf_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     u32 espi_ch_supp, val;
+
+     espi_ch_supp = ofnode_conf_read_int("espi-channel-support", 0);
+
+     if (espi_ch_supp) {
+             /* Use eSPI function and initialize ESPICFG */
+             u32 hindp = 0x00011110 | espi_ch_supp;
+
+             writel((readl(&gcr->mfsel4) | (1 << MFSEL4_ESPISEL)), &gcr->mfsel4);
+             writel(hindp, NPCM_ESPI_BA + ESPIHINDP);
+             val = readl(NPCM_ESPI_BA + ESPICFG);
+             val |= ESPI_IO_MODE_SINGLE_DUAL_QUAD << ESPICFG_IOMODE_SHIFT;
+             val |= ESPI_MAX_33_MHZ << ESPICFG_MAXFREQ_SHIFT;
+             val |= ((espi_ch_supp & ESPICFG_CHNSUPP_MASK) << ESPICFG_CHNSUPP_SHFT);
+             writel(val, NPCM_ESPI_BA + ESPICFG);
+     } else {
+             /* Use LPC function */
+             writel((readl(&gcr->mfsel1) | (1 << MFSEL1_LPCSEL)), &gcr->mfsel1);
+     }
+}
+
+int arch_cpu_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     if (!IS_ENABLED(CONFIG_SYS_DCACHE_OFF)) {
+             /* enable cache to speed up system running */
+             if (get_sctlr() & CR_M)
+                     return 0;
+
+             icache_enable();
+             __asm_invalidate_dcache_all();
+             __asm_invalidate_tlb_all();
+             set_sctlr(get_sctlr() | CR_C);
+     }
+
+     /* Power voltage select setup */
+     setbits_le32(&gcr->vsrcr, BIT(30));
+
+     npcm_sysintf_init();
+
+     return 0;
+}
+
+static struct mm_region npcm_mem_map[1 + CONFIG_NR_DRAM_BANKS + 1] = {
+     {
+             /* DRAM */
+             .phys = 0x0UL,
+             .virt = 0x0UL,
+             .size = 0x80000000UL,
+             .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+                      PTE_BLOCK_INNER_SHARE
+     },
+     {
+             .phys = 0x80000000UL,
+             .virt = 0x80000000UL,
+             .size = 0x80000000UL,
+             .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                      PTE_BLOCK_NON_SHARE |
+                      PTE_BLOCK_PXN | PTE_BLOCK_UXN
+     },
+     {
+             /* List terminator */
+             0,
+     }
+};
+
+struct mm_region *mem_map = npcm_mem_map;
+
+int timer_init(void)
+{
+     struct sctr_regs *sctr = (struct sctr_regs *)SYSCNT_CTRL_BASE_ADDR;
+     unsigned int cntfrq_el0;
+
+     __asm__ __volatile__("mrs %0, CNTFRQ_EL0\n\t" : "=r" (cntfrq_el0) : : "memory");
+     writel(cntfrq_el0, &sctr->cntfid0);
+
+     clrsetbits_le32(&sctr->cntcr, SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1,
+                     SC_CNTCR_ENABLE | SC_CNTCR_HDBG);
+
+     gd->arch.tbl = 0;
+     gd->arch.tbu = 0;
+
+     return 0;
+}
arch/arm/mach-nuvoton/npcm8xx/reset.c new file +51 -0
new file mode 100644
index 0000000000..7fbed7ba76
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/rst.h>
+#include <asm/arch/gcr.h>
+
+void reset_cpu(void)
+{
+     /* Watcdog reset - WTCR register set  WTE-BIT7 WTRE-BIT1 WTR-BIT0 */
+     writel(0x83, 0xf000801c);
+
+     while (1)
+             ;
+}
+
+void reset_misc(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     /* clear WDC */
+     writel(readl(&gcr->intcr2) & ~(1 << INTCR2_WDC), &gcr->intcr2);
+}
+
+enum reset_type npcm8xx_reset_reason(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+     enum reset_type type = UNKNOWN_TYPE;
+     u32 value = readl(&gcr->ressr);
+
+     if (value == 0)
+             value = ~readl(&gcr->intcr2);
+
+     value &= RESSR_MASK;
+
+     if (value & CORST)
+             type = CORST;
+     if (value & WD0RST)
+             type = WD0RST;
+     if (value & WD1RST)
+             type = WD1RST;
+     if (value & WD2RST)
+             type = WD2RST;
+     if (value & PORST)
+             type = PORST;
+
+     return type;
+}
board/nuvoton/arbel/Kconfig new file +18 -0
new file mode 100644
index 0000000000..4a03ea1abf
@@ -0,0 +1,18 @@
+if TARGET_ARBEL_EVB
+
+config SYS_BOARD
+     default "arbel"
+
+config SYS_VENDOR
+     default "nuvoton"
+
+config SYS_CONFIG_NAME
+     default "arbel"
+
+config SYS_MEM_TOP_HIDE
+     hex "Reserved TOP memory"
+     default 0xB000000
+     help
+       Reserve memory for ECC/GFX/VCD/ECE.
+
+endif
board/nuvoton/arbel/Makefile new file +1 -0
new file mode 100644
index 0000000000..f9ad1dea34
@@ -0,0 +1 @@
+obj-y        += arbel.o
board/nuvoton/arbel/arbel.c new file +33 -0
new file mode 100644
index 0000000000..86cef98c5f
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/mach-types.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+     gd->bd->bi_arch_number = MACH_TYPE_NPCMX50;
+     gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100UL);
+
+     return 0;
+}
+
+int dram_init(void)
+{
+     struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+     /*
+      * get dram active size value from bootblock.
+      * Value sent using scrpad_02 register.
+      */
+     gd->ram_size = readl(&gcr->scrpad_b);
+
+     return 0;
+}
include/configs/arbel.h new file +54 -0
new file mode 100644
index 0000000000..2cb658c3e6
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef __CONFIG_ARBEL_H
+#define __CONFIG_ARBEL_H
+
+#define CONFIG_GICV2
+#define GICD_BASE                    (0xDFFF9000)
+#define GICC_BASE                    (0xDFFFA000)
+
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS   1
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG
+#define CONFIG_SYS_MAXARGS              32
+#define CONFIG_SYS_CBSIZE               256
+#define CONFIG_SYS_PBSIZE               (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_PROMPT_HUSH_PS2       "> "
+#define CONFIG_SYS_BOOTM_LEN            (20 << 20)
+#define CONFIG_SYS_BOOTMAPSZ            (20 << 20)
+#define CONFIG_SYS_SDRAM_BASE           0x0
+#define CONFIG_SYS_INIT_SP_ADDR         (0x00008000 - GENERATED_GBL_DATA_SIZE)
+#define CONFIG_SYS_MONITOR_LEN          (256 << 10)
+#define CONFIG_SYS_MONITOR_BASE              CONFIG_SYS_TEXT_BASE
+#define CONFIG_BAUDRATE                 115200
+#define CONFIG_SYS_HZ                   1000
+#define CONFIG_BITBANGMII_MULTI
+
+/* Default environemnt variables */
+#define CONFIG_BOOTCOMMAND "run common_bootargs; run romboot"
+#define CONFIG_EXTRA_ENV_SETTINGS   "uimage_flash_addr=80200000\0"   \
+             "stdin=serial\0"   \
+             "stdout=serial\0"   \
+             "stderr=serial\0"    \
+             "ethact=gmac1\0"   \
+             "autostart=no\0"   \
+             "ethaddr=00:00:F7:A0:00:FC\0"    \
+             "eth1addr=00:00:F7:A0:00:FD\0"   \
+             "eth2addr=00:00:F7:A0:00:FE\0"    \
+             "eth3addr=00:00:F7:A0:00:FF\0"    \
+             "gatewayip=192.168.0.17\0"    \
+             "serverip=192.168.0.17\0"    \
+             "ipaddr=192.168.0.15\0"    \
+             "romboot=echo Booting Kernel from flash at 0x${uimage_flash_addr}; " \
+             "echo Using bootargs: ${bootargs};bootm ${uimage_flash_addr}\0" \
+             "earlycon=uart8250,mmio32,0xf0000000\0" \
+             "console=ttyS0,115200n8\0" \
+             "common_bootargs=setenv bootargs earlycon=${earlycon} root=/dev/ram " \
+             "console=${console} ramdisk_size=48000\0" \
+             "\0"
+
+#endif
#12 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

In reply to Stanley Chu
Quoted 3 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

I see there's a number of outstanding questions to this first part of the port. Can you please address them? Furthermore, the defconfig and dts patches should be part of this first patch and the dts needs to be in linux-next at least, if not a full linux kernel release. Thanks and sorry for the delay here.

Signature · 1 line
Tom
#13 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Hi Tom,
We need time to prepare linux dts, can I send the rest of the drivers first or need to wait until the linux dts is submitted? Because I want to remove some unused nodes/properties away from linux dts to reduce dtb size, can we use different dts for uboot? Thanks a lot for your comments.

--
Stanley

Quoted 15 lines · Tom Rini
Quoted 3 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

I see there's a number of outstanding questions to this first part of the port. Can you please address them? Furthermore, the defconfig and dts patches should be part of this first patch and the dts needs to be in linux-next at least, if not a full linux kernel release. Thanks and sorry for the delay here.

--
Tom

#14 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Quoted 6 lines · Stanley Chu

Hi Tom,
We need time to prepare linux dts, can I send the rest of the drivers first or need to wait until the linux dts is submitted? Because I want to remove some unused nodes/properties away from linux dts to reduce dtb size, can we use different dts for uboot? Thanks a lot for your comments.

The dts should be the same, except for any U-Boot specific bindings that we're still working to upstream, between Linux and U-Boot.

Quoted 20 lines

--
Stanley

Quoted 15 lines · Tom Rini
Quoted 3 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

I see there's a number of outstanding questions to this first part of the port. Can you please address them? Furthermore, the defconfig and dts patches should be part of this first patch and the dts needs to be in linux-next at least, if not a full linux kernel release. Thanks and sorry for the delay here.

--
Tom

Signature · 1 line
Tom
#15 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

In reply to Stanley Chu

Hi Stanley,

Quoted 7 lines

Il giorno 11 mar 2022, alle ore 03:13, Stanley Chu <[email protected]> ha scritto:

Hi Tom,
We need time to prepare linux dts, can I send the rest of the drivers first or need to wait until the linux dts is submitted? Because I want to remove some unused nodes/properties away from linux dts to reduce dtb size, can we use different dts for uboot?

You can add a specific -uboot.dtsi file where you tag every node to be or not to be part of final uboot .dtb This way the original .dts file will be synced with Linux, except the -uboot.dtsi inclusion. Take a look at upstreamed .dts files and look for uboot.dtsi suffix files.

Best regards
—-
Giulio Benetti
Benetti Engineering sas

Quoted 21 lines

Thanks a lot for your comments.

--
Stanley

Quoted 16 lines · Tom Rini
Quoted 6 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

I see there's a number of outstanding questions to this first part of the port. Can you please address them? Furthermore, the defconfig and dts patches should be part of this first patch and the dts needs to be in linux-next at least, if not a full linux kernel release. Thanks and sorry for the delay here.

--
Tom

#16 lore raw

Re: [PATCH v1 1/9] arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Quoted 11 lines · Giulio Benetti

Hi Stanley,

Quoted 7 lines

Il giorno 11 mar 2022, alle ore 03:13, Stanley Chu <[email protected]> ha scritto:

Hi Tom,
We need time to prepare linux dts, can I send the rest of the drivers first or need to wait until the linux dts is submitted? Because I want to remove some unused nodes/properties away from linux dts to reduce dtb size, can we use different dts for uboot?

Quoted 3 lines

You can add a specific -uboot.dtsi file where you tag every node to be or not to be part of final uboot .dtb This way the original .dts file will be synced with Linux, except the -uboot.dtsi inclusion. Take a look at upstreamed .dts files and look for uboot.dtsi suffix files.

Hi Giulio,
Thanks a lot.
It will be done in v2.

--
Stanley

Quoted 28 lines

Best regards
—-
Giulio Benetti
Benetti Engineering sas

Quoted 21 lines

Thanks a lot for your comments.

--
Stanley

Quoted 16 lines · Tom Rini
Quoted 6 lines · Stanley Chu

Add basic support for the Nuvoton NPCM845 BMC.

I see there's a number of outstanding questions to this first part of the port. Can you please address them? Furthermore, the defconfig and dts patches should be part of this first patch and the dts needs to be in linux-next at least, if not a full linux kernel release. Thanks and sorry for the delay here.

--
Tom

#17 lore raw

PATCH 2/9 clk: nuvoton: Add support for NPCM845

In reply to Stanley Chu

Add clock controller driver for NPCM845

---
 drivers/clk/Makefile                      |   1 +
 drivers/clk/nuvoton/Makefile              |   1 +
 drivers/clk/nuvoton/clk_npcm8xx.c         | 213 ++++++++++++++++++++++
 include/dt-bindings/clock/npcm845-clock.h |  17 ++
 4 files changed, 232 insertions(+)
 create mode 100644 drivers/clk/nuvoton/Makefile
 create mode 100644 drivers/clk/nuvoton/clk_npcm8xx.c
 create mode 100644 include/dt-bindings/clock/npcm845-clock.h
drivers/clk/Makefile +1 -0
index 711ae5bc29..a3b64b73c2 100644
@@ -53,3 +53,4 @@ obj-$(CONFIG_STM32H7) += clk_stm32h7.o
 obj-$(CONFIG_CLK_VERSAL) += clk_versal.o
 obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
 obj-$(CONFIG_CLK_VERSACLOCK) += clk_versaclock.o
+obj-$(CONFIG_ARCH_NPCM) += nuvoton/
drivers/clk/nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..998e5329bb
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += clk_npcm8xx.o
drivers/clk/nuvoton/clk_npcm8xx.c new file +213 -0

213 lines not on this page · raw message

include/dt-bindings/clock/npcm845-clock.h new file +17 -0
new file mode 100644
index 0000000000..fca10d39c8
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _DT_BINDINGS_NPCM845_CLOCK_H_
+#define _DT_BINDINGS_NPCM845_CLOCK_H_
+
+#define CLK_TIMER	    0
+#define CLK_UART	    1
+#define CLK_SD		    2
+#define CLK_EMMC	    3
+#define CLK_APB1	    4
+#define CLK_APB2	    5
+#define CLK_APB3	    6
+#define CLK_APB4	    7
+#define CLK_APB5	    8
+#define CLK_AHB		    9
+
+#endif
Signature · 1 line
2.17.1
#18 lore raw

Re: [PATCH v1 2/9] clk: nuvoton: Add support for NPCM845

Quoted 18 lines · Stanley Chu

Add clock controller driver for NPCM845

---
  drivers/clk/Makefile                      |   1 +
  drivers/clk/nuvoton/Makefile              |   1 +
  drivers/clk/nuvoton/clk_npcm8xx.c         | 213 ++++++++++++++++++++++
  include/dt-bindings/clock/npcm845-clock.h |  17 ++
  4 files changed, 232 insertions(+)

create mode 100644 drivers/clk/nuvoton/Makefile create mode 100644 drivers/clk/nuvoton/clk_npcm8xx.c create mode 100644 include/dt-bindings/clock/npcm845-clock.h

drivers/clk/Makefile +0 -0
index 711ae5bc29..a3b64b73c2 100644

drivers/clk/Makefile obj-$(CONFIG_STM32H7) += clk_stm32h7.o · line 56

Quoted 4 lines
drivers/clk/Makefile +1 -0
@@ -53,3 +53,4 @@ obj-$(CONFIG_STM32H7) += clk_stm32h7.o
  obj-$(CONFIG_CLK_VERSAL) += clk_versal.o
  obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
  obj-$(CONFIG_CLK_VERSACLOCK) += clk_versaclock.o
+obj-$(CONFIG_ARCH_NPCM) += nuvoton/

Please keep this in alphabetical order (I know the file isn't perfect).

Quoted 13 lines
drivers/clk/nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..998e5329bb
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += clk_npcm8xx.o
drivers/clk/nuvoton/clk_npcm8xx.c new file +0 -0
new file mode 100644
index 0000000000..c547c47e82

drivers/clk/nuvoton/clk_npcm8xx.c line 10

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
@@ -0,0 +1,213 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <clk-uclass.h>
+#include <asm/types.h>
+#include <asm/arch/clock.h>

Please add this include file in this patch.

drivers/clk/nuvoton/clk_npcm8xx.c line 13

Quoted 3 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +3 -0
+#include <asm/io.h>
+#include <linux/delay.h>
+#include <dt-bindings/clock/npcm845-clock.h>

Please order these correctly. See https://www.denx.de/wiki/U-Boot/CodingStyle#Include_files

drivers/clk/nuvoton/clk_npcm8xx.c line 19

Quoted 6 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +6 -0
+
+struct npcm_clk_priv {
+	struct clk_ctl *regs;
+};
+
+enum regss {

perhaps "pll_id" or similar?

drivers/clk/nuvoton/clk_npcm8xx.c line 29

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+	PLL_0,
+	PLL_1,
+	PLL_2,
+	PLL_CLKREF,
+};
+
+static u32 clk_get_pll_freq(struct clk_ctl *regs, enum regss pll)
+{
+	u32 pllval;
+	u32 fin = EXT_CLOCK_FREQUENCY_KHZ; /* 25KHz */

Please get this from the device tree.

drivers/clk/nuvoton/clk_npcm8xx.c line 42

Quoted 13 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +13 -0
+	u32 fout, nr, nf, no;
+
+	switch (pll) {
+	case PLL_0:
+		pllval = readl(&regs->pllcon0);
+		break;
+	case PLL_1:
+		pllval = readl(&regs->pllcon1);
+		break;
+	case PLL_2:
+		pllval = readl(&regs->pllcon2);
+		break;
+	case PLL_CLKREF:

This is not used.

drivers/clk/nuvoton/clk_npcm8xx.c line 48

Quoted 6 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +6 -0
+	default:
+		return 0;
+	}
+
+	/* PLL Input Clock Divider */
+	nr = (pllval >> PLLCON_INDV) & 0x1f;

With

	#define PLLCON_INDV GENMASK(6, 0)

you can do

	nr = FIELD_GET(PLLCON_INDV, pllval);

This applies to all your other register accesses.

drivers/clk/nuvoton/clk_npcm8xx.c line 55

Quoted 7 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +7 -0
+	/* PLL VCO Output Clock Feedback Divider */
+	nf = (pllval >> PLLCON_FBDV) & 0xfff;
+	/* PLL Output Clock Divider 1 */
+	no = ((pllval >> PLLCON_OTDV1) & 0x7) *
+		((pllval >> PLLCON_OTDV2) & 0x7);
+
+	fout = ((10 * fin * nf) / (no * nr));

Can this overflow? Can you add a comment about that?

drivers/clk/nuvoton/clk_npcm8xx.c line 57

Quoted 2 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +2 -0
+
+	return fout * 100;

Where do these 10 and 100 factors come from? Please combine them.

Quoted 4 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +4 -0
+}
+
+static u32 npcm_mmc_set_rate(struct clk_ctl *regs, ulong rate)
+{

drivers/clk/nuvoton/clk_npcm8xx.c line 71

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+	u32 pll0_freq, div, sdhci_clk;
+
+	/* To acquire PLL0 frequency. */
+	pll0_freq = clk_get_pll_freq(regs, PLL_0);
+
+	/* Calculate rounded up div to produce closest to
+	 * target output clock
+	 */
+	div = (pll0_freq % rate == 0) ? (pll0_freq / rate) :
+					(pll0_freq / rate) + 1;

div = DIV_ROUND_UP(pll0_freq, rate);

drivers/clk/nuvoton/clk_npcm8xx.c line 74

Quoted 3 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +3 -0
+
+	writel((readl(&regs->clkdiv1) & ~(0x1f << CLKDIV1_MMCCKDIV))
+	       | (div - 1) << CLKDIV1_MMCCKDIV, &regs->clkdiv1);

example of FIELD_PREP:

	clkdiv1 = readl(&regs->clkdiv1);
	clkdiv1 &= ~CLKDIV1_MMCCKDIV;
	clkdiv1 |= FIELD_PREP(CLKDIV1_MMCCKDIV, div - 1);
	writel(clkdiv1, &regs->clkdiv1);

You don't have to break out each line, but please apply this to your register writes.

Quoted 26 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +26 -0
+
+	/* Wait to the div to stabilize */
+	udelay(100);
+
+	/* Select PLL0 as source */
+	writel((readl(&regs->clksel) & ~(0x3 << CLKSEL_SDCKSEL))
+		| (CLKSEL_SDCKSEL_PLL0 << CLKSEL_SDCKSEL),
+		&regs->clksel);
+
+	sdhci_clk = pll0_freq / div;
+
+	return sdhci_clk;
+}
+
+static u32 npcm_uart_set_rate(struct clk_ctl *regs, ulong rate)
+{
+	u32 src_freq, div;
+
+	src_freq = clk_get_pll_freq(regs, PLL_2) / 2;
+	div = (src_freq % rate == 0) ? (src_freq / rate) :
+					(src_freq / rate) + 1;
+	writel((readl(&regs->clkdiv1) & ~(0x1f << CLKDIV1_UARTDIV))
+		| (div - 1) << CLKDIV1_UARTDIV, &regs->clkdiv1);
+	writel((readl(&regs->clksel) & ~(3 << CLKSEL_UARTCKSEL))
+		| (CLKSEL_UARTCKSEL_PLL2 << CLKSEL_UARTCKSEL),
+		&regs->clksel);

drivers/clk/nuvoton/clk_npcm8xx.c line 110

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+
+	return (src_freq / div);
+}
+
+static ulong npcm_get_cpu_freq(struct clk_ctl *regs)
+{
+	ulong fout = 0;
+	u32 clksel = readl(&regs->clksel) & (0x3 << CLKSEL_CPUCKSEL);
+
+	if (clksel == CLKSEL_CPUCKSEL_PLL0)

Use a switch here.

Quoted 4 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +4 -0
+		fout = (ulong)clk_get_pll_freq(regs, PLL_0);
+	else if (clksel == CLKSEL_CPUCKSEL_PLL1)
+		fout = (ulong)clk_get_pll_freq(regs, PLL_1);
+	else if (clksel == CLKSEL_CPUCKSEL_CLKREF)

drivers/clk/nuvoton/clk_npcm8xx.c line 124

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+		fout = EXT_CLOCK_FREQUENCY_MHZ; /* FOUT is specified in MHz */
+	else
+		fout = EXT_CLOCK_FREQUENCY_MHZ; /* FOUT is specified in MHz */
+
+	return fout;
+}
+
+static u32 npcm_get_apb_divisor(struct clk_ctl *regs, u32 apb)
+{
+	u32 apb_divisor = 2;

Just inline this. E.g.

	return 2 << ...;
Quoted 8 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +8 -0
+
+	/* AHBn div */
+	apb_divisor = apb_divisor * (1 << ((readl(&regs->clkdiv1)
+						>> CLKDIV1_CLK4DIV) & 0x3));
+
+	switch (apb) {
+	case APB2: /* APB divisor */
+		apb_divisor = apb_divisor *

drivers/clk/nuvoton/clk_npcm8xx.c line 142

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+				(1 << ((readl(&regs->clkdiv2)
+					>> CLKDIV2_APB2CKDIV) & 0x3));
+		break;
+	case APB5: /* APB divisor */
+		apb_divisor = apb_divisor *
+				(1 << ((readl(&regs->clkdiv2)
+					>> CLKDIV2_APB5CKDIV) & 0x3));
+		break;
+	default:
+		apb_divisor = 0xFFFFFFFF;

Isn't getting here a bug?

Quoted 7 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +7 -0
+		break;
+	}
+
+	return apb_divisor;
+}
+
+static ulong npcm_clk_get_rate(struct clk *clk)

drivers/clk/nuvoton/clk_npcm8xx.c line 159

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+{
+	struct npcm_clk_priv *priv = dev_get_priv(clk->dev);
+
+	switch (clk->id) {
+	case CLK_APB2:
+		return npcm_get_cpu_freq(priv->regs) /
+			npcm_get_apb_divisor(priv->regs, APB2);
+	case CLK_APB5:
+		return npcm_get_cpu_freq(priv->regs) /
+			npcm_get_apb_divisor(priv->regs, APB5);

I think you can use a more modular approach here:

	struct clk parent;
	
	switch (clk->id) {
	case CLK_APB2:
		parent.id = CLK_AHB;
		ret = clk_request(clk->dev, &parent);
		if (ret)
			return ret;
		
		fin = clk_get_rate(&parent);
		if (IS_ERR_VALUE(fin))
			return fin;

		return fin / FIELD_GET(CLKDIV2_APB2CKDIV, readl(&regs->clkdiv2));
	}

And of course you can go further and create some arrays to hold those parameters if you like.

This switch statement should also return -ENOSYS in the default case.

Quoted 7 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +7 -0
+	}
+
+	return 0;
+}
+
+static ulong npcm_clk_set_rate(struct clk *clk, ulong rate)
+{

drivers/clk/nuvoton/clk_npcm8xx.c line 176

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+	struct npcm_clk_priv *priv = dev_get_priv(clk->dev);
+
+	switch (clk->id) {
+	case CLK_EMMC:
+		return npcm_mmc_set_rate(priv->regs, rate);
+
+	case CLK_UART:
+		return npcm_uart_set_rate(priv->regs, rate);
+	default:
+		return -ENOENT;

-ENOSYS

Quoted 5 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +5 -0
+	}
+
+	return 0;
+}
+

drivers/clk/nuvoton/clk_npcm8xx.c line 191

Quoted 10 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +10 -0
+static int npcm_clk_probe(struct udevice *dev)
+{
+	struct npcm_clk_priv *priv = dev_get_priv(dev);
+	void *base;
+
+	base = dev_read_addr_ptr(dev);
+	if (!base)
+		return -ENOENT;
+
+	priv->regs = (struct clk_ctl *)base;

You can directly assign to regs. And there is no need to cast here, since base is a void pointer.

drivers/clk/nuvoton/clk_npcm8xx.c line 198

Quoted 7 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +7 -0
+
+	return 0;
+}
+
+static struct clk_ops npcm_clk_ops = {
+	.get_rate = npcm_clk_get_rate,
+	.set_rate = npcm_clk_set_rate,

Please add a .request callback which enforces the max clock id.

--Sean

Quoted 39 lines
drivers/clk/nuvoton/clk_npcm8xx.c new file +15 -0
+};
+
+static const struct udevice_id npcm_clk_ids[] = {
+	{ .compatible = "nuvoton,npcm845-clock" },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_npcm) = {
+	.name           = "clk_npcm",
+	.id             = UCLASS_CLK,
+	.of_match       = npcm_clk_ids,
+	.ops            = &npcm_clk_ops,
+	.priv_auto	= sizeof(struct npcm_clk_priv),
+	.probe          = npcm_clk_probe,
+};
include/dt-bindings/clock/npcm845-clock.h new file +17 -0
new file mode 100644
index 0000000000..fca10d39c8
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _DT_BINDINGS_NPCM845_CLOCK_H_
+#define _DT_BINDINGS_NPCM845_CLOCK_H_
+
+#define CLK_TIMER	    0
+#define CLK_UART	    1
+#define CLK_SD		    2
+#define CLK_EMMC	    3
+#define CLK_APB1	    4
+#define CLK_APB2	    5
+#define CLK_APB3	    6
+#define CLK_APB4	    7
+#define CLK_APB5	    8
+#define CLK_AHB		    9
+
+#endif
#19 lore raw

Re: [PATCH v1 2/9] clk: nuvoton: Add support for NPCM845

In reply to Stanley Chu
Quoted 12 lines · Stanley Chu

Add clock controller driver for NPCM845

---
 drivers/clk/Makefile                      |   1 +
 drivers/clk/nuvoton/Makefile              |   1 +
 drivers/clk/nuvoton/clk_npcm8xx.c         | 213 ++++++++++++++++++++++
 include/dt-bindings/clock/npcm845-clock.h |  17 ++
 4 files changed, 232 insertions(+)
 create mode 100644 drivers/clk/nuvoton/Makefile
 create mode 100644 drivers/clk/nuvoton/clk_npcm8xx.c
 create mode 100644 include/dt-bindings/clock/npcm845-clock.h

Following up here, Sean had comments and while I've seen follow-up timer and serial patches, I haven't seen a follow-up clk patch.

Signature · 1 line
Tom
author
#20 lore raw

Re: [PATCH v1 2/9] clk: nuvoton: Add support for NPCM845

Hi Tom,
Thanks for the reminder. I made a big change on clk driver and will submit the new patch later.

--
Stanley

Tom Rini <[email protected]> 於 2022年2月17日 週四 上午12:25 寫道:

Quoted 21 lines · Stanley Chu
Quoted 4 lines

Add clock controller driver for NPCM845

Quoted 9 lines
---
 drivers/clk/Makefile                      |   1 +
 drivers/clk/nuvoton/Makefile              |   1 +
 drivers/clk/nuvoton/clk_npcm8xx.c         | 213 ++++++++++++++++++++++
 include/dt-bindings/clock/npcm845-clock.h |  17 ++
 4 files changed, 232 insertions(+)
 create mode 100644 drivers/clk/nuvoton/Makefile
 create mode 100644 drivers/clk/nuvoton/clk_npcm8xx.c
 create mode 100644 include/dt-bindings/clock/npcm845-clock.h

Following up here, Sean had comments and while I've seen follow-up timer and serial patches, I haven't seen a follow-up clk patch.

--
Tom

#21 lore raw

PATCH 3/9 timer: npcm: Add NPCM timer support

In reply to Stanley Chu

Add Nuvoton BMC NPCM7xx/NPCM8xx timer driver.

---
 drivers/timer/Kconfig      |  7 ++++
 drivers/timer/Makefile     |  1 +
 drivers/timer/npcm_timer.c | 82 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 drivers/timer/npcm_timer.c
drivers/timer/Kconfig +7 -0
index 8913142654..c17bc5b8b9 100644
@@ -234,4 +234,11 @@ config IMX_GPT_TIMER
 	  Select this to enable support for the timer found on
 	  NXP i.MX devices.
 
+config NPCM_TIMER
+	bool "Nuvoton NPCM timer support"
+	depends on TIMER
+	help
+	  Select this to enable support for the timer found on
+	  Nuvoton NPCM devices.
+
 endmenu
drivers/timer/Makefile +1 -0
index e2bd530eb0..d6f04f1cf4 100644
@@ -26,3 +26,4 @@ obj-$(CONFIG_X86_TSC_TIMER)	+= tsc_timer.o
 obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
 obj-$(CONFIG_MCHP_PIT64B_TIMER)	+= mchp-pit64b-timer.o
 obj-$(CONFIG_IMX_GPT_TIMER)	+= imx-gpt-timer.o
+obj-$(CONFIG_NPCM_TIMER)	+= npcm_timer.o
drivers/timer/npcm_timer.c new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
2.17.1
#22 lore raw

PATCH 4/9 serial: npcm: Add support for Nuvoton NPCM SoCs

In reply to Stanley Chu

Add Nuvoton BMC NPCM7xx/NPCM8xx uart driver

---
 arch/arm/include/asm/arch-npcm8xx/uart.h |  82 ++++++++++++++
 drivers/serial/Kconfig                   |   7 ++
 drivers/serial/Makefile                  |   1 +
 drivers/serial/serial_npcm.c             | 137 +++++++++++++++++++++++
 4 files changed, 227 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/uart.h
 create mode 100644 drivers/serial/serial_npcm.c
arch/arm/include/asm/arch-npcm8xx/uart.h new file +82 -0
new file mode 100644
index 0000000000..e3c86849f3
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _NPCM_UART_H_
+#define _NPCM_UART_H_
+
+struct npcm_uart {
+	union {
+		unsigned int	rbr;
+		unsigned int	thr;
+		unsigned int	dll;
+	};
+	union {
+		unsigned int	ier;
+		unsigned int	dlm;
+	};
+	union {
+		unsigned int	iir;
+		unsigned int	fcr;
+	};
+	unsigned int	lcr;
+	unsigned int	mcr;
+	unsigned int	lsr;
+	unsigned int	msr;
+	unsigned int	tor;
+};
+
+#define	IER_DBGACK	BIT(4)
+#define	IER_MSIE	BIT(3)
+#define	IER_RLSE	BIT(2)
+#define	IER_THREIE	BIT(1)
+#define	IER_RDAIE	BIT(0)
+
+#define	IIR_FMES	BIT(7)
+#define	IIR_RFTLS	BIT(5)
+#define	IIR_DMS		BIT(4)
+#define	IIR_IID		BIT(1)
+#define	IIR_NIP		BIT(0)
+
+#define	FCR_RFITL_1B	(0 << 4)
+#define	FCR_RFITL_4B	(4 << 4)
+#define	FCR_RFITL_8B	(8 << 4)
+#define	FCR_RFITL_14B	(12 << 4)
+#define	FCR_DMS		BIT(3)
+#define	FCR_TFR		BIT(2)
+#define	FCR_RFR		BIT(1)
+#define	FCR_FME		BIT(0)
+
+#define	LCR_DLAB	BIT(7)
+#define	LCR_BCB		BIT(6)
+#define	LCR_SPE		BIT(5)
+#define	LCR_EPS		BIT(4)
+#define	LCR_PBE		BIT(3)
+#define	LCR_NSB		BIT(2)
+#define	LCR_WLS_8b	3
+#define	LCR_WLS_7b	2
+#define	LCR_WLS_6b	1
+#define	LCR_WLS_5b	0
+
+#define	MCR_LBME	BIT(4)
+#define	MCR_OUT2	BIT(3)
+#define	MCR_RTS		BIT(1)
+#define	MCR_DTR		BIT(0)
+
+#define	LSR_ERR_RX	BIT(7)
+#define	LSR_TE		BIT(6)
+#define	LSR_THRE	BIT(5)
+#define	LSR_BII		BIT(4)
+#define	LSR_FEI		BIT(3)
+#define	LSR_PEI		BIT(2)
+#define	LSR_OEI		BIT(1)
+#define	LSR_RFDR	BIT(0)
+
+#define	MSR_DCD		BIT(7)
+#define	MSR_RI		BIT(6)
+#define	MSR_DSR		BIT(5)
+#define	MSR_CTS		BIT(4)
+#define	MSR_DDCD	BIT(3)
+#define	MSR_DRI		BIT(2)
+#define	MSR_DDSR	BIT(1)
+#define	MSR_DCTS	BIT(0)
+
+#endif
drivers/serial/Kconfig +7 -0
index 6c8fdda9a0..3982bc9426 100644
@@ -975,4 +975,11 @@ config SYS_SDMR
 	depends on MPC8XX_CONS
 	default 0
 
+config NPCM_SERIAL
+	bool "Nuvoton NPCM UART driver"
+	depends on DM_SERIAL
+	help
+	  Select this to enable UART support for Nuvoton BMCs
+	  (NPCM7xx and NPCM8xx)
+
 endif
drivers/serial/Makefile +1 -0
index 8168af640f..1b86acf5cf 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o
 obj-$(CONFIG_MT7620_SERIAL) += serial_mt7620.o
 obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o
 obj-$(CONFIG_XEN_SERIAL) += serial_xen.o
+obj-$(CONFIG_NPCM_SERIAL) += serial_npcm.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
drivers/serial/serial_npcm.c new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
2.17.1
#23 lore raw

PATCH 5/9 gpio: npcm: Add support for Nuvoton NPCM SoCs

In reply to Stanley Chu

Add Nuvoton BMC NPCM7xx/NPCM8xx gpio driver

---
 drivers/gpio/Kconfig     |   7 +++
 drivers/gpio/Makefile    |   1 +
 drivers/gpio/npcm_gpio.c | 133 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+)
 create mode 100644 drivers/gpio/npcm_gpio.c
drivers/gpio/Kconfig +7 -0
index 40abc33772..2aed8fdae3 100644
@@ -523,4 +523,11 @@ config NOMADIK_GPIO
 	  into a number of banks each with 32 GPIOs. The GPIOs for a device are
 	  defined in the device tree with one node for each bank.
 
+config NPCM_GPIO
+	bool "NuvoTon NPCM GPIO driver"
+	depends on DM_GPIO
+	help
+	  Support GPIO controllers on NuvoTon NPCM SoCs.
+	  It contains eight GPIO modules with total 256 pins.
+
 endif
drivers/gpio/Makefile +1 -0
index 3c851b38c7..d0206580c4 100644
@@ -69,3 +69,4 @@ obj-$(CONFIG_NX_GPIO)		+= nx_gpio.o
 obj-$(CONFIG_SIFIVE_GPIO)	+= sifive-gpio.o
 obj-$(CONFIG_NOMADIK_GPIO)	+= nmk_gpio.o
 obj-$(CONFIG_MAX7320_GPIO)	+= max7320_gpio.o
+obj-$(CONFIG_NPCM_GPIO)      += npcm_gpio.o
drivers/gpio/npcm_gpio.c new file +133 -0

133 lines not on this page · raw message

Signature · 1 line
2.17.1
#24 lore raw

PATCH 6/9 pinctrl: nuvoton: Add NPCM8xx pinctrl driver

In reply to Stanley Chu

Add Nuvoton BMC NPCM845 Pinmux and Pinconf support.

---
 drivers/pinctrl/Kconfig                   |    1 +
 drivers/pinctrl/Makefile                  |    1 +
 drivers/pinctrl/nuvoton/Kconfig           |    6 +
 drivers/pinctrl/nuvoton/Makefile          |    1 +
 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 2042 +++++++++++++++++++++
 5 files changed, 2051 insertions(+)
 create mode 100644 drivers/pinctrl/nuvoton/Kconfig
 create mode 100644 drivers/pinctrl/nuvoton/Makefile
 create mode 100644 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
drivers/pinctrl/Kconfig +1 -0
index 30eaa376c8..276b7aaa56 100644
@@ -313,5 +313,6 @@ source "drivers/pinctrl/nxp/Kconfig"
 source "drivers/pinctrl/renesas/Kconfig"
 source "drivers/pinctrl/rockchip/Kconfig"
 source "drivers/pinctrl/uniphier/Kconfig"
+source "drivers/pinctrl/nuvoton/Kconfig"
 
 endmenu
drivers/pinctrl/Makefile +1 -0
index 05b71f2f13..2c19eb00f5 100644
@@ -29,3 +29,4 @@ obj-$(CONFIG_PINCTRL_STI)	+= pinctrl-sti.o
 obj-$(CONFIG_PINCTRL_STM32)	+= pinctrl_stm32.o
 obj-$(CONFIG_$(SPL_)PINCTRL_STMFX)	+= pinctrl-stmfx.o
 obj-y				+= broadcom/
+obj-$(CONFIG_PINCTRL_NPCM8XX) += nuvoton/
drivers/pinctrl/nuvoton/Kconfig new file +6 -0
new file mode 100644
index 0000000000..e7063f13ab
@@ -0,0 +1,6 @@
+config PINCTRL_NPCM8XX
+	bool "Pinctrl and GPIO driver for Nuvoton NPCM8XX"
+	depends on DM && PINCTRL_GENERIC && ARCH_NPCM8XX
+	help
+	  Say Y here to enable pin controller and GPIO support
+	  for Nuvoton NPCM8xx SoCs.
drivers/pinctrl/nuvoton/Makefile new file +1 -0
new file mode 100644
index 0000000000..b05aa62d33
@@ -0,0 +1 @@
+ obj-$(CONFIG_PINCTRL_NPCM8XX) += pinctrl-npcm8xx.o
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c new file +2042 -0

2,042 lines not on this page · raw message

Signature · 1 line
2.17.1
#25 lore raw

PATCH 7/9 spi: npcm-fiu: add NPCM8xx FIU controller driver

In reply to Stanley Chu

Add Nuvoton NPCM BMC Flash Interface Unit(FIU) SPI master controller driver using SPI-MEM interface.

The FIU supports single, dual or quad communication interface.

The FIU controller driver provides flash access in UMA(User Mode Access) mode by using an indirect address/data mechanism.

---
 arch/arm/include/asm/arch-npcm8xx/fiu.h |  61 +++++
 drivers/spi/Kconfig                     |   6 +
 drivers/spi/Makefile                    |   1 +
 drivers/spi/npcm_fiu_spi.c              | 311 ++++++++++++++++++++++++
 4 files changed, 379 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-npcm8xx/fiu.h
 create mode 100644 drivers/spi/npcm_fiu_spi.c
arch/arm/include/asm/arch-npcm8xx/fiu.h new file +61 -0
new file mode 100644
index 0000000000..22fc66dd9a
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#ifndef _NPCM_FIU_H_
+#define _NPCM_FIU_H_
+
+#define CHUNK_SIZE		    16
+
+/* FIU UMA Configuration Register (FIU_UMA_CFG) */
+#define FIU_UMA_CFG_LCK                 31
+#define FIU_UMA_CFG_CMMLCK              30
+#define FIU_UMA_CFG_RDATSIZ             24
+#define FIU_UMA_CFG_DBSIZ               21
+#define FIU_UMA_CFG_WDATSIZ             16
+#define FIU_UMA_CFG_ADDSIZ              11
+#define FIU_UMA_CFG_CMDSIZ              10
+#define FIU_UMA_CFG_RDBPCK              8
+#define FIU_UMA_CFG_DBPCK               6
+#define FIU_UMA_CFG_WDBPCK              4
+#define FIU_UMA_CFG_ADBPCK              2
+#define FIU_UMA_CFG_CMBPCK              0
+
+/* FIU UMA Control and Status Register (FIU_UMA_CTS) */
+#define FIU_UMA_CTS_SW_CS		16
+#define FIU_UMA_CTS_DEV_NUM		8
+#define FIU_UMA_CTS_EXEC_DONE		0
+
+struct npcm_fiu_regs {
+	unsigned int    drd_cfg;
+	unsigned int    dwr_cfg;
+	unsigned int    uma_cfg;
+	unsigned int    uma_cts;
+	unsigned int    uma_cmd;
+	unsigned int    uma_addr;
+	unsigned int    prt_cfg;
+	unsigned char   res1[4];
+	unsigned int    uma_dw0;
+	unsigned int    uma_dw1;
+	unsigned int    uma_dw2;
+	unsigned int    uma_dw3;
+	unsigned int    uma_dr0;
+	unsigned int    uma_dr1;
+	unsigned int    uma_dr2;
+	unsigned int    uma_dr3;
+	unsigned int    prt_cmd0;
+	unsigned int    prt_cmd1;
+	unsigned int    prt_cmd2;
+	unsigned int    prt_cmd3;
+	unsigned int    prt_cmd4;
+	unsigned int    prt_cmd5;
+	unsigned int    prt_cmd6;
+	unsigned int    prt_cmd7;
+	unsigned int    prt_cmd8;
+	unsigned int    prt_cmd9;
+	unsigned int    stuff[4];
+	unsigned int    fiu_cfg;
+};
+
+#endif
drivers/spi/Kconfig +6 -0
index d07e9a28af..a7b8f2fa1b 100644
@@ -474,6 +474,12 @@ config ZYNQMP_GQSPI
 	  This option is used to enable ZynqMP QSPI controller driver which
 	  is used to communicate with qspi flash devices.
 
+config NPCM_FIU_SPI
+	bool "FIU driver for Nuvoton NPCM SoC"
+	help
+	  This enables support for the Flash Interface Unit SPI controller
+	  in master mode.
+
 endif # if DM_SPI
 
 config FSL_ESPI
drivers/spi/Makefile +1 -0
index d2f24bccef..4d1be1bb67 100644
@@ -71,3 +71,4 @@ obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o
 obj-$(CONFIG_ZYNQ_SPI) += zynq_spi.o
 obj-$(CONFIG_ZYNQ_QSPI) += zynq_qspi.o
 obj-$(CONFIG_ZYNQMP_GQSPI) += zynqmp_gqspi.o
+obj-$(CONFIG_NPCM_FIU_SPI) += npcm_fiu_spi.o
drivers/spi/npcm_fiu_spi.c new file +311 -0

311 lines not on this page · raw message

Signature · 1 line
2.17.1
#26 lore raw

PATCH 8/9 ARM: dts: Add Nuvoton NPCM845 device tree

In reply to Stanley Chu

Add a common device tree for all Nuvoton NPCM8xx BMCs and a board specific device tree for the NPCM845(Arbel) evaluation board.

---
 arch/arm/dts/Makefile                     |    2 +
 arch/arm/dts/nuvoton-common-npcm8xx.dtsi  |  598 ++++++
 arch/arm/dts/nuvoton-npcm845-evb.dts      |  264 +++
 arch/arm/dts/nuvoton-npcm845-pincfg.dtsi  | 2007 +++++++++++++++++++++
 arch/arm/dts/nuvoton-npcm8xx-pinctrl.dtsi |  623 +++++++
 5 files changed, 3494 insertions(+)
 create mode 100644 arch/arm/dts/nuvoton-common-npcm8xx.dtsi
 create mode 100644 arch/arm/dts/nuvoton-npcm845-evb.dts
 create mode 100644 arch/arm/dts/nuvoton-npcm845-pincfg.dtsi
 create mode 100644 arch/arm/dts/nuvoton-npcm8xx-pinctrl.dtsi
arch/arm/dts/Makefile +2 -0
index 7f622fedbd..b866d488c5 100644
@@ -1162,6 +1162,8 @@ dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) += imx8mm-cl-iot-gate-optee.dtb
 
 dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
 
+dtb-$(CONFIG_TARGET_ARBEL_EVB) += nuvoton-npcm845-evb.dtb
+
 targets += $(dtb-y)
 
 # Add any required device tree compiler flags here
arch/arm/dts/nuvoton-common-npcm8xx.dtsi new file +598 -0

598 lines not on this page · raw message

arch/arm/dts/nuvoton-npcm845-evb.dts new file +264 -0

264 lines not on this page · raw message

arch/arm/dts/nuvoton-npcm845-pincfg.dtsi new file +2007 -0

2,007 lines not on this page · raw message

arch/arm/dts/nuvoton-npcm8xx-pinctrl.dtsi new file +623 -0

123 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#27 lore raw

Re: [PATCH v1 8/9] ARM: dts: Add Nuvoton NPCM845 device tree

Quoted 4 lines · Stanley Chu

Add a common device tree for all Nuvoton NPCM8xx BMCs and a board specific device tree for the NPCM845(Arbel) evaluation board.

Which Linux kernel release are these from? Thanks!

Signature · 1 line
Tom
author
#28 lore raw

Re: [PATCH v1 8/9] ARM: dts: Add Nuvoton NPCM845 device tree

Tom Rini <[email protected]> 於 2021年12月15日 週三 下午9:07寫道:

Quoted 9 lines · Stanley Chu
Quoted 5 lines

Add a common device tree for all Nuvoton NPCM8xx BMCs and a board specific device tree for the NPCM845(Arbel) evaluation board.

Which Linux kernel release are these from? Thanks!

These are new created because NPCM845 is an new generation BMC chip, not upstream to Linux kernel yet.

Quoted 3 lines

--
Tom

#29 lore raw

Re: [PATCH v1 8/9] ARM: dts: Add Nuvoton NPCM845 device tree

Quoted 4 lines · On Wed, Dec 15, 2021 at 09:32:00PM +0800, 盛 wrote:

Tom Rini <[email protected]> 於 2021年12月15日 週三 下午9:07寫道:

Quoted 3 lines · Stanley Chu
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Add a common device tree for all Nuvoton NPCM8xx BMCs and a board specific device tree for the NPCM845(Arbel) evaluation board.

Which Linux kernel release are these from? Thanks!

These are new created because NPCM845 is an new generation BMC chip, not upstream to Linux kernel yet.

OK. The device trees at least need to be in linux-next. That will cover a lot of baseline review that needs to happen before we take it in.

Signature · 1 line
Tom
#30 lore raw

Re: [PATCH v1 8/9] ARM: dts: Add Nuvoton NPCM845 device tree

Quoted 4 lines

OK. The device trees at least need to be in linux-next. That will cover a lot of baseline review that needs to happen before we take it in.

Hi Tom!
If my understanding is correct device tree's should be accepted into Linux-next before U-Boot, or am I wrong.

Also Stanley, I don't think I apply to this patch set...
When getting maintainers I think you should pass --nogit --norolestats. I may be wrong about this though as I'm new to contributions.

Thanks,
Jesse T

#31 lore raw

Re: [PATCH v1 8/9] ARM: dts: Add Nuvoton NPCM845 device tree

Quoted 7 lines · Jesse Taube
Quoted 4 lines

OK. The device trees at least need to be in linux-next. That will cover a lot of baseline review that needs to happen before we take it in.

Hi Tom!
If my understanding is correct device tree's should be accepted into Linux-next before U-Boot, or am I wrong.

Yes, they should be in linux-next at least before going in to U-Boot.

Signature · 1 line
Tom
#32 lore raw

PATCH 9/9 ARM: configs: Add defconfig for Nuvoton NPCM845

In reply to Stanley Chu

Add defconfig for NPCM845 EVB (Arbel).

---
 board/nuvoton/arbel/MAINTAINERS |  7 +++
 configs/arbel_evb_defconfig     | 77 +++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 board/nuvoton/arbel/MAINTAINERS
 create mode 100644 configs/arbel_evb_defconfig
board/nuvoton/arbel/MAINTAINERS new file +7 -0
new file mode 100644
index 0000000000..1086401f7d
@@ -0,0 +1,7 @@
+Arbel EVB
+M:	Stanley Chu <[email protected]>
+M:	Medad Cchien <[email protected]>
+S:	Maintained
+F:	board/nuvoton/arbel/
+F:	include/configs/arbel.h
+F:	configs/arbel_evb_defconfig
configs/arbel_evb_defconfig new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.17.1