Skip to content

hal: microchip: add the USART SWRST alias the four mapping packs lack - #73

Merged
NhMchp merged 1 commit into
zephyrproject-rtos:masterfrom
ArivEmb:sercom-usart-swrst-alias
Aug 27, 2026
Merged

NhMchp merged 1 commit into
zephyrproject-rtos:masterfrom
ArivEmb:sercom-usart-swrst-alias

Conversation

@TheArkadiuszGrzelka

Copy link
Copy Markdown
Contributor

uart_mchp_sercom_g1.c is gaining a SERCOM software reset for a USART the bootloader handed over enabled, and the generic name it uses is defined natively only by the SG/GC and PL packs, so the four packs that map the generic USART names need the missing alias or the change breaks every other in-tree user of the driver.

One name missing from forty-seven, four times over

Four pack headers map the generic SERCOM_USART_ names onto their own
SERCOM_USART_INT_ ones - sercom_pic32cm_jh.h, sercom_pic32cx_sg.h,
sercom_pic32cz_ca.h and sercom_samd5xe5x.h - forty-seven definitions
apiece, and CTRLA_SWRST is in none of them. Only the PIC32CM SG/GC and PL
packs spell it natively, because their SERCOM has a single USART register
view rather than an INT/EXT pair.

Nothing noticed, because uart_mchp_sercom_g1.c never reset a SERCOM.

Why now

The Zephyr change serial-mchp-sercom-reset adds exactly that: a USART
handed over by a bootloader arrives still enabled, and an enable-protected
register cannot be written in that state, so the driver disables and then
software-resets before configuring. The line it needs is

usart_regs->SERCOM_CTRLA = SERCOM_USART_CTRLA_SWRST_Msk;

which compiles on this board's family and on nothing else.

Evidence

Board Before After
pic32cm_jh01_cpro 'SERCOM_USART_CTRLA_SWRST_Msk' undeclared links
sam_e54_xpro 'SERCOM_USART_CTRLA_SWRST_Msk' undeclared links
pic32cm_gc00_cpro links links

Scope

One line per header, four headers, the same one-line form as the
forty-seven already in each. SWRST is bit 0 of CTRLA in both the INT and
the EXT register view of every one of these packs, so mapping to the INT
spelling - which is what all forty-seven neighbours do - is the same bit
either way. Nothing that compiles today changes meaning.

Testing

samples/hello_world on pic32cm_jh01_cpro and sam_e54_xpro, with the
Zephyr serial patch in the tree, before and after. No board of any of these
four families is on this bench, so the rung that could watch the reset
happen is UNVERIFIED; the reset itself is measured on
pic32cm_gc00_cpro, which does not need this change.

Verification

Built in the project's dev container, whose west workspace applies this
change as a module patch. This is the consumer-side pair of
zephyrproject-rtos/zephyr's serial-mchp-sercom-reset, and it has to land
in the same window or that change breaks four families.

Each of these headers maps the generic SERCOM_USART_ names onto its own
pack's SERCOM_USART_INT_ ones, 47 definitions apiece, and CTRLA_SWRST is
missing from every one of them. Only the PIC32CM SG/GC and PL packs
define the generic spelling natively, so a driver line that resets a
SERCOM through SERCOM_USART_CTRLA_SWRST_Msk compiles on those two
families and on no other.

uart_mchp_sercom_g1.c is gaining exactly such a line, to reset a USART
that a bootloader handed over still enabled. Without these four
definitions that change would break PIC32CM JH, PIC32CX SG, PIC32CZ CA
and SAM D5x/E5x, which is every other in-tree user of the driver.

The mask is bit 0 of CTRLA in both the INT and the EXT register views, so
mapping to the INT spelling matches the 47 lines already in each file.

Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>

@Madhan-Kurukondar Madhan-Kurukondar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you. This looks fine

@TheArkadiuszGrzelka

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Is anything else needed here before this can merge?

Asking because it sits on the critical path for a Zephyr-side change: the SERCOM G1 UART driver has to reset a peripheral the bootloader left enabled, and that needs the USART SWRST alias this pull request adds. We are holding that one back rather than opening a pull request that would not build until this has landed.

@nandojve
nandojve requested a review from NhMchp August 26, 2026 09:44
@NhMchp NhMchp self-assigned this Aug 27, 2026
@NhMchp
NhMchp merged commit 27c17f4 into zephyrproject-rtos:master Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants