clk: amlogic: aoclk: use clkc-utils syscon probe

The clock related part of aoclk probe function duplicates what
the clkc-utils syscon helper does. Factorize this to have a single path to
maintain.

Link: https://lore.kernel.org/r/20250825-meson-clk-cleanup-24-v2-4-0f402f01e117@baylibre.com
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
This commit is contained in:
Jerome Brunet 2025-08-25 16:26:29 +02:00
parent d7c001bd76
commit 2aeeb649ea
5 changed files with 33 additions and 31 deletions

View File

@ -300,16 +300,18 @@ static const struct meson_aoclk_data axg_ao_clkc_data = {
.reset_reg = AO_RTI_GEN_CNTL_REG0,
.num_reset = ARRAY_SIZE(axg_ao_reset),
.reset = axg_ao_reset,
.hw_clks = {
.hws = axg_ao_hw_clks,
.num = ARRAY_SIZE(axg_ao_hw_clks),
.clkc_data = {
.hw_clks = {
.hws = axg_ao_hw_clks,
.num = ARRAY_SIZE(axg_ao_hw_clks),
},
},
};
static const struct of_device_id axg_ao_clkc_match_table[] = {
{
.compatible = "amlogic,meson-axg-aoclkc",
.data = &axg_ao_clkc_data,
.data = &axg_ao_clkc_data.clkc_data,
},
{ }
};

View File

@ -424,16 +424,18 @@ static const struct meson_aoclk_data g12a_ao_clkc_data = {
.reset_reg = AO_RTI_GEN_CNTL_REG0,
.num_reset = ARRAY_SIZE(g12a_ao_reset),
.reset = g12a_ao_reset,
.hw_clks = {
.hws = g12a_ao_hw_clks,
.num = ARRAY_SIZE(g12a_ao_hw_clks),
.clkc_data = {
.hw_clks = {
.hws = g12a_ao_hw_clks,
.num = ARRAY_SIZE(g12a_ao_hw_clks),
},
},
};
static const struct of_device_id g12a_ao_clkc_match_table[] = {
{
.compatible = "amlogic,meson-g12a-aoclkc",
.data = &g12a_ao_clkc_data,
.data = &g12a_ao_clkc_data.clkc_data,
},
{ }
};

View File

@ -258,16 +258,18 @@ static const struct meson_aoclk_data gxbb_ao_clkc_data = {
.reset_reg = AO_RTI_GEN_CNTL_REG0,
.num_reset = ARRAY_SIZE(gxbb_ao_reset),
.reset = gxbb_ao_reset,
.hw_clks = {
.hws = gxbb_ao_hw_clks,
.num = ARRAY_SIZE(gxbb_ao_hw_clks),
.clkc_data = {
.hw_clks = {
.hws = gxbb_ao_hw_clks,
.num = ARRAY_SIZE(gxbb_ao_hw_clks),
},
},
};
static const struct of_device_id gxbb_ao_clkc_match_table[] = {
{
.compatible = "amlogic,meson-gx-aoclkc",
.data = &gxbb_ao_clkc_data,
.data = &gxbb_ao_clkc_data.clkc_data,
},
{ }
};

View File

@ -37,15 +37,23 @@ static const struct reset_control_ops meson_aoclk_reset_ops = {
int meson_aoclkc_probe(struct platform_device *pdev)
{
struct meson_aoclk_reset_controller *rstc;
struct meson_aoclk_data *data;
const struct meson_clkc_data *clkc_data;
const struct meson_aoclk_data *data;
struct device *dev = &pdev->dev;
struct device_node *np;
struct regmap *regmap;
int ret, clkid;
int ret;
data = (struct meson_aoclk_data *) of_device_get_match_data(dev);
if (!data)
return -ENODEV;
clkc_data = of_device_get_match_data(dev);
if (!clkc_data)
return -EINVAL;
ret = meson_clkc_syscon_probe(pdev);
if (ret)
return ret;
data = container_of(clkc_data, struct meson_aoclk_data,
clkc_data);
rstc = devm_kzalloc(dev, sizeof(*rstc), GFP_KERNEL);
if (!rstc)
@ -71,19 +79,7 @@ int meson_aoclkc_probe(struct platform_device *pdev)
return ret;
}
/* Register all clks */
for (clkid = 0; clkid < data->hw_clks.num; clkid++) {
if (!data->hw_clks.hws[clkid])
continue;
ret = devm_clk_hw_register(dev, data->hw_clks.hws[clkid]);
if (ret) {
dev_err(dev, "Clock registration failed\n");
return ret;
}
}
return devm_of_clk_add_hw_provider(dev, meson_clk_hw_get, (void *)&data->hw_clks);
return 0;
}
EXPORT_SYMBOL_NS_GPL(meson_aoclkc_probe, "CLK_MESON");

View File

@ -20,10 +20,10 @@
#include "meson-clkc-utils.h"
struct meson_aoclk_data {
const struct meson_clkc_data clkc_data;
const unsigned int reset_reg;
const int num_reset;
const unsigned int *reset;
struct meson_clk_hw_data hw_clks;
};
struct meson_aoclk_reset_controller {