drivers/power/reset/at91-poweroff.c
Source file repositories/reference/linux-study-clean/drivers/power/reset/at91-poweroff.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/reset/at91-poweroff.c- Extension
.c- Size
- 6244 bytes
- Lines
- 237
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/io.hlinux/module.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/printk.hsoc/at91/at91sam9_ddrsdr.h
Detected Declarations
enum wakeup_typefunction at91_wakeup_statusfunction at91_powerofffunction at91_poweroff_get_wakeup_modefunction at91_poweroff_dt_set_wakeup_modefunction at91_poweroff_probefunction at91_poweroff_remove
Annotated Snippet
if (tmp > AT91_SHDW_CPTWK0_MAX) {
dev_warn(&pdev->dev,
"shdwc wakeup counter 0x%x > 0x%x reduce it to 0x%x\n",
tmp, AT91_SHDW_CPTWK0_MAX, AT91_SHDW_CPTWK0_MAX);
tmp = AT91_SHDW_CPTWK0_MAX;
}
mode |= AT91_SHDW_CPTWK0_(tmp);
}
if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
mode |= AT91_SHDW_RTCWKEN;
if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
mode |= AT91_SHDW_RTTWKEN;
writel(wakeup_mode | mode, at91_shdwc.shdwc_base + AT91_SHDW_MR);
}
static int at91_poweroff_probe(struct platform_device *pdev)
{
struct device_node *np;
u32 ddr_type;
int ret;
at91_shdwc.shdwc_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(at91_shdwc.shdwc_base))
return PTR_ERR(at91_shdwc.shdwc_base);
at91_shdwc.sclk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(at91_shdwc.sclk))
return PTR_ERR(at91_shdwc.sclk);
ret = clk_prepare_enable(at91_shdwc.sclk);
if (ret) {
dev_err(&pdev->dev, "Could not enable slow clock\n");
return ret;
}
at91_wakeup_status(pdev);
if (pdev->dev.of_node)
at91_poweroff_dt_set_wakeup_mode(pdev);
np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc");
if (np) {
at91_shdwc.mpddrc_base = of_iomap(np, 0);
of_node_put(np);
if (!at91_shdwc.mpddrc_base) {
ret = -ENOMEM;
goto clk_disable;
}
ddr_type = readl(at91_shdwc.mpddrc_base + AT91_DDRSDRC_MDR) &
AT91_DDRSDRC_MD;
if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
iounmap(at91_shdwc.mpddrc_base);
at91_shdwc.mpddrc_base = NULL;
}
}
pm_power_off = at91_poweroff;
return 0;
clk_disable:
clk_disable_unprepare(at91_shdwc.sclk);
return ret;
}
static void at91_poweroff_remove(struct platform_device *pdev)
{
if (pm_power_off == at91_poweroff)
pm_power_off = NULL;
if (at91_shdwc.mpddrc_base)
iounmap(at91_shdwc.mpddrc_base);
clk_disable_unprepare(at91_shdwc.sclk);
}
static const struct of_device_id at91_poweroff_of_match[] = {
{ .compatible = "atmel,at91sam9260-shdwc", },
{ .compatible = "atmel,at91sam9rl-shdwc", },
{ .compatible = "atmel,at91sam9x5-shdwc", },
{ /*sentinel*/ }
};
MODULE_DEVICE_TABLE(of, at91_poweroff_of_match);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/platform_device.h`, `linux/printk.h`, `soc/at91/at91sam9_ddrsdr.h`.
- Detected declarations: `enum wakeup_type`, `function at91_wakeup_status`, `function at91_poweroff`, `function at91_poweroff_get_wakeup_mode`, `function at91_poweroff_dt_set_wakeup_mode`, `function at91_poweroff_probe`, `function at91_poweroff_remove`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
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.