Skip to content
Open
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
24 changes: 24 additions & 0 deletions boards/microchip/sam/sama7g54_ek/sama7g54_ek.dts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,16 @@
bias-pull-up;
};
};

pinctrl_usba_vbus_det: usba_vbus_det {
pinmux = <PIN_PD11__GPIO>;
bias-disable;
};

pinctrl_usbb_vbus_det: usbb_vbus_det {
pinmux = <PIN_PC12__GPIO>;
bias-disable;
};
};

&pit64b0 {
Expand Down Expand Up @@ -408,3 +418,17 @@
&trng {
status = "okay";
};

zephyr_udc0: &udphsa {
vbus-gpios = <&piod 11 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usba_vbus_det>;
status = "okay";
};

&udphsb {
vbus-gpios = <&pioc 12 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usbb_vbus_det>;
status = "disabled";
};
1 change: 1 addition & 0 deletions boards/microchip/sam/sama7g54_ek/sama7g54_ek.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ supported:
- sdhc
- shell
- uart
- udc
vendor: microchip
1 change: 1 addition & 0 deletions drivers/usb/udc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ zephyr_library_sources_ifdef(CONFIG_UDC_VIRTUAL udc_virtual.c)
zephyr_library_sources_ifdef(CONFIG_UDC_SMARTBOND udc_smartbond.c)
zephyr_library_sources_ifdef(CONFIG_UDC_STM32 udc_stm32.c)
zephyr_library_sources_ifdef(CONFIG_UDC_IT82XX2 udc_it82xx2.c)
zephyr_library_sources_ifdef(CONFIG_UDC_MCHP_SAM udc_mchp_sam.c)
zephyr_library_sources_ifdef(CONFIG_UDC_NXP_EHCI udc_mcux_ehci.c)
zephyr_library_sources_ifdef(CONFIG_UDC_NXP_IP3511 udc_mcux_ip3511.c)
zephyr_library_sources_ifdef(CONFIG_UDC_NUMAKER udc_numaker.c)
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/udc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ source "drivers/usb/udc/Kconfig.virtual"
source "drivers/usb/udc/Kconfig.smartbond"
source "drivers/usb/udc/Kconfig.stm32"
source "drivers/usb/udc/Kconfig.it82xx2"
source "drivers/usb/udc/Kconfig.mchp_sam"
source "drivers/usb/udc/Kconfig.mcux"
source "drivers/usb/udc/Kconfig.numaker"
source "drivers/usb/udc/Kconfig.rpi_pico"
Expand Down
45 changes: 45 additions & 0 deletions drivers/usb/udc/Kconfig.mchp_sam
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (C) 2025 Microchip Technology Inc. and its subsidiaries
#
# SPDX-License-Identifier: Apache-2.0
#

config UDC_MCHP_SAM
bool "Microchip SAM UDPHS USB Device High Speed Port"
default y
depends on DT_HAS_MICROCHIP_SAM_UDPHS_ENABLED
select CACHE_MANAGEMENT
select PINCTRL
select GPIO
select SYS_MEM_BLOCKS
select EVENTS
select UDC_DRIVER_HAS_HIGH_SPEED_SUPPORT
help
Enable the Microchip SAM UDPHS driver.

if UDC_MCHP_SAM

config UDC_MCHP_SAM_STACK_SIZE
int "UDC controller driver internal thread stack size"
default 1024
help
Device controller driver internal thread stack size.

config UDC_MCHP_SAM_THREAD_PRI
int "UDC controller driver thread priority"
default 8
help
Device controller driver thread priority.

config UDC_MCHP_SAM_BURST_LOCK
bool "Lock bus access for maximum bandwidth"
help
USB packets system data bursts will be locked for
maximum optimization of the bus bandwidth usage.
Comment on lines +36 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what this really means. From code it seems that you set some bit. Is it essentially affecting DMA operation/memory access arbitrage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is a chip related feature, for more details please refer to the datasheet, see bit BURST_LCK in register UDPHS_DMACONTROL.
This will allow the UDPHS DMA channel has max burst length when accessing the bus.

And I made a switch for this feature in the Kconfig, customer can enable it for higher USB bandwidth under heavy system load.


config UDC_MCHP_SAM_RAW_DEBUG
bool "UDC controller driver raw debug"
depends on LOG_MODE_IMMEDIATE
help
Enable driver raw debugging for short and real-time log outputs.
Comment on lines +39 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this option. No idea what you are meaning with "raw debugging" or "real-time log outputs", but there is no reason to overwrite LOG_DBG with printk() neither when using LOG_MODE_IMMEDIATE nor without it, or using LOG_MODE_IMMEDIATE.


endif # UDC_MCHP_SAM
7 changes: 7 additions & 0 deletions drivers/usb/udc/udc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,13 @@ int udc_ctrl_submit_status(const struct device *dev,
return udc_submit_ep_event(dev, buf, 0);
}

bool udc_ctrl_stage_is_setup(const struct device *dev)
{
struct udc_data *data = dev->data;

return data->stage == CTRL_PIPE_STAGE_SETUP ? true : false;
}

bool udc_ctrl_stage_is_data_out(const struct device *dev)
{
struct udc_data *data = dev->data;
Expand Down
9 changes: 9 additions & 0 deletions drivers/usb/udc/udc_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ static inline uint16_t udc_data_stage_length(const struct net_buf *const buf)
return sys_le16_to_cpu(setup->wLength);
}

/**
* @brief Checks whether the current control transfer stage is Setup Stage
*
* @param[in] dev Pointer to device struct of the driver instance
*
* @return true if stage is Setup Stage
*/
bool udc_ctrl_stage_is_setup(const struct device *dev);

/**
* @brief Checks whether the current control transfer stage is Data Stage OUT
*
Expand Down
Loading