drivers/opp/debugfs.c

Source file repositories/reference/linux-study-clean/drivers/opp/debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/opp/debugfs.c
Extension
.c
Size
7596 bytes
Lines
282
Domain
Driver Families
Bucket
drivers/opp
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations bw_name_fops = {
	.open = simple_open,
	.read = bw_name_read,
	.llseek = default_llseek,
};

static void opp_debug_create_bw(struct dev_pm_opp *opp,
				struct opp_table *opp_table,
				struct dentry *pdentry)
{
	struct dentry *d;
	char name[] = "icc-path-XXXXXXXXXXX"; /* Integers can take 11 chars max */
	int i;

	for (i = 0; i < opp_table->path_count; i++) {
		snprintf(name, sizeof(name), "icc-path-%d", i);

		/* Create per-path directory */
		d = debugfs_create_dir(name, pdentry);

		debugfs_create_file("name", S_IRUGO, d, opp_table->paths[i],
				    &bw_name_fops);
		debugfs_create_u32("peak_bw", S_IRUGO, d,
				   &opp->bandwidth[i].peak);
		debugfs_create_u32("avg_bw", S_IRUGO, d,
				   &opp->bandwidth[i].avg);
	}
}

static void opp_debug_create_clks(struct dev_pm_opp *opp,
				  struct opp_table *opp_table,
				  struct dentry *pdentry)
{
	char name[] = "rate_hz_XXXXXXXXXXX"; /* Integers can take 11 chars max */
	int i;

	if (opp_table->clk_count == 1) {
		debugfs_create_ulong("rate_hz", S_IRUGO, pdentry, &opp->rates[0]);
		return;
	}

	for (i = 0; i < opp_table->clk_count; i++) {
		snprintf(name, sizeof(name), "rate_hz_%d", i);
		debugfs_create_ulong(name, S_IRUGO, pdentry, &opp->rates[i]);
	}
}

static void opp_debug_create_supplies(struct dev_pm_opp *opp,
				      struct opp_table *opp_table,
				      struct dentry *pdentry)
{
	struct dentry *d;
	int i;

	for (i = 0; i < opp_table->regulator_count; i++) {
		char name[] = "supply-XXXXXXXXXXX"; /* Integers can take 11 chars max */

		snprintf(name, sizeof(name), "supply-%d", i);

		/* Create per-opp directory */
		d = debugfs_create_dir(name, pdentry);

		debugfs_create_ulong("u_volt_target", S_IRUGO, d,
				     &opp->supplies[i].u_volt);

		debugfs_create_ulong("u_volt_min", S_IRUGO, d,
				     &opp->supplies[i].u_volt_min);

		debugfs_create_ulong("u_volt_max", S_IRUGO, d,
				     &opp->supplies[i].u_volt_max);

		debugfs_create_ulong("u_amp", S_IRUGO, d,
				     &opp->supplies[i].u_amp);

		debugfs_create_ulong("u_watt", S_IRUGO, d,
				     &opp->supplies[i].u_watt);
	}
}

void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
{
	struct dentry *pdentry = opp_table->dentry;
	struct dentry *d;
	char name[36];	/* "opp:"(4) + u64(20) + "-" (1) + u32(10) + NULL(1) */

	/*
	 * Get directory name for OPP.
	 *
	 * - Normally rate is unique to each OPP, use it to get unique opp-name,
	 *   together with performance level if available.

Annotation

Implementation Notes