#include <dev/ofw/ofw_bus_subr.h>
#include <dev/mmc/bridge.h>
+#include <dev/mmc/mmc_fdt_helpers.h>
#include <dev/mmc/mmcbrvar.h>
#include <dev/mmc/mmcreg.h>
struct sdhci_slot *slot; /* SDHCI internal data */
struct resource *mem_res; /* Memory resource */
- regulator_t reg_vqmmc; /* vqmmc-supply regulator */
uint8_t znr; /* PHY ZNR */
uint8_t zpr; /* PHY ZPR */
bool no_18v; /* No 1.8V support */
bool slow_mode; /* PHY slow mode */
- bool wp_inverted; /* WP pin is inverted */
+
+ struct mmc_fdt_helper mmc_helper; /* MMC helper for parsing FDT */
};
static uint8_t
{
struct sdhci_xenon_softc *sc = device_get_softc(bus);
- return (sdhci_generic_get_ro(bus, dev) ^ sc->wp_inverted);
+ return (sdhci_generic_get_ro(bus, dev) ^
+ (sc->mmc_helper.props & MMC_PROP_WP_INVERTED));
}
static bool
if (bootverbose)
device_printf(sc->dev, "Powering down sd/mmc\n");
- if (sc->reg_vqmmc)
- regulator_disable(sc->reg_vqmmc);
+ if (sc->mmc_helper.vmmc_supply)
+ regulator_disable(sc->mmc_helper.vmmc_supply);
+ if (sc->mmc_helper.vqmmc_supply)
+ regulator_disable(sc->mmc_helper.vqmmc_supply);
break;
case power_up:
if (bootverbose)
device_printf(sc->dev, "Powering up sd/mmc\n");
- if (sc->reg_vqmmc)
- regulator_enable(sc->reg_vqmmc);
+ if (sc->mmc_helper.vmmc_supply)
+ regulator_enable(sc->mmc_helper.vmmc_supply);
+ if (sc->mmc_helper.vqmmc_supply)
+ regulator_enable(sc->mmc_helper.vqmmc_supply);
break;
};
sc = device_get_softc(brdev);
- if (sc->reg_vqmmc == NULL)
+ if (sc->mmc_helper.vqmmc_supply == NULL)
return EOPNOTSUPP;
slot = device_get_ivars(reqdev);
return EINVAL;
}
- err = regulator_set_voltage(sc->reg_vqmmc, uvolt, uvolt);
+ err = regulator_set_voltage(sc->mmc_helper.vqmmc_supply, uvolt, uvolt);
if (err != 0) {
device_printf(sc->dev,
"Cannot set vqmmc to %d<->%d\n",
sc->max_clk = cid;
if (OF_hasprop(sc->node, "no-1-8-v"))
sc->no_18v = true;
- if (OF_hasprop(sc->node, "wp-inverted"))
- sc->wp_inverted = true;
if (OF_hasprop(sc->node, "marvell,xenon-phy-slow-mode"))
sc->slow_mode = true;
sc->znr = XENON_ZNR_DEF_VALUE;
if ((OF_getencprop(sc->node, "marvell,xenon-phy-zpr", &cid,
sizeof(cid))) > 0)
sc->zpr = cid & XENON_ZPR_MASK;
- if (regulator_get_by_ofw_property(dev, 0, "vqmmc-supply",
- &sc->reg_vqmmc) == 0 && bootverbose) {
- if (bootverbose)
- device_printf(dev, "vqmmc-supply regulator found\n");
- }
return (0);
}
*/
sc->gpio = sdhci_fdt_gpio_setup(dev, slot);
+ mmc_fdt_parse(dev, 0, &sc->mmc_helper, &sc->slot->host);
+
if (sdhci_init_slot(dev, sc->slot, 0))
goto fail;