Re: [PATCH v3] arm64: dts: mediatek: Add mt8192 power domains controller

2021-02-18 Thread Weiyi Lu
On Mon, 2020-11-30 at 19:16 +0800, Weiyi Lu wrote:
> On Fri, 2020-11-27 at 13:42 +0100, Matthias Brugger wrote:
> > 
> > On 19/11/2020 15:13, Enric Balletbo Serra wrote:
> > > Hi Weiyi,
> > > 
> > > Missatge de Weiyi Lu  del dia dj., 19 de nov.
> > > 2020 a les 14:10:
> > >>
> > >> On Thu, 2020-11-19 at 13:13 +0100, Enric Balletbo Serra wrote:
> > >>> Hi Weiyi,
> > >>>
> > >>> Thank you for the patch
> > >>>
> > >>> Missatge de Weiyi Lu  del dia dj., 19 de nov.
> > >>> 2020 a les 11:48:
> > >>>>
> > >>>> Add power domains controller node for SoC mt8192
> > >>>>
> > >>>> Signed-off-by: Weiyi Lu 
> > >>>> ---
> > [...]
> > >>>> +   /* System Power Manager */
> > >>>> +   spm: power-controller {
> > >>>> +   compatible = 
> > >>>> "mediatek,mt8192-power-controller";
> > >>>> +   #address-cells = <1>;
> > >>>> +   #size-cells = <0>;
> > >>>> +   #power-domain-cells = <1>;
> > >>>> +
> > >>>> +   /* power domain of the SoC */
> > >>>> +   audio@MT8192_POWER_DOMAIN_AUDIO {
> > >>>
> > >>> If you run the dt_bindings_check it should return some errors, as all
> > >>> these node names should be 'power-domain@'. Which is a bit annoying
> > >>> because then you will get a bunch of errors like this:
> > >>>
> > >>> [1.969110] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [1.976997] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [1.984828] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [1.992657] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.000685] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.008566] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.016395] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.024221] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.032049] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.039874] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.047699] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.055524] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.063352] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>> [2.071176] debugfs: Directory 'power-domain' with parent
> > >>> 'pm_genpd' already present!
> > >>>
> > >>> But that's another problem that should be handled in debugfs system.
> > >>>
> > >>
> > >> Indeed...so I chose to use different name in dts to avoid problems in
> > >> debugfs. It does violate the naming rules.
> > >>
> > > 
> > > But your binding will not pass (or trigger warnings) the dtb check
> > > then. Rob was clear that names should be generic. Proper fix is fix
> > > debugfs not the binding.
> > > 
> > 
> > By the way, is anybody working on this debugfs issue?
> > 
> 
> I think we can solve this problem by adding "name" to the struct
> scpsys_domain_data and use this domain_data->name as the genpd.name.
> This is very simple. But I want to know if you both like it?
> 

Hi Enric and Matthias,

May I have your opinions on how you might to fix this issue?
I'll try to give another name to each power domain in the
scpsys_domain_data and register power domain with this name like below

struct scpsys_domain_data {
...
+   char *name;
 };


-   pd->genpd.name = node->name;
+   pd->genpd.name = pd->data->name ?: node->name;


Does it violate the naming rules to some extent? or it's acceptable?

> > Regards,
> > Matthias
> 
> 
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek



Re: [PATCH v6 10/22] clk: mediatek: Add MT8192 basic clocks support

2021-02-17 Thread Weiyi Lu
On Wed, 2021-02-10 at 13:46 +0100, Matthias Brugger wrote:
> 
> On 22/12/2020 14:09, Weiyi Lu wrote:
> > Add MT8192 basic clock providers, include topckgen, apmixedsys,
> > infracfg and pericfg.
> > 
> > Signed-off-by: Weiyi Lu 
> > ---
> >  drivers/clk/mediatek/Kconfig  |8 +
> >  drivers/clk/mediatek/Makefile |1 +
> >  drivers/clk/mediatek/clk-mt8192.c | 1326 
> > +
> >  drivers/clk/mediatek/clk-mux.h|   15 +
> >  4 files changed, 1350 insertions(+)
> >  create mode 100644 drivers/clk/mediatek/clk-mt8192.c
> > 
> 
> [...]
> 
> > +static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
> > +{
> > +   struct clk_onecell_data *clk_data;
> > +   struct device_node *node = pdev->dev.of_node;
> > +   int r;
> > +
> > +   clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
> > +   if (!clk_data)
> > +   return -ENOMEM;
> > +
> > +   mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
> > +   r = mtk_clk_register_gates(node, apmixed_clks, 
> > ARRAY_SIZE(apmixed_clks), clk_data);
> > +   if (r)
> > +   return r;
> > +
> > +   return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
> > +}
> > +
> > +static const struct of_device_id of_match_clk_mt8192[] = {
> > +   {
> > +   .compatible = "mediatek,mt8192-apmixedsys",
> > +   .data = clk_mt8192_apmixed_probe,
> > +   }, {
> > +   .compatible = "mediatek,mt8192-topckgen",
> > +   .data = clk_mt8192_top_probe,
> > +   }, {
> > +   .compatible = "mediatek,mt8192-infracfg",
> > +   .data = clk_mt8192_infra_probe,
> > +   }, {
> > +   .compatible = "mediatek,mt8192-pericfg",
> > +   .data = clk_mt8192_peri_probe,
> > +   }, {
> > +   /* sentinel */
> > +   }
> > +};
> > +
> > +static int clk_mt8192_probe(struct platform_device *pdev)
> > +{
> > +   int (*clk_probe)(struct platform_device *pdev);
> > +   int r;
> > +
> > +   clk_probe = of_device_get_match_data(>dev);
> > +   if (!clk_probe)
> > +   return -EINVAL;
> > +
> > +   r = clk_probe(pdev);
> > +   if (r)
> > +   dev_err(>dev, "could not register clock provider: %s: 
> > %d\n", pdev->name, r);
> > +
> > +   return r;
> > +}
> > +
> > +static struct platform_driver clk_mt8192_drv = {
> > +   .probe = clk_mt8192_probe,
> > +   .driver = {
> > +   .name = "clk-mt8192",
> > +   .of_match_table = of_match_clk_mt8192,
> > +   },
> > +};
> > +
> > +static int __init clk_mt8192_init(void)
> > +{
> > +   return platform_driver_register(_mt8192_drv);
> > +}
> > +
> > +arch_initcall(clk_mt8192_init);
> 
> Do we really need all these clocks that early?
> Why don't we use CLK_OF_DECLARE_DRIVER() then and why do we initialize some
> clocks CLK_OF_DECLARE_DRIVER and other with arch_initcall?
> 
> I know that this is in other drivers for MediaTek SoCs, but that does not mean
> it's the right approach.
> 

I guess you mean CLK_OF_DECLARE() but not CLK_OF_DECLARE_DRIVER(), am I
correct?
I saw there had some discussion[1][2] about initializing these basic
clocks by CLK_OF_DECLARE() or the current implementation by arch_init().
Could I have more of your opinion on this discussion?
[1]
https://patchwork.kernel.org/project/linux-mediatek/patch/1454665050-37776-5-git-send-email-jamesjj.l...@mediatek.com/
[2]
https://patchwork.kernel.org/project/linux-mediatek/patch/1460621514-65191-5-git-send-email-jamesjj.l...@mediatek.com/

As to CLK_OF_DECLARE_DRIVER(), we have to initialize the clocks earlier
for timer(clocksource) driver by this way.

> 
> > diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h
> > index f5625f4..afbc7df 100644
> > --- a/drivers/clk/mediatek/clk-mux.h
> > +++ b/drivers/clk/mediatek/clk-mux.h
> > @@ -77,6 +77,21 @@ struct mtk_mux {
> > _width, _gate, _upd_ofs, _upd,  \
> > CLK_SET_RATE_PARENT)
> >  
> > +#define MUX_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs,  
> > \
> > +   _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
> > +   _upd_ofs, _upd, _flags) \
> > +   GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs,  \
> > +   _mux_set_ofs, _mux_clr_ofs, _

Re: [PATCH v6 01/22] dt-bindings: ARM: Mediatek: Add new document bindings of imp i2c wrapper controller

2021-02-17 Thread Weiyi Lu
On Wed, 2021-02-10 at 13:19 +0100, Matthias Brugger wrote:
> 
> On 22/12/2020 14:09, Weiyi Lu wrote:
> > This patch adds the new binding documentation of imp i2c wrapper controller
> > for Mediatek MT8192.
> 
> The wrapper controller has only clock parts, or are the clock register mapped
> into the i2c wrapper block. In that case we might want to probe the clock 
> driver
> through the i2c wrapper driver.
> 
> Regards,
> Matthias
> 

Yes, the clock registers are mapped into partial of the i2c wrapper
block.
AFAIK, the i2c wrapper works with the i2c
driver(i2c/busses/i2c-mt65xx.c) but not a new driver.
So do you still suggest us to probe the clock driver through the i2c
driver(i2c/busses/i2c-mt65xx.c) just like the mtk-mm driver?

> > 
> > Signed-off-by: Weiyi Lu 
> > ---
> >  .../arm/mediatek/mediatek,imp_iic_wrap.yaml| 78 
> > ++
> >  1 file changed, 78 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml 
> > b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
> > new file mode 100644
> > index 000..5d0cf37
> > --- /dev/null
> > +++ 
> > b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
> > @@ -0,0 +1,78 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,imp_iic_wrap.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: MediaTek IMP I2C Wrapper Controller
> > +
> > +maintainers:
> > +  - Weiyi Lu 
> > +
> > +description:
> > +  The Mediatek imp i2c wrapper controller provides functional 
> > configurations and clocks to the system.
> > +
> > +properties:
> > +  compatible:
> > +items:
> > +  - enum:
> > +  - mediatek,mt8192-imp_iic_wrap_c
> > +  - mediatek,mt8192-imp_iic_wrap_e
> > +  - mediatek,mt8192-imp_iic_wrap_s
> > +  - mediatek,mt8192-imp_iic_wrap_ws
> > +  - mediatek,mt8192-imp_iic_wrap_w
> > +  - mediatek,mt8192-imp_iic_wrap_n
> > +  - const: syscon
> > +
> > +  reg:
> > +maxItems: 1
> > +
> > +  '#clock-cells':
> > +const: 1
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +
> > +examples:
> > +  - |
> > +imp_iic_wrap_c: syscon@11007000 {
> > +compatible = "mediatek,mt8192-imp_iic_wrap_c", "syscon";
> > +reg = <0 0x11007000 0 0x1000>;
> > +#clock-cells = <1>;
> > +};
> > +
> > +  - |
> > +imp_iic_wrap_e: syscon@11cb1000 {
> > +compatible = "mediatek,mt8192-imp_iic_wrap_e", "syscon";
> > +reg = <0 0x11cb1000 0 0x1000>;
> > +#clock-cells = <1>;
> > +};
> > +
> > +  - |
> > +imp_iic_wrap_s: syscon@11d03000 {
> > +compatible = "mediatek,mt8192-imp_iic_wrap_s", "syscon";
> > +reg = <0 0x11d03000 0 0x1000>;
> > +#clock-cells = <1>;
> > +};
> > +
> > +  - |
> > +imp_iic_wrap_ws: syscon@11d23000 {
> > +compatible = "mediatek,mt8192-imp_iic_wrap_ws", "syscon";
> > +reg = <0 0x11d23000 0 0x1000>;
> > +#clock-cells = <1>;
> > +};
> > +
> > +  - |
> > +imp_iic_wrap_w: syscon@11e01000 {
> > +compatible = "mediatek,mt8192-imp_iic_wrap_w", "syscon";
> > +reg = <0 0x11e01000 0 0x1000>;
> > +#clock-cells = <1>;
> > +};
> > +
> > +  - |
> > +imp_iic_wrap_n: syscon@11f02000 {
> > +compatible = "mediatek,mt8192-imp_iic_wrap_n", "syscon";
> > +reg = <0 0x11f02000 0 0x1000>;
> > +#clock-cells = <1>;
> > +};
> > 
> 
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek



Re: [PATCH v6 00/22] Mediatek MT8192 clock support

2021-02-17 Thread Weiyi Lu
On Mon, 2021-02-08 at 17:00 -0800, Stephen Boyd wrote:
> Quoting Weiyi Lu (2020-12-22 05:09:25)
> > This series is based on v5.10-rc1.
> > 
> 
> The DT bindings fail, can you fix and resend?
> 

OK, I'll fix and resend. Thank you for reviewing.

> Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml: 
> 'additionalProperties' is a required property
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml: 
> 'additionalProperties' is a required property
> Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml: 
> 'additionalProperties' is a required property
> Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml: 
> 'additionalProperties' is a required property
> Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml: ignoring, 
> error in schema:
> warning: no schema found in file: 
> Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml: 
> ignoring, error in schema:
> warning: no schema found in file: 
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml: 
> ignoring, error in schema:
> warning: no schema found in file: 
> Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml: 
> ignoring, error in schema:
> warning: no schema found in file: 
> Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.example.dt.yaml: 
> example-0: syscon@11f6:reg:0: [0, 301334528, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.example.dt.yaml: 
> example-1: syscon@11f1:reg:0: [0, 301006848, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.example.dt.yaml:
>  example-0: syscon@1f00:reg:0: [0, 520093696, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.example.dt.yaml:
>  example-0: syscon@11007000:reg:0: [0, 285241344, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.example.dt.yaml:
>  example-1: syscon@11cb1000:reg:0: [0, 298520576, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.example.dt.yaml:
>  example-2: syscon@11d03000:reg:0: [0, 298856448, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.example.dt.yaml:
>  example-3: syscon@11d23000:reg:0: [0, 298987520, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.example.dt.yaml:
>  example-4: syscon@11e01000:reg:0: [0, 299896832, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.example.dt.yaml:
>  example-5: syscon@11f02000:reg:0: [0, 300949504, 0, 4096] is too long
> From schema: 
> ~/.local/lib/python3.8/site-packages/dtschema/schemas/reg.yaml
> 
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek



Re: [PATCH 0/2] Add MediaTek MT8192 clock provider device nodes

2021-02-01 Thread Weiyi Lu
On Sun, 2021-01-31 at 14:27 +0100, Matthias Brugger wrote:
> 
> On 22/12/2020 14:40, Weiyi Lu wrote:
> > This series is based on v5.10-rc1, MT8192 dts v6[1] and
> > MT8192 clock v6 series[2].
> > 
> > [1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=373899
> > [2] https://patchwork.kernel.org/project/linux-mediatek/list/?series=405295
> > 
> 
> [1] is already mainline. You could add this patch as a new one to [2]. But
> please try to improve the series, before sending just a new version with this
> patch added.
> 
> Regards,
> Matthias
> 
Hi Matthias,

Actually I'm a little confused now. Stephen suggested me to send clock
dts separately because dts may not go through his tree.
So I separated it from the MT8192 clock series since clock v6.
What do you suggest me to do next time?

> > Weiyi Lu (2):
> >   arm64: dts: mediatek: Add mt8192 clock controllers
> >   arm64: dts: mediatek: Correct UART0 bus clock of MT8192
> > 
> >  arch/arm64/boot/dts/mediatek/mt8192.dtsi | 165 ++-
> >  1 file changed, 164 insertions(+), 1 deletion(-)
> > 



Re: [PATCH v6 10/22] clk: mediatek: Add MT8192 basic clocks support

2021-01-06 Thread Weiyi Lu
On Wed, 2021-01-06 at 18:52 +0800, Ikjoon Jang wrote:
> On Wed, Jan 6, 2021 at 6:42 PM Weiyi Lu  wrote:
> >
> > On Wed, 2021-01-06 at 18:25 +0800, Ikjoon Jang wrote:
> > > On Tue, Dec 22, 2020 at 9:14 PM Weiyi Lu  wrote:
> > > >
> > > > Add MT8192 basic clock providers, include topckgen, apmixedsys,
> > > > infracfg and pericfg.
> > > >
> > > > Signed-off-by: Weiyi Lu 
> > > > ---
> > > >  drivers/clk/mediatek/Kconfig  |8 +
> > > >  drivers/clk/mediatek/Makefile |1 +
> > > >  drivers/clk/mediatek/clk-mt8192.c | 1326 
> > > > +
> > > >  drivers/clk/mediatek/clk-mux.h|   15 +
> > > >  4 files changed, 1350 insertions(+)
> > > >  create mode 100644 drivers/clk/mediatek/clk-mt8192.c
> > > >
> > >
> > > 
> > >
> > > > diff --git a/drivers/clk/mediatek/clk-mux.h 
> > > > b/drivers/clk/mediatek/clk-mux.h
> > > > index f5625f4..afbc7df 100644
> > > > --- a/drivers/clk/mediatek/clk-mux.h
> > > > +++ b/drivers/clk/mediatek/clk-mux.h
> > > > @@ -77,6 +77,21 @@ struct mtk_mux {
> > > > _width, _gate, _upd_ofs, _upd,  
> > > > \
> > > > CLK_SET_RATE_PARENT)
> > > >
> > > > +#define MUX_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs,  
> > > > \
> > > > +   _mux_set_ofs, _mux_clr_ofs, _shift, _width, 
> > > > \
> > > > +   _upd_ofs, _upd, _flags) 
> > > > \
> > > > +   GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs,  
> > > > \
> > > > +   _mux_set_ofs, _mux_clr_ofs, _shift, _width, 
> > > > \
> > > > +   0, _upd_ofs, _upd, _flags,  
> > > > \
> > > > +   mtk_mux_clr_set_upd_ops)
> > > > +
> > > > +#define MUX_CLR_SET_UPD(_id, _name, _parents, _mux_ofs,
> > > > \
> > > > +   _mux_set_ofs, _mux_clr_ofs, _shift, _width, 
> > > > \
> > > > +   _upd_ofs, _upd) 
> > > > \
> > > > +   MUX_CLR_SET_UPD_FLAGS(_id, _name, _parents, 
> > > > \
> > > > +   _mux_ofs, _mux_set_ofs, _mux_clr_ofs, _shift,   
> > > > \
> > > > +   _width, _upd_ofs, _upd, CLK_SET_RATE_PARENT)
> > > > +
> > >
> > > conflicts, these macros are already existed in upstream.
> >
> > really? These two macros don't show up in 5.11-rc1 yet.
> 
> yep, maybe this one: a3ae549917f1 "clk: mediatek: Add new clkmux register API"
> 

The new macros in this patch are for the clock MUX without gate control.
It's a little different from those mux macros with gate control in
a3ae549917f1 "clk: mediatek: Add new clkmux register API"

> >
> > > >  struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
> > > >  struct regmap *regmap,
> > > >  spinlock_t *lock);
> > > > --
> > > > 1.8.1.1.dirty
> > > > ___
> > > > Linux-mediatek mailing list
> > > > linux-media...@lists.infradead.org
> > > > http://lists.infradead.org/mailman/listinfo/linux-mediatek
> >
> > ___
> > Linux-mediatek mailing list
> > linux-media...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-mediatek



Re: [PATCH v6 10/22] clk: mediatek: Add MT8192 basic clocks support

2021-01-06 Thread Weiyi Lu
On Wed, 2021-01-06 at 18:25 +0800, Ikjoon Jang wrote:
> On Tue, Dec 22, 2020 at 9:14 PM Weiyi Lu  wrote:
> >
> > Add MT8192 basic clock providers, include topckgen, apmixedsys,
> > infracfg and pericfg.
> >
> > Signed-off-by: Weiyi Lu 
> > ---
> >  drivers/clk/mediatek/Kconfig  |8 +
> >  drivers/clk/mediatek/Makefile |1 +
> >  drivers/clk/mediatek/clk-mt8192.c | 1326 
> > +
> >  drivers/clk/mediatek/clk-mux.h|   15 +
> >  4 files changed, 1350 insertions(+)
> >  create mode 100644 drivers/clk/mediatek/clk-mt8192.c
> >
> 
> 
> 
> > diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h
> > index f5625f4..afbc7df 100644
> > --- a/drivers/clk/mediatek/clk-mux.h
> > +++ b/drivers/clk/mediatek/clk-mux.h
> > @@ -77,6 +77,21 @@ struct mtk_mux {
> > _width, _gate, _upd_ofs, _upd,  \
> > CLK_SET_RATE_PARENT)
> >
> > +#define MUX_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs,  \
> > +   _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
> > +   _upd_ofs, _upd, _flags) \
> > +   GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs,  \
> > +   _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
> > +   0, _upd_ofs, _upd, _flags,  \
> > +   mtk_mux_clr_set_upd_ops)
> > +
> > +#define MUX_CLR_SET_UPD(_id, _name, _parents, _mux_ofs,
> > \
> > +   _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
> > +   _upd_ofs, _upd) \
> > +   MUX_CLR_SET_UPD_FLAGS(_id, _name, _parents, \
> > +   _mux_ofs, _mux_set_ofs, _mux_clr_ofs, _shift,   \
> > +   _width, _upd_ofs, _upd, CLK_SET_RATE_PARENT)
> > +
> 
> conflicts, these macros are already existed in upstream.

really? These two macros don't show up in 5.11-rc1 yet.

> >  struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
> >  struct regmap *regmap,
> >  spinlock_t *lock);
> > --
> > 1.8.1.1.dirty
> > ___
> > Linux-mediatek mailing list
> > linux-media...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-mediatek



[PATCH 2/2] soc: mediatek: Fix the clock prepared issue

2021-01-04 Thread Weiyi Lu
In this new power domain driver, when adding one power domain
it will prepare the depenedent clocks at the same.
So we only do clk_bulk_enable/disable control during power ON/OFF.
When system suspend, the pm runtime framework will forcely power off
power domains. However, the dependent clocks are disabled but kept
preapred.

In MediaTek clock drivers, PLL would be turned ON when we do
clk_bulk_prepare control.

Clock hierarchy:
PLL -->
   DIV_CK -->
 CLK_MUX
 (may be dependent clocks)
 -->
 SUBSYS_CG
 (may be dependent clocks)

It will lead some unexpected clock states during system suspend.
This patch will fix by doing prepare_enable/disable_unprepare on
dependent clocks at the same time while we are going to power on/off
any power domain.

Signed-off-by: Weiyi Lu 
---
 drivers/soc/mediatek/mtk-pm-domains.c | 31 ---
 1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-pm-domains.c 
b/drivers/soc/mediatek/mtk-pm-domains.c
index a160800..f0bcc84 100644
--- a/drivers/soc/mediatek/mtk-pm-domains.c
+++ b/drivers/soc/mediatek/mtk-pm-domains.c
@@ -216,7 +216,7 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
if (ret < 0)
return ret;
 
-   ret = clk_bulk_enable(pd->num_clks, pd->clks);
+   ret = clk_bulk_prepare_enable(pd->num_clks, pd->clks);
if (ret)
goto err_disable_regulator;
 
@@ -234,7 +234,7 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_ISO_BIT);
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
 
-   ret = clk_bulk_enable(pd->num_subsys_clks, pd->subsys_clks);
+   ret = clk_bulk_prepare_enable(pd->num_subsys_clks, pd->subsys_clks);
if (ret)
goto err_pwr_ack;
 
@@ -251,9 +251,9 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
 err_disable_sram:
scpsys_sram_disable(pd);
 err_disable_subsys_clks:
-   clk_bulk_disable(pd->num_subsys_clks, pd->subsys_clks);
+   clk_bulk_disable_unprepare(pd->num_subsys_clks, pd->subsys_clks);
 err_pwr_ack:
-   clk_bulk_disable(pd->num_clks, pd->clks);
+   clk_bulk_disable_unprepare(pd->num_clks, pd->clks);
 err_disable_regulator:
scpsys_regulator_disable(pd);
return ret;
@@ -274,7 +274,7 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
if (ret < 0)
return ret;
 
-   clk_bulk_disable(pd->num_subsys_clks, pd->subsys_clks);
+   clk_bulk_disable_unprepare(pd->num_subsys_clks, pd->subsys_clks);
 
/* subsys power off */
regmap_clear_bits(scpsys->base, pd->data->ctl_offs, PWR_RST_B_BIT);
@@ -289,7 +289,7 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
if (ret < 0)
return ret;
 
-   clk_bulk_disable(pd->num_clks, pd->clks);
+   clk_bulk_disable_unprepare(pd->num_clks, pd->clks);
 
ret = scpsys_regulator_disable(pd);
if (ret < 0)
@@ -402,14 +402,6 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys 
*scpsys, struct device_no
pd->subsys_clks[i].clk = clk;
}
 
-   ret = clk_bulk_prepare(pd->num_clks, pd->clks);
-   if (ret)
-   goto err_put_subsys_clocks;
-
-   ret = clk_bulk_prepare(pd->num_subsys_clks, pd->subsys_clks);
-   if (ret)
-   goto err_unprepare_clocks;
-
/*
 * Initially turn on all domains to make the domains usable
 * with !CONFIG_PM and to get the hardware in sync with the
@@ -424,7 +416,7 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys 
*scpsys, struct device_no
ret = scpsys_power_on(>genpd);
if (ret < 0) {
dev_err(scpsys->dev, "%pOF: failed to power on domain: 
%d\n", node, ret);
-   goto err_unprepare_clocks;
+   goto err_put_subsys_clocks;
}
}
 
@@ -432,7 +424,7 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys 
*scpsys, struct device_no
ret = -EINVAL;
dev_err(scpsys->dev,
"power domain with id %d already exists, check your 
device-tree\n", id);
-   goto err_unprepare_subsys_clocks;
+   goto err_put_subsys_clocks;
}
 
pd->genpd.name = pd->data->name ?: node->name;
@@ -448,10 +440,6 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys 
*scpsys, struct device_no
 
return scpsys->pd_data.domains[id];
 
-err_unprepare_subsys_clocks:
-   clk_bulk_unprepare(pd->num_subsys_clks, pd->subsys_clks)

[PATCH 0/2] Fixes for new SCPSYS power domains controller driver

2021-01-04 Thread Weiyi Lu
This patch is base on v5.10-rc1 and
series "Add new driver for SCPSYS power domains controller"[1]

[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=374013

Weiyi Lu (2):
  soc: mediatek: Add regulator control for MT8192 MFG power domain
  soc: mediatek: Fix the clock prepared issue

 drivers/soc/mediatek/mt8192-pm-domains.h |  1 +
 drivers/soc/mediatek/mtk-pm-domains.c| 73 
 drivers/soc/mediatek/mtk-pm-domains.h|  2 +
 3 files changed, 51 insertions(+), 25 deletions(-)



[PATCH 1/2] soc: mediatek: Add regulator control for MT8192 MFG power domain

2021-01-04 Thread Weiyi Lu
Add regulator control support and specific power domain name of
MT8192 MFG power domain for regulator lookup.
Also power domain name can fix the debugfs warning.
(e.g. debugfs: Directory 'power-domain' with parent 'pm_genpd'
already present!)
However, not every domain with name need to get the regulator,
if we just want to fix the debugfs warning log by adding names to
power domains. Considering this case, lookup regulator by
regulator_get_optional() instead of getting a dummy regulator from
regulator_get() to operate.

Signed-off-by: Weiyi Lu 
---
 drivers/soc/mediatek/mt8192-pm-domains.h |  1 +
 drivers/soc/mediatek/mtk-pm-domains.c| 42 ++--
 drivers/soc/mediatek/mtk-pm-domains.h|  2 ++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/mediatek/mt8192-pm-domains.h 
b/drivers/soc/mediatek/mt8192-pm-domains.h
index 0fdf6dc..7db0ad3 100644
--- a/drivers/soc/mediatek/mt8192-pm-domains.h
+++ b/drivers/soc/mediatek/mt8192-pm-domains.h
@@ -49,6 +49,7 @@
.ctl_offs = 0x0308,
.sram_pdn_bits = GENMASK(8, 8),
.sram_pdn_ack_bits = GENMASK(12, 12),
+   .name = "mfg",
},
[MT8192_POWER_DOMAIN_MFG1] = {
.sta_mask = BIT(3),
diff --git a/drivers/soc/mediatek/mtk-pm-domains.c 
b/drivers/soc/mediatek/mtk-pm-domains.c
index fb70cb3..a160800 100644
--- a/drivers/soc/mediatek/mtk-pm-domains.c
+++ b/drivers/soc/mediatek/mtk-pm-domains.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "mt8173-pm-domains.h"
@@ -40,6 +41,7 @@ struct scpsys_domain {
struct clk_bulk_data *subsys_clks;
struct regmap *infracfg;
struct regmap *smi;
+   struct regulator *supply;
 };
 
 struct scpsys {
@@ -187,6 +189,22 @@ static int scpsys_bus_protect_disable(struct scpsys_domain 
*pd)
return _scpsys_bus_protect_disable(pd->data->bp_infracfg, pd->infracfg);
 }
 
+static int scpsys_regulator_enable(struct scpsys_domain *pd)
+{
+   if (!pd->supply)
+   return 0;
+
+   return regulator_enable(pd->supply);
+}
+
+static int scpsys_regulator_disable(struct scpsys_domain *pd)
+{
+   if (!pd->supply)
+   return 0;
+
+   return regulator_disable(pd->supply);
+}
+
 static int scpsys_power_on(struct generic_pm_domain *genpd)
 {
struct scpsys_domain *pd = container_of(genpd, struct scpsys_domain, 
genpd);
@@ -194,9 +212,13 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
bool tmp;
int ret;
 
+   ret = scpsys_regulator_enable(pd);
+   if (ret < 0)
+   return ret;
+
ret = clk_bulk_enable(pd->num_clks, pd->clks);
if (ret)
-   return ret;
+   goto err_disable_regulator;
 
/* subsys power on */
regmap_set_bits(scpsys->base, pd->data->ctl_offs, PWR_ON_BIT);
@@ -232,6 +254,8 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
clk_bulk_disable(pd->num_subsys_clks, pd->subsys_clks);
 err_pwr_ack:
clk_bulk_disable(pd->num_clks, pd->clks);
+err_disable_regulator:
+   scpsys_regulator_disable(pd);
return ret;
 }
 
@@ -267,6 +291,10 @@ static int scpsys_power_off(struct generic_pm_domain 
*genpd)
 
clk_bulk_disable(pd->num_clks, pd->clks);
 
+   ret = scpsys_regulator_disable(pd);
+   if (ret < 0)
+   return ret;
+
return 0;
 }
 
@@ -315,6 +343,16 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys 
*scpsys, struct device_no
if (IS_ERR(pd->smi))
return ERR_CAST(pd->smi);
 
+   if (pd->data->name) {
+   pd->supply = devm_regulator_get_optional(scpsys->dev, 
pd->data->name);
+   if (IS_ERR(pd->supply)) {
+   if (PTR_ERR(pd->supply) == -ENODEV)
+   pd->supply = NULL;
+   else
+   return ERR_CAST(pd->supply);
+   }
+   }
+
num_clks = of_clk_get_parent_count(node);
if (num_clks > 0) {
/* Calculate number of subsys_clks */
@@ -397,7 +435,7 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys 
*scpsys, struct device_no
goto err_unprepare_subsys_clocks;
}
 
-   pd->genpd.name = node->name;
+   pd->genpd.name = pd->data->name ?: node->name;
pd->genpd.power_off = scpsys_power_off;
pd->genpd.power_on = scpsys_power_on;
 
diff --git a/drivers/soc/mediatek/mtk-pm-domains.h 
b/drivers/soc/mediatek/mtk-pm-domains.h
index a2f4d8f..58d72fb 100644
--- a/drivers/soc/mediatek/mtk-pm-domains.h
+++ b/drivers/soc/mediatek/mtk-pm-domains.h
@@ -81,6 +81,7 @@ struct scpsys_bus_prot_data {
  * @caps: The flag for active wake-up action.
  * @bp_infracfg: bus protect

[PATCH v4] arm64: dts: mediatek: Add mt8192 power domains controller

2020-12-22 Thread Weiyi Lu
Add power domains controller node for SoC mt8192

Signed-off-by: Weiyi Lu 
---
This patch is base on v5.10-rc1,
series "Add new driver for SCPSYS power domains controller"[1]
and series "Add MediaTek MT8192 clock provider device nodes"[2]

[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=374013
[2] https://patchwork.kernel.org/project/linux-mediatek/list/?series=405329

change since v4: correct the power domain node names

 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 201 +++
 1 file changed, 201 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index ac5dca6..9958a64 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 / {
compatible = "mediatek,mt8192";
@@ -257,6 +258,206 @@
#interrupt-cells = <2>;
};
 
+   scpsys: syscon@10006000 {
+   compatible = "syscon", "simple-mfd";
+   reg = <0 0x10006000 0 0x1000>;
+   #power-domain-cells = <1>;
+
+   /* System Power Manager */
+   spm: power-controller {
+   compatible = "mediatek,mt8192-power-controller";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   #power-domain-cells = <1>;
+
+   /* power domain of the SoC */
+   power-domain@MT8192_POWER_DOMAIN_AUDIO {
+   reg = ;
+   clocks = < 
CLK_TOP_AUD_INTBUS_SEL>,
+< 
CLK_INFRA_AUDIO_26M_B>,
+< CLK_INFRA_AUDIO>;
+   clock-names = "audio", "audio1", 
"audio2";
+   mediatek,infracfg = <>;
+   #power-domain-cells = <0>;
+   };
+
+   power-domain@MT8192_POWER_DOMAIN_CONN {
+   reg = ;
+   clocks = < 
CLK_INFRA_PMIC_CONN>;
+   clock-names = "conn";
+   mediatek,infracfg = <>;
+   #power-domain-cells = <0>;
+   };
+
+   power-domain@MT8192_POWER_DOMAIN_MFG0 {
+   reg = ;
+   clocks = < 
CLK_TOP_MFG_PLL_SEL>;
+   clock-names = "mfg";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   #power-domain-cells = <1>;
+
+   power-domain@MT8192_POWER_DOMAIN_MFG1 {
+   reg = 
;
+   mediatek,infracfg = <>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   #power-domain-cells = <1>;
+
+   
power-domain@MT8192_POWER_DOMAIN_MFG2 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   };
+
+   
power-domain@MT8192_POWER_DOMAIN_MFG3 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   };
+
+   
power-domain@MT8192_POWER_DOMAIN_MFG4 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   };
+
+   
power-domain@MT8192_POWER_DOMAIN_MFG5 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+ 

[PATCH 2/2] arm64: dts: mediatek: Correct UART0 bus clock of MT8192

2020-12-22 Thread Weiyi Lu
infra_uart0 clock is the real one what uart0 uses as bus clock.

Signed-off-by: Weiyi Lu 
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index 92dcfbd..ac5dca6 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -283,7 +283,7 @@
 "mediatek,mt6577-uart";
reg = <0 0x11002000 0 0x1000>;
interrupts = ;
-   clocks = <>, <>;
+   clocks = <>, < CLK_INFRA_UART0>;
clock-names = "baud", "bus";
status = "disabled";
};
-- 
1.8.1.1.dirty



[PATCH 0/2] Add MediaTek MT8192 clock provider device nodes

2020-12-22 Thread Weiyi Lu
This series is based on v5.10-rc1, MT8192 dts v6[1] and
MT8192 clock v6 series[2].

[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=373899
[2] https://patchwork.kernel.org/project/linux-mediatek/list/?series=405295

Weiyi Lu (2):
  arm64: dts: mediatek: Add mt8192 clock controllers
  arm64: dts: mediatek: Correct UART0 bus clock of MT8192

 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 165 ++-
 1 file changed, 164 insertions(+), 1 deletion(-)


[PATCH 1/2] arm64: dts: mediatek: Add mt8192 clock controllers

2020-12-22 Thread Weiyi Lu
Add clock controller nodes for SoC mt8192

Signed-off-by: Weiyi Lu 
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 163 +++
 1 file changed, 163 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index e12e024..92dcfbd 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -5,6 +5,7 @@
  */
 
 /dts-v1/;
+#include 
 #include 
 #include 
 #include 
@@ -213,6 +214,24 @@
};
};
 
+   topckgen: syscon@1000 {
+   compatible = "mediatek,mt8192-topckgen", "syscon";
+   reg = <0 0x1000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   infracfg: syscon@10001000 {
+   compatible = "mediatek,mt8192-infracfg", "syscon";
+   reg = <0 0x10001000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   pericfg: syscon@10003000 {
+   compatible = "mediatek,mt8192-pericfg", "syscon";
+   reg = <0 0x10003000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
pio: pinctrl@10005000 {
compatible = "mediatek,mt8192-pinctrl";
reg = <0 0x10005000 0 0x1000>,
@@ -238,6 +257,12 @@
#interrupt-cells = <2>;
};
 
+   apmixedsys: syscon@1000c000 {
+   compatible = "mediatek,mt8192-apmixedsys", "syscon";
+   reg = <0 0x1000c000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
systimer: timer@10017000 {
compatible = "mediatek,mt8192-timer",
 "mediatek,mt6765-timer";
@@ -247,6 +272,12 @@
clock-names = "clk13m";
};
 
+   scp_adsp: syscon@1072 {
+   compatible = "mediatek,mt8192-scp_adsp", "syscon";
+   reg = <0 0x1072 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
uart0: serial@11002000 {
compatible = "mediatek,mt8192-uart",
 "mediatek,mt6577-uart";
@@ -267,6 +298,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_c: syscon@11007000 {
+   compatible = "mediatek,mt8192-imp_iic_wrap_c", "syscon";
+   reg = <0 0x11007000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
spi0: spi@1100a000 {
compatible = "mediatek,mt8192-spi",
 "mediatek,mt6765-spi";
@@ -379,6 +416,12 @@
status = "disabled";
};
 
+   audsys: syscon@1121 {
+   compatible = "mediatek,mt8192-audsys", "syscon";
+   reg = <0 0x1121 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
i2c3: i2c3@11cb {
compatible = "mediatek,mt8192-i2c";
reg = <0 0x11cb 0 0x1000>,
@@ -392,6 +435,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_e: syscon@11cb1000 {
+   compatible = "mediatek,mt8192-imp_iic_wrap_e", "syscon";
+   reg = <0 0x11cb1000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
i2c7: i2c7@11d0 {
compatible = "mediatek,mt8192-i2c";
reg = <0 0x11d0 0 0x1000>,
@@ -431,6 +480,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_s: syscon@11d03000 {
+   compatible = "mediatek,mt8192-imp_iic_wrap_s", "syscon";
+   reg = <0 0x11d03000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
i2c1: i2c1@11d2 {
compatible = "mediatek,mt8192-i2c";
reg = <0 0x11d2 0 0x1000>,
@@ -470,6 +525,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_ws: syscon@11d23000 {
+  

[PATCH v6 10/22] clk: mediatek: Add MT8192 basic clocks support

2020-12-22 Thread Weiyi Lu
Add MT8192 basic clock providers, include topckgen, apmixedsys,
infracfg and pericfg.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |8 +
 drivers/clk/mediatek/Makefile |1 +
 drivers/clk/mediatek/clk-mt8192.c | 1326 +
 drivers/clk/mediatek/clk-mux.h|   15 +
 4 files changed, 1350 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index ce84750..f628efd 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -489,6 +489,14 @@ config COMMON_CLK_MT8183_VENCSYS
help
  This driver supports MediaTek MT8183 vencsys clocks.
 
+config COMMON_CLK_MT8192
+   bool "Clock driver for MediaTek MT8192"
+   depends on ARM64 || COMPILE_TEST
+   select COMMON_CLK_MEDIATEK
+   default ARM64
+   help
+ This driver supports MediaTek MT8192 basic clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 3b0c2be..fcde421 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -67,5 +67,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_MFGCFG) += clk-mt8183-mfgcfg.o
 obj-$(CONFIG_COMMON_CLK_MT8183_MMSYS) += clk-mt8183-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
+obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192.c 
b/drivers/clk/mediatek/clk-mt8192.c
new file mode 100644
index 000..bf6a208
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192.c
@@ -0,0 +1,1326 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-mux.h"
+#include "clk-gate.h"
+
+#include 
+
+static DEFINE_SPINLOCK(mt8192_clk_lock);
+
+static const struct mtk_fixed_clk top_fixed_clks[] = {
+   FIXED_CLK(CLK_TOP_ULPOSC, "ulposc", NULL, 26000),
+};
+
+static const struct mtk_fixed_factor top_early_divs[] = {
+   FACTOR(CLK_TOP_CSW_F26M_D2, "csw_f26m_d2", "clk26m", 1, 2),
+};
+
+static const struct mtk_fixed_factor top_divs[] = {
+   FACTOR(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll", 1, 3),
+   FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D4_D2, "mainpll_d4_d2", "mainpll_d4", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D4_D4, "mainpll_d4_d4", "mainpll_d4", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D4_D8, "mainpll_d4_d8", "mainpll_d4", 1, 8),
+   FACTOR(CLK_TOP_MAINPLL_D4_D16, "mainpll_d4_d16", "mainpll_d4", 1, 16),
+   FACTOR(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll", 1, 5),
+   FACTOR(CLK_TOP_MAINPLL_D5_D2, "mainpll_d5_d2", "mainpll_d5", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D5_D4, "mainpll_d5_d4", "mainpll_d5", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D5_D8, "mainpll_d5_d8", "mainpll_d5", 1, 8),
+   FACTOR(CLK_TOP_MAINPLL_D6, "mainpll_d6", "mainpll", 1, 6),
+   FACTOR(CLK_TOP_MAINPLL_D6_D2, "mainpll_d6_d2", "mainpll_d6", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D6_D4, "mainpll_d6_d4", "mainpll_d6", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll", 1, 7),
+   FACTOR(CLK_TOP_MAINPLL_D7_D2, "mainpll_d7_d2", "mainpll_d7", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D7_D4, "mainpll_d7_d4", "mainpll_d7", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D7_D8, "mainpll_d7_d8", "mainpll_d7", 1, 8),
+   FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3),
+   FACTOR(CLK_TOP_UNIVPLL_D4, "univpll_d4", "univpll", 1, 4),
+   FACTOR(CLK_TOP_UNIVPLL_D4_D2, "univpll_d4_d2", "univpll_d4", 1, 2),
+   FACTOR(CLK_TOP_UNIVPLL_D4_D4, "univpll_d4_d4", "univpll_d4", 1, 4),
+   FACTOR(CLK_TOP_UNIVPLL_D4_D8, "univpll_d4_d8", "univpll_d4", 1, 8),
+   FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5),
+   FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll_d5", 1, 2),
+   FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll_d5", 1, 4),
+   FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d

[PATCH v6 06/22] clk: mediatek: Add dt-bindings of MT8192 clocks

2020-12-22 Thread Weiyi Lu
Add MT8192 clock dt-bindings, include topckgen, apmixedsys,
infracfg, pericfg and subsystem clocks.

Signed-off-by: Weiyi Lu 
---
 include/dt-bindings/clock/mt8192-clk.h | 585 +
 1 file changed, 585 insertions(+)
 create mode 100644 include/dt-bindings/clock/mt8192-clk.h

diff --git a/include/dt-bindings/clock/mt8192-clk.h 
b/include/dt-bindings/clock/mt8192-clk.h
new file mode 100644
index 000..ece5b4c
--- /dev/null
+++ b/include/dt-bindings/clock/mt8192-clk.h
@@ -0,0 +1,585 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2020 MediaTek Inc.
+ * Author: Weiyi Lu 
+ */
+
+#ifndef _DT_BINDINGS_CLK_MT8192_H
+#define _DT_BINDINGS_CLK_MT8192_H
+
+/* TOPCKGEN */
+
+#define CLK_TOP_AXI_SEL0
+#define CLK_TOP_SPM_SEL1
+#define CLK_TOP_SCP_SEL2
+#define CLK_TOP_BUS_AXIMEM_SEL 3
+#define CLK_TOP_DISP_SEL   4
+#define CLK_TOP_MDP_SEL5
+#define CLK_TOP_IMG1_SEL   6
+#define CLK_TOP_IMG2_SEL   7
+#define CLK_TOP_IPE_SEL8
+#define CLK_TOP_DPE_SEL9
+#define CLK_TOP_CAM_SEL10
+#define CLK_TOP_CCU_SEL11
+#define CLK_TOP_DSP7_SEL   12
+#define CLK_TOP_MFG_REF_SEL13
+#define CLK_TOP_MFG_PLL_SEL14
+#define CLK_TOP_CAMTG_SEL  15
+#define CLK_TOP_CAMTG2_SEL 16
+#define CLK_TOP_CAMTG3_SEL 17
+#define CLK_TOP_CAMTG4_SEL 18
+#define CLK_TOP_CAMTG5_SEL 19
+#define CLK_TOP_CAMTG6_SEL 20
+#define CLK_TOP_UART_SEL   21
+#define CLK_TOP_SPI_SEL22
+#define CLK_TOP_MSDC50_0_H_SEL 23
+#define CLK_TOP_MSDC50_0_SEL   24
+#define CLK_TOP_MSDC30_1_SEL   25
+#define CLK_TOP_MSDC30_2_SEL   26
+#define CLK_TOP_AUDIO_SEL  27
+#define CLK_TOP_AUD_INTBUS_SEL 28
+#define CLK_TOP_PWRAP_ULPOSC_SEL   29
+#define CLK_TOP_ATB_SEL30
+#define CLK_TOP_DPI_SEL31
+#define CLK_TOP_SCAM_SEL   32
+#define CLK_TOP_DISP_PWM_SEL   33
+#define CLK_TOP_USB_TOP_SEL34
+#define CLK_TOP_SSUSB_XHCI_SEL 35
+#define CLK_TOP_I2C_SEL36
+#define CLK_TOP_SENINF_SEL 37
+#define CLK_TOP_SENINF1_SEL38
+#define CLK_TOP_SENINF2_SEL39
+#define CLK_TOP_SENINF3_SEL40
+#define CLK_TOP_TL_SEL 41
+#define CLK_TOP_DXCC_SEL   42
+#define CLK_TOP_AUD_ENGEN1_SEL 43
+#define CLK_TOP_AUD_ENGEN2_SEL 44
+#define CLK_TOP_AES_UFSFDE_SEL 45
+#define CLK_TOP_UFS_SEL46
+#define CLK_TOP_AUD_1_SEL  47
+#define CLK_TOP_AUD_2_SEL  48
+#define CLK_TOP_ADSP_SEL   49
+#define CLK_TOP_DPMAIF_MAIN_SEL50
+#define CLK_TOP_VENC_SEL   51
+#define CLK_TOP_VDEC_SEL   52
+#define CLK_TOP_CAMTM_SEL  53
+#define CLK_TOP_PWM_SEL54
+#define CLK_TOP_AUDIO_H_SEL55
+#define CLK_TOP_SPMI_MST_SEL   56
+#define CLK_TOP_AES_MSDCFDE_SEL57
+#define CLK_TOP_SFLASH_SEL 58
+#define CLK_TOP_APLL_I2S0_M_SEL59
+#define CLK_TOP_APLL_I2S1_M_SEL60
+#define CLK_TOP_APLL_I2S2_M_SEL61
+#define CLK_TOP_APLL_I2S3_M_SEL62
+#define CLK_TOP_APLL_I2S4_M_SEL63
+#define CLK_TOP_APLL_I2S5_M_SEL64
+#define CLK_TOP_APLL_I2S6_M_SEL65
+#define CLK_TOP_APLL_I2S7_M_SEL66
+#define CLK_TOP_APLL_I2S8_M_SEL67
+#define CLK_TOP_APLL_I2S9_M_SEL68
+#define CLK_TOP_MAINPLL_D3 69
+#define CLK_TOP_MAINPLL_D4 70
+#define CLK_TOP_MAINPLL_D4_D2  71
+#define CLK_TOP_MAINPLL_D4_D4  72
+#define CLK_TOP_MAINPLL_D4_D8  73
+#define CLK_TOP_MAINPLL_D4_D16 74
+#define CLK_TOP_MAINPLL_D5 75
+#define CLK_TOP_MAINPLL_D5_D2  76
+#define CLK_TOP_MAINPLL_D5_D4  77
+#define CLK_TOP_MAINPLL_D5_D8  78
+#define CLK_TOP_MAINPLL_D6 79
+#define CLK_TOP_MAINPLL_D6_D2  80
+#define CLK_TOP_MAINPLL_D6_D4  81
+#define CLK_TOP_MAINPLL_D7 82
+#define CLK_TOP_MAINPLL_D7_D2  83
+#define CLK_TOP_MAINPLL_D7_D4  84
+#define CLK_TOP_MAINPLL_D7_D8  85
+#define CLK_TOP_UNIVPLL_D3 86
+#define CLK_TOP_UNIVPLL_D4 87
+#define CLK_TOP_UNIVPLL_D4_D2  88
+#define CLK_TOP_UNIVPLL_D4_D4  89
+#define CLK_TOP_UNIVPLL_D4_D8  90
+#define CLK_TOP_UNIVPLL_D5 91
+#define CLK_TOP_UNIVPLL_D5_D2  92
+#define CLK_TOP_UNIVPLL_D5_D4  93
+#define CLK_TOP_UNIVPLL_D5_D8

[PATCH v6 12/22] clk: mediatek: Add MT8192 camsys clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 camsys and camsys raw clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |   6 ++
 drivers/clk/mediatek/Makefile |   1 +
 drivers/clk/mediatek/clk-mt8192-cam.c | 107 ++
 3 files changed, 114 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-cam.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 1a8b0c1..a75b7ec 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -503,6 +503,12 @@ config COMMON_CLK_MT8192_AUDSYS
help
  This driver supports MediaTek MT8192 audsys clocks.
 
+config COMMON_CLK_MT8192_CAMSYS
+   bool "Clock driver for MediaTek MT8192 camsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 camsys and camsys_raw clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 1d0f2e8..94bf7a0 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -69,5 +69,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
+obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-cam.c 
b/drivers/clk/mediatek/clk-mt8192-cam.c
new file mode 100644
index 000..549ea8e
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-cam.c
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs cam_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_CAM(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate cam_clks[] = {
+   GATE_CAM(CLK_CAM_LARB13, "cam_larb13", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_DFP_VAD, "cam_dfp_vad", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_LARB14, "cam_larb14", "cam_sel", 2),
+   GATE_CAM(CLK_CAM_CAM, "cam_cam", "cam_sel", 6),
+   GATE_CAM(CLK_CAM_CAMTG, "cam_camtg", "cam_sel", 7),
+   GATE_CAM(CLK_CAM_SENINF, "cam_seninf", "cam_sel", 8),
+   GATE_CAM(CLK_CAM_CAMSV0, "cam_camsv0", "cam_sel", 9),
+   GATE_CAM(CLK_CAM_CAMSV1, "cam_camsv1", "cam_sel", 10),
+   GATE_CAM(CLK_CAM_CAMSV2, "cam_camsv2", "cam_sel", 11),
+   GATE_CAM(CLK_CAM_CAMSV3, "cam_camsv3", "cam_sel", 12),
+   GATE_CAM(CLK_CAM_CCU0, "cam_ccu0", "cam_sel", 13),
+   GATE_CAM(CLK_CAM_CCU1, "cam_ccu1", "cam_sel", 14),
+   GATE_CAM(CLK_CAM_MRAW0, "cam_mraw0", "cam_sel", 15),
+   GATE_CAM(CLK_CAM_FAKE_ENG, "cam_fake_eng", "cam_sel", 17),
+   GATE_CAM(CLK_CAM_CCU_GALS, "cam_ccu_gals", "cam_sel", 18),
+   GATE_CAM(CLK_CAM_CAM2MM_GALS, "cam2mm_gals", "cam_sel", 19),
+};
+
+static const struct mtk_gate cam_rawa_clks[] = {
+   GATE_CAM(CLK_CAM_RAWA_LARBX, "cam_rawa_larbx", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_RAWA_CAM, "cam_rawa_cam", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_RAWA_CAMTG, "cam_rawa_camtg", "cam_sel", 2),
+};
+
+static const struct mtk_gate cam_rawb_clks[] = {
+   GATE_CAM(CLK_CAM_RAWB_LARBX, "cam_rawb_larbx", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_RAWB_CAM, "cam_rawb_cam", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_RAWB_CAMTG, "cam_rawb_camtg", "cam_sel", 2),
+};
+
+static const struct mtk_gate cam_rawc_clks[] = {
+   GATE_CAM(CLK_CAM_RAWC_LARBX, "cam_rawc_larbx", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_RAWC_CAM, "cam_rawc_cam", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_RAWC_CAMTG, "cam_rawc_camtg", "cam_sel", 2),
+};
+
+static const struct mtk_clk_desc cam_desc = {
+   .clks = cam_clks,
+   .num_clks = ARRAY_SIZE(cam_clks),
+};
+
+static const struct mtk_clk_desc cam_rawa_desc = {
+   .clks = cam_rawa_clks,
+   .num_clks = ARRAY_SIZE(cam_rawa_clks),
+};
+
+static const struct mtk_clk_desc cam_rawb_desc = {
+   .clks = cam_rawb_clks,
+   .num_cl

[PATCH v6 02/22] dt-bindings: ARM: Mediatek: Add new document bindings of mdpsys controller

2020-12-22 Thread Weiyi Lu
This patch adds the new binding documentation of mdpsys controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,mdpsys.yaml | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml
new file mode 100644
index 000..831acdc
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mdpsys.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MDPSYS Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek mdpsys controller provides functional configurations and clocks 
to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-mdpsys
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+mdpsys: syscon@1f00 {
+compatible = "mediatek,mt8192-mdpsys", "syscon";
+reg = <0 0x1f00 0 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty



[PATCH v6 16/22] clk: mediatek: Add MT8192 mdpsys clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 mdpsys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 +++
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-mdp.c | 82 +++
 3 files changed, 89 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-mdp.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index c6bc618..a0a2efa9 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -527,6 +527,12 @@ config COMMON_CLK_MT8192_IPESYS
help
  This driver supports MediaTek MT8192 ipesys clocks.
 
+config COMMON_CLK_MT8192_MDPSYS
+   bool "Clock driver for MediaTek MT8192 mdpsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 mdpsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 33dc974..7b258cb 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -73,5 +73,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-mdp.c 
b/drivers/clk/mediatek/clk-mt8192-mdp.c
new file mode 100644
index 000..3109104
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-mdp.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs mdp0_cg_regs = {
+   .set_ofs = 0x104,
+   .clr_ofs = 0x108,
+   .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs mdp1_cg_regs = {
+   .set_ofs = 0x124,
+   .clr_ofs = 0x128,
+   .sta_ofs = 0x120,
+};
+
+#define GATE_MDP0(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+#define GATE_MDP1(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate mdp_clks[] = {
+   /* MDP0 */
+   GATE_MDP0(CLK_MDP_RDMA0, "mdp_mdp_rdma0", "mdp_sel", 0),
+   GATE_MDP0(CLK_MDP_TDSHP0, "mdp_mdp_tdshp0", "mdp_sel", 1),
+   GATE_MDP0(CLK_MDP_IMG_DL_ASYNC0, "mdp_img_dl_async0", "mdp_sel", 2),
+   GATE_MDP0(CLK_MDP_IMG_DL_ASYNC1, "mdp_img_dl_async1", "mdp_sel", 3),
+   GATE_MDP0(CLK_MDP_RDMA1, "mdp_mdp_rdma1", "mdp_sel", 4),
+   GATE_MDP0(CLK_MDP_TDSHP1, "mdp_mdp_tdshp1", "mdp_sel", 5),
+   GATE_MDP0(CLK_MDP_SMI0, "mdp_smi0", "mdp_sel", 6),
+   GATE_MDP0(CLK_MDP_APB_BUS, "mdp_apb_bus", "mdp_sel", 7),
+   GATE_MDP0(CLK_MDP_WROT0, "mdp_mdp_wrot0", "mdp_sel", 8),
+   GATE_MDP0(CLK_MDP_RSZ0, "mdp_mdp_rsz0", "mdp_sel", 9),
+   GATE_MDP0(CLK_MDP_HDR0, "mdp_mdp_hdr0", "mdp_sel", 10),
+   GATE_MDP0(CLK_MDP_MUTEX0, "mdp_mdp_mutex0", "mdp_sel", 11),
+   GATE_MDP0(CLK_MDP_WROT1, "mdp_mdp_wrot1", "mdp_sel", 12),
+   GATE_MDP0(CLK_MDP_RSZ1, "mdp_mdp_rsz1", "mdp_sel", 13),
+   GATE_MDP0(CLK_MDP_HDR1, "mdp_mdp_hdr1", "mdp_sel", 14),
+   GATE_MDP0(CLK_MDP_FAKE_ENG0, "mdp_mdp_fake_eng0", "mdp_sel", 15),
+   GATE_MDP0(CLK_MDP_AAL0, "mdp_mdp_aal0", "mdp_sel", 16),
+   GATE_MDP0(CLK_MDP_AAL1, "mdp_mdp_aal1", "mdp_sel", 17),
+   GATE_MDP0(CLK_MDP_COLOR0, "mdp_mdp_color0", "mdp_sel", 18),
+   GATE_MDP0(CLK_MDP_COLOR1, "mdp_mdp_color1", "mdp_sel", 19),
+   /* MDP1 */
+   GATE_MDP1(CLK_MDP_IMG_DL_RELAY0_ASYNC0, "mdp_img_dl_relay0_async0", 
"mdp_sel", 0),
+   GATE_MDP1(CLK_MDP_IMG_DL_RELAY1_ASYNC1, "mdp_img_dl_relay1_async1", 
"mdp_sel", 8),
+};
+
+static const struct mtk_clk_desc mdp_desc = {
+   .clks = mdp_clks,
+   .num_clks = ARRAY_SIZE(mdp_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_mdp[] = {
+   {
+   .compatible = "mediatek,mt8192-mdpsys",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_mdp_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-mdp",
+   .of_match_table = of_match_clk_mt8192_mdp,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_mdp_drv);
-- 
1.8.1.1.dirty



[PATCH v6 20/22] clk: mediatek: Add MT8192 scp adsp clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 scp adsp clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-scp_adsp.c | 50 ++
 3 files changed, 57 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-scp_adsp.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index aba662f..1009e1f 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -551,6 +551,12 @@ config COMMON_CLK_MT8192_MSDC
help
  This driver supports MediaTek MT8192 msdc and msdc_top clocks.
 
+config COMMON_CLK_MT8192_SCP_ADSP
+   bool "Clock driver for MediaTek MT8192 scp_adsp"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 scp_adsp clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 8e4e343..a336fe7 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -77,5 +77,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
+obj-$(CONFIG_COMMON_CLK_MT8192_SCP_ADSP) += clk-mt8192-scp_adsp.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-scp_adsp.c 
b/drivers/clk/mediatek/clk-mt8192-scp_adsp.c
new file mode 100644
index 000..4bc2403
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-scp_adsp.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs scp_adsp_cg_regs = {
+   .set_ofs = 0x180,
+   .clr_ofs = 0x180,
+   .sta_ofs = 0x180,
+};
+
+#define GATE_SCP_ADSP(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _adsp_cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+static const struct mtk_gate scp_adsp_clks[] = {
+   GATE_SCP_ADSP(CLK_SCP_ADSP_AUDIODSP, "scp_adsp_audiodsp", "adsp_sel", 
0),
+};
+
+static const struct mtk_clk_desc scp_adsp_desc = {
+   .clks = scp_adsp_clks,
+   .num_clks = ARRAY_SIZE(scp_adsp_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_scp_adsp[] = {
+   {
+   .compatible = "mediatek,mt8192-scp_adsp",
+   .data = _adsp_desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_scp_adsp_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-scp_adsp",
+   .of_match_table = of_match_clk_mt8192_scp_adsp,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_scp_adsp_drv);
-- 
1.8.1.1.dirty



[PATCH v6 18/22] clk: mediatek: Add MT8192 mmsys clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 mmsys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig |   6 ++
 drivers/clk/mediatek/Makefile|   1 +
 drivers/clk/mediatek/clk-mt8192-mm.c | 108 +++
 3 files changed, 115 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-mm.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 3db8670..bc92611 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -539,6 +539,12 @@ config COMMON_CLK_MT8192_MFGCFG
help
  This driver supports MediaTek MT8192 mfgcfg clocks.
 
+config COMMON_CLK_MT8192_MMSYS
+   bool "Clock driver for MediaTek MT8192 mmsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 mmsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 024841a..838bb01 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -75,5 +75,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += 
clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-mm.c 
b/drivers/clk/mediatek/clk-mt8192-mm.c
new file mode 100644
index 000..dfdfb21
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-mm.c
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs mm0_cg_regs = {
+   .set_ofs = 0x104,
+   .clr_ofs = 0x108,
+   .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs mm1_cg_regs = {
+   .set_ofs = 0x114,
+   .clr_ofs = 0x118,
+   .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs mm2_cg_regs = {
+   .set_ofs = 0x1a4,
+   .clr_ofs = 0x1a8,
+   .sta_ofs = 0x1a0,
+};
+
+#define GATE_MM0(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+#define GATE_MM1(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+#define GATE_MM2(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate mm_clks[] = {
+   /* MM0 */
+   GATE_MM0(CLK_MM_DISP_MUTEX0, "mm_disp_mutex0", "disp_sel", 0),
+   GATE_MM0(CLK_MM_DISP_CONFIG, "mm_disp_config", "disp_sel", 1),
+   GATE_MM0(CLK_MM_DISP_OVL0, "mm_disp_ovl0", "disp_sel", 2),
+   GATE_MM0(CLK_MM_DISP_RDMA0, "mm_disp_rdma0", "disp_sel", 3),
+   GATE_MM0(CLK_MM_DISP_OVL0_2L, "mm_disp_ovl0_2l", "disp_sel", 4),
+   GATE_MM0(CLK_MM_DISP_WDMA0, "mm_disp_wdma0", "disp_sel", 5),
+   GATE_MM0(CLK_MM_DISP_UFBC_WDMA0, "mm_disp_ufbc_wdma0", "disp_sel", 6),
+   GATE_MM0(CLK_MM_DISP_RSZ0, "mm_disp_rsz0", "disp_sel", 7),
+   GATE_MM0(CLK_MM_DISP_AAL0, "mm_disp_aal0", "disp_sel", 8),
+   GATE_MM0(CLK_MM_DISP_CCORR0, "mm_disp_ccorr0", "disp_sel", 9),
+   GATE_MM0(CLK_MM_DISP_DITHER0, "mm_disp_dither0", "disp_sel", 10),
+   GATE_MM0(CLK_MM_SMI_INFRA, "mm_smi_infra", "disp_sel", 11),
+   GATE_MM0(CLK_MM_DISP_GAMMA0, "mm_disp_gamma0", "disp_sel", 12),
+   GATE_MM0(CLK_MM_DISP_POSTMASK0, "mm_disp_postmask0", "disp_sel", 13),
+   GATE_MM0(CLK_MM_DISP_DSC_WRAP0, "mm_disp_dsc_wrap0", "disp_sel", 14),
+   GATE_MM0(CLK_MM_DSI0, "mm_dsi0", "disp_sel", 15),
+   GATE_MM0(CLK_MM_DISP_COLOR0, "mm_disp_color0", "disp_sel", 16),
+   GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "disp_sel", 17),
+   GATE_MM0(CLK_MM_DISP_FAKE_ENG0, "mm_disp_fake_eng0", "disp_sel", 18),
+   GATE_MM0(CLK_MM_DISP_FAKE_ENG1, "mm_disp_fake_eng1", "disp_sel", 19),
+   GATE_MM0(CLK_MM_MDP_TDSHP4, "mm_mdp_tdshp4", "disp_sel", 20),
+   GATE_MM0(CLK_MM_MDP_RSZ4, "mm_mdp_rsz4", "disp_sel", 21),
+   GATE_MM0(CLK_MM_MDP_AAL4, "mm_mdp_aal4", "disp_sel", 22),
+   GATE_MM0(CLK_MM_MDP_HD

[PATCH v6 04/22] dt-bindings: ARM: Mediatek: Add new document bindings of scp adsp controller

2020-12-22 Thread Weiyi Lu
This patch adds the new binding documentation of scp adsp controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,scp-adsp.yaml   | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml
new file mode 100644
index 000..24df35d
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,scp-adsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek SCP ADSP Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek scp adsp controller provides functional configurations and 
clocks to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-scp_adsp
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+scp_adsp: syscon@1072 {
+compatible = "mediatek,mt8192-scp_adsp", "syscon";
+reg = <0x1072 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty



[PATCH v6 05/22] dt-bindings: ARM: Mediatek: Document bindings of MT8192 clock controllers

2020-12-22 Thread Weiyi Lu
This patch adds the binding documentation of topckgen, apmixedsys,
infracfg, pericfg and subsystem clocks for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,apmixedsys.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,audsys.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,camsys.txt  | 22 ++
 .../bindings/arm/mediatek/mediatek,imgsys.txt  |  2 ++
 .../bindings/arm/mediatek/mediatek,infracfg.txt|  1 +
 .../bindings/arm/mediatek/mediatek,ipesys.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,mfgcfg.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,mmsys.txt   |  1 +
 .../bindings/arm/mediatek/mediatek,pericfg.yaml|  1 +
 .../bindings/arm/mediatek/mediatek,topckgen.txt|  1 +
 .../bindings/arm/mediatek/mediatek,vdecsys.txt |  8 
 .../bindings/arm/mediatek/mediatek,vencsys.txt |  1 +
 12 files changed, 41 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
index ea827e87..551c307 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
@@ -18,6 +18,7 @@ Required Properties:
- "mediatek,mt8167-apmixedsys", "syscon"
- "mediatek,mt8173-apmixedsys"
- "mediatek,mt8183-apmixedsys", "syscon"
+   - "mediatek,mt8192-apmixedsys", "syscon"
- "mediatek,mt8516-apmixedsys"
 - #clock-cells: Must be 1
 
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
index b32d374..699776b 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
@@ -13,6 +13,7 @@ Required Properties:
- "mediatek,mt7623-audsys", "mediatek,mt2701-audsys", "syscon"
- "mediatek,mt8167-audiosys", "syscon"
- "mediatek,mt8183-audiosys", "syscon"
+   - "mediatek,mt8192-audsys", "syscon"
- "mediatek,mt8516-audsys", "syscon"
 - #clock-cells: Must be 1
 
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
index a0ce820..7d0b14e 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
@@ -9,6 +9,10 @@ Required Properties:
- "mediatek,mt6765-camsys", "syscon"
- "mediatek,mt6779-camsys", "syscon"
- "mediatek,mt8183-camsys", "syscon"
+   - "mediatek,mt8192-camsys", "syscon"
+   - "mediatek,mt8192-camsys_rawa", "syscon"
+   - "mediatek,mt8192-camsys_rawb", "syscon"
+   - "mediatek,mt8192-camsys_rawc", "syscon"
 - #clock-cells: Must be 1
 
 The camsys controller uses the common clk binding from
@@ -22,3 +26,21 @@ camsys: camsys@1a00  {
reg = <0 0x1a00  0 0x1000>;
#clock-cells = <1>;
 };
+
+camsys_rawa: syscon@1a04f000 {
+   compatible = "mediatek,mt8192-camsys_rawa", "syscon";
+   reg = <0 0x1a04f000 0 0x1000>;
+   #clock-cells = <1>;
+};
+
+camsys_rawb: syscon@1a06f000 {
+   compatible = "mediatek,mt8192-camsys_rawb", "syscon";
+   reg = <0 0x1a06f000 0 0x1000>;
+   #clock-cells = <1>;
+};
+
+camsys_rawc: syscon@1a08f000 {
+   compatible = "mediatek,mt8192-camsys_rawc", "syscon";
+   reg = <0 0x1a08f000 0 0x1000>;
+   #clock-cells = <1>;
+};
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
index dce4c924..b9e599e 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
@@ -15,6 +15,8 @@ Required Properties:
- "mediatek,mt8167-imgsys", "syscon"
- "mediatek,mt8173-imgsys", "syscon"
- "mediatek,mt8183-imgsys", "syscon"
+   - "mediatek,mt8192-imgsys", "syscon"
+   - "mediatek,mt8192-imgsys2", "syscon"
 - #clock-cells: Must be 1
 
 The imgsys controller uses the common clk binding from
diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
index e

[PATCH v6 08/22] clk: mediatek: Add configurable enable control to mtk_pll_data

2020-12-22 Thread Weiyi Lu
In all MediaTek PLL design, bit0 of CON0 register is always
the enable bit.
However, there's a special case of usbpll on MT8192.
The enable bit of usbpll is moved to bit2 of other register.
Add configurable en_reg and pll_en_bit for enable control or
default 0 where pll data are static variables.
Hence, CON0_BASE_EN could also be removed.
And there might have another special case on other chips,
the enable bit is still on CON0 register but not at bit0.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mtk.h |  2 ++
 drivers/clk/mediatek/clk-pll.c | 15 ++-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index c3d6756..c580663 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -233,6 +233,8 @@ struct mtk_pll_data {
uint32_t pcw_chg_reg;
const struct mtk_pll_div_table *div_table;
const char *parent_name;
+   uint32_t en_reg;
+   uint8_t pll_en_bit; /* Assume 0, indicates BIT(0) by default */
 };
 
 void mtk_clk_register_plls(struct device_node *node,
diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index 11ed5d1..7fb001a 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -44,6 +44,7 @@ struct mtk_clk_pll {
void __iomem*tuner_en_addr;
void __iomem*pcw_addr;
void __iomem*pcw_chg_addr;
+   void __iomem*en_addr;
const struct mtk_pll_data *data;
 };
 
@@ -56,7 +57,7 @@ static int mtk_pll_is_prepared(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
-   return (readl(pll->base_addr + REG_CON0) & CON0_BASE_EN) != 0;
+   return (readl(pll->en_addr) & BIT(pll->data->pll_en_bit)) != 0;
 }
 
 static unsigned long __mtk_pll_recalc_rate(struct mtk_clk_pll *pll, u32 fin,
@@ -248,8 +249,8 @@ static int mtk_pll_prepare(struct clk_hw *hw)
writel(r, pll->pwr_addr);
udelay(1);
 
-   r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN;
-   writel(r, pll->base_addr + REG_CON0);
+   r = readl(pll->en_addr) | BIT(pll->data->pll_en_bit);
+   writel(r, pll->en_addr);
 
div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
if (div_en_mask) {
@@ -290,8 +291,8 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
writel(r, pll->base_addr + REG_CON0);
}
 
-   r = readl(pll->base_addr + REG_CON0) & ~CON0_BASE_EN;
-   writel(r, pll->base_addr + REG_CON0);
+   r = readl(pll->en_addr) & ~BIT(pll->data->pll_en_bit);
+   writel(r, pll->en_addr);
 
r = readl(pll->pwr_addr) | CON0_ISO_EN;
writel(r, pll->pwr_addr);
@@ -333,6 +334,10 @@ static struct clk *mtk_clk_register_pll(const struct 
mtk_pll_data *data,
pll->tuner_addr = base + data->tuner_reg;
if (data->tuner_en_reg)
pll->tuner_en_addr = base + data->tuner_en_reg;
+   if (data->en_reg)
+   pll->en_addr = base + data->en_reg;
+   else
+   pll->en_addr = pll->base_addr + REG_CON0;
pll->hw.init = 
pll->data = data;
 
-- 
1.8.1.1.dirty



[PATCH v6 00/22] Mediatek MT8192 clock support

2020-12-22 Thread Weiyi Lu
This series is based on v5.10-rc1.

change since v5:
- remove unused clocks by rolling Tinghan's patches[1][2] into series
[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=398781
[2] https://patchwork.kernel.org/project/linux-mediatek/list/?series=405143
- remove dts related patches from series

change since v4:
- merge some subsystem into same driver
- add a generic probe function to reduce duplicated code

changes since v3:
- add critical clocks
- split large patches into small ones

changes since v2:
- update and split dt-binding documents by functionalities
- add error checking in probe() function
- fix incorrect clock relation and add critical clocks
- update license identifier and minor fix of coding style

changes since v1:
- fix asymmetrical control of PLL
- have en_mask used as divider enable mask on all MediaTek SoC

Weiyi Lu (22):
  dt-bindings: ARM: Mediatek: Add new document bindings of imp i2c
wrapper controller
  dt-bindings: ARM: Mediatek: Add new document bindings of mdpsys
controller
  dt-bindings: ARM: Mediatek: Add new document bindings of msdc
controller
  dt-bindings: ARM: Mediatek: Add new document bindings of scp adsp
controller
  dt-bindings: ARM: Mediatek: Document bindings of MT8192 clock
controllers
  clk: mediatek: Add dt-bindings of MT8192 clocks
  clk: mediatek: Fix asymmetrical PLL enable and disable control
  clk: mediatek: Add configurable enable control to mtk_pll_data
  clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers
  clk: mediatek: Add MT8192 basic clocks support
  clk: mediatek: Add MT8192 audio clock support
  clk: mediatek: Add MT8192 camsys clock support
  clk: mediatek: Add MT8192 imgsys clock support
  clk: mediatek: Add MT8192 imp i2c wrapper clock support
  clk: mediatek: Add MT8192 ipesys clock support
  clk: mediatek: Add MT8192 mdpsys clock support
  clk: mediatek: Add MT8192 mfgcfg clock support
  clk: mediatek: Add MT8192 mmsys clock support
  clk: mediatek: Add MT8192 msdc clock support
  clk: mediatek: Add MT8192 scp adsp clock support
  clk: mediatek: Add MT8192 vdecsys clock support
  clk: mediatek: Add MT8192 vencsys clock support

 .../arm/mediatek/mediatek,apmixedsys.txt  |1 +
 .../bindings/arm/mediatek/mediatek,audsys.txt |1 +
 .../bindings/arm/mediatek/mediatek,camsys.txt |   22 +
 .../bindings/arm/mediatek/mediatek,imgsys.txt |2 +
 .../arm/mediatek/mediatek,imp_iic_wrap.yaml   |   78 +
 .../arm/mediatek/mediatek,infracfg.txt|1 +
 .../bindings/arm/mediatek/mediatek,ipesys.txt |1 +
 .../arm/mediatek/mediatek,mdpsys.yaml |   38 +
 .../bindings/arm/mediatek/mediatek,mfgcfg.txt |1 +
 .../bindings/arm/mediatek/mediatek,mmsys.txt  |1 +
 .../bindings/arm/mediatek/mediatek,msdc.yaml  |   46 +
 .../arm/mediatek/mediatek,pericfg.yaml|1 +
 .../arm/mediatek/mediatek,scp-adsp.yaml   |   38 +
 .../arm/mediatek/mediatek,topckgen.txt|1 +
 .../arm/mediatek/mediatek,vdecsys.txt |8 +
 .../arm/mediatek/mediatek,vencsys.txt |1 +
 drivers/clk/mediatek/Kconfig  |   80 +
 drivers/clk/mediatek/Makefile |   13 +
 drivers/clk/mediatek/clk-mt8192-aud.c |  118 ++
 drivers/clk/mediatek/clk-mt8192-cam.c |  107 ++
 drivers/clk/mediatek/clk-mt8192-img.c |   70 +
 .../clk/mediatek/clk-mt8192-imp_iic_wrap.c|  119 ++
 drivers/clk/mediatek/clk-mt8192-ipe.c |   57 +
 drivers/clk/mediatek/clk-mt8192-mdp.c |   82 +
 drivers/clk/mediatek/clk-mt8192-mfg.c |   50 +
 drivers/clk/mediatek/clk-mt8192-mm.c  |  108 ++
 drivers/clk/mediatek/clk-mt8192-msdc.c|   85 ++
 drivers/clk/mediatek/clk-mt8192-scp_adsp.c|   50 +
 drivers/clk/mediatek/clk-mt8192-vdec.c|   94 ++
 drivers/clk/mediatek/clk-mt8192-venc.c|   53 +
 drivers/clk/mediatek/clk-mt8192.c | 1326 +
 drivers/clk/mediatek/clk-mtk.c|   23 +
 drivers/clk/mediatek/clk-mtk.h|   10 +
 drivers/clk/mediatek/clk-mux.h|   15 +
 drivers/clk/mediatek/clk-pll.c|   31 +-
 include/dt-bindings/clock/mt8192-clk.h|  585 
 36 files changed, 3310 insertions(+), 7 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml
 create mode 100644 drivers/clk/mediatek/clk-mt8192-aud.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-cam.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-img.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-ipe.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192

[PATCH v6 14/22] clk: mediatek: Add MT8192 imp i2c wrapper clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 imp i2c wrapper clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |   6 ++
 drivers/clk/mediatek/Makefile  |   1 +
 drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c | 119 +
 3 files changed, 126 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index eb549f8..8acc7d6 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -515,6 +515,12 @@ config COMMON_CLK_MT8192_IMGSYS
help
  This driver supports MediaTek MT8192 imgsys and imgsys2 clocks.
 
+config COMMON_CLK_MT8192_IMP_IIC_WRAP
+   bool "Clock driver for MediaTek MT8192 imp_iic_wrap"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 imp_iic_wrap clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 91392cb..3798162 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -71,5 +71,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
+obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c 
b/drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
new file mode 100644
index 000..7acb903
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs imp_iic_wrap_cg_regs = {
+   .set_ofs = 0xe08,
+   .clr_ofs = 0xe04,
+   .sta_ofs = 0xe00,
+};
+
+#define GATE_IMP_IIC_WRAP(_id, _name, _parent, _shift) \
+   GATE_MTK_FLAGS(_id, _name, _parent, _iic_wrap_cg_regs, _shift,  
\
+   _clk_gate_ops_setclr, CLK_OPS_PARENT_ENABLE)
+
+static const struct mtk_gate imp_iic_wrap_c_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C10, "imp_iic_wrap_c_i2c10", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C11, "imp_iic_wrap_c_i2c11", 
"infra_i2c0", 1),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C12, "imp_iic_wrap_c_i2c12", 
"infra_i2c0", 2),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C13, "imp_iic_wrap_c_i2c13", 
"infra_i2c0", 3),
+};
+
+static const struct mtk_gate imp_iic_wrap_e_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_E_I2C3, "imp_iic_wrap_e_i2c3", 
"infra_i2c0", 0),
+};
+
+static const struct mtk_gate imp_iic_wrap_n_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C0, "imp_iic_wrap_n_i2c0", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C6, "imp_iic_wrap_n_i2c6", 
"infra_i2c0", 1),
+};
+
+static const struct mtk_gate imp_iic_wrap_s_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C7, "imp_iic_wrap_s_i2c7", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C8, "imp_iic_wrap_s_i2c8", 
"infra_i2c0", 1),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C9, "imp_iic_wrap_s_i2c9", 
"infra_i2c0", 2),
+};
+
+static const struct mtk_gate imp_iic_wrap_w_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_I2C5, "imp_iic_wrap_w_i2c5", 
"infra_i2c0", 0),
+};
+
+static const struct mtk_gate imp_iic_wrap_ws_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C1, "imp_iic_wrap_ws_i2c1", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C2, "imp_iic_wrap_ws_i2c2", 
"infra_i2c0", 1),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C4, "imp_iic_wrap_ws_i2c4", 
"infra_i2c0", 2),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_c_desc = {
+   .clks = imp_iic_wrap_c_clks,
+   .num_clks = ARRAY_SIZE(imp_iic_wrap_c_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_e_desc = {
+   .clks = imp_iic_wrap_e_clks,
+   .num_clks = ARRAY_SIZE(imp_iic_wrap_e_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_n_desc = {
+   .clks = imp_iic_wrap_n_clks,
+   .num_clks = ARRAY_SIZE(imp_iic_wrap_n_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_s_desc = {
+   .clks = imp_iic_w

[PATCH v6 07/22] clk: mediatek: Fix asymmetrical PLL enable and disable control

2020-12-22 Thread Weiyi Lu
In fact, the en_mask is a combination of divider enable mask
and pll enable bit(bit0).
Before this patch, we enabled both divider mask and bit0 in prepare(),
but only cleared the bit0 in unprepare().
In the future, we hope en_mask will only be used as divider enable mask.
The enable register(CON0) will be set in 2 steps:
first is divider mask, and then bit0 during prepare(), and vice versa.
But considering backward compatibility, at this stage we allow en_mask
to be a combination or a pure divider enable mask.
And then we will make en_mask a pure divider enable mask in another
following patch series.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-pll.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index f440f2cd..11ed5d1 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -238,6 +238,7 @@ static int mtk_pll_prepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
+   u32 div_en_mask;
 
r = readl(pll->pwr_addr) | CON0_PWR_ON;
writel(r, pll->pwr_addr);
@@ -247,10 +248,15 @@ static int mtk_pll_prepare(struct clk_hw *hw)
writel(r, pll->pwr_addr);
udelay(1);
 
-   r = readl(pll->base_addr + REG_CON0);
-   r |= pll->data->en_mask;
+   r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN;
writel(r, pll->base_addr + REG_CON0);
 
+   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
+   if (div_en_mask) {
+   r = readl(pll->base_addr + REG_CON0) | div_en_mask;
+   writel(r, pll->base_addr + REG_CON0);
+   }
+
__mtk_pll_tuner_enable(pll);
 
udelay(20);
@@ -268,6 +274,7 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
+   u32 div_en_mask;
 
if (pll->data->flags & HAVE_RST_BAR) {
r = readl(pll->base_addr + REG_CON0);
@@ -277,8 +284,13 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 
__mtk_pll_tuner_disable(pll);
 
-   r = readl(pll->base_addr + REG_CON0);
-   r &= ~CON0_BASE_EN;
+   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
+   if (div_en_mask) {
+   r = readl(pll->base_addr + REG_CON0) & ~div_en_mask;
+   writel(r, pll->base_addr + REG_CON0);
+   }
+
+   r = readl(pll->base_addr + REG_CON0) & ~CON0_BASE_EN;
writel(r, pll->base_addr + REG_CON0);
 
r = readl(pll->pwr_addr) | CON0_ISO_EN;
-- 
1.8.1.1.dirty



[PATCH v6 01/22] dt-bindings: ARM: Mediatek: Add new document bindings of imp i2c wrapper controller

2020-12-22 Thread Weiyi Lu
This patch adds the new binding documentation of imp i2c wrapper controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../arm/mediatek/mediatek,imp_iic_wrap.yaml| 78 ++
 1 file changed, 78 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
new file mode 100644
index 000..5d0cf37
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,imp_iic_wrap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek IMP I2C Wrapper Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek imp i2c wrapper controller provides functional configurations 
and clocks to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-imp_iic_wrap_c
+  - mediatek,mt8192-imp_iic_wrap_e
+  - mediatek,mt8192-imp_iic_wrap_s
+  - mediatek,mt8192-imp_iic_wrap_ws
+  - mediatek,mt8192-imp_iic_wrap_w
+  - mediatek,mt8192-imp_iic_wrap_n
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+imp_iic_wrap_c: syscon@11007000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_c", "syscon";
+reg = <0 0x11007000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_e: syscon@11cb1000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_e", "syscon";
+reg = <0 0x11cb1000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_s: syscon@11d03000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_s", "syscon";
+reg = <0 0x11d03000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_ws: syscon@11d23000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_ws", "syscon";
+reg = <0 0x11d23000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_w: syscon@11e01000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_w", "syscon";
+reg = <0 0x11e01000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_n: syscon@11f02000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_n", "syscon";
+reg = <0 0x11f02000 0 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty



[PATCH v6 22/22] clk: mediatek: Add MT8192 vencsys clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 vencsys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-venc.c | 53 ++
 3 files changed, 60 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-venc.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 633e806..6a6ac41 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -563,6 +563,12 @@ config COMMON_CLK_MT8192_VDECSYS
help
  This driver supports MediaTek MT8192 vdecsys and vdecsys_soc clocks.
 
+config COMMON_CLK_MT8192_VENCSYS
+   bool "Clock driver for MediaTek MT8192 vencsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 vencsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 887dd6b..15bc045 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -79,5 +79,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
 obj-$(CONFIG_COMMON_CLK_MT8192_SCP_ADSP) += clk-mt8192-scp_adsp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_VDECSYS) += clk-mt8192-vdec.o
+obj-$(CONFIG_COMMON_CLK_MT8192_VENCSYS) += clk-mt8192-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-venc.c 
b/drivers/clk/mediatek/clk-mt8192-venc.c
new file mode 100644
index 000..ce220c5
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-venc.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs venc_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_VENC(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate venc_clks[] = {
+   GATE_VENC(CLK_VENC_SET0_LARB, "venc_set0_larb", "venc_sel", 0),
+   GATE_VENC(CLK_VENC_SET1_VENC, "venc_set1_venc", "venc_sel", 4),
+   GATE_VENC(CLK_VENC_SET2_JPGENC, "venc_set2_jpgenc", "venc_sel", 8),
+   GATE_VENC(CLK_VENC_SET5_GALS, "venc_set5_gals", "venc_sel", 28),
+};
+
+static const struct mtk_clk_desc venc_desc = {
+   .clks = venc_clks,
+   .num_clks = ARRAY_SIZE(venc_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_venc[] = {
+   {
+   .compatible = "mediatek,mt8192-vencsys",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_venc_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-venc",
+   .of_match_table = of_match_clk_mt8192_venc,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_venc_drv);
-- 
1.8.1.1.dirty



[PATCH v6 21/22] clk: mediatek: Add MT8192 vdecsys clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 vdecsys and vdecsys soc clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 +++
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-vdec.c | 94 ++
 3 files changed, 101 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-vdec.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 1009e1f..633e806 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -557,6 +557,12 @@ config COMMON_CLK_MT8192_SCP_ADSP
help
  This driver supports MediaTek MT8192 scp_adsp clocks.
 
+config COMMON_CLK_MT8192_VDECSYS
+   bool "Clock driver for MediaTek MT8192 vdecsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 vdecsys and vdecsys_soc clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index a336fe7..887dd6b 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -78,5 +78,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
 obj-$(CONFIG_COMMON_CLK_MT8192_SCP_ADSP) += clk-mt8192-scp_adsp.o
+obj-$(CONFIG_COMMON_CLK_MT8192_VDECSYS) += clk-mt8192-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-vdec.c 
b/drivers/clk/mediatek/clk-mt8192-vdec.c
new file mode 100644
index 000..a6043c1
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-vdec.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs vdec0_cg_regs = {
+   .set_ofs = 0x0,
+   .clr_ofs = 0x4,
+   .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs vdec1_cg_regs = {
+   .set_ofs = 0x200,
+   .clr_ofs = 0x204,
+   .sta_ofs = 0x200,
+};
+
+static const struct mtk_gate_regs vdec2_cg_regs = {
+   .set_ofs = 0x8,
+   .clr_ofs = 0xc,
+   .sta_ofs = 0x8,
+};
+
+#define GATE_VDEC0(_id, _name, _parent, _shift)\
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+#define GATE_VDEC1(_id, _name, _parent, _shift)\
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+#define GATE_VDEC2(_id, _name, _parent, _shift)\
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate vdec_clks[] = {
+   /* VDEC0 */
+   GATE_VDEC0(CLK_VDEC_VDEC, "vdec_vdec", "vdec_sel", 0),
+   GATE_VDEC0(CLK_VDEC_ACTIVE, "vdec_active", "vdec_sel", 4),
+   /* VDEC1 */
+   GATE_VDEC1(CLK_VDEC_LAT, "vdec_lat", "vdec_sel", 0),
+   GATE_VDEC1(CLK_VDEC_LAT_ACTIVE, "vdec_lat_active", "vdec_sel", 4),
+   /* VDEC2 */
+   GATE_VDEC2(CLK_VDEC_LARB1, "vdec_larb1", "vdec_sel", 0),
+};
+
+static const struct mtk_gate vdec_soc_clks[] = {
+   /* VDEC_SOC0 */
+   GATE_VDEC0(CLK_VDEC_SOC_VDEC, "vdec_soc_vdec", "vdec_sel", 0),
+   GATE_VDEC0(CLK_VDEC_SOC_VDEC_ACTIVE, "vdec_soc_vdec_active", 
"vdec_sel", 4),
+   /* VDEC_SOC1 */
+   GATE_VDEC1(CLK_VDEC_SOC_LAT, "vdec_soc_lat", "vdec_sel", 0),
+   GATE_VDEC1(CLK_VDEC_SOC_LAT_ACTIVE, "vdec_soc_lat_active", "vdec_sel", 
4),
+   /* VDEC_SOC2 */
+   GATE_VDEC2(CLK_VDEC_SOC_LARB1, "vdec_soc_larb1", "vdec_sel", 0),
+};
+
+static const struct mtk_clk_desc vdec_desc = {
+   .clks = vdec_clks,
+   .num_clks = ARRAY_SIZE(vdec_clks),
+};
+
+static const struct mtk_clk_desc vdec_soc_desc = {
+   .clks = vdec_soc_clks,
+   .num_clks = ARRAY_SIZE(vdec_soc_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_vdec[] = {
+   {
+   .compatible = "mediatek,mt8192-vdecsys",
+   .data = _desc,
+   }, {
+   .compatible = "mediatek,mt8192-vdecsys_soc",
+   .data = _soc_desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_vdec_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-vdec",
+   .of_match_table = of_match_clk_mt8192_vdec,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_vdec_drv);
-- 
1.8.1.1.dirty



[PATCH v6 03/22] dt-bindings: ARM: Mediatek: Add new document bindings of msdc controller

2020-12-22 Thread Weiyi Lu
This patch adds the new binding documentation of msdc controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,msdc.yaml   | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml
new file mode 100644
index 000..5aa9536
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,msdc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MSDC Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek msdc controller provides functional configurations and clocks 
to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-msdc
+  - mediatek,mt8192-msdc_top
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+msdc: syscon@11f6 {
+compatible = "mediatek,mt8192-msdc", "syscon";
+reg = <0 0x11f6 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+msdc_top: syscon@11f1 {
+compatible = "mediatek,mt8192-msdc_top", "syscon";
+reg = <0 0x11f1 0 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty



[PATCH v6 15/22] clk: mediatek: Add MT8192 ipesys clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 ipesys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-ipe.c | 57 +++
 3 files changed, 64 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-ipe.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 8acc7d6..c6bc618 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -521,6 +521,12 @@ config COMMON_CLK_MT8192_IMP_IIC_WRAP
help
  This driver supports MediaTek MT8192 imp_iic_wrap clocks.
 
+config COMMON_CLK_MT8192_IPESYS
+   bool "Clock driver for MediaTek MT8192 ipesys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 ipesys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 3798162..33dc974 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -72,5 +72,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
+obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-ipe.c 
b/drivers/clk/mediatek/clk-mt8192-ipe.c
new file mode 100644
index 000..218e688
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-ipe.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs ipe_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_IPE(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate ipe_clks[] = {
+   GATE_IPE(CLK_IPE_LARB19, "ipe_larb19", "ipe_sel", 0),
+   GATE_IPE(CLK_IPE_LARB20, "ipe_larb20", "ipe_sel", 1),
+   GATE_IPE(CLK_IPE_SMI_SUBCOM, "ipe_smi_subcom", "ipe_sel", 2),
+   GATE_IPE(CLK_IPE_FD, "ipe_fd", "ipe_sel", 3),
+   GATE_IPE(CLK_IPE_FE, "ipe_fe", "ipe_sel", 4),
+   GATE_IPE(CLK_IPE_RSC, "ipe_rsc", "ipe_sel", 5),
+   GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6),
+   GATE_IPE(CLK_IPE_GALS, "ipe_gals", "ipe_sel", 8),
+};
+
+static const struct mtk_clk_desc ipe_desc = {
+   .clks = ipe_clks,
+   .num_clks = ARRAY_SIZE(ipe_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_ipe[] = {
+   {
+   .compatible = "mediatek,mt8192-ipesys",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_ipe_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-ipe",
+   .of_match_table = of_match_clk_mt8192_ipe,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_ipe_drv);
-- 
1.8.1.1.dirty



[PATCH v6 11/22] clk: mediatek: Add MT8192 audio clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 audio clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |   6 ++
 drivers/clk/mediatek/Makefile |   1 +
 drivers/clk/mediatek/clk-mt8192-aud.c | 118 ++
 3 files changed, 125 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-aud.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index f628efd..1a8b0c1 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -497,6 +497,12 @@ config COMMON_CLK_MT8192
help
  This driver supports MediaTek MT8192 basic clocks.
 
+config COMMON_CLK_MT8192_AUDSYS
+   bool "Clock driver for MediaTek MT8192 audsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 audsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index fcde421..1d0f2e8 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -68,5 +68,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_MMSYS) += clk-mt8183-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
+obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-aud.c 
b/drivers/clk/mediatek/clk-mt8192-aud.c
new file mode 100644
index 000..b38f5a5
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-aud.c
@@ -0,0 +1,118 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs aud0_cg_regs = {
+   .set_ofs = 0x0,
+   .clr_ofs = 0x0,
+   .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs aud1_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x4,
+   .sta_ofs = 0x4,
+};
+
+static const struct mtk_gate_regs aud2_cg_regs = {
+   .set_ofs = 0x8,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x8,
+};
+
+#define GATE_AUD0(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+#define GATE_AUD1(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+#define GATE_AUD2(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+static const struct mtk_gate aud_clks[] = {
+   /* AUD0 */
+   GATE_AUD0(CLK_AUD_AFE, "aud_afe", "audio_sel", 2),
+   GATE_AUD0(CLK_AUD_22M, "aud_22m", "aud_engen1_sel", 8),
+   GATE_AUD0(CLK_AUD_24M, "aud_24m", "aud_engen2_sel", 9),
+   GATE_AUD0(CLK_AUD_APLL2_TUNER, "aud_apll2_tuner", "aud_engen2_sel", 18),
+   GATE_AUD0(CLK_AUD_APLL_TUNER, "aud_apll_tuner", "aud_engen1_sel", 19),
+   GATE_AUD0(CLK_AUD_TDM, "aud_tdm", "aud_1_sel", 20),
+   GATE_AUD0(CLK_AUD_ADC, "aud_adc", "audio_sel", 24),
+   GATE_AUD0(CLK_AUD_DAC, "aud_dac", "audio_sel", 25),
+   GATE_AUD0(CLK_AUD_DAC_PREDIS, "aud_dac_predis", "audio_sel", 26),
+   GATE_AUD0(CLK_AUD_TML, "aud_tml", "audio_sel", 27),
+   GATE_AUD0(CLK_AUD_NLE, "aud_nle", "audio_sel", 28),
+   /* AUD1 */
+   GATE_AUD1(CLK_AUD_I2S1_B, "aud_i2s1_b", "audio_sel", 4),
+   GATE_AUD1(CLK_AUD_I2S2_B, "aud_i2s2_b", "audio_sel", 5),
+   GATE_AUD1(CLK_AUD_I2S3_B, "aud_i2s3_b", "audio_sel", 6),
+   GATE_AUD1(CLK_AUD_I2S4_B, "aud_i2s4_b", "audio_sel", 7),
+   GATE_AUD1(CLK_AUD_CONNSYS_I2S_ASRC, "aud_connsys_i2s_asrc", 
"audio_sel", 12),
+   GATE_AUD1(CLK_AUD_GENERAL1_ASRC, "aud_general1_asrc", "audio_sel", 13),
+   GATE_AUD1(CLK_AUD_GENERAL2_ASRC, "aud_general2_asrc", "audio_sel", 14),
+   GATE_AUD1(CLK_AUD_DAC_HIRES, "aud_dac_hires", "audio_h_sel", 15),
+   GATE_AUD1(CLK_AUD_ADC_HIRES, "aud_adc_hires", "audio_h_sel", 16),
+   GATE_AUD1(CLK_AUD_ADC_HIRES_TML, "aud_adc_hires_tml", "audio_h_sel", 
17),
+   GATE_AUD1(CLK_AUD_ADDA6_ADC, "aud_adda6_adc", "audio_sel", 20),
+   GATE_AUD1(CLK_AUD_ADDA6_ADC_HIRES, "aud_adda6_adc_hires", 
"audio_h_sel", 21),
+   GATE_AUD1(CLK_AUD_3RD_DAC, "

[PATCH v6 19/22] clk: mediatek: Add MT8192 msdc clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 msdc and msdc top clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 +++
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-msdc.c | 85 ++
 3 files changed, 92 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-msdc.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index bc92611..aba662f 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -545,6 +545,12 @@ config COMMON_CLK_MT8192_MMSYS
help
  This driver supports MediaTek MT8192 mmsys clocks.
 
+config COMMON_CLK_MT8192_MSDC
+   bool "Clock driver for MediaTek MT8192 msdc"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 msdc and msdc_top clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 838bb01..8e4e343 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -76,5 +76,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-msdc.c 
b/drivers/clk/mediatek/clk-mt8192-msdc.c
new file mode 100644
index 000..0fb8d01
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-msdc.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs msdc_cg_regs = {
+   .set_ofs = 0xb4,
+   .clr_ofs = 0xb4,
+   .sta_ofs = 0xb4,
+};
+
+static const struct mtk_gate_regs msdc_top_cg_regs = {
+   .set_ofs = 0x0,
+   .clr_ofs = 0x0,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_MSDC(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr_inv)
+
+#define GATE_MSDC_TOP(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _top_cg_regs, _shift, 
_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate msdc_clks[] = {
+   GATE_MSDC(CLK_MSDC_AXI_WRAP, "msdc_axi_wrap", "axi_sel", 22),
+};
+
+static const struct mtk_gate msdc_top_clks[] = {
+   GATE_MSDC_TOP(CLK_MSDC_TOP_AES_0P, "msdc_top_aes_0p", 
"aes_msdcfde_sel", 0),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_SRC_0P, "msdc_top_src_0p", 
"infra_msdc0_src", 1),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_SRC_1P, "msdc_top_src_1p", 
"infra_msdc1_src", 2),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_SRC_2P, "msdc_top_src_2p", 
"infra_msdc2_src", 3),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_MSDC0, "msdc_top_p_msdc0", "axi_sel", 4),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_MSDC1, "msdc_top_p_msdc1", "axi_sel", 5),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_MSDC2, "msdc_top_p_msdc2", "axi_sel", 6),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_CFG, "msdc_top_p_cfg", "axi_sel", 7),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_AXI, "msdc_top_axi", "axi_sel", 8),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_H_MST_0P, "msdc_top_h_mst_0p", 
"infra_msdc0", 9),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_H_MST_1P, "msdc_top_h_mst_1p", 
"infra_msdc1", 10),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_H_MST_2P, "msdc_top_h_mst_2p", 
"infra_msdc2", 11),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_MEM_OFF_DLY_26M, "msdc_top_mem_off_dly_26m", 
"clk26m", 12),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_32K, "msdc_top_32k", "clk32k", 13),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_AHB2AXI_BRG_AXI, "msdc_top_ahb2axi_brg_axi", 
"axi_sel", 14),
+};
+
+static const struct mtk_clk_desc msdc_desc = {
+   .clks = msdc_clks,
+   .num_clks = ARRAY_SIZE(msdc_clks),
+};
+
+static const struct mtk_clk_desc msdc_top_desc = {
+   .clks = msdc_top_clks,
+   .num_clks = ARRAY_SIZE(msdc_top_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_msdc[] = {
+   {
+   .compatible = "mediatek,mt8192-msdc",
+   .data = _desc,
+   }, {
+   .compatible = "mediatek,mt8192-msdc_top",
+   .data = _top_desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_msdc_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-msdc",
+   .of_match_table = of_match_clk_mt8192_msdc,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_msdc_drv);
-- 
1.8.1.1.dirty



[PATCH v6 17/22] clk: mediatek: Add MT8192 mfgcfg clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 mfgcfg clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 +
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-mfg.c | 50 +++
 3 files changed, 57 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-mfg.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index a0a2efa9..3db8670 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -533,6 +533,12 @@ config COMMON_CLK_MT8192_MDPSYS
help
  This driver supports MediaTek MT8192 mdpsys clocks.
 
+config COMMON_CLK_MT8192_MFGCFG
+   bool "Clock driver for MediaTek MT8192 mfgcfg"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 mfgcfg clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 7b258cb..024841a 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -74,5 +74,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-mfg.c 
b/drivers/clk/mediatek/clk-mt8192-mfg.c
new file mode 100644
index 000..510be98
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-mfg.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs mfg_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_MFG(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate mfg_clks[] = {
+   GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_pll_sel", 0),
+};
+
+static const struct mtk_clk_desc mfg_desc = {
+   .clks = mfg_clks,
+   .num_clks = ARRAY_SIZE(mfg_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_mfg[] = {
+   {
+   .compatible = "mediatek,mt8192-mfgcfg",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_mfg_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-mfg",
+   .of_match_table = of_match_clk_mt8192_mfg,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_mfg_drv);
-- 
1.8.1.1.dirty



[PATCH v6 13/22] clk: mediatek: Add MT8192 imgsys clock support

2020-12-22 Thread Weiyi Lu
Add MT8192 imgsys and imgsys2 clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 +++
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-img.c | 70 +++
 3 files changed, 77 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-img.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index a75b7ec..eb549f8 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -509,6 +509,12 @@ config COMMON_CLK_MT8192_CAMSYS
help
  This driver supports MediaTek MT8192 camsys and camsys_raw clocks.
 
+config COMMON_CLK_MT8192_IMGSYS
+   bool "Clock driver for MediaTek MT8192 imgsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 imgsys and imgsys2 clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 94bf7a0..91392cb 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -70,5 +70,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
+obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-img.c 
b/drivers/clk/mediatek/clk-mt8192-img.c
new file mode 100644
index 000..24b4143
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-img.c
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs img_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_IMG(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate img_clks[] = {
+   GATE_IMG(CLK_IMG_LARB9, "img_larb9", "img1_sel", 0),
+   GATE_IMG(CLK_IMG_LARB10, "img_larb10", "img1_sel", 1),
+   GATE_IMG(CLK_IMG_DIP, "img_dip", "img1_sel", 2),
+   GATE_IMG(CLK_IMG_GALS, "img_gals", "img1_sel", 12),
+};
+
+static const struct mtk_gate img2_clks[] = {
+   GATE_IMG(CLK_IMG2_LARB11, "img2_larb11", "img1_sel", 0),
+   GATE_IMG(CLK_IMG2_LARB12, "img2_larb12", "img1_sel", 1),
+   GATE_IMG(CLK_IMG2_MFB, "img2_mfb", "img1_sel", 6),
+   GATE_IMG(CLK_IMG2_WPE, "img2_wpe", "img1_sel", 7),
+   GATE_IMG(CLK_IMG2_MSS, "img2_mss", "img1_sel", 8),
+   GATE_IMG(CLK_IMG2_GALS, "img2_gals", "img1_sel", 12),
+};
+
+static const struct mtk_clk_desc img_desc = {
+   .clks = img_clks,
+   .num_clks = ARRAY_SIZE(img_clks),
+};
+
+static const struct mtk_clk_desc img2_desc = {
+   .clks = img2_clks,
+   .num_clks = ARRAY_SIZE(img2_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_img[] = {
+   {
+   .compatible = "mediatek,mt8192-imgsys",
+   .data = _desc,
+   }, {
+   .compatible = "mediatek,mt8192-imgsys2",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_img_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-img",
+   .of_match_table = of_match_clk_mt8192_img,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_img_drv);
-- 
1.8.1.1.dirty



[PATCH v6 09/22] clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers

2020-12-22 Thread Weiyi Lu
Most of subsystem clock providers only need to register clock gates
in their probe() function.
To reduce the duplicated code by add a generic function.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mtk.c | 23 +++
 drivers/clk/mediatek/clk-mtk.h |  8 
 2 files changed, 31 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index cec1c8a..67693b7 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
@@ -286,3 +287,25 @@ void mtk_clk_register_dividers(const struct 
mtk_clk_divider *mcds,
clk_data->clks[mcd->id] = clk;
}
 }
+
+int mtk_clk_simple_probe(struct platform_device *pdev)
+{
+   const struct mtk_clk_desc *mcd;
+   struct clk_onecell_data *clk_data;
+   struct device_node *node = pdev->dev.of_node;
+   int r;
+
+   mcd = of_device_get_match_data(>dev);
+   if (!mcd)
+   return -EINVAL;
+
+   clk_data = mtk_alloc_clk_data(mcd->num_clks);
+   if (!clk_data)
+   return -ENOMEM;
+
+   r = mtk_clk_register_gates(node, mcd->clks, mcd->num_clks, clk_data);
+   if (r)
+   return r;
+
+   return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index c580663..2f61fba 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct clk;
 struct clk_onecell_data;
@@ -250,4 +251,11 @@ void mtk_register_reset_controller(struct device_node *np,
 void mtk_register_reset_controller_set_clr(struct device_node *np,
unsigned int num_regs, int regofs);
 
+struct mtk_clk_desc {
+   const struct mtk_gate *clks;
+   size_t num_clks;
+};
+
+int mtk_clk_simple_probe(struct platform_device *pdev);
+
 #endif /* __DRV_CLK_MTK_H */
-- 
1.8.1.1.dirty



Re: [PATCH v3] arm64: dts: mediatek: Add mt8192 power domains controller

2020-11-30 Thread Weiyi Lu

On Fri, 2020-11-27 at 13:42 +0100, Matthias Brugger wrote:
> 
> On 19/11/2020 15:13, Enric Balletbo Serra wrote:
> > Hi Weiyi,
> > 
> > Missatge de Weiyi Lu  del dia dj., 19 de nov.
> > 2020 a les 14:10:
> >>
> >> On Thu, 2020-11-19 at 13:13 +0100, Enric Balletbo Serra wrote:
> >>> Hi Weiyi,
> >>>
> >>> Thank you for the patch
> >>>
> >>> Missatge de Weiyi Lu  del dia dj., 19 de nov.
> >>> 2020 a les 11:48:
> >>>>
> >>>> Add power domains controller node for SoC mt8192
> >>>>
> >>>> Signed-off-by: Weiyi Lu 
> >>>> ---
> [...]
> >>>> +   /* System Power Manager */
> >>>> +   spm: power-controller {
> >>>> +   compatible = 
> >>>> "mediatek,mt8192-power-controller";
> >>>> +   #address-cells = <1>;
> >>>> +   #size-cells = <0>;
> >>>> +   #power-domain-cells = <1>;
> >>>> +
> >>>> +   /* power domain of the SoC */
> >>>> +   audio@MT8192_POWER_DOMAIN_AUDIO {
> >>>
> >>> If you run the dt_bindings_check it should return some errors, as all
> >>> these node names should be 'power-domain@'. Which is a bit annoying
> >>> because then you will get a bunch of errors like this:
> >>>
> >>> [1.969110] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [1.976997] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [1.984828] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [1.992657] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.000685] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.008566] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.016395] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.024221] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.032049] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.039874] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.047699] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.055524] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.063352] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>> [2.071176] debugfs: Directory 'power-domain' with parent
> >>> 'pm_genpd' already present!
> >>>
> >>> But that's another problem that should be handled in debugfs system.
> >>>
> >>
> >> Indeed...so I chose to use different name in dts to avoid problems in
> >> debugfs. It does violate the naming rules.
> >>
> > 
> > But your binding will not pass (or trigger warnings) the dtb check
> > then. Rob was clear that names should be generic. Proper fix is fix
> > debugfs not the binding.
> > 
> 
> By the way, is anybody working on this debugfs issue?
> 

I think we can solve this problem by adding "name" to the struct
scpsys_domain_data and use this domain_data->name as the genpd.name.
This is very simple. But I want to know if you both like it?

> Regards,
> Matthias




Re: [PATCH v4 01/16] dt-bindings: power: Add bindings for the Mediatek SCPSYS power domains controller

2020-11-26 Thread Weiyi Lu
On Fri, 2020-10-30 at 12:36 +0100, Enric Balletbo i Serra wrote:
> The System Control Processor System (SCPSYS) has several power management
> related tasks in the system. Add the bindings to define the power
> domains for the SCPSYS power controller.
> 
> Co-developed-by: Matthias Brugger 
> Signed-off-by: Matthias Brugger 
> Signed-off-by: Enric Balletbo i Serra 
> Reviewed-by: Rob Herring 
> ---
> 
> Changes in v4:
> - Fix indentation warnings reported by yamllint
> 
> Changes in v3:
> - Use hex for unit-addresses.
> - Define child nodes for nested power domains even are duplicated, but
>   more clear than adding a regex scaped to be a valid URI.
> 
> Changes in v2:
> - Use generic node names (power-domain).
> - Define valid values for common properties like #power-domain-cells.
> 
>  .../power/mediatek,power-controller.yaml  | 289 ++
>  1 file changed, 289 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/power/mediatek,power-controller.yaml
> 
> diff --git 
> a/Documentation/devicetree/bindings/power/mediatek,power-controller.yaml 
> b/Documentation/devicetree/bindings/power/mediatek,power-controller.yaml
> new file mode 100644
> index ..73b8988bd063
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/mediatek,power-controller.yaml
> @@ -0,0 +1,289 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/power/mediatek,power-controller.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Mediatek Power Domains Controller
> +
> +maintainers:
> +  - Weiyi Lu 
> +  - Matthias Brugger 
> +
> +description: |
> +  Mediatek processors include support for multiple power domains which can be
> +  powered up/down by software based on different application scenes to save 
> power.
> +
> +  IP cores belonging to a power domain should contain a 'power-domains'
> +  property that is a phandle for SCPSYS node representing the domain.
> +
> +properties:
> +  $nodename:
> +const: power-controller
> +
> +  compatible:
> +enum:
> +  - mediatek,mt8173-power-controller
> +
> +  '#power-domain-cells':
> +const: 1
> +
> +  '#address-cells':
> +const: 1
> +
> +  '#size-cells':
> +const: 0
> +
> +patternProperties:
> +  "^power-domain@[0-9a-f]+$":
> +type: object
> +description: |
> +  Represents the power domains within the power controller node as 
> documented
> +  in Documentation/devicetree/bindings/power/power-domain.yaml.
> +
> +properties:
> +
> +  '#power-domain-cells':
> +description:
> +  Must be 0 for nodes representing a single PM domain and 1 for nodes
> +  providing multiple PM domains.
> +
> +  '#address-cells':
> +const: 1
> +
> +  '#size-cells':
> +const: 0
> +
> +  reg:
> +description: |
> +  Power domain index. Valid values are defined in:
> +  "include/dt-bindings/power/mt8173-power.h" - for MT8173 type 
> power domain.
> +maxItems: 1
> +
> +  clocks:
> +description: |
> +  A number of phandles to clocks that need to be enabled during 
> domain
> +  power-up sequencing.
> +
> +  clock-names:
> +description: |
> +  List of names of clocks, in order to match the power-up sequencing
> +  for each power domain we need to group the clocks by name. BASIC
> +  clocks need to be enabled before enabling the corresponding power
> +  domain, and should not have a '-' in their name (i.e mm, mfg, 
> venc).
> +  SUSBYS clocks need to be enabled before releasing the bus 
> protection,
> +  and should contain a '-' in their name (i.e mm-0, isp-0, cam-0).
> +
> +  In order to follow properly the power-up sequencing, the clocks 
> must
> +  be specified by order, adding first the BASIC clocks followed by 
> the
> +  SUSBSYS clocks.
> +
> +  mediatek,infracfg:
> +$ref: /schemas/types.yaml#definitions/phandle
> +description: phandle to the device containing the INFRACFG register 
> range.
> +
> +  mediatek,smi:
> +$ref: /schemas/types.yaml#definitions/phandle
> +description: phandle to the device containing the SMI register range.
> +
> +patternProperties:
> +  "^power-domain@[0-9a-f]+$":
> +type: object
> +description: |
> +  Represents a power domain child within a power domain parent node.
> 

Re: [PATCH v3] arm64: dts: mediatek: Add mt8192 power domains controller

2020-11-19 Thread Weiyi Lu
On Thu, 2020-11-19 at 13:13 +0100, Enric Balletbo Serra wrote:
> Hi Weiyi,
> 
> Thank you for the patch
> 
> Missatge de Weiyi Lu  del dia dj., 19 de nov.
> 2020 a les 11:48:
> >
> > Add power domains controller node for SoC mt8192
> >
> > Signed-off-by: Weiyi Lu 
> > ---
> >
> > Change in v3: None, just rebase dts onto v5.10-rc1 and
> >V4 of series "Add new driver for SCPSYS power domains controller"[1]
> >
> > [1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=374013
> >
> >  arch/arm64/boot/dts/mediatek/mt8192.dtsi | 201 
> > +++
> >  1 file changed, 201 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
> > b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
> > index 69d45c7..08449eb 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
> > +++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
> > @@ -9,6 +9,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  / {
> > compatible = "mediatek,mt8192";
> > @@ -257,6 +258,206 @@
> > #interrupt-cells = <2>;
> > };
> >
> > +   scpsys: syscon@10006000 {
> > +   compatible = "syscon", "simple-mfd";
> > +   reg = <0 0x10006000 0 0x1000>;
> > +   #power-domain-cells = <1>;
> > +
> > +   /* System Power Manager */
> > +   spm: power-controller {
> > +   compatible = 
> > "mediatek,mt8192-power-controller";
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +   #power-domain-cells = <1>;
> > +
> > +   /* power domain of the SoC */
> > +   audio@MT8192_POWER_DOMAIN_AUDIO {
> 
> If you run the dt_bindings_check it should return some errors, as all
> these node names should be 'power-domain@'. Which is a bit annoying
> because then you will get a bunch of errors like this:
> 
> [1.969110] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [1.976997] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [1.984828] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [1.992657] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.000685] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.008566] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.016395] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.024221] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.032049] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.039874] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.047699] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.055524] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.063352] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> [2.071176] debugfs: Directory 'power-domain' with parent
> 'pm_genpd' already present!
> 
> But that's another problem that should be handled in debugfs system.
> 

Indeed...so I chose to use different name in dts to avoid problems in
debugfs. It does violate the naming rules.

> > +   reg = ;
> > +   clocks = < 
> > CLK_TOP_AUD_INTBUS_SEL>,
> > +< 
> > CLK_INFRA_AUDIO_26M_B>,
> > +< 
> > CLK_INFRA_AUDIO>;
> > +   clock-names = "audio", "audio1", 
> > "audio2";
> > +   mediatek,infracfg = <>;
> > +   #power-domain-cells = <0>;
> > +   };
> > +
> > +   conn@MT8192_POWER_DOMAIN_CONN {
> > +   reg = ;
> > +   clocks = < 
> > CLK_I

Re: [PATCH v4 16/16] soc: mediatek: pm-domains: Add support for mt8192

2020-11-19 Thread Weiyi Lu
On Fri, 2020-10-30 at 12:36 +0100, Enric Balletbo i Serra wrote:
> From: Weiyi Lu 
> 
> Add the needed board data to support mt8192 SoC.
> 
> Signed-off-by: Weiyi Lu 
> Signed-off-by: Enric Balletbo i Serra 
> ---
> 

Hi Enric,

I've verified with my dts v3[1] on MT8192 EVB, so

Tested-by: Weiyi Lu 

[1]
https://patchwork.kernel.org/project/linux-mediatek/list/?series=387453

> Changes in v4:
> - Adapt scpsys_soc_data struct to the changes done in previous patches.
> 
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/soc/mediatek/mt8192-pm-domains.h | 292 +++
>  drivers/soc/mediatek/mtk-pm-domains.c|   5 +
>  include/linux/soc/mediatek/infracfg.h|  56 +
>  3 files changed, 353 insertions(+)
>  create mode 100644 drivers/soc/mediatek/mt8192-pm-domains.h
> 
> diff --git a/drivers/soc/mediatek/mt8192-pm-domains.h 
> b/drivers/soc/mediatek/mt8192-pm-domains.h
> new file mode 100644
> index ..0fdf6dc6231f
> --- /dev/null
> +++ b/drivers/soc/mediatek/mt8192-pm-domains.h
> @@ -0,0 +1,292 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef __SOC_MEDIATEK_MT8192_PM_DOMAINS_H
> +#define __SOC_MEDIATEK_MT8192_PM_DOMAINS_H
> +
> +#include "mtk-pm-domains.h"
> +#include 
> +
> +/*
> + * MT8192 power domain support
> + */
> +
> +static const struct scpsys_domain_data scpsys_domain_data_mt8192[] = {
> + [MT8192_POWER_DOMAIN_AUDIO] = {
> + .sta_mask = BIT(21),
> + .ctl_offs = 0x0354,
> + .sram_pdn_bits = GENMASK(8, 8),
> + .sram_pdn_ack_bits = GENMASK(12, 12),
> + .bp_infracfg = {
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_2_AUDIO,
> + MT8192_TOP_AXI_PROT_EN_2_SET,
> + MT8192_TOP_AXI_PROT_EN_2_CLR,
> + MT8192_TOP_AXI_PROT_EN_2_STA1),
> + },
> + },
> + [MT8192_POWER_DOMAIN_CONN] = {
> + .sta_mask = PWR_STATUS_CONN,
> + .ctl_offs = 0x0304,
> + .sram_pdn_bits = 0,
> + .sram_pdn_ack_bits = 0,
> + .bp_infracfg = {
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_CONN,
> + MT8192_TOP_AXI_PROT_EN_SET,
> + MT8192_TOP_AXI_PROT_EN_CLR,
> + MT8192_TOP_AXI_PROT_EN_STA1),
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_CONN_2ND,
> + MT8192_TOP_AXI_PROT_EN_SET,
> + MT8192_TOP_AXI_PROT_EN_CLR,
> + MT8192_TOP_AXI_PROT_EN_STA1),
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_1_CONN,
> + MT8192_TOP_AXI_PROT_EN_1_SET,
> + MT8192_TOP_AXI_PROT_EN_1_CLR,
> + MT8192_TOP_AXI_PROT_EN_1_STA1),
> + },
> + .caps = MTK_SCPD_KEEP_DEFAULT_OFF,
> + },
> + [MT8192_POWER_DOMAIN_MFG0] = {
> + .sta_mask = BIT(2),
> + .ctl_offs = 0x0308,
> + .sram_pdn_bits = GENMASK(8, 8),
> + .sram_pdn_ack_bits = GENMASK(12, 12),
> + },
> + [MT8192_POWER_DOMAIN_MFG1] = {
> + .sta_mask = BIT(3),
> + .ctl_offs = 0x030c,
> + .sram_pdn_bits = GENMASK(8, 8),
> + .sram_pdn_ack_bits = GENMASK(12, 12),
> + .bp_infracfg = {
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_1_MFG1,
> + MT8192_TOP_AXI_PROT_EN_1_SET,
> + MT8192_TOP_AXI_PROT_EN_1_CLR,
> + MT8192_TOP_AXI_PROT_EN_1_STA1),
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_2_MFG1,
> + MT8192_TOP_AXI_PROT_EN_2_SET,
> + MT8192_TOP_AXI_PROT_EN_2_CLR,
> + MT8192_TOP_AXI_PROT_EN_2_STA1),
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_MFG1,
> + MT8192_TOP_AXI_PROT_EN_SET,
> + MT8192_TOP_AXI_PROT_EN_CLR,
> + MT8192_TOP_AXI_PROT_EN_STA1),
> + BUS_PROT_WR(MT8192_TOP_AXI_PROT_EN_2_MFG1_2ND,
> + MT8192_TOP_AXI_PROT_EN_2_SET,
> + MT8192_TOP_AXI_PROT_EN_2_CLR,
> + MT8192_TOP_AXI_PROT_EN_2_STA1),
> + },
> + },
> + [MT8192_POWER_DOMAIN_MFG2] = {
> + .sta_mask = BIT(4),
> +   

[PATCH v3] arm64: dts: mediatek: Add mt8192 power domains controller

2020-11-19 Thread Weiyi Lu
Add power domains controller node for SoC mt8192

Signed-off-by: Weiyi Lu 
---

Change in v3: None, just rebase dts onto v5.10-rc1 and
   V4 of series "Add new driver for SCPSYS power domains controller"[1]

[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=374013

 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 201 +++
 1 file changed, 201 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index 69d45c7..08449eb 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 / {
compatible = "mediatek,mt8192";
@@ -257,6 +258,206 @@
#interrupt-cells = <2>;
};
 
+   scpsys: syscon@10006000 {
+   compatible = "syscon", "simple-mfd";
+   reg = <0 0x10006000 0 0x1000>;
+   #power-domain-cells = <1>;
+
+   /* System Power Manager */
+   spm: power-controller {
+   compatible = "mediatek,mt8192-power-controller";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   #power-domain-cells = <1>;
+
+   /* power domain of the SoC */
+   audio@MT8192_POWER_DOMAIN_AUDIO {
+   reg = ;
+   clocks = < 
CLK_TOP_AUD_INTBUS_SEL>,
+< 
CLK_INFRA_AUDIO_26M_B>,
+< CLK_INFRA_AUDIO>;
+   clock-names = "audio", "audio1", 
"audio2";
+   mediatek,infracfg = <>;
+   #power-domain-cells = <0>;
+   };
+
+   conn@MT8192_POWER_DOMAIN_CONN {
+   reg = ;
+   clocks = < 
CLK_INFRA_PMIC_CONN>;
+   clock-names = "conn";
+   mediatek,infracfg = <>;
+   #power-domain-cells = <0>;
+   };
+
+   mfg@MT8192_POWER_DOMAIN_MFG0 {
+   reg = ;
+   clocks = < 
CLK_TOP_MFG_PLL_SEL>;
+   clock-names = "mfg";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   #power-domain-cells = <1>;
+
+   mfg1@MT8192_POWER_DOMAIN_MFG1 {
+   reg = 
;
+   mediatek,infracfg = <>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   #power-domain-cells = <1>;
+
+   mfg2@MT8192_POWER_DOMAIN_MFG2 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   };
+
+   mfg3@MT8192_POWER_DOMAIN_MFG3 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   };
+
+   mfg4@MT8192_POWER_DOMAIN_MFG4 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   };
+
+   mfg5@MT8192_POWER_DOMAIN_MFG5 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   };
+
+   mfg6@MT8192_POWER_DOMAIN_MFG6 {
+   reg = 
;
+   #power-domain-cells = 
<0>;
+   

Re: [PATCH v5 07/24] clk: mediatek: Fix asymmetrical PLL enable and disable control

2020-11-17 Thread Weiyi Lu
On Wed, 2020-11-18 at 11:55 +0800, Ikjoon Jang wrote:
> On Mon, Nov 09, 2020 at 10:03:32AM +0800, Weiyi Lu wrote:
> > In fact, the en_mask is a combination of divider enable mask
> > and pll enable bit(bit0).
> > Before this patch, we enabled both divider mask and bit0 in prepare(),
> > but only cleared the bit0 in unprepare().
> > In the future, we hope en_mask will only be used as divider enable mask.
> > The enable register(CON0) will be set in 2 steps:
> > first is divider mask, and then bit0 during prepare(), and vice versa.
> > But considering backward compatibility, at this stage we allow en_mask
> > to be a combination or a pure divider enable mask.
> > And then we will make en_mask a pure divider enable mask in another
> > following patch series.
> 
> I have a question on this: Are there any possible problems on controlling
> divider_en and bit0 at the same time? Or is this only for cleanups?
> 

Yes, this is only for cleanups and controlling divider_en and bit0 at
the same time will not cause any problem.

> If mtk_pll_data::en_mask is not allowed to control with bit0 together,
> I guess register_pll() also needs to check en_mask::bit0 is cleared?
> 
> > 
> > Signed-off-by: Weiyi Lu 
> > ---
> >  drivers/clk/mediatek/clk-pll.c | 20 
> >  1 file changed, 16 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
> > index f440f2cd..11ed5d1 100644
> > --- a/drivers/clk/mediatek/clk-pll.c
> > +++ b/drivers/clk/mediatek/clk-pll.c
> > @@ -238,6 +238,7 @@ static int mtk_pll_prepare(struct clk_hw *hw)
> >  {
> > struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
> > u32 r;
> > +   u32 div_en_mask;
> >  
> > r = readl(pll->pwr_addr) | CON0_PWR_ON;
> > writel(r, pll->pwr_addr);
> > @@ -247,10 +248,15 @@ static int mtk_pll_prepare(struct clk_hw *hw)
> > writel(r, pll->pwr_addr);
> > udelay(1);
> >  
> > -   r = readl(pll->base_addr + REG_CON0);
> > -   r |= pll->data->en_mask;
> > +   r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN;
> > writel(r, pll->base_addr + REG_CON0);
> >  
> > +   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
> > +   if (div_en_mask) {
> > +   r = readl(pll->base_addr + REG_CON0) | div_en_mask;
> > +   writel(r, pll->base_addr + REG_CON0);
> > +   }
> > +
> > __mtk_pll_tuner_enable(pll);
> >  
> > udelay(20);
> > @@ -268,6 +274,7 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
> >  {
> > struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
> > u32 r;
> > +   u32 div_en_mask;
> >  
> > if (pll->data->flags & HAVE_RST_BAR) {
> > r = readl(pll->base_addr + REG_CON0);
> > @@ -277,8 +284,13 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
> >  
> > __mtk_pll_tuner_disable(pll);
> >  
> > -   r = readl(pll->base_addr + REG_CON0);
> > -   r &= ~CON0_BASE_EN;
> > +   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
> > +   if (div_en_mask) {
> > +   r = readl(pll->base_addr + REG_CON0) & ~div_en_mask;
> > +   writel(r, pll->base_addr + REG_CON0);
> > +   }
> > +
> > +   r = readl(pll->base_addr + REG_CON0) & ~CON0_BASE_EN;
> > writel(r, pll->base_addr + REG_CON0);
> >  
> > r = readl(pll->pwr_addr) | CON0_ISO_EN;
> > -- 
> > 1.8.1.1.dirty
> > ___
> > linux-arm-kernel mailing list
> > linux-arm-ker...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



Re: [PATCH v5 14/24] clk: mediatek: Add MT8192 imp i2c wrapper clock support

2020-11-17 Thread Weiyi Lu
On Wed, 2020-11-18 at 10:41 +0800, Yingjoe Chen wrote:
> On Mon, 2020-11-09 at 10:03 +0800, Weiyi Lu wrote:
> > Add MT8192 imp i2c wrapper clock provider
> > 
> > Signed-off-by: Weiyi Lu 
> > ---
> >  drivers/clk/mediatek/Kconfig   |   6 ++
> >  drivers/clk/mediatek/Makefile  |   1 +
> >  drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c | 119 
> > +
> >  3 files changed, 126 insertions(+)
> >  create mode 100644 drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
> > 
> > diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
> > index eb549f8..8acc7d6 100644
> > --- a/drivers/clk/mediatek/Kconfig
> > +++ b/drivers/clk/mediatek/Kconfig
> > @@ -515,6 +515,12 @@ config COMMON_CLK_MT8192_IMGSYS
> > help
> >   This driver supports MediaTek MT8192 imgsys and imgsys2 clocks.
> >  
> > +config COMMON_CLK_MT8192_IMP_IIC_WRAP
> > +   bool "Clock driver for MediaTek MT8192 imp_iic_wrap"
> > +   depends on COMMON_CLK_MT8192
> > +   help
> > + This driver supports MediaTek MT8192 imp_iic_wrap clocks.
> > +
> >  config COMMON_CLK_MT8516
> > bool "Clock driver for MediaTek MT8516"
> > depends on ARCH_MEDIATEK || COMPILE_TEST
> 
> <...>
> 
> > +
> > +static struct platform_driver clk_mt8192_imp_iic_wrap_drv = {
> > +   .probe = mtk_clk_simple_probe,
> 
> Good to have this generic probe function. Now several mtk clk drivers
> are just a few data.
> 
> But this series still add >10 configs for mt8192 clock drivers. Why do
> we need separate configs for clocks of different domain? I don't think
> they need lots of resource. We should review the rationale and reduce
> the numbers. 
> 
Hi Joe,

Thanks for reviewing.

There have been some discussions in patch[1] as to why the subsystem
clocks are now separated by different configs.
And we do need these clocks to be optional on some MediatTek SoC
platform.

I thought it it now a rationale number of subsystem clock provider
drivers. In this series, we have reduced from 23 to 12.

[1]
https://patchwork.kernel.org/project/linux-mediatek/patch/1460621514-65191-5-git-send-email-jamesjj.l...@mediatek.com/


> 
> Joe.C
> 
> 



[PATCH v3] clk: mediatek: Make mtk_clk_register_mux() a static function

2020-11-13 Thread Weiyi Lu
mtk_clk_register_mux() should be a static function

Fixes: a3ae549917f16 ("clk: mediatek: Add new clkmux register API")
Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mux.c | 2 +-
 drivers/clk/mediatek/clk-mux.h | 4 
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c
index 14e127e..dcc1352 100644
--- a/drivers/clk/mediatek/clk-mux.c
+++ b/drivers/clk/mediatek/clk-mux.c
@@ -155,7 +155,7 @@ static int mtk_clk_mux_set_parent_setclr_lock(struct clk_hw 
*hw, u8 index)
.set_parent = mtk_clk_mux_set_parent_setclr_lock,
 };
 
-struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
+static struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
 struct regmap *regmap,
 spinlock_t *lock)
 {
diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h
index f5625f4..8e2f927 100644
--- a/drivers/clk/mediatek/clk-mux.h
+++ b/drivers/clk/mediatek/clk-mux.h
@@ -77,10 +77,6 @@ struct mtk_mux {
_width, _gate, _upd_ofs, _upd,  \
CLK_SET_RATE_PARENT)
 
-struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
-struct regmap *regmap,
-spinlock_t *lock);
-
 int mtk_clk_register_muxes(const struct mtk_mux *muxes,
   int num, struct device_node *node,
   spinlock_t *lock,
-- 
1.8.1.1.dirty



[PATCH v2] clk: mediatek: fix mtk_clk_register_mux() as static function

2020-11-10 Thread Weiyi Lu
mtk_clk_register_mux() should be a static function

Fixes: a3ae549917f16 ("clk: mediatek: Add new clkmux register API")
Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mux.c | 2 +-
 drivers/clk/mediatek/clk-mux.h | 4 
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c
index 14e127e..dcc1352 100644
--- a/drivers/clk/mediatek/clk-mux.c
+++ b/drivers/clk/mediatek/clk-mux.c
@@ -155,7 +155,7 @@ static int mtk_clk_mux_set_parent_setclr_lock(struct clk_hw 
*hw, u8 index)
.set_parent = mtk_clk_mux_set_parent_setclr_lock,
 };
 
-struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
+static struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
 struct regmap *regmap,
 spinlock_t *lock)
 {
diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h
index f5625f4..8e2f927 100644
--- a/drivers/clk/mediatek/clk-mux.h
+++ b/drivers/clk/mediatek/clk-mux.h
@@ -77,10 +77,6 @@ struct mtk_mux {
_width, _gate, _upd_ofs, _upd,  \
CLK_SET_RATE_PARENT)
 
-struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
-struct regmap *regmap,
-spinlock_t *lock);
-
 int mtk_clk_register_muxes(const struct mtk_mux *muxes,
   int num, struct device_node *node,
   spinlock_t *lock,
-- 
1.8.1.1.dirty


Re: [PATCH] clk: mediatek: fix mtk_clk_register_mux() as static function

2020-11-09 Thread Weiyi Lu
On Mon, 2020-11-09 at 11:20 +0100, Greg KH wrote:
> On Mon, Nov 09, 2020 at 05:37:07PM +0800, Weiyi Lu wrote:
> > mtk_clk_register_mux() should be a static function
> > 
> > Fixes: a3ae549917f16 ("clk: mediatek: Add new clkmux register API")
> > Cc: 
> 
> Why is this for stable trees?

Hi Greg,

My Mistake. Indeed, this is not a bug fix for stable tree.
And there are simple questions.
Will I be allowed to keep the fixes tag in this patch to indicate the
mistakes we made in previous commit if it's not a bug fix for stable
tree?
And all I need to do now is to remove stable tree from cc list. Is it
correct?

Many thanks.

> 



[PATCH] clk: mediatek: fix mtk_clk_register_mux() as static function

2020-11-09 Thread Weiyi Lu
mtk_clk_register_mux() should be a static function

Fixes: a3ae549917f16 ("clk: mediatek: Add new clkmux register API")
Cc: 
Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mux.c | 2 +-
 drivers/clk/mediatek/clk-mux.h | 4 
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c
index 14e127e..dcc1352 100644
--- a/drivers/clk/mediatek/clk-mux.c
+++ b/drivers/clk/mediatek/clk-mux.c
@@ -155,7 +155,7 @@ static int mtk_clk_mux_set_parent_setclr_lock(struct clk_hw 
*hw, u8 index)
.set_parent = mtk_clk_mux_set_parent_setclr_lock,
 };
 
-struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
+static struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
 struct regmap *regmap,
 spinlock_t *lock)
 {
diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h
index f5625f4..8e2f927 100644
--- a/drivers/clk/mediatek/clk-mux.h
+++ b/drivers/clk/mediatek/clk-mux.h
@@ -77,10 +77,6 @@ struct mtk_mux {
_width, _gate, _upd_ofs, _upd,  \
CLK_SET_RATE_PARENT)
 
-struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
-struct regmap *regmap,
-spinlock_t *lock);
-
 int mtk_clk_register_muxes(const struct mtk_mux *muxes,
   int num, struct device_node *node,
   spinlock_t *lock,
-- 
1.8.1.1.dirty


Re: [PATCH 10/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8183

2020-11-08 Thread Weiyi Lu
On Wed, 2020-10-28 at 11:27 +0100, Fabien Parent wrote:
> Hi Weiyi,
> 
> The clock driver for MT8167 has been merged in v5.10-rc1. Can you also
> apply the change to that driver.
> Thank you
> 
> Fabien
> 

Hi Fabien,

Done. update in v2.
Many thanks.

> On Fri, Oct 23, 2020 at 2:44 AM Weiyi Lu  wrote:
> >
> > remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
> > that only used for pll dividers.
> >
> > Signed-off-by: Weiyi Lu 
> > ---
> >  drivers/clk/mediatek/clk-mt8183.c | 22 +++---
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/clk/mediatek/clk-mt8183.c 
> > b/drivers/clk/mediatek/clk-mt8183.c
> > index 5046852..608108c 100644
> > --- a/drivers/clk/mediatek/clk-mt8183.c
> > +++ b/drivers/clk/mediatek/clk-mt8183.c
> > @@ -1121,34 +1121,34 @@
> >  };
> >
> >  static const struct mtk_pll_data plls[] = {
> > -   PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 
> > 0x0001,
> > +   PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0,
> > HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0204, 24, 0x0, 
> > 0x0, 0,
> > 0x0204, 0, 0, armpll_div_table),
> > -   PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0x0001,
> > +   PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0,
> > HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0214, 24, 0x0, 
> > 0x0, 0,
> > 0x0214, 0, 0, armpll_div_table),
> > -   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0x0001,
> > +   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0,
> > HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0294, 24, 0x0, 
> > 0x0, 0,
> > 0x0294, 0, 0),
> > -   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0x0001,
> > +   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0,
> > HAVE_RST_BAR, BIT(24), 22, 8, 0x0224, 24, 0x0, 0x0, 0,
> > 0x0224, 0, 0),
> > -   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0x0001,
> > +   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0,
> > HAVE_RST_BAR, BIT(24), 22, 8, 0x0234, 24, 0x0, 0x0, 0,
> > 0x0234, 0, 0),
> > -   PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0x0001,
> > +   PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0,
> > 0, 0, 22, 8, 0x0244, 24, 0x0, 0x0, 0, 0x0244, 0, 0,
> > mfgpll_div_table),
> > -   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0x0001,
> > +   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0,
> > 0, 0, 22, 8, 0x0254, 24, 0x0, 0x0, 0, 0x0254, 0, 0),
> > -   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0x0001,
> > +   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0,
> > 0, 0, 22, 8, 0x0264, 24, 0x0, 0x0, 0, 0x0264, 0, 0),
> > -   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0x0001,
> > +   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0,
> > HAVE_RST_BAR, BIT(23), 22, 8, 0x0274, 24, 0x0, 0x0, 0,
> > 0x0274, 0, 0),
> > -   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0x0001,
> > +   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0,
> > 0, 0, 32, 8, 0x02A0, 1, 0x02A8, 0x0014, 0, 0x02A4, 0, 
> > 0x02A0),
> > -   PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0x0001,
> > +   PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0,
> > 0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 
> > 0x02B4),
> >  };
> >
> > --
> > 1.8.1.1.dirty
> > ___
> > linux-arm-kernel mailing list
> > linux-arm-ker...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 
> ___
> Linux-mediatek mailing list
> linux-media...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek



[PATCH v2 06/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT7622

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt7622.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt7622.c 
b/drivers/clk/mediatek/clk-mt7622.c
index ef5947e1..2fdb27a 100644
--- a/drivers/clk/mediatek/clk-mt7622.c
+++ b/drivers/clk/mediatek/clk-mt7622.c
@@ -328,23 +328,23 @@
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0001,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0,
PLL_AO, 21, 0x0204, 24, 0, 0x0204, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0,
HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0x0001,
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0,
HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14),
-   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0x0001,
+   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0,
0, 21, 0x0300, 1, 0, 0x0304, 0),
-   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0x0001,
+   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0,
0, 21, 0x0314, 1, 0, 0x0318, 0),
-   PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0x0001,
+   PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0,
0, 31, 0x0324, 1, 0, 0x0328, 0),
-   PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0x0001,
+   PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0,
0, 31, 0x0334, 1, 0, 0x0338, 0),
-   PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0x0001,
+   PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0,
0, 21, 0x0344, 1, 0, 0x0348, 0),
-   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0x0001,
+   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0,
0, 21, 0x0358, 1, 0, 0x035C, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 01/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT2701

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt2701.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt2701.c 
b/drivers/clk/mediatek/clk-mt2701.c
index 695be0f..462a998 100644
--- a/drivers/clk/mediatek/clk-mt2701.c
+++ b/drivers/clk/mediatek/clk-mt2701.c
@@ -934,31 +934,31 @@ static int mtk_pericfg_init(struct platform_device *pdev)
}
 
 static const struct mtk_pll_data apmixed_plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x200, 0x20c, 0x8001,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x200, 0x20c, 0x8000,
PLL_AO, 21, 0x204, 24, 0x0, 0x204, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x210, 0x21c, 0xf001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x210, 0x21c, 0xf000,
  HAVE_RST_BAR, 21, 0x210, 4, 0x0, 0x214, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x220, 0x22c, 0xf301,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x220, 0x22c, 0xf300,
  HAVE_RST_BAR, 7, 0x220, 4, 0x0, 0x224, 14),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x230, 0x23c, 0x0001, 0,
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x230, 0x23c, 0, 0,
21, 0x230, 4, 0x0, 0x234, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x240, 0x24c, 0x0001, 0,
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x240, 0x24c, 0, 0,
21, 0x240, 4, 0x0, 0x244, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x250, 0x25c, 0x0001, 0,
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x250, 0x25c, 0, 0,
21, 0x250, 4, 0x0, 0x254, 0),
-   PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x270, 0x27c, 0x0001, 0,
+   PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x270, 0x27c, 0, 0,
31, 0x270, 4, 0x0, 0x274, 0),
-   PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x280, 0x28c, 0x0001, 0,
+   PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x280, 0x28c, 0, 0,
31, 0x280, 4, 0x0, 0x284, 0),
-   PLL(CLK_APMIXED_ETHPLL, "ethpll", 0x290, 0x29c, 0x0001, 0,
+   PLL(CLK_APMIXED_ETHPLL, "ethpll", 0x290, 0x29c, 0, 0,
31, 0x290, 4, 0x0, 0x294, 0),
-   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x2a0, 0x2ac, 0x0001, 0,
+   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x2a0, 0x2ac, 0, 0,
31, 0x2a0, 4, 0x0, 0x2a4, 0),
-   PLL(CLK_APMIXED_HADDS2PLL, "hadds2pll", 0x2b0, 0x2bc, 0x0001, 0,
+   PLL(CLK_APMIXED_HADDS2PLL, "hadds2pll", 0x2b0, 0x2bc, 0, 0,
31, 0x2b0, 4, 0x0, 0x2b4, 0),
-   PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x2c0, 0x2cc, 0x0001, 0,
+   PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x2c0, 0x2cc, 0, 0,
31, 0x2c0, 4, 0x0, 0x2c4, 0),
-   PLL(CLK_APMIXED_TVD2PLL, "tvd2pll", 0x2d0, 0x2dc, 0x0001, 0,
+   PLL(CLK_APMIXED_TVD2PLL, "tvd2pll", 0x2d0, 0x2dc, 0, 0,
21, 0x2d0, 4, 0x0, 0x2d4, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 05/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT6797

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt6797.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6797.c 
b/drivers/clk/mediatek/clk-mt6797.c
index 428eb24..32f46e7 100644
--- a/drivers/clk/mediatek/clk-mt6797.c
+++ b/drivers/clk/mediatek/clk-mt6797.c
@@ -634,25 +634,25 @@ static int mtk_infrasys_init(struct platform_device *pdev)
NULL)
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0xF101, PLL_AO,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0xF100, PLL_AO,
21, 0x220, 4, 0x0, 0x224, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0230, 0x023C, 0xFE11, 0, 7,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0230, 0x023C, 0xFE10, 0, 7,
0x230, 4, 0x0, 0x234, 14),
-   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0x0101, 0, 21,
+   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0x0100, 0, 21,
0x244, 24, 0x0, 0x244, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0x0120, 0, 21,
0x250, 4, 0x0, 0x254, 0),
-   PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0260, 0x026C, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0260, 0x026C, 0x0120, 0, 21,
0x260, 4, 0x0, 0x264, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, 0xC121, 0, 21,
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, 0xC120, 0, 21,
0x270, 4, 0x0, 0x274, 0),
-   PLL(CLK_APMIXED_CODECPLL, "codecpll", 0x0290, 0x029C, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_CODECPLL, "codecpll", 0x0290, 0x029C, 0x0120, 0, 21,
0x290, 4, 0x0, 0x294, 0),
-   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x02E4, 0x02F0, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x02E4, 0x02F0, 0x0120, 0, 21,
0x2E4, 4, 0x0, 0x2E8, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0x0131, 0, 31,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0x0130, 0, 31,
0x2A0, 4, 0x2A8, 0x2A4, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x02B4, 0x02C4, 0x0131, 0, 31,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x02B4, 0x02C4, 0x0130, 0, 31,
0x2B4, 4, 0x2BC, 0x2B8, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 04/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT6779

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt6779.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6779.c 
b/drivers/clk/mediatek/clk-mt6779.c
index 6e0d3a1..89e1bd4 100644
--- a/drivers/clk/mediatek/clk-mt6779.c
+++ b/drivers/clk/mediatek/clk-mt6779.c
@@ -1180,33 +1180,33 @@
_pcw_chg_reg, NULL)
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0,
PLL_AO, 0, 22, 8, 0x0204, 24, 0, 0, 0, 0x0204, 0, 0),
-   PLL(CLK_APMIXED_ARMPLL_BL, "armpll_bl", 0x0210, 0x021C, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL_BL, "armpll_bl", 0x0210, 0x021C, 0,
PLL_AO, 0, 22, 8, 0x0214, 24, 0, 0, 0, 0x0214, 0, 0),
-   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x02A0, 0x02AC, BIT(0),
+   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x02A0, 0x02AC, 0,
PLL_AO, 0, 22, 8, 0x02A4, 24, 0, 0, 0, 0x02A4, 0, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, BIT(0),
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0,
(HAVE_RST_BAR), BIT(24), 22, 8, 0x0234, 24, 0, 0, 0,
0x0234, 0, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0240, 0x024C, BIT(0),
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0240, 0x024C, 0,
(HAVE_RST_BAR), BIT(24), 22, 8, 0x0244, 24,
0, 0, 0, 0x0244, 0, 0),
-   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0250, 0x025C, BIT(0),
+   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0250, 0x025C, 0,
0, 0, 22, 8, 0x0254, 24, 0, 0, 0, 0x0254, 0, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0260, 0x026C, BIT(0),
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0260, 0x026C, 0,
0, 0, 22, 8, 0x0264, 24, 0, 0, 0, 0x0264, 0, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, BIT(0),
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, 0,
0, 0, 22, 8, 0x0274, 24, 0, 0, 0, 0x0274, 0, 0),
-   PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x02b0, 0x02bC, BIT(0),
+   PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x02b0, 0x02bC, 0,
(HAVE_RST_BAR), BIT(23), 22, 8, 0x02b4, 24,
0, 0, 0, 0x02b4, 0, 0),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0280, 0x028C, BIT(0),
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0280, 0x028C, 0,
(HAVE_RST_BAR), BIT(23), 22, 8, 0x0284, 24,
0, 0, 0, 0x0284, 0, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x02C0, 0x02D0, BIT(0),
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x02C0, 0x02D0, 0,
0, 0, 32, 8, 0x02C0, 1, 0, 0x14, 0, 0x02C4, 0, 0x2C0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x02D4, 0x02E4, BIT(0),
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x02D4, 0x02E4, 0,
0, 0, 32, 8, 0x02D4, 1, 0, 0x14, 1, 0x02D8, 0, 0x02D4),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 07/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT7629

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt7629.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt7629.c 
b/drivers/clk/mediatek/clk-mt7629.c
index a0ee079..b97e0eb 100644
--- a/drivers/clk/mediatek/clk-mt7629.c
+++ b/drivers/clk/mediatek/clk-mt7629.c
@@ -335,17 +335,17 @@
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0001,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0,
0, 21, 0x0204, 24, 0, 0x0204, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0,
HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0x0001,
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0,
HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14),
-   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0x0001,
+   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0,
0, 21, 0x0300, 1, 0, 0x0304, 0),
-   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0x0001,
+   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0,
0, 21, 0x0314, 1, 0, 0x0318, 0),
-   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0x0001,
+   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0,
0, 21, 0x0358, 1, 0, 0x035C, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 08/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8135

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8135.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8135.c 
b/drivers/clk/mediatek/clk-mt8135.c
index 9b4b645..a1d462f 100644
--- a/drivers/clk/mediatek/clk-mt8135.c
+++ b/drivers/clk/mediatek/clk-mt8135.c
@@ -611,16 +611,16 @@ static void __init mtk_pericfg_init(struct device_node 
*node)
}
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x8001, 0, 21, 
0x204, 24, 0x0, 0x204, 0),
-   PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x8001, 0, 21, 
0x2d0, 24, 0x0, 0x2d0, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf001, 
HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf301, 
HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf001, HAVE_RST_BAR, 
21, 0x254, 6, 0x0, 0x258, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x8001, 0, 21, 
0x278, 6, 0x0, 0x27c, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x8001, 0, 31, 
0x294, 6, 0x0, 0x298, 0),
-   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8,   0x8001, 0, 
21, 0x2b0, 6, 0x0, 0x2b4, 0),
-   PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x8001, 0, 31, 
0x2e8, 6, 0x2f8, 0x2ec, 0),
-   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c,   0x8001, 0, 
21, 0x2b0, 6, 0x0, 0x308, 0),
+   PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x8000, 0, 21, 
0x204, 24, 0x0, 0x204, 0),
+   PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x8000, 0, 21, 
0x2d0, 24, 0x0, 0x2d0, 0),
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf000, 
HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0),
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf300, 
HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9),
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf000, HAVE_RST_BAR, 
21, 0x254, 6, 0x0, 0x258, 0),
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x8000, 0, 21, 
0x278, 6, 0x0, 0x27c, 0),
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x8000, 0, 31, 
0x294, 6, 0x0, 0x298, 0),
+   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8, 0x8000, 0, 21, 
0x2b0, 6, 0x0, 0x2b4, 0),
+   PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x8000, 0, 31, 
0x2e8, 6, 0x2f8, 0x2ec, 0),
+   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x8000, 0, 21, 
0x2b0, 6, 0x0, 0x308, 0),
 };
 
 static void __init mtk_apmixedsys_init(struct device_node *node)
-- 
1.8.1.1.dirty


[PATCH v2 00/13] Clean up the pll_en_bit from en_mask on all the MediaTek clock drivers

2020-11-08 Thread Weiyi Lu
This series is based on v5.10-rc1 and
[v5,07/24] clk: mediatek: Fix asymmetrical PLL enable and disable control[1] in 
Mediatek MT8192 clock support series

[1] 
https://patchwork.kernel.org/project/linux-mediatek/patch/1604887429-29445-8-git-send-email-weiyi...@mediatek.com/

change since v1:
- add patch for MT8167

Weiyi Lu (13):
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT2701
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT2712
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT6765
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT6779
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT6797
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT7622
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT7629
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8135
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8167
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8173
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8183
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8516
  clk: mediatek: use en_mask as a pure div_en_mask

 drivers/clk/mediatek/clk-mt2701.c | 26 +-
 drivers/clk/mediatek/clk-mt2712.c | 30 +++---
 drivers/clk/mediatek/clk-mt6765.c | 20 ++--
 drivers/clk/mediatek/clk-mt6779.c | 24 
 drivers/clk/mediatek/clk-mt6797.c | 20 ++--
 drivers/clk/mediatek/clk-mt7622.c | 18 +-
 drivers/clk/mediatek/clk-mt7629.c | 12 ++--
 drivers/clk/mediatek/clk-mt8135.c | 20 ++--
 drivers/clk/mediatek/clk-mt8167.c | 16 
 drivers/clk/mediatek/clk-mt8173.c | 28 ++--
 drivers/clk/mediatek/clk-mt8183.c | 22 +++---
 drivers/clk/mediatek/clk-mt8516.c | 12 ++--
 drivers/clk/mediatek/clk-pll.c| 12 
 13 files changed, 128 insertions(+), 132 deletions(-)


[PATCH v2 13/13] clk: mediatek: use en_mask as a pure div_en_mask

2020-11-08 Thread Weiyi Lu
Because all pll data has been updated. We no longer allow
en_mask to be a combination of pll_en_bit and div_en_mask.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-pll.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index 11ed5d1..e0b00bc 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -238,7 +238,6 @@ static int mtk_pll_prepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
-   u32 div_en_mask;
 
r = readl(pll->pwr_addr) | CON0_PWR_ON;
writel(r, pll->pwr_addr);
@@ -251,9 +250,8 @@ static int mtk_pll_prepare(struct clk_hw *hw)
r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN;
writel(r, pll->base_addr + REG_CON0);
 
-   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
-   if (div_en_mask) {
-   r = readl(pll->base_addr + REG_CON0) | div_en_mask;
+   if (pll->data->en_mask) {
+   r = readl(pll->base_addr + REG_CON0) | pll->data->en_mask;
writel(r, pll->base_addr + REG_CON0);
}
 
@@ -274,7 +272,6 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
-   u32 div_en_mask;
 
if (pll->data->flags & HAVE_RST_BAR) {
r = readl(pll->base_addr + REG_CON0);
@@ -284,9 +281,8 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 
__mtk_pll_tuner_disable(pll);
 
-   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
-   if (div_en_mask) {
-   r = readl(pll->base_addr + REG_CON0) & ~div_en_mask;
+   if (pll->data->en_mask) {
+   r = readl(pll->base_addr + REG_CON0) & ~pll->data->en_mask;
writel(r, pll->base_addr + REG_CON0);
}
 
-- 
1.8.1.1.dirty


[PATCH v2 03/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT6765

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt6765.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6765.c 
b/drivers/clk/mediatek/clk-mt6765.c
index d77ea5a..ab2ff8f 100644
--- a/drivers/clk/mediatek/clk-mt6765.c
+++ b/drivers/clk/mediatek/clk-mt6765.c
@@ -747,26 +747,26 @@
_pcw_reg, _pcw_shift, NULL) \
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x021C, 0x0228, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x021C, 0x0228, 0,
PLL_AO, 22, 8, 0x0220, 24, 0, 0, 0, 0x0220, 0),
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x020C, 0x0218, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x020C, 0x0218, 0,
PLL_AO, 22, 8, 0x0210, 24, 0, 0, 0, 0x0210, 0),
-   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x022C, 0x0238, BIT(0),
+   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x022C, 0x0238, 0,
PLL_AO, 22, 8, 0x0230, 24, 0, 0, 0, 0x0230, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x023C, 0x0248, BIT(0),
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x023C, 0x0248, 0,
(HAVE_RST_BAR | PLL_AO), 22, 8, 0x0240, 24, 0, 0, 0, 0x0240,
0),
-   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x024C, 0x0258, BIT(0),
+   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x024C, 0x0258, 0,
0, 22, 8, 0x0250, 24, 0, 0, 0, 0x0250, 0),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x025C, 0x0268, BIT(0),
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x025C, 0x0268, 0,
0, 22, 8, 0x0260, 24, 0, 0, 0, 0x0260, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x026C, 0x0278, BIT(0),
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x026C, 0x0278, 0,
HAVE_RST_BAR, 22, 8, 0x0270, 24, 0, 0, 0, 0x0270, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x027C, 0x0288, BIT(0),
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x027C, 0x0288, 0,
0, 22, 8, 0x0280, 24, 0, 0, 0, 0x0280, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x028C, 0x029C, BIT(0),
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x028C, 0x029C, 0,
0, 32, 8, 0x0290, 24, 0x0040, 0x000C, 0, 0x0294, 0),
-   PLL(CLK_APMIXED_MPLL, "mpll", 0x02A0, 0x02AC, BIT(0),
+   PLL(CLK_APMIXED_MPLL, "mpll", 0x02A0, 0x02AC, 0,
PLL_AO, 22, 8, 0x02A4, 24, 0, 0, 0, 0x02A4, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 11/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8183

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8183.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8183.c 
b/drivers/clk/mediatek/clk-mt8183.c
index 5046852..608108c 100644
--- a/drivers/clk/mediatek/clk-mt8183.c
+++ b/drivers/clk/mediatek/clk-mt8183.c
@@ -1121,34 +1121,34 @@
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0x0001,
+   PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0,
HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0204, 24, 0x0, 0x0, 0,
0x0204, 0, 0, armpll_div_table),
-   PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0x0001,
+   PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0,
HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0214, 24, 0x0, 0x0, 0,
0x0214, 0, 0, armpll_div_table),
-   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0x0001,
+   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0,
HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0294, 24, 0x0, 0x0, 0,
0x0294, 0, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0,
HAVE_RST_BAR, BIT(24), 22, 8, 0x0224, 24, 0x0, 0x0, 0,
0x0224, 0, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0x0001,
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0,
HAVE_RST_BAR, BIT(24), 22, 8, 0x0234, 24, 0x0, 0x0, 0,
0x0234, 0, 0),
-   PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0x0001,
+   PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0,
0, 0, 22, 8, 0x0244, 24, 0x0, 0x0, 0, 0x0244, 0, 0,
mfgpll_div_table),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0x0001,
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0,
0, 0, 22, 8, 0x0254, 24, 0x0, 0x0, 0, 0x0254, 0, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0x0001,
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0,
0, 0, 22, 8, 0x0264, 24, 0x0, 0x0, 0, 0x0264, 0, 0),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0x0001,
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0,
HAVE_RST_BAR, BIT(23), 22, 8, 0x0274, 24, 0x0, 0x0, 0,
0x0274, 0, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0x0001,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0,
0, 0, 32, 8, 0x02A0, 1, 0x02A8, 0x0014, 0, 0x02A4, 0, 0x02A0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0x0001,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0,
0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 0x02B4),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 09/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8167

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8167.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8167.c 
b/drivers/clk/mediatek/clk-mt8167.c
index e5ea10e..180e24a 100644
--- a/drivers/clk/mediatek/clk-mt8167.c
+++ b/drivers/clk/mediatek/clk-mt8167.c
@@ -1016,21 +1016,21 @@ static void __init mtk_infracfg_init(struct device_node 
*node)
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0x0001, 0,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0,
21, 0x0104, 24, 0, 0x0104, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0,
HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x3001,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x3000,
HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0),
-   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0x0001, 0,
+   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0,
21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0x0001, 0,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0,
31, 0x0180, 1, 0x0194, 0x0184, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0x0001, 0,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0,
31, 0x01A0, 1, 0x01B4, 0x01A4, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x01C0, 0x01D0, 0x0001, 0,
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x01C0, 0x01D0, 0, 0,
21, 0x01C4, 24, 0, 0x01C4, 0),
-   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x01E0, 0x01F0, 0x0001, 0,
+   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x01E0, 0x01F0, 0, 0,
21, 0x01E4, 24, 0, 0x01E4, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 12/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8516

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8516.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8516.c 
b/drivers/clk/mediatek/clk-mt8516.c
index 9d4261e..ec215e5 100644
--- a/drivers/clk/mediatek/clk-mt8516.c
+++ b/drivers/clk/mediatek/clk-mt8516.c
@@ -770,17 +770,17 @@ static void __init mtk_infracfg_init(struct device_node 
*node)
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0x0001, 0,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0,
21, 0x0104, 24, 0, 0x0104, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0,
HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x3001,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x3000,
HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0),
-   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0x0001, 0,
+   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0,
21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0x0001, 0,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0,
31, 0x0180, 1, 0x0194, 0x0184, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0x0001, 0,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0,
31, 0x01A0, 1, 0x01B4, 0x01A4, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v2 10/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8173

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8173.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c 
b/drivers/clk/mediatek/clk-mt8173.c
index 8f898ac..f309e78 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -972,20 +972,20 @@ struct mtk_clk_usb {
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMCA15PLL, "armca15pll", 0x200, 0x20c, 0x0001, 0, 
21, 0x204, 24, 0x0, 0x204, 0),
-   PLL(CLK_APMIXED_ARMCA7PLL, "armca7pll", 0x210, 0x21c, 0x0001, 0, 
21, 0x214, 24, 0x0, 0x214, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x220, 0x22c, 0xf101, 
HAVE_RST_BAR, 21, 0x220, 4, 0x0, 0x224, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x230, 0x23c, 0xfe01, 
HAVE_RST_BAR, 7, 0x230, 4, 0x0, 0x234, 14),
-   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x240, 0x24c, 0x0001, 0, 21, 
0x244, 24, 0x0, 0x244, 0, mmpll_div_table),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x250, 0x25c, 0x0001, 0, 21, 
0x250, 4, 0x0, 0x254, 0),
-   PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x260, 0x26c, 0x0001, 0, 21, 
0x260, 4, 0x0, 0x264, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x270, 0x27c, 0x0001, 0, 21, 
0x270, 4, 0x0, 0x274, 0),
-   PLL(CLK_APMIXED_MPLL, "mpll", 0x280, 0x28c, 0x0001, 0, 21, 0x280, 
4, 0x0, 0x284, 0),
-   PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x290, 0x29c, 0x0001, 0, 
21, 0x290, 4, 0x0, 0x294, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x2a0, 0x2b0, 0x0001, 0, 31, 0x2a0, 
4, 0x2a4, 0x2a4, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x2b4, 0x2c4, 0x0001, 0, 31, 0x2b4, 
4, 0x2b8, 0x2b8, 0),
-   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2d0, 0x2dc, 0x0001, 0, 21, 
0x2d0, 4, 0x0, 0x2d4, 0),
-   PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x2f0, 0x2fc, 0x0001, 0, 21, 
0x2f0, 4, 0x0, 0x2f4, 0),
+   PLL(CLK_APMIXED_ARMCA15PLL, "armca15pll", 0x200, 0x20c, 0, 0, 21, 
0x204, 24, 0x0, 0x204, 0),
+   PLL(CLK_APMIXED_ARMCA7PLL, "armca7pll", 0x210, 0x21c, 0, 0, 21, 0x214, 
24, 0x0, 0x214, 0),
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x220, 0x22c, 0xf100, 
HAVE_RST_BAR, 21, 0x220, 4, 0x0, 0x224, 0),
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x230, 0x23c, 0xfe00, 
HAVE_RST_BAR, 7, 0x230, 4, 0x0, 0x234, 14),
+   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x240, 0x24c, 0, 0, 21, 0x244, 24, 
0x0, 0x244, 0, mmpll_div_table),
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x250, 0x25c, 0, 0, 21, 0x250, 4, 
0x0, 0x254, 0),
+   PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x260, 0x26c, 0, 0, 21, 0x260, 4, 
0x0, 0x264, 0),
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x270, 0x27c, 0, 0, 21, 0x270, 4, 
0x0, 0x274, 0),
+   PLL(CLK_APMIXED_MPLL, "mpll", 0x280, 0x28c, 0, 0, 21, 0x280, 4, 0x0, 
0x284, 0),
+   PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x290, 0x29c, 0, 0, 21, 0x290, 
4, 0x0, 0x294, 0),
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x2a0, 0x2b0, 0, 0, 31, 0x2a0, 4, 
0x2a4, 0x2a4, 0),
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x2b4, 0x2c4, 0, 0, 31, 0x2b4, 4, 
0x2b8, 0x2b8, 0),
+   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2d0, 0x2dc, 0, 0, 21, 0x2d0, 4, 
0x0, 0x2d4, 0),
+   PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x2f0, 0x2fc, 0, 0, 21, 0x2f0, 4, 
0x0, 0x2f4, 0),
 };
 
 static void __init mtk_apmixedsys_init(struct device_node *node)
-- 
1.8.1.1.dirty


[PATCH v2 02/13] clk: mediatek: Clean up the pll_en_bit from en_mask on MT2712

2020-11-08 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt2712.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt2712.c 
b/drivers/clk/mediatek/clk-mt2712.c
index a3bd9a1..fd81162 100644
--- a/drivers/clk/mediatek/clk-mt2712.c
+++ b/drivers/clk/mediatek/clk-mt2712.c
@@ -1222,38 +1222,38 @@
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf101,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf100,
HAVE_RST_BAR, 31, 0x0230, 4, 0, 0, 0, 0x0234, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000101,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000100,
HAVE_RST_BAR, 31, 0x0240, 4, 0, 0, 0, 0x0244, 0),
-   PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc101,
+   PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc100,
0, 31, 0x0320, 4, 0, 0, 0, 0x0324, 0),
-   PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x0101,
+   PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x0100,
0, 31, 0x0280, 4, 0, 0, 0, 0x0284, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x0101,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x0100,
0, 31, 0x0330, 4, 0x0338, 0x0014, 0, 0x0334, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x0101,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x0100,
0, 31, 0x0350, 4, 0x0358, 0x0014, 1, 0x0354, 0),
-   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x0101,
+   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x0100,
0, 31, 0x0370, 4, 0, 0, 0, 0x0374, 0),
-   PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x0101,
+   PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x0100,
0, 31, 0x0390, 4, 0, 0, 0, 0x0394, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x0101,
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x0100,
0, 31, 0x0270, 4, 0, 0, 0, 0x0274, 0),
-   PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x0101,
+   PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x0100,
0, 31, 0x0410, 4, 0, 0, 0, 0x0414, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc101,
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc100,
0, 31, 0x0290, 4, 0, 0, 0, 0x0294, 0),
-   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x0101,
+   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x0100,
0, 31, 0x0250, 4, 0, 0, 0, 0x0254, 0,
mmpll_div_table),
-   PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf101,
+   PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf100,
HAVE_RST_BAR, 31, 0x0100, 4, 0, 0, 0, 0x0104, 0,
armca35pll_div_table),
-   PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x0101,
+   PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x0100,
0, 31, 0x0210, 4, 0, 0, 0, 0x0214, 0,
armca72pll_div_table),
-   PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc101,
+   PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc100,
0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH v5 07/24] clk: mediatek: Fix asymmetrical PLL enable and disable control

2020-11-08 Thread Weiyi Lu
In fact, the en_mask is a combination of divider enable mask
and pll enable bit(bit0).
Before this patch, we enabled both divider mask and bit0 in prepare(),
but only cleared the bit0 in unprepare().
In the future, we hope en_mask will only be used as divider enable mask.
The enable register(CON0) will be set in 2 steps:
first is divider mask, and then bit0 during prepare(), and vice versa.
But considering backward compatibility, at this stage we allow en_mask
to be a combination or a pure divider enable mask.
And then we will make en_mask a pure divider enable mask in another
following patch series.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-pll.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index f440f2cd..11ed5d1 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -238,6 +238,7 @@ static int mtk_pll_prepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
+   u32 div_en_mask;
 
r = readl(pll->pwr_addr) | CON0_PWR_ON;
writel(r, pll->pwr_addr);
@@ -247,10 +248,15 @@ static int mtk_pll_prepare(struct clk_hw *hw)
writel(r, pll->pwr_addr);
udelay(1);
 
-   r = readl(pll->base_addr + REG_CON0);
-   r |= pll->data->en_mask;
+   r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN;
writel(r, pll->base_addr + REG_CON0);
 
+   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
+   if (div_en_mask) {
+   r = readl(pll->base_addr + REG_CON0) | div_en_mask;
+   writel(r, pll->base_addr + REG_CON0);
+   }
+
__mtk_pll_tuner_enable(pll);
 
udelay(20);
@@ -268,6 +274,7 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
+   u32 div_en_mask;
 
if (pll->data->flags & HAVE_RST_BAR) {
r = readl(pll->base_addr + REG_CON0);
@@ -277,8 +284,13 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 
__mtk_pll_tuner_disable(pll);
 
-   r = readl(pll->base_addr + REG_CON0);
-   r &= ~CON0_BASE_EN;
+   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
+   if (div_en_mask) {
+   r = readl(pll->base_addr + REG_CON0) & ~div_en_mask;
+   writel(r, pll->base_addr + REG_CON0);
+   }
+
+   r = readl(pll->base_addr + REG_CON0) & ~CON0_BASE_EN;
writel(r, pll->base_addr + REG_CON0);
 
r = readl(pll->pwr_addr) | CON0_ISO_EN;
-- 
1.8.1.1.dirty


[PATCH v5 11/24] clk: mediatek: Add MT8192 audio clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 audio clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |   6 ++
 drivers/clk/mediatek/Makefile |   1 +
 drivers/clk/mediatek/clk-mt8192-aud.c | 118 ++
 3 files changed, 125 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-aud.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index f628efd..1a8b0c1 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -497,6 +497,12 @@ config COMMON_CLK_MT8192
help
  This driver supports MediaTek MT8192 basic clocks.
 
+config COMMON_CLK_MT8192_AUDSYS
+   bool "Clock driver for MediaTek MT8192 audsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 audsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index fcde421..1d0f2e8 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -68,5 +68,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_MMSYS) += clk-mt8183-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
+obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-aud.c 
b/drivers/clk/mediatek/clk-mt8192-aud.c
new file mode 100644
index 000..b38f5a5
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-aud.c
@@ -0,0 +1,118 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs aud0_cg_regs = {
+   .set_ofs = 0x0,
+   .clr_ofs = 0x0,
+   .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs aud1_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x4,
+   .sta_ofs = 0x4,
+};
+
+static const struct mtk_gate_regs aud2_cg_regs = {
+   .set_ofs = 0x8,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x8,
+};
+
+#define GATE_AUD0(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+#define GATE_AUD1(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+#define GATE_AUD2(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+static const struct mtk_gate aud_clks[] = {
+   /* AUD0 */
+   GATE_AUD0(CLK_AUD_AFE, "aud_afe", "audio_sel", 2),
+   GATE_AUD0(CLK_AUD_22M, "aud_22m", "aud_engen1_sel", 8),
+   GATE_AUD0(CLK_AUD_24M, "aud_24m", "aud_engen2_sel", 9),
+   GATE_AUD0(CLK_AUD_APLL2_TUNER, "aud_apll2_tuner", "aud_engen2_sel", 18),
+   GATE_AUD0(CLK_AUD_APLL_TUNER, "aud_apll_tuner", "aud_engen1_sel", 19),
+   GATE_AUD0(CLK_AUD_TDM, "aud_tdm", "aud_1_sel", 20),
+   GATE_AUD0(CLK_AUD_ADC, "aud_adc", "audio_sel", 24),
+   GATE_AUD0(CLK_AUD_DAC, "aud_dac", "audio_sel", 25),
+   GATE_AUD0(CLK_AUD_DAC_PREDIS, "aud_dac_predis", "audio_sel", 26),
+   GATE_AUD0(CLK_AUD_TML, "aud_tml", "audio_sel", 27),
+   GATE_AUD0(CLK_AUD_NLE, "aud_nle", "audio_sel", 28),
+   /* AUD1 */
+   GATE_AUD1(CLK_AUD_I2S1_B, "aud_i2s1_b", "audio_sel", 4),
+   GATE_AUD1(CLK_AUD_I2S2_B, "aud_i2s2_b", "audio_sel", 5),
+   GATE_AUD1(CLK_AUD_I2S3_B, "aud_i2s3_b", "audio_sel", 6),
+   GATE_AUD1(CLK_AUD_I2S4_B, "aud_i2s4_b", "audio_sel", 7),
+   GATE_AUD1(CLK_AUD_CONNSYS_I2S_ASRC, "aud_connsys_i2s_asrc", 
"audio_sel", 12),
+   GATE_AUD1(CLK_AUD_GENERAL1_ASRC, "aud_general1_asrc", "audio_sel", 13),
+   GATE_AUD1(CLK_AUD_GENERAL2_ASRC, "aud_general2_asrc", "audio_sel", 14),
+   GATE_AUD1(CLK_AUD_DAC_HIRES, "aud_dac_hires", "audio_h_sel", 15),
+   GATE_AUD1(CLK_AUD_ADC_HIRES, "aud_adc_hires", "audio_h_sel", 16),
+   GATE_AUD1(CLK_AUD_ADC_HIRES_TML, "aud_adc_hires_tml", "audio_h_sel", 
17),
+   GATE_AUD1(CLK_AUD_ADDA6_ADC, "aud_adda6_adc", "audio_sel", 20),
+   GATE_AUD1(CLK_AUD_ADDA6_ADC_HIRES, "aud_adda6_adc_hires", 
"audio_h_sel", 21),
+   GATE_AUD1(CLK_AUD_3RD_DAC, "

[PATCH v5 14/24] clk: mediatek: Add MT8192 imp i2c wrapper clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 imp i2c wrapper clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |   6 ++
 drivers/clk/mediatek/Makefile  |   1 +
 drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c | 119 +
 3 files changed, 126 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index eb549f8..8acc7d6 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -515,6 +515,12 @@ config COMMON_CLK_MT8192_IMGSYS
help
  This driver supports MediaTek MT8192 imgsys and imgsys2 clocks.
 
+config COMMON_CLK_MT8192_IMP_IIC_WRAP
+   bool "Clock driver for MediaTek MT8192 imp_iic_wrap"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 imp_iic_wrap clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 91392cb..3798162 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -71,5 +71,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
+obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c 
b/drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
new file mode 100644
index 000..7acb903
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs imp_iic_wrap_cg_regs = {
+   .set_ofs = 0xe08,
+   .clr_ofs = 0xe04,
+   .sta_ofs = 0xe00,
+};
+
+#define GATE_IMP_IIC_WRAP(_id, _name, _parent, _shift) \
+   GATE_MTK_FLAGS(_id, _name, _parent, _iic_wrap_cg_regs, _shift,  
\
+   _clk_gate_ops_setclr, CLK_OPS_PARENT_ENABLE)
+
+static const struct mtk_gate imp_iic_wrap_c_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C10, "imp_iic_wrap_c_i2c10", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C11, "imp_iic_wrap_c_i2c11", 
"infra_i2c0", 1),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C12, "imp_iic_wrap_c_i2c12", 
"infra_i2c0", 2),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C13, "imp_iic_wrap_c_i2c13", 
"infra_i2c0", 3),
+};
+
+static const struct mtk_gate imp_iic_wrap_e_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_E_I2C3, "imp_iic_wrap_e_i2c3", 
"infra_i2c0", 0),
+};
+
+static const struct mtk_gate imp_iic_wrap_n_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C0, "imp_iic_wrap_n_i2c0", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C6, "imp_iic_wrap_n_i2c6", 
"infra_i2c0", 1),
+};
+
+static const struct mtk_gate imp_iic_wrap_s_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C7, "imp_iic_wrap_s_i2c7", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C8, "imp_iic_wrap_s_i2c8", 
"infra_i2c0", 1),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C9, "imp_iic_wrap_s_i2c9", 
"infra_i2c0", 2),
+};
+
+static const struct mtk_gate imp_iic_wrap_w_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_I2C5, "imp_iic_wrap_w_i2c5", 
"infra_i2c0", 0),
+};
+
+static const struct mtk_gate imp_iic_wrap_ws_clks[] = {
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C1, "imp_iic_wrap_ws_i2c1", 
"infra_i2c0", 0),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C2, "imp_iic_wrap_ws_i2c2", 
"infra_i2c0", 1),
+   GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C4, "imp_iic_wrap_ws_i2c4", 
"infra_i2c0", 2),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_c_desc = {
+   .clks = imp_iic_wrap_c_clks,
+   .num_clks = ARRAY_SIZE(imp_iic_wrap_c_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_e_desc = {
+   .clks = imp_iic_wrap_e_clks,
+   .num_clks = ARRAY_SIZE(imp_iic_wrap_e_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_n_desc = {
+   .clks = imp_iic_wrap_n_clks,
+   .num_clks = ARRAY_SIZE(imp_iic_wrap_n_clks),
+};
+
+static const struct mtk_clk_desc imp_iic_wrap_s_desc = {
+   .clks = imp_iic_w

[PATCH v5 01/24] dt-bindings: ARM: Mediatek: Add new document bindings of imp i2c wrapper controller

2020-11-08 Thread Weiyi Lu
This patch adds the new binding documentation of imp i2c wrapper controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../arm/mediatek/mediatek,imp_iic_wrap.yaml| 78 ++
 1 file changed, 78 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
new file mode 100644
index 000..5d0cf37
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,imp_iic_wrap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek IMP I2C Wrapper Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek imp i2c wrapper controller provides functional configurations 
and clocks to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-imp_iic_wrap_c
+  - mediatek,mt8192-imp_iic_wrap_e
+  - mediatek,mt8192-imp_iic_wrap_s
+  - mediatek,mt8192-imp_iic_wrap_ws
+  - mediatek,mt8192-imp_iic_wrap_w
+  - mediatek,mt8192-imp_iic_wrap_n
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+imp_iic_wrap_c: syscon@11007000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_c", "syscon";
+reg = <0 0x11007000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_e: syscon@11cb1000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_e", "syscon";
+reg = <0 0x11cb1000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_s: syscon@11d03000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_s", "syscon";
+reg = <0 0x11d03000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_ws: syscon@11d23000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_ws", "syscon";
+reg = <0 0x11d23000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_w: syscon@11e01000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_w", "syscon";
+reg = <0 0x11e01000 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+imp_iic_wrap_n: syscon@11f02000 {
+compatible = "mediatek,mt8192-imp_iic_wrap_n", "syscon";
+reg = <0 0x11f02000 0 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty


[PATCH v5 17/24] clk: mediatek: Add MT8192 mfgcfg clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 mfgcfg clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 +
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-mfg.c | 50 +++
 3 files changed, 57 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-mfg.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index a0a2efa9..3db8670 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -533,6 +533,12 @@ config COMMON_CLK_MT8192_MDPSYS
help
  This driver supports MediaTek MT8192 mdpsys clocks.
 
+config COMMON_CLK_MT8192_MFGCFG
+   bool "Clock driver for MediaTek MT8192 mfgcfg"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 mfgcfg clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 7b258cb..024841a 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -74,5 +74,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-mfg.c 
b/drivers/clk/mediatek/clk-mt8192-mfg.c
new file mode 100644
index 000..510be98
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-mfg.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs mfg_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_MFG(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate mfg_clks[] = {
+   GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_pll_sel", 0),
+};
+
+static const struct mtk_clk_desc mfg_desc = {
+   .clks = mfg_clks,
+   .num_clks = ARRAY_SIZE(mfg_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_mfg[] = {
+   {
+   .compatible = "mediatek,mt8192-mfgcfg",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_mfg_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-mfg",
+   .of_match_table = of_match_clk_mt8192_mfg,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_mfg_drv);
-- 
1.8.1.1.dirty


[PATCH v5 15/24] clk: mediatek: Add MT8192 ipesys clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 ipesys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-ipe.c | 57 +++
 3 files changed, 64 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-ipe.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 8acc7d6..c6bc618 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -521,6 +521,12 @@ config COMMON_CLK_MT8192_IMP_IIC_WRAP
help
  This driver supports MediaTek MT8192 imp_iic_wrap clocks.
 
+config COMMON_CLK_MT8192_IPESYS
+   bool "Clock driver for MediaTek MT8192 ipesys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 ipesys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 3798162..33dc974 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -72,5 +72,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
+obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-ipe.c 
b/drivers/clk/mediatek/clk-mt8192-ipe.c
new file mode 100644
index 000..218e688
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-ipe.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs ipe_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_IPE(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate ipe_clks[] = {
+   GATE_IPE(CLK_IPE_LARB19, "ipe_larb19", "ipe_sel", 0),
+   GATE_IPE(CLK_IPE_LARB20, "ipe_larb20", "ipe_sel", 1),
+   GATE_IPE(CLK_IPE_SMI_SUBCOM, "ipe_smi_subcom", "ipe_sel", 2),
+   GATE_IPE(CLK_IPE_FD, "ipe_fd", "ipe_sel", 3),
+   GATE_IPE(CLK_IPE_FE, "ipe_fe", "ipe_sel", 4),
+   GATE_IPE(CLK_IPE_RSC, "ipe_rsc", "ipe_sel", 5),
+   GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "ipe_sel", 6),
+   GATE_IPE(CLK_IPE_GALS, "ipe_gals", "ipe_sel", 8),
+};
+
+static const struct mtk_clk_desc ipe_desc = {
+   .clks = ipe_clks,
+   .num_clks = ARRAY_SIZE(ipe_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_ipe[] = {
+   {
+   .compatible = "mediatek,mt8192-ipesys",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_ipe_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-ipe",
+   .of_match_table = of_match_clk_mt8192_ipe,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_ipe_drv);
-- 
1.8.1.1.dirty


[PATCH v5 06/24] clk: mediatek: Add dt-bindings of MT8192 clocks

2020-11-08 Thread Weiyi Lu
Add MT8192 clock dt-bindings, include topckgen, apmixedsys,
infracfg, pericfg and subsystem clocks.

Signed-off-by: Weiyi Lu 
---
 include/dt-bindings/clock/mt8192-clk.h | 592 +
 1 file changed, 592 insertions(+)
 create mode 100644 include/dt-bindings/clock/mt8192-clk.h

diff --git a/include/dt-bindings/clock/mt8192-clk.h 
b/include/dt-bindings/clock/mt8192-clk.h
new file mode 100644
index 000..50b1ba2
--- /dev/null
+++ b/include/dt-bindings/clock/mt8192-clk.h
@@ -0,0 +1,592 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2020 MediaTek Inc.
+ * Author: Weiyi Lu 
+ */
+
+#ifndef _DT_BINDINGS_CLK_MT8192_H
+#define _DT_BINDINGS_CLK_MT8192_H
+
+/* TOPCKGEN */
+
+#define CLK_TOP_AXI_SEL0
+#define CLK_TOP_SPM_SEL1
+#define CLK_TOP_SCP_SEL2
+#define CLK_TOP_BUS_AXIMEM_SEL 3
+#define CLK_TOP_DISP_SEL   4
+#define CLK_TOP_MDP_SEL5
+#define CLK_TOP_IMG1_SEL   6
+#define CLK_TOP_IMG2_SEL   7
+#define CLK_TOP_IPE_SEL8
+#define CLK_TOP_DPE_SEL9
+#define CLK_TOP_CAM_SEL10
+#define CLK_TOP_CCU_SEL11
+#define CLK_TOP_DSP7_SEL   12
+#define CLK_TOP_MFG_REF_SEL13
+#define CLK_TOP_MFG_PLL_SEL14
+#define CLK_TOP_CAMTG_SEL  15
+#define CLK_TOP_CAMTG2_SEL 16
+#define CLK_TOP_CAMTG3_SEL 17
+#define CLK_TOP_CAMTG4_SEL 18
+#define CLK_TOP_CAMTG5_SEL 19
+#define CLK_TOP_CAMTG6_SEL 20
+#define CLK_TOP_UART_SEL   21
+#define CLK_TOP_SPI_SEL22
+#define CLK_TOP_MSDC50_0_H_SEL 23
+#define CLK_TOP_MSDC50_0_SEL   24
+#define CLK_TOP_MSDC30_1_SEL   25
+#define CLK_TOP_MSDC30_2_SEL   26
+#define CLK_TOP_AUDIO_SEL  27
+#define CLK_TOP_AUD_INTBUS_SEL 28
+#define CLK_TOP_PWRAP_ULPOSC_SEL   29
+#define CLK_TOP_ATB_SEL30
+#define CLK_TOP_SSPM_SEL   31
+#define CLK_TOP_DPI_SEL32
+#define CLK_TOP_SCAM_SEL   33
+#define CLK_TOP_DISP_PWM_SEL   34
+#define CLK_TOP_USB_TOP_SEL35
+#define CLK_TOP_SSUSB_XHCI_SEL 36
+#define CLK_TOP_I2C_SEL37
+#define CLK_TOP_SENINF_SEL 38
+#define CLK_TOP_SENINF1_SEL39
+#define CLK_TOP_SENINF2_SEL40
+#define CLK_TOP_SENINF3_SEL41
+#define CLK_TOP_TL_SEL 42
+#define CLK_TOP_DXCC_SEL   43
+#define CLK_TOP_AUD_ENGEN1_SEL 44
+#define CLK_TOP_AUD_ENGEN2_SEL 45
+#define CLK_TOP_AES_UFSFDE_SEL 46
+#define CLK_TOP_UFS_SEL47
+#define CLK_TOP_AUD_1_SEL  48
+#define CLK_TOP_AUD_2_SEL  49
+#define CLK_TOP_ADSP_SEL   50
+#define CLK_TOP_DPMAIF_MAIN_SEL51
+#define CLK_TOP_VENC_SEL   52
+#define CLK_TOP_VDEC_SEL   53
+#define CLK_TOP_CAMTM_SEL  54
+#define CLK_TOP_PWM_SEL55
+#define CLK_TOP_AUDIO_H_SEL56
+#define CLK_TOP_SPMI_MST_SEL   57
+#define CLK_TOP_AES_MSDCFDE_SEL58
+#define CLK_TOP_MCUPM_SEL  59
+#define CLK_TOP_SFLASH_SEL 60
+#define CLK_TOP_APLL_I2S0_M_SEL61
+#define CLK_TOP_APLL_I2S1_M_SEL62
+#define CLK_TOP_APLL_I2S2_M_SEL63
+#define CLK_TOP_APLL_I2S3_M_SEL64
+#define CLK_TOP_APLL_I2S4_M_SEL65
+#define CLK_TOP_APLL_I2S5_M_SEL66
+#define CLK_TOP_APLL_I2S6_M_SEL67
+#define CLK_TOP_APLL_I2S7_M_SEL68
+#define CLK_TOP_APLL_I2S8_M_SEL69
+#define CLK_TOP_APLL_I2S9_M_SEL70
+#define CLK_TOP_MAINPLL_D3 71
+#define CLK_TOP_MAINPLL_D4 72
+#define CLK_TOP_MAINPLL_D4_D2  73
+#define CLK_TOP_MAINPLL_D4_D4  74
+#define CLK_TOP_MAINPLL_D4_D8  75
+#define CLK_TOP_MAINPLL_D4_D16 76
+#define CLK_TOP_MAINPLL_D5 77
+#define CLK_TOP_MAINPLL_D5_D2  78
+#define CLK_TOP_MAINPLL_D5_D4  79
+#define CLK_TOP_MAINPLL_D5_D8  80
+#define CLK_TOP_MAINPLL_D6 81
+#define CLK_TOP_MAINPLL_D6_D2  82
+#define CLK_TOP_MAINPLL_D6_D4  83
+#define CLK_TOP_MAINPLL_D7 84
+#define CLK_TOP_MAINPLL_D7_D2  85
+#define CLK_TOP_MAINPLL_D7_D4  86
+#define CLK_TOP_MAINPLL_D7_D8  87
+#define CLK_TOP_UNIVPLL_D3 88
+#define CLK_TOP_UNIVPLL_D4 89
+#define CLK_TOP_UNIVPLL_D4_D2  90
+#define CLK_TOP_UNIVPLL_D4_D4  91
+#define CLK_TOP_UNIVPLL_D4_D8  92
+#define CLK_TOP_UNIVPLL_D5 93
+#define CLK_TOP_UNIVPLL_D5_D2

[PATCH v5 03/24] dt-bindings: ARM: Mediatek: Add new document bindings of msdc controller

2020-11-08 Thread Weiyi Lu
This patch adds the new binding documentation of msdc controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,msdc.yaml   | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml
new file mode 100644
index 000..5aa9536
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,msdc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MSDC Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek msdc controller provides functional configurations and clocks 
to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-msdc
+  - mediatek,mt8192-msdc_top
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+msdc: syscon@11f6 {
+compatible = "mediatek,mt8192-msdc", "syscon";
+reg = <0 0x11f6 0 0x1000>;
+#clock-cells = <1>;
+};
+
+  - |
+msdc_top: syscon@11f1 {
+compatible = "mediatek,mt8192-msdc_top", "syscon";
+reg = <0 0x11f1 0 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty


[PATCH v5 18/24] clk: mediatek: Add MT8192 mmsys clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 mmsys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig |   6 ++
 drivers/clk/mediatek/Makefile|   1 +
 drivers/clk/mediatek/clk-mt8192-mm.c | 108 +++
 3 files changed, 115 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-mm.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 3db8670..bc92611 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -539,6 +539,12 @@ config COMMON_CLK_MT8192_MFGCFG
help
  This driver supports MediaTek MT8192 mfgcfg clocks.
 
+config COMMON_CLK_MT8192_MMSYS
+   bool "Clock driver for MediaTek MT8192 mmsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 mmsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 024841a..838bb01 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -75,5 +75,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += 
clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-mm.c 
b/drivers/clk/mediatek/clk-mt8192-mm.c
new file mode 100644
index 000..dfdfb21
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-mm.c
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs mm0_cg_regs = {
+   .set_ofs = 0x104,
+   .clr_ofs = 0x108,
+   .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs mm1_cg_regs = {
+   .set_ofs = 0x114,
+   .clr_ofs = 0x118,
+   .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs mm2_cg_regs = {
+   .set_ofs = 0x1a4,
+   .clr_ofs = 0x1a8,
+   .sta_ofs = 0x1a0,
+};
+
+#define GATE_MM0(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+#define GATE_MM1(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+#define GATE_MM2(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate mm_clks[] = {
+   /* MM0 */
+   GATE_MM0(CLK_MM_DISP_MUTEX0, "mm_disp_mutex0", "disp_sel", 0),
+   GATE_MM0(CLK_MM_DISP_CONFIG, "mm_disp_config", "disp_sel", 1),
+   GATE_MM0(CLK_MM_DISP_OVL0, "mm_disp_ovl0", "disp_sel", 2),
+   GATE_MM0(CLK_MM_DISP_RDMA0, "mm_disp_rdma0", "disp_sel", 3),
+   GATE_MM0(CLK_MM_DISP_OVL0_2L, "mm_disp_ovl0_2l", "disp_sel", 4),
+   GATE_MM0(CLK_MM_DISP_WDMA0, "mm_disp_wdma0", "disp_sel", 5),
+   GATE_MM0(CLK_MM_DISP_UFBC_WDMA0, "mm_disp_ufbc_wdma0", "disp_sel", 6),
+   GATE_MM0(CLK_MM_DISP_RSZ0, "mm_disp_rsz0", "disp_sel", 7),
+   GATE_MM0(CLK_MM_DISP_AAL0, "mm_disp_aal0", "disp_sel", 8),
+   GATE_MM0(CLK_MM_DISP_CCORR0, "mm_disp_ccorr0", "disp_sel", 9),
+   GATE_MM0(CLK_MM_DISP_DITHER0, "mm_disp_dither0", "disp_sel", 10),
+   GATE_MM0(CLK_MM_SMI_INFRA, "mm_smi_infra", "disp_sel", 11),
+   GATE_MM0(CLK_MM_DISP_GAMMA0, "mm_disp_gamma0", "disp_sel", 12),
+   GATE_MM0(CLK_MM_DISP_POSTMASK0, "mm_disp_postmask0", "disp_sel", 13),
+   GATE_MM0(CLK_MM_DISP_DSC_WRAP0, "mm_disp_dsc_wrap0", "disp_sel", 14),
+   GATE_MM0(CLK_MM_DSI0, "mm_dsi0", "disp_sel", 15),
+   GATE_MM0(CLK_MM_DISP_COLOR0, "mm_disp_color0", "disp_sel", 16),
+   GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "disp_sel", 17),
+   GATE_MM0(CLK_MM_DISP_FAKE_ENG0, "mm_disp_fake_eng0", "disp_sel", 18),
+   GATE_MM0(CLK_MM_DISP_FAKE_ENG1, "mm_disp_fake_eng1", "disp_sel", 19),
+   GATE_MM0(CLK_MM_MDP_TDSHP4, "mm_mdp_tdshp4", "disp_sel", 20),
+   GATE_MM0(CLK_MM_MDP_RSZ4, "mm_mdp_rsz4", "disp_sel", 21),
+   GATE_MM0(CLK_MM_MDP_AAL4, "mm_mdp_aal4", "disp_sel", 22),
+   GATE_MM0(CLK_MM_MDP_HD

[PATCH v5 02/24] dt-bindings: ARM: Mediatek: Add new document bindings of mdpsys controller

2020-11-08 Thread Weiyi Lu
This patch adds the new binding documentation of mdpsys controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,mdpsys.yaml | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml
new file mode 100644
index 000..831acdc
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mdpsys.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MDPSYS Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek mdpsys controller provides functional configurations and clocks 
to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-mdpsys
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+mdpsys: syscon@1f00 {
+compatible = "mediatek,mt8192-mdpsys", "syscon";
+reg = <0 0x1f00 0 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty


[PATCH v5 21/24] clk: mediatek: Add MT8192 vdecsys clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 vdecsys and vdecsys soc clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 +++
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-vdec.c | 94 ++
 3 files changed, 101 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-vdec.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 1009e1f..633e806 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -557,6 +557,12 @@ config COMMON_CLK_MT8192_SCP_ADSP
help
  This driver supports MediaTek MT8192 scp_adsp clocks.
 
+config COMMON_CLK_MT8192_VDECSYS
+   bool "Clock driver for MediaTek MT8192 vdecsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 vdecsys and vdecsys_soc clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index a336fe7..887dd6b 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -78,5 +78,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
 obj-$(CONFIG_COMMON_CLK_MT8192_SCP_ADSP) += clk-mt8192-scp_adsp.o
+obj-$(CONFIG_COMMON_CLK_MT8192_VDECSYS) += clk-mt8192-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-vdec.c 
b/drivers/clk/mediatek/clk-mt8192-vdec.c
new file mode 100644
index 000..a6043c1
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-vdec.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs vdec0_cg_regs = {
+   .set_ofs = 0x0,
+   .clr_ofs = 0x4,
+   .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs vdec1_cg_regs = {
+   .set_ofs = 0x200,
+   .clr_ofs = 0x204,
+   .sta_ofs = 0x200,
+};
+
+static const struct mtk_gate_regs vdec2_cg_regs = {
+   .set_ofs = 0x8,
+   .clr_ofs = 0xc,
+   .sta_ofs = 0x8,
+};
+
+#define GATE_VDEC0(_id, _name, _parent, _shift)\
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+#define GATE_VDEC1(_id, _name, _parent, _shift)\
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+#define GATE_VDEC2(_id, _name, _parent, _shift)\
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate vdec_clks[] = {
+   /* VDEC0 */
+   GATE_VDEC0(CLK_VDEC_VDEC, "vdec_vdec", "vdec_sel", 0),
+   GATE_VDEC0(CLK_VDEC_ACTIVE, "vdec_active", "vdec_sel", 4),
+   /* VDEC1 */
+   GATE_VDEC1(CLK_VDEC_LAT, "vdec_lat", "vdec_sel", 0),
+   GATE_VDEC1(CLK_VDEC_LAT_ACTIVE, "vdec_lat_active", "vdec_sel", 4),
+   /* VDEC2 */
+   GATE_VDEC2(CLK_VDEC_LARB1, "vdec_larb1", "vdec_sel", 0),
+};
+
+static const struct mtk_gate vdec_soc_clks[] = {
+   /* VDEC_SOC0 */
+   GATE_VDEC0(CLK_VDEC_SOC_VDEC, "vdec_soc_vdec", "vdec_sel", 0),
+   GATE_VDEC0(CLK_VDEC_SOC_VDEC_ACTIVE, "vdec_soc_vdec_active", 
"vdec_sel", 4),
+   /* VDEC_SOC1 */
+   GATE_VDEC1(CLK_VDEC_SOC_LAT, "vdec_soc_lat", "vdec_sel", 0),
+   GATE_VDEC1(CLK_VDEC_SOC_LAT_ACTIVE, "vdec_soc_lat_active", "vdec_sel", 
4),
+   /* VDEC_SOC2 */
+   GATE_VDEC2(CLK_VDEC_SOC_LARB1, "vdec_soc_larb1", "vdec_sel", 0),
+};
+
+static const struct mtk_clk_desc vdec_desc = {
+   .clks = vdec_clks,
+   .num_clks = ARRAY_SIZE(vdec_clks),
+};
+
+static const struct mtk_clk_desc vdec_soc_desc = {
+   .clks = vdec_soc_clks,
+   .num_clks = ARRAY_SIZE(vdec_soc_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_vdec[] = {
+   {
+   .compatible = "mediatek,mt8192-vdecsys",
+   .data = _desc,
+   }, {
+   .compatible = "mediatek,mt8192-vdecsys_soc",
+   .data = _soc_desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_vdec_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-vdec",
+   .of_match_table = of_match_clk_mt8192_vdec,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_vdec_drv);
-- 
1.8.1.1.dirty


[PATCH v5 16/24] clk: mediatek: Add MT8192 mdpsys clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 mdpsys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 +++
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-mdp.c | 82 +++
 3 files changed, 89 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-mdp.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index c6bc618..a0a2efa9 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -527,6 +527,12 @@ config COMMON_CLK_MT8192_IPESYS
help
  This driver supports MediaTek MT8192 ipesys clocks.
 
+config COMMON_CLK_MT8192_MDPSYS
+   bool "Clock driver for MediaTek MT8192 mdpsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 mdpsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 33dc974..7b258cb 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -73,5 +73,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IMP_IIC_WRAP) += clk-mt8192-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-mdp.c 
b/drivers/clk/mediatek/clk-mt8192-mdp.c
new file mode 100644
index 000..3109104
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-mdp.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs mdp0_cg_regs = {
+   .set_ofs = 0x104,
+   .clr_ofs = 0x108,
+   .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs mdp1_cg_regs = {
+   .set_ofs = 0x124,
+   .clr_ofs = 0x128,
+   .sta_ofs = 0x120,
+};
+
+#define GATE_MDP0(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+#define GATE_MDP1(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate mdp_clks[] = {
+   /* MDP0 */
+   GATE_MDP0(CLK_MDP_RDMA0, "mdp_mdp_rdma0", "mdp_sel", 0),
+   GATE_MDP0(CLK_MDP_TDSHP0, "mdp_mdp_tdshp0", "mdp_sel", 1),
+   GATE_MDP0(CLK_MDP_IMG_DL_ASYNC0, "mdp_img_dl_async0", "mdp_sel", 2),
+   GATE_MDP0(CLK_MDP_IMG_DL_ASYNC1, "mdp_img_dl_async1", "mdp_sel", 3),
+   GATE_MDP0(CLK_MDP_RDMA1, "mdp_mdp_rdma1", "mdp_sel", 4),
+   GATE_MDP0(CLK_MDP_TDSHP1, "mdp_mdp_tdshp1", "mdp_sel", 5),
+   GATE_MDP0(CLK_MDP_SMI0, "mdp_smi0", "mdp_sel", 6),
+   GATE_MDP0(CLK_MDP_APB_BUS, "mdp_apb_bus", "mdp_sel", 7),
+   GATE_MDP0(CLK_MDP_WROT0, "mdp_mdp_wrot0", "mdp_sel", 8),
+   GATE_MDP0(CLK_MDP_RSZ0, "mdp_mdp_rsz0", "mdp_sel", 9),
+   GATE_MDP0(CLK_MDP_HDR0, "mdp_mdp_hdr0", "mdp_sel", 10),
+   GATE_MDP0(CLK_MDP_MUTEX0, "mdp_mdp_mutex0", "mdp_sel", 11),
+   GATE_MDP0(CLK_MDP_WROT1, "mdp_mdp_wrot1", "mdp_sel", 12),
+   GATE_MDP0(CLK_MDP_RSZ1, "mdp_mdp_rsz1", "mdp_sel", 13),
+   GATE_MDP0(CLK_MDP_HDR1, "mdp_mdp_hdr1", "mdp_sel", 14),
+   GATE_MDP0(CLK_MDP_FAKE_ENG0, "mdp_mdp_fake_eng0", "mdp_sel", 15),
+   GATE_MDP0(CLK_MDP_AAL0, "mdp_mdp_aal0", "mdp_sel", 16),
+   GATE_MDP0(CLK_MDP_AAL1, "mdp_mdp_aal1", "mdp_sel", 17),
+   GATE_MDP0(CLK_MDP_COLOR0, "mdp_mdp_color0", "mdp_sel", 18),
+   GATE_MDP0(CLK_MDP_COLOR1, "mdp_mdp_color1", "mdp_sel", 19),
+   /* MDP1 */
+   GATE_MDP1(CLK_MDP_IMG_DL_RELAY0_ASYNC0, "mdp_img_dl_relay0_async0", 
"mdp_sel", 0),
+   GATE_MDP1(CLK_MDP_IMG_DL_RELAY1_ASYNC1, "mdp_img_dl_relay1_async1", 
"mdp_sel", 8),
+};
+
+static const struct mtk_clk_desc mdp_desc = {
+   .clks = mdp_clks,
+   .num_clks = ARRAY_SIZE(mdp_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_mdp[] = {
+   {
+   .compatible = "mediatek,mt8192-mdpsys",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_mdp_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-mdp",
+   .of_match_table = of_match_clk_mt8192_mdp,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_mdp_drv);
-- 
1.8.1.1.dirty


[PATCH v5 20/24] clk: mediatek: Add MT8192 scp adsp clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 scp adsp clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-scp_adsp.c | 50 ++
 3 files changed, 57 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-scp_adsp.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index aba662f..1009e1f 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -551,6 +551,12 @@ config COMMON_CLK_MT8192_MSDC
help
  This driver supports MediaTek MT8192 msdc and msdc_top clocks.
 
+config COMMON_CLK_MT8192_SCP_ADSP
+   bool "Clock driver for MediaTek MT8192 scp_adsp"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 scp_adsp clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 8e4e343..a336fe7 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -77,5 +77,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
+obj-$(CONFIG_COMMON_CLK_MT8192_SCP_ADSP) += clk-mt8192-scp_adsp.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-scp_adsp.c 
b/drivers/clk/mediatek/clk-mt8192-scp_adsp.c
new file mode 100644
index 000..4bc2403
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-scp_adsp.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs scp_adsp_cg_regs = {
+   .set_ofs = 0x180,
+   .clr_ofs = 0x180,
+   .sta_ofs = 0x180,
+};
+
+#define GATE_SCP_ADSP(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _adsp_cg_regs, _shift, 
_clk_gate_ops_no_setclr)
+
+static const struct mtk_gate scp_adsp_clks[] = {
+   GATE_SCP_ADSP(CLK_SCP_ADSP_AUDIODSP, "scp_adsp_audiodsp", "adsp_sel", 
0),
+};
+
+static const struct mtk_clk_desc scp_adsp_desc = {
+   .clks = scp_adsp_clks,
+   .num_clks = ARRAY_SIZE(scp_adsp_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_scp_adsp[] = {
+   {
+   .compatible = "mediatek,mt8192-scp_adsp",
+   .data = _adsp_desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_scp_adsp_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-scp_adsp",
+   .of_match_table = of_match_clk_mt8192_scp_adsp,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_scp_adsp_drv);
-- 
1.8.1.1.dirty


[PATCH v5 04/24] dt-bindings: ARM: Mediatek: Add new document bindings of scp adsp controller

2020-11-08 Thread Weiyi Lu
This patch adds the new binding documentation of scp adsp controller
for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,scp-adsp.yaml   | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml
new file mode 100644
index 000..24df35d
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,scp-adsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek SCP ADSP Controller
+
+maintainers:
+  - Weiyi Lu 
+
+description:
+  The Mediatek scp adsp controller provides functional configurations and 
clocks to the system.
+
+properties:
+  compatible:
+items:
+  - enum:
+  - mediatek,mt8192-scp_adsp
+  - const: syscon
+
+  reg:
+maxItems: 1
+
+  '#clock-cells':
+const: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+scp_adsp: syscon@1072 {
+compatible = "mediatek,mt8192-scp_adsp", "syscon";
+reg = <0x1072 0x1000>;
+#clock-cells = <1>;
+};
-- 
1.8.1.1.dirty


[PATCH v5 19/24] clk: mediatek: Add MT8192 msdc clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 msdc and msdc top clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 +++
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-msdc.c | 85 ++
 3 files changed, 92 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-msdc.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index bc92611..aba662f 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -545,6 +545,12 @@ config COMMON_CLK_MT8192_MMSYS
help
  This driver supports MediaTek MT8192 mmsys clocks.
 
+config COMMON_CLK_MT8192_MSDC
+   bool "Clock driver for MediaTek MT8192 msdc"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 msdc and msdc_top clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 838bb01..8e4e343 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -76,5 +76,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_IPESYS) += clk-mt8192-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MDPSYS) += clk-mt8192-mdp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MFGCFG) += clk-mt8192-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
+obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-msdc.c 
b/drivers/clk/mediatek/clk-mt8192-msdc.c
new file mode 100644
index 000..0fb8d01
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-msdc.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs msdc_cg_regs = {
+   .set_ofs = 0xb4,
+   .clr_ofs = 0xb4,
+   .sta_ofs = 0xb4,
+};
+
+static const struct mtk_gate_regs msdc_top_cg_regs = {
+   .set_ofs = 0x0,
+   .clr_ofs = 0x0,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_MSDC(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_no_setclr_inv)
+
+#define GATE_MSDC_TOP(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _top_cg_regs, _shift, 
_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate msdc_clks[] = {
+   GATE_MSDC(CLK_MSDC_AXI_WRAP, "msdc_axi_wrap", "axi_sel", 22),
+};
+
+static const struct mtk_gate msdc_top_clks[] = {
+   GATE_MSDC_TOP(CLK_MSDC_TOP_AES_0P, "msdc_top_aes_0p", 
"aes_msdcfde_sel", 0),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_SRC_0P, "msdc_top_src_0p", 
"infra_msdc0_src", 1),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_SRC_1P, "msdc_top_src_1p", 
"infra_msdc1_src", 2),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_SRC_2P, "msdc_top_src_2p", 
"infra_msdc2_src", 3),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_MSDC0, "msdc_top_p_msdc0", "axi_sel", 4),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_MSDC1, "msdc_top_p_msdc1", "axi_sel", 5),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_MSDC2, "msdc_top_p_msdc2", "axi_sel", 6),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_P_CFG, "msdc_top_p_cfg", "axi_sel", 7),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_AXI, "msdc_top_axi", "axi_sel", 8),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_H_MST_0P, "msdc_top_h_mst_0p", 
"infra_msdc0", 9),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_H_MST_1P, "msdc_top_h_mst_1p", 
"infra_msdc1", 10),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_H_MST_2P, "msdc_top_h_mst_2p", 
"infra_msdc2", 11),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_MEM_OFF_DLY_26M, "msdc_top_mem_off_dly_26m", 
"clk26m", 12),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_32K, "msdc_top_32k", "clk32k", 13),
+   GATE_MSDC_TOP(CLK_MSDC_TOP_AHB2AXI_BRG_AXI, "msdc_top_ahb2axi_brg_axi", 
"axi_sel", 14),
+};
+
+static const struct mtk_clk_desc msdc_desc = {
+   .clks = msdc_clks,
+   .num_clks = ARRAY_SIZE(msdc_clks),
+};
+
+static const struct mtk_clk_desc msdc_top_desc = {
+   .clks = msdc_top_clks,
+   .num_clks = ARRAY_SIZE(msdc_top_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_msdc[] = {
+   {
+   .compatible = "mediatek,mt8192-msdc",
+   .data = _desc,
+   }, {
+   .compatible = "mediatek,mt8192-msdc_top",
+   .data = _top_desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_msdc_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-msdc",
+   .of_match_table = of_match_clk_mt8192_msdc,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_msdc_drv);
-- 
1.8.1.1.dirty


[PATCH v5 00/24] Mediatek MT8192 clock support

2020-11-08 Thread Weiyi Lu
This series is based on v5.10-rc1 and MT8192 dts v6[1].

[1] 
https://patchwork.kernel.org/project/linux-mediatek/patch/20201030092207.26488-2-seiya.w...@mediatek.com/

change since v4:
- merge some subsystem into same driver
- add a generic probe function to reduce duplicated code

changes since v3:
- add critical clocks
- split large patches into small ones

changes since v2:
- update and split dt-binding documents by functionalities
- add error checking in probe() function
- fix incorrect clock relation and add critical clocks
- update license identifier and minor fix of coding style

changes since v1:
- fix asymmetrical control of PLL
- have en_mask used as divider enable mask on all MediaTek SoC

Weiyi Lu (24):
  dt-bindings: ARM: Mediatek: Add new document bindings of imp i2c
wrapper controller
  dt-bindings: ARM: Mediatek: Add new document bindings of mdpsys
controller
  dt-bindings: ARM: Mediatek: Add new document bindings of msdc
controller
  dt-bindings: ARM: Mediatek: Add new document bindings of scp adsp
controller
  dt-bindings: ARM: Mediatek: Document bindings of MT8192 clock
controllers
  clk: mediatek: Add dt-bindings of MT8192 clocks
  clk: mediatek: Fix asymmetrical PLL enable and disable control
  clk: mediatek: Add configurable enable control to mtk_pll_data
  clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers
  clk: mediatek: Add MT8192 basic clocks support
  clk: mediatek: Add MT8192 audio clock support
  clk: mediatek: Add MT8192 camsys clock support
  clk: mediatek: Add MT8192 imgsys clock support
  clk: mediatek: Add MT8192 imp i2c wrapper clock support
  clk: mediatek: Add MT8192 ipesys clock support
  clk: mediatek: Add MT8192 mdpsys clock support
  clk: mediatek: Add MT8192 mfgcfg clock support
  clk: mediatek: Add MT8192 mmsys clock support
  clk: mediatek: Add MT8192 msdc clock support
  clk: mediatek: Add MT8192 scp adsp clock support
  clk: mediatek: Add MT8192 vdecsys clock support
  clk: mediatek: Add MT8192 vencsys clock support
  arm64: dts: mediatek: Add mt8192 clock controllers
  arm64: dts: mediatek: Correct UART0 bus clock of MT8192

 .../arm/mediatek/mediatek,apmixedsys.txt  |1 +
 .../bindings/arm/mediatek/mediatek,audsys.txt |1 +
 .../bindings/arm/mediatek/mediatek,camsys.txt |   22 +
 .../bindings/arm/mediatek/mediatek,imgsys.txt |2 +
 .../arm/mediatek/mediatek,imp_iic_wrap.yaml   |   78 +
 .../arm/mediatek/mediatek,infracfg.txt|1 +
 .../bindings/arm/mediatek/mediatek,ipesys.txt |1 +
 .../arm/mediatek/mediatek,mdpsys.yaml |   38 +
 .../bindings/arm/mediatek/mediatek,mfgcfg.txt |1 +
 .../bindings/arm/mediatek/mediatek,mmsys.txt  |1 +
 .../bindings/arm/mediatek/mediatek,msdc.yaml  |   46 +
 .../arm/mediatek/mediatek,pericfg.yaml|1 +
 .../arm/mediatek/mediatek,scp-adsp.yaml   |   38 +
 .../arm/mediatek/mediatek,topckgen.txt|1 +
 .../arm/mediatek/mediatek,vdecsys.txt |8 +
 .../arm/mediatek/mediatek,vencsys.txt |1 +
 arch/arm64/boot/dts/mediatek/mt8192.dtsi  |  165 +-
 drivers/clk/mediatek/Kconfig  |   80 +
 drivers/clk/mediatek/Makefile |   13 +
 drivers/clk/mediatek/clk-mt8192-aud.c |  118 ++
 drivers/clk/mediatek/clk-mt8192-cam.c |  107 ++
 drivers/clk/mediatek/clk-mt8192-img.c |   70 +
 .../clk/mediatek/clk-mt8192-imp_iic_wrap.c|  119 ++
 drivers/clk/mediatek/clk-mt8192-ipe.c |   57 +
 drivers/clk/mediatek/clk-mt8192-mdp.c |   82 +
 drivers/clk/mediatek/clk-mt8192-mfg.c |   50 +
 drivers/clk/mediatek/clk-mt8192-mm.c  |  108 ++
 drivers/clk/mediatek/clk-mt8192-msdc.c|   85 ++
 drivers/clk/mediatek/clk-mt8192-scp_adsp.c|   50 +
 drivers/clk/mediatek/clk-mt8192-vdec.c|   94 ++
 drivers/clk/mediatek/clk-mt8192-venc.c|   53 +
 drivers/clk/mediatek/clk-mt8192.c | 1350 +
 drivers/clk/mediatek/clk-mtk.c|   23 +
 drivers/clk/mediatek/clk-mtk.h|   10 +
 drivers/clk/mediatek/clk-mux.h|   15 +
 drivers/clk/mediatek/clk-pll.c|   31 +-
 include/dt-bindings/clock/mt8192-clk.h|  592 
 37 files changed, 3505 insertions(+), 8 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,imp_iic_wrap.yaml
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,mdpsys.yaml
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,msdc.yaml
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,scp-adsp.yaml
 create mode 100644 drivers/clk/mediatek/clk-mt8192-aud.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-cam.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-img.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
 create mode 100644 drivers/clk/mediatek/clk-mt8192-ipe.c
 create mode 100644 drivers/clk

[PATCH v5 10/24] clk: mediatek: Add MT8192 basic clocks support

2020-11-08 Thread Weiyi Lu
Add MT8192 basic clock providers, include topckgen, apmixedsys,
infracfg and pericfg.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |8 +
 drivers/clk/mediatek/Makefile |1 +
 drivers/clk/mediatek/clk-mt8192.c | 1350 +
 drivers/clk/mediatek/clk-mux.h|   15 +
 4 files changed, 1374 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index ce84750..f628efd 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -489,6 +489,14 @@ config COMMON_CLK_MT8183_VENCSYS
help
  This driver supports MediaTek MT8183 vencsys clocks.
 
+config COMMON_CLK_MT8192
+   bool "Clock driver for MediaTek MT8192"
+   depends on ARM64 || COMPILE_TEST
+   select COMMON_CLK_MEDIATEK
+   default ARM64
+   help
+ This driver supports MediaTek MT8192 basic clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 3b0c2be..fcde421 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -67,5 +67,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_MFGCFG) += clk-mt8183-mfgcfg.o
 obj-$(CONFIG_COMMON_CLK_MT8183_MMSYS) += clk-mt8183-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
+obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192.c 
b/drivers/clk/mediatek/clk-mt8192.c
new file mode 100644
index 000..673dc601
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192.c
@@ -0,0 +1,1350 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-mux.h"
+#include "clk-gate.h"
+
+#include 
+
+static DEFINE_SPINLOCK(mt8192_clk_lock);
+
+static const struct mtk_fixed_clk top_fixed_clks[] = {
+   FIXED_CLK(CLK_TOP_ULPOSC, "ulposc", NULL, 26000),
+};
+
+static const struct mtk_fixed_factor top_early_divs[] = {
+   FACTOR(CLK_TOP_CSW_F26M_D2, "csw_f26m_d2", "clk26m", 1, 2),
+};
+
+static const struct mtk_fixed_factor top_divs[] = {
+   FACTOR(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll", 1, 3),
+   FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D4_D2, "mainpll_d4_d2", "mainpll_d4", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D4_D4, "mainpll_d4_d4", "mainpll_d4", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D4_D8, "mainpll_d4_d8", "mainpll_d4", 1, 8),
+   FACTOR(CLK_TOP_MAINPLL_D4_D16, "mainpll_d4_d16", "mainpll_d4", 1, 16),
+   FACTOR(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll", 1, 5),
+   FACTOR(CLK_TOP_MAINPLL_D5_D2, "mainpll_d5_d2", "mainpll_d5", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D5_D4, "mainpll_d5_d4", "mainpll_d5", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D5_D8, "mainpll_d5_d8", "mainpll_d5", 1, 8),
+   FACTOR(CLK_TOP_MAINPLL_D6, "mainpll_d6", "mainpll", 1, 6),
+   FACTOR(CLK_TOP_MAINPLL_D6_D2, "mainpll_d6_d2", "mainpll_d6", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D6_D4, "mainpll_d6_d4", "mainpll_d6", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll", 1, 7),
+   FACTOR(CLK_TOP_MAINPLL_D7_D2, "mainpll_d7_d2", "mainpll_d7", 1, 2),
+   FACTOR(CLK_TOP_MAINPLL_D7_D4, "mainpll_d7_d4", "mainpll_d7", 1, 4),
+   FACTOR(CLK_TOP_MAINPLL_D7_D8, "mainpll_d7_d8", "mainpll_d7", 1, 8),
+   FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3),
+   FACTOR(CLK_TOP_UNIVPLL_D4, "univpll_d4", "univpll", 1, 4),
+   FACTOR(CLK_TOP_UNIVPLL_D4_D2, "univpll_d4_d2", "univpll_d4", 1, 2),
+   FACTOR(CLK_TOP_UNIVPLL_D4_D4, "univpll_d4_d4", "univpll_d4", 1, 4),
+   FACTOR(CLK_TOP_UNIVPLL_D4_D8, "univpll_d4_d8", "univpll_d4", 1, 8),
+   FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5),
+   FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll_d5", 1, 2),
+   FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll_d5", 1, 4),
+   FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d

[PATCH v5 22/24] clk: mediatek: Add MT8192 vencsys clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 vencsys clock provider

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |  6 
 drivers/clk/mediatek/Makefile  |  1 +
 drivers/clk/mediatek/clk-mt8192-venc.c | 53 ++
 3 files changed, 60 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-venc.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 633e806..6a6ac41 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -563,6 +563,12 @@ config COMMON_CLK_MT8192_VDECSYS
help
  This driver supports MediaTek MT8192 vdecsys and vdecsys_soc clocks.
 
+config COMMON_CLK_MT8192_VENCSYS
+   bool "Clock driver for MediaTek MT8192 vencsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 vencsys clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 887dd6b..15bc045 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -79,5 +79,6 @@ obj-$(CONFIG_COMMON_CLK_MT8192_MMSYS) += clk-mt8192-mm.o
 obj-$(CONFIG_COMMON_CLK_MT8192_MSDC) += clk-mt8192-msdc.o
 obj-$(CONFIG_COMMON_CLK_MT8192_SCP_ADSP) += clk-mt8192-scp_adsp.o
 obj-$(CONFIG_COMMON_CLK_MT8192_VDECSYS) += clk-mt8192-vdec.o
+obj-$(CONFIG_COMMON_CLK_MT8192_VENCSYS) += clk-mt8192-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-venc.c 
b/drivers/clk/mediatek/clk-mt8192-venc.c
new file mode 100644
index 000..ce220c5
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-venc.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs venc_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_VENC(_id, _name, _parent, _shift) \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate venc_clks[] = {
+   GATE_VENC(CLK_VENC_SET0_LARB, "venc_set0_larb", "venc_sel", 0),
+   GATE_VENC(CLK_VENC_SET1_VENC, "venc_set1_venc", "venc_sel", 4),
+   GATE_VENC(CLK_VENC_SET2_JPGENC, "venc_set2_jpgenc", "venc_sel", 8),
+   GATE_VENC(CLK_VENC_SET5_GALS, "venc_set5_gals", "venc_sel", 28),
+};
+
+static const struct mtk_clk_desc venc_desc = {
+   .clks = venc_clks,
+   .num_clks = ARRAY_SIZE(venc_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_venc[] = {
+   {
+   .compatible = "mediatek,mt8192-vencsys",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_venc_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-venc",
+   .of_match_table = of_match_clk_mt8192_venc,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_venc_drv);
-- 
1.8.1.1.dirty


[PATCH v5 24/24] arm64: dts: mediatek: Correct UART0 bus clock of MT8192

2020-11-08 Thread Weiyi Lu
infra_uart0 clock is the real one what uart0 uses as bus clock.

Signed-off-by: Weiyi Lu 
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index 92dcfbd..ac5dca6 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -283,7 +283,7 @@
 "mediatek,mt6577-uart";
reg = <0 0x11002000 0 0x1000>;
interrupts = ;
-   clocks = <>, <>;
+   clocks = <>, < CLK_INFRA_UART0>;
clock-names = "baud", "bus";
status = "disabled";
};
-- 
1.8.1.1.dirty


[PATCH v5 09/24] clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers

2020-11-08 Thread Weiyi Lu
Most of subsystem clock providers only need to register clock gates
in their probe() function.
To reduce the duplicated code by add a generic function.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mtk.c | 23 +++
 drivers/clk/mediatek/clk-mtk.h |  8 
 2 files changed, 31 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index cec1c8a..67693b7 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
@@ -286,3 +287,25 @@ void mtk_clk_register_dividers(const struct 
mtk_clk_divider *mcds,
clk_data->clks[mcd->id] = clk;
}
 }
+
+int mtk_clk_simple_probe(struct platform_device *pdev)
+{
+   const struct mtk_clk_desc *mcd;
+   struct clk_onecell_data *clk_data;
+   struct device_node *node = pdev->dev.of_node;
+   int r;
+
+   mcd = of_device_get_match_data(>dev);
+   if (!mcd)
+   return -EINVAL;
+
+   clk_data = mtk_alloc_clk_data(mcd->num_clks);
+   if (!clk_data)
+   return -ENOMEM;
+
+   r = mtk_clk_register_gates(node, mcd->clks, mcd->num_clks, clk_data);
+   if (r)
+   return r;
+
+   return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index c580663..2f61fba 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct clk;
 struct clk_onecell_data;
@@ -250,4 +251,11 @@ void mtk_register_reset_controller(struct device_node *np,
 void mtk_register_reset_controller_set_clr(struct device_node *np,
unsigned int num_regs, int regofs);
 
+struct mtk_clk_desc {
+   const struct mtk_gate *clks;
+   size_t num_clks;
+};
+
+int mtk_clk_simple_probe(struct platform_device *pdev);
+
 #endif /* __DRV_CLK_MTK_H */
-- 
1.8.1.1.dirty


[PATCH v5 13/24] clk: mediatek: Add MT8192 imgsys clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 imgsys and imgsys2 clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |  6 +++
 drivers/clk/mediatek/Makefile |  1 +
 drivers/clk/mediatek/clk-mt8192-img.c | 70 +++
 3 files changed, 77 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-img.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index a75b7ec..eb549f8 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -509,6 +509,12 @@ config COMMON_CLK_MT8192_CAMSYS
help
  This driver supports MediaTek MT8192 camsys and camsys_raw clocks.
 
+config COMMON_CLK_MT8192_IMGSYS
+   bool "Clock driver for MediaTek MT8192 imgsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 imgsys and imgsys2 clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 94bf7a0..91392cb 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -70,5 +70,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
+obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-img.c 
b/drivers/clk/mediatek/clk-mt8192-img.c
new file mode 100644
index 000..24b4143
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-img.c
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs img_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_IMG(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate img_clks[] = {
+   GATE_IMG(CLK_IMG_LARB9, "img_larb9", "img1_sel", 0),
+   GATE_IMG(CLK_IMG_LARB10, "img_larb10", "img1_sel", 1),
+   GATE_IMG(CLK_IMG_DIP, "img_dip", "img1_sel", 2),
+   GATE_IMG(CLK_IMG_GALS, "img_gals", "img1_sel", 12),
+};
+
+static const struct mtk_gate img2_clks[] = {
+   GATE_IMG(CLK_IMG2_LARB11, "img2_larb11", "img1_sel", 0),
+   GATE_IMG(CLK_IMG2_LARB12, "img2_larb12", "img1_sel", 1),
+   GATE_IMG(CLK_IMG2_MFB, "img2_mfb", "img1_sel", 6),
+   GATE_IMG(CLK_IMG2_WPE, "img2_wpe", "img1_sel", 7),
+   GATE_IMG(CLK_IMG2_MSS, "img2_mss", "img1_sel", 8),
+   GATE_IMG(CLK_IMG2_GALS, "img2_gals", "img1_sel", 12),
+};
+
+static const struct mtk_clk_desc img_desc = {
+   .clks = img_clks,
+   .num_clks = ARRAY_SIZE(img_clks),
+};
+
+static const struct mtk_clk_desc img2_desc = {
+   .clks = img2_clks,
+   .num_clks = ARRAY_SIZE(img2_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8192_img[] = {
+   {
+   .compatible = "mediatek,mt8192-imgsys",
+   .data = _desc,
+   }, {
+   .compatible = "mediatek,mt8192-imgsys2",
+   .data = _desc,
+   }, {
+   /* sentinel */
+   }
+};
+
+static struct platform_driver clk_mt8192_img_drv = {
+   .probe = mtk_clk_simple_probe,
+   .driver = {
+   .name = "clk-mt8192-img",
+   .of_match_table = of_match_clk_mt8192_img,
+   },
+};
+
+builtin_platform_driver(clk_mt8192_img_drv);
-- 
1.8.1.1.dirty


[PATCH v5 23/24] arm64: dts: mediatek: Add mt8192 clock controllers

2020-11-08 Thread Weiyi Lu
Add clock controller nodes for SoC mt8192

Signed-off-by: Weiyi Lu 
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 163 +++
 1 file changed, 163 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8192.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
index e12e024..92dcfbd 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8192.dtsi
@@ -5,6 +5,7 @@
  */
 
 /dts-v1/;
+#include 
 #include 
 #include 
 #include 
@@ -213,6 +214,24 @@
};
};
 
+   topckgen: syscon@1000 {
+   compatible = "mediatek,mt8192-topckgen", "syscon";
+   reg = <0 0x1000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   infracfg: syscon@10001000 {
+   compatible = "mediatek,mt8192-infracfg", "syscon";
+   reg = <0 0x10001000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   pericfg: syscon@10003000 {
+   compatible = "mediatek,mt8192-pericfg", "syscon";
+   reg = <0 0x10003000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
pio: pinctrl@10005000 {
compatible = "mediatek,mt8192-pinctrl";
reg = <0 0x10005000 0 0x1000>,
@@ -238,6 +257,12 @@
#interrupt-cells = <2>;
};
 
+   apmixedsys: syscon@1000c000 {
+   compatible = "mediatek,mt8192-apmixedsys", "syscon";
+   reg = <0 0x1000c000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
systimer: timer@10017000 {
compatible = "mediatek,mt8192-timer",
 "mediatek,mt6765-timer";
@@ -247,6 +272,12 @@
clock-names = "clk13m";
};
 
+   scp_adsp: syscon@1072 {
+   compatible = "mediatek,mt8192-scp_adsp", "syscon";
+   reg = <0 0x1072 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
uart0: serial@11002000 {
compatible = "mediatek,mt8192-uart",
 "mediatek,mt6577-uart";
@@ -267,6 +298,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_c: syscon@11007000 {
+   compatible = "mediatek,mt8192-imp_iic_wrap_c", "syscon";
+   reg = <0 0x11007000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
spi0: spi@1100a000 {
compatible = "mediatek,mt8192-spi",
 "mediatek,mt6765-spi";
@@ -379,6 +416,12 @@
status = "disabled";
};
 
+   audsys: syscon@1121 {
+   compatible = "mediatek,mt8192-audsys", "syscon";
+   reg = <0 0x1121 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
i2c3: i2c3@11cb {
compatible = "mediatek,mt8192-i2c";
reg = <0 0x11cb 0 0x1000>,
@@ -392,6 +435,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_e: syscon@11cb1000 {
+   compatible = "mediatek,mt8192-imp_iic_wrap_e", "syscon";
+   reg = <0 0x11cb1000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
i2c7: i2c7@11d0 {
compatible = "mediatek,mt8192-i2c";
reg = <0 0x11d0 0 0x1000>,
@@ -431,6 +480,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_s: syscon@11d03000 {
+   compatible = "mediatek,mt8192-imp_iic_wrap_s", "syscon";
+   reg = <0 0x11d03000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
i2c1: i2c1@11d2 {
compatible = "mediatek,mt8192-i2c";
reg = <0 0x11d2 0 0x1000>,
@@ -470,6 +525,12 @@
status = "disabled";
};
 
+   imp_iic_wrap_ws: syscon@11d23000 {
+  

[PATCH v5 05/24] dt-bindings: ARM: Mediatek: Document bindings of MT8192 clock controllers

2020-11-08 Thread Weiyi Lu
This patch adds the binding documentation of topckgen, apmixedsys,
infracfg, pericfg and subsystem clocks for Mediatek MT8192.

Signed-off-by: Weiyi Lu 
---
 .../bindings/arm/mediatek/mediatek,apmixedsys.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,audsys.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,camsys.txt  | 22 ++
 .../bindings/arm/mediatek/mediatek,imgsys.txt  |  2 ++
 .../bindings/arm/mediatek/mediatek,infracfg.txt|  1 +
 .../bindings/arm/mediatek/mediatek,ipesys.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,mfgcfg.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,mmsys.txt   |  1 +
 .../bindings/arm/mediatek/mediatek,pericfg.yaml|  1 +
 .../bindings/arm/mediatek/mediatek,topckgen.txt|  1 +
 .../bindings/arm/mediatek/mediatek,vdecsys.txt |  8 
 .../bindings/arm/mediatek/mediatek,vencsys.txt |  1 +
 12 files changed, 41 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
index ea827e87..551c307 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
@@ -18,6 +18,7 @@ Required Properties:
- "mediatek,mt8167-apmixedsys", "syscon"
- "mediatek,mt8173-apmixedsys"
- "mediatek,mt8183-apmixedsys", "syscon"
+   - "mediatek,mt8192-apmixedsys", "syscon"
- "mediatek,mt8516-apmixedsys"
 - #clock-cells: Must be 1
 
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
index b32d374..699776b 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
@@ -13,6 +13,7 @@ Required Properties:
- "mediatek,mt7623-audsys", "mediatek,mt2701-audsys", "syscon"
- "mediatek,mt8167-audiosys", "syscon"
- "mediatek,mt8183-audiosys", "syscon"
+   - "mediatek,mt8192-audsys", "syscon"
- "mediatek,mt8516-audsys", "syscon"
 - #clock-cells: Must be 1
 
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
index a0ce820..7d0b14e 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
@@ -9,6 +9,10 @@ Required Properties:
- "mediatek,mt6765-camsys", "syscon"
- "mediatek,mt6779-camsys", "syscon"
- "mediatek,mt8183-camsys", "syscon"
+   - "mediatek,mt8192-camsys", "syscon"
+   - "mediatek,mt8192-camsys_rawa", "syscon"
+   - "mediatek,mt8192-camsys_rawb", "syscon"
+   - "mediatek,mt8192-camsys_rawc", "syscon"
 - #clock-cells: Must be 1
 
 The camsys controller uses the common clk binding from
@@ -22,3 +26,21 @@ camsys: camsys@1a00  {
reg = <0 0x1a00  0 0x1000>;
#clock-cells = <1>;
 };
+
+camsys_rawa: syscon@1a04f000 {
+   compatible = "mediatek,mt8192-camsys_rawa", "syscon";
+   reg = <0 0x1a04f000 0 0x1000>;
+   #clock-cells = <1>;
+};
+
+camsys_rawb: syscon@1a06f000 {
+   compatible = "mediatek,mt8192-camsys_rawb", "syscon";
+   reg = <0 0x1a06f000 0 0x1000>;
+   #clock-cells = <1>;
+};
+
+camsys_rawc: syscon@1a08f000 {
+   compatible = "mediatek,mt8192-camsys_rawc", "syscon";
+   reg = <0 0x1a08f000 0 0x1000>;
+   #clock-cells = <1>;
+};
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
index dce4c924..b9e599e 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
@@ -15,6 +15,8 @@ Required Properties:
- "mediatek,mt8167-imgsys", "syscon"
- "mediatek,mt8173-imgsys", "syscon"
- "mediatek,mt8183-imgsys", "syscon"
+   - "mediatek,mt8192-imgsys", "syscon"
+   - "mediatek,mt8192-imgsys2", "syscon"
 - #clock-cells: Must be 1
 
 The imgsys controller uses the common clk binding from
diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
index e

[PATCH v5 12/24] clk: mediatek: Add MT8192 camsys clock support

2020-11-08 Thread Weiyi Lu
Add MT8192 camsys and camsys raw clock providers

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig  |   6 ++
 drivers/clk/mediatek/Makefile |   1 +
 drivers/clk/mediatek/clk-mt8192-cam.c | 107 ++
 3 files changed, 114 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8192-cam.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 1a8b0c1..a75b7ec 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -503,6 +503,12 @@ config COMMON_CLK_MT8192_AUDSYS
help
  This driver supports MediaTek MT8192 audsys clocks.
 
+config COMMON_CLK_MT8192_CAMSYS
+   bool "Clock driver for MediaTek MT8192 camsys"
+   depends on COMMON_CLK_MT8192
+   help
+ This driver supports MediaTek MT8192 camsys and camsys_raw clocks.
+
 config COMMON_CLK_MT8516
bool "Clock driver for MediaTek MT8516"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 1d0f2e8..94bf7a0 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -69,5 +69,6 @@ obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
+obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o
 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
diff --git a/drivers/clk/mediatek/clk-mt8192-cam.c 
b/drivers/clk/mediatek/clk-mt8192-cam.c
new file mode 100644
index 000..549ea8e
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mt8192-cam.c
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2020 MediaTek Inc.
+// Author: Weiyi Lu 
+
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-gate.h"
+
+#include 
+
+static const struct mtk_gate_regs cam_cg_regs = {
+   .set_ofs = 0x4,
+   .clr_ofs = 0x8,
+   .sta_ofs = 0x0,
+};
+
+#define GATE_CAM(_id, _name, _parent, _shift)  \
+   GATE_MTK(_id, _name, _parent, _cg_regs, _shift, 
_clk_gate_ops_setclr)
+
+static const struct mtk_gate cam_clks[] = {
+   GATE_CAM(CLK_CAM_LARB13, "cam_larb13", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_DFP_VAD, "cam_dfp_vad", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_LARB14, "cam_larb14", "cam_sel", 2),
+   GATE_CAM(CLK_CAM_CAM, "cam_cam", "cam_sel", 6),
+   GATE_CAM(CLK_CAM_CAMTG, "cam_camtg", "cam_sel", 7),
+   GATE_CAM(CLK_CAM_SENINF, "cam_seninf", "cam_sel", 8),
+   GATE_CAM(CLK_CAM_CAMSV0, "cam_camsv0", "cam_sel", 9),
+   GATE_CAM(CLK_CAM_CAMSV1, "cam_camsv1", "cam_sel", 10),
+   GATE_CAM(CLK_CAM_CAMSV2, "cam_camsv2", "cam_sel", 11),
+   GATE_CAM(CLK_CAM_CAMSV3, "cam_camsv3", "cam_sel", 12),
+   GATE_CAM(CLK_CAM_CCU0, "cam_ccu0", "cam_sel", 13),
+   GATE_CAM(CLK_CAM_CCU1, "cam_ccu1", "cam_sel", 14),
+   GATE_CAM(CLK_CAM_MRAW0, "cam_mraw0", "cam_sel", 15),
+   GATE_CAM(CLK_CAM_FAKE_ENG, "cam_fake_eng", "cam_sel", 17),
+   GATE_CAM(CLK_CAM_CCU_GALS, "cam_ccu_gals", "cam_sel", 18),
+   GATE_CAM(CLK_CAM_CAM2MM_GALS, "cam2mm_gals", "cam_sel", 19),
+};
+
+static const struct mtk_gate cam_rawa_clks[] = {
+   GATE_CAM(CLK_CAM_RAWA_LARBX, "cam_rawa_larbx", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_RAWA_CAM, "cam_rawa_cam", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_RAWA_CAMTG, "cam_rawa_camtg", "cam_sel", 2),
+};
+
+static const struct mtk_gate cam_rawb_clks[] = {
+   GATE_CAM(CLK_CAM_RAWB_LARBX, "cam_rawb_larbx", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_RAWB_CAM, "cam_rawb_cam", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_RAWB_CAMTG, "cam_rawb_camtg", "cam_sel", 2),
+};
+
+static const struct mtk_gate cam_rawc_clks[] = {
+   GATE_CAM(CLK_CAM_RAWC_LARBX, "cam_rawc_larbx", "cam_sel", 0),
+   GATE_CAM(CLK_CAM_RAWC_CAM, "cam_rawc_cam", "cam_sel", 1),
+   GATE_CAM(CLK_CAM_RAWC_CAMTG, "cam_rawc_camtg", "cam_sel", 2),
+};
+
+static const struct mtk_clk_desc cam_desc = {
+   .clks = cam_clks,
+   .num_clks = ARRAY_SIZE(cam_clks),
+};
+
+static const struct mtk_clk_desc cam_rawa_desc = {
+   .clks = cam_rawa_clks,
+   .num_clks = ARRAY_SIZE(cam_rawa_clks),
+};
+
+static const struct mtk_clk_desc cam_rawb_desc = {
+   .clks = cam_rawb_clks,
+   .num_cl

[PATCH v5 08/24] clk: mediatek: Add configurable enable control to mtk_pll_data

2020-11-08 Thread Weiyi Lu
In all MediaTek PLL design, bit0 of CON0 register is always
the enable bit.
However, there's a special case of usbpll on MT8192.
The enable bit of usbpll is moved to bit2 of other register.
Add configurable en_reg and pll_en_bit for enable control or
default 0 where pll data are static variables.
Hence, CON0_BASE_EN could also be removed.
And there might have another special case on other chips,
the enable bit is still on CON0 register but not at bit0.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mtk.h |  2 ++
 drivers/clk/mediatek/clk-pll.c | 15 ++-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index c3d6756..c580663 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -233,6 +233,8 @@ struct mtk_pll_data {
uint32_t pcw_chg_reg;
const struct mtk_pll_div_table *div_table;
const char *parent_name;
+   uint32_t en_reg;
+   uint8_t pll_en_bit; /* Assume 0, indicates BIT(0) by default */
 };
 
 void mtk_clk_register_plls(struct device_node *node,
diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index 11ed5d1..7fb001a 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -44,6 +44,7 @@ struct mtk_clk_pll {
void __iomem*tuner_en_addr;
void __iomem*pcw_addr;
void __iomem*pcw_chg_addr;
+   void __iomem*en_addr;
const struct mtk_pll_data *data;
 };
 
@@ -56,7 +57,7 @@ static int mtk_pll_is_prepared(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
-   return (readl(pll->base_addr + REG_CON0) & CON0_BASE_EN) != 0;
+   return (readl(pll->en_addr) & BIT(pll->data->pll_en_bit)) != 0;
 }
 
 static unsigned long __mtk_pll_recalc_rate(struct mtk_clk_pll *pll, u32 fin,
@@ -248,8 +249,8 @@ static int mtk_pll_prepare(struct clk_hw *hw)
writel(r, pll->pwr_addr);
udelay(1);
 
-   r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN;
-   writel(r, pll->base_addr + REG_CON0);
+   r = readl(pll->en_addr) | BIT(pll->data->pll_en_bit);
+   writel(r, pll->en_addr);
 
div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
if (div_en_mask) {
@@ -290,8 +291,8 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
writel(r, pll->base_addr + REG_CON0);
}
 
-   r = readl(pll->base_addr + REG_CON0) & ~CON0_BASE_EN;
-   writel(r, pll->base_addr + REG_CON0);
+   r = readl(pll->en_addr) & ~BIT(pll->data->pll_en_bit);
+   writel(r, pll->en_addr);
 
r = readl(pll->pwr_addr) | CON0_ISO_EN;
writel(r, pll->pwr_addr);
@@ -333,6 +334,10 @@ static struct clk *mtk_clk_register_pll(const struct 
mtk_pll_data *data,
pll->tuner_addr = base + data->tuner_reg;
if (data->tuner_en_reg)
pll->tuner_en_addr = base + data->tuner_en_reg;
+   if (data->en_reg)
+   pll->en_addr = base + data->en_reg;
+   else
+   pll->en_addr = pll->base_addr + REG_CON0;
pll->hw.init = 
pll->data = data;
 
-- 
1.8.1.1.dirty


Re: [PATCH v3 15/16] soc: mediatek: pm-domains: Add default power off flag

2020-10-27 Thread Weiyi Lu
On Tue, 2020-10-27 at 11:53 +0100, Matthias Brugger wrote:
> 
> On 26/10/2020 18:55, Enric Balletbo i Serra wrote:
> > From: Weiyi Lu 
> > 
> > For some power domain, like conn on MT8192, it should be default OFF.
> > Because the power on/off control relies the function of connectivity chip
> > and its firmware. And if project choose other chip vendor solution,
> > those necessary connectivity functions will not provided.
> > 
> > Signed-off-by: Weiyi Lu 
> > Signed-off-by: Enric Balletbo i Serra 
> > ---
> > 
> > Changes in v3: None
> > Changes in v2: None
> > 
> >   drivers/soc/mediatek/mtk-pm-domains.c | 23 +--
> >   drivers/soc/mediatek/mtk-pm-domains.h |  1 +
> >   2 files changed, 18 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/soc/mediatek/mtk-pm-domains.c 
> > b/drivers/soc/mediatek/mtk-pm-domains.c
> > index 63993076a544..fe0e955076a0 100644
> > --- a/drivers/soc/mediatek/mtk-pm-domains.c
> > +++ b/drivers/soc/mediatek/mtk-pm-domains.c
> > @@ -378,10 +378,16 @@ generic_pm_domain *scpsys_add_one_domain(struct 
> > scpsys *scpsys, struct device_no
> >  * software.  The unused domains will be switched off during
> >  * late_init time.
> >  */
> > -   ret = scpsys_power_on(>genpd);
> > -   if (ret < 0) {
> > -   dev_err(scpsys->dev, "%pOF: failed to power on domain: %d\n", 
> > node, ret);
> > -   goto err_unprepare_clocks;
> > +   if (MTK_SCPD_CAPS(pd, MTK_SCPD_KEEP_DEFAULT_OFF)) {
> > +   if (scpsys_domain_is_on(pd))
> > +   dev_warn(scpsys->dev,
> > +"%pOF: A default off power domain has been 
> > ON\n", node);
> > +   } else {
> > +   ret = scpsys_power_on(>genpd);
> > +   if (ret < 0) {
> > +   dev_err(scpsys->dev, "%pOF: failed to power on domain: 
> > %d\n", node, ret);
> > +   goto err_unprepare_clocks;
> > +   }
> > }
> >   
> > if (scpsys->domains[id]) {
> > @@ -395,7 +401,11 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys 
> > *scpsys, struct device_no
> > pd->genpd.power_off = scpsys_power_off;
> > pd->genpd.power_on = scpsys_power_on;
> >   
> > -   pm_genpd_init(>genpd, NULL, false);
> > +   if (MTK_SCPD_CAPS(pd, MTK_SCPD_KEEP_DEFAULT_OFF))
> > +   pm_genpd_init(>genpd, NULL, true);
> > +   else
> > +   pm_genpd_init(>genpd, NULL, false);
> > +
> > scpsys->domains[id] = >genpd;
> >   
> > return scpsys->pd_data.domains[id];
> > @@ -478,7 +488,8 @@ static void scpsys_remove_one_domain(struct 
> > scpsys_domain *pd)
> > "failed to remove domain '%s' : %d - state may be 
> > inconsistent\n",
> > pd->genpd.name, ret);
> >   
> > -   scpsys_power_off(>genpd);
> > +   if (!MTK_SCPD_CAPS(pd, MTK_SCPD_KEEP_DEFAULT_OFF))
> > +   scpsys_power_off(>genpd);
> 
> OK, so you merged Weiyi's patches in this series :)
> 
> So same comment here: Does it really hurt if we turn-off a already turned-off 
> power domain? Or can we get rid of this check?
> 

We do need this check here. If you try to turn-off this power domain,
you might make the clock or regulator reference count unbalanced.

> Regards,
> Matthias
> 
> >   
> > clk_bulk_unprepare(pd->num_clks, pd->clks);
> > clk_bulk_put(pd->num_clks, pd->clks);
> > diff --git a/drivers/soc/mediatek/mtk-pm-domains.h 
> > b/drivers/soc/mediatek/mtk-pm-domains.h
> > index 2ad213be84a5..0fa6a938b40c 100644
> > --- a/drivers/soc/mediatek/mtk-pm-domains.h
> > +++ b/drivers/soc/mediatek/mtk-pm-domains.h
> > @@ -6,6 +6,7 @@
> >   #define MTK_SCPD_ACTIVE_WAKEUPBIT(0)
> >   #define MTK_SCPD_FWAIT_SRAM   BIT(1)
> >   #define MTK_SCPD_SRAM_ISO BIT(2)
> > +#define MTK_SCPD_KEEP_DEFAULT_OFF  BIT(3)
> >   #define MTK_SCPD_CAPS(_scpd, _x)  ((_scpd)->data->caps & (_x))
> >   
> >   #define SPM_VDE_PWR_CON   0x0210
> > 



Re: [PATCH v3 04/16] soc: mediatek: pm-domains: Add bus protection protocol

2020-10-27 Thread Weiyi Lu
On Mon, 2020-10-26 at 18:55 +0100, Enric Balletbo i Serra wrote:
> From: Matthias Brugger 
> 
> Bus protection will need to update more then one register
> in infracfg. Add support for several operations.
> 
> Signed-off-by: Matthias Brugger 
> Signed-off-by: Enric Balletbo i Serra 
> ---
> 
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/soc/mediatek/mt8173-pm-domains.h |  4 +--
>  drivers/soc/mediatek/mtk-pm-domains.c| 36 +---
>  drivers/soc/mediatek/mtk-pm-domains.h|  4 ++-
>  3 files changed, 31 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/soc/mediatek/mt8173-pm-domains.h 
> b/drivers/soc/mediatek/mt8173-pm-domains.h
> index a2a624bbd8b8..341cc287c8ce 100644
> --- a/drivers/soc/mediatek/mt8173-pm-domains.h
> +++ b/drivers/soc/mediatek/mt8173-pm-domains.h
> @@ -34,7 +34,7 @@ static const struct scpsys_domain_data 
> scpsys_domain_data_mt8173[] = {
>   .ctl_offs = SPM_DIS_PWR_CON,
>   .sram_pdn_bits = GENMASK(11, 8),
>   .sram_pdn_ack_bits = GENMASK(12, 12),
> - .bp_infracfg = {
> + .bp_infracfg[0] = {
>   .bus_prot_reg_update = true,
>   .bus_prot_mask = MT8173_TOP_AXI_PROT_EN_MM_M0 |
>   MT8173_TOP_AXI_PROT_EN_MM_M1,
> @@ -76,7 +76,7 @@ static const struct scpsys_domain_data 
> scpsys_domain_data_mt8173[] = {
>   .ctl_offs = SPM_MFG_PWR_CON,
>   .sram_pdn_bits = GENMASK(13, 8),
>   .sram_pdn_ack_bits = GENMASK(21, 16),
> - .bp_infracfg = {
> + .bp_infracfg[0] = {
>   .bus_prot_reg_update = true,
>   .bus_prot_mask = MT8173_TOP_AXI_PROT_EN_MFG_S |
>   MT8173_TOP_AXI_PROT_EN_MFG_M0 |
> diff --git a/drivers/soc/mediatek/mtk-pm-domains.c 
> b/drivers/soc/mediatek/mtk-pm-domains.c
> index 16503d6db6a8..2121e05cb9a4 100644
> --- a/drivers/soc/mediatek/mtk-pm-domains.c
> +++ b/drivers/soc/mediatek/mtk-pm-domains.c
> @@ -89,24 +89,40 @@ static int scpsys_sram_disable(struct scpsys_domain *pd)
>  
>  static int scpsys_bus_protect_enable(struct scpsys_domain *pd)
>  {
> - const struct scpsys_bus_prot_data *bp_data = >data->bp_infracfg;
> + const struct scpsys_bus_prot_data *bpd = pd->data->bp_infracfg;
> + int i, ret;
>  
> - if (!bp_data->bus_prot_mask)
> - return 0;
> + for (i = 0; i < SPM_MAX_BUS_PROT_DATA; i++) {
> + if (!bpd[i].bus_prot_mask)
> + break;
>  
> - return mtk_infracfg_set_bus_protection(pd->infracfg, 
> bp_data->bus_prot_mask,
> -bp_data->bus_prot_reg_update);
> + ret = mtk_infracfg_set_bus_protection(pd->infracfg,
> +   bpd[i].bus_prot_mask,
> +   
> bpd[i].bus_prot_reg_update);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
>  }
>  
>  static int scpsys_bus_protect_disable(struct scpsys_domain *pd)
>  {
> - const struct scpsys_bus_prot_data *bp_data = >data->bp_infracfg;
> + const struct scpsys_bus_prot_data *bpd = pd->data->bp_infracfg;
> + int i, ret;
>  
> - if (!bp_data->bus_prot_mask)
> - return 0;
> + for (i = 0; i < SPM_MAX_BUS_PROT_DATA; i++) {

I thought it should be

for (i = SPM_MAX_BUS_PROT_DATA - 1; i > 0; i--) {
if (!bpd[i].bus_prot_mask)
continue;

...

> + if (!bpd[i].bus_prot_mask)
> + return 0;
>  
> - return mtk_infracfg_clear_bus_protection(pd->infracfg, 
> bp_data->bus_prot_mask,
> -  bp_data->bus_prot_reg_update);
> + ret = mtk_infracfg_clear_bus_protection(pd->infracfg,
> + bpd[i].bus_prot_mask,
> + 
> bpd[i].bus_prot_reg_update);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
>  }
>  
>  static int scpsys_power_on(struct generic_pm_domain *genpd)
> diff --git a/drivers/soc/mediatek/mtk-pm-domains.h 
> b/drivers/soc/mediatek/mtk-pm-domains.h
> index 7c8efcb3cef2..e428fe23a7e3 100644
> --- a/drivers/soc/mediatek/mtk-pm-domains.h
> +++ b/drivers/soc/mediatek/mtk-pm-domains.h
> @@ -32,6 +32,8 @@
>  #define PWR_STATUS_AUDIO BIT(24)
>  #define PWR_STATUS_USB   BIT(25)
>  
> +#define SPM_MAX_BUS_PROT_DATA3
> +

#define SPM_MAX_BUS_PROT_DATA   5

to be compatible with MT8192

>  struct scpsys_bus_prot_data {
>   u32 bus_prot_mask;
>   bool bus_prot_reg_update;
> @@ -52,7 +54,7 @@ struct scpsys_domain_data {
>   u32 sram_pdn_bits;
>   u32 sram_pdn_ack_bits;
>   u8 caps;
> - const struct scpsys_bus_prot_data bp_infracfg;
> + const struct 

[PATCH 04/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT6779

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt6779.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6779.c 
b/drivers/clk/mediatek/clk-mt6779.c
index 9766ccc..d8444ed 100644
--- a/drivers/clk/mediatek/clk-mt6779.c
+++ b/drivers/clk/mediatek/clk-mt6779.c
@@ -1178,33 +1178,33 @@
_pcw_chg_reg, NULL)
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0,
PLL_AO, 0, 22, 8, 0x0204, 24, 0, 0, 0, 0x0204, 0, 0),
-   PLL(CLK_APMIXED_ARMPLL_BL, "armpll_bl", 0x0210, 0x021C, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL_BL, "armpll_bl", 0x0210, 0x021C, 0,
PLL_AO, 0, 22, 8, 0x0214, 24, 0, 0, 0, 0x0214, 0, 0),
-   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x02A0, 0x02AC, BIT(0),
+   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x02A0, 0x02AC, 0,
PLL_AO, 0, 22, 8, 0x02A4, 24, 0, 0, 0, 0x02A4, 0, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, BIT(0),
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0,
(HAVE_RST_BAR), BIT(24), 22, 8, 0x0234, 24, 0, 0, 0,
0x0234, 0, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0240, 0x024C, BIT(0),
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0240, 0x024C, 0,
(HAVE_RST_BAR), BIT(24), 22, 8, 0x0244, 24,
0, 0, 0, 0x0244, 0, 0),
-   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0250, 0x025C, BIT(0),
+   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0250, 0x025C, 0,
0, 0, 22, 8, 0x0254, 24, 0, 0, 0, 0x0254, 0, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0260, 0x026C, BIT(0),
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0260, 0x026C, 0,
0, 0, 22, 8, 0x0264, 24, 0, 0, 0, 0x0264, 0, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, BIT(0),
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, 0,
0, 0, 22, 8, 0x0274, 24, 0, 0, 0, 0x0274, 0, 0),
-   PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x02b0, 0x02bC, BIT(0),
+   PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x02b0, 0x02bC, 0,
(HAVE_RST_BAR), BIT(23), 22, 8, 0x02b4, 24,
0, 0, 0, 0x02b4, 0, 0),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0280, 0x028C, BIT(0),
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0280, 0x028C, 0,
(HAVE_RST_BAR), BIT(23), 22, 8, 0x0284, 24,
0, 0, 0, 0x0284, 0, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x02C0, 0x02D0, BIT(0),
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x02C0, 0x02D0, 0,
0, 0, 32, 8, 0x02C0, 1, 0, 0x14, 0, 0x02C4, 0, 0x2C0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x02D4, 0x02E4, BIT(0),
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x02D4, 0x02E4, 0,
0, 0, 32, 8, 0x02D4, 1, 0, 0x14, 1, 0x02D8, 0, 0x02D4),
 };
 
-- 
1.8.1.1.dirty


[PATCH 02/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT2712

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt2712.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt2712.c 
b/drivers/clk/mediatek/clk-mt2712.c
index a3bd9a1..fd81162 100644
--- a/drivers/clk/mediatek/clk-mt2712.c
+++ b/drivers/clk/mediatek/clk-mt2712.c
@@ -1222,38 +1222,38 @@
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf101,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf100,
HAVE_RST_BAR, 31, 0x0230, 4, 0, 0, 0, 0x0234, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000101,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000100,
HAVE_RST_BAR, 31, 0x0240, 4, 0, 0, 0, 0x0244, 0),
-   PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc101,
+   PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc100,
0, 31, 0x0320, 4, 0, 0, 0, 0x0324, 0),
-   PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x0101,
+   PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x0100,
0, 31, 0x0280, 4, 0, 0, 0, 0x0284, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x0101,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x0100,
0, 31, 0x0330, 4, 0x0338, 0x0014, 0, 0x0334, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x0101,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x0100,
0, 31, 0x0350, 4, 0x0358, 0x0014, 1, 0x0354, 0),
-   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x0101,
+   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x0100,
0, 31, 0x0370, 4, 0, 0, 0, 0x0374, 0),
-   PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x0101,
+   PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x0100,
0, 31, 0x0390, 4, 0, 0, 0, 0x0394, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x0101,
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x0100,
0, 31, 0x0270, 4, 0, 0, 0, 0x0274, 0),
-   PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x0101,
+   PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x0100,
0, 31, 0x0410, 4, 0, 0, 0, 0x0414, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc101,
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc100,
0, 31, 0x0290, 4, 0, 0, 0, 0x0294, 0),
-   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x0101,
+   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x0100,
0, 31, 0x0250, 4, 0, 0, 0, 0x0254, 0,
mmpll_div_table),
-   PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf101,
+   PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf100,
HAVE_RST_BAR, 31, 0x0100, 4, 0, 0, 0, 0x0104, 0,
armca35pll_div_table),
-   PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x0101,
+   PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x0100,
0, 31, 0x0210, 4, 0, 0, 0, 0x0214, 0,
armca72pll_div_table),
-   PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc101,
+   PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc100,
0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH 03/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT6765

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt6765.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6765.c 
b/drivers/clk/mediatek/clk-mt6765.c
index db8db1b..097bbc4 100644
--- a/drivers/clk/mediatek/clk-mt6765.c
+++ b/drivers/clk/mediatek/clk-mt6765.c
@@ -747,26 +747,26 @@
_pcw_reg, _pcw_shift, NULL) \
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x021C, 0x0228, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x021C, 0x0228, 0,
PLL_AO, 22, 8, 0x0220, 24, 0, 0, 0, 0x0220, 0),
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x020C, 0x0218, BIT(0),
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x020C, 0x0218, 0,
PLL_AO, 22, 8, 0x0210, 24, 0, 0, 0, 0x0210, 0),
-   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x022C, 0x0238, BIT(0),
+   PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x022C, 0x0238, 0,
PLL_AO, 22, 8, 0x0230, 24, 0, 0, 0, 0x0230, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x023C, 0x0248, BIT(0),
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x023C, 0x0248, 0,
(HAVE_RST_BAR | PLL_AO), 22, 8, 0x0240, 24, 0, 0, 0, 0x0240,
0),
-   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x024C, 0x0258, BIT(0),
+   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x024C, 0x0258, 0,
0, 22, 8, 0x0250, 24, 0, 0, 0, 0x0250, 0),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x025C, 0x0268, BIT(0),
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x025C, 0x0268, 0,
0, 22, 8, 0x0260, 24, 0, 0, 0, 0x0260, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x026C, 0x0278, BIT(0),
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x026C, 0x0278, 0,
HAVE_RST_BAR, 22, 8, 0x0270, 24, 0, 0, 0, 0x0270, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x027C, 0x0288, BIT(0),
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x027C, 0x0288, 0,
0, 22, 8, 0x0280, 24, 0, 0, 0, 0x0280, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x028C, 0x029C, BIT(0),
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x028C, 0x029C, 0,
0, 32, 8, 0x0290, 24, 0x0040, 0x000C, 0, 0x0294, 0),
-   PLL(CLK_APMIXED_MPLL, "mpll", 0x02A0, 0x02AC, BIT(0),
+   PLL(CLK_APMIXED_MPLL, "mpll", 0x02A0, 0x02AC, 0,
PLL_AO, 22, 8, 0x02A4, 24, 0, 0, 0, 0x02A4, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH 11/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8516

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8516.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8516.c 
b/drivers/clk/mediatek/clk-mt8516.c
index 9d4261e..ec215e5 100644
--- a/drivers/clk/mediatek/clk-mt8516.c
+++ b/drivers/clk/mediatek/clk-mt8516.c
@@ -770,17 +770,17 @@ static void __init mtk_infracfg_init(struct device_node 
*node)
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0x0001, 0,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0,
21, 0x0104, 24, 0, 0x0104, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0,
HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x3001,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x3000,
HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0),
-   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0x0001, 0,
+   PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0,
21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0x0001, 0,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0,
31, 0x0180, 1, 0x0194, 0x0184, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0x0001, 0,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0,
31, 0x01A0, 1, 0x01B4, 0x01A4, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH 05/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT6797

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt6797.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6797.c 
b/drivers/clk/mediatek/clk-mt6797.c
index f35389a..4395423 100644
--- a/drivers/clk/mediatek/clk-mt6797.c
+++ b/drivers/clk/mediatek/clk-mt6797.c
@@ -638,25 +638,25 @@ static int mtk_infrasys_init(struct platform_device *pdev)
NULL)
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0xF101, PLL_AO,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0xF100, PLL_AO,
21, 0x220, 4, 0x0, 0x224, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0230, 0x023C, 0xFE11, 0, 7,
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0230, 0x023C, 0xFE10, 0, 7,
0x230, 4, 0x0, 0x234, 14),
-   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0x0101, 0, 21,
+   PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0x0100, 0, 21,
0x244, 24, 0x0, 0x244, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0x0120, 0, 21,
0x250, 4, 0x0, 0x254, 0),
-   PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0260, 0x026C, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0260, 0x026C, 0x0120, 0, 21,
0x260, 4, 0x0, 0x264, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, 0xC121, 0, 21,
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0270, 0x027C, 0xC120, 0, 21,
0x270, 4, 0x0, 0x274, 0),
-   PLL(CLK_APMIXED_CODECPLL, "codecpll", 0x0290, 0x029C, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_CODECPLL, "codecpll", 0x0290, 0x029C, 0x0120, 0, 21,
0x290, 4, 0x0, 0x294, 0),
-   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x02E4, 0x02F0, 0x0121, 0, 21,
+   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x02E4, 0x02F0, 0x0120, 0, 21,
0x2E4, 4, 0x0, 0x2E8, 0),
-   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0x0131, 0, 31,
+   PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0x0130, 0, 31,
0x2A0, 4, 0x2A8, 0x2A4, 0),
-   PLL(CLK_APMIXED_APLL2, "apll2", 0x02B4, 0x02C4, 0x0131, 0, 31,
+   PLL(CLK_APMIXED_APLL2, "apll2", 0x02B4, 0x02C4, 0x0130, 0, 31,
0x2B4, 4, 0x2BC, 0x2B8, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH 00/12] Clean up the pll_en_bit from en_mask on all the MediaTek clock drivers

2020-10-22 Thread Weiyi Lu
This series is based on v5.9-rc1 and
[v4,09/34] clk: mediatek: Fix asymmetrical PLL enable and disable control[1]
in Mediatek MT8192 clock support series

[1] 
https://patchwork.kernel.org/project/linux-mediatek/patch/1603370247-30437-10-git-send-email-weiyi...@mediatek.com/

Weiyi Lu (12):
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT2701
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT2712
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT6765
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT6779
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT6797
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT7622
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT7629
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8135
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8173
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8183
  clk: mediatek: Clean up the pll_en_bit from en_mask on MT8516
  clk: mediatek: limit en_mask to a pure div_en_mask

 drivers/clk/mediatek/clk-mt2701.c | 26 +-
 drivers/clk/mediatek/clk-mt2712.c | 30 +++---
 drivers/clk/mediatek/clk-mt6765.c | 20 ++--
 drivers/clk/mediatek/clk-mt6779.c | 24 
 drivers/clk/mediatek/clk-mt6797.c | 20 ++--
 drivers/clk/mediatek/clk-mt7622.c | 18 +-
 drivers/clk/mediatek/clk-mt7629.c | 12 ++--
 drivers/clk/mediatek/clk-mt8135.c | 20 ++--
 drivers/clk/mediatek/clk-mt8173.c | 28 ++--
 drivers/clk/mediatek/clk-mt8183.c | 22 +++---
 drivers/clk/mediatek/clk-mt8516.c | 12 ++--
 drivers/clk/mediatek/clk-pll.c| 12 
 12 files changed, 120 insertions(+), 124 deletions(-)


[PATCH 08/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT8135

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8135.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8135.c 
b/drivers/clk/mediatek/clk-mt8135.c
index 9b4b645..a1d462f 100644
--- a/drivers/clk/mediatek/clk-mt8135.c
+++ b/drivers/clk/mediatek/clk-mt8135.c
@@ -611,16 +611,16 @@ static void __init mtk_pericfg_init(struct device_node 
*node)
}
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x8001, 0, 21, 
0x204, 24, 0x0, 0x204, 0),
-   PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x8001, 0, 21, 
0x2d0, 24, 0x0, 0x2d0, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf001, 
HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0),
-   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf301, 
HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9),
-   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf001, HAVE_RST_BAR, 
21, 0x254, 6, 0x0, 0x258, 0),
-   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x8001, 0, 21, 
0x278, 6, 0x0, 0x27c, 0),
-   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x8001, 0, 31, 
0x294, 6, 0x0, 0x298, 0),
-   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8,   0x8001, 0, 
21, 0x2b0, 6, 0x0, 0x2b4, 0),
-   PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x8001, 0, 31, 
0x2e8, 6, 0x2f8, 0x2ec, 0),
-   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c,   0x8001, 0, 
21, 0x2b0, 6, 0x0, 0x308, 0),
+   PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x8000, 0, 21, 
0x204, 24, 0x0, 0x204, 0),
+   PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x8000, 0, 21, 
0x2d0, 24, 0x0, 0x2d0, 0),
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf000, 
HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0),
+   PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf300, 
HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9),
+   PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf000, HAVE_RST_BAR, 
21, 0x254, 6, 0x0, 0x258, 0),
+   PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x8000, 0, 21, 
0x278, 6, 0x0, 0x27c, 0),
+   PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x8000, 0, 31, 
0x294, 6, 0x0, 0x298, 0),
+   PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8, 0x8000, 0, 21, 
0x2b0, 6, 0x0, 0x2b4, 0),
+   PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x8000, 0, 31, 
0x2e8, 6, 0x2f8, 0x2ec, 0),
+   PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x8000, 0, 21, 
0x2b0, 6, 0x0, 0x308, 0),
 };
 
 static void __init mtk_apmixedsys_init(struct device_node *node)
-- 
1.8.1.1.dirty


[PATCH 06/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT7622

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt7622.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt7622.c 
b/drivers/clk/mediatek/clk-mt7622.c
index ef5947e1..2fdb27a 100644
--- a/drivers/clk/mediatek/clk-mt7622.c
+++ b/drivers/clk/mediatek/clk-mt7622.c
@@ -328,23 +328,23 @@
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0001,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0,
PLL_AO, 21, 0x0204, 24, 0, 0x0204, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0,
HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0x0001,
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0,
HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14),
-   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0x0001,
+   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0,
0, 21, 0x0300, 1, 0, 0x0304, 0),
-   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0x0001,
+   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0,
0, 21, 0x0314, 1, 0, 0x0318, 0),
-   PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0x0001,
+   PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0,
0, 31, 0x0324, 1, 0, 0x0328, 0),
-   PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0x0001,
+   PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0,
0, 31, 0x0334, 1, 0, 0x0338, 0),
-   PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0x0001,
+   PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0,
0, 21, 0x0344, 1, 0, 0x0348, 0),
-   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0x0001,
+   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0,
0, 21, 0x0358, 1, 0, 0x035C, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH 07/12] clk: mediatek: Clean up the pll_en_bit from en_mask on MT7629

2020-10-22 Thread Weiyi Lu
remove pll_en_bit(bit0) from en_mask to make en_mask a pure en_mask
that only used for pll dividers.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt7629.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt7629.c 
b/drivers/clk/mediatek/clk-mt7629.c
index b73bdf1..e2105ea 100644
--- a/drivers/clk/mediatek/clk-mt7629.c
+++ b/drivers/clk/mediatek/clk-mt7629.c
@@ -335,17 +335,17 @@
 };
 
 static const struct mtk_pll_data plls[] = {
-   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0001,
+   PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0,
0, 21, 0x0204, 24, 0, 0x0204, 0),
-   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0x0001,
+   PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0,
HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0),
-   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0x0001,
+   PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0,
HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14),
-   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0x0001,
+   PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0,
0, 21, 0x0300, 1, 0, 0x0304, 0),
-   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0x0001,
+   PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0,
0, 21, 0x0314, 1, 0, 0x0318, 0),
-   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0x0001,
+   PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0,
0, 21, 0x0358, 1, 0, 0x035C, 0),
 };
 
-- 
1.8.1.1.dirty


[PATCH 12/12] clk: mediatek: limit en_mask to a pure div_en_mask

2020-10-22 Thread Weiyi Lu
Because all pll data has been updated. We no longer allow
en_mask is a combination of pll_en_bit and div_en_mask.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-pll.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index 11ed5d1..e0b00bc 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -238,7 +238,6 @@ static int mtk_pll_prepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
-   u32 div_en_mask;
 
r = readl(pll->pwr_addr) | CON0_PWR_ON;
writel(r, pll->pwr_addr);
@@ -251,9 +250,8 @@ static int mtk_pll_prepare(struct clk_hw *hw)
r = readl(pll->base_addr + REG_CON0) | CON0_BASE_EN;
writel(r, pll->base_addr + REG_CON0);
 
-   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
-   if (div_en_mask) {
-   r = readl(pll->base_addr + REG_CON0) | div_en_mask;
+   if (pll->data->en_mask) {
+   r = readl(pll->base_addr + REG_CON0) | pll->data->en_mask;
writel(r, pll->base_addr + REG_CON0);
}
 
@@ -274,7 +272,6 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 {
struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
u32 r;
-   u32 div_en_mask;
 
if (pll->data->flags & HAVE_RST_BAR) {
r = readl(pll->base_addr + REG_CON0);
@@ -284,9 +281,8 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 
__mtk_pll_tuner_disable(pll);
 
-   div_en_mask = pll->data->en_mask & ~CON0_BASE_EN;
-   if (div_en_mask) {
-   r = readl(pll->base_addr + REG_CON0) & ~div_en_mask;
+   if (pll->data->en_mask) {
+   r = readl(pll->base_addr + REG_CON0) & ~pll->data->en_mask;
writel(r, pll->base_addr + REG_CON0);
}
 
-- 
1.8.1.1.dirty


  1   2   3   4   5   6   7   >