Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: uhc: implement UHC shim driver for NXP KHCI and EHCI controller #77973

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions boards/nxp/frdm_k22f/frdm_k22f.dts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ zephyr_udc0: &usbotg {
num-bidir-endpoints = <8>;
};

zephyr_uhc0: &usbh {
status = "okay";
};

&gpioa {
status = "okay";
};
Expand Down
18 changes: 18 additions & 0 deletions boards/nxp/lpcxpresso55s28/lpcxpresso55s28-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@
};
};

pinmux_usbhfs: pinmux_usbhfs {
group0 {
pinmux = <USB0_VBUS_PIO0_22>,
<USB0_OVERCURRENTN_PIO0_28>,
<USB0_PORTPWRN_PIO1_12>;
bias-pull-up;
slew-rate = "standard";
};
};

pinmux_usbhhs: pinmux_usbhhs {
group0 {
pinmux = <USB1_OVERCURRENTN_PIO1_30>,
<USB1_PORTPWRN_PIO1_29>;
bias-pull-up;
slew-rate = "standard";
};
};
};
20 changes: 20 additions & 0 deletions boards/nxp/lpcxpresso55s28/lpcxpresso55s28.dts
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,23 @@
zephyr_udc0: &usbhs {
status = "okay";
};

zephyr_uhc0: &usbhfs {
pinctrl-0 = <&pinmux_usbhfs>;
pinctrl-names = "default";
status = "okay";
};

zephyr_uhc1: &usbhhs {
pinctrl-0 = <&pinmux_usbhhs>;
pinctrl-names = "default";
status = "okay";
phy_handle = <&usbphy1>;
};

&usbphy1 {
status = "okay";
tx-d-cal = <5>;
tx-cal-45-dp-ohms = <10>;
tx-cal-45-dm-ohms = <10>;
};
21 changes: 20 additions & 1 deletion boards/nxp/lpcxpresso55s69/lpcxpresso55s69-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* NOTE: File generated by gen_board_pinctrl.py
* from LPCXpresso55S69.mex
*
* Copyright 2022 NXP
* Copyright 2022,2024 NXP
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -108,4 +108,23 @@
slew-rate = "standard";
};
};

pinmux_usbhfs: pinmux_usbhfs {
group0 {
pinmux = <USB0_VBUS_PIO0_22>,
<USB0_OVERCURRENTN_PIO0_28>,
<USB0_PORTPWRN_PIO1_12>;
bias-pull-up;
slew-rate = "standard";
};
};

pinmux_usbhhs: pinmux_usbhhs {
group0 {
pinmux = <USB1_OVERCURRENTN_PIO1_30>,
<USB1_PORTPWRN_PIO1_29>;
bias-pull-up;
slew-rate = "standard";
};
};
};
13 changes: 13 additions & 0 deletions boards/nxp/lpcxpresso55s69/lpcxpresso55s69_lpc55s69_cpu0.dts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ zephyr_udc0: &usbhs {
phy_handle = <&usbphy1>;
};

zephyr_uhc0: &usbhfs {
pinctrl-0 = <&pinmux_usbhfs>;
pinctrl-names = "default";
status = "okay";
};

zephyr_uhc1: &usbhhs {
pinctrl-0 = <&pinmux_usbhhs>;
pinctrl-names = "default";
status = "okay";
phy_handle = <&usbphy1>;
};

&usbphy1 {
status = "okay";
tx-d-cal = <5>;
Expand Down
24 changes: 24 additions & 0 deletions boards/nxp/mimxrt1050_evk/mimxrt1050_evk.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@ zephyr_udc0: &usb1 {
status = "okay";
};

zephyr_uhc0: &usbh1 {
status = "okay";
phy_handle = <&usbphy1>;
};

zephyr_uhc1: &usbh2 {
status = "okay";
phy_handle = <&usbphy2>;
};

&usbphy1 {
status = "okay";
tx-d-cal = <12>;
tx-cal-45-dp-ohms = <6>;
tx-cal-45-dm-ohms = <6>;
};

&usbphy2 {
status = "okay";
tx-d-cal = <12>;
tx-cal-45-dp-ohms = <6>;
tx-cal-45-dm-ohms = <6>;
};

&usdhc1 {
status = "okay";
pwr-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
Expand Down
17 changes: 17 additions & 0 deletions boards/nxp/mimxrt1060_evk/mimxrt1060_evk.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,30 @@ zephyr_udc0: &usb1 {
phy_handle = <&usbphy1>;
};

zephyr_uhc0: &usbh1 {
status = "okay";
phy_handle = <&usbphy1>;
};

zephyr_uhc1: &usbh2 {
status = "okay";
phy_handle = <&usbphy2>;
};

&usbphy1 {
status = "okay";
tx-d-cal = <12>;
tx-cal-45-dp-ohms = <6>;
tx-cal-45-dm-ohms = <6>;
};

&usbphy2 {
status = "okay";
tx-d-cal = <12>;
tx-cal-45-dp-ohms = <6>;
tx-cal-45-dm-ohms = <6>;
};

&csi {
pinctrl-0 = <&pinmux_csi>;
pinctrl-names = "default";
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/udc/Kconfig.mcux
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ config UDC_NXP_EHCI
depends on DT_HAS_NXP_EHCI_ENABLED
select PINCTRL
select NOCACHE_MEMORY if HAS_MCUX_CACHE && CPU_HAS_DCACHE
select DYNAMIC_INTERRUPTS
imply UDC_BUF_FORCE_NOCACHE
imply UDC_WORKQUEUE
help
Expand Down
8 changes: 4 additions & 4 deletions drivers/usb/udc/udc_mcux_ehci.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,10 +871,10 @@ static usb_phy_config_struct_t phy_config_##n = { \
\
static void udc_irq_enable_func##n(const struct device *dev) \
{ \
IRQ_CONNECT(DT_INST_IRQN(n), \
DT_INST_IRQ(n, priority), \
udc_mcux_isr, \
DEVICE_DT_INST_GET(n), 0); \
irq_connect_dynamic(DT_INST_IRQN(n), \
DT_INST_IRQ(n, priority), \
(void (*)(const void *))udc_mcux_isr, \
DEVICE_DT_INST_GET(n), 0); \
\
irq_enable(DT_INST_IRQN(n)); \
} \
Expand Down
5 changes: 5 additions & 0 deletions drivers/usb/uhc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Copyright (c) 2022 Nordic Semiconductor
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0

zephyr_library()

zephyr_library_sources(uhc_common.c)
zephyr_library_sources_ifdef(CONFIG_UHC_MAX3421E uhc_max3421e.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)
zephyr_library_sources_ifdef(CONFIG_UHC_NXP_OHCI uhc_mcux_common.c uhc_mcux_ohci.c)
zephyr_library_sources_ifdef(CONFIG_UHC_NXP_IP3516HS uhc_mcux_common.c uhc_mcux_ip3516hs.c)
1 change: 1 addition & 0 deletions drivers/usb/uhc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ source "subsys/logging/Kconfig.template.log_config"

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

endif # UHC_DRIVER
47 changes: 47 additions & 0 deletions drivers/usb/uhc/Kconfig.mcux
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0

config UHC_NXP_EHCI
bool "NXP MCUX USB EHCI Host controller driver"
default y
depends on DT_HAS_NXP_UHC_EHCI_ENABLED
select EVENTS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is k_event used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The NXP hal controller drivers use the k_event. Hal controller drivers depend on the event of modules\hal\nxp\mcux\mcux-sdk\components\osa\fsl_os_abstraction_zephyr, and the fsl_os_abstraction_zephyr depend on k_event.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The hal driver must not use anything from Zephyr RTOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The MCUX usb host hal controller driver is like the UHC of Zephyr. In the hal driver, one task function is provided, the upper layer can use the task function to create one task to handle the controller interrupts. Then the OS event is used to handle interrupts in this task function.

select NOCACHE_MEMORY if ARCH_HAS_NOCACHE_MEMORY_SUPPORT
select DYNAMIC_INTERRUPTS
help
NXP MCUX USB Host Controller Driver for EHCI.

config UHC_NXP_KHCI
bool "NXP MCUX USB KHCI Host controller driver"
default y
depends on DT_HAS_NXP_UHC_KHCI_ENABLED
select EVENTS
help
NXP MCUX USB Host Controller Driver for KHCI.

config UHC_NXP_IP3516HS
bool "NXP MCUX USB IP3516HS Host controller driver"
default y
depends on DT_HAS_NXP_UHC_IP3516HS_ENABLED
select EVENTS
select NOCACHE_MEMORY if ARCH_HAS_NOCACHE_MEMORY_SUPPORT
help
NXP MCUX USB Host Controller Driver for ip3516hs.

config UHC_NXP_OHCI
bool "NXP MCUX USB IP3516HS Host controller driver"
default y
depends on DT_HAS_NXP_UHC_OHCI_ENABLED
select EVENTS
help
NXP MCUX USB Host Controller Driver for ohci.

config HEAP_MEM_POOL_ADD_SIZE_UHC_MCUX
int "The heap that NXP hal usb host controller drivers need"
default 4096

config UHC_NXP_THREAD_STACK_SIZE
int "MCUX UHC Driver internal thread stack size"
default 2048
help
Size of the stack used in the driver.
Loading
Loading