2022-10-10 11:53:36

by Yongqiang Niu

[permalink] [raw]
Subject: [PATCH v10, 0/4] mailbox: mtk-cmdq: add MT8186 support

base linux-next/master

change since v9:
1. improve register GCE_GCTL_VALUE write method reviewd in v9

Yongqiang Niu (4):
mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number
mailbox: mtk-cmdq: add gce software ddr enable private data
mailbox: mtk-cmdq: add gce ddr enable support flow
mailbox: mtk-cmdq: add MT8186 support

drivers/mailbox/mtk-cmdq-mailbox.c | 45 +++++++++++++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)

--
2.25.1


2022-10-10 12:04:43

by Yongqiang Niu

[permalink] [raw]
Subject: [PATCH v10, 2/4] mailbox: mtk-cmdq: add gce software ddr enable private data

if gce work control by software, we need set software enable
for MT8186 Soc

there is a handshake flow between gce and ddr hardware,
if not set ddr enable flag of gce, ddr will fall into idle
mode, then gce instructions will not process done.
we need set this flag of gce to tell ddr when gce is idle or busy
controlled by software flow.

0x48[2:0] means control by software
0x48[18:16] means ddr enable
0x48[2:0] is pre-condition of 0x48[18:16].
if we want set 0x48[18:16] ddr enable, 0x48[2:0] must be set at same
time.
and only these bits is useful, other bits is useless bits

Signed-off-by: Yongqiang Niu <[email protected]>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index c3cb24f51699..d2363c6b8b7a 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -39,6 +39,7 @@

#define GCE_GCTL_VALUE 0x48
#define GCE_CTRL_BY_SW GENMASK(2, 0)
+#define GCE_DDR_EN GENMASK(18, 16)

#define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200
#define CMDQ_THR_ENABLED 0x1
@@ -81,6 +82,7 @@ struct cmdq {
bool suspended;
u8 shift_pa;
bool control_by_sw;
+ bool sw_ddr_en;
u32 gce_num;
};

@@ -88,6 +90,7 @@ struct gce_plat {
u32 thread_nr;
u8 shift;
bool control_by_sw;
+ bool sw_ddr_en;
u32 gce_num;
};

@@ -127,10 +130,16 @@ static void cmdq_thread_resume(struct cmdq_thread *thread)
static void cmdq_init(struct cmdq *cmdq)
{
int i;
+ u32 gctl_regval = 0;

WARN_ON(clk_bulk_enable(cmdq->gce_num, cmdq->clocks));
if (cmdq->control_by_sw)
- writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
+ gctl_regval = GCE_CTRL_BY_SW;
+ if (cmdq->sw_ddr_en)
+ gctl_regval |= GCE_DDR_EN;
+
+ if (gctl_regval)
+ writel(gctl_regval, cmdq->base + GCE_GCTL_VALUE);

writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
for (i = 0; i <= CMDQ_MAX_EVENT; i++)
@@ -545,6 +554,7 @@ static int cmdq_probe(struct platform_device *pdev)
cmdq->thread_nr = plat_data->thread_nr;
cmdq->shift_pa = plat_data->shift;
cmdq->control_by_sw = plat_data->control_by_sw;
+ cmdq->sw_ddr_en = plat_data->sw_ddr_en;
cmdq->gce_num = plat_data->gce_num;
cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0);
err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
--
2.25.1

2022-10-10 12:12:22

by Yongqiang Niu

[permalink] [raw]
Subject: [PATCH v10, 1/4] mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number

Use GCE_CTRL_BY_SW definition instead of number

Signed-off-by: Yongqiang Niu <[email protected]>
Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 9465f9081515..c3cb24f51699 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -38,6 +38,7 @@
#define CMDQ_THR_PRIORITY 0x40

#define GCE_GCTL_VALUE 0x48
+#define GCE_CTRL_BY_SW GENMASK(2, 0)

#define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200
#define CMDQ_THR_ENABLED 0x1
@@ -129,7 +130,8 @@ static void cmdq_init(struct cmdq *cmdq)

WARN_ON(clk_bulk_enable(cmdq->gce_num, cmdq->clocks));
if (cmdq->control_by_sw)
- writel(0x7, cmdq->base + GCE_GCTL_VALUE);
+ writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
+
writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
for (i = 0; i <= CMDQ_MAX_EVENT; i++)
writel(i, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE);
--
2.25.1

2022-10-10 12:20:59

by Yongqiang Niu

[permalink] [raw]
Subject: [PATCH v10, 4/4] mailbox: mtk-cmdq: add MT8186 support

add MT8186 cmdq support

Signed-off-by: Yongqiang Niu <[email protected]>
Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 53904511598d..c5229f377c5e 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -694,9 +694,18 @@ static const struct gce_plat gce_plat_v6 = {
.gce_num = 2
};

+static const struct gce_plat gce_plat_v7 = {
+ .thread_nr = 24,
+ .shift = 3,
+ .control_by_sw = true,
+ .sw_ddr_en = true,
+ .gce_num = 1
+};
+
static const struct of_device_id cmdq_of_ids[] = {
{.compatible = "mediatek,mt8173-gce", .data = (void *)&gce_plat_v2},
{.compatible = "mediatek,mt8183-gce", .data = (void *)&gce_plat_v3},
+ {.compatible = "mediatek,mt8186-gce", .data = (void *)&gce_plat_v7},
{.compatible = "mediatek,mt6779-gce", .data = (void *)&gce_plat_v4},
{.compatible = "mediatek,mt8192-gce", .data = (void *)&gce_plat_v5},
{.compatible = "mediatek,mt8195-gce", .data = (void *)&gce_plat_v6},
--
2.25.1

2022-10-18 05:58:19

by CK Hu (胡俊光)

[permalink] [raw]
Subject: Re: [PATCH v10, 1/4] mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number

Hi, Yongqiang:

On Mon, 2022-10-10 at 16:50 +0800, Yongqiang Niu wrote:
> Use GCE_CTRL_BY_SW definition instead of number

Reviewed-by: CK Hu <[email protected]>

>
> Signed-off-by: Yongqiang Niu <[email protected]>
> Reviewed-by: AngeloGioacchino Del Regno <
> [email protected]>
> ---
> drivers/mailbox/mtk-cmdq-mailbox.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c
> b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 9465f9081515..c3cb24f51699 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -38,6 +38,7 @@
> #define CMDQ_THR_PRIORITY 0x40
>
> #define GCE_GCTL_VALUE 0x48
> +#define GCE_CTRL_BY_SW GENMASK(2, 0)
>
> #define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200
> #define CMDQ_THR_ENABLED 0x1
> @@ -129,7 +130,8 @@ static void cmdq_init(struct cmdq *cmdq)
>
> WARN_ON(clk_bulk_enable(cmdq->gce_num, cmdq->clocks));
> if (cmdq->control_by_sw)
> - writel(0x7, cmdq->base + GCE_GCTL_VALUE);
> + writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
> +
> writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base +
> CMDQ_THR_SLOT_CYCLES);
> for (i = 0; i <= CMDQ_MAX_EVENT; i++)
> writel(i, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE);

2022-10-18 06:14:56

by CK Hu (胡俊光)

[permalink] [raw]
Subject: Re: [PATCH v10, 4/4] mailbox: mtk-cmdq: add MT8186 support

Hi, Yongqiang:

On Mon, 2022-10-10 at 16:50 +0800, Yongqiang Niu wrote:
> add MT8186 cmdq support

Reviewed-by: CK Hu <[email protected]>

>
> Signed-off-by: Yongqiang Niu <[email protected]>
> Reviewed-by: AngeloGioacchino Del Regno <
> [email protected]>
> ---
> drivers/mailbox/mtk-cmdq-mailbox.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c
> b/drivers/mailbox/mtk-cmdq-mailbox.c
> index 53904511598d..c5229f377c5e 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -694,9 +694,18 @@ static const struct gce_plat gce_plat_v6 = {
> .gce_num = 2
> };
>
> +static const struct gce_plat gce_plat_v7 = {
> + .thread_nr = 24,
> + .shift = 3,
> + .control_by_sw = true,
> + .sw_ddr_en = true,
> + .gce_num = 1
> +};
> +
> static const struct of_device_id cmdq_of_ids[] = {
> {.compatible = "mediatek,mt8173-gce", .data = (void
> *)&gce_plat_v2},
> {.compatible = "mediatek,mt8183-gce", .data = (void
> *)&gce_plat_v3},
> + {.compatible = "mediatek,mt8186-gce", .data = (void
> *)&gce_plat_v7},
> {.compatible = "mediatek,mt6779-gce", .data = (void
> *)&gce_plat_v4},
> {.compatible = "mediatek,mt8192-gce", .data = (void
> *)&gce_plat_v5},
> {.compatible = "mediatek,mt8195-gce", .data = (void
> *)&gce_plat_v6},

2022-10-18 06:22:59

by CK Hu (胡俊光)

[permalink] [raw]
Subject: Re: [PATCH v10, 2/4] mailbox: mtk-cmdq: add gce software ddr enable private data

Hi, Yongqiang:

On Mon, 2022-10-10 at 16:50 +0800, Yongqiang Niu wrote:
> if gce work control by software, we need set software enable
> for MT8186 Soc
>
> there is a handshake flow between gce and ddr hardware,
> if not set ddr enable flag of gce, ddr will fall into idle
> mode, then gce instructions will not process done.
> we need set this flag of gce to tell ddr when gce is idle or busy
> controlled by software flow.
>
> 0x48[2:0] means control by software
> 0x48[18:16] means ddr enable
> 0x48[2:0] is pre-condition of 0x48[18:16].
> if we want set 0x48[18:16] ddr enable, 0x48[2:0] must be set at same
> time.
> and only these bits is useful, other bits is useless bits

Reviewed-by: CK Hu <[email protected]>

>
> Signed-off-by: Yongqiang Niu <[email protected]>
> ---
> drivers/mailbox/mtk-cmdq-mailbox.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c
> b/drivers/mailbox/mtk-cmdq-mailbox.c
> index c3cb24f51699..d2363c6b8b7a 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -39,6 +39,7 @@
>
> #define GCE_GCTL_VALUE 0x48
> #define GCE_CTRL_BY_SW GENMASK(2, 0)
> +#define GCE_DDR_EN GENMASK(18, 16)
>
> #define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200
> #define CMDQ_THR_ENABLED 0x1
> @@ -81,6 +82,7 @@ struct cmdq {
> bool suspended;
> u8 shift_pa;
> bool control_by_sw;
> + bool sw_ddr_en;
> u32 gce_num;
> };
>
> @@ -88,6 +90,7 @@ struct gce_plat {
> u32 thread_nr;
> u8 shift;
> bool control_by_sw;
> + bool sw_ddr_en;
> u32 gce_num;
> };
>
> @@ -127,10 +130,16 @@ static void cmdq_thread_resume(struct
> cmdq_thread *thread)
> static void cmdq_init(struct cmdq *cmdq)
> {
> int i;
> + u32 gctl_regval = 0;
>
> WARN_ON(clk_bulk_enable(cmdq->gce_num, cmdq->clocks));
> if (cmdq->control_by_sw)
> - writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
> + gctl_regval = GCE_CTRL_BY_SW;
> + if (cmdq->sw_ddr_en)
> + gctl_regval |= GCE_DDR_EN;
> +
> + if (gctl_regval)
> + writel(gctl_regval, cmdq->base + GCE_GCTL_VALUE);
>
> writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base +
> CMDQ_THR_SLOT_CYCLES);
> for (i = 0; i <= CMDQ_MAX_EVENT; i++)
> @@ -545,6 +554,7 @@ static int cmdq_probe(struct platform_device
> *pdev)
> cmdq->thread_nr = plat_data->thread_nr;
> cmdq->shift_pa = plat_data->shift;
> cmdq->control_by_sw = plat_data->control_by_sw;
> + cmdq->sw_ddr_en = plat_data->sw_ddr_en;
> cmdq->gce_num = plat_data->gce_num;
> cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0);
> err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler,
> IRQF_SHARED,

2022-11-15 09:17:33

by Yongqiang Niu

[permalink] [raw]
Subject: Re: [PATCH v10, 4/4] mailbox: mtk-cmdq: add MT8186 support

hi jassi

do you have any comment about this series patch?



On Tue, 2022-10-18 at 05:52 +0000, CK Hu (胡俊光) wrote:
> Hi, Yongqiang:
>
> On Mon, 2022-10-10 at 16:50 +0800, Yongqiang Niu wrote:
> > add MT8186 cmdq support
>
> Reviewed-by: CK Hu <[email protected]>
>
> >
> > Signed-off-by: Yongqiang Niu <[email protected]>
> > Reviewed-by: AngeloGioacchino Del Regno <
> > [email protected]>
> > ---
> > drivers/mailbox/mtk-cmdq-mailbox.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c
> > b/drivers/mailbox/mtk-cmdq-mailbox.c
> > index 53904511598d..c5229f377c5e 100644
> > --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> > +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> > @@ -694,9 +694,18 @@ static const struct gce_plat gce_plat_v6 = {
> > .gce_num = 2
> > };
> >
> > +static const struct gce_plat gce_plat_v7 = {
> > + .thread_nr = 24,
> > + .shift = 3,
> > + .control_by_sw = true,
> > + .sw_ddr_en = true,
> > + .gce_num = 1
> > +};
> > +
> > static const struct of_device_id cmdq_of_ids[] = {
> > {.compatible = "mediatek,mt8173-gce", .data = (void
> > *)&gce_plat_v2},
> > {.compatible = "mediatek,mt8183-gce", .data = (void
> > *)&gce_plat_v3},
> > + {.compatible = "mediatek,mt8186-gce", .data = (void
> > *)&gce_plat_v7},
> > {.compatible = "mediatek,mt6779-gce", .data = (void
> > *)&gce_plat_v4},
> > {.compatible = "mediatek,mt8192-gce", .data = (void
> > *)&gce_plat_v5},
> > {.compatible = "mediatek,mt8195-gce", .data = (void
> > *)&gce_plat_v6},