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

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

Merge "clk: add bus voting ops for debug purposes"

parents 8f716eac 813f6662
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -3236,10 +3236,14 @@ static void clk_summary_show_subtree(struct seq_file *s, struct clk_core *c,
	if (!c)
		return;

	if (c->ops->bus_vote)
		c->ops->bus_vote(c->hw, true);
	clk_summary_show_one(s, c, level);

	hlist_for_each_entry(child, &c->children, child_node)
		clk_summary_show_subtree(s, child, level + 1);
	if (c->ops->bus_vote)
		c->ops->bus_vote(c->hw, false);
}

static int clk_summary_show(struct seq_file *s, void *data)
@@ -3287,6 +3291,9 @@ static void clk_dump_subtree(struct seq_file *s, struct clk_core *c, int level)
	if (!c)
		return;

	if (c->ops->bus_vote)
		c->ops->bus_vote(c->hw, true);

	clk_dump_one(s, c, level);

	hlist_for_each_entry(child, &c->children, child_node) {
@@ -3295,6 +3302,9 @@ static void clk_dump_subtree(struct seq_file *s, struct clk_core *c, int level)
	}

	seq_putc(s, '}');

	if (c->ops->bus_vote)
		c->ops->bus_vote(c->hw, false);
}

static int clk_dump_show(struct seq_file *s, void *data)
@@ -3596,7 +3606,15 @@ void clk_debug_print_hw(struct clk_core *clk, struct seq_file *f)
	if (!clk->ops->list_registers)
		return;

	clk_prepare_lock();
	if (clk->ops->bus_vote)
		clk->ops->bus_vote(clk->hw, true);

	clk->ops->list_registers(f, clk->hw);

	if (clk->ops->bus_vote)
		clk->ops->bus_vote(clk->hw, false);
	clk_prepare_unlock();
}
EXPORT_SYMBOL(clk_debug_print_hw);

@@ -3604,8 +3622,16 @@ static int print_hw_show(struct seq_file *m, void *unused)
{
	struct clk_core *c = m->private;

	clk_prepare_lock();
	if (c->ops->bus_vote)
		c->ops->bus_vote(c->hw, true);

	clk_debug_print_hw(c, m);

	if (c->ops->bus_vote)
		c->ops->bus_vote(c->hw, false);
	clk_prepare_unlock();

	return 0;
}

+16 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/bitops.h>
#include <linux/msm-bus.h>

#include "clk-regmap.h"
#include "clk-debug.h"
@@ -243,6 +244,13 @@ static int clk_debug_measure_get(void *data, u64 *val)

	mutex_lock(&clk_debug_lock);

	/*
	 * Vote for bandwidth to re-connect config ports
	 * to multimedia clock controllers.
	 */
	if (meas->bus_cl_id)
		msm_bus_scale_client_update_request(meas->bus_cl_id, 1);

	ret = clk_set_parent(measure->clk, hw->clk);
	if (!ret) {
		par = measure;
@@ -280,6 +288,8 @@ static int clk_debug_measure_get(void *data, u64 *val)
exit1:
	disable_debug_clks(meas, index);
exit:
	if (meas->bus_cl_id)
		msm_bus_scale_client_update_request(meas->bus_cl_id, 0);
	mutex_unlock(&clk_debug_lock);
	return ret;
}
@@ -335,11 +345,13 @@ void clk_debug_measure_add(struct clk_hw *hw, struct dentry *dentry)
	}

	meas = to_clk_measure(measure);
	if (meas->bus_cl_id)
		msm_bus_scale_client_update_request(meas->bus_cl_id, 1);
	ret = clk_set_parent(measure->clk, hw->clk);
	if (ret) {
		pr_debug("Unable to set %s as %s's parent, ret=%d\n",
			clk_hw_get_name(hw), clk_hw_get_name(measure), ret);
		return;
		goto err;
	}

	index = clk_debug_mux_get_parent(measure);
@@ -349,6 +361,9 @@ void clk_debug_measure_add(struct clk_hw *hw, struct dentry *dentry)
	else
		debugfs_create_file("clk_measure", 0444, dentry, hw,
					&clk_measure_fops);
err:
	if (meas->bus_cl_id)
		msm_bus_scale_client_update_request(meas->bus_cl_id, 0);
}
EXPORT_SYMBOL(clk_debug_measure_add);

+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ struct clk_debug_mux {
	u32 post_div_mask;
	u32 post_div_shift;
	u32 period_offset;
	u32 bus_cl_id;
	struct clk_hw hw;
};

+6 −0
Original line number Diff line number Diff line
@@ -219,6 +219,9 @@ struct clk_duty {
 *		clock that is below rate_max. Return -ENXIO in case there is
 *		no frequency table.
 *
 * @bus_vote:	Votes for bandwidth on certain config slaves to connect
 *		ports in order to gain access to clock controllers.
 *
 * The clk_enable/clk_disable and clk_prepare/clk_unprepare pairs allow
 * implementations to split any work between atomic (enable) and sleepable
 * (prepare) contexts.  If enabling a clock requires code that might sleep,
@@ -267,6 +270,7 @@ struct clk_ops {
							struct clk_hw *hw);
	long		(*list_rate)(struct clk_hw *hw, unsigned int n,
							unsigned long rate_max);
	void		(*bus_vote)(struct clk_hw *hw, bool enable);
};

/**
@@ -281,6 +285,7 @@ struct clk_ops {
 * @vdd_class: voltage scaling requirement class
 * @rate_max: maximum clock rate in Hz supported at each voltage level
 * @num_rate_max: number of maximum voltage level supported
 * @bus_cl_id: client id registered with the bus driver used for bw votes
 */
struct clk_init_data {
	const char		*name;
@@ -291,6 +296,7 @@ struct clk_init_data {
	struct clk_vdd_class	*vdd_class;
	unsigned long		*rate_max;
	int			num_rate_max;
	unsigned int		bus_cl_id;
};

struct regulator;