mbox series

[v4,00/16] soc: mediatek: pm-domains: Add new driver for SCPSYS power domains controller

Message ID 20201030113622.201188-1-enric.balletbo@collabora.com
Headers show
Series soc: mediatek: pm-domains: Add new driver for SCPSYS power domains controller | expand

Message

Enric Balletbo i Serra Oct. 30, 2020, 11:36 a.m. UTC
Dear all,

This is a new driver with the aim to deprecate the mtk-scpsys driver.
The problem with that driver is that, in order to support more Mediatek
SoCs you need to add some logic to handle properly the power-up
sequence of newer Mediatek SoCs, doesn't handle parent-child power
domains and need to hardcode all the clocks in the driver itself. The
result is that the driver is getting bigger and bigger every time a
new SoC needs to be supported.

All this information can be getted from a properly defined binding, so
can be cleaner and smaller, hence, we implemented a new driver. For
now, only MT8173 and MT8183 is supported but should be fairly easy to
add support for new SoCs.

Three important notes:

1. This patch depends now on [1] to build correctly.

2. Support for MT8183 is not ready to land yet because has some
   dependencies, i.e mmsys support is still missing.

3. Support for MT8192. I picked the patches [2] from Weiyi Lu and
   adapted to this new series. I posted only for reference due that this
   new version has some changes that affects that patchset.

Only patches from 1 to 9 are ready, the others are provided for reference and test.

[1] https://lore.kernel.org/patchwork/patch/1328096/
[2] https://patchwork.kernel.org/project/linux-mediatek/list/?series=368821

Best regards,
  Enric

Enric Balletbo i Serra (5):
  dt-bindings: power: Add bindings for the Mediatek SCPSYS power domains
    controller
  soc: mediatek: Add MediaTek SCPSYS power domains
  arm64: dts: mediatek: Add mt8173 power domain controller
  dt-bindings: power: Add MT8183 power domains
  arm64: dts: mediatek: Add smi_common node for MT8183

Matthias Brugger (8):
  soc: mediatek: pm-domains: Add bus protection protocol
  soc: mediatek: pm_domains: Make bus protection generic
  soc: mediatek: pm-domains: Add SMI block as bus protection block
  soc: mediatek: pm-domains: Add extra sram control
  soc: mediatek: pm-domains: Add subsystem clocks
  soc: mediatek: pm-domains: Allow bus protection to ignore clear ack
  soc: mediatek: pm-domains: Add support for mt8183
  arm64: dts: mediatek: Add mt8183 power domains controller

Weiyi Lu (3):
  dt-bindings: power: Add MT8192 power domains
  soc: mediatek: pm-domains: Add default power off flag
  soc: mediatek: pm-domains: Add support for mt8192

 .../power/mediatek,power-controller.yaml      | 293 +++++++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi      | 164 +++--
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      | 172 +++++
 drivers/soc/mediatek/Kconfig                  |  12 +
 drivers/soc/mediatek/Makefile                 |   1 +
 drivers/soc/mediatek/mt8173-pm-domains.h      |  94 +++
 drivers/soc/mediatek/mt8183-pm-domains.h      | 221 +++++++
 drivers/soc/mediatek/mt8192-pm-domains.h      | 292 +++++++++
 drivers/soc/mediatek/mtk-infracfg.c           |   5 -
 drivers/soc/mediatek/mtk-pm-domains.c         | 614 ++++++++++++++++++
 drivers/soc/mediatek/mtk-pm-domains.h         | 102 +++
 include/dt-bindings/power/mt8183-power.h      |  26 +
 include/dt-bindings/power/mt8192-power.h      |  32 +
 include/linux/soc/mediatek/infracfg.h         | 107 +++
 14 files changed, 2081 insertions(+), 54 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/mediatek,power-controller.yaml
 create mode 100644 drivers/soc/mediatek/mt8173-pm-domains.h
 create mode 100644 drivers/soc/mediatek/mt8183-pm-domains.h
 create mode 100644 drivers/soc/mediatek/mt8192-pm-domains.h
 create mode 100644 drivers/soc/mediatek/mtk-pm-domains.c
 create mode 100644 drivers/soc/mediatek/mtk-pm-domains.h
 create mode 100644 include/dt-bindings/power/mt8183-power.h
 create mode 100644 include/dt-bindings/power/mt8192-power.h

Comments

Rob Herring Nov. 4, 2020, 10:03 p.m. UTC | #1
On Fri, 30 Oct 2020 12:36:16 +0100, Enric Balletbo i Serra wrote:
> Add power domains dt-bindings for MT8183.

> 

> Signed-off-by: Matthias Brugger <mbrugger@suse.com>

> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

> ---

> 

> Changes in v4: None

> Changes in v3: None

> Changes in v2: None

> 

>  .../power/mediatek,power-controller.yaml      |  2 ++

>  include/dt-bindings/power/mt8183-power.h      | 26 +++++++++++++++++++

>  2 files changed, 28 insertions(+)

>  create mode 100644 include/dt-bindings/power/mt8183-power.h

> 


Acked-by: Rob Herring <robh@kernel.org>
Weiyi Lu Nov. 27, 2020, 2:24 a.m. UTC | #2
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 <mbrugger@suse.com>

> Signed-off-by: Matthias Brugger <mbrugger@suse.com>

> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

> Reviewed-by: Rob Herring <robh@kernel.org>

> ---

> 

> 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 000000000000..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 <weiyi.lu@mediatek.com>

> +  - Matthias Brugger <mbrugger@suse.com>

> +

> +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.

> +

> +        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:

> +            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.

> +

> +            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:

> +                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.

> +

> +            required:

> +              - reg

> +

> +            additionalProperties: false

> +

> +        required:

> +          - reg

> +

> +        additionalProperties: false

> +

> +    required:

> +      - reg

> +

> +    additionalProperties: false

> +

> +required:

> +  - compatible

> +

> +additionalProperties: false

> +

> +examples:

> +  - |

> +    #include <dt-bindings/clock/mt8173-clk.h>

> +    #include <dt-bindings/power/mt8173-power.h>

> +

> +    soc {

> +        #address-cells = <2>;

> +        #size-cells = <2>;

> +

> +        scpsys: syscon@10006000 {

> +            compatible = "syscon", "simple-mfd";

> +            reg = <0 0x10006000 0 0x1000>;

> +

> +            spm: power-controller {

> +                compatible = "mediatek,mt8173-power-controller";

> +                #address-cells = <1>;

> +                #size-cells = <0>;

> +                #power-domain-cells = <1>;


Hi Enric and Matthias,

I'd like to know whether we could only keep this power-domain-cells
property here and make others optional, which can more directly point
out who is the real power domain provider?

> +

> +                /* power domains of the SoC */

> +                power-domain@MT8173_POWER_DOMAIN_VDEC {

> +                    reg = <MT8173_POWER_DOMAIN_VDEC>;

> +                    clocks = <&topckgen CLK_TOP_MM_SEL>;

> +                    clock-names = "mm";

> +                    #power-domain-cells = <0>;

> +                };

> +                power-domain@MT8173_POWER_DOMAIN_VENC {

> +                    reg = <MT8173_POWER_DOMAIN_VENC>;

> +                    clocks = <&topckgen CLK_TOP_MM_SEL>,

> +                             <&topckgen CLK_TOP_VENC_SEL>;

> +                    clock-names = "mm", "venc";

> +                    #power-domain-cells = <0>;

> +                };

> +                power-domain@MT8173_POWER_DOMAIN_ISP {

> +                    reg = <MT8173_POWER_DOMAIN_ISP>;

> +                    clocks = <&topckgen CLK_TOP_MM_SEL>;

> +                    clock-names = "mm";

> +                    #power-domain-cells = <0>;

> +                };

> +                power-domain@MT8173_POWER_DOMAIN_MM {

> +                    reg = <MT8173_POWER_DOMAIN_MM>;

> +                    clocks = <&topckgen CLK_TOP_MM_SEL>;

> +                    clock-names = "mm";

> +                    #power-domain-cells = <0>;

> +                    mediatek,infracfg = <&infracfg>;

> +                };

> +                power-domain@MT8173_POWER_DOMAIN_VENC_LT {

> +                    reg = <MT8173_POWER_DOMAIN_VENC_LT>;

> +                    clocks = <&topckgen CLK_TOP_MM_SEL>,

> +                             <&topckgen CLK_TOP_VENC_LT_SEL>;

> +                    clock-names = "mm", "venclt";

> +                    #power-domain-cells = <0>;

> +                };

> +                power-domain@MT8173_POWER_DOMAIN_AUDIO {

> +                    reg = <MT8173_POWER_DOMAIN_AUDIO>;

> +                    #power-domain-cells = <0>;

> +                };

> +                power-domain@MT8173_POWER_DOMAIN_USB {

> +                    reg = <MT8173_POWER_DOMAIN_USB>;

> +                    #power-domain-cells = <0>;

> +                };

> +                power-domain@MT8173_POWER_DOMAIN_MFG_ASYNC {

> +                    reg = <MT8173_POWER_DOMAIN_MFG_ASYNC>;

> +                    clocks = <&clk26m>;

> +                    clock-names = "mfg";

> +                    #address-cells = <1>;

> +                    #size-cells = <0>;

> +                    #power-domain-cells = <1>;

> +

> +                    power-domain@MT8173_POWER_DOMAIN_MFG_2D {

> +                        reg = <MT8173_POWER_DOMAIN_MFG_2D>;

> +                        #address-cells = <1>;

> +                        #size-cells = <0>;

> +                        #power-domain-cells = <1>;

> +

> +                        power-domain@MT8173_POWER_DOMAIN_MFG {

> +                            reg = <MT8173_POWER_DOMAIN_MFG>;

> +                            #power-domain-cells = <0>;

> +                            mediatek,infracfg = <&infracfg>;

> +                        };

> +                    };

> +                };

> +            };

> +        };

> +    };
Enric Balletbo i Serra Nov. 27, 2020, 8:56 a.m. UTC | #3
Hi Weiyi,

On 27/11/20 3:24, Weiyi Lu wrote:
> 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 <mbrugger@suse.com>

>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>

>> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

>> Reviewed-by: Rob Herring <robh@kernel.org>

>> ---

>>

>> 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 000000000000..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 <weiyi.lu@mediatek.com>

>> +  - Matthias Brugger <mbrugger@suse.com>

>> +

>> +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.

>> +

>> +        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:

>> +            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.

>> +

>> +            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:

>> +                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.

>> +

>> +            required:

>> +              - reg

>> +

>> +            additionalProperties: false

>> +

>> +        required:

>> +          - reg

>> +

>> +        additionalProperties: false

>> +

>> +    required:

>> +      - reg

>> +

>> +    additionalProperties: false

>> +

>> +required:

>> +  - compatible

>> +

>> +additionalProperties: false

>> +

>> +examples:

>> +  - |

>> +    #include <dt-bindings/clock/mt8173-clk.h>

>> +    #include <dt-bindings/power/mt8173-power.h>

>> +

>> +    soc {

>> +        #address-cells = <2>;

>> +        #size-cells = <2>;

>> +

>> +        scpsys: syscon@10006000 {

>> +            compatible = "syscon", "simple-mfd";

>> +            reg = <0 0x10006000 0 0x1000>;

>> +

>> +            spm: power-controller {

>> +                compatible = "mediatek,mt8173-power-controller";

>> +                #address-cells = <1>;

>> +                #size-cells = <0>;

>> +                #power-domain-cells = <1>;

> 

> Hi Enric and Matthias,

> 

> I'd like to know whether we could only keep this power-domain-cells

> property here and make others optional, which can more directly point

> out who is the real power domain provider?

> 


This is enforced by the generic power-domain binding
(Documentation/devicetree/bindings/power/power-domain.yaml) as a required
property. So, if needs to be changed, should be changed there. My understanding,
though, is that (like the binding is) this property should be required to
properly define a power-domain.

Cheers,
 Enric

>> +

>> +                /* power domains of the SoC */

>> +                power-domain@MT8173_POWER_DOMAIN_VDEC {

>> +                    reg = <MT8173_POWER_DOMAIN_VDEC>;

>> +                    clocks = <&topckgen CLK_TOP_MM_SEL>;

>> +                    clock-names = "mm";

>> +                    #power-domain-cells = <0>;

>> +                };

>> +                power-domain@MT8173_POWER_DOMAIN_VENC {

>> +                    reg = <MT8173_POWER_DOMAIN_VENC>;

>> +                    clocks = <&topckgen CLK_TOP_MM_SEL>,

>> +                             <&topckgen CLK_TOP_VENC_SEL>;

>> +                    clock-names = "mm", "venc";

>> +                    #power-domain-cells = <0>;

>> +                };

>> +                power-domain@MT8173_POWER_DOMAIN_ISP {

>> +                    reg = <MT8173_POWER_DOMAIN_ISP>;

>> +                    clocks = <&topckgen CLK_TOP_MM_SEL>;

>> +                    clock-names = "mm";

>> +                    #power-domain-cells = <0>;

>> +                };

>> +                power-domain@MT8173_POWER_DOMAIN_MM {

>> +                    reg = <MT8173_POWER_DOMAIN_MM>;

>> +                    clocks = <&topckgen CLK_TOP_MM_SEL>;

>> +                    clock-names = "mm";

>> +                    #power-domain-cells = <0>;

>> +                    mediatek,infracfg = <&infracfg>;

>> +                };

>> +                power-domain@MT8173_POWER_DOMAIN_VENC_LT {

>> +                    reg = <MT8173_POWER_DOMAIN_VENC_LT>;

>> +                    clocks = <&topckgen CLK_TOP_MM_SEL>,

>> +                             <&topckgen CLK_TOP_VENC_LT_SEL>;

>> +                    clock-names = "mm", "venclt";

>> +                    #power-domain-cells = <0>;

>> +                };

>> +                power-domain@MT8173_POWER_DOMAIN_AUDIO {

>> +                    reg = <MT8173_POWER_DOMAIN_AUDIO>;

>> +                    #power-domain-cells = <0>;

>> +                };

>> +                power-domain@MT8173_POWER_DOMAIN_USB {

>> +                    reg = <MT8173_POWER_DOMAIN_USB>;

>> +                    #power-domain-cells = <0>;

>> +                };

>> +                power-domain@MT8173_POWER_DOMAIN_MFG_ASYNC {

>> +                    reg = <MT8173_POWER_DOMAIN_MFG_ASYNC>;

>> +                    clocks = <&clk26m>;

>> +                    clock-names = "mfg";

>> +                    #address-cells = <1>;

>> +                    #size-cells = <0>;

>> +                    #power-domain-cells = <1>;

>> +

>> +                    power-domain@MT8173_POWER_DOMAIN_MFG_2D {

>> +                        reg = <MT8173_POWER_DOMAIN_MFG_2D>;

>> +                        #address-cells = <1>;

>> +                        #size-cells = <0>;

>> +                        #power-domain-cells = <1>;

>> +

>> +                        power-domain@MT8173_POWER_DOMAIN_MFG {

>> +                            reg = <MT8173_POWER_DOMAIN_MFG>;

>> +                            #power-domain-cells = <0>;

>> +                            mediatek,infracfg = <&infracfg>;

>> +                        };

>> +                    };

>> +                };

>> +            };

>> +        };

>> +    };

>
Matthias Brugger Nov. 27, 2020, 11:19 a.m. UTC | #4
On 30/10/2020 12:36, Enric Balletbo i Serra wrote:
> Dear all,

> 

> This is a new driver with the aim to deprecate the mtk-scpsys driver.

> The problem with that driver is that, in order to support more Mediatek

> SoCs you need to add some logic to handle properly the power-up

> sequence of newer Mediatek SoCs, doesn't handle parent-child power

> domains and need to hardcode all the clocks in the driver itself. The

> result is that the driver is getting bigger and bigger every time a

> new SoC needs to be supported.

> 

> All this information can be getted from a properly defined binding, so

> can be cleaner and smaller, hence, we implemented a new driver. For

> now, only MT8173 and MT8183 is supported but should be fairly easy to

> add support for new SoCs.

> 


All patches are pushed:
DT-bindings went to v5.10-next/pm-domains-stable as they are needed by both soc 
and dts64 branch.

Regards,
Matthias

> Three important notes:

> 

> 1. This patch depends now on [1] to build correctly.

> 

> 2. Support for MT8183 is not ready to land yet because has some

>     dependencies, i.e mmsys support is still missing.

> 

> 3. Support for MT8192. I picked the patches [2] from Weiyi Lu and

>     adapted to this new series. I posted only for reference due that this

>     new version has some changes that affects that patchset.

> 

> Only patches from 1 to 9 are ready, the others are provided for reference and test.

> 

> [1] https://lore.kernel.org/patchwork/patch/1328096/

> [2] https://patchwork.kernel.org/project/linux-mediatek/list/?series=368821

> 

> Best regards,

>    Enric

> 

> Enric Balletbo i Serra (5):

>    dt-bindings: power: Add bindings for the Mediatek SCPSYS power domains

>      controller

>    soc: mediatek: Add MediaTek SCPSYS power domains

>    arm64: dts: mediatek: Add mt8173 power domain controller

>    dt-bindings: power: Add MT8183 power domains

>    arm64: dts: mediatek: Add smi_common node for MT8183

> 

> Matthias Brugger (8):

>    soc: mediatek: pm-domains: Add bus protection protocol

>    soc: mediatek: pm_domains: Make bus protection generic

>    soc: mediatek: pm-domains: Add SMI block as bus protection block

>    soc: mediatek: pm-domains: Add extra sram control

>    soc: mediatek: pm-domains: Add subsystem clocks

>    soc: mediatek: pm-domains: Allow bus protection to ignore clear ack

>    soc: mediatek: pm-domains: Add support for mt8183

>    arm64: dts: mediatek: Add mt8183 power domains controller

> 

> Weiyi Lu (3):

>    dt-bindings: power: Add MT8192 power domains

>    soc: mediatek: pm-domains: Add default power off flag

>    soc: mediatek: pm-domains: Add support for mt8192

> 

>   .../power/mediatek,power-controller.yaml      | 293 +++++++++

>   arch/arm64/boot/dts/mediatek/mt8173.dtsi      | 164 +++--

>   arch/arm64/boot/dts/mediatek/mt8183.dtsi      | 172 +++++

>   drivers/soc/mediatek/Kconfig                  |  12 +

>   drivers/soc/mediatek/Makefile                 |   1 +

>   drivers/soc/mediatek/mt8173-pm-domains.h      |  94 +++

>   drivers/soc/mediatek/mt8183-pm-domains.h      | 221 +++++++

>   drivers/soc/mediatek/mt8192-pm-domains.h      | 292 +++++++++

>   drivers/soc/mediatek/mtk-infracfg.c           |   5 -

>   drivers/soc/mediatek/mtk-pm-domains.c         | 614 ++++++++++++++++++

>   drivers/soc/mediatek/mtk-pm-domains.h         | 102 +++

>   include/dt-bindings/power/mt8183-power.h      |  26 +

>   include/dt-bindings/power/mt8192-power.h      |  32 +

>   include/linux/soc/mediatek/infracfg.h         | 107 +++

>   14 files changed, 2081 insertions(+), 54 deletions(-)

>   create mode 100644 Documentation/devicetree/bindings/power/mediatek,power-controller.yaml

>   create mode 100644 drivers/soc/mediatek/mt8173-pm-domains.h

>   create mode 100644 drivers/soc/mediatek/mt8183-pm-domains.h

>   create mode 100644 drivers/soc/mediatek/mt8192-pm-domains.h

>   create mode 100644 drivers/soc/mediatek/mtk-pm-domains.c

>   create mode 100644 drivers/soc/mediatek/mtk-pm-domains.h

>   create mode 100644 include/dt-bindings/power/mt8183-power.h

>   create mode 100644 include/dt-bindings/power/mt8192-power.h

>