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

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

Merge "clk: qcom: Add support for RCGs with dynamic and fixed sources"

parents e8475506 69d0752e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ struct freq_tbl {
	u8 pre_div;
	u16 m;
	u16 n;
	unsigned long src_freq;
#define FIXED_FREQ_SRC   0
};

/**
+19 −1
Original line number Diff line number Diff line
@@ -264,9 +264,10 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f,
				    enum freq_policy policy)
{
	unsigned long clk_flags, rate = req->rate;
	struct clk_rate_request parent_req = { };
	struct clk_hw *p;
	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
	int index;
	int index, ret = 0;

	switch (policy) {
	case FLOOR:
@@ -288,6 +289,8 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f,

	clk_flags = clk_hw_get_flags(hw);
	p = clk_hw_get_parent_by_index(hw, index);
	if (!p)
		return -EINVAL;
	if (clk_flags & CLK_SET_RATE_PARENT) {
		rate = f->freq;
		if (f->pre_div) {
@@ -308,6 +311,21 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f,
	req->best_parent_rate = rate;
	req->rate = f->freq;

	if (f->src_freq != FIXED_FREQ_SRC) {
		rate = parent_req.rate = f->src_freq;
		parent_req.best_parent_hw = p;
		ret = __clk_determine_rate(p, &parent_req);
		if (ret)
			return ret;

		ret = clk_set_rate(p->clk, parent_req.rate);
		if (ret) {
			pr_err("Failed set rate(%lu) on parent for non-fixed source\n",
							parent_req.rate);
			return ret;
		}
	}

	return 0;
}