Skip to content

Commit

Permalink
drivers: ethernet: support npcm4xx ethernet
Browse files Browse the repository at this point in the history
1. Jtag is disabled by default.
2. samples/net/sockets/dumb_http_server is used
   for testing. (optional)
3. Test result for reference:
   Local IP: 192.0.2.1
   Remote IP: 192.0.2.2
   uart:~$ net ping 192.0.2.2
   PING 192.0.2.2
   28 bytes from 192.0.2.2 to 192.0.2.1: icmp_seq=0 ttl=64 time=1 ms
   28 bytes from 192.0.2.2 to 192.0.2.1: icmp_seq=1 ttl=64 time=1 ms
   28 bytes from 192.0.2.2 to 192.0.2.1: icmp_seq=2 ttl=64 time=1 ms
4. The local and remote IPs could be changed in
   CONFIG_NET_CONFIG_MY_IPV4_ADDR and
   CONFIG_NET_CONFIG_PEER_IPV4_ADDR.

Signed-off-by: Tyrone Ting <[email protected]>
  • Loading branch information
warp5tw authored and maxdog988 committed Aug 28, 2024
1 parent d4877e0 commit 13f61bc
Show file tree
Hide file tree
Showing 14 changed files with 2,678 additions and 4 deletions.
4 changes: 4 additions & 0 deletions boards/arm/npcm400f_evb/fun_def_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ FUN_DEFINE(DT_NODELABEL(pinctrl_sgpio0_default), IOX1_LDSH, IOX1_DOUT, IOX1_DIN,
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sgpio1), okay) && CONFIG_SGPIO_NPCM4XX
FUN_DEFINE(DT_NODELABEL(pinctrl_sgpio1_default), IOX2_LDSH, IOX2_DOUT, IOX2_DIN, IOX2_SCLK)
#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(emac), okay) && CONFIG_ETH_NPCM4XX
FUN_DEFINE(DT_NODELABEL(pinctrl_emac_default), EMAC)
#endif
6 changes: 5 additions & 1 deletion boards/arm/npcm400f_evb/npcm400f_evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
tdi-gpios = <&gpio0 1 (GPIO_PUSH_PULL | GPIO_ACTIVE_HIGH)>;
tdo-gpios = <&gpio0 2 (GPIO_ACTIVE_HIGH)>;
tms-gpios = <&gpio0 3 (GPIO_PUSH_PULL | GPIO_ACTIVE_HIGH)>;
status = "okay";
status = "disabled";
};

&i3c4 {
Expand Down Expand Up @@ -608,3 +608,7 @@
pin-offset = <120>;
};
};

&emac {
status = "okay";
};
28 changes: 25 additions & 3 deletions boards/arm/npcm400f_evb/npcm400f_evb_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,31 @@ CONFIG_USB=y
CONFIG_USB_DC_NPCM4XX=y

# JTAG Driver
CONFIG_JTAG=y
CONFIG_JTAG_SHELL=y
CONFIG_JTAG_NPCM4XX=y
CONFIG_JTAG=n
CONFIG_JTAG_SHELL=n
CONFIG_JTAG_NPCM4XX=n

# SGPIO Driver
CONFIG_SGPIO_NPCM4XX=n

# EMAC Driver
CONFIG_ETH_NPCM4XX=y

# Networking config
CONFIG_NETWORKING=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_TCP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SHELL=y
CONFIG_NET_TCP_ISN_RFC6528=n
CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_AUTO_INIT=y
CONFIG_NET_CONFIG_NEED_IPV4=y
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
CONFIG_NET_CONFIG_INIT_TIMEOUT=3

# Network driver config
CONFIG_TEST_RANDOM_GENERATOR=y
1 change: 1 addition & 0 deletions drivers/ethernet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ zephyr_sources_ifdef(CONFIG_ETH_STM32_HAL eth_stm32_hal.c)
zephyr_sources_ifdef(CONFIG_ETH_LITEETH eth_liteeth.c)
zephyr_sources_ifdef(CONFIG_ETH_W5500 eth_w5500.c)
zephyr_sources_ifdef(CONFIG_DSA_KSZ8794 dsa_ksz8794.c)
zephyr_sources_ifdef(CONFIG_ETH_NPCM4XX eth_npcm4xx.c)

if(CONFIG_ETH_NATIVE_POSIX)
zephyr_library()
Expand Down
1 change: 1 addition & 0 deletions drivers/ethernet/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ source "drivers/ethernet/Kconfig.liteeth"
source "drivers/ethernet/Kconfig.gecko"
source "drivers/ethernet/Kconfig.w5500"
source "drivers/ethernet/Kconfig.dsa"
source "drivers/ethernet/Kconfig.npcm4xx"

endmenu # "Ethernet Drivers"
71 changes: 71 additions & 0 deletions drivers/ethernet/Kconfig.npcm4xx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Nuvoton Ethernet driver configuration options

# SPDX-License-Identifier: Apache-2.0

DT_COMPAT_NUVOTON_NPCM4XX_ETHERNET := nuvoton,npcm4xx-ethernet

config ETH_NPCM4XX
bool "Nuvoton NPCM4XX Ethernet driver"
depends on SOC_FAMILY_NPCM4XX
help
This option enables the ethernet driver for NPCM4XX family of
processors.
Say y if you wish to use ethernet on NPCM4XX MCU.

config ETH_NPCM4XX_RX_THREAD_STACK_SIZE
int "RX thread stack size"
default 4096
help
RX thread stack size

config ETH_NPCM4XX_RX_THREAD_PRIO
int "RX thread priority"
default 3
help
RX thread priority

config ETH_NPCM4XX_PHY_ADDRESS
int "Phy address"
default 1
help
The phy address to use.

config ETH_NPCM4XX_RANDOM_MAC
bool "Random MAC address"
depends on ENTROPY_GENERATOR
default y
help
Generate a random MAC address dynamically.

if !ETH_NPCM4XX_RANDOM_MAC

config ETH_NPCM4XX_MAC3
hex "MAC Address Byte 3"
default 0
range 0 0xff
help
This is the byte 3 of the MAC address.

config ETH_NPCM4XX_MAC4
hex "MAC Address Byte 4"
default 0
range 0 0xff
help
This is the byte 4 of the MAC address.

config ETH_NPCM4XX_MAC5
hex "MAC Address Byte 5"
default 0
range 0 0xff
help
This is the byte 5 of the MAC address.

endif # !ETH_NPCM4XX_RANDOM_MAC

config ETH_NPCM4XX_CARRIER_CHECK_RX_IDLE_TIMEOUT_MS
int "Carrier check timeout period (ms)"
default 500
range 100 30000
help
Set the RX idle timeout period in milliseconds after which the
PHY's carrier status is re-evaluated.
Loading

0 comments on commit 13f61bc

Please sign in to comment.