drivers/power/sequencing/pwrseq-thead-gpu.c
Source file repositories/reference/linux-study-clean/drivers/power/sequencing/pwrseq-thead-gpu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/sequencing/pwrseq-thead-gpu.c- Extension
.c- Size
- 6585 bytes
- Lines
- 250
- Domain
- Driver Families
- Bucket
- drivers/power
- 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/clk.hlinux/delay.hlinux/module.hlinux/of.hlinux/pwrseq/provider.hlinux/reset.hlinux/slab.hdt-bindings/power/thead,th1520-power.h
Detected Declarations
struct pwrseq_thead_gpu_ctxfunction pwrseq_thead_gpu_enablefunction pwrseq_thead_gpu_disablefunction pwrseq_thead_gpu_matchfunction pwrseq_thead_gpu_probefunction pwrseq_thead_gpu_remove
Annotated Snippet
struct pwrseq_thead_gpu_ctx {
struct pwrseq_device *pwrseq;
struct reset_control *clkgen_reset;
struct device_node *aon_node;
/* Consumer resources */
struct device_node *consumer_node;
struct clk_bulk_data *clks;
int num_clks;
struct reset_control *gpu_reset;
};
static int pwrseq_thead_gpu_enable(struct pwrseq_device *pwrseq)
{
struct pwrseq_thead_gpu_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);
int ret;
if (!ctx->clks || !ctx->gpu_reset)
return -ENODEV;
ret = clk_bulk_prepare_enable(ctx->num_clks, ctx->clks);
if (ret)
return ret;
ret = reset_control_deassert(ctx->clkgen_reset);
if (ret)
goto err_disable_clks;
/*
* According to the hardware manual, a delay of at least 32 clock
* cycles is required between de-asserting the clkgen reset and
* de-asserting the GPU reset. Assuming a worst-case scenario with
* a very high GPU clock frequency, a delay of 1 microsecond is
* sufficient to ensure this requirement is met across all
* feasible GPU clock speeds.
*/
udelay(1);
ret = reset_control_deassert(ctx->gpu_reset);
if (ret)
goto err_assert_clkgen;
return 0;
err_assert_clkgen:
reset_control_assert(ctx->clkgen_reset);
err_disable_clks:
clk_bulk_disable_unprepare(ctx->num_clks, ctx->clks);
return ret;
}
static int pwrseq_thead_gpu_disable(struct pwrseq_device *pwrseq)
{
struct pwrseq_thead_gpu_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);
int ret = 0, err;
if (!ctx->clks || !ctx->gpu_reset)
return -ENODEV;
err = reset_control_assert(ctx->gpu_reset);
if (err)
ret = err;
err = reset_control_assert(ctx->clkgen_reset);
if (err && !ret)
ret = err;
clk_bulk_disable_unprepare(ctx->num_clks, ctx->clks);
/* ret stores values of the first error code */
return ret;
}
static const struct pwrseq_unit_data pwrseq_thead_gpu_unit = {
.name = "gpu-power-sequence",
.enable = pwrseq_thead_gpu_enable,
.disable = pwrseq_thead_gpu_disable,
};
static const struct pwrseq_target_data pwrseq_thead_gpu_target = {
.name = "gpu-power",
.unit = &pwrseq_thead_gpu_unit,
};
static const struct pwrseq_target_data *pwrseq_thead_gpu_targets[] = {
&pwrseq_thead_gpu_target,
NULL
};
static int pwrseq_thead_gpu_match(struct pwrseq_device *pwrseq,
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/clk.h`, `linux/delay.h`, `linux/module.h`, `linux/of.h`, `linux/pwrseq/provider.h`, `linux/reset.h`, `linux/slab.h`.
- Detected declarations: `struct pwrseq_thead_gpu_ctx`, `function pwrseq_thead_gpu_enable`, `function pwrseq_thead_gpu_disable`, `function pwrseq_thead_gpu_match`, `function pwrseq_thead_gpu_probe`, `function pwrseq_thead_gpu_remove`.
- Atlas domain: Driver Families / drivers/power.
- 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.