Skip to content

Conversation

@xingrz
Copy link
Member

@xingrz xingrz commented Nov 16, 2025

This PR models all GPIO-controlled 5V rails on the M5Stack CoreS3/CoreS3-SE as fixed regulators: bus_5v, bus_out_reg, and usb_otg_reg. The bus_5v regulator matches the equivalent node present on the M5Stack Core2. (See #67280)

Two optional snippets (cores3-bus-out-en and cores3-usb-otg-en) are added to enable the external 5V outputs at build time. All regulators remain disabled by default to preserve existing behavior.

The board documentation is updated to describe the CoreS3 power routing matrix and the behavior of the BUS_OUT_EN and USB_OTG_EN control signals.

These additions allow shields and applications to use the standard vin-supply property and Zephyr’s regulator API for correct power sequencing and runtime control.

Copy link
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Also, shouldn't the bus just have a reference to the regulator itself? So that when it is enabled the PM code will power on the regulator, and power it off if the device is suspended? @fabiobaltieri ?

# Takes good care of initialization priorities

if REGULATOR_FIXED
config REGULATOR_FIXED_INIT_PRIORITY
Copy link
Contributor

Choose a reason for hiding this comment

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

@xingrz
Copy link
Member Author

xingrz commented Nov 17, 2025

shouldn't the bus just have a reference to the regulator itself? So that when it is enabled the PM code will power on the regulator, and power it off if the device is suspended?

The bus can also be externally powered. For example the Base LAN PoE v1.2 feeds 5V back into pin 28 of the bus.

The bus_5v regulator will indeed be enabled by whatever shield consumes it (I’m planning to model those shields as MFDs). But bus_out_reg and usb_otg_reg still need to be controlled explicitly to choose the correct power source or sink configuration.

@xingrz
Copy link
Member Author

xingrz commented Nov 17, 2025

I’m planning to model those shields as MFDs

For those interested in the overall approach, here is a WIP branch: xingrz/zephyr@cores3-power/pr...m5-bytebutton/dev.

I'm still gathering more Units to verify the design, and will submit a follow-up PR for the Unit support once it’s ready.

@fabiobaltieri
Copy link
Member

Also, shouldn't the bus just have a reference to the regulator itself? So that when it is enabled the PM code will power on the regulator, and power it off if the device is suspended? @fabiobaltieri ?

Like having the USB stack call the regulator APIs to control the supply before initializing? Sounds reasonable to me, may be worth a followup

Add a `bus_5v` fixed-regulator node driven by the `BOOST_EN` pin. This
enables drivers and shields to reference the 5V supply through the standard
`vin-supply` property, providing correct power sequencing and runtime
control via Zephyr’s regulator API.

This regulator is equivalent to the `bus_5v` already defined on the M5Stack
Core2 board.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
Add two fixed-regulator nodes on the M5Stack CoreS3 to model the load
switches controlled by the AW9523B GPIO expander:

- `bus_out_reg`: drives 5V output on the M-Bus/Grove connectors via the
  `BUS_OUT_EN` control signal.
- `usb_otg_reg`: drives 5V VBUS output on the USB port via the `USB_OTG_EN`
  control signal, enabling USB-OTG/host-power mode.

Both regulators are defined but off by default. Two new snippets
(`cores3-bus-out-en` and `cores3-usb-otg-en`) are added to allow enabling
these rails at build time when needed. This keeps the default power
configuration unchanged while providing an opt-in mechanism for
applications and shields that require external 5V output.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
endif # REGULATOR_AXP192_AXP2101

if MIPI_DBI
# Needs to init after MFD_AW9523B (80), since reset-gpios uses aw9523b_gpio on this board.
Copy link
Member

Choose a reason for hiding this comment

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

Oh I see this impacts multiple drivers, would it not be easier to change the aw9523b_gpio priority instead and leave the others alone?

Copy link
Member Author

Choose a reason for hiding this comment

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

aw9523b_gpio already initializes at priority 40, which is not late. The issue is that it relies on a k_sem from the aw9523b MFD, so anything using aw9523b_gpio must be initialized after the MFD itself.

k_sem_take(aw9523b_get_lock(config->mfd_dev), K_FOREVER);

@sonarqubecloud
Copy link

@xingrz xingrz requested a review from nordicjm November 17, 2025 13:21
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.

5 participants