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

Commit 9cad46b3 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "clk: qcom: Support to add hardware clocks to of_clk_hw_provider"

parents 06aebf4d 84196373
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2014, 2017-2018, The Linux Foundation. All rights reserved.
 */

#include <linux/export.h>
@@ -20,7 +20,9 @@
struct qcom_cc {
	struct qcom_reset_controller reset;
	struct clk_regmap **rclks;
	struct clk_hw **hwclks;
	size_t num_rclks;
	size_t num_hwclks;
};

const
@@ -197,11 +199,14 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,
	struct qcom_cc *cc = data;
	unsigned int idx = clkspec->args[0];

	if (idx >= cc->num_rclks) {
		pr_err("%s: invalid index %u\n", __func__, idx);
	if (idx >= cc->num_rclks + cc->num_hwclks) {
		pr_err("invalid index %u\n", idx);
		return ERR_PTR(-EINVAL);
	}

	if (idx < cc->num_hwclks && cc->hwclks[idx])
		return cc->hwclks[idx];

	return cc->rclks[idx] ? &cc->rclks[idx]->hw : ERR_PTR(-ENOENT);
}

@@ -214,7 +219,9 @@ int qcom_cc_really_probe(struct platform_device *pdev,
	struct qcom_cc *cc;
	struct gdsc_desc *scd;
	size_t num_clks = desc->num_clks;
	size_t num_hwclks = desc->num_hwclks;
	struct clk_regmap **rclks = desc->clks;
	struct clk_hw **hwclks = desc->hwclks;

	cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL);
	if (!cc)
@@ -250,6 +257,17 @@ int qcom_cc_really_probe(struct platform_device *pdev,

	cc->rclks = rclks;
	cc->num_rclks = num_clks;
	cc->hwclks = hwclks;
	cc->num_hwclks = num_hwclks;

	for (i = 0; i < num_hwclks; i++) {
		if (!hwclks[i])
			continue;

		ret = devm_clk_hw_register(dev, hwclks[i]);
		if (ret)
			return ret;
	}

	for (i = 0; i < num_clks; i++) {
		if (!rclks[i])
+3 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2014, 2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved.
 */

#ifndef __QCOM_CLK_COMMON_H__
@@ -26,7 +26,9 @@ struct clk_hw;
struct qcom_cc_desc {
	const struct regmap_config *config;
	struct clk_regmap **clks;
	struct clk_hw **hwclks;
	size_t num_clks;
	size_t num_hwclks;
	const struct qcom_reset_map *resets;
	size_t num_resets;
	struct gdsc **gdscs;