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

Commit 119da71a authored by Mike Tipton's avatar Mike Tipton
Browse files

clk: qcom: Fix incorrect mux_get_parent mapping



The current mux_get_parent logic attempts to find the parent index by
passing the HW parent to qcom_find_src_index, which compares against the
logical value (parent_map::src) instead of the raw HW value
(parent_map::cfg). This can lead to improperly parented muxes or orphans
since there is no guarantee that the logical values match the HW values.

Add a new helper function (qcom_find_cfg_index), which returns the index
associated with the HW parent value (parent_map::cfg). Call this
function in mux_get_parent instead of qcom_find_src_index to fix the
improper mux parents.

Change-Id: I87efb8a798ab481a86d29a9b830cbc1f889a4e5b
Signed-off-by: default avatarMike Tipton <mdtipton@codeaurora.org>
parent 2cfd8943
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014, 2019, The Linux Foundation. All rights reserved.
 */

#include <linux/kernel.h>
@@ -28,7 +28,7 @@ static u8 mux_get_parent(struct clk_hw *hw)
	val &= mask;

	if (mux->parent_map)
		return qcom_find_src_index(hw, mux->parent_map, val);
		return qcom_find_cfg_index(hw, mux->parent_map, val);

	return val;
}
+12 −0
Original line number Diff line number Diff line
@@ -69,6 +69,18 @@ int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, u8 src)
}
EXPORT_SYMBOL_GPL(qcom_find_src_index);

int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map, u8 cfg)
{
	int i, num_parents = clk_hw_get_num_parents(hw);

	for (i = 0; i < num_parents; i++)
		if (cfg == map[i].cfg)
			return i;

	return -ENOENT;
}
EXPORT_SYMBOL(qcom_find_cfg_index);

struct regmap *
qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc)
{
+3 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2014, 2018, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2014, 2018-2019, The Linux Foundation. All rights reserved. */

#ifndef __QCOM_CLK_COMMON_H__
#define __QCOM_CLK_COMMON_H__
@@ -57,6 +57,8 @@ extern void
qcom_pll_set_fsm_mode(struct regmap *m, u32 reg, u8 bias_count, u8 lock_count);
extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
			       u8 src);
extern int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map,
			       u8 cfg);

extern int qcom_cc_register_board_clk(struct device *dev, const char *path,
				      const char *name, unsigned long rate);