drivers/power/reset/ocelot-reset.c
Source file repositories/reference/linux-study-clean/drivers/power/reset/ocelot-reset.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/reset/ocelot-reset.c- Extension
.c- Size
- 3905 bytes
- Lines
- 153
- 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.
- 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/io.hlinux/notifier.hlinux/mod_devicetable.hlinux/mfd/syscon.hlinux/platform_device.hlinux/property.hlinux/reboot.hlinux/regmap.h
Detected Declarations
struct reset_propsstruct ocelot_reset_contextfunction ocelot_restart_handlefunction ocelot_reset_probe
Annotated Snippet
struct reset_props {
const char *syscon;
u32 protect_reg;
u32 vcore_protect;
u32 if_si_owner_bit;
};
struct ocelot_reset_context {
void __iomem *base;
struct regmap *cpu_ctrl;
const struct reset_props *props;
struct notifier_block restart_handler;
};
#define BIT_OFF_INVALID 32
#define SOFT_CHIP_RST BIT(0)
#define ICPU_CFG_CPU_SYSTEM_CTRL_GENERAL_CTRL 0x24
#define IF_SI_OWNER_MASK GENMASK(1, 0)
#define IF_SI_OWNER_SISL 0
#define IF_SI_OWNER_SIBM 1
#define IF_SI_OWNER_SIMC 2
static int ocelot_restart_handle(struct notifier_block *this,
unsigned long mode, void *cmd)
{
struct ocelot_reset_context *ctx = container_of(this, struct
ocelot_reset_context,
restart_handler);
u32 if_si_owner_bit = ctx->props->if_si_owner_bit;
/* Make sure the core is not protected from reset */
regmap_update_bits(ctx->cpu_ctrl, ctx->props->protect_reg,
ctx->props->vcore_protect, 0);
/* Make the SI back to boot mode */
if (if_si_owner_bit != BIT_OFF_INVALID)
regmap_update_bits(ctx->cpu_ctrl,
ICPU_CFG_CPU_SYSTEM_CTRL_GENERAL_CTRL,
IF_SI_OWNER_MASK << if_si_owner_bit,
IF_SI_OWNER_SIBM << if_si_owner_bit);
pr_emerg("Resetting SoC\n");
writel(SOFT_CHIP_RST, ctx->base);
pr_emerg("Unable to restart system\n");
return NOTIFY_DONE;
}
static int ocelot_reset_probe(struct platform_device *pdev)
{
struct ocelot_reset_context *ctx;
struct device *dev = &pdev->dev;
int err;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
ctx->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ctx->base))
return PTR_ERR(ctx->base);
ctx->props = device_get_match_data(dev);
ctx->cpu_ctrl = syscon_regmap_lookup_by_compatible(ctx->props->syscon);
if (IS_ERR(ctx->cpu_ctrl)) {
dev_err(dev, "No syscon map: %s\n", ctx->props->syscon);
return PTR_ERR(ctx->cpu_ctrl);
}
ctx->restart_handler.notifier_call = ocelot_restart_handle;
ctx->restart_handler.priority = 192;
err = register_restart_handler(&ctx->restart_handler);
if (err)
dev_err(dev, "can't register restart notifier (err=%d)\n", err);
return err;
}
static const struct reset_props reset_props_jaguar2 = {
.syscon = "mscc,ocelot-cpu-syscon",
.protect_reg = 0x20,
.vcore_protect = BIT(2),
.if_si_owner_bit = 6,
};
static const struct reset_props reset_props_luton = {
Annotation
- Immediate include surface: `linux/delay.h`, `linux/io.h`, `linux/notifier.h`, `linux/mod_devicetable.h`, `linux/mfd/syscon.h`, `linux/platform_device.h`, `linux/property.h`, `linux/reboot.h`.
- Detected declarations: `struct reset_props`, `struct ocelot_reset_context`, `function ocelot_restart_handle`, `function ocelot_reset_probe`.
- 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.