drivers/power/reset/gemini-poweroff.c
Source file repositories/reference/linux-study-clean/drivers/power/reset/gemini-poweroff.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/reset/gemini-poweroff.c- Extension
.c- Size
- 4355 bytes
- Lines
- 176
- Domain
- Driver Families
- Bucket
- drivers/power
- 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/of.hlinux/of_platform.hlinux/platform_device.hlinux/pm.hlinux/bitops.hlinux/interrupt.hlinux/io.hlinux/reboot.h
Detected Declarations
struct gemini_powerconfunction gemini_powerbutton_interruptfunction gemini_powerofffunction gemini_poweroff_probe
Annotated Snippet
struct gemini_powercon {
struct device *dev;
void __iomem *base;
};
static irqreturn_t gemini_powerbutton_interrupt(int irq, void *data)
{
struct gemini_powercon *gpw = data;
u32 val;
/* ACK the IRQ */
val = readl(gpw->base + GEMINI_PWC_CTRLREG);
val |= GEMINI_CTRL_IRQ_CLR;
writel(val, gpw->base + GEMINI_PWC_CTRLREG);
val = readl(gpw->base + GEMINI_PWC_STATREG);
val &= 0x70U;
switch (val) {
case GEMINI_STAT_CIR:
/*
* We do not yet have a driver for the infrared
* controller so it can cause spurious poweroff
* events. Ignore those for now.
*/
dev_info(gpw->dev, "infrared poweroff - ignored\n");
break;
case GEMINI_STAT_RTC:
dev_info(gpw->dev, "RTC poweroff\n");
orderly_poweroff(true);
break;
case GEMINI_STAT_POWERBUTTON:
dev_info(gpw->dev, "poweroff button pressed\n");
orderly_poweroff(true);
break;
default:
dev_info(gpw->dev, "other power management IRQ\n");
break;
}
return IRQ_HANDLED;
}
static int gemini_poweroff(struct sys_off_data *data)
{
struct gemini_powercon *gpw = data->cb_data;
u32 val;
dev_crit(gpw->dev, "Gemini power off\n");
val = readl(gpw->base + GEMINI_PWC_CTRLREG);
val |= GEMINI_CTRL_ENABLE | GEMINI_CTRL_IRQ_CLR;
writel(val, gpw->base + GEMINI_PWC_CTRLREG);
val &= ~GEMINI_CTRL_ENABLE;
val |= GEMINI_CTRL_SHUTDOWN;
writel(val, gpw->base + GEMINI_PWC_CTRLREG);
return NOTIFY_DONE;
}
static int gemini_poweroff_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct gemini_powercon *gpw;
u32 val;
int irq;
int ret;
gpw = devm_kzalloc(dev, sizeof(*gpw), GFP_KERNEL);
if (!gpw)
return -ENOMEM;
gpw->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(gpw->base))
return PTR_ERR(gpw->base);
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
gpw->dev = dev;
val = readl(gpw->base + GEMINI_PWC_IDREG);
val &= 0xFFFFFF00U;
if (val != GEMINI_PWC_ID) {
dev_err(dev, "wrong power controller ID: %08x\n",
val);
return -ENODEV;
}
/*
Annotation
- Immediate include surface: `linux/of.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/pm.h`, `linux/bitops.h`, `linux/interrupt.h`, `linux/io.h`, `linux/reboot.h`.
- Detected declarations: `struct gemini_powercon`, `function gemini_powerbutton_interrupt`, `function gemini_poweroff`, `function gemini_poweroff_probe`.
- Atlas domain: Driver Families / drivers/power.
- 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.