drivers/clk/stm32/reset-stm32.c
Source file repositories/reference/linux-study-clean/drivers/clk/stm32/reset-stm32.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/stm32/reset-stm32.c- Extension
.c- Size
- 3651 bytes
- Lines
- 149
- Domain
- Driver Families
- Bucket
- drivers/clk
- 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/of.hlinux/platform_device.hlinux/regmap.hlinux/reset-controller.hlinux/slab.hlinux/spinlock.hreset-stm32.h
Detected Declarations
struct stm32_reset_datafunction to_stm32_reset_datafunction stm32_reset_updatefunction stm32_reset_assertfunction stm32_reset_deassertfunction stm32_reset_statusfunction stm32_rcc_reset_init
Annotated Snippet
struct stm32_reset_data {
/* reset lock */
spinlock_t lock;
struct reset_controller_dev rcdev;
void __iomem *membase;
u32 clear_offset;
const struct stm32_reset_cfg **reset_lines;
};
static inline struct stm32_reset_data *
to_stm32_reset_data(struct reset_controller_dev *rcdev)
{
return container_of(rcdev, struct stm32_reset_data, rcdev);
}
static const struct stm32_reset_cfg *stm32_get_reset_line(struct reset_controller_dev *rcdev,
unsigned long id,
struct stm32_reset_cfg *line)
{
struct stm32_reset_data *data = to_stm32_reset_data(rcdev);
if (!data->reset_lines) {
int reg_width = sizeof(u32);
int bank = id / (reg_width * BITS_PER_BYTE);
int offset = id % (reg_width * BITS_PER_BYTE);
line->offset = bank * reg_width;
line->bit_idx = offset;
line->set_clr = (data->clear_offset ? true : false);
return line;
}
return data->reset_lines[id];
}
static int stm32_reset_update(struct reset_controller_dev *rcdev,
unsigned long id, bool assert)
{
struct stm32_reset_data *data = to_stm32_reset_data(rcdev);
struct stm32_reset_cfg line_reset;
const struct stm32_reset_cfg *ptr_line;
ptr_line = stm32_get_reset_line(rcdev, id, &line_reset);
if (!ptr_line)
return -EPERM;
if (ptr_line->set_clr) {
void __iomem *addr;
addr = data->membase + ptr_line->offset;
if (!assert)
addr += data->clear_offset;
writel(BIT(ptr_line->bit_idx), addr);
} else {
unsigned long flags;
u32 reg;
spin_lock_irqsave(&data->lock, flags);
reg = readl(data->membase + ptr_line->offset);
if (assert)
reg |= BIT(ptr_line->bit_idx);
else
reg &= ~BIT(ptr_line->bit_idx);
writel(reg, data->membase + ptr_line->offset);
spin_unlock_irqrestore(&data->lock, flags);
}
return 0;
}
static int stm32_reset_assert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return stm32_reset_update(rcdev, id, true);
}
static int stm32_reset_deassert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return stm32_reset_update(rcdev, id, false);
}
static int stm32_reset_status(struct reset_controller_dev *rcdev,
Annotation
- Immediate include surface: `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/reset-controller.h`, `linux/slab.h`, `linux/spinlock.h`, `reset-stm32.h`.
- Detected declarations: `struct stm32_reset_data`, `function to_stm32_reset_data`, `function stm32_reset_update`, `function stm32_reset_assert`, `function stm32_reset_deassert`, `function stm32_reset_status`, `function stm32_rcc_reset_init`.
- Atlas domain: Driver Families / drivers/clk.
- 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.