Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mmc/mmc_fdt_helpers.c
Show All 39 Lines | |||||
#include <dev/gpio/gpiobusvar.h> | #include <dev/gpio/gpiobusvar.h> | ||||
#include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
#include <dev/ofw/ofw_bus_subr.h> | #include <dev/ofw/ofw_bus_subr.h> | ||||
#ifdef EXT_RESOURCES | #ifdef EXT_RESOURCES | ||||
#include <dev/extres/regulator/regulator.h> | #include <dev/extres/regulator/regulator.h> | ||||
#endif | #endif | ||||
#include "mmc_pwrseq_if.h" | |||||
static inline void | static inline void | ||||
mmc_fdt_parse_sd_speed(phandle_t node, struct mmc_host *host) | mmc_fdt_parse_sd_speed(phandle_t node, struct mmc_host *host) | ||||
{ | { | ||||
bool no_18v = false; | bool no_18v = false; | ||||
/* | /* | ||||
* Parse SD supported modes | * Parse SD supported modes | ||||
* All UHS-I modes requires 1.8V signaling. | * All UHS-I modes requires 1.8V signaling. | ||||
▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | if (helper->wp_disabled) | ||||
return (false); | return (false); | ||||
if (helper->wp_pin == NULL) | if (helper->wp_pin == NULL) | ||||
return (false); | return (false); | ||||
gpio_pin_is_active(helper->wp_pin, &pinstate); | gpio_pin_is_active(helper->wp_pin, &pinstate); | ||||
return (pinstate ^ (helper->props & MMC_PROP_WP_INVERTED)); | return (pinstate ^ (helper->props & MMC_PROP_WP_INVERTED)); | ||||
} | |||||
void | |||||
mmc_fdt_set_power(struct mmc_fdt_helper *helper, enum mmc_power_mode power_mode) | |||||
{ | |||||
int reg_status; | |||||
int rv; | |||||
switch (power_mode) { | |||||
case power_on: | |||||
break; | |||||
case power_off: | |||||
if (helper->vmmc_supply) { | |||||
rv = regulator_status(helper->vmmc_supply, ®_status); | |||||
if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED) | |||||
regulator_disable(helper->vmmc_supply); | |||||
} | |||||
if (helper->vqmmc_supply) { | |||||
rv = regulator_status(helper->vqmmc_supply, ®_status); | |||||
if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED) | |||||
regulator_disable(helper->vqmmc_supply); | |||||
} | |||||
if (helper->mmc_pwrseq) | |||||
MMC_PWRSEQ_SET_POWER(helper->mmc_pwrseq, false); | |||||
break; | |||||
case power_up: | |||||
if (helper->vmmc_supply) { | |||||
rv = regulator_status(helper->vmmc_supply, ®_status); | |||||
if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED) | |||||
regulator_enable(helper->vmmc_supply); | |||||
} | |||||
if (helper->vqmmc_supply) { | |||||
rv = regulator_status(helper->vqmmc_supply, ®_status); | |||||
if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED) | |||||
regulator_enable(helper->vqmmc_supply); | |||||
} | |||||
if (helper->mmc_pwrseq) | |||||
MMC_PWRSEQ_SET_POWER(helper->mmc_pwrseq, true); | |||||
break; | |||||
} | |||||
} | } |