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

Commit 73cb701d authored by Patrick Daly's avatar Patrick Daly Committed by Gerrit - the friendly Code Review server
Browse files

clk: clock-voter: Support parsing sw voter clocks from dt



This clock type is able to manage several software clients.
Add functionality to parse this voter clock information
from device tree.

Change-Id: I0ea2df05c7c0cb29d5e6eaa8091d5759255c75f0
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent 44b5732e
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -535,3 +535,25 @@ Optional Properties:
	qcom,xo-div4-cbcr = <GCC_GCC_XO_DIV4_CBCR>;
	qcom,test-pad-cfg = <0x51A00>;
};

*****************************************************************************

"qcom,sw-vote-clk"

This clock, like RPM clocks, is a logical rather than physical entity. When several
drivers are clients of a clock which is able to change rate, avoiding a "last vote
wins" scenario is desirable. Several voter clocks are created with the original clock
as their parent, one per client driver. When one client requests to change rate, the
rates of all the "sibling" voter clocks are examined and the maximum rate is passed
on to the parent clock.

Required Properties:
- compatible: 		Must be "qcom,sw-vote-clk".
- qcom,parent:		Phandle reference to the clock which the rate requests are for.
- qcom,config-rate:	Initial rate setting.

snoc_msmbus_clk: snoc_msmbus_clk {
	compatible = "qcom,sw-vote-clk";
	qcom,parent = <&snoc_clk>;
	qcom,config-rate = <100000000>;
};
+27 −0
Original line number Diff line number Diff line
@@ -10,11 +10,14 @@
 * GNU General Public License for more details.
 */

#define pr_fmt(fmt) "%s: " fmt, __func__

#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/clk.h>
#include <linux/clk/msm-clk-provider.h>
#include <soc/qcom/clock-voter.h>
#include <soc/qcom/msm-clock-controller.h>

static DEFINE_MUTEX(voter_clk_lock);

@@ -173,3 +176,27 @@ struct clk_ops clk_ops_voter = {
	.is_local = voter_clk_is_local,
	.handoff = voter_clk_handoff,
};

static void *sw_vote_clk_dt_parser(struct device *dev,
					struct device_node *np)
{
	struct clk_voter *v;
	int rc;
	u32 temp;

	v = devm_kzalloc(dev, sizeof(*v), GFP_KERNEL);
	if (!v) {
		dt_err(np, "failed to alloc memory\n");
		return ERR_PTR(-ENOMEM);
	}

	rc = of_property_read_u32(np, "qcom,config-rate", &temp);
	if (rc) {
		dt_prop_err(np, "qcom,config-rate", "is missing");
		return ERR_PTR(rc);
	}

	v->c.ops = &clk_ops_voter;
	return msmclk_generic_clk_init(dev, np, &v->c);
}
MSMCLK_PARSER(sw_vote_clk_dt_parser, "qcom,sw-vote-clk", 0);