drivers/platform/x86/intel/bytcrc_pwrsrc.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/intel/bytcrc_pwrsrc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/intel/bytcrc_pwrsrc.c- Extension
.c- Size
- 6992 bytes
- Lines
- 256
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/bits.hlinux/debugfs.hlinux/interrupt.hlinux/mfd/intel_soc_pmic.hlinux/module.hlinux/platform_device.hlinux/power_supply.hlinux/property.hlinux/regmap.h
Detected Declarations
struct crc_pwrsrc_datafunction crc_pwrsrc_logfunction pwrsrc_showfunction resetsrc_showfunction wakesrc_showfunction crc_pwrsrc_read_and_clearfunction crc_pwrsrc_irq_handlerfunction crc_pwrsrc_psy_get_propertyfunction crc_pwrsrc_probefunction crc_pwrsrc_remove
Annotated Snippet
struct crc_pwrsrc_data {
struct regmap *regmap;
struct dentry *debug_dentry;
struct power_supply *psy;
unsigned int resetsrc0;
unsigned int resetsrc1;
unsigned int wakesrc;
};
static const char * const pwrsrc_pwrsrc_info[] = {
/* bit 0 */ "USB",
/* bit 1 */ "DC in",
/* bit 2 */ "Battery",
NULL,
};
static const char * const pwrsrc_resetsrc0_info[] = {
/* bit 0 */ "SOC reporting a thermal event",
/* bit 1 */ "critical PMIC temperature",
/* bit 2 */ "critical system temperature",
/* bit 3 */ "critical battery temperature",
/* bit 4 */ "VSYS under voltage",
/* bit 5 */ "VSYS over voltage",
/* bit 6 */ "battery removal",
NULL,
};
static const char * const pwrsrc_resetsrc1_info[] = {
/* bit 0 */ "VCRIT threshold",
/* bit 1 */ "BATID reporting battery removal",
/* bit 2 */ "user pressing the power button",
NULL,
};
static const char * const pwrsrc_wakesrc_info[] = {
/* bit 0 */ "user pressing the power button",
/* bit 1 */ "a battery insertion",
/* bit 2 */ "a USB charger insertion",
/* bit 3 */ "an adapter insertion",
NULL,
};
static void crc_pwrsrc_log(struct seq_file *seq, const char *prefix,
const char * const *info, unsigned int reg_val)
{
int i;
for (i = 0; info[i]; i++) {
if (reg_val & BIT(i))
seq_printf(seq, "%s by %s\n", prefix, info[i]);
}
}
static int pwrsrc_show(struct seq_file *seq, void *unused)
{
struct crc_pwrsrc_data *data = seq->private;
unsigned int reg_val;
int ret;
ret = regmap_read(data->regmap, CRYSTALCOVE_SPWRSRC_REG, ®_val);
if (ret)
return ret;
crc_pwrsrc_log(seq, "System powered", pwrsrc_pwrsrc_info, reg_val);
return 0;
}
static int resetsrc_show(struct seq_file *seq, void *unused)
{
struct crc_pwrsrc_data *data = seq->private;
crc_pwrsrc_log(seq, "Last shutdown caused", pwrsrc_resetsrc0_info, data->resetsrc0);
crc_pwrsrc_log(seq, "Last shutdown caused", pwrsrc_resetsrc1_info, data->resetsrc1);
return 0;
}
static int wakesrc_show(struct seq_file *seq, void *unused)
{
struct crc_pwrsrc_data *data = seq->private;
crc_pwrsrc_log(seq, "Last wake caused", pwrsrc_wakesrc_info, data->wakesrc);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(pwrsrc);
DEFINE_SHOW_ATTRIBUTE(resetsrc);
DEFINE_SHOW_ATTRIBUTE(wakesrc);
static int crc_pwrsrc_read_and_clear(struct crc_pwrsrc_data *data,
unsigned int reg, unsigned int *val)
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bits.h`, `linux/debugfs.h`, `linux/interrupt.h`, `linux/mfd/intel_soc_pmic.h`, `linux/module.h`, `linux/platform_device.h`, `linux/power_supply.h`.
- Detected declarations: `struct crc_pwrsrc_data`, `function crc_pwrsrc_log`, `function pwrsrc_show`, `function resetsrc_show`, `function wakesrc_show`, `function crc_pwrsrc_read_and_clear`, `function crc_pwrsrc_irq_handler`, `function crc_pwrsrc_psy_get_property`, `function crc_pwrsrc_probe`, `function crc_pwrsrc_remove`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.