drivers/power/reset/at91-reset.c
Source file repositories/reference/linux-study-clean/drivers/power/reset/at91-reset.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/reset/at91-reset.c- Extension
.c- Size
- 11735 bytes
- Lines
- 440
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk.hlinux/io.hlinux/module.hlinux/of_address.hlinux/platform_device.hlinux/reboot.hlinux/reset-controller.hlinux/power/power_on_reason.hsoc/at91/at91sam9_ddrsdr.hsoc/at91/at91sam9_sdramc.hdt-bindings/reset/sama7g5-reset.h
Detected Declarations
struct at91_resetstruct at91_reset_dataenum reset_typefunction at91_resetfunction power_on_reason_showfunction at91_reset_updatefunction at91_reset_assertfunction at91_reset_deassertfunction at91_reset_dev_statusfunction at91_reset_of_xlatefunction at91_rcdev_initfunction at91_reset_probefunction at91_reset_remove
Annotated Snippet
struct at91_reset {
void __iomem *rstc_base;
void __iomem *ramc_base[2];
void __iomem *dev_base;
struct clk *sclk;
const struct at91_reset_data *data;
struct reset_controller_dev rcdev;
spinlock_t lock;
struct notifier_block nb;
u32 args;
u32 ramc_lpr;
};
#define to_at91_reset(r) container_of(r, struct at91_reset, rcdev)
/**
* struct at91_reset_data - AT91 reset data
* @reset_args: SoC specific system reset arguments
* @n_device_reset: number of device resets
* @device_reset_min_id: min id for device reset
* @device_reset_max_id: max id for device reset
*/
struct at91_reset_data {
u32 reset_args;
u32 n_device_reset;
u8 device_reset_min_id;
u8 device_reset_max_id;
};
/*
* unless the SDRAM is cleanly shutdown before we hit the
* reset register it can be left driving the data bus and
* killing the chance of a subsequent boot from NAND
*/
static int at91_reset(struct notifier_block *this, unsigned long mode,
void *cmd)
{
struct at91_reset *reset = container_of(this, struct at91_reset, nb);
asm volatile(
/* Align to cache lines */
".balign 32\n\t"
/* Disable SDRAM0 accesses */
" tst %0, #0\n\t"
" beq 1f\n\t"
" str %3, [%0, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t"
/* Power down SDRAM0 */
" str %4, [%0, %6]\n\t"
/* Disable SDRAM1 accesses */
"1: tst %1, #0\n\t"
" strne %3, [%1, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t"
/* Power down SDRAM1 */
" strne %4, [%1, %6]\n\t"
/* Reset CPU */
" str %5, [%2, #" __stringify(AT91_RSTC_CR) "]\n\t"
" b .\n\t"
:
: "r" (reset->ramc_base[0]),
"r" (reset->ramc_base[1]),
"r" (reset->rstc_base),
"r" (1),
"r" cpu_to_le32(AT91_DDRSDRC_LPCB_POWER_DOWN),
"r" (reset->data->reset_args),
"r" (reset->ramc_lpr)
);
return NOTIFY_DONE;
}
static const char *at91_reset_reason(struct at91_reset *reset)
{
u32 reg = readl(reset->rstc_base + AT91_RSTC_SR);
const char *reason;
switch ((reg & AT91_RSTC_RSTTYP) >> 8) {
case RESET_TYPE_GENERAL:
reason = POWER_ON_REASON_REGULAR;
break;
case RESET_TYPE_WAKEUP:
reason = POWER_ON_REASON_RTC;
break;
case RESET_TYPE_WATCHDOG:
reason = POWER_ON_REASON_WATCHDOG;
break;
case RESET_TYPE_SOFTWARE:
reason = POWER_ON_REASON_SOFTWARE;
break;
case RESET_TYPE_USER:
Annotation
- Immediate include surface: `linux/clk.h`, `linux/io.h`, `linux/module.h`, `linux/of_address.h`, `linux/platform_device.h`, `linux/reboot.h`, `linux/reset-controller.h`, `linux/power/power_on_reason.h`.
- Detected declarations: `struct at91_reset`, `struct at91_reset_data`, `enum reset_type`, `function at91_reset`, `function power_on_reason_show`, `function at91_reset_update`, `function at91_reset_assert`, `function at91_reset_deassert`, `function at91_reset_dev_status`, `function at91_reset_of_xlate`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.