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

Commit 2fadb00c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: clock: Add a new API to print registers for debugging"

parents ec6b26c4 c4380fd7
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <linux/clkdev.h>
#include <linux/uaccess.h>
#include <linux/mutex.h>
#include <linux/io.h>

#include <mach/clk-provider.h>

@@ -412,6 +413,56 @@ static const struct file_operations clock_parent_fops = {
	.write		= clock_parent_write,
};

void clk_debug_print_hw(struct clk *clk, struct seq_file *f)
{
	void __iomem *base;
	struct clk_register_data *regs;
	u32 i, j, size;

	if (IS_ERR_OR_NULL(clk))
		return;

	clk_debug_print_hw(clk->parent, f);

	clock_debug_output(f, false, "%s\n", clk->dbg_name);

	if (!clk->ops->list_registers)
		return;

	j = 0;
	base = clk->ops->list_registers(clk, j, &regs, &size);
	while (!IS_ERR(base)) {
		for (i = 0; i < size; i++) {
			u32 val = readl_relaxed(base + regs[i].offset);
			clock_debug_output(f, false, "%20s: 0x%.8x\n",
						regs[i].name, val);
		}
		j++;
		base = clk->ops->list_registers(clk, j, &regs, &size);
	}
}

static int print_hw_show(struct seq_file *m, void *unused)
{
	struct clk *c = m->private;
	clk_debug_print_hw(c, m);

	return 0;
}

static int print_hw_open(struct inode *inode, struct file *file)
{
	return single_open(file, print_hw_show, inode->i_private);
}

static const struct file_operations clock_print_hw_fops = {
	.open		= print_hw_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= seq_release,
};


static int clock_debug_add(struct clk *clock)
{
	char temp[50], *ptr;
@@ -463,6 +514,10 @@ static int clock_debug_add(struct clk *clock)
				&clock_parent_fops))
			goto error;

	if (!debugfs_create_file("print", S_IRUGO, clk_dir, clock,
				&clock_print_hw_fops))
			goto error;

	return 0;
error:
	debugfs_remove_recursive(clk_dir);
+18 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
#include <linux/seq_file.h>
#include <mach/clk.h>

/*
@@ -41,6 +42,21 @@
#define ENABLE_VOTED	4	/* Bit pol: 1 = running; delay on disable */
#define DELAY		5	/* No bit to check, just delay */

struct clk_register_data {
	char *name;
	u32 offset;
};
#ifdef CONFIG_DEBUG_FS
void clk_debug_print_hw(struct clk *clk, struct seq_file *f);
#else
static inline void clock_debug_print_hw(struct clk *clk, struct seq_file *f) {}
#endif

#define CLK_WARN(clk, cond, fmt, ...) do {				\
	clk_debug_print_hw(clk, NULL);					\
	WARN(cond, "%s: " fmt, (clk)->dbg_name, ##__VA_ARGS__);		\
} while (0)

/**
 * struct clk_vdd_class - Voltage scaling class
 * @class_name: name of the class
@@ -129,6 +145,8 @@ struct clk_ops {
	int (*set_parent)(struct clk *clk, struct clk *parent);
	struct clk *(*get_parent)(struct clk *clk);
	bool (*is_local)(struct clk *clk);
	void __iomem *(*list_registers)(struct clk *clk, int n,
				struct clk_register_data **regs, u32 *size);
};

/**