Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bf1a660
usb: host: add host status to the host context
Aug 8, 2025
958d08f
usb: host: add copyright notice to linker script
Oct 23, 2025
bd7462c
usb: host: class: implement more of the class/data struct fields
Aug 14, 2025
789795a
usb: host: introduce wrappers to access the class function pointers
Aug 15, 2025
210673d
usb: host: introduce usbh_class with init/remove functions
Aug 15, 2025
750162e
usb: uvc: move the header definition to include/
Jul 25, 2025
1c89dc3
tests: usb: host: test basic API functionality
Sep 11, 2025
dc61cc2
tests: usb: host: test basic API functionality
Sep 11, 2025
949e792
usb: uvc: move the header definition to include/
Jul 25, 2025
c9dd480
uvc: device: move helper functions to a common directory
Aug 17, 2025
764c816
usb: uvc: common: correct the size for UVC_PU_CONTRAST_CONTROL
Nov 27, 2025
a58ea38
usb: host: uvc: placeholder implementation
Jul 26, 2025
a655736
tests: usb: uvc: connect USB device and host via UVB
Jul 24, 2025
6396988
usb: device_next: uvc: fix public API include
Oct 29, 2025
d235b65
usb: host: device: Read descriptor after setting device address
santhosh-c-c Nov 13, 2025
c2b4bde
subsys: usb: host: support multiple devices under hub
AidenHu Nov 18, 2025
ece50f3
subsys: usb: host: remove root member for usbh_context
AidenHu Nov 19, 2025
4596079
drivers: uhc: use correct endpoint type and interval
AidenHu Nov 18, 2025
d22fe3b
drivers: uhc: correct interval usage for usb xfer
AidenHu Nov 18, 2025
3a73f60
drivers: uhc: set right value for pipe by xfer's mps
AidenHu Nov 19, 2025
7bf8093
subsys: usb: host: refine connect/disconnect handling
AidenHu Nov 26, 2025
44fbdfb
usb: host: class: Add CDC ECM class support for USBH
santhosh-c-c Oct 29, 2025
42741a1
dts: bindings: usb: Add DT bindings for USB Host CDC ECM class
santhosh-c-c Oct 29, 2025
a01c220
usb: add common directory for shared host/device support
santhosh-c-c Oct 29, 2025
563b297
Revert "usb: add common directory for shared host/device support"
D-Veda Dec 1, 2025
c3a18fa
subsys: usb: host: add missing usbh_class.h include
D-Veda Dec 1, 2025
948c836
usb: host: ch9: Add string descriptor request helper function
D-Veda Dec 1, 2025
0b5b4c3
usb: class: cdc: Add ECM statistics and notification definitions
D-Veda Dec 1, 2025
b191fed
usb: host: class: cdc_ecm: Rewrite CDC-ECM host driver implementation
D-Veda Dec 1, 2025
2e9f7ea
dts: bindings: usb: Rename CDC-ECM host binding file
D-Veda Dec 1, 2025
15a9ae5
samples: net: dhcpv4_client: Add USB host stack initialization support
D-Veda Dec 1, 2025
7c3e00d
samples: net: dhcpv4_client: Add board configuration for rd_rw612_bga
D-Veda Dec 1, 2025
0d7f337
usb: host: class: cdc_ecm: Fix incorrect Ethernet API calls
D-Veda Dec 3, 2025
3b13943
usb: host: class: cdc_ecm: Simplify connection speed notification
D-Veda Dec 3, 2025
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
8 changes: 8 additions & 0 deletions drivers/usb/uhc/uhc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
const struct uhc_api *api = dev->api;
struct uhc_transfer *xfer = NULL;
uint16_t mps;
uint16_t interval;
uint8_t type;

api->lock(dev);

Expand All @@ -109,6 +111,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
}

if (ep_idx == 0) {
interval = 0;
type = USB_EP_TYPE_CONTROL;
mps = udev->dev_desc.bMaxPacketSize0;
} else {
struct usb_ep_descriptor *ep_desc;
Expand All @@ -125,6 +129,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
}

mps = ep_desc->wMaxPacketSize;
interval = ep_desc->bInterval;
type = ep_desc->bmAttributes & USB_EP_TRANSFER_TYPE_MASK;
}

LOG_DBG("Allocate xfer, ep 0x%02x mps %u cb %p", ep, mps, cb);
Expand All @@ -137,6 +143,8 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
memset(xfer, 0, sizeof(struct uhc_transfer));
xfer->ep = ep;
xfer->mps = mps;
xfer->interval = interval;
xfer->type = type;
xfer->udev = udev;
xfer->cb = cb;
xfer->priv = cb_priv;
Expand Down
18 changes: 7 additions & 11 deletions drivers/usb/uhc/uhc_mcux_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,9 @@ static usb_host_pipe_handle uhc_mcux_check_hal_ep(const struct device *dev,
}
}

/* TODO: need to check endpoint type too */
if (mcux_ep != NULL &&
if (mcux_ep != NULL && mcux_ep->pipeType == xfer->type &&
(mcux_ep->maxPacketSize != xfer->mps ||
mcux_ep->interval != xfer->interval)) {
priv->mcux_eps_interval[i] != xfer->interval)) {
/* re-initialize the ep */
status = priv->mcux_if->controllerClosePipe(priv->mcux_host.controllerHandle,
mcux_ep);
Expand All @@ -256,6 +255,7 @@ static usb_host_pipe_handle uhc_mcux_check_hal_ep(const struct device *dev,

uhc_mcux_lock(dev);
priv->mcux_eps[i] = NULL;
priv->mcux_eps_interval[i] = 0;
uhc_mcux_unlock(dev);
mcux_ep = NULL;
}
Expand All @@ -280,21 +280,16 @@ usb_host_pipe_t *uhc_mcux_init_hal_ep(const struct device *dev, struct uhc_trans
/* USB_HostHelperGetPeripheralInformation uses this value as first parameter */
pipe_init.devInstance = xfer->udev;
pipe_init.nakCount = USB_HOST_CONFIG_MAX_NAK;
pipe_init.maxPacketSize = xfer->mps;
pipe_init.maxPacketSize = USB_MPS_EP_SIZE(xfer->mps);
pipe_init.endpointAddress = USB_EP_GET_IDX(xfer->ep);
pipe_init.direction = USB_EP_GET_IDX(xfer->ep) == 0 ? USB_OUT :
USB_EP_GET_DIR(xfer->ep) ? USB_IN : USB_OUT;
/* Current Zephyr Host stack is experimental, the endpoint's interval,
* 'number per uframe' and the endpoint type cannot be got yet.
*/
pipe_init.numberPerUframe = 0; /* TODO: need right way to implement it. */
pipe_init.numberPerUframe = USB_MPS_ADDITIONAL_TRANSACTIONS(xfer->mps);
pipe_init.interval = xfer->interval;
/* TODO: need right way to implement it. */
if (pipe_init.endpointAddress == 0) {
pipe_init.pipeType = USB_ENDPOINT_CONTROL;
} else {
pipe_init.pipeType = USB_ENDPOINT_BULK;
}
pipe_init.pipeType = xfer->type;

status = priv->mcux_if->controllerOpenPipe(priv->mcux_host.controllerHandle,
(usb_host_pipe_handle *)&mcux_ep, &pipe_init);
Expand All @@ -314,6 +309,7 @@ usb_host_pipe_t *uhc_mcux_init_hal_ep(const struct device *dev, struct uhc_trans
for (i = 0; i < USB_HOST_CONFIG_MAX_PIPES; i++) {
if (priv->mcux_eps[i] == NULL) {
priv->mcux_eps[i] = mcux_ep;
priv->mcux_eps_interval[i] = xfer->interval;
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/uhc/uhc_mcux_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct uhc_mcux_data {
const usb_host_controller_interface_t *mcux_if;
/* TODO: Maybe make it to link with udev->ep_in and udev->ep_out */
usb_host_pipe_t *mcux_eps[USB_HOST_CONFIG_MAX_PIPES];
uint16_t mcux_eps_interval[USB_HOST_CONFIG_MAX_PIPES];
usb_host_instance_t mcux_host;
struct k_thread drv_stack_data;
uint8_t controller_id; /* MCUX hal controller id, 0xFF is invalid value */
Expand Down
16 changes: 16 additions & 0 deletions dts/bindings/usb/zephyr,cdc-ecm-host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2025 NXP
# Copyright (c) 2025 Linumiz GmbH
# SPDX-License-Identifier: Apache-2.0

description: |
USB CDC Ethernet Control Model (CDC-ECM) host instance.
Each CDC-ECM instance added to the USB Host Controller (UHC) node
will be visible as a new ethernet interface from Zephyr point of
view.
As soon as a ethernet interface is connected to USB this device will
be usable by the application as a ethernet interface device,
following the networking API.

compatible: "zephyr,cdc-ecm-host"

include: base.yaml
15 changes: 15 additions & 0 deletions dts/bindings/usb/zephyr,uvc-host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

description: |
USB Video Class (UVC) host instance.

Each UVC instance added to the USB Host Controller (UHC) node will be visible
as a new camera from Zephyr point of view.

as soon as a camera is connected to USB this device will be usable by the application as a
video device, following the video API.

compatible: "zephyr,uvc-host"

include: base.yaml
2 changes: 2 additions & 0 deletions include/zephyr/drivers/usb/uhc.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ struct uhc_transfer {
struct net_buf *buf;
/** Endpoint to which request is associated */
uint8_t ep;
/** Endpoint type */
uint8_t type;
/** Maximum packet size */
uint16_t mps;
/** Interval, used for periodic transfers only */
Expand Down
53 changes: 52 additions & 1 deletion include/zephyr/usb/class/usb_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/*
* Copyright (c) 2017 PHYTEC Messtechnik GmbH
* Copyright (c) 2025 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -74,8 +75,9 @@
#define USB_CDC_AUX_JACK_HOOK_STATE 0x08
#define USB_CDC_RING_DETECT 0x09
#define USB_CDC_SERIAL_STATE 0x20
#define USB_CDC_CALL_STATE_CHANGE 0x28
#define USB_CDC_LINE_STATE_CHANGE 0x23
#define USB_CDC_CALL_STATE_CHANGE 0x28
#define USB_CDC_CONNECTION_SPEED_CHANGE 0x2A

/**
* @brief PSTN UART State Bitmap Values
Expand Down Expand Up @@ -158,6 +160,10 @@
#define GET_CRC_MODE 0x89
#define SET_CRC_MODE 0x8A

/** Ethernet Power Management Pattern Activation */
#define ETHERNET_PM_PATTERN_ACTIVE_TRUE 0x0001
#define ETHERNET_PM_PATTERN_ACTIVE_FALSE 0x0000

/** Ethernet Packet Filter Bitmap */
#define PACKET_TYPE_MULTICAST 0x10
#define PACKET_TYPE_BROADCAST 0x08
Expand Down Expand Up @@ -229,6 +235,39 @@
uint8_t bNumberPowerFilters;
} __packed;

/** Ethernet Statistics Feature Selector */
enum cdc_ecm_ethernet_stats {
XMIT_OK = 0x01, /* Frames transmitted without errors */
RCV_OK = 0x02, /* Frames received without errors */
XMIT_ERROR = 0x03, /* Frames not transmitted, or transmitted with */
RCV_ERROR = 0x04, /* Frames received with errors */
RCV_NO_BUFFER = 0x05, /* Frames missed, no buffers */
DIRECTED_BYTES_XMIT = 0x06, /* Directed bytes transmitted without errors */
DIRECTED_FRAMES_XMIT = 0x07, /* Directed frames transmitted without errors */
MULTICAST_BYTES_XMIT = 0x08, /* Multicast bytes transmitted without errors */
MULTICAST_FRAMES_XMIT = 0x09, /* Multicast frames transmitted without errors */
BROADCAST_BYTES_XMIT = 0x0A, /* Broadcast bytes transmitted without errors */
BROADCAST_FRAMES_XMIT = 0x0B, /* Broadcast frames transmitted without errors */
DIRECTED_BYTES_RCV = 0x0C, /* Directed bytes received without errors */
DIRECTED_FRAMES_RCV = 0x0D, /* Directed frames received without errors */
MULTICAST_BYTES_RCV = 0x0E, /* Multicast bytes received without errors */
MULTICAST_FRAMES_RCV = 0x0F, /* Multicast frames received without errors */
BROADCAST_BYTES_RCV = 0x10, /* Broadcast bytes received without errors */
BROADCAST_FRAMES_RCV = 0x11, /* Broadcast frames received without errors */
RCV_CRC_ERROR = 0x12, /* Frames received with circular redundancy check (CRC) or frame check sequence (FCS) error */

Check warning on line 257 in include/zephyr/usb/class/usb_cdc.h

View workflow job for this annotation

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

LONG_LINE_COMMENT

include/zephyr/usb/class/usb_cdc.h:257 line length of 133 exceeds 100 columns
TRANSMIT_QUEUE_LENGTH = 0x13, /* Length of transmit queue */
RCV_ERROR_ALIGNMENT = 0x14, /* Frames received with alignment error */
XMIT_ONE_COLLISION = 0x15, /* Frames transmitted with one collision */
XMIT_MORE_COLLISIONS = 0x16, /* Frames transmitted with more than one collision */
XMIT_DEFERRED = 0x17, /* Frames transmitted after deferral */
XMIT_MAX_COLLISIONS = 0x18, /* Frames not transmitted due to collisions */
RCV_OVERRUN = 0x19, /* Frames not received due to overrun */
XMIT_UNDERRUN = 0x1A, /* Frames not transmitted due to underrun */
XMIT_HEARTBEAT_FAILURE = 0x1B, /* Frames transmitted with heartbeat failure */
XMIT_TIMES_CRS_LOST = 0x1C, /* Times carrier sense signal lost during transmission */
XMIT_LATE_COLLISIONS = 0x1D, /* Late collisions detected */
};

/** Ethernet Network Control Model (NCM) Descriptor */
struct cdc_ncm_descriptor {
uint8_t bFunctionLength;
Expand All @@ -238,4 +277,16 @@
uint8_t bmNetworkCapabilities;
} __packed;

/** CDC Notification Packet */
struct cdc_notification_packet {
union {
uint8_t bmRequestType;
struct usb_req_type_field RequestType;
} __packed;
uint8_t bNotification;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
} __packed;

#endif /* ZEPHYR_INCLUDE_USB_CLASS_USB_CDC_H_ */
1 change: 1 addition & 0 deletions include/zephyr/usb/class/usbd_uvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define ZEPHYR_INCLUDE_USB_CLASS_USBD_UVC_H

#include <zephyr/device.h>
#include <zephyr/drivers/video.h>

/**
* @brief USB Video Class (UVC) device API
Expand Down
Loading
Loading