[PATCH] arm: moxa: add nport6600 platform

Support for NPort 6600 Series RS-232/422/485 secure terminal servers.
Technical specifications: FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, optional expansion modules, up to 32 RS-232/422/485 ports.
Signed-off-by: Sergei Antonov saproj@gmail.com --- arch/arm/Kconfig | 9 +++ arch/arm/dts/nport6600.dts | 134 +++++++++++++++++++++++++++++++ board/moxa/nport6600/Kconfig | 15 ++++ board/moxa/nport6600/MAINTAINERS | 7 ++ board/moxa/nport6600/Makefile | 3 + board/moxa/nport6600/nport6600.c | 78 ++++++++++++++++++ configs/nport6600_defconfig | 129 +++++++++++++++++++++++++++++ include/configs/nport6600.h | 13 +++ 8 files changed, 388 insertions(+) create mode 100644 arch/arm/dts/nport6600.dts create mode 100644 board/moxa/nport6600/Kconfig create mode 100644 board/moxa/nport6600/MAINTAINERS create mode 100644 board/moxa/nport6600/Makefile create mode 100644 board/moxa/nport6600/nport6600.c create mode 100644 configs/nport6600_defconfig create mode 100644 include/configs/nport6600.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 97c25b4f146d..de5b746b93c9 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -705,6 +705,14 @@ config TARGET_BCMNS3 ARMv8 Cortex-A72 processors targeting a broad range of networking applications.
+config TARGET_NPORT6600 + bool "Support NPort 6600" + select CPU_ARM720T + help + Support for NPort 6600 Series RS-232/422/485 secure terminal servers. + FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, + optional expansion modules, up to 32 RS-232/422/485 ports. + config ARCH_EXYNOS bool "Samsung EXYNOS" select DM @@ -2312,6 +2320,7 @@ source "board/hisilicon/hikey960/Kconfig" source "board/hisilicon/poplar/Kconfig" source "board/isee/igep003x/Kconfig" source "board/kontron/sl28/Kconfig" +source "board/moxa/nport6600/Kconfig" source "board/myir/mys_6ulx/Kconfig" source "board/samsung/common/Kconfig" source "board/siemens/common/Kconfig" diff --git a/arch/arm/dts/nport6600.dts b/arch/arm/dts/nport6600.dts new file mode 100644 index 000000000000..ea268ed16d9b --- /dev/null +++ b/arch/arm/dts/nport6600.dts @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/dts-v1/; + +#include <dt-bindings/gpio/gpio.h> + +/ { + model = "MOXA NPort 6600 Series"; + compatible = "moxa,nport6600"; + #address-cells = <1>; + #size-cells = <1>; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x4000000>; + }; + + ahb { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + device_type = "soc"; + ranges; + bootph-all; + + apb { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + bootph-all; + + uart1: serial@98200020 { + compatible = "ns16550a"; + reg = <0x98200020 0x20>; + reg-io-width = <4>; + reg-shift = <2>; + clock-frequency = <14745600>; + no-loopback-test; + bootph-all; + status = "okay"; + }; + + timer: timer@98400000 { + compatible = "faraday,fttmr010-timer"; + reg = <0x98400000 0x40>; + clock-frequency = <12000000>; + }; + + wdt: wdt@98500000 { + compatible = "faraday,ftwdt010"; + reg = <0x98500000 0x20>; + }; + + gpio: gpio@98700000 { + compatible = "faraday,ftgpio010"; + reg = <0x98700000 0x20>; + nr-gpios = <32>; + #gpio-cells = <2>; + }; + + rtc { + compatible = "holtek,ht1380"; + rst-gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + clk-gpios = <&gpio 20 GPIO_ACTIVE_HIGH>; + dat-gpios = <&gpio 21 GPIO_ACTIVE_HIGH>; + }; + + mmc0: mmc@98e00000 { + compatible = "andestech,atfsdc010"; + bus-width = <4>; + max-frequency = <25000000>; + reg = <0x98e00000 0x1000>; + cap-sd-highspeed; + }; + }; + + nor@80000000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "cfi-flash"; + reg = <0x80000000 0x0>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + mtd1 { + label = "moxa"; + reg = <0x0 0x40000>; + read-only; + }; + mtd2 { + label = "env"; + reg = <0x40000 0x100000>; + read-only; + }; + mtd3 { + label = "uboot"; + reg = <0x140000 0xc0000>; + }; + mtd4 { + label = "mfs"; + reg = <0x200000 0x20000>; + read-only; + }; + mtd5 { + label = "ubi"; + reg = <0x220000 0xde0000>; + }; + }; + }; + + mac@92000000 { + compatible = "andestech,atmac100"; + reg = <0x92000000 0x90>; + }; + + pci0@90c00000 { + compatible = "faraday,ftpci100"; + device_type = "pci"; + reg = <0x90c00000 0x30>; + + #address-cells = <3>; + #size-cells = <2>; + bus-range = <0x0 0xff>; + ranges = <0x01000000 0 0x90c00000 0x90c00000 0 0x00100000 /* I/O */ + 0x02000000 0 0xa0000000 0xa0000000 0 0x02000000 /* MEM */>; + + status = "okay"; + }; + }; +}; diff --git a/board/moxa/nport6600/Kconfig b/board/moxa/nport6600/Kconfig new file mode 100644 index 000000000000..3094b380c0fd --- /dev/null +++ b/board/moxa/nport6600/Kconfig @@ -0,0 +1,15 @@ +if TARGET_NPORT6600 + +config SYS_BOARD + default "nport6600" + +config SYS_VENDOR + default "moxa" + +config SYS_SOC + default "moxa" + +config SYS_CONFIG_NAME + default "nport6600" + +endif diff --git a/board/moxa/nport6600/MAINTAINERS b/board/moxa/nport6600/MAINTAINERS new file mode 100644 index 000000000000..fca3d9d0dbfa --- /dev/null +++ b/board/moxa/nport6600/MAINTAINERS @@ -0,0 +1,7 @@ +NPORT6600 BOARD +M: Sergei Antonov saproj@gmail.com +S: Maintained +F: board/moxa/nport6600/ +F: arch/arm/dts/nport6600.dts +F: include/configs/nport6600.h +F: configs/nport6600_defconfig diff --git a/board/moxa/nport6600/Makefile b/board/moxa/nport6600/Makefile new file mode 100644 index 000000000000..8d853eaa1a57 --- /dev/null +++ b/board/moxa/nport6600/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +obj-y := nport6600.o diff --git a/board/moxa/nport6600/nport6600.c b/board/moxa/nport6600/nport6600.c new file mode 100644 index 000000000000..88fa98c315fd --- /dev/null +++ b/board/moxa/nport6600/nport6600.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <common.h> +#include <init.h> +#include <env.h> +#include <cpu_func.h> +#include <string.h> + +int dram_init(void) +{ + return fdtdec_setup_mem_size_base(); +} + +int board_init(void) +{ + return 0; +} + +int show_board_info(void) +{ + const u8 *NPORT_EXPANSION_MODULE = (const u8 *)0x8c0000c0; + const unsigned int module_id = *NPORT_EXPANSION_MODULE; + static const char * const modules[] = { + NULL, + "NM-TX01", + "NM-FX01-M-SC", + "NM-FX01-S-SC", + NULL, + "NM-FX02-M-SC", + "NM-FX02-S-SC", + "NM_GPRS", + "NM-TX02", + }; + + /* Check for Module */ + if (module_id < ARRAY_SIZE(modules) && modules[module_id]) + printf("Expansion module %s detected\n", modules[module_id]); + + return 0; +} + +static int read_net_params(void) +{ + const u8 *MAC_ADDR = (const u8 *)0x80000050; + + if (eth_env_set_enetaddr("ethaddr", MAC_ADDR)) + return -1; + + return 0; +} + +int misc_init_r(void) +{ + const char *SERIAL_STR = (const char *)0x80000034; + const unsigned int SERIAL_LEN = 12; + char str[SERIAL_LEN + 1]; + + if (*SERIAL_STR) { + memcpy(str, SERIAL_STR, SERIAL_LEN); + str[SERIAL_LEN] = 0; + } else { + /* No serial string. Resort to a 2-byte serial number. */ + const u16 *SERIAL_NO = (const u16 *)0x8000004c; + + sprintf(str, "%05u", *SERIAL_NO); + } + + if (env_set("serial#", str)) + return -1; + + return read_net_params(); +} + +void enable_caches(void) +{ + icache_enable(); + dcache_enable(); +} diff --git a/configs/nport6600_defconfig b/configs/nport6600_defconfig new file mode 100644 index 000000000000..47db1ca20ae6 --- /dev/null +++ b/configs/nport6600_defconfig @@ -0,0 +1,129 @@ +CONFIG_ARM=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="echo Serial number: ${serial#}" +CONFIG_USE_BOOTCOMMAND=y +CONFIG_BOOTCOMMAND="" +CONFIG_BOOTDELAY=1 +# CONFIG_BOOTSTD is not set +CONFIG_DISPLAY_BOARDINFO=y +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_LTO=y +CONFIG_CMD_BOOTZ=y +CONFIG_CMD_CACHE=y +CONFIG_CMD_CLS=y +CONFIG_CMD_CRC32=y +CONFIG_CMD_FLASH=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_CMD_LOG=y +CONFIG_CMD_MD5SUM=y +CONFIG_CMD_MEMTEST=y +CONFIG_CMD_MTDPARTS=y +CONFIG_CMD_MTD=y +CONFIG_CMD_NET=y +CONFIG_CMD_PING=y +CONFIG_CMD_UBI=y +CONFIG_CRC32_VERIFY=y +CONFIG_DM=y +CONFIG_ENV_SUPPORT=y +CONFIG_FTMAC100=y +CONFIG_HUSH_PARSER=y +CONFIG_LOG_CONSOLE=y +CONFIG_LOG_MAX_LEVEL=8 +CONFIG_LOG_DEFAULT_LEVEL=6 +CONFIG_LOGLEVEL=7 +CONFIG_LOG=y +CONFIG_MISC_INIT_R=y +CONFIG_OF_LIBFDT=y +CONFIG_SKIP_LOWLEVEL_INIT=y +CONFIG_SYS_CBSIZE=256 +CONFIG_SYS_DCACHE_OFF=y +CONFIG_SYS_LONGHELP=y +CONFIG_SYS_MEMTEST_END=0x3F00000 +CONFIG_SYS_MEMTEST_START=0x00000000 +CONFIG_SYS_NS16550=y +CONFIG_NS16550_DYNAMIC=y +CONFIG_SYS_PBSIZE=280 +CONFIG_SYS_PROMPT="MOXA NPort 6600 # " +CONFIG_TEXT_BASE=0x80140020 +CONFIG_TARGET_NPORT6600=y +CONFIG_FS_EXT4=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_FS_FAT=y +CONFIG_CMD_FAT=y +CONFIG_CMD_TIME=y +CONFIG_CMD_SHA1SUM=y +CONFIG_CMD_STRINGS=y +CONFIG_CMD_UNLZ4=y +CONFIG_CMD_UNZIP=y +CONFIG_CMD_SETEXPR=y +CONFIG_CMD_SETEXPR_FMT=y +CONFIG_CMD_READ=y +CONFIG_CMD_GETTIME=y +CONFIG_CMD_TIMER=y +CONFIG_CMD_UBI_RENAME=y +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_MEM_SEARCH=y +CONFIG_CMD_ASKENV=y +CONFIG_CMD_EXPORTENV=y +CONFIG_CMD_IMPORTENV=y +CONFIG_CMD_EDITENV=y +CONFIG_CMD_GREPENV=y +CONFIG_CMD_SAVEENV=y +CONFIG_CMD_ERASEENV=y +CONFIG_CMD_ENV_EXISTS=y +CONFIG_CMD_ENV_CALLBACK=y +CONFIG_CMD_ENV_FLAGS=y +CONFIG_SYS_LOAD_ADDR=0x100000 +CONFIG_CMD_LOADB=y +CONFIG_CMD_DM=y +CONFIG_CMD_GPT=y +CONFIG_CMD_MBR=y +CONFIG_CMD_PART=y +CONFIG_CMD_WGET=y +CONFIG_DM_STATS=y +CONFIG_CMD_HASH=y +CONFIG_HASH_VERIFY=y +CONFIG_CMD_DHCP=y +CONFIG_BAUDRATE=115200 +CONFIG_MTD=y +CONFIG_DM_MTD=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_MTD=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SYS_FLASH_CFI_WIDTH_16BIT=y +CONFIG_SYS_FLASH_EMPTY_INFO=y +CONFIG_OF_CONTROL=y +CONFIG_DEFAULT_DEVICE_TREE="nport6600" +CONFIG_SYS_CLK_FREQ=48000000 +CONFIG_TIMER=y +CONFIG_FTTMR010_TIMER=y +CONFIG_DM_SERIAL=y +CONFIG_DM_ETH=y +CONFIG_MMC=y +CONFIG_DM_MMC=y +CONFIG_MMC_VERBOSE=y +CONFIG_CMD_MMC=y +CONFIG_FTSDC010=y +CONFIG_WDT_FTWDT010=y +CONFIG_WDT=y +CONFIG_CMD_WDT=y +CONFIG_SYSRESET=y +CONFIG_SYSRESET_WATCHDOG=y +CONFIG_SYSRESET_WATCHDOG_AUTO=y +CONFIG_CMD_GPIO=y +CONFIG_DM_GPIO=y +CONFIG_DM_RTC=y +CONFIG_RTC_HT1380=y +CONFIG_CMD_RTC=y +CONFIG_CMD_DATE=y +CONFIG_FTGPIO010=y +CONFIG_CMD_MII=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200n8" +CONFIG_IPV6=y +CONFIG_PCI=y +CONFIG_CMD_PCI=y +CONFIG_PCI_FTPCI100=y diff --git a/include/configs/nport6600.h b/include/configs/nport6600.h new file mode 100644 index 000000000000..c70cc7e1ac72 --- /dev/null +++ b/include/configs/nport6600.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _CONFIG_NPORT6600_H +#define _CONFIG_NPORT6600_H + +#include <linux/sizes.h> + +#define CFG_SYS_INIT_RAM_ADDR 0 +#define CFG_SYS_INIT_RAM_SIZE SZ_64M + +#define __io + +#endif /* _CONFIG_NPORT6600_H */

On Mon, Jul 31, 2023 at 09:43:29PM +0300, Sergei Antonov wrote:
Support for NPort 6600 Series RS-232/422/485 secure terminal servers.
Technical specifications: FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, optional expansion modules, up to 32 RS-232/422/485 ports.
Signed-off-by: Sergei Antonov saproj@gmail.com
arch/arm/Kconfig | 9 +++ arch/arm/dts/nport6600.dts | 134 +++++++++++++++++++++++++++++++
Where does the device tree come from?
diff --git a/board/moxa/nport6600/nport6600.c b/board/moxa/nport6600/nport6600.c new file mode 100644 index 000000000000..88fa98c315fd --- /dev/null +++ b/board/moxa/nport6600/nport6600.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
+#include <common.h>
New files must not add common.h
diff --git a/include/configs/nport6600.h b/include/configs/nport6600.h new file mode 100644 index 000000000000..c70cc7e1ac72 --- /dev/null +++ b/include/configs/nport6600.h
[snip]
+#define __io
What's this for?

On Mon, 31 Jul 2023 at 21:59, Tom Rini trini@konsulko.com wrote:
On Mon, Jul 31, 2023 at 09:43:29PM +0300, Sergei Antonov wrote:
Support for NPort 6600 Series RS-232/422/485 secure terminal servers.
Technical specifications: FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, optional expansion modules, up to 32 RS-232/422/485 ports.
Signed-off-by: Sergei Antonov saproj@gmail.com
arch/arm/Kconfig | 9 +++ arch/arm/dts/nport6600.dts | 134 +++++++++++++++++++++++++++++++
Where does the device tree come from?
From the datasheet, testing, and a similar dts in Linux:
https://github.com/torvalds/linux/tree/master/arch/arm/boot/dts/moxa
diff --git a/board/moxa/nport6600/nport6600.c b/board/moxa/nport6600/nport6600.c new file mode 100644 index 000000000000..88fa98c315fd --- /dev/null +++ b/board/moxa/nport6600/nport6600.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
+#include <common.h>
OK. Compiles without it.
New files must not add common.h
diff --git a/include/configs/nport6600.h b/include/configs/nport6600.h new file mode 100644 index 000000000000..c70cc7e1ac72 --- /dev/null +++ b/include/configs/nport6600.h
[snip]
+#define __io
What's this for?
Removing it leads to warnings:
.../u-boot/drivers/serial/ns16550.c: In function ‘serial_out_dynamic’: .../u-boot/drivers/serial/ns16550.c:111:17: warning: implicit declaration of function ‘outb’ [-Wimplicit-function-declaration] 111 | outb(value, addr); | ^~~~ .../u-boot/drivers/serial/ns16550.c: In function ‘serial_in_dynamic’: .../u-boot/drivers/serial/ns16550.c:131:24: warning: implicit declaration of function ‘inb’; did you mean ‘isb’? [-Wimplicit-function-declaration] 131 | return inb(addr); | ^~~ | isb
and then linking errors:
.../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_writeb.isra.0': .../u-boot/drivers/serial/ns16550.c:111: undefined reference to `outb' .../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_readb.isra.0': .../u-boot/drivers/serial/ns16550.c:131: undefined reference to `inb'

On Tue, Aug 01, 2023 at 01:11:28PM +0300, Sergei Antonov wrote:
On Mon, 31 Jul 2023 at 21:59, Tom Rini trini@konsulko.com wrote:
On Mon, Jul 31, 2023 at 09:43:29PM +0300, Sergei Antonov wrote:
Support for NPort 6600 Series RS-232/422/485 secure terminal servers.
Technical specifications: FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, optional expansion modules, up to 32 RS-232/422/485 ports.
Signed-off-by: Sergei Antonov saproj@gmail.com
arch/arm/Kconfig | 9 +++ arch/arm/dts/nport6600.dts | 134 +++++++++++++++++++++++++++++++
Where does the device tree come from?
From the datasheet, testing, and a similar dts in Linux: https://github.com/torvalds/linux/tree/master/arch/arm/boot/dts/moxa
It needs to be the same dts as in Linux, and re-synced periodically. The -u-boot.dtsi file can be used for changes that are still being staged to Linux, but shouldn't be used indefinitely.
diff --git a/board/moxa/nport6600/nport6600.c b/board/moxa/nport6600/nport6600.c new file mode 100644 index 000000000000..88fa98c315fd --- /dev/null +++ b/board/moxa/nport6600/nport6600.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
+#include <common.h>
OK. Compiles without it.
New files must not add common.h
diff --git a/include/configs/nport6600.h b/include/configs/nport6600.h new file mode 100644 index 000000000000..c70cc7e1ac72 --- /dev/null +++ b/include/configs/nport6600.h
[snip]
+#define __io
What's this for?
Removing it leads to warnings:
.../u-boot/drivers/serial/ns16550.c: In function ‘serial_out_dynamic’: .../u-boot/drivers/serial/ns16550.c:111:17: warning: implicit declaration of function ‘outb’ [-Wimplicit-function-declaration] 111 | outb(value, addr); | ^~~~ .../u-boot/drivers/serial/ns16550.c: In function ‘serial_in_dynamic’: .../u-boot/drivers/serial/ns16550.c:131:24: warning: implicit declaration of function ‘inb’; did you mean ‘isb’? [-Wimplicit-function-declaration] 131 | return inb(addr); | ^~~ | isb
and then linking errors:
.../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_writeb.isra.0': .../u-boot/drivers/serial/ns16550.c:111: undefined reference to `outb' .../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_readb.isra.0': .../u-boot/drivers/serial/ns16550.c:131: undefined reference to `inb'
Oh, you need to be enabling CONFIG_DM_SERIAL.

On Tue, 1 Aug 2023 at 17:27, Tom Rini trini@konsulko.com wrote:
On Tue, Aug 01, 2023 at 01:11:28PM +0300, Sergei Antonov wrote:
On Mon, 31 Jul 2023 at 21:59, Tom Rini trini@konsulko.com wrote:
On Mon, Jul 31, 2023 at 09:43:29PM +0300, Sergei Antonov wrote:
Support for NPort 6600 Series RS-232/422/485 secure terminal servers.
Technical specifications: FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, optional expansion modules, up to 32 RS-232/422/485 ports.
Signed-off-by: Sergei Antonov saproj@gmail.com
arch/arm/Kconfig | 9 +++ arch/arm/dts/nport6600.dts | 134 +++++++++++++++++++++++++++++++
Where does the device tree come from?
From the datasheet, testing, and a similar dts in Linux: https://github.com/torvalds/linux/tree/master/arch/arm/boot/dts/moxa
It needs to be the same dts as in Linux, and re-synced periodically. The -u-boot.dtsi file can be used for changes that are still being staged to Linux, but shouldn't be used indefinitely.
There is no dts in Linux for the device (a family of devices) I am submitting. Linux has a dts for a similar device.
diff --git a/board/moxa/nport6600/nport6600.c b/board/moxa/nport6600/nport6600.c new file mode 100644 index 000000000000..88fa98c315fd --- /dev/null +++ b/board/moxa/nport6600/nport6600.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
+#include <common.h>
OK. Compiles without it.
New files must not add common.h
diff --git a/include/configs/nport6600.h b/include/configs/nport6600.h new file mode 100644 index 000000000000..c70cc7e1ac72 --- /dev/null +++ b/include/configs/nport6600.h
[snip]
+#define __io
What's this for?
Removing it leads to warnings:
.../u-boot/drivers/serial/ns16550.c: In function ‘serial_out_dynamic’: .../u-boot/drivers/serial/ns16550.c:111:17: warning: implicit declaration of function ‘outb’ [-Wimplicit-function-declaration] 111 | outb(value, addr); | ^~~~ .../u-boot/drivers/serial/ns16550.c: In function ‘serial_in_dynamic’: .../u-boot/drivers/serial/ns16550.c:131:24: warning: implicit declaration of function ‘inb’; did you mean ‘isb’? [-Wimplicit-function-declaration] 131 | return inb(addr); | ^~~ | isb
and then linking errors:
.../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_writeb.isra.0': .../u-boot/drivers/serial/ns16550.c:111: undefined reference to `outb' .../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_readb.isra.0': .../u-boot/drivers/serial/ns16550.c:131: undefined reference to `inb'
Oh, you need to be enabling CONFIG_DM_SERIAL.
It IS enabled.

On Wed, Aug 02, 2023 at 05:27:54PM +0300, Sergei Antonov wrote:
On Tue, 1 Aug 2023 at 17:27, Tom Rini trini@konsulko.com wrote:
On Tue, Aug 01, 2023 at 01:11:28PM +0300, Sergei Antonov wrote:
On Mon, 31 Jul 2023 at 21:59, Tom Rini trini@konsulko.com wrote:
On Mon, Jul 31, 2023 at 09:43:29PM +0300, Sergei Antonov wrote:
Support for NPort 6600 Series RS-232/422/485 secure terminal servers.
Technical specifications: FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, optional expansion modules, up to 32 RS-232/422/485 ports.
Signed-off-by: Sergei Antonov saproj@gmail.com
arch/arm/Kconfig | 9 +++ arch/arm/dts/nport6600.dts | 134 +++++++++++++++++++++++++++++++
Where does the device tree come from?
From the datasheet, testing, and a similar dts in Linux: https://github.com/torvalds/linux/tree/master/arch/arm/boot/dts/moxa
It needs to be the same dts as in Linux, and re-synced periodically. The -u-boot.dtsi file can be used for changes that are still being staged to Linux, but shouldn't be used indefinitely.
There is no dts in Linux for the device (a family of devices) I am submitting. Linux has a dts for a similar device.
Please upstream the device tree.
diff --git a/board/moxa/nport6600/nport6600.c b/board/moxa/nport6600/nport6600.c new file mode 100644 index 000000000000..88fa98c315fd --- /dev/null +++ b/board/moxa/nport6600/nport6600.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
+#include <common.h>
OK. Compiles without it.
New files must not add common.h
diff --git a/include/configs/nport6600.h b/include/configs/nport6600.h new file mode 100644 index 000000000000..c70cc7e1ac72 --- /dev/null +++ b/include/configs/nport6600.h
[snip]
+#define __io
What's this for?
Removing it leads to warnings:
.../u-boot/drivers/serial/ns16550.c: In function ‘serial_out_dynamic’: .../u-boot/drivers/serial/ns16550.c:111:17: warning: implicit declaration of function ‘outb’ [-Wimplicit-function-declaration] 111 | outb(value, addr); | ^~~~ .../u-boot/drivers/serial/ns16550.c: In function ‘serial_in_dynamic’: .../u-boot/drivers/serial/ns16550.c:131:24: warning: implicit declaration of function ‘inb’; did you mean ‘isb’? [-Wimplicit-function-declaration] 131 | return inb(addr); | ^~~ | isb
and then linking errors:
.../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_writeb.isra.0': .../u-boot/drivers/serial/ns16550.c:111: undefined reference to `outb' .../armv4/lib/gcc/armv4-linux-gnueabi/13.0.1/../../../../armv4-linux-gnueabi/bin/ld: /tmp/ccIta0uJ.ltrans12.ltrans.o: in function `ns16550_readb.isra.0': .../u-boot/drivers/serial/ns16550.c:131: undefined reference to `inb'
Oh, you need to be enabling CONFIG_DM_SERIAL.
It IS enabled.
Oh, I see it now, you're right, sorry. But, is CONFIG_NS16550_DYNAMIC really the only choice here?

Hi Sergei,
On Mon, 31 Jul 2023 at 12:43, Sergei Antonov saproj@gmail.com wrote:
Support for NPort 6600 Series RS-232/422/485 secure terminal servers.
Technical specifications: FA526 ARMv4 CPU, 64 MB of RAM, 16 MB NOR flash, 100 Mbit/s Ethernet, optional expansion modules, up to 32 RS-232/422/485 ports.
Signed-off-by: Sergei Antonov saproj@gmail.com
arch/arm/Kconfig | 9 +++ arch/arm/dts/nport6600.dts | 134 +++++++++++++++++++++++++++++++ board/moxa/nport6600/Kconfig | 15 ++++ board/moxa/nport6600/MAINTAINERS | 7 ++ board/moxa/nport6600/Makefile | 3 + board/moxa/nport6600/nport6600.c | 78 ++++++++++++++++++ configs/nport6600_defconfig | 129 +++++++++++++++++++++++++++++ include/configs/nport6600.h | 13 +++ 8 files changed, 388 insertions(+) create mode 100644 arch/arm/dts/nport6600.dts create mode 100644 board/moxa/nport6600/Kconfig create mode 100644 board/moxa/nport6600/MAINTAINERS create mode 100644 board/moxa/nport6600/Makefile create mode 100644 board/moxa/nport6600/nport6600.c create mode 100644 configs/nport6600_defconfig create mode 100644 include/configs/nport6600.h
[..]
diff --git a/board/moxa/nport6600/Makefile b/board/moxa/nport6600/Makefile new file mode 100644 index 000000000000..8d853eaa1a57 --- /dev/null +++ b/board/moxa/nport6600/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-or-later
+obj-y := nport6600.o diff --git a/board/moxa/nport6600/nport6600.c b/board/moxa/nport6600/nport6600.c new file mode 100644 index 000000000000..88fa98c315fd --- /dev/null +++ b/board/moxa/nport6600/nport6600.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
+#include <common.h> +#include <init.h> +#include <env.h> +#include <cpu_func.h> +#include <string.h>
+int dram_init(void) +{
return fdtdec_setup_mem_size_base();
+}
+int board_init(void) +{
return 0;
+}
+int show_board_info(void)
Can you use the sysinfo API and command instead?
+{
const u8 *NPORT_EXPANSION_MODULE = (const u8 *)0x8c0000c0;
const unsigned int module_id = *NPORT_EXPANSION_MODULE;
static const char * const modules[] = {
NULL,
"NM-TX01",
"NM-FX01-M-SC",
"NM-FX01-S-SC",
NULL,
"NM-FX02-M-SC",
"NM-FX02-S-SC",
"NM_GPRS",
"NM-TX02",
};
/* Check for Module */
if (module_id < ARRAY_SIZE(modules) && modules[module_id])
printf("Expansion module %s detected\n", modules[module_id]);
return 0;
+}
+static int read_net_params(void) +{
const u8 *MAC_ADDR = (const u8 *)0x80000050;
if (eth_env_set_enetaddr("ethaddr", MAC_ADDR))
return -1;
return 0;
+}
+int misc_init_r(void) +{
const char *SERIAL_STR = (const char *)0x80000034;
Is that in the devicetree ?
const unsigned int SERIAL_LEN = 12;
char str[SERIAL_LEN + 1];
if (*SERIAL_STR) {
memcpy(str, SERIAL_STR, SERIAL_LEN);
str[SERIAL_LEN] = 0;
} else {
/* No serial string. Resort to a 2-byte serial number. */
const u16 *SERIAL_NO = (const u16 *)0x8000004c;
sprintf(str, "%05u", *SERIAL_NO);
}
if (env_set("serial#", str))
return -1;
return read_net_params();
+}
+void enable_caches(void) +{
icache_enable();
dcache_enable();
+}
[..]
+++ b/include/configs/nport6600.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _CONFIG_NPORT6600_H +#define _CONFIG_NPORT6600_H
+#include <linux/sizes.h>
+#define CFG_SYS_INIT_RAM_ADDR 0 +#define CFG_SYS_INIT_RAM_SIZE SZ_64M
What code uses this? I suppose it is SoC-specific?
+#define __io
+#endif /* _CONFIG_NPORT6600_H */
2.37.2
Regards, Simon
participants (3)
-
Sergei Antonov
-
Simon Glass
-
Tom Rini