Skip to content

Conversation

@JonyZhang7
Copy link

@JonyZhang7 JonyZhang7 commented Oct 10, 2025

nxp: add usb support on frdm-imx93

Depends on zephyrproject-rtos/hal_nxp#615 (has been merged)

@github-actions
Copy link

Hello @JonyZhang7, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

}

LOG_DBG("wLength %u, bLength %u, tailroom %u",
LOG_DBG("wLength %u, bLength %u, tailroom %zu",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this commit should go in its own PR. Can you also provide better PR title so it is immediately clear that this adds support for new target?

Copy link
Author

Choose a reason for hiding this comment

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

I think this commit should go in its own PR. Can you also provide better PR title so it is immediately clear that this adds support for new target?

Hi @tmon-nordic sorry for late, I modified PR title. tomorrow is feature freeze, there is no time left for me to submit a new PR for this patch. terribly sorry. Could you help review again, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

@JonyZhang7 Please move this commit to own PR.

Copy link
Author

Choose a reason for hiding this comment

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

@JonyZhang7 Please move this commit to own PR.

Hi @jfischer-no add to PR: #98245

@JonyZhang7 JonyZhang7 changed the title Jony usb upstream nxp: usb: add frdm-imx93 support Oct 10, 2025
@JonyZhang7 JonyZhang7 changed the title nxp: usb: add frdm-imx93 support nxp: usb: zephyr support on imx93 frdm Cortex-A Core Oct 10, 2025
@decsny decsny removed their request for review October 10, 2025 13:58
@github-actions
Copy link

github-actions bot commented Oct 11, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest-hal_nxp DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 24, 2025
struct udc_ep_config *ep_cfg_in;
struct udc_ep_config *ep_cfg_out;
uintptr_t base;
DEVICE_MMIO_NAMED_ROM(reg_base);
Copy link
Contributor

Choose a reason for hiding this comment

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

Enable support on i.MX93.

Nothing justifies your changes in the commit message. Please add meaningful commit message and fix commit title.

Also, it looks like this commit should be reworked in two smaller, one with MMIO changes and one about clock.

Comment on lines 53 to 58
const struct device *usb_clock_dev;
clock_control_subsys_t usb_clock_subsys;
clock_control_subsys_rate_t usb_clock_rate;
const struct device *usbphy_clock_dev;
clock_control_subsys_t usbphy_clock_subsys;
clock_control_subsys_rate_t usbphy_clock_rate;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove usb_ and usb prefixes.

Comment on lines 894 to 929
#define UDC_MCUX_CLK0_DEFINE(n) \
.usb_clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR_BY_IDX(n, 0)), \
.usb_clock_subsys = (clock_control_subsys_t) \
DT_INST_CLOCKS_CELL_BY_IDX(n, 0, name), \
.usb_clock_rate = (void *)(uintptr_t)DT_INST_PROP_BY_IDX(n, clock_rates, 0),

#define UDC_MCUX_CLK0_DEFINE_NULL \
.usb_clock_dev = NULL, \
.usb_clock_subsys = NULL, \
.usb_clock_rate = NULL,

#define UDC_MCUX_CLK0_DEFINE_OR(n) \
COND_CODE_1(DT_INST_CLOCKS_HAS_IDX(n, 0), \
(COND_CODE_1(DT_INST_PROP_HAS_IDX(n, clock_rates, 0), \
(UDC_MCUX_CLK0_DEFINE(n)), \
(UDC_MCUX_CLK0_DEFINE_NULL))), \
(UDC_MCUX_CLK0_DEFINE_NULL))

#define UDC_MCUX_CLK1_DEFINE(n) \
.usbphy_clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR_BY_IDX(n, 1)), \
.usbphy_clock_subsys = (clock_control_subsys_t) \
DT_INST_CLOCKS_CELL_BY_IDX(n, 1, name), \
.usbphy_clock_rate = (void *)(uintptr_t)DT_INST_PROP_BY_IDX(n, clock_rates, 1),

#define UDC_MCUX_CLK1_DEFINE_NULL \
.usbphy_clock_dev = NULL, \
.usbphy_clock_subsys = NULL, \
.usbphy_clock_rate = NULL,

#define UDC_MCUX_CLK1_DEFINE_OR(n) \
COND_CODE_1(DT_INST_CLOCKS_HAS_IDX(n, 1), \
(COND_CODE_1(DT_INST_PROP_HAS_IDX(n, clock_rates, 1), \
(UDC_MCUX_CLK1_DEFINE(n)), \
(UDC_MCUX_CLK1_DEFINE_NULL))), \
(UDC_MCUX_CLK1_DEFINE_NULL))

Copy link
Contributor

Choose a reason for hiding this comment

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

You need to fix style in all these new macros first.

zephyr,shell-uart = &lpuart2;
zephyr,sram = &dram;
zephyr,canbus = &flexcan2;
zephyr,usb-device = &usb1;
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 line, we do not use chosen node zephyr,usb-device property.

- can
- net
- watchdog
- usb_device
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace it with - usbd.

Comment on lines +31 to +33

# USB Except
CONFIG_UDC_WORKQUEUE=n
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Author

Choose a reason for hiding this comment

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

Why?

@JiafeiPan do we need close udc workqueue?

@jfischer-no jfischer-no assigned dleach02 and unassigned nordic-krch Oct 24, 2025
@github-actions github-actions bot removed manifest manifest-hal_nxp DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 25, 2025
@zephyrbot zephyrbot requested a review from jfischer-no October 25, 2025 01:01
@JonyZhang7 JonyZhang7 force-pushed the jony_usb_upstream branch 7 times, most recently from 12c278c to 449dfc4 Compare October 27, 2025 06:54
@zephyrbot zephyrbot added the area: Tracing Tracing label Oct 27, 2025
@zephyrbot zephyrbot requested a review from nashif October 27, 2025 06:57
JasonHe-nxp and others added 2 commits October 27, 2025 18:40
Add usb clock support.

Signed-off-by: Jason He <jason.he_1@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
As middleware.cmake could be included by mcux-sdk's CMakeLists.txt,
so use CMAKE_CURRENT_LIST_DIR to make sure the directory is correct.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
@sonarqubecloud
Copy link

JiafeiPan and others added 5 commits October 28, 2025 02:09
Use zu% format for size_t type.
Use d% format for int type.
Use u% format for uint32_t type.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
1013 | void sys_trace_socket_accept_exit(int sock, const struct sockaddr *addr, const size_t *addrlen,
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /__w/zephyr/zephyr/include/zephyr/tracing/tracing.h:22,
                 from /__w/zephyr/zephyr/include/zephyr/kernel.h:6679,
                 from /__w/zephyr/zephyr/subsys/tracing/ctf/ctf_top.c:7:
/__w/zephyr/zephyr/subsys/tracing/ctf/./tracing_ctf.h:707:6: note: previous declaration of 'sys_trace_socket_accept_exit' with type 'void(int,  const struct sockaddr *, const uint32_t *, int)' {aka 'void(int,  const struct sockaddr *, const unsigned int *, int)'}
  707 | void sys_trace_socket_accept_exit(int sock, const struct sockaddr *addr, const uint32_t *addrlen,
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
frdm_imx93 dosen't include the comlilation of usb.uvc.encoder,
disable bellow samples to make sure twister build.
- sample.subsys.usb.uvc.encoder.h264
- sample.subsys.usb.uvc.encoder.jpeg

Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
Enable i.MX93 support with dynamic clock and MMIO configuration.

Signed-off-by: Jason He <jason.he_1@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
Enable USB support on i.MX93 FRDM.

Signed-off-by: Jason He <jason.he_1@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants