// SPDX-License-Identifier: GPL-2.0 /* * T-HEAD TH1520 GPU Power Sequencer Driver * * Copyright (c) 2025 Samsung Electronics Co., Ltd. * Author: Michal Wilczynski <m.wilczynski@samsung.com> * * This driver implements the power sequence for the Imagination BXM-4-64 * GPU on the T-HEAD TH1520 SoC. The sequence requires coordinating resources * from both the sequencer's parent device node (clkgen_reset) and the GPU's * device node (clocks and core reset). * * The `match` function is used to acquire the GPU's resources when the * GPU driver requests the "gpu-power" sequence target.
*/
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;
/* We only match the specific T-HEAD TH1520 GPU compatible */ if (!of_device_is_compatible(dev->of_node, "thead,th1520-gpu")) return PWRSEQ_NO_MATCH;
ret = of_parse_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells", 0, &pwr_spec); if (ret) return PWRSEQ_NO_MATCH;
/* Additionally verify consumer device has AON as power-domain */ if (pwr_spec.np != ctx->aon_node || pwr_spec.args[0] != TH1520_GPU_PD) {
of_node_put(pwr_spec.np); return PWRSEQ_NO_MATCH;
}
of_node_put(pwr_spec.np);
/* If a consumer is already bound, only allow a re-match from it */ if (ctx->consumer_node) return ctx->consumer_node == dev->of_node ?
PWRSEQ_MATCH_OK : PWRSEQ_NO_MATCH;
ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM;
ctx->aon_node = parent_dev->of_node;
ctx->clkgen_reset =
devm_reset_control_get_exclusive(parent_dev, "gpu-clkgen"); if (IS_ERR(ctx->clkgen_reset)) return dev_err_probe(
dev, PTR_ERR(ctx->clkgen_reset), "Failed to get GPU clkgen reset from parent\n");
ctx->pwrseq = devm_pwrseq_device_register(dev, &config); if (IS_ERR(ctx->pwrseq)) return dev_err_probe(dev, PTR_ERR(ctx->pwrseq), "Failed to register power sequencer\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.