[PATCH V2 08/12] clk: mediatek: reset: Add new register reset function with device

Rex-BC Chen rex-bc.chen at mediatek.com
Thu Apr 21 22:05:16 PDT 2022


On Thu, 2022-04-21 at 11:07 +0200, AngeloGioacchino Del Regno wrote:
> 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");

Hello Angelo,

ok, I will do this in next version.

BRs,
Rex




More information about the Linux-mediatek mailing list