Skip to content

Commit

Permalink
Merge pull request zephyrproject-rtos#10 from westonrobot/patch-upstr…
Browse files Browse the repository at this point in the history
…eam-tag-v2.7.0-can_native_posix

Patch upstream tag v2.7.0 can native posix
  • Loading branch information
rdu-weston authored Jan 10, 2022
2 parents 6f989fe + 338905f commit 351d12b
Show file tree
Hide file tree
Showing 11 changed files with 672 additions and 10 deletions.
3 changes: 3 additions & 0 deletions boards/posix/native_posix/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ config NET_L2_ETHERNET
config ETH_NATIVE_POSIX
default y if NET_L2_ETHERNET

config CAN_NATIVE_POSIX
default y if NET_SOCKETS_CAN

endif # NETWORKING

config FAKE_ENTROPY_NATIVE_POSIX
Expand Down
20 changes: 20 additions & 0 deletions boards/posix/native_posix/native_posix.dts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@
current-speed = <0>;
};

can1: can_1 {
status = "okay";
compatible = "zephyr,native-posix-can";
label = "CAN_1";
/* Dummy bus-speed entry to comply with can
* DTS binding
*/
bus-speed = <500000>;
};

can2: can_2 {
status = "okay";
compatible = "zephyr,native-posix-can";
label = "CAN_2";
/* Dummy bus-speed entry to comply with can
* DTS binding
*/
bus-speed = <500000>;
};

rng: rng {
status = "okay";
compatible = "zephyr,native-posix-rng";
Expand Down
11 changes: 11 additions & 0 deletions drivers/can/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ zephyr_library_sources_ifdef(CONFIG_CAN_RCAR can_rcar.c)
zephyr_library_sources_ifdef(CONFIG_USERSPACE can_handlers.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SHELL can_shell.c)
zephyr_library_sources_ifdef(CONFIG_CAN_NET can_net.c)

if(CONFIG_CAN_NATIVE_POSIX)
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/l2)
zephyr_library_compile_definitions(NO_POSIX_CHEATS)
zephyr_library_compile_definitions(_BSD_SOURCE)
zephyr_library_compile_definitions(_DEFAULT_SOURCE)
zephyr_library_sources(
can_native_posix.c
can_native_posix_adapt.c
)
endif()
1 change: 1 addition & 0 deletions drivers/can/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ source "drivers/can/Kconfig.mcan"
source "drivers/can/Kconfig.rcar"
source "drivers/can/Kconfig.loopback"
source "drivers/can/Kconfig.net"
source "drivers/can/Kconfig.native_posix"

endif # CAN
71 changes: 71 additions & 0 deletions drivers/can/Kconfig.native_posix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Native posix CAN configuration options

# Copyright (c) 2019 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

config CAN_NATIVE_POSIX
bool "native_posix CAN Driver"
depends on ARCH_POSIX && NETWORKING
help
Enable native_posix CAN driver

if CAN_NATIVE_POSIX

config CAN_MAX_FILTER
int "Maximum number of concurrent active filters"
depends on CAN_NATIVE_POSIX
default 32
range 1 56
help
Defines the array size of the callback/msgq pointers.
Must be at least the size of concurrent reads.

## Interface 1
config CAN_NATIVE_POSIX_INTERFACE_1_ENABLED
bool "CANBUS interface 1"
default y
depends on CAN_NATIVE_POSIX
help
This option enables the CANBUS network interface for Native POSIX board.

config CAN_NATIVE_POSIX_INTERFACE_1_NAME
string "CANBUS interface 1 name on Linux side"
depends on CAN_NATIVE_POSIX_INTERFACE_1_ENABLED
default "vcan0"
help
This option sets the CANBUS network interface 1 name in host system.

config CAN_NATIVE_POSIX_INTERFACE_1_SOCKETCAN_NAME
string "Network device name"
depends on CAN_NATIVE_POSIX_INTERFACE_1_ENABLED
default "SOCKET_CAN_1"
help
Name of the network device driver for SocketCAN.

## Interface 2
config CAN_NATIVE_POSIX_INTERFACE_2_ENABLED
bool "CANBUS interface 2"
default n
depends on CAN_NATIVE_POSIX
help
This option enables the CANBUS network interface for Native POSIX board.

if CAN_NATIVE_POSIX_INTERFACE_2_ENABLED

config CAN_NATIVE_POSIX_INTERFACE_2_NAME
string "CANBUS interface 2 name on Linux side"
depends on CAN_NATIVE_POSIX_INTERFACE_2_ENABLED
default "vcan1"
help
This option sets the CANBUS network interface 2 name in host system.

config CAN_NATIVE_POSIX_INTERFACE_2_SOCKETCAN_NAME
string "Network device name"
depends on CAN_NATIVE_POSIX_INTERFACE_2_ENABLED
default "SOCKET_CAN_2"
help
Name of the network device driver for SocketCAN.

endif #CAN_NATIVE_POSIX_INTERFACE_2_ENABLED

endif #CAN_NATIVE_POSIX
Loading

0 comments on commit 351d12b

Please sign in to comment.