drivers/platform/x86/intel/pmc/core.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/intel/pmc/core.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/intel/pmc/core.c
Extension
.c
Size
54022 bytes
Lines
2078
Domain
Driver Families
Bucket
drivers/platform
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

const struct file_operations pmc_core_substate_blk_req_fops = {
	.owner		= THIS_MODULE,
	.open		= pmc_core_substate_blk_req_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

static int pmc_core_substate_req_regs_show(struct seq_file *s, void *unused)
{
	struct pmc_dev *pmcdev = s->private;
	u32 sts_offset;
	u32 sts_offset_live;
	u32 *lpm_req_regs;
	unsigned int mp, pmc_idx;
	int num_maps;

	for (pmc_idx = 0; pmc_idx < ARRAY_SIZE(pmcdev->pmcs); ++pmc_idx) {
		struct pmc *pmc = pmcdev->pmcs[pmc_idx];
		const struct pmc_bit_map **maps;

		if (!pmc)
			continue;

		maps = pmc->map->lpm_sts;
		num_maps = pmc->map->lpm_num_maps;
		sts_offset = pmc->map->lpm_status_offset;
		sts_offset_live = pmc->map->lpm_live_status_offset;
		lpm_req_regs = pmc->lpm_req_regs;

		/*
		 * When there are multiple PMCs, though the PMC may exist, the
		 * requirement register discovery could have failed so check
		 * before accessing.
		 */
		if (!lpm_req_regs)
			continue;

		/* Display the header */
		pmc_core_substate_req_header_show(s, pmc_idx, HEADER_STATUS);

		/* Loop over maps */
		for (mp = 0; mp < num_maps; mp++) {
			u32 req_mask = 0;
			u32 lpm_status;
			u32 lpm_status_live;
			const struct pmc_bit_map *map;
			int i, len = 32;
			u8 mode;

			/*
			 * Capture the requirements and create a mask so that we only
			 * show an element if it's required for at least one of the
			 * enabled low power modes
			 */
			pmc_for_each_mode(mode, pmc)
				req_mask |= lpm_req_regs[mp + (mode * num_maps)];

			/* Get the last latched status for this map */
			lpm_status = pmc_core_reg_read(pmc, sts_offset + (mp * 4));

			/* Get the runtime status for this map */
			lpm_status_live = pmc_core_reg_read(pmc, sts_offset_live + (mp * 4));

			/*  Loop over elements in this map */
			map = maps[mp];
			for (i = 0; map[i].name && i < len; i++) {
				u32 bit_mask = map[i].bit_mask;

				if (!(bit_mask & req_mask)) {
					/*
					 * Not required for any enabled states
					 * so don't display
					 */
					continue;
				}

				/* Display the element name in the first column */
				seq_printf(s, "pmc%d: %34s |", pmc_idx, map[i].name);

				/* Loop over the enabled states and display if required */
				pmc_for_each_mode(mode, pmc) {
					bool required = lpm_req_regs[mp + (mode * num_maps)] &
							bit_mask;
					seq_printf(s, " %9s |", required ? "Required" : " ");
				}

				/* In Status column, show the last captured state of this agent */
				seq_printf(s, " %9s |", lpm_status & bit_mask ? "Yes" : " ");

Annotation

Implementation Notes