2022-11-29 16:25:53

by Alexandre Mergnat

[permalink] [raw]
Subject: [PATCH v7 0/8] Add MediaTek MT6357 PMIC support

Hi,
This patch series adds MFD, PMIC keys, and regulator support for MT6357.
MT6357 is a MediaTek PMIC very similar to MT6358.

Currently, MTK bindings related to the PMICs are not converted yet (still .txt):

soc/mediatek/pwrap.txt (all PMIC parent)
|
V
mfd/mt6397.txt (support lot of mt63XX PMIC)
+---------------+----------------+---...
V V V
regulator/... rtc/... codec/...

1) Convert pwrap to yaml is ok.

2) For the PMIC bindings, there are two option:
- Convert mt6397.txt to mediatek,mt6397.yaml and continue to support multiple
PMIC with only one file. IMO, the file will be hard to read because
the supported features aren't the same for each PMIC.

- Make a binding file for each PMIC ref:
- mfd/mediatek,mt6357.yaml
- mfd/mediatek,mt6358.yaml
- ...

3) All PMIC daughter bindings (regulator, rtc, codec, led, ...) aren't fully
converted yet. Refering to the two PMIC convertion options above:
- To be clean, all daughter bindings should be converted. This is hard because
a good understanding of each device is requiered to write efficient bindings.
- Only daughter bindings supported by the added PMIC should be converted, that
allows to do the task conversion step by step.

In the V4 of this serie, I chose the second option.

Regards,
Alex

Changes in v7:
- Drop mt6397 RTC schema conversion.
- Integrate mt6357 RTC schema directly in mediatek,mt6357.yaml.
- Fix unit address in mediatek,pwrap.yaml.
- Link to v6: https://lore.kernel.org/r/[email protected]

Changes in v6:
- Fix typo in documentations.
- Remove mediatek,mt6397-rtc.yaml example.
- Align pwrap convertion with the original .txt file.
- Remove unecessary include in the mt6357-regulator driver.
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Add missing maintainers
- Improve RTC binding by adding rtc.yaml ref and start-year property
- Split the txt->yaml conversion in one commit and the addition of the
new mt6357-rtc compatible in another commit.
- Improve PWRAP binding:
- clocks and clock-name have been refactored.
- reset-names is now properly dependent to resets.
- additionalProperties change from true to false.
- change example for a most recent and popular SoC.
- "allOf" part has been simplified.
- Pass binding tests with the updated tools. Here the command:
"make DT_CHECKER_FLAGS=-m dt_binding_check"
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- "dt-bindings: mfd: mt6397: add binding for MT6357" has been applied
by Lee Jones
- All fixed regulator are now refering to fixed-regulator.yaml
- vfe28 and vcamio18 regulators have been added
- pwrap binding has been converted and mt8365 support has been added
- mt6357 PMIC binding has been created
- mt6397 RTC binding has been converted and mt6357 support has been added
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- To be consistent with regulator/driver.h and helper.c, shift
variables have been removed and the mask values have been directly shifted.
- Remove index tables and rework volt tables to use set/get helper functions.
- Add comment to structure and function.
- Fix Fabien Parent mail address.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rebase
- Fix typo
- Remove dependencies with https://lore.kernel.org/all/[email protected]/
which is no longer relevant.

Previous versions:
v1 - https://lore.kernel.org/all/[email protected]/

To: Lee Jones <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Matthias Brugger <[email protected]>
To: Dmitry Torokhov <[email protected]>
To: Chen Zhong <[email protected]>
To: Liam Girdwood <[email protected]>
To: Mark Brown <[email protected]>
To: Fabien Parent <[email protected]>
To: Alessandro Zummo <[email protected]>
To: Alexandre Belloni <[email protected]>
To: Sean Wang <[email protected]>
To: Pavel Machek <[email protected]>
To: Tianping Fang <[email protected]>
To: Flora Fu <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Fabien Parent <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: AngeloGioacchino Del Regno <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Alexandre Mergnat <[email protected]>

---
Alexandre Mergnat (4):
dt-bindings: soc: mediatek: convert pwrap documentation
dt-bindings: mfd: mediatek: Add bindings for MT6357 PMIC
arm64: dts: mt6358: change node names
arm64: dts: mt8173: change node name

Fabien Parent (4):
dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC
regulator: dt-bindings: Add binding schema for mt6357 regulators
regulator: add mt6357 regulator
Input: mtk-pmic-keys: add MT6357 support

.../bindings/input/mediatek,pmic-keys.yaml | 1 +
.../devicetree/bindings/leds/leds-mt6323.txt | 2 +-
.../devicetree/bindings/mfd/mediatek,mt6357.yaml | 111 +++++
Documentation/devicetree/bindings/mfd/mt6397.txt | 2 +-
.../regulator/mediatek,mt6357-regulator.yaml | 294 +++++++++++++
.../bindings/soc/mediatek/mediatek,pwrap.yaml | 147 +++++++
.../devicetree/bindings/soc/mediatek/pwrap.txt | 75 ----
arch/arm64/boot/dts/mediatek/mt6358.dtsi | 6 +-
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 2 +-
arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 2 +-
drivers/input/keyboard/mtk-pmic-keys.c | 17 +
drivers/regulator/Kconfig | 9 +
drivers/regulator/Makefile | 1 +
drivers/regulator/mt6357-regulator.c | 453 +++++++++++++++++++++
include/linux/regulator/mt6357-regulator.h | 51 +++
15 files changed, 1091 insertions(+), 82 deletions(-)
---
base-commit: f6e37bb630736d880a319b7845e8837c8536dd59
change-id: 20221005-mt6357-support-55308b82e33f

Best regards,
--
Alexandre Mergnat <[email protected]>


2022-11-29 16:26:13

by Alexandre Mergnat

[permalink] [raw]
Subject: [PATCH v7 3/8] dt-bindings: soc: mediatek: convert pwrap documentation

- Convert soc/mediatek/pwrap.txt to soc/mediatek/mediatek,pwrap.yaml
- Add syscon compatible const for mt8186 and mt8195 to match the DTS needs,
which is missing from pwrap.txt.

Signed-off-by: Alexandre Mergnat <[email protected]>
---
.../devicetree/bindings/leds/leds-mt6323.txt | 2 +-
Documentation/devicetree/bindings/mfd/mt6397.txt | 2 +-
.../bindings/soc/mediatek/mediatek,pwrap.yaml | 147 +++++++++++++++++++++
.../devicetree/bindings/soc/mediatek/pwrap.txt | 75 -----------
4 files changed, 149 insertions(+), 77 deletions(-)

diff --git a/Documentation/devicetree/bindings/leds/leds-mt6323.txt b/Documentation/devicetree/bindings/leds/leds-mt6323.txt
index 45bf9f7d85f3..73353692efa1 100644
--- a/Documentation/devicetree/bindings/leds/leds-mt6323.txt
+++ b/Documentation/devicetree/bindings/leds/leds-mt6323.txt
@@ -9,7 +9,7 @@ MT6323 PMIC hardware.
For MT6323 MFD bindings see:
Documentation/devicetree/bindings/mfd/mt6397.txt
For MediaTek PMIC wrapper bindings see:
-Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
+Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml

Required properties:
- compatible : Must be "mediatek,mt6323-led"
diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
index 0088442efca1..33b3d39d4ddd 100644
--- a/Documentation/devicetree/bindings/mfd/mt6397.txt
+++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
@@ -13,7 +13,7 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
It is interfaced to host controller using SPI interface by a proprietary hardware
called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap.
See the following for pwarp node definitions:
-../soc/mediatek/pwrap.txt
+../soc/mediatek/mediatek,pwrap.yaml

This document describes the binding for MFD device and its sub module.

diff --git a/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
new file mode 100644
index 000000000000..3fefd634bc69
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/mediatek/mediatek,pwrap.yaml
@@ -0,0 +1,147 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/mediatek/mediatek,pwrap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek PMIC Wrapper
+
+maintainers:
+ - Flora Fu <[email protected]>
+ - Alexandre Mergnat <[email protected]>
+
+description:
+ On MediaTek SoCs the PMIC is connected via SPI. The SPI master interface
+ is not directly visible to the CPU, but only through the PMIC wrapper
+ inside the SoC. The communication between the SoC and the PMIC can
+ optionally be encrypted. Also a non standard Dual IO SPI mode can be
+ used to increase speed.
+
+ IP Pairing
+
+ On MT8135 the pins of some SoC internal peripherals can be on the PMIC.
+ The signals of these pins are routed over the SPI bus using the pwrap
+ bridge. In the binding description below the properties needed for bridging
+ are marked with "IP Pairing". These are optional on SoCs which do not support
+ IP Pairing
+
+properties:
+ compatible:
+ oneOf:
+ - items:
+ - enum:
+ - mediatek,mt2701-pwrap
+ - mediatek,mt6765-pwrap
+ - mediatek,mt6779-pwrap
+ - mediatek,mt6797-pwrap
+ - mediatek,mt6873-pwrap
+ - mediatek,mt7622-pwrap
+ - mediatek,mt8135-pwrap
+ - mediatek,mt8173-pwrap
+ - mediatek,mt8183-pwrap
+ - mediatek,mt8186-pwrap
+ - mediatek,mt8188-pwrap
+ - mediatek,mt8195-pwrap
+ - mediatek,mt8365-pwrap
+ - mediatek,mt8516-pwrap
+ - items:
+ - enum:
+ - mediatek,mt8186-pwrap
+ - mediatek,mt8195-pwrap
+ - const: syscon
+
+ reg:
+ minItems: 1
+ items:
+ - description: PMIC wrapper registers
+ - description: IP pairing registers
+
+ reg-names:
+ minItems: 1
+ items:
+ - const: pwrap
+ - const: pwrap-bridge
+
+ interrupts:
+ maxItems: 1
+
+ clocks:
+ minItems: 2
+ items:
+ - description: SPI bus clock
+ - description: Main module clock
+ - description: System module clock
+ - description: Timer module clock
+
+ clock-names:
+ minItems: 2
+ items:
+ - const: spi
+ - const: wrap
+ - const: sys
+ - const: tmr
+
+ resets:
+ minItems: 1
+ items:
+ - description: PMIC wrapper reset
+ - description: IP pairing reset
+
+ reset-names:
+ minItems: 1
+ items:
+ - const: pwrap
+ - const: pwrap-bridge
+
+ pmic:
+ type: object
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - interrupts
+ - clocks
+ - clock-names
+
+dependentRequired:
+ resets: [reset-names]
+
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: mediatek,mt8365-pwrap
+ then:
+ properties:
+ clocks:
+ minItems: 4
+
+ clock-names:
+ minItems: 4
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/reset/mt8135-resets.h>
+
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ pwrap@1000f000 {
+ compatible = "mediatek,mt8135-pwrap";
+ reg = <0 0x1000f000 0 0x1000>,
+ <0 0x11017000 0 0x1000>;
+ reg-names = "pwrap", "pwrap-bridge";
+ interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&clk26m>, <&clk26m>;
+ clock-names = "spi", "wrap";
+ resets = <&infracfg MT8135_INFRA_PMIC_WRAP_RST>,
+ <&pericfg MT8135_PERI_PWRAP_BRIDGE_SW_RST>;
+ reset-names = "pwrap", "pwrap-bridge";
+ };
+ };
diff --git a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
deleted file mode 100644
index 8424b93c432e..000000000000
--- a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
+++ /dev/null
@@ -1,75 +0,0 @@
-MediaTek PMIC Wrapper Driver
-
-This document describes the binding for the MediaTek PMIC wrapper.
-
-On MediaTek SoCs the PMIC is connected via SPI. The SPI master interface
-is not directly visible to the CPU, but only through the PMIC wrapper
-inside the SoC. The communication between the SoC and the PMIC can
-optionally be encrypted. Also a non standard Dual IO SPI mode can be
-used to increase speed.
-
-IP Pairing
-
-on MT8135 the pins of some SoC internal peripherals can be on the PMIC.
-The signals of these pins are routed over the SPI bus using the pwrap
-bridge. In the binding description below the properties needed for bridging
-are marked with "IP Pairing". These are optional on SoCs which do not support
-IP Pairing
-
-Required properties in pwrap device node.
-- compatible:
- "mediatek,mt2701-pwrap" for MT2701/7623 SoCs
- "mediatek,mt6765-pwrap" for MT6765 SoCs
- "mediatek,mt6779-pwrap" for MT6779 SoCs
- "mediatek,mt6797-pwrap" for MT6797 SoCs
- "mediatek,mt6873-pwrap" for MT6873/8192 SoCs
- "mediatek,mt7622-pwrap" for MT7622 SoCs
- "mediatek,mt8135-pwrap" for MT8135 SoCs
- "mediatek,mt8173-pwrap" for MT8173 SoCs
- "mediatek,mt8183-pwrap" for MT8183 SoCs
- "mediatek,mt8186-pwrap" for MT8186 SoCs
- "mediatek,mt8188-pwrap", "mediatek,mt8195-pwrap" for MT8188 SoCs
- "mediatek,mt8195-pwrap" for MT8195 SoCs
- "mediatek,mt8365-pwrap" for MT8365 SoCs
- "mediatek,mt8516-pwrap" for MT8516 SoCs
-- interrupts: IRQ for pwrap in SOC
-- reg-names: "pwrap" is required; "pwrap-bridge" is optional.
- "pwrap": Main registers base
- "pwrap-bridge": bridge base (IP Pairing)
-- reg: Must contain an entry for each entry in reg-names.
-- clock-names: Must include the following entries:
- "spi": SPI bus clock
- "wrap": Main module clock
- "sys": System module clock (for MT8365 SoC)
- "tmr": Timer module clock (for MT8365 SoC)
-- clocks: Must contain an entry for each entry in clock-names.
-
-Optional properities:
-- reset-names: Some SoCs include the following entries:
- "pwrap"
- "pwrap-bridge" (IP Pairing)
-- resets: Must contain an entry for each entry in reset-names.
-- pmic: Using either MediaTek PMIC MFD as the child device of pwrap
- See the following for child node definitions:
- Documentation/devicetree/bindings/mfd/mt6397.txt
- or the regulator-only device as the child device of pwrap, such as MT6380.
- See the following definitions for such kinds of devices.
- Documentation/devicetree/bindings/regulator/mt6380-regulator.txt
-
-Example:
- pwrap: pwrap@1000f000 {
- compatible = "mediatek,mt8135-pwrap";
- reg = <0 0x1000f000 0 0x1000>,
- <0 0x11017000 0 0x1000>;
- reg-names = "pwrap", "pwrap-bridge";
- interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
- resets = <&infracfg MT8135_INFRA_PMIC_WRAP_RST>,
- <&pericfg MT8135_PERI_PWRAP_BRIDGE_SW_RST>;
- reset-names = "pwrap", "pwrap-bridge";
- clocks = <&clk26m>, <&clk26m>;
- clock-names = "spi", "wrap";
-
- pmic {
- compatible = "mediatek,mt6397";
- };
- };

--
b4 0.10.1

2022-12-01 23:49:20

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v7 3/8] dt-bindings: soc: mediatek: convert pwrap documentation


On Tue, 29 Nov 2022 16:57:02 +0100, Alexandre Mergnat wrote:
> - Convert soc/mediatek/pwrap.txt to soc/mediatek/mediatek,pwrap.yaml
> - Add syscon compatible const for mt8186 and mt8195 to match the DTS needs,
> which is missing from pwrap.txt.
>
> Signed-off-by: Alexandre Mergnat <[email protected]>
> ---
> .../devicetree/bindings/leds/leds-mt6323.txt | 2 +-
> Documentation/devicetree/bindings/mfd/mt6397.txt | 2 +-
> .../bindings/soc/mediatek/mediatek,pwrap.yaml | 147 +++++++++++++++++++++
> .../devicetree/bindings/soc/mediatek/pwrap.txt | 75 -----------
> 4 files changed, 149 insertions(+), 77 deletions(-)
>

Reviewed-by: Rob Herring <[email protected]>

2022-12-02 14:23:02

by Mark Brown

[permalink] [raw]
Subject: Re: (subset) [PATCH v7 0/8] Add MediaTek MT6357 PMIC support

On Tue, 29 Nov 2022 16:56:59 +0100, Alexandre Mergnat wrote:
> This patch series adds MFD, PMIC keys, and regulator support for MT6357.
> MT6357 is a MediaTek PMIC very similar to MT6358.
>
> Currently, MTK bindings related to the PMICs are not converted yet (still .txt):
>
> soc/mediatek/pwrap.txt (all PMIC parent)
> |
> V
> mfd/mt6397.txt (support lot of mt63XX PMIC)
> +---------------+----------------+---...
> V V V
> regulator/... rtc/... codec/...
>
> [...]

Applied to

broonie/regulator.git for-next

Thanks!

[2/8] regulator: dt-bindings: Add binding schema for mt6357 regulators
commit: b4387db19d7f1caf166852782a5f0e5a393bdf24
[7/8] regulator: add mt6357 regulator
commit: dafc7cde23dca239987d3cd000b11cdccc3728ea

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

2022-12-05 13:43:10

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH v7 0/8] Add MediaTek MT6357 PMIC support

Matthias,

Alexandre Mergnat <[email protected]> writes:

> This patch series adds MFD, PMIC keys, and regulator support for MT6357.
> MT6357 is a MediaTek PMIC very similar to MT6358.

The regulator driver (and bindings) were merged by Mark. Could you take
the rest of this series via your mediatek tree? The input driver (and
bindings) are ack'd by Dmitry.

Kevin




2022-12-16 13:06:29

by Matthias Brugger

[permalink] [raw]
Subject: Re: [PATCH v7 0/8] Add MediaTek MT6357 PMIC support

Hi Kevin,
Hi Alexandre,

On 05/12/2022 14:16, Kevin Hilman wrote:
> Matthias,
>
> Alexandre Mergnat <[email protected]> writes:
>
>> This patch series adds MFD, PMIC keys, and regulator support for MT6357.
>> MT6357 is a MediaTek PMIC very similar to MT6358.
>
> The regulator driver (and bindings) were merged by Mark. Could you take
> the rest of this series via your mediatek tree? The input driver (and
> bindings) are ack'd by Dmitry.
>

Yes I can do that but 3/8 does not apply cleanly. Could you please rebase on top
of v6.2-tmp/soc?

Thanks
Matthias

2023-01-02 16:36:06

by Alexandre Mergnat

[permalink] [raw]
Subject: Re: [PATCH v7 0/8] Add MediaTek MT6357 PMIC support

> >> This patch series adds MFD, PMIC keys, and regulator support for MT6357.
> >> MT6357 is a MediaTek PMIC very similar to MT6358.
> >
> > The regulator driver (and bindings) were merged by Mark. Could you take
> > the rest of this series via your mediatek tree? The input driver (and
> > bindings) are ack'd by Dmitry.
> >
>
> Yes I can do that but 3/8 does not apply cleanly. Could you please rebase on top
> of v6.2-tmp/soc?

Hi Matthias,

I've pushed the V8 rebased on top of v6.2-tmp/soc.
https://lore.kernel.org/r/[email protected]

Thanks,
Alex

2023-01-18 10:43:10

by Alexandre Mergnat

[permalink] [raw]
Subject: Re: [PATCH v7 0/8] Add MediaTek MT6357 PMIC support

Hi Matthias,

Gentle ping to merge the v8 rebased on top of v6.2-tmp/soc.
https://lore.kernel.org/r/[email protected]

Thanks,
Alex

Le lun. 2 janv. 2023 à 17:10, Alexandre Mergnat
<[email protected]> a écrit :
>
> > >> This patch series adds MFD, PMIC keys, and regulator support for MT6357.
> > >> MT6357 is a MediaTek PMIC very similar to MT6358.
> > >
> > > The regulator driver (and bindings) were merged by Mark. Could you take
> > > the rest of this series via your mediatek tree? The input driver (and
> > > bindings) are ack'd by Dmitry.
> > >
> >
> > Yes I can do that but 3/8 does not apply cleanly. Could you please rebase on top
> > of v6.2-tmp/soc?
>
> Hi Matthias,
>
> I've pushed the V8 rebased on top of v6.2-tmp/soc.
> https://lore.kernel.org/r/[email protected]
>
> Thanks,
> Alex