drivers/reset/reset-gpio.c
Source file repositories/reference/linux-study-clean/drivers/reset/reset-gpio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/reset-gpio.c- Extension
.c- Size
- 2632 bytes
- Lines
- 101
- 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.
- 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/auxiliary_bus.hlinux/gpio/consumer.hlinux/mod_devicetable.hlinux/module.hlinux/property.hlinux/reset-controller.h
Detected Declarations
struct reset_gpio_privfunction reset_gpio_assertfunction reset_gpio_deassertfunction reset_gpio_statusfunction reset_gpio_fwnode_xlatefunction reset_gpio_probe
Annotated Snippet
struct reset_gpio_priv {
struct reset_controller_dev rc;
struct gpio_desc *reset;
};
static inline struct reset_gpio_priv
*rc_to_reset_gpio(struct reset_controller_dev *rc)
{
return container_of(rc, struct reset_gpio_priv, rc);
}
static int reset_gpio_assert(struct reset_controller_dev *rc, unsigned long id)
{
struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
return gpiod_set_value_cansleep(priv->reset, 1);
}
static int reset_gpio_deassert(struct reset_controller_dev *rc,
unsigned long id)
{
struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
return gpiod_set_value_cansleep(priv->reset, 0);
}
static int reset_gpio_status(struct reset_controller_dev *rc, unsigned long id)
{
struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
return gpiod_get_value_cansleep(priv->reset);
}
static const struct reset_control_ops reset_gpio_ops = {
.assert = reset_gpio_assert,
.deassert = reset_gpio_deassert,
.status = reset_gpio_status,
};
static int reset_gpio_fwnode_xlate(struct reset_controller_dev *rcdev,
const struct fwnode_reference_args *reset_spec)
{
return reset_spec->args[0];
}
static int reset_gpio_probe(struct auxiliary_device *adev,
const struct auxiliary_device_id *id)
{
struct device *dev = &adev->dev;
struct reset_gpio_priv *priv;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(priv->reset))
return dev_err_probe(dev, PTR_ERR(priv->reset),
"Could not get reset gpios\n");
priv->rc.ops = &reset_gpio_ops;
priv->rc.owner = THIS_MODULE;
priv->rc.dev = dev;
/* Cells to match GPIO specifier, but it's not really used */
priv->rc.fwnode_reset_n_cells = 2;
priv->rc.fwnode_xlate = reset_gpio_fwnode_xlate;
priv->rc.nr_resets = 1;
return devm_reset_controller_register(dev, &priv->rc);
}
static const struct auxiliary_device_id reset_gpio_ids[] = {
{ .name = "reset.gpio" },
{}
};
MODULE_DEVICE_TABLE(auxiliary, reset_gpio_ids);
static struct auxiliary_driver reset_gpio_driver = {
.probe = reset_gpio_probe,
.id_table = reset_gpio_ids,
.driver = {
.name = "reset-gpio",
.suppress_bind_attrs = true,
},
};
module_auxiliary_driver(reset_gpio_driver);
MODULE_AUTHOR("Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>");
MODULE_DESCRIPTION("Generic GPIO reset driver");
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/gpio/consumer.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/property.h`, `linux/reset-controller.h`.
- Detected declarations: `struct reset_gpio_priv`, `function reset_gpio_assert`, `function reset_gpio_deassert`, `function reset_gpio_status`, `function reset_gpio_fwnode_xlate`, `function reset_gpio_probe`.
- Atlas domain: Driver Families / drivers/reset.
- 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.