2020-12-13 14:11:48

by Yongqiang Niu

[permalink] [raw]
Subject: [PATCH v2, 14/17] soc: mediatek: mmsys: Use function call for setting mmsys ovl mout register

Use function call for setting mmsys ovl mout register

Signed-off-by: Yongqiang Niu <[email protected]>
---
drivers/soc/mediatek/mmsys/mtk-mmsys.c | 18 ++++++++++++++++++
include/linux/soc/mediatek/mtk-mmsys.h | 3 +++
2 files changed, 21 insertions(+)

diff --git a/drivers/soc/mediatek/mmsys/mtk-mmsys.c b/drivers/soc/mediatek/mmsys/mtk-mmsys.c
index cb76e64..2558b42 100644
--- a/drivers/soc/mediatek/mmsys/mtk-mmsys.c
+++ b/drivers/soc/mediatek/mmsys/mtk-mmsys.c
@@ -78,6 +78,15 @@ void mtk_mmsys_ddp_connect(struct device *dev,
reg = readl_relaxed(mmsys->regs + addr) | value;
writel_relaxed(reg, mmsys->regs + addr);
}
+
+ if (!funcs->ovl_mout_en)
+ return;
+
+ value = funcs->ovl_mout_en(cur, next, &addr);
+ if (value) {
+ reg = readl_relaxed(mmsys->regs + addr) | value;
+ writel_relaxed(reg, mmsys->regs + addr);
+ }
}
EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect);

@@ -103,6 +112,15 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
reg = readl_relaxed(mmsys->regs + addr) & ~value;
writel_relaxed(reg, mmsys->regs + addr);
}
+
+ if (!funcs->ovl_mout_en)
+ return;
+
+ value = funcs->ovl_mout_en(cur, next, &addr);
+ if (value) {
+ reg = readl_relaxed(mmsys->regs + addr) & ~value;
+ writel_relaxed(reg, mmsys->regs + addr);
+ }
}
EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);

diff --git a/include/linux/soc/mediatek/mtk-mmsys.h b/include/linux/soc/mediatek/mtk-mmsys.h
index aa4f60e..220203d 100644
--- a/include/linux/soc/mediatek/mtk-mmsys.h
+++ b/include/linux/soc/mediatek/mtk-mmsys.h
@@ -49,6 +49,9 @@ struct mtk_mmsys_conn_funcs {
u32 (*mout_en)(enum mtk_ddp_comp_id cur,
enum mtk_ddp_comp_id next,
unsigned int *addr);
+ u32 (*ovl_mout_en)(enum mtk_ddp_comp_id cur,
+ enum mtk_ddp_comp_id next,
+ unsigned int *addr);
u32 (*sel_in)(enum mtk_ddp_comp_id cur,
enum mtk_ddp_comp_id next,
unsigned int *addr);
--
1.8.1.1.dirty


2020-12-15 13:46:30

by Nicolas Boichat

[permalink] [raw]
Subject: Re: [PATCH v2, 14/17] soc: mediatek: mmsys: Use function call for setting mmsys ovl mout register

On Sat, Dec 12, 2020 at 12:13 PM Yongqiang Niu
<[email protected]> wrote:
>
> Use function call for setting mmsys ovl mout register
>
> Signed-off-by: Yongqiang Niu <[email protected]>
> ---
> drivers/soc/mediatek/mmsys/mtk-mmsys.c | 18 ++++++++++++++++++
> include/linux/soc/mediatek/mtk-mmsys.h | 3 +++
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/soc/mediatek/mmsys/mtk-mmsys.c b/drivers/soc/mediatek/mmsys/mtk-mmsys.c
> index cb76e64..2558b42 100644
> --- a/drivers/soc/mediatek/mmsys/mtk-mmsys.c
> +++ b/drivers/soc/mediatek/mmsys/mtk-mmsys.c
> @@ -78,6 +78,15 @@ void mtk_mmsys_ddp_connect(struct device *dev,
> reg = readl_relaxed(mmsys->regs + addr) | value;
> writel_relaxed(reg, mmsys->regs + addr);
> }
> +
> + if (!funcs->ovl_mout_en)
> + return;
> +
> + value = funcs->ovl_mout_en(cur, next, &addr);
> + if (value) {
> + reg = readl_relaxed(mmsys->regs + addr) | value;
> + writel_relaxed(reg, mmsys->regs + addr);
> + }

This is technically correct, but I'm afraid this may become and issue
later if we have another function like ovl_mout_en.

So maybe it's better to do:
if (funcs->ovl_mout_en) {
value = funcs->ovl_mout_en(cur, next, &addr);
...
}

Or another option: Create a new function
static unsigned int mtk_mmsys_ovl_mout_en(...) {
if (!funcs->ovl_mout_en)
return 0;
}

and call that, following the same pattern as
mtk_mmsys_ddp_mout_en/mtk_mmsys_ddp_sel_in?

> }
> EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect);
>
> @@ -103,6 +112,15 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
> reg = readl_relaxed(mmsys->regs + addr) & ~value;
> writel_relaxed(reg, mmsys->regs + addr);
> }
> +
> + if (!funcs->ovl_mout_en)
> + return;
> +
> + value = funcs->ovl_mout_en(cur, next, &addr);
> + if (value) {
> + reg = readl_relaxed(mmsys->regs + addr) & ~value;
> + writel_relaxed(reg, mmsys->regs + addr);
> + }
> }
> EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
>
> diff --git a/include/linux/soc/mediatek/mtk-mmsys.h b/include/linux/soc/mediatek/mtk-mmsys.h
> index aa4f60e..220203d 100644
> --- a/include/linux/soc/mediatek/mtk-mmsys.h
> +++ b/include/linux/soc/mediatek/mtk-mmsys.h
> @@ -49,6 +49,9 @@ struct mtk_mmsys_conn_funcs {
> u32 (*mout_en)(enum mtk_ddp_comp_id cur,
> enum mtk_ddp_comp_id next,
> unsigned int *addr);
> + u32 (*ovl_mout_en)(enum mtk_ddp_comp_id cur,
> + enum mtk_ddp_comp_id next,
> + unsigned int *addr);
> u32 (*sel_in)(enum mtk_ddp_comp_id cur,
> enum mtk_ddp_comp_id next,
> unsigned int *addr);
> --
> 1.8.1.1.dirty
> _______________________________________________
> Linux-mediatek mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-mediatek

2020-12-23 01:42:55

by Yongqiang Niu

[permalink] [raw]
Subject: Re: [PATCH v2, 14/17] soc: mediatek: mmsys: Use function call for setting mmsys ovl mout register

On Tue, 2020-12-15 at 21:42 +0800, Nicolas Boichat wrote:
> On Sat, Dec 12, 2020 at 12:13 PM Yongqiang Niu
> <[email protected]> wrote:
> >
> > Use function call for setting mmsys ovl mout register
> >
> > Signed-off-by: Yongqiang Niu <[email protected]>
> > ---
> > drivers/soc/mediatek/mmsys/mtk-mmsys.c | 18 ++++++++++++++++++
> > include/linux/soc/mediatek/mtk-mmsys.h | 3 +++
> > 2 files changed, 21 insertions(+)
> >
> > diff --git a/drivers/soc/mediatek/mmsys/mtk-mmsys.c b/drivers/soc/mediatek/mmsys/mtk-mmsys.c
> > index cb76e64..2558b42 100644
> > --- a/drivers/soc/mediatek/mmsys/mtk-mmsys.c
> > +++ b/drivers/soc/mediatek/mmsys/mtk-mmsys.c
> > @@ -78,6 +78,15 @@ void mtk_mmsys_ddp_connect(struct device *dev,
> > reg = readl_relaxed(mmsys->regs + addr) | value;
> > writel_relaxed(reg, mmsys->regs + addr);
> > }
> > +
> > + if (!funcs->ovl_mout_en)
> > + return;
> > +
> > + value = funcs->ovl_mout_en(cur, next, &addr);
> > + if (value) {
> > + reg = readl_relaxed(mmsys->regs + addr) | value;
> > + writel_relaxed(reg, mmsys->regs + addr);
> > + }
>
> This is technically correct, but I'm afraid this may become and issue
> later if we have another function like ovl_mout_en.
>
> So maybe it's better to do:
> if (funcs->ovl_mout_en) {
> value = funcs->ovl_mout_en(cur, next, &addr);
> ...
> }

will be improved like this in next version
>
> Or another option: Create a new function
> static unsigned int mtk_mmsys_ovl_mout_en(...) {
> if (!funcs->ovl_mout_en)
> return 0;
> }
>
> and call that, following the same pattern as
> mtk_mmsys_ddp_mout_en/mtk_mmsys_ddp_sel_in?
>
> > }
> > EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect);
> >
> > @@ -103,6 +112,15 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
> > reg = readl_relaxed(mmsys->regs + addr) & ~value;
> > writel_relaxed(reg, mmsys->regs + addr);
> > }
> > +
> > + if (!funcs->ovl_mout_en)
> > + return;
> > +
> > + value = funcs->ovl_mout_en(cur, next, &addr);
> > + if (value) {
> > + reg = readl_relaxed(mmsys->regs + addr) & ~value;
> > + writel_relaxed(reg, mmsys->regs + addr);
> > + }
> > }
> > EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
> >
> > diff --git a/include/linux/soc/mediatek/mtk-mmsys.h b/include/linux/soc/mediatek/mtk-mmsys.h
> > index aa4f60e..220203d 100644
> > --- a/include/linux/soc/mediatek/mtk-mmsys.h
> > +++ b/include/linux/soc/mediatek/mtk-mmsys.h
> > @@ -49,6 +49,9 @@ struct mtk_mmsys_conn_funcs {
> > u32 (*mout_en)(enum mtk_ddp_comp_id cur,
> > enum mtk_ddp_comp_id next,
> > unsigned int *addr);
> > + u32 (*ovl_mout_en)(enum mtk_ddp_comp_id cur,
> > + enum mtk_ddp_comp_id next,
> > + unsigned int *addr);
> > u32 (*sel_in)(enum mtk_ddp_comp_id cur,
> > enum mtk_ddp_comp_id next,
> > unsigned int *addr);
> > --
> > 1.8.1.1.dirty
> > _______________________________________________
> > Linux-mediatek mailing list
> > [email protected]
> > http://lists.infradead.org/mailman/listinfo/linux-mediatek