Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 760be658 authored by Jeffrey Hugo's avatar Jeffrey Hugo Committed by Stephen Boyd
Browse files

clk: qcom: Make common clk_hw registrations



Several clock controller drivers define a list of clk_hw devices, and then
register those devices in probe() before using common code to process the
rest of initialization.  Extend the common code to accept a list of clk_hw
devices to process, thus eliminating many duplicate implementations.

Signed-off-by: default avatarJeffrey Hugo <jhugo@codeaurora.org>
Suggested-by: default avatarStephen Boyd <sboyd@kernel.org>
Reviewed-by: default avatarVinod Koul <vkoul@kernel.org>
Tested-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 6131dc81
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -231,6 +231,8 @@ int qcom_cc_really_probe(struct platform_device *pdev,
	struct gdsc_desc *scd;
	size_t num_clks = desc->num_clks;
	struct clk_regmap **rclks = desc->clks;
	size_t num_clk_hws = desc->num_clk_hws;
	struct clk_hw **clk_hws = desc->clk_hws;

	cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL);
	if (!cc)
@@ -269,6 +271,12 @@ int qcom_cc_really_probe(struct platform_device *pdev,

	qcom_cc_drop_protected(dev, cc);

	for (i = 0; i < num_clk_hws; i++) {
		ret = devm_clk_hw_register(dev, clk_hws[i]);
		if (ret)
			return ret;
	}

	for (i = 0; i < num_clks; i++) {
		if (!rclks[i])
			continue;
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ struct qcom_cc_desc {
	size_t num_resets;
	struct gdsc **gdscs;
	size_t num_gdscs;
	struct clk_hw **clk_hws;
	size_t num_clk_hws;
};

/**
+2 −8
Original line number Diff line number Diff line
@@ -4715,18 +4715,12 @@ static const struct qcom_cc_desc gcc_ipq8074_desc = {
	.num_clks = ARRAY_SIZE(gcc_ipq8074_clks),
	.resets = gcc_ipq8074_resets,
	.num_resets = ARRAY_SIZE(gcc_ipq8074_resets),
	.clk_hws = gcc_ipq8074_hws,
	.num_clk_hws = ARRAY_SIZE(gcc_ipq8074_hws),
};

static int gcc_ipq8074_probe(struct platform_device *pdev)
{
	int ret, i;

	for (i = 0; i < ARRAY_SIZE(gcc_ipq8074_hws); i++) {
		ret = devm_clk_hw_register(&pdev->dev, gcc_ipq8074_hws[i]);
		if (ret)
			return ret;
	}

	return qcom_cc_probe(pdev, &gcc_ipq8074_desc);
}

+2 −9
Original line number Diff line number Diff line
@@ -1702,6 +1702,8 @@ static const struct qcom_cc_desc gcc_mdm9615_desc = {
	.num_clks = ARRAY_SIZE(gcc_mdm9615_clks),
	.resets = gcc_mdm9615_resets,
	.num_resets = ARRAY_SIZE(gcc_mdm9615_resets),
	.clk_hws = gcc_mdm9615_hws,
	.num_clk_hws = ARRAY_SIZE(gcc_mdm9615_hws),
};

static const struct of_device_id gcc_mdm9615_match_table[] = {
@@ -1712,21 +1714,12 @@ MODULE_DEVICE_TABLE(of, gcc_mdm9615_match_table);

static int gcc_mdm9615_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct regmap *regmap;
	int ret;
	int i;

	regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc);
	if (IS_ERR(regmap))
		return PTR_ERR(regmap);

	for (i = 0; i < ARRAY_SIZE(gcc_mdm9615_hws); i++) {
		ret = devm_clk_hw_register(dev, gcc_mdm9615_hws[i]);
		if (ret)
			return ret;
	}

	return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap);
}

+2 −8
Original line number Diff line number Diff line
@@ -3656,6 +3656,8 @@ static const struct qcom_cc_desc gcc_msm8996_desc = {
	.num_resets = ARRAY_SIZE(gcc_msm8996_resets),
	.gdscs = gcc_msm8996_gdscs,
	.num_gdscs = ARRAY_SIZE(gcc_msm8996_gdscs),
	.clk_hws = gcc_msm8996_hws,
	.num_clk_hws = ARRAY_SIZE(gcc_msm8996_hws),
};

static const struct of_device_id gcc_msm8996_match_table[] = {
@@ -3666,8 +3668,6 @@ MODULE_DEVICE_TABLE(of, gcc_msm8996_match_table);

static int gcc_msm8996_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	int i, ret;
	struct regmap *regmap;

	regmap = qcom_cc_map(pdev, &gcc_msm8996_desc);
@@ -3680,12 +3680,6 @@ static int gcc_msm8996_probe(struct platform_device *pdev)
	 */
	regmap_update_bits(regmap, 0x52008, BIT(21), BIT(21));

	for (i = 0; i < ARRAY_SIZE(gcc_msm8996_hws); i++) {
		ret = devm_clk_hw_register(dev, gcc_msm8996_hws[i]);
		if (ret)
			return ret;
	}

	return qcom_cc_really_probe(pdev, &gcc_msm8996_desc, regmap);
}

Loading