linux/drivers/regulator/qcom-rpmh-regulator.c

// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
// Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.

#define pr_fmt(fmt)

#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>

#include <soc/qcom/cmd-db.h>
#include <soc/qcom/rpmh.h>

#include <dt-bindings/regulator/qcom,rpmh-regulator.h>

/**
 * enum rpmh_regulator_type - supported RPMh accelerator types
 * @VRM:	RPMh VRM accelerator which supports voting on enable, voltage,
 *		and mode of LDO, SMPS, and BOB type PMIC regulators.
 * @XOB:	RPMh XOB accelerator which supports voting on the enable state
 *		of PMIC regulators.
 */
enum rpmh_regulator_type {};

#define RPMH_REGULATOR_REG_VRM_VOLTAGE
#define RPMH_REGULATOR_REG_ENABLE
#define RPMH_REGULATOR_REG_VRM_MODE

#define PMIC4_LDO_MODE_RETENTION
#define PMIC4_LDO_MODE_LPM
#define PMIC4_LDO_MODE_HPM

#define PMIC4_SMPS_MODE_RETENTION
#define PMIC4_SMPS_MODE_PFM
#define PMIC4_SMPS_MODE_AUTO
#define PMIC4_SMPS_MODE_PWM

#define PMIC4_BOB_MODE_PASS
#define PMIC4_BOB_MODE_PFM
#define PMIC4_BOB_MODE_AUTO
#define PMIC4_BOB_MODE_PWM

#define PMIC5_LDO_MODE_RETENTION
#define PMIC5_LDO_MODE_LPM
#define PMIC5_LDO_MODE_HPM

#define PMIC5_SMPS_MODE_RETENTION
#define PMIC5_SMPS_MODE_PFM
#define PMIC5_SMPS_MODE_AUTO
#define PMIC5_SMPS_MODE_PWM

#define PMIC5_BOB_MODE_PASS
#define PMIC5_BOB_MODE_PFM
#define PMIC5_BOB_MODE_AUTO
#define PMIC5_BOB_MODE_PWM

/**
 * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations
 * @regulator_type:		RPMh accelerator type used to manage this
 *				regulator
 * @ops:			Pointer to regulator ops callback structure
 * @voltage_ranges:		The possible ranges of voltages supported by this
 * 				PMIC regulator type
 * @n_linear_ranges:		Number of entries in voltage_ranges
 * @n_voltages:			The number of unique voltage set points defined
 *				by voltage_ranges
 * @hpm_min_load_uA:		Minimum load current in microamps that requires
 *				high power mode (HPM) operation.  This is used
 *				for LDO hardware type regulators only.
 * @pmic_mode_map:		Array indexed by regulator framework mode
 *				containing PMIC hardware modes.  Must be large
 *				enough to index all framework modes supported
 *				by this regulator hardware type.
 * @of_map_mode:		Maps an RPMH_REGULATOR_MODE_* mode value defined
 *				in device tree to a regulator framework mode
 */
struct rpmh_vreg_hw_data {};

/**
 * struct rpmh_vreg - individual RPMh regulator data structure encapsulating a
 *		single regulator device
 * @dev:			Device pointer for the top-level PMIC RPMh
 *				regulator parent device.  This is used as a
 *				handle in RPMh write requests.
 * @addr:			Base address of the regulator resource within
 *				an RPMh accelerator
 * @rdesc:			Regulator descriptor
 * @hw_data:			PMIC regulator configuration data for this RPMh
 *				regulator
 * @always_wait_for_ack:	Boolean flag indicating if a request must always
 *				wait for an ACK from RPMh before continuing even
 *				if it corresponds to a strictly lower power
 *				state (e.g. enabled --> disabled).
 * @enabled:			Flag indicating if the regulator is enabled or
 *				not
 * @bypassed:			Boolean indicating if the regulator is in
 *				bypass (pass-through) mode or not.  This is
 *				only used by BOB rpmh-regulator resources.
 * @voltage_selector:		Selector used for get_voltage_sel() and
 *				set_voltage_sel() callbacks
 * @mode:			RPMh VRM regulator current framework mode
 */
struct rpmh_vreg {};

/**
 * struct rpmh_vreg_init_data - initialization data for an RPMh regulator
 * @name:			Name for the regulator which also corresponds
 *				to the device tree subnode name of the regulator
 * @resource_name:		RPMh regulator resource name format string.
 *				This must include exactly one field: '%s' which
 *				is filled at run-time with the PMIC ID provided
 *				by device tree property qcom,pmic-id.  Example:
 *				"ldo%s1" for RPMh resource "ldoa1".
 * @supply_name:		Parent supply regulator name
 * @hw_data:			Configuration data for this PMIC regulator type
 */
struct rpmh_vreg_init_data {};

/**
 * rpmh_regulator_send_request() - send the request to RPMh
 * @vreg:		Pointer to the RPMh regulator
 * @cmd:		Pointer to the RPMh command to send
 * @wait_for_ack:	Boolean indicating if execution must wait until the
 *			request has been acknowledged as complete
 *
 * Return: 0 on success, errno on failure
 */
static int rpmh_regulator_send_request(struct rpmh_vreg *vreg,
			struct tcs_cmd *cmd, bool wait_for_ack)
{}

static int _rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev,
				unsigned int selector, bool wait_for_ack)
{}

static int rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev,
					unsigned int selector)
{}

static int rpmh_regulator_vrm_get_voltage_sel(struct regulator_dev *rdev)
{}

static int rpmh_regulator_is_enabled(struct regulator_dev *rdev)
{}

static int rpmh_regulator_set_enable_state(struct regulator_dev *rdev,
					bool enable)
{}

static int rpmh_regulator_enable(struct regulator_dev *rdev)
{}

static int rpmh_regulator_disable(struct regulator_dev *rdev)
{}

static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg,
					unsigned int mode, bool bypassed)
{}

static int rpmh_regulator_vrm_set_mode(struct regulator_dev *rdev,
					unsigned int mode)
{}

static unsigned int rpmh_regulator_vrm_get_mode(struct regulator_dev *rdev)
{}

/**
 * rpmh_regulator_vrm_get_optimum_mode() - get the mode based on the  load
 * @rdev:		Regulator device pointer for the rpmh-regulator
 * @input_uV:		Input voltage
 * @output_uV:		Output voltage
 * @load_uA:		Aggregated load current in microamps
 *
 * This function is used in the regulator_ops for VRM type RPMh regulator
 * devices.
 *
 * Return: 0 on success, errno on failure
 */
static unsigned int rpmh_regulator_vrm_get_optimum_mode(
	struct regulator_dev *rdev, int input_uV, int output_uV, int load_uA)
{}

static int rpmh_regulator_vrm_set_bypass(struct regulator_dev *rdev,
				bool enable)
{}

static int rpmh_regulator_vrm_get_bypass(struct regulator_dev *rdev,
				bool *enable)
{}

static const struct regulator_ops rpmh_regulator_vrm_ops =;

static const struct regulator_ops rpmh_regulator_vrm_drms_ops =;

static const struct regulator_ops rpmh_regulator_vrm_bypass_ops =;

static const struct regulator_ops rpmh_regulator_xob_ops =;

/**
 * rpmh_regulator_init_vreg() - initialize all attributes of an rpmh-regulator
 * @vreg:		Pointer to the individual rpmh-regulator resource
 * @dev:			Pointer to the top level rpmh-regulator PMIC device
 * @node:		Pointer to the individual rpmh-regulator resource
 *			device node
 * @pmic_id:		String used to identify the top level rpmh-regulator
 *			PMIC device on the board
 * @pmic_rpmh_data:	Pointer to a null-terminated array of rpmh-regulator
 *			resources defined for the top level PMIC device
 *
 * Return: 0 on success, errno on failure
 */
static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev,
			struct device_node *node, const char *pmic_id,
			const struct rpmh_vreg_init_data *pmic_rpmh_data)
{}

static const int pmic_mode_map_pmic4_ldo[REGULATOR_MODE_STANDBY + 1] =;

static const int pmic_mode_map_pmic5_ldo[REGULATOR_MODE_STANDBY + 1] =;

static const int pmic_mode_map_pmic5_ldo_hpm[REGULATOR_MODE_STANDBY + 1] =;

static unsigned int rpmh_regulator_pmic4_ldo_of_map_mode(unsigned int rpmh_mode)
{}

static const int pmic_mode_map_pmic4_smps[REGULATOR_MODE_STANDBY + 1] =;

static const int pmic_mode_map_pmic5_smps[REGULATOR_MODE_STANDBY + 1] =;

static unsigned int
rpmh_regulator_pmic4_smps_of_map_mode(unsigned int rpmh_mode)
{}

static const int pmic_mode_map_pmic4_bob[REGULATOR_MODE_STANDBY + 1] =;

static const int pmic_mode_map_pmic5_bob[REGULATOR_MODE_STANDBY + 1] =;

static unsigned int rpmh_regulator_pmic4_bob_of_map_mode(unsigned int rpmh_mode)
{}

static const struct rpmh_vreg_hw_data pmic4_pldo =;

static const struct rpmh_vreg_hw_data pmic4_pldo_lv =;

static const struct rpmh_vreg_hw_data pmic4_nldo =;

static const struct rpmh_vreg_hw_data pmic4_hfsmps3 =;

static const struct rpmh_vreg_hw_data pmic4_ftsmps426 =;

static const struct rpmh_vreg_hw_data pmic4_bob =;

static const struct rpmh_vreg_hw_data pmic4_lvs =;

static const struct rpmh_vreg_hw_data pmic5_pldo =;

static const struct rpmh_vreg_hw_data pmic5_pldo_lv =;

static const struct rpmh_vreg_hw_data pmic5_pldo515_mv =;

static const struct rpmh_vreg_hw_data pmic5_pldo502 =;

static const struct rpmh_vreg_hw_data pmic5_pldo502ln =;

static const struct rpmh_vreg_hw_data pmic5_nldo =;

static const struct rpmh_vreg_hw_data pmic5_nldo515 =;

static const struct rpmh_vreg_hw_data pmic5_nldo502 =;

static const struct rpmh_vreg_hw_data pmic5_hfsmps510 =;

static const struct rpmh_vreg_hw_data pmic5_ftsmps510 =;

static const struct rpmh_vreg_hw_data pmic5_ftsmps520 =;

static const struct rpmh_vreg_hw_data pmic5_ftsmps525_lv =;

static const struct rpmh_vreg_hw_data pmic5_ftsmps525_mv =;

static const struct rpmh_vreg_hw_data pmic5_ftsmps527 =;

static const struct rpmh_vreg_hw_data pmic5_hfsmps515 =;

static const struct rpmh_vreg_hw_data pmic5_hfsmps515_1 =;

static const struct rpmh_vreg_hw_data pmic5_bob =;

#define RPMH_VREG(_name, _resource_name, _hw_data, _supply_name)

static const struct rpmh_vreg_init_data pm8998_vreg_data[] =;

static const struct rpmh_vreg_init_data pmg1110_vreg_data[] =;

static const struct rpmh_vreg_init_data pmi8998_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8005_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8150_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8150l_vreg_data[] =;

static const struct rpmh_vreg_init_data pmm8155au_vreg_data[] =;

static const struct rpmh_vreg_init_data pmm8654au_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8350_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8350c_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8450_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8550_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8550vs_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8550ve_vreg_data[] =;

static const struct rpmh_vreg_init_data pmc8380_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8009_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8009_1_vreg_data[] =;

static const struct rpmh_vreg_init_data pm8010_vreg_data[] =;

static const struct rpmh_vreg_init_data pm6150_vreg_data[] =;

static const struct rpmh_vreg_init_data pm6150l_vreg_data[] =;

static const struct rpmh_vreg_init_data pm6350_vreg_data[] =;

static const struct rpmh_vreg_init_data pmx55_vreg_data[] =;

static const struct rpmh_vreg_init_data pmx65_vreg_data[] =;

static const struct rpmh_vreg_init_data pmx75_vreg_data[] =;

static const struct rpmh_vreg_init_data pm7325_vreg_data[] =;

static const struct rpmh_vreg_init_data pmr735a_vreg_data[] =;

static const struct rpmh_vreg_init_data pm660_vreg_data[] =;

static const struct rpmh_vreg_init_data pm660l_vreg_data[] =;

static int rpmh_regulator_probe(struct platform_device *pdev)
{}

static const struct of_device_id __maybe_unused rpmh_regulator_match_table[] =;
MODULE_DEVICE_TABLE(of, rpmh_regulator_match_table);

static struct platform_driver rpmh_regulator_driver =;
module_platform_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();