drivers/reset/reset-microchip-sparx5.c
Source file repositories/reference/linux-study-clean/drivers/reset/reset-microchip-sparx5.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/reset-microchip-sparx5.c- Extension
.c- Size
- 5906 bytes
- Lines
- 228
- Domain
- Driver Families
- Bucket
- drivers/reset
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/mfd/syscon.hlinux/of.hlinux/of_address.hlinux/module.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/reset-controller.h
Detected Declarations
struct reset_propsstruct mchp_reset_contextfunction sparx5_switch_resetfunction sparx5_reset_noopfunction mchp_sparx5_map_sysconfunction mchp_sparx5_map_iofunction mchp_sparx5_reset_probefunction mchp_sparx5_reset_init
Annotated Snippet
struct reset_props {
u32 protect_reg;
u32 protect_bit;
u32 reset_reg;
u32 reset_bit;
};
struct mchp_reset_context {
struct regmap *cpu_ctrl;
struct regmap *gcb_ctrl;
struct reset_controller_dev rcdev;
const struct reset_props *props;
};
static struct regmap_config sparx5_reset_regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
};
static int sparx5_switch_reset(struct mchp_reset_context *ctx)
{
u32 val;
/* Make sure the core is PROTECTED from reset */
regmap_update_bits(ctx->cpu_ctrl, ctx->props->protect_reg,
ctx->props->protect_bit, ctx->props->protect_bit);
/* Start soft reset */
regmap_write(ctx->gcb_ctrl, ctx->props->reset_reg,
ctx->props->reset_bit);
/* Wait for soft reset done */
return regmap_read_poll_timeout(ctx->gcb_ctrl, ctx->props->reset_reg, val,
(val & ctx->props->reset_bit) == 0,
1, 100);
}
static int sparx5_reset_noop(struct reset_controller_dev *rcdev,
unsigned long id)
{
return 0;
}
static const struct reset_control_ops sparx5_reset_ops = {
.reset = sparx5_reset_noop,
};
static const struct regmap_config mchp_lan966x_syscon_regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
};
static struct regmap *mchp_lan966x_syscon_to_regmap(struct device *dev,
struct device_node *syscon_np)
{
struct regmap_config regmap_config = mchp_lan966x_syscon_regmap_config;
struct resource res;
void __iomem *base;
int err;
err = of_address_to_resource(syscon_np, 0, &res);
if (err)
return ERR_PTR(err);
/* It is not possible to use devm_of_iomap because this resource is
* shared with other drivers.
*/
base = devm_ioremap(dev, res.start, resource_size(&res));
if (!base)
return ERR_PTR(-ENOMEM);
regmap_config.max_register = resource_size(&res) - 4;
return devm_regmap_init_mmio(dev, base, ®map_config);
}
static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name,
struct regmap **target)
{
struct device_node *syscon_np;
struct regmap *regmap;
int err;
syscon_np = of_parse_phandle(pdev->dev.of_node, name, 0);
if (!syscon_np)
return -ENODEV;
/*
Annotation
- Immediate include surface: `linux/mfd/syscon.h`, `linux/of.h`, `linux/of_address.h`, `linux/module.h`, `linux/platform_device.h`, `linux/property.h`, `linux/regmap.h`, `linux/reset-controller.h`.
- Detected declarations: `struct reset_props`, `struct mchp_reset_context`, `function sparx5_switch_reset`, `function sparx5_reset_noop`, `function mchp_sparx5_map_syscon`, `function mchp_sparx5_map_io`, `function mchp_sparx5_reset_probe`, `function mchp_sparx5_reset_init`.
- Atlas domain: Driver Families / drivers/reset.
- Implementation status: integration 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.