Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0c90ebd authored by Vivek Aknurwar's avatar Vivek Aknurwar Committed by Gerrit - the friendly Code Review server
Browse files

clk: qcom: Add common regulator handle initialization



To clean up clock controllers probe function, move to common regulator
handle initialization.

Also add common multiple regulator initialization support within
single clk_vdd_class.

Change-Id: I999966d3bc877e0e8bcbb54839c0dd86f41869bd
Signed-off-by: default avatarVivek Aknurwar <viveka@codeaurora.org>
parent 53badd7f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2013-2014, 2017-2019, The Linux Foundation.
 * Copyright (c) 2013-2014, 2017-2020, The Linux Foundation.
 * All rights reserved.
 */

@@ -267,6 +267,10 @@ int qcom_cc_really_probe(struct platform_device *pdev,
	reset->regmap = regmap;
	reset->reset_map = desc->resets;

	ret = clk_regulator_init(&pdev->dev, desc);
	if (ret)
		return ret;

	if (desc->num_resets) {
		ret = devm_reset_controller_register(dev, &reset->rcdev);
		if (ret)
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ struct qcom_cc_desc {
	size_t num_gdscs;
	struct clk_hw **clk_hws;
	size_t num_clk_hws;
	struct clk_vdd_class **clk_regulators;
	size_t num_clk_regulators;
};

/**
+28 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2019, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. */

#include <linux/clk-provider.h>
#include <linux/kernel.h>
#include <linux/regulator/consumer.h>
#include <linux/device.h>

#include "vdd-class.h"
#include "clk-regmap.h"
@@ -182,3 +183,29 @@ int clk_list_rate_vdd_level(struct clk_hw *hw, unsigned int rate)
	return clk_find_vdd_level(hw, vdd_data, rate);
}

int clk_regulator_init(struct device *dev, const struct qcom_cc_desc *desc)
{
	struct clk_vdd_class *vdd_class;
	struct regulator *regulator;
	const char *name;
	u32 i, cnt;

	for (i = 0; i < desc->num_clk_regulators; i++) {
		vdd_class = desc->clk_regulators[i];

		for (cnt = 0; cnt < vdd_class->num_regulators; cnt++) {
			name = vdd_class->regulator_names[cnt];
			regulator = devm_regulator_get(dev, name);
			if (IS_ERR(regulator)) {
				if (PTR_ERR(regulator) != -EPROBE_DEFER)
					dev_err(dev, "%s error %s regulator\n",
						__func__, name);
				return PTR_ERR(regulator);
			}
			vdd_class->regulator[cnt] = regulator;
		}
	}

	return 0;
}
+7 −3
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2019, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. */

#ifndef __QCOM_CLK_VDD_CLASS_H__
#define __QCOM_CLK_VDD_CLASS_H__

#include <linux/regulator/consumer.h>

#include <linux/device.h>
#include "common.h"
/**
 * struct clk_vdd_class - Voltage scaling class
 *
 * @class_name:		name of the class
 * @regulator:		array of regulators
 * @regulator_names:	regulator names
 * @num_regulators:	size of regulator array
 * @vdd_uv:		sorted 2D array of legal voltage settings. Indexed by
 *			level, then regulator
@@ -21,6 +23,7 @@
struct clk_vdd_class {
	const char		*class_name;
	struct regulator	**regulator;
	const char		**regulator_names;
	int			num_regulators;
	int			*vdd_uv;
	int			*level_votes;
@@ -48,6 +51,7 @@ struct clk_vdd_class_data {
	struct clk_vdd_class _name = { \
		.class_name = #_name, \
		.vdd_uv = _vdd_uv, \
		.regulator_names = (const char * [_num_regulators]) { #_name}, \
		.regulator = (struct regulator * [_num_regulators]) {}, \
		.num_regulators = _num_regulators, \
		.level_votes = (int [_num_levels]) {}, \
@@ -67,5 +71,5 @@ int clk_find_vdd_level(struct clk_hw *hw, struct clk_vdd_class_data *vdd_data,
int clk_vote_vdd_level(struct clk_vdd_class_data *vdd_class, int level);
int clk_unvote_vdd_level(struct clk_vdd_class_data *vdd_class, int level);
int clk_list_rate_vdd_level(struct clk_hw *hw, unsigned int rate);

int clk_regulator_init(struct device *dev, const struct qcom_cc_desc *desc);
#endif