drivers/clk/mediatek/clk-pllfh.c

Source file repositories/reference/linux-study-clean/drivers/clk/mediatek/clk-pllfh.c

File Facts

System
Linux kernel
Corpus path
drivers/clk/mediatek/clk-pllfh.c
Extension
.c
Size
6793 bytes
Lines
302
Domain
Driver Families
Bucket
drivers/clk
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (IS_ERR(hw)) {
			pr_err("Failed to register %s clk %s: %ld\n",
			       use_fhctl ? "fhpll" : "pll", pll->name,
			       PTR_ERR(hw));
			goto err;
		}

		clk_data->hws[pll->id] = hw;
	}

	return 0;

err:
	while (--i >= 0) {
		const struct mtk_pll_data *pll = &plls[i];
		struct mtk_pllfh_data *pllfh;
		bool use_fhctl;

		pllfh = get_pllfh_by_id(pllfhs, num_fhs, pll->id);
		use_fhctl = fhctl_is_supported_and_enabled(pllfh);

		if (use_fhctl)
			mtk_clk_unregister_pllfh(clk_data->hws[pll->id]);
		else
			mtk_clk_unregister_pll(clk_data->hws[pll->id]);

		clk_data->hws[pll->id] = ERR_PTR(-ENOENT);
	}

	iounmap(base);

	return PTR_ERR(hw);
}
EXPORT_SYMBOL_GPL(mtk_clk_register_pllfhs);

void mtk_clk_unregister_pllfhs(const struct mtk_pll_data *plls, int num_plls,
			       struct mtk_pllfh_data *pllfhs, int num_fhs,
			       struct clk_hw_onecell_data *clk_data)
{
	void __iomem *base = NULL, *fhctl_base = NULL;
	int i;

	if (!clk_data)
		return;

	for (i = num_plls; i > 0; i--) {
		const struct mtk_pll_data *pll = &plls[i - 1];
		struct mtk_pllfh_data *pllfh;
		bool use_fhctl;

		if (IS_ERR_OR_NULL(clk_data->hws[pll->id]))
			continue;

		pllfh = get_pllfh_by_id(pllfhs, num_fhs, pll->id);
		use_fhctl = fhctl_is_supported_and_enabled(pllfh);

		if (use_fhctl) {
			fhctl_base = pllfh->state.base;
			mtk_clk_unregister_pllfh(clk_data->hws[pll->id]);
		} else {
			base = mtk_clk_pll_get_base(clk_data->hws[pll->id],
						    pll);
			mtk_clk_unregister_pll(clk_data->hws[pll->id]);
		}

		clk_data->hws[pll->id] = ERR_PTR(-ENOENT);
	}

	if (fhctl_base)
		iounmap(fhctl_base);

	iounmap(base);
}
EXPORT_SYMBOL_GPL(mtk_clk_unregister_pllfhs);

Annotation

Implementation Notes