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

Commit 182657b0 authored by Amit Nischal's avatar Amit Nischal Committed by Taniya Das
Browse files

clk: qcom: Check for errors during RCG read



There could be instances where the RCG configuration update or readback
could fail. Notify the caller of the failure. Add support to change
scope of mux_div_get_src_div() in order to use it globally.

Change-Id: Ica07c28cede695785db81697effcb40ab6b717d4
Signed-off-by: default avatarAmit Nischal <anischal@codeaurora.org>
Signed-off-by: default avatarTaniya Das <tdas@codeaurora.org>
parent 37854450
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015, Linaro Limited
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014, 2017, The Linux Foundation. All rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
@@ -64,20 +64,26 @@ int __mux_div_set_src_div(struct clk_regmap_mux_div *md, u32 src, u32 div)
	return -EBUSY;
}

static void __mux_div_get_src_div(struct clk_regmap_mux_div *md, u32 *src,
int mux_div_get_src_div(struct clk_regmap_mux_div *md, u32 *src,
				  u32 *div)
{
	int ret = 0;
	u32 val, __div, __src;
	const char *name = clk_hw_get_name(&md->clkr.hw);

	regmap_read(md->clkr.regmap, CMD_RCGR + md->reg_offset, &val);
	ret = regmap_read(md->clkr.regmap, CMD_RCGR + md->reg_offset, &val);
	if (ret)
		return ret;

	if (val & CMD_RCGR_DIRTY_CFG) {
		pr_err("%s: RCG configuration is pending\n", name);
		return;
		return -EBUSY;
	}

	regmap_read(md->clkr.regmap, CFG_RCGR + md->reg_offset, &val);
	ret = regmap_read(md->clkr.regmap, CFG_RCGR + md->reg_offset, &val);
	if (ret)
		return ret;

	__src = (val >> md->src_shift);
	__src &= BIT(md->src_width) - 1;
	*src = __src;
@@ -85,6 +91,8 @@ static void __mux_div_get_src_div(struct clk_regmap_mux_div *md, u32 *src,
	__div = (val >> md->hid_shift);
	__div &= BIT(md->hid_width) - 1;
	*div = __div;

	return ret;
}

static int mux_div_enable(struct clk_hw *hw)
@@ -181,7 +189,7 @@ static u8 mux_div_get_parent(struct clk_hw *hw)
	const char *name = clk_hw_get_name(hw);
	u32 i, div, src = 0;

	__mux_div_get_src_div(md, &src, &div);
	mux_div_get_src_div(md, &src, &div);

	for (i = 0; i < clk_hw_get_num_parents(hw); i++)
		if (src == md->parent_map[i].cfg)
@@ -222,7 +230,7 @@ static unsigned long mux_div_recalc_rate(struct clk_hw *hw, unsigned long prate)
	int i, num_parents = clk_hw_get_num_parents(hw);
	const char *name = clk_hw_get_name(hw);

	__mux_div_get_src_div(md, &src, &div);
	mux_div_get_src_div(md, &src, &div);
	for (i = 0; i < num_parents; i++)
		if (src == md->parent_map[i].cfg) {
			struct clk_hw *p = clk_hw_get_parent_by_index(hw, i);
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015, Linaro Limited
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014, 2017, The Linux Foundation. All rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
@@ -61,5 +61,6 @@ struct clk_regmap_mux_div {

extern const struct clk_ops clk_regmap_mux_div_ops;
int __mux_div_set_src_div(struct clk_regmap_mux_div *md, u32 src, u32 div);
int mux_div_get_src_div(struct clk_regmap_mux_div *md, u32 *src, u32 *div);

#endif