drivers/reset/reset-bcm6345.c
Source file repositories/reference/linux-study-clean/drivers/reset/reset-bcm6345.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/reset-bcm6345.c- Extension
.c- Size
- 3549 bytes
- Lines
- 135
- Domain
- Driver Families
- Bucket
- drivers/reset
- 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/delay.hlinux/init.hlinux/io.hlinux/mod_devicetable.hlinux/platform_device.hlinux/reset-controller.h
Detected Declarations
struct bcm6345_resetfunction to_bcm6345_resetfunction bcm6345_reset_updatefunction bcm6345_reset_assertfunction bcm6345_reset_deassertfunction bcm6345_reset_resetfunction bcm6345_reset_statusfunction bcm6345_reset_probe
Annotated Snippet
struct bcm6345_reset {
struct reset_controller_dev rcdev;
void __iomem *base;
spinlock_t lock;
};
static inline struct bcm6345_reset *
to_bcm6345_reset(struct reset_controller_dev *rcdev)
{
return container_of(rcdev, struct bcm6345_reset, rcdev);
}
static int bcm6345_reset_update(struct reset_controller_dev *rcdev,
unsigned long id, bool assert)
{
struct bcm6345_reset *bcm6345_reset = to_bcm6345_reset(rcdev);
unsigned long flags;
uint32_t val;
spin_lock_irqsave(&bcm6345_reset->lock, flags);
val = __raw_readl(bcm6345_reset->base);
if (assert)
val &= ~BIT(id);
else
val |= BIT(id);
__raw_writel(val, bcm6345_reset->base);
spin_unlock_irqrestore(&bcm6345_reset->lock, flags);
return 0;
}
static int bcm6345_reset_assert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return bcm6345_reset_update(rcdev, id, true);
}
static int bcm6345_reset_deassert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return bcm6345_reset_update(rcdev, id, false);
}
static int bcm6345_reset_reset(struct reset_controller_dev *rcdev,
unsigned long id)
{
bcm6345_reset_update(rcdev, id, true);
usleep_range(BCM6345_RESET_SLEEP_MIN_US,
BCM6345_RESET_SLEEP_MAX_US);
bcm6345_reset_update(rcdev, id, false);
/*
* Ensure component is taken out reset state by sleeping also after
* deasserting the reset. Otherwise, the component may not be ready
* for operation.
*/
usleep_range(BCM6345_RESET_SLEEP_MIN_US,
BCM6345_RESET_SLEEP_MAX_US);
return 0;
}
static int bcm6345_reset_status(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct bcm6345_reset *bcm6345_reset = to_bcm6345_reset(rcdev);
return !(__raw_readl(bcm6345_reset->base) & BIT(id));
}
static const struct reset_control_ops bcm6345_reset_ops = {
.assert = bcm6345_reset_assert,
.deassert = bcm6345_reset_deassert,
.reset = bcm6345_reset_reset,
.status = bcm6345_reset_status,
};
static int bcm6345_reset_probe(struct platform_device *pdev)
{
struct bcm6345_reset *bcm6345_reset;
bcm6345_reset = devm_kzalloc(&pdev->dev,
sizeof(*bcm6345_reset), GFP_KERNEL);
if (!bcm6345_reset)
return -ENOMEM;
bcm6345_reset->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(bcm6345_reset->base))
return PTR_ERR(bcm6345_reset->base);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/io.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/reset-controller.h`.
- Detected declarations: `struct bcm6345_reset`, `function to_bcm6345_reset`, `function bcm6345_reset_update`, `function bcm6345_reset_assert`, `function bcm6345_reset_deassert`, `function bcm6345_reset_reset`, `function bcm6345_reset_status`, `function bcm6345_reset_probe`.
- Atlas domain: Driver Families / drivers/reset.
- 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.