Re: [PATCH 2/3] clk: thead: add support for the T-HEAD TH1520 CCU

From: Stephen Boyd
Date: Mon Jun 12 2023 - 21:35:49 EST


Quoting Yangtao Li (2023-05-14 22:44:00)
> diff --git a/drivers/clk/clk-th1520.c b/drivers/clk/clk-th1520.c
> new file mode 100644
> index 000000000000..5dfa9e5207e2
> --- /dev/null
> +++ b/drivers/clk/clk-th1520.c
> @@ -0,0 +1,999 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2023 Vivo Communication Technology Co. Ltd.
> + * Authors: Yangtao Li <frank.li@xxxxxxxx>
> + */
> +
[....]
> +
> +
> +static CLK_FIXED_FACTOR_HW(pll_gmac_100m_clk, "pll-gmac-100m",
> + &pll_gmac_clk.common.hw,
> + 10, 1, 0);
> +
> +static const char * const uart_parents[] = { "pll-gmac-100m", "osc24m" };
> +struct ccu_mux uart_clk = {
> + .mux = TH_CCU_ARG(0, 1),
> + .common = {
> + .reg = 0x210,
> + .hw.init = CLK_HW_INIT_PARENTS("uart",

Don't use strings for clk tree topology. Instead use clk_parent_data or
clk_hw pointers directly.

> + uart_parents,
> + &ccu_mux_ops,
> + 0),
> + }
> +};
> +};
> +
> +static const struct regmap_config config = {

Namespace this, th1520_clk_regmap_config[]

> + .reg_bits = 32,
> + .val_bits = 32,
> + .reg_stride = 4,
> + .fast_io = true,
> +};
> +
> +static int th1520_clock_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct regmap *map;
> + void __iomem *regs;
> + int ret, i;
> +
> + regs = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(regs))
> + return PTR_ERR(regs);
> +
> + map = devm_regmap_init_mmio(dev, regs, &config);
> + if (IS_ERR(map))
> + return PTR_ERR(map);
> +
> + for (i = 0; i < ARRAY_SIZE(th1520_clks); i++)
> + th1520_clks[i]->map = map;
> +
> + for (i = 0; i < th1520_hw_clks.num; i++) {
> + ret = devm_clk_hw_register(dev, th1520_hw_clks.hws[i]);
> + if (ret)
> + return ret;
> + }
> +
> + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
> + &th1520_hw_clks);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static const struct of_device_id clk_match_table[] = {

Namespace this, th1520_clk_match_table[]

> + {
> + .compatible = "thead,th1520-ccu",
> + },
> + { /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(of, clk_match_table);
> +