drivers/reset/reset-tn48m.c
Source file repositories/reference/linux-study-clean/drivers/reset/reset-tn48m.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/reset-tn48m.c- Extension
.c- Size
- 3018 bytes
- Lines
- 129
- 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/device.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/regmap.hlinux/reset-controller.hdt-bindings/reset/delta,tn48m-reset.h
Detected Declarations
struct tn48_reset_mapstruct tn48_reset_datafunction tn48m_control_resetfunction tn48m_control_statusfunction tn48m_reset_probe
Annotated Snippet
struct tn48_reset_map {
u8 bit;
};
struct tn48_reset_data {
struct reset_controller_dev rcdev;
struct regmap *regmap;
};
static const struct tn48_reset_map tn48m_resets[] = {
[CPU_88F7040_RESET] = {0},
[CPU_88F6820_RESET] = {1},
[MAC_98DX3265_RESET] = {2},
[PHY_88E1680_RESET] = {4},
[PHY_88E1512_RESET] = {6},
[POE_RESET] = {7},
};
static inline struct tn48_reset_data *to_tn48_reset_data(
struct reset_controller_dev *rcdev)
{
return container_of(rcdev, struct tn48_reset_data, rcdev);
}
static int tn48m_control_reset(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct tn48_reset_data *data = to_tn48_reset_data(rcdev);
unsigned int val;
regmap_update_bits(data->regmap, TN48M_RESET_REG,
BIT(tn48m_resets[id].bit), 0);
return regmap_read_poll_timeout(data->regmap,
TN48M_RESET_REG,
val,
val & BIT(tn48m_resets[id].bit),
TN48M_RESET_SLEEP_US,
TN48M_RESET_TIMEOUT_US);
}
static int tn48m_control_status(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct tn48_reset_data *data = to_tn48_reset_data(rcdev);
unsigned int regval;
int ret;
ret = regmap_read(data->regmap, TN48M_RESET_REG, ®val);
if (ret < 0)
return ret;
if (BIT(tn48m_resets[id].bit) & regval)
return 0;
else
return 1;
}
static const struct reset_control_ops tn48_reset_ops = {
.reset = tn48m_control_reset,
.status = tn48m_control_status,
};
static int tn48m_reset_probe(struct platform_device *pdev)
{
struct tn48_reset_data *data;
struct regmap *regmap;
regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!regmap)
return -ENODEV;
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->regmap = regmap;
data->rcdev.owner = THIS_MODULE;
data->rcdev.ops = &tn48_reset_ops;
data->rcdev.nr_resets = ARRAY_SIZE(tn48m_resets);
data->rcdev.of_node = pdev->dev.of_node;
return devm_reset_controller_register(&pdev->dev, &data->rcdev);
}
static const struct of_device_id tn48m_reset_of_match[] = {
{ .compatible = "delta,tn48m-reset" },
{ }
};
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/reset-controller.h`, `dt-bindings/reset/delta,tn48m-reset.h`.
- Detected declarations: `struct tn48_reset_map`, `struct tn48_reset_data`, `function tn48m_control_reset`, `function tn48m_control_status`, `function tn48m_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.