[PATCH V2 08/12] clk: mediatek: reset: Add new register reset function with device
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Thu Apr 21 02:07:44 PDT 2022
Il 20/04/22 15:05, Rex-BC Chen ha scritto:
> Some clock drvier only support device_node, so we still remain
> register reset function with device_node and add a function to
> register reset controller with device.
>
> Signed-off-by: Rex-BC Chen <rex-bc.chen at mediatek.com>
> ---
> drivers/clk/mediatek/clk-mt2701-eth.c | 2 +-
> drivers/clk/mediatek/clk-mt2701-g3d.c | 2 +-
> drivers/clk/mediatek/clk-mt2701-hif.c | 2 +-
> drivers/clk/mediatek/clk-mt2701.c | 4 +--
> drivers/clk/mediatek/clk-mt2712.c | 4 +--
> drivers/clk/mediatek/clk-mt7622-eth.c | 2 +-
> drivers/clk/mediatek/clk-mt7622-hif.c | 4 +--
> drivers/clk/mediatek/clk-mt7622.c | 4 +--
> drivers/clk/mediatek/clk-mt7629-eth.c | 2 +-
> drivers/clk/mediatek/clk-mt7629-hif.c | 4 +--
> drivers/clk/mediatek/clk-mt8183.c | 2 +-
> drivers/clk/mediatek/reset.c | 43 +++++++++++++++++++++++++++
> drivers/clk/mediatek/reset.h | 2 ++
> 13 files changed, 61 insertions(+), 16 deletions(-)
>
..snip..
> diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c
> index b164b1da7dd3..1173111af3ab 100644
> --- a/drivers/clk/mediatek/reset.c
> +++ b/drivers/clk/mediatek/reset.c
> @@ -107,4 +107,47 @@ int mtk_clk_register_rst_ctrl(struct device_node *np,
> return ret;
> }
>
> +int mtk_clk_register_rst_ctrl_with_dev(struct device *dev,
> + const struct mtk_clk_rst_desc *desc)
> +{
> + struct device_node *np = dev->of_node;
> + struct regmap *regmap;
> + struct mtk_clk_rst_data *data;
> + int ret;
> +
> + if (!desc) {
> + dev_err(dev, "mtk clock reset desc is NULL\n");
> + return -EINVAL;
> + }
> +
> + if (desc->version >= MTK_RST_MAX) {
> + dev_err(dev, "Error version number: %d\n", desc->version);
> + return -EINVAL;
> + }
> +
> + regmap = device_node_to_regmap(np);
> + if (IS_ERR(regmap)) {
> + dev_err(dev, "Cannot find regmap %pe\n", regmap);
> + return -EINVAL;
> + }
> +
> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + data->desc = desc;
> + data->regmap = regmap;
> + data->rcdev.owner = THIS_MODULE;
> + data->rcdev.nr_resets = desc->reg_num * 32;
> + data->rcdev.ops = rst_op[desc->version];
> + data->rcdev.of_node = np;
> + data->rcdev.dev = dev;
> +
> + ret = devm_reset_controller_register(dev, &data->rcdev);
> + if (ret)
> + dev_err(dev, "could not register reset controller: %d\n", ret);
if (ret) {
dev_err(dev, "could not register reset controller: %d\n", ret);
return ret;
}
return 0;
> +
> + return ret;
> +}
> +
> MODULE_LICENSE("GPL");
More information about the Linux-mediatek
mailing list