linux/drivers/mmc/core/regulator.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Helper functions for MMC regulators.
 */

#include <linux/device.h>
#include <linux/err.h>
#include <linux/log2.h>
#include <linux/regulator/consumer.h>

#include <linux/mmc/host.h>

#include "core.h"
#include "host.h"

#ifdef CONFIG_REGULATOR

/**
 * mmc_ocrbitnum_to_vdd - Convert a OCR bit number to its voltage
 * @vdd_bit:	OCR bit number
 * @min_uV:	minimum voltage value (mV)
 * @max_uV:	maximum voltage value (mV)
 *
 * This function returns the voltage range according to the provided OCR
 * bit number. If conversion is not possible a negative errno value returned.
 */
static int mmc_ocrbitnum_to_vdd(int vdd_bit, int *min_uV, int *max_uV)
{}

/**
 * mmc_regulator_get_ocrmask - return mask of supported voltages
 * @supply: regulator to use
 *
 * This returns either a negative errno, or a mask of voltages that
 * can be provided to MMC/SD/SDIO devices using the specified voltage
 * regulator.  This would normally be called before registering the
 * MMC host adapter.
 */
static int mmc_regulator_get_ocrmask(struct regulator *supply)
{}

/**
 * mmc_regulator_set_ocr - set regulator to match host->ios voltage
 * @mmc: the host to regulate
 * @supply: regulator to use
 * @vdd_bit: zero for power off, else a bit number (host->ios.vdd)
 *
 * Returns zero on success, else negative errno.
 *
 * MMC host drivers may use this to enable or disable a regulator using
 * a particular supply voltage.  This would normally be called from the
 * set_ios() method.
 */
int mmc_regulator_set_ocr(struct mmc_host *mmc,
			struct regulator *supply,
			unsigned short vdd_bit)
{}
EXPORT_SYMBOL_GPL();

static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator,
						  int min_uV, int target_uV,
						  int max_uV)
{}

/**
 * mmc_regulator_set_vqmmc - Set VQMMC as per the ios
 * @mmc: the host to regulate
 * @ios: io bus settings
 *
 * For 3.3V signaling, we try to match VQMMC to VMMC as closely as possible.
 * That will match the behavior of old boards where VQMMC and VMMC were supplied
 * by the same supply.  The Bus Operating conditions for 3.3V signaling in the
 * SD card spec also define VQMMC in terms of VMMC.
 * If this is not possible we'll try the full 2.7-3.6V of the spec.
 *
 * For 1.2V and 1.8V signaling we'll try to get as close as possible to the
 * requested voltage.  This is definitely a good idea for UHS where there's a
 * separate regulator on the card that's trying to make 1.8V and it's best if
 * we match.
 *
 * This function is expected to be used by a controller's
 * start_signal_voltage_switch() function.
 */
int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios)
{}
EXPORT_SYMBOL_GPL();

#else

static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
{
	return 0;
}

#endif /* CONFIG_REGULATOR */

/**
 * mmc_regulator_get_supply - try to get VMMC and VQMMC regulators for a host
 * @mmc: the host to regulate
 *
 * Returns 0 or errno. errno should be handled, it is either a critical error
 * or -EPROBE_DEFER. 0 means no critical error but it does not mean all
 * regulators have been found because they all are optional. If you require
 * certain regulators, you need to check separately in your driver if they got
 * populated after calling this function.
 */
int mmc_regulator_get_supply(struct mmc_host *mmc)
{}
EXPORT_SYMBOL_GPL();

/**
 * mmc_regulator_enable_vqmmc - enable VQMMC regulator for a host
 * @mmc: the host to regulate
 *
 * Returns 0 or errno. Enables the regulator for vqmmc.
 * Keeps track of the enable status for ensuring that calls to
 * regulator_enable/disable are balanced.
 */
int mmc_regulator_enable_vqmmc(struct mmc_host *mmc)
{}
EXPORT_SYMBOL_GPL();

/**
 * mmc_regulator_disable_vqmmc - disable VQMMC regulator for a host
 * @mmc: the host to regulate
 *
 * Returns 0 or errno. Disables the regulator for vqmmc.
 * Keeps track of the enable status for ensuring that calls to
 * regulator_enable/disable are balanced.
 */
void mmc_regulator_disable_vqmmc(struct mmc_host *mmc)
{}
EXPORT_SYMBOL_GPL();