drivers/reset/reset-tps380x.c
Source file repositories/reference/linux-study-clean/drivers/reset/reset-tps380x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/reset-tps380x.c- Extension
.c- Size
- 3341 bytes
- Lines
- 127
- 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/delay.hlinux/gpio/consumer.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/reset-controller.h
Detected Declarations
struct tps380x_resetstruct tps380x_reset_devdatafunction tps380x_reset_assertfunction tps380x_reset_deassertfunction tps380x_reset_of_xlatefunction tps380x_reset_probe
Annotated Snippet
struct tps380x_reset {
struct reset_controller_dev rcdev;
struct gpio_desc *reset_gpio;
unsigned int reset_ms;
};
struct tps380x_reset_devdata {
unsigned int min_reset_ms;
unsigned int typ_reset_ms;
unsigned int max_reset_ms;
};
static inline
struct tps380x_reset *to_tps380x_reset(struct reset_controller_dev *rcdev)
{
return container_of(rcdev, struct tps380x_reset, rcdev);
}
static int
tps380x_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
{
struct tps380x_reset *tps380x = to_tps380x_reset(rcdev);
gpiod_set_value_cansleep(tps380x->reset_gpio, 1);
return 0;
}
static int
tps380x_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
{
struct tps380x_reset *tps380x = to_tps380x_reset(rcdev);
gpiod_set_value_cansleep(tps380x->reset_gpio, 0);
msleep(tps380x->reset_ms);
return 0;
}
static const struct reset_control_ops reset_tps380x_ops = {
.assert = tps380x_reset_assert,
.deassert = tps380x_reset_deassert,
};
static int tps380x_reset_of_xlate(struct reset_controller_dev *rcdev,
const struct of_phandle_args *reset_spec)
{
/* No special handling needed, we have only one reset line per device */
return 0;
}
static int tps380x_reset_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct tps380x_reset_devdata *devdata;
struct tps380x_reset *tps380x;
devdata = device_get_match_data(dev);
if (!devdata)
return -EINVAL;
tps380x = devm_kzalloc(dev, sizeof(*tps380x), GFP_KERNEL);
if (!tps380x)
return -ENOMEM;
tps380x->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(tps380x->reset_gpio))
return dev_err_probe(dev, PTR_ERR(tps380x->reset_gpio),
"Failed to get GPIO\n");
tps380x->reset_ms = devdata->max_reset_ms;
tps380x->rcdev.ops = &reset_tps380x_ops;
tps380x->rcdev.owner = THIS_MODULE;
tps380x->rcdev.dev = dev;
tps380x->rcdev.of_node = dev->of_node;
tps380x->rcdev.of_reset_n_cells = 0;
tps380x->rcdev.of_xlate = tps380x_reset_of_xlate;
tps380x->rcdev.nr_resets = 1;
return devm_reset_controller_register(dev, &tps380x->rcdev);
}
static const struct tps380x_reset_devdata tps3801_reset_data = {
.min_reset_ms = 120,
.typ_reset_ms = 200,
.max_reset_ms = 280,
};
static const struct of_device_id tps380x_reset_dt_ids[] = {
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/property.h`, `linux/reset-controller.h`.
- Detected declarations: `struct tps380x_reset`, `struct tps380x_reset_devdata`, `function tps380x_reset_assert`, `function tps380x_reset_deassert`, `function tps380x_reset_of_xlate`, `function tps380x_reset_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.