Page MenuHomeFreeBSD

sdhci_fsl_fdt: Add voltage switching through syscon
ClosedPublic

Authored by hum_semihalf.com on Jan 25 2022, 8:36 AM.

Details

Summary

Some SoCs does not have a fixed regulator to handle voltage
switching automatically. Add support for voltage switching
through syscon register when necessary. Add new errata flag
indicating missing regulator. Apply errata to SoCs, which are
known to be affected, i.e. LS1046 and LS1012.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

sys/dev/sdhci/sdhci_fsl_fdt.c
174

s/does not have fixed regulator/don't have a fixed regulator

214

s/char* syscon_compat/char *syscon_compat

674

Does a write to SCFG_SDHCIOVSELCR clear SCFG_SDHCIOVSELCR_TGLEN? Otherwise I see no reason setting it again for each voltage, when it's already set in line 665.

735

Will we still get non-null value here on boards that have the regulator connected by syscon? If so, I think the logic should terminate here.

Fix typos. Don't return from function right after voltage switching with a syscon, but go to the fixed regulator logic.

sys/dev/sdhci/sdhci_fsl_fdt.c
727

Now we're skipping over the switch (slot->host.ios.vccq) block, leaving uvolt uninitialized, but we later use it in regulator_set_voltage(vqmmc_supply, uvolt, uvolt).
I will reiterate my question - can boards with syscon voltage regulator get non-null vqmmc_supply?

sys/dev/sdhci/sdhci_fsl_fdt.c
713

One more thought - to prevent this code from becoming spaghetti, I'd suggest to delegate the actual voltage switch logic to its own helper.
I.e. sc->soc_data->vccq_switch(brdev, reqdev), that will do the switching either through syscon or device register set, depending on the SoC revision. This way we don't have to awkwardly skip over switch (slot->host.ios.vccq), or use SDHCI_FSL_MISSING_VCCQ_REG.

Change voltage switching logic. After setting registers check for errata flag for missing regulator and use syscon register for voltage switch if necessary. Check for a fixed regulator presence afterwards, as it still might be possible and use it.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 22 2022, 8:59 AM
This revision was automatically updated to reflect the committed changes.