drivers/clk/qcom/krait-cc.c

Source file repositories/reference/linux-study-clean/drivers/clk/qcom/krait-cc.c

File Facts

System
Linux kernel
Corpus path
drivers/clk/qcom/krait-cc.c
Extension
.c
Size
10543 bytes
Lines
449
Domain
Driver Families
Bucket
drivers/clk
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!parent_name) {
			clk = ERR_PTR(-ENOMEM);
			goto err_aux;
		}
		sec_mux_list[1].fw_name = parent_name;
		sec_mux_list[1].name = parent_name;
	} else {
		sec_mux_list[1].name = "apu_aux";
	}

	ret = devm_clk_hw_register(dev, &mux->hw);
	if (ret) {
		clk = ERR_PTR(ret);
		goto err_clk;
	}

	clk = &mux->hw;

	ret = krait_notifier_register(dev, mux->hw.clk, mux);
	if (ret) {
		clk = ERR_PTR(ret);
		goto err_clk;
	}

	/* clk-krait ignore any rate change if mux is not flagged as enabled */
	if (id < 0)
		for_each_online_cpu(cpu)
			clk_prepare_enable(mux->hw.clk);
	else
		clk_prepare_enable(mux->hw.clk);

err_clk:
	if (unique_aux)
		kfree(parent_name);
err_aux:
	kfree(init.name);
	return clk;
}

static struct clk_hw *
krait_add_pri_mux(struct device *dev, struct clk_hw *hfpll_div, struct clk_hw *sec_mux,
		  int id, const char *s, unsigned int offset)
{
	int ret;
	struct krait_mux_clk *mux;
	static struct clk_parent_data p_data[3];
	struct clk_init_data init = {
		.parent_data = p_data,
		.num_parents = ARRAY_SIZE(p_data),
		.ops = &krait_mux_clk_ops,
		.flags = CLK_SET_RATE_PARENT,
	};
	struct clk_hw *clk;
	char *hfpll_name;

	mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
	if (!mux)
		return ERR_PTR(-ENOMEM);

	mux->mask = 0x3;
	mux->shift = 0;
	mux->offset = offset;
	mux->lpl = id >= 0;
	mux->parent_map = pri_mux_map;
	mux->hw.init = &init;
	mux->safe_sel = 2;

	init.name = kasprintf(GFP_KERNEL, "krait%s_pri_mux", s);
	if (!init.name)
		return ERR_PTR(-ENOMEM);

	hfpll_name = kasprintf(GFP_KERNEL, "hfpll%s", s);
	if (!hfpll_name) {
		clk = ERR_PTR(-ENOMEM);
		goto err_hfpll;
	}

	p_data[0].fw_name = hfpll_name;
	p_data[0].name = hfpll_name;

	p_data[1].hw = hfpll_div;
	p_data[2].hw = sec_mux;

	ret = devm_clk_hw_register(dev, &mux->hw);
	if (ret) {
		clk = ERR_PTR(ret);
		goto err_clk;
	}

	clk = &mux->hw;

Annotation

Implementation Notes