drivers/reset/hisilicon/reset-hi3660.c
Source file repositories/reference/linux-study-clean/drivers/reset/hisilicon/reset-hi3660.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/hisilicon/reset-hi3660.c- Extension
.c- Size
- 3209 bytes
- Lines
- 128
- 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/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/reset-controller.h
Detected Declarations
struct hi3660_reset_controllerfunction hi3660_reset_program_hwfunction hi3660_reset_assertfunction hi3660_reset_deassertfunction hi3660_reset_devfunction hi3660_reset_xlatefunction hi3660_reset_probefunction hi3660_reset_init
Annotated Snippet
struct hi3660_reset_controller {
struct reset_controller_dev rst;
struct regmap *map;
};
#define to_hi3660_reset_controller(_rst) \
container_of(_rst, struct hi3660_reset_controller, rst)
static int hi3660_reset_program_hw(struct reset_controller_dev *rcdev,
unsigned long idx, bool assert)
{
struct hi3660_reset_controller *rc = to_hi3660_reset_controller(rcdev);
unsigned int offset = idx >> 8;
unsigned int mask = BIT(idx & 0x1f);
if (assert)
return regmap_write(rc->map, offset, mask);
else
return regmap_write(rc->map, offset + 4, mask);
}
static int hi3660_reset_assert(struct reset_controller_dev *rcdev,
unsigned long idx)
{
return hi3660_reset_program_hw(rcdev, idx, true);
}
static int hi3660_reset_deassert(struct reset_controller_dev *rcdev,
unsigned long idx)
{
return hi3660_reset_program_hw(rcdev, idx, false);
}
static int hi3660_reset_dev(struct reset_controller_dev *rcdev,
unsigned long idx)
{
int err;
err = hi3660_reset_assert(rcdev, idx);
if (err)
return err;
return hi3660_reset_deassert(rcdev, idx);
}
static const struct reset_control_ops hi3660_reset_ops = {
.reset = hi3660_reset_dev,
.assert = hi3660_reset_assert,
.deassert = hi3660_reset_deassert,
};
static int hi3660_reset_xlate(struct reset_controller_dev *rcdev,
const struct of_phandle_args *reset_spec)
{
unsigned int offset, bit;
offset = reset_spec->args[0];
bit = reset_spec->args[1];
return (offset << 8) | bit;
}
static int hi3660_reset_probe(struct platform_device *pdev)
{
struct hi3660_reset_controller *rc;
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
if (!rc)
return -ENOMEM;
rc->map = syscon_regmap_lookup_by_phandle(np, "hisilicon,rst-syscon");
if (rc->map == ERR_PTR(-ENODEV)) {
/* fall back to the deprecated compatible */
rc->map = syscon_regmap_lookup_by_phandle(np,
"hisi,rst-syscon");
}
if (IS_ERR(rc->map)) {
return dev_err_probe(dev, PTR_ERR(rc->map),
"failed to get hisilicon,rst-syscon\n");
}
rc->rst.ops = &hi3660_reset_ops,
rc->rst.of_node = np;
rc->rst.of_reset_n_cells = 2;
rc->rst.of_xlate = hi3660_reset_xlate;
return reset_controller_register(&rc->rst);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/reset-controller.h`.
- Detected declarations: `struct hi3660_reset_controller`, `function hi3660_reset_program_hw`, `function hi3660_reset_assert`, `function hi3660_reset_deassert`, `function hi3660_reset_dev`, `function hi3660_reset_xlate`, `function hi3660_reset_probe`, `function hi3660_reset_init`.
- 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.