Skip to content

Commit 7095608

Browse files
ccli8kartben
authored andcommitted
drivers: usb: udc: support numaker m55m1x series soc
This supports nuvoton numaker m55m1x series soc. Besides, it also has relevant modifications, including: 1. Fix failure to enable HICR48M, which is to clock usbd and phy 2. Support HWINFO for USB device serial number Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
1 parent c32488f commit 7095608

File tree

6 files changed

+54
-7
lines changed

6 files changed

+54
-7
lines changed

boards/nuvoton/numaker_m55m1/numaker_m55m1-pinctrl.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@
5151
slew-rate = "fast";
5252
};
5353
};
54+
55+
/* USBD multi-function pins for VBUS, D+, D-, and ID pins */
56+
usbd_default: usbd_default {
57+
group0 {
58+
pinmux = <PA12MFP_USB_VBUS>,
59+
<PA13MFP_USB_D_MINUS>,
60+
<PA14MFP_USB_D_PLUS>,
61+
<PA15MFP_USB_OTG_ID>;
62+
};
63+
};
5464
};

boards/nuvoton/numaker_m55m1/numaker_m55m1.dts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
status = "okay";
5050
};
5151

52+
&gpioh {
53+
status = "okay";
54+
};
55+
56+
&gpioi {
57+
status = "okay";
58+
};
59+
5260
&flash0 {
5361
partitions {
5462
compatible = "fixed-partitions";
@@ -99,3 +107,10 @@
99107
pinctrl-names = "default";
100108
status = "okay";
101109
};
110+
111+
/* On enabled, usbd is required to be clocked in 48MHz. */
112+
zephyr_udc0: &usbd {
113+
pinctrl-0 = <&usbd_default>;
114+
pinctrl-names = "default";
115+
status = "okay";
116+
};

drivers/hwinfo/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ config HWINFO_AMBIQ
265265
config HWINFO_NUMAKER
266266
bool "NuMaker hwinfo"
267267
default y
268-
depends on SOC_SERIES_M46X
268+
depends on SOC_SERIES_M46X || SOC_SERIES_M55M1X
269269
select HWINFO_HAS_DRIVER
270270
select HAS_NUMAKER_FMC
271271
help

drivers/usb/udc/udc_numaker.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,17 @@ static int numaker_usbd_hw_setup(const struct device *dev)
299299

300300
SYS_UnlockReg();
301301

302-
/* Configure USB PHY for USBD */
302+
/* Configure USB role as USB Device and enable USB PHY */
303+
#if defined(CONFIG_SOC_SERIES_M46X)
303304
SYS->USBPHY = (SYS->USBPHY & ~SYS_USBPHY_USBROLE_Msk) |
304305
(SYS_USBPHY_USBROLE_STD_USBD | SYS_USBPHY_USBEN_Msk | SYS_USBPHY_SBO_Msk);
306+
#elif defined(CONFIG_SOC_SERIES_M2L31X)
307+
SYS->USBPHY = (SYS->USBPHY & ~SYS_USBPHY_USBROLE_Msk) |
308+
(SYS_USBPHY_USBROLE_STD_USBD | SYS_USBPHY_USBEN_Msk | SYS_USBPHY_SBO_Msk);
309+
#elif defined(CONFIG_SOC_SERIES_M55M1X)
310+
SYS->USBPHY = (SYS->USBPHY & ~SYS_USBPHY_USBROLE_Msk) |
311+
((0 << SYS_USBPHY_USBROLE_Pos) | SYS_USBPHY_OTGPHYEN_Msk);
312+
#endif
305313

306314
/* Invoke Clock controller to enable module clock */
307315
memset(&scc_subsys, 0x00, sizeof(scc_subsys));

dts/arm/nuvoton/m55m1x.dtsi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
reg = <0x40001000 0x100>;
4646
#clock-cells = <0>;
4747
lxt = "enable";
48+
hirc48m = "enable";
4849
clk-pclkdiv = <(NUMAKER_CLK_PCLKDIV_PCLK0DIV(2) |
4950
NUMAKER_CLK_PCLKDIV_PCLK1DIV(2) |
5051
NUMAKER_CLK_PCLKDIV_PCLK2DIV(2) |
@@ -460,6 +461,19 @@
460461
#pwm-cells = <3>;
461462
status = "disabled";
462463
};
464+
465+
usbd: usbd@4025c000 {
466+
compatible = "nuvoton,numaker-usbd";
467+
reg = <0x4025c000 0x1000>;
468+
interrupts = <58 0>;
469+
resets = <&rst NUMAKER_SYS_USBD0RST>;
470+
clocks = <&pcc NUMAKER_USBD0_MODULE NUMAKER_CLK_USBSEL_USBSEL_HIRC48M
471+
NUMAKER_CLK_USBDIV_USBDIV(1)>;
472+
dma-buffer-size = <1536>;
473+
status = "disabled";
474+
num-bidir-endpoints = <25>;
475+
disallow-iso-in-out-same-number;
476+
};
463477
};
464478
};
465479

soc/nuvoton/numaker/m55m1x/soc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ void soc_reset_hook(void)
141141
/* Wait for LIRC clock ready */
142142
CLK_WaitClockReady(CLK_STATUS_LIRCSTB_Msk);
143143

144-
#if DT_NODE_HAS_PROP(DT_NODELABEL(scc), hirc48)
145-
/* Enable/disable 48 MHz high-speed internal RC oscillator (HIRC48) */
146-
if (DT_ENUM_IDX(DT_NODELABEL(scc), hirc48) == NUMAKER_SCC_CLKSW_ENABLE) {
144+
#if DT_NODE_HAS_PROP(DT_NODELABEL(scc), hirc48m)
145+
/* Enable/disable 48 MHz high-speed internal RC oscillator (HIRC48M) */
146+
if (DT_ENUM_IDX(DT_NODELABEL(scc), hirc48m) == NUMAKER_SCC_CLKSW_ENABLE) {
147147
CLK_EnableXtalRC(CLK_SRCCTL_HIRC48MEN_Msk);
148-
/* Wait for HIRC48 clock ready */
148+
/* Wait for HIRC48M clock ready */
149149
CLK_WaitClockReady(CLK_STATUS_HIRC48MSTB_Msk);
150-
} else if (DT_ENUM_IDX(DT_NODELABEL(scc), hirc48) == NUMAKER_SCC_CLKSW_DISABLE) {
150+
} else if (DT_ENUM_IDX(DT_NODELABEL(scc), hirc48m) == NUMAKER_SCC_CLKSW_DISABLE) {
151151
CLK_DisableXtalRC(CLK_SRCCTL_HIRC48MEN_Msk);
152152
}
153153
#endif

0 commit comments

Comments
 (0)