Skip to content

Add optional ZynqMP PHY init over GEM MDIO#829

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:zynqmp_phy
Open

Add optional ZynqMP PHY init over GEM MDIO#829
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:zynqmp_phy

Conversation

@dgarske

@dgarske dgarske commented Jul 21, 2026

Copy link
Copy Markdown
Member

Lets wolfBoot configure the Ethernet PHY on ZynqMP boards where U-Boot would normally do it (via mii/mw) before the OS runs. wolfBoot has no network stack, so this drives only the GEM MDIO management plane -- enough to replay a board's PHY register sequence and leave the PHY ready for the OS.

  • Enable with CFLAGS_EXTRA+=-DWOLFBOOT_ZYNQMP_PHY_INIT (off by default; commented example in config/examples/zynqmp.config).
  • Runs in hal_init(): brings up MDIO, then walks a configurable {op, arg0, arg1} step table (GPIO poke / MDIO write / MDIO read). Best-effort -- errors are logged, never block boot.
  • Defaults target a PHY at MDIO 0x0E on GEM3 plus a PL AXI-GPIO reset at 0x80060000. All values overridable from CFLAGS_EXTRA: ZYNQMP_GEM_BASE, ZYNQMP_PHY_ADDR, ZYNQMP_PHY_GPIO_ADDR (0 skips the poke), ZYNQMP_GEM_MDC_DIV, ZYNQMP_PHY_INIT_STEPS.

@dgarske dgarske self-assigned this Jul 21, 2026
Copilot AI review requested due to automatic review settings July 21, 2026 23:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in mechanism for ZynqMP targets to perform early Ethernet PHY register initialization via the Cadence GEM MDIO management interface, allowing wolfBoot to replace the “U-Boot pre-init” role on boards that require it before the OS starts.

Changes:

  • Introduces a configurable PHY init step table and minimal GEM MDIO read/write helpers, executed from hal_init() when enabled.
  • Documents the feature and adds commented enablement/override examples in ZynqMP config templates.
  • Extends CI reusable workflow inputs to allow passing extra CFLAGS, and adds a build job that compiles with the PHY-init flag enabled.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
hal/zynq.h Adds GEM MDIO/PHY-init configuration macros and default step sequence behind WOLFBOOT_ZYNQMP_PHY_INIT.
hal/zynq.c Implements the minimal MDIO engine and runs the configurable init sequence during hal_init().
docs/Targets.md Documents how to enable/configure the optional ZynqMP PHY init feature.
config/examples/zynqmp.config Adds commented example flags/overrides for enabling PHY init.
config/examples/zynqmp_sdcard.config Adds commented example flags/overrides for enabling PHY init (sdcard config).
.github/workflows/test-configs.yml Adds a CI job that builds ZynqMP with WOLFBOOT_ZYNQMP_PHY_INIT enabled.
.github/workflows/test-build-aarch64.yml Adds an extra-cflags input and appends it into .config during CI builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hal/zynq.h
Comment on lines +436 to +439
* "mii"/"mw" commands) can configure the PHY before the OS starts. Every
* magic value below is behind an #ifndef so a board can override it from
* CFLAGS_EXTRA. Register layout mirrors the Cadence GEM in wolfIP
* (src/port/amd/common/gem_regs.h). */
Comment thread hal/zynq.c
Comment on lines +1697 to +1700
/* Enable the MDIO management port with a safe MDC divisor. */
GEM_NWCFG = (GEM_NWCFG & ~(0x7UL << GEM_NWCFG_MDCDIV_SHIFT))
| ((uint32_t)ZYNQMP_GEM_MDC_DIV << GEM_NWCFG_MDCDIV_SHIFT);
GEM_NWCTRL |= GEM_NWCTRL_MDEN;
Comment thread hal/zynq.c
Comment on lines +1682 to +1685
/* Run the configurable PHY init sequence (default: the board's U-Boot flow).
* Best-effort: MDIO errors are reported but never block boot. */
void zynq_phy_init(void)
{
Comment on lines 93 to +98
- name: Select config
run: |
cp ${{inputs.config-file}} .config
if [ -n "${{inputs.extra-cflags}}" ]; then
echo "CFLAGS_EXTRA+=${{inputs.extra-cflags}}" >> .config
fi
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.

2 participants