Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions boards/qemu/riscv32/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@

if BOARD_QEMU_RISCV32

if NETWORKING

choice NET_QEMU_NETWORKING
default NET_QEMU_USER
endchoice

configdefault USB_HOST_STACK
default y

configdefault USBH_CDC_ECM_CLASS
default y

endif # NETWORKING

configdefault NET_DRIVERS
default n

configdefault NET_L2_ETHERNET
default y

# Use thread local storage by default so that this feature gets more CI coverage.
config THREAD_LOCAL_STORAGE
default y
Expand Down
2 changes: 2 additions & 0 deletions boards/qemu/riscv32/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ set(QEMU_FLAGS_${ARCH}
-cpu ${qemu_riscv_cpu}
)

set(QEMU_PCI_OHCI_FLAGS addr=2.0)

include(${ZEPHYR_BASE}/boards/common/qemu.board.cmake)
14 changes: 14 additions & 0 deletions boards/qemu/riscv32/qemu_riscv32.dts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: Apache-2.0 */

Check warning on line 1 in boards/qemu/riscv32/qemu_riscv32.dts

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Copyright missing

boards/qemu/riscv32/qemu_riscv32.dts:1 File has no SPDX-FileCopyrightText header, consider adding one. Check SPDX headers and copyright lines with the reuse Python API.

/dts-v1/;

Expand All @@ -9,9 +9,23 @@
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,sram = &ram0;
zephyr,uhc = &zephyr_uhc0;
};
};

&uart0 {
status = "okay";
};

&pcie {
zephyr_uhc0: pcie@2,0 {
compatible = "generic-ohci";
reg = <0x1000 0 0 0 0>;
vendor-id = <0x106b>;
device-id = <0x003f>;
interrupts = <1>;
interrupt-parent = <&pcie>;
maximum-speed = "full-speed";
status = "okay";
};
};
14 changes: 14 additions & 0 deletions boards/qemu/riscv32/qemu_riscv32_qemu_virt_riscv32_smp.dts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: Apache-2.0 */

Check warning on line 1 in boards/qemu/riscv32/qemu_riscv32_qemu_virt_riscv32_smp.dts

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Copyright missing

boards/qemu/riscv32/qemu_riscv32_qemu_virt_riscv32_smp.dts:1 File has no SPDX-FileCopyrightText header, consider adding one. Check SPDX headers and copyright lines with the reuse Python API.

/dts-v1/;

Expand All @@ -9,9 +9,23 @@
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,sram = &ram0;
zephyr,uhc = &zephyr_uhc0;
};
};

&uart0 {
status = "okay";
};

&pcie {
zephyr_uhc0: pcie@2,0 {
compatible = "generic-ohci";
reg = <0x1000 0 0 0 0>;
vendor-id = <0x106b>;
device-id = <0x003f>;
interrupts = <1>;
interrupt-parent = <&pcie>;
maximum-speed = "full-speed";
status = "okay";
};
};
34 changes: 34 additions & 0 deletions cmake/emu/qemu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,40 @@ else()
add_custom_target(qemu_nvme_disk)
endif()

if(CONFIG_UHC_OHCI_PCI)
list(APPEND QEMU_EXTRA_FLAGS
-device pci-ohci,${QEMU_PCI_OHCI_FLAGS}
)
endif()

# If we are using a suitable ethernet driver inside qemu, then these options
# must be set, otherwise a zephyr instance cannot receive any network packets.
# The Qemu supported ethernet driver should define CONFIG_ETH_NIC_MODEL
# string that tells what nic model Qemu should use.
if(CONFIG_QEMU_TARGET)
if((CONFIG_NET_QEMU_ETHERNET OR CONFIG_NET_QEMU_USER) AND NOT CONFIG_ETH_NIC_MODEL)
message(FATAL_ERROR "
No Qemu ethernet driver configured!
Enable Qemu supported ethernet driver like e1000 at drivers/ethernet"
)
elseif(CONFIG_NET_QEMU_ETHERNET)
if(CONFIG_ETH_QEMU_EXTRA_ARGS)
set(NET_QEMU_ETH_EXTRA_ARGS ",${CONFIG_ETH_QEMU_EXTRA_ARGS}")
endif()
list(APPEND QEMU_EXTRA_FLAGS
-netdev tap,id=n1,script=no,downscript=no,ifname=${CONFIG_ETH_QEMU_IFACE_NAME}${NET_QEMU_ETH_EXTRA_ARGS} -device ${CONFIG_ETH_NIC_MODEL},netdev=n1
)
elseif(CONFIG_NET_QEMU_USER)
list(APPEND QEMU_EXTRA_FLAGS
-netdev user,id=n1,${CONFIG_NET_QEMU_USER_EXTRA_ARGS} -device ${CONFIG_ETH_NIC_MODEL},netdev=n1
)
else()
list(APPEND QEMU_EXTRA_FLAGS
-net none
)
endif()
endif()

if(NOT QEMU_PIPE)
set(QEMU_PIPE_COMMENT "\nTo exit from QEMU enter: 'CTRL+a, x'\n")
endif()
Expand Down
28 changes: 0 additions & 28 deletions cmake/modules/kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,34 +184,6 @@ foreach(dir ${BOARD_DIRECTORIES})
include(${dir}/board.cmake OPTIONAL)
endforeach()

# If we are using a suitable ethernet driver inside qemu, then these options
# must be set, otherwise a zephyr instance cannot receive any network packets.
# The Qemu supported ethernet driver should define CONFIG_ETH_NIC_MODEL
# string that tells what nic model Qemu should use.
if(CONFIG_QEMU_TARGET)
if((CONFIG_NET_QEMU_ETHERNET OR CONFIG_NET_QEMU_USER) AND NOT CONFIG_ETH_NIC_MODEL)
message(FATAL_ERROR "
No Qemu ethernet driver configured!
Enable Qemu supported ethernet driver like e1000 at drivers/ethernet"
)
elseif(CONFIG_NET_QEMU_ETHERNET)
if(CONFIG_ETH_QEMU_EXTRA_ARGS)
set(NET_QEMU_ETH_EXTRA_ARGS ",${CONFIG_ETH_QEMU_EXTRA_ARGS}")
endif()
list(APPEND QEMU_FLAGS_${ARCH}
-nic tap,model=${CONFIG_ETH_NIC_MODEL},script=no,downscript=no,ifname=${CONFIG_ETH_QEMU_IFACE_NAME}${NET_QEMU_ETH_EXTRA_ARGS}
)
elseif(CONFIG_NET_QEMU_USER)
list(APPEND QEMU_FLAGS_${ARCH}
-nic user,model=${CONFIG_ETH_NIC_MODEL},${CONFIG_NET_QEMU_USER_EXTRA_ARGS}
)
else()
list(APPEND QEMU_FLAGS_${ARCH}
-net none
)
endif()
endif()

# General purpose Zephyr target.
# This target can be used for custom zephyr settings that needs to be used elsewhere in the build system
#
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/uhc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ zephyr_library()

zephyr_library_sources(uhc_common.c)
zephyr_library_sources_ifdef(CONFIG_UHC_MAX3421E uhc_max3421e.c)
zephyr_library_sources_ifdef(CONFIG_UHC_OHCI uhc_ohci.c)
zephyr_library_sources_ifdef(CONFIG_UHC_VIRTUAL uhc_virtual.c)
zephyr_library_sources_ifdef(CONFIG_UHC_NXP_EHCI uhc_mcux_common.c uhc_mcux_ehci.c)
zephyr_library_sources_ifdef(CONFIG_UHC_NXP_KHCI uhc_mcux_common.c uhc_mcux_khci.c)
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/uhc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module-str = uhc drv
source "subsys/logging/Kconfig.template.log_config"

source "drivers/usb/uhc/Kconfig.max3421e"
source "drivers/usb/uhc/Kconfig.ohci"
source "drivers/usb/uhc/Kconfig.virtual"
source "drivers/usb/uhc/Kconfig.mcux"

Expand Down
45 changes: 45 additions & 0 deletions drivers/usb/uhc/Kconfig.ohci
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
# SPDX-License-Identifier: Apache-2.0

config UHC_OHCI
bool "Generic OHCI USB host controller driver"
default y
depends on DT_HAS_GENERIC_OHCI_ENABLED
depends on !64BIT
select EVENTS
help
Generic OHCI USB host controller driver for any OHCI
controller (OpenHCI 1.0a compatible). Only supported on
32 bit, as OHCI only uses 32 bit registers for addresses.

if UHC_OHCI

config UHC_OHCI_PCI
bool
default y
depends on $(dt_compat_on_bus,$(DT_COMPAT_GENERIC_OHCI),pcie)
select PCIE
select DYNAMIC_INTERRUPTS if !PCIE_CONTROLLER

config UHC_OHCI_BULK_SLOTS
int "Number of concurrent bulk/interrupt transfer slots"
range 1 8
default 3
help
Number of concurrently active bulk/interrupt transfer slots. One slot
is always reserved for control transfers. Each additional slot allows
one more bulk or interrupt endpoint to stay posted simultaneously
(e.g. both IN and OUT for CDC-ECM data plus the interrupt notification
endpoint). Memory cost is one ED plus UHC_OHCI_MAX_TDS transfer
descriptors per slot.

config UHC_OHCI_MAX_TDS
int "Maximum TDs per transfer slot"
range 4 128
default 64
help
Maximum number of OHCI transfer descriptors per slot. The driver
allocates one pool of this size for the control slot and for each
bulk/interrupt slot (see UHC_OHCI_BULK_SLOTS).

endif # UHC_OHCI
Loading
Loading