Add support for MT6392 PMIC
Subsystems (11)
v10 cover Add support for MT6392 PMIC
The MediaTek MT6392 PMIC is usually found on devices powered by the MT8516/MT8167 SoC and is yet another MT6323/MT6397 variant.
This series is mostly based around patches submitted a couple years ago by Fabien Parent and not merged and from Val Packett's submission from Jan 2025 that included extra cleanups, fixes, and a new dtsi file similar to ones that exist for other PMICs. Some comments weren't addressed and the series was ultimately not merged.
These patches enable four functions: keys, regulator, pinctrl and RTC. Mono speaker amp will follow later as I need to work further on the audio codec.
I added a handful of device tree improvements to fix some dtbs_check errors, added support for the pinctrl device and addressed the comments from last year's reviews.
Please note that patch 0006 and 0008 depend on patch 0005 as they need the registers.h file, but belong to different driver areas. I'm not sure if I'm supposed to squash them even if they belong to different driver areas of if it's fine like this. Any advice is welcome.
Patch 0009 also depends on patch 0003 because of mt6392-regulator.h.
The series has been tested on Xiaomi Mi Smart Clock X04G, on the Lenovo Smart Clock 2 CD-24502F, on Sony PlayStation Classic Mini SCPH-1000R and on the Lenovo Tab E7 TB-7104F.
Changes in v10:
- Removed the fallback on mediatek,mt6323 in the MFD binding document and in the dtsi file. Suggested by Sashiko [11], thus removed the Reviewed-by tag provided by Kryzsztof Kozlowski in patch #1, version 9.
Changes in v9 [10]:
- Correct binding for vrtc as it does not support mode setting.
From Sashiko:
- Added missing include in MFD documentation example.
- Fixed constraints for regulator-initial-mode in regulator binding.
- Fixed wrong register write while setting LDO standby mode.
- Added missing pmic interrupt definition in the pumpkin-common include.
Changes in v8 [9]:
From reviewers:
- Added example code to the MFD device binding, removed it from the regulators docs.
- Added minItems/maxItems constraints on the regulator mode definitions, improved the mode constants.
- Fixed formatting issues in the regulator binding.
- Import the mt6392.dtsi file in pumpkin-common.dtsi, as it was originally meant in [8].
From sashiko:
- Added more explicit constraints on the regulator modes definitions.
- Use the appropriate modeget register for LDO regulators, Buck registers don't have the corresponding register according to the data sheet.
- Added the missing of_map_mode function.
- Removed some debugging code that had no use and masked error codes.
Changes in v7 [7]:
- Removed patch 0008 dependency on patch 0003.
- Reintroduced the regulator driver. In earlier revisions of this series, it was proposed to remove the dedicated compatible for the regulator device [3]. The driver does not use actually it, but it is not possible at this time to remove it from the bindings since it's a required property.
Making the regulator-required property conditional was NACKed in [5], with the suggestion to create a separate binding altogether for devices that do not require the compatible property. I tried implementing this, but since the parent device needs to be declared as compatible with mt6323, it leads to a warning in dt_binding_check since mt6323 would be declared as a compatible in both mt6392 and mt6397.
In the end the only regulator driver from the mt6397 documentation that still declares an of_match is mt6397-regulator and it does not seem to be necessary, so it should be possible to remove it and make the regulator compatible optional for all regulators, but that change would probably deserve its own separate patch series.
Changes in v6 [6]:
- Dropped the regulators driver for the moment
- Explained the FCHR key name origin in the commit message
- Introduced the MFD_CELL_* macro in the sub-devices definitions. A separate, independent commit introduced MFD_CELL_* to all the subdevices in the mt6397-core.c file for consistency
- Replaced of_device_get_match_data with device_get_match_data
- Removed the mfd_match_data enum in favor of the preexisting chip_id enum
- Adjusted the error message if the device is unsupported
Changes in v5 [5]:
- Double checked regulator driver with data sheet and Android sources. The data sheet I have misses a lot of register descriptions, but Android sources have been helpful to fill the gaps
- Reintroduced the required attribute for the regulator compatible in the bindings
- Fixed the missing reference to the MT6392 schema
- Fixed casts/unused vars reported by kernel test robot
- Removed Reviewed-by tags from the regulator patches as they have been modified in this version
Changes in v4 [4]:
- Dropped usage of the regulator compatible
- Fixed commit messages text to properly reference the target subsystem
- Added supply rails to the regulator
- Reworked the regulator schema and PMIC dtsi. Now all supplies are documented and the schema no longer includes voltage information
- Removed redundant ldo- / buck- prefixes
- Renamed the pinfunc header to mediatek,mt6392-pinfunc.h
- Modified the MFD driver to use a simple identifier in the of_match data properties
Changes in v3 [3]:
- Added pinctrl device
- Changed mt6397-rtc fallback to mt6323-rtc
- Added schema for regulators
- Fixed checkpatch issues
Changes in v2 [2]:
- Replaced explicit compatibles with fallbacks
Initial version: [1]
[1] https://lore.kernel.org/linux-mediatek/[email protected]/
[2] https://lore.kernel.org/linux-mediatek/[email protected]/
[3] https://lore.kernel.org/linux-mediatek/[email protected]/
[4] https://lore.kernel.org/linux-mediatek/[email protected]/
[5] https://lore.kernel.org/linux-mediatek/[email protected]/
[6] https://lore.kernel.org/linux-mediatek/[email protected]/
[7] https://lore.kernel.org/linux-mediatek/[email protected]/
[8] https://lore.kernel.org/linux-mediatek/[email protected]/
[9] https://lore.kernel.org/linux-mediatek/[email protected]/
[10] https://lore.kernel.org/linux-mediatek/[email protected]/
[11] https://sashiko.dev/#/message/20260820125850.3B34D1F000E9%40smtp.kernel.org
Fabien Parent (3):
dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys
mfd: mt6397: Add support for MT6392 PMIC
regulator: Add MediaTek MT6392 regulator
Luca Leonardo Scorcia (4):
dt-bindings: mfd: mt6397: Add MT6392 PMIC
regulator: dt-bindings: Add MediaTek MT6392 PMIC
mfd: mt6397: Use MFD_CELL_* to describe sub-devices
pinctrl: mediatek: mt6397: Add MediaTek MT6392
Val Packett (2):
input: keyboard: mtk-pmic-keys: Add MT6392 support
arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi
.../bindings/input/mediatek,pmic-keys.yaml | 1 + .../bindings/mfd/mediatek,mt6397.yaml | 72 ++ .../regulator/mediatek,mt6392-regulator.yaml | 112 +++ arch/arm64/boot/dts/mediatek/mt6392.dtsi | 145 ++++ .../boot/dts/mediatek/pumpkin-common.dtsi | 7 + drivers/input/keyboard/mtk-pmic-keys.c | 18 + drivers/mfd/mt6397-core.c | 307 ++++--- drivers/mfd/mt6397-irq.c | 8 + drivers/pinctrl/mediatek/pinctrl-mt6397.c | 37 +- drivers/pinctrl/mediatek/pinctrl-mtk-mt6392.h | 64 ++ drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/mt6392-regulator.c | 764 ++++++++++++++++++ .../regulator/mediatek,mt6392-regulator.h | 23 + include/linux/mfd/mt6392/core.h | 43 + include/linux/mfd/mt6392/registers.h | 488 +++++++++++ include/linux/mfd/mt6397/core.h | 1 + include/linux/regulator/mt6392-regulator.h | 42 + 18 files changed, 1974 insertions(+), 168 deletions(-) create mode 100644 Documentation/devicetree/bindings/regulator/mediatek,mt6392-regulator.yaml create mode 100644 arch/arm64/boot/dts/mediatek/mt6392.dtsi create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt6392.h create mode 100644 drivers/regulator/mt6392-regulator.c create mode 100644 include/dt-bindings/regulator/mediatek,mt6392-regulator.h create mode 100644 include/linux/mfd/mt6392/core.h create mode 100644 include/linux/mfd/mt6392/registers.h create mode 100644 include/linux/regulator/mt6392-regulator.h
Signature · 1 line
2.43.0
PATCH RESEND v10 1/9 dt-bindings: mfd: mt6397: Add MT6392 PMIC
Describe the MT6392 PMIC and its RTC and regulator devices. This device is mostly based on MT6323 with some similarities to MT6397 and is usually found on boards using the MT8516/MT8167 SoC.
--- .../bindings/mfd/mediatek,mt6397.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+)
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +72 -0
@@ -39,6 +39,7 @@ properties: - mediatek,mt6328 - mediatek,mt6358 - mediatek,mt6359 + - mediatek,mt6392 - mediatek,mt6397 - items: - enum:
@@ -72,6 +73,10 @@ properties: - mediatek,mt6331-rtc - mediatek,mt6358-rtc - mediatek,mt6397-rtc + - items: + - enum: + - mediatek,mt6392-rtc + - const: mediatek,mt6323-rtc - items: - enum: - mediatek,mt6359-rtc
@@ -99,6 +104,7 @@ properties: - mediatek,mt6331-regulator - mediatek,mt6358-regulator - mediatek,mt6359-regulator + - mediatek,mt6392-regulator - mediatek,mt6397-regulator - items: - enum:
@@ -663,3 +669,69 @@ examples: compatible = "mediatek,mt6397-rtc"; }; }; + + - | + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + pmic { + compatible = "mediatek,mt6392"; + + interrupts-extended = <&pio 28 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <2>; + + keys { + compatible = "mediatek,mt6392-keys"; + + key-power { + linux,keycodes = <KEY_POWER>; + wakeup-source; + }; + + key-home { + linux,keycodes = <KEY_HOME>; + wakeup-source; + }; + }; + + pinctrl { + compatible = "mediatek,mt6392-pinctrl"; + + gpio-controller; + #gpio-cells = <2>; + }; + + regulators { + compatible = "mediatek,mt6392-regulator"; + + vproc { + regulator-allowed-modes = <0 1>; + regulator-initial-mode = <0>; + regulator-min-microvolt = < 700000>; + regulator-max-microvolt = <1350000>; + regulator-always-on; + regulator-boot-on; + }; + + // ... + + vadc18 { + regulator-allowed-modes = <0 2>; + regulator-initial-mode = <0>; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + + vefuse { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <2000000>; + }; + }; + + rtc { + compatible = "mediatek,mt6392-rtc", "mediatek,mt6323-rtc"; + }; + };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
Describe the MT6392 PMIC and its RTC and regulator devices. This device is mostly based on MT6323 with some similarities to MT6397 and is usually found on boards using the MT8516/MT8167 SoC.
Signed-off-by Luca Leonardo Scorcia <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Rob Herring (Arm)
maintainerRe: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
In reply to Luca Leonardo ScorciaQuoted 11 lines · Luca Leonardo Scorcia
Describe the MT6392 PMIC and its RTC and regulator devices. This device is mostly based on MT6323 with some similarities to MT6397 and is usually found on boards using the MT8516/MT8167 SoC.
Signed-off-by Luca Leonardo Scorcia <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>--- .../bindings/mfd/mediatek,mt6397.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+)
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:Documentation/devicetree/bindings/mfd/mediatek,mt6397.example.dtb: pmic (mediatek,mt6392): keys:compatible: 'oneOf' conditional failed, one must be fixed:
['mediatek,mt6392-keys'] is too short 'mediatek,mt6392-keys' is not one of ['mediatek,mt6323-keys', 'mediatek,mt6328-keys', 'mediatek,mt6331-keys', 'mediatek,mt6357-keys', 'mediatek,mt6358-keys', 'mediatek,mt6359-keys', 'mediatek,mt6397-keys'] 'mediatek,mt6392-keys' is not one of ['mediatek,mt6365-keys'] from schema $id: http://devicetree.org/schemas/mfd/mediatek,mt6397.yaml
Documentation/devicetree/bindings/mfd/mediatek,mt6397.example.dtb: /example-3/pmic/keys: failed to match any schema with compatible: ['mediatek,mt6392-keys']
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Rob Herring
maintainerRe: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
In reply to Luca Leonardo ScorciaQuoted 10 lines · Luca Leonardo Scorcia
Describe the MT6392 PMIC and its RTC and regulator devices. This device is mostly based on MT6323 with some similarities to MT6397 and is usually found on boards using the MT8516/MT8167 SoC.
Signed-off-by Luca Leonardo Scorcia <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>--- .../bindings/mfd/mediatek,mt6397.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+)
You need to reorder your patches to avoid errors.
Quoted 33 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +6
-0@@ -39,6 +39,7 @@ properties: - mediatek,mt6328 - mediatek,mt6358 - mediatek,mt6359 + - mediatek,mt6392 - mediatek,mt6397 - items: - enum:@@ -72,6 +73,10 @@ properties: - mediatek,mt6331-rtc - mediatek,mt6358-rtc - mediatek,mt6397-rtc + - items: + - enum: + - mediatek,mt6392-rtc + - const: mediatek,mt6323-rtc - items: - enum: - mediatek,mt6359-rtc@@ -99,6 +104,7 @@ properties: - mediatek,mt6331-regulator - mediatek,mt6358-regulator - mediatek,mt6359-regulator + - mediatek,mt6392-regulator - mediatek,mt6397-regulator - items: - enum:
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml examples: · line 678
Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +7
-0@@ -663,3 +669,69 @@ examples: compatible = "mediatek,mt6397-rtc"; }; }; + + - | + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + pmic { + compatible = "mediatek,mt6392";
Or drop the example. Is this one really different enough from the existing example(s)?
Quoted 62 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6397.yaml +59
-0+ + interrupts-extended = <&pio 28 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <2>; + + keys { + compatible = "mediatek,mt6392-keys"; + + key-power { + linux,keycodes = <KEY_POWER>; + wakeup-source; + }; + + key-home { + linux,keycodes = <KEY_HOME>; + wakeup-source; + }; + }; + + pinctrl { + compatible = "mediatek,mt6392-pinctrl"; + + gpio-controller; + #gpio-cells = <2>; + }; + + regulators { + compatible = "mediatek,mt6392-regulator"; + + vproc { + regulator-allowed-modes = <0 1>; + regulator-initial-mode = <0>; + regulator-min-microvolt = < 700000>; + regulator-max-microvolt = <1350000>; + regulator-always-on; + regulator-boot-on; + }; + + // ... + + vadc18 { + regulator-allowed-modes = <0 2>; + regulator-initial-mode = <0>; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + + vefuse { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <2000000>; + }; + }; + + rtc { + compatible = "mediatek,mt6392-rtc", "mediatek,mt6323-rtc"; + }; + };Signature · 1 line
2.43.0
Re: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
Quoted 2 lines
Or drop the example. Is this one really different enough from the existing example(s)?
I am so sorry, there actually was a previous email by Krzystof Kozlowski where he already asked me to do that and I thought I had done it!
I'll send out v11 without the example.
Re: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
In reply to Luca Leonardo ScorciaQuoted 8 lines · Luca Leonardo Scorcia
Describe the MT6392 PMIC and its RTC and regulator devices. This device is mostly based on MT6323 with some similarities to MT6397 and is usually found on boards using the MT8516/MT8167 SoC.
Signed-off-by Luca Leonardo Scorcia <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>---
And here you write clear note about dependency, once you fixed bisectability.
Best regards,
Krzysztof
Re: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
Quoted 2 lines
And here you write clear note about dependency, once you fixed bisectability.
Just to confirm, would the same text I put in the cover email be ok:
"Please note that patch 0006 and 0008 depend on patch 0005 as they need the registers.h file, but belong to different driver areas. Patch 0009 also depends on
patch 0003 because of mt6392-regulator.h."
or did I misunderstand which dependency you are referring to?
Thank you
Re: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
Quoted 11 lines · Luca Leonardo Scorcia
Quoted 2 lines
And here you write clear note about dependency, once you fixed bisectability.
Just to confirm, would the same text I put in the cover email be ok:
"Please note that patch 0006 and 0008 depend on patch 0005 as they need the
registers.hfile, but belong to different driver areas. Patch 0009 also depends on
patch 0003 because ofmt6392-regulator.h."or did I misunderstand which dependency you are referring to?
The dependency of this patch. This one uses compatibles defined in other patch.
Just apply it yourself and run full testing - you will see notice about undocumented compatibles.
Best regards,
Krzysztof
Re: [PATCH RESEND v10 1/9] dt-bindings: mfd: mt6397: Add MT6392 PMIC
Quoted 5 lines
The dependency of this patch. This one uses compatibles defined in other patch.
Just apply it yourself and run full testing - you will see notice about undocumented compatibles.
Thank you, now I get it. I had already removed the example from my testing branch and removing the example also removed the dependency. I'll run another round of dt tests to be sure and resubmit without the example.
PATCH RESEND v10 2/9 dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys
In reply to Luca Leonardo ScorciaFrom: Fabien Parent <[email protected]>
Add the binding documentation of mtk-pmic-keys for the MT6392 PMIC.
--- Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/input/mediatek,pmic-keys.yaml +1 -0
@@ -31,6 +31,7 @@ properties: - mediatek,mt6357-keys - mediatek,mt6358-keys - mediatek,mt6359-keys + - mediatek,mt6392-keys - mediatek,mt6397-keys - items: - enum:
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 2/9] dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
From: Fabien Parent <[email protected]>
Add the binding documentation of mtk-pmic-keys for the MT6392 PMIC.
Signed-off-by Fabien Parent <[email protected]>Signed-off-by Val Packett <[email protected]>Signed-off-by Luca Leonardo Scorcia <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH RESEND v10 3/9 regulator: dt-bindings: Add MediaTek MT6392 PMIC
In reply to Luca Leonardo ScorciaAdd bindings for the regulators found in the MediaTek MT6392 PMIC, usually found in board designs using the MediaTek MT8516/MT8167 SoCs.
--- .../regulator/mediatek,mt6392-regulator.yaml | 112 ++++++++++++++++++ .../regulator/mediatek,mt6392-regulator.h | 23 ++++ 2 files changed, 135 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/mediatek,mt6392-regulator.yaml create mode 100644 include/dt-bindings/regulator/mediatek,mt6392-regulator.h
Documentation/devicetree/bindings/regulator/mediatek,mt6392-regulator.yaml new file +112 -0
@@ -0,0 +1,112 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/mediatek,mt6392-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek MT6392 regulator + +maintainers: + - Luca Leonardo Scorcia <[email protected]> + +description: + MT6392 is a power management system chip containing three buck converters and + 23 LDOs. All voltage regulators provided by the PMIC are described as + sub-nodes of this node. + +properties: + compatible: + items: + - const: mediatek,mt6392-regulator + + vproc-supply: + description: Supply for buck regulator vproc + vcore-supply: + description: Supply for buck regulator vcore + vsys-supply: + description: Supply for buck regulator vsys + avddldo-supply: + description: + Supply for AVDD LDOs (vm, vio18, vcn18, vcamd, vcamio). According to the data sheet + this is an internal supply derived from vsys. + ldo1-supply: + description: Supply for LDOs group 1 (vaud28, vxo22, vaud22, vadc18, vcama, vrtc) + ldo2-supply: + description: Supply for LDOs group 2 (vcn35, vio28, vmc, vmch, vefuse, vdig18) + ldo3-supply: + description: Supply for LDOs group 3 (vusb, vemc3v3, vcamaf, vgp1, vgp2, vm25) + +patternProperties: + "^v(core|proc|sys)$": + description: Buck regulators + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + properties: + regulator-allowed-modes: + description: + BUCK regulators can set regulator-allowed-modes to values specified in + dt-bindings/regulator/mediatek,mt6392-regulator.h + items: + enum: [0, 1] + minItems: 1 + maxItems: 2 + regulator-initial-mode: + description: + BUCK regulators can set regulator-initial-mode to values specified in + dt-bindings/regulator/mediatek,mt6392-regulator.h + enum: [0, 1] + + "^v(adc18|camio|cn18|io18|xo22|m25|aud28|io28|usb)$": + description: LDOs with fixed output and mode setting + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + properties: + regulator-allowed-modes: + description: + LDO regulators can set regulator-allowed-modes to values specified in + dt-bindings/regulator/mediatek,mt6392-regulator.h + items: + enum: [0, 2] + minItems: 1 + maxItems: 2 + regulator-initial-mode: + description: + LDO regulators can set regulator-initial-mode to values specified in + dt-bindings/regulator/mediatek,mt6392-regulator.h + enum: [0, 2] + + "^v(cama|dig18|rtc)$": + description: LDOs with fixed output without mode setting + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + properties: + regulator-allowed-modes: false + regulator-initial-mode: false + + "^v(aud22|camaf|camd|cn35|efuse|emc3v3|gp1|gp2|m|mc|mch)$": + description: LDOs with adjustable output and mode setting + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + properties: + regulator-allowed-modes: + description: + LDO regulators can set regulator-allowed-modes to values specified in + dt-bindings/regulator/mediatek,mt6392-regulator.h + items: + enum: [0, 2] + minItems: 1 + maxItems: 2 + regulator-initial-mode: + description: + LDO regulators can set regulator-initial-mode to values specified in + dt-bindings/regulator/mediatek,mt6392-regulator.h + enum: [0, 2] + +required: + - compatible + +additionalProperties: false
include/dt-bindings/regulator/mediatek,mt6392-regulator.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +#ifndef _DT_BINDINGS_REGULATOR_MEDIATEK_MT6392_H_ +#define _DT_BINDINGS_REGULATOR_MEDIATEK_MT6392_H_ + +/* +* Buck mode constants which may be used in devicetree properties (eg. +* regulator-initial-mode, regulator-allowed-modes). +* See the manufacturer's datasheet for more information on these modes. +*/ + +#define MT6392_REGULATOR_MODE_NORMAL 0 +#define MT6392_BUCK_MODE_FORCE_PWM 1 + +/* +* LDO mode constants which may be used in devicetree properties (eg. +* regulator-initial-mode, regulator-allowed-modes). +* See the manufacturer's datasheet for more information on these modes. +*/ + +#define MT6392_LDO_MODE_LP 2 + +#endif
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 3/9] regulator: dt-bindings: Add MediaTek MT6392 PMIC
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Add bindings for the regulators found in the MediaTek MT6392 PMIC, usually found in board designs using the MediaTek MT8516/MT8167 SoCs.
Signed-off-by Luca Leonardo Scorcia <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH RESEND v10 4/9 mfd: mt6397: Use MFD_CELL_* to describe sub-devices
In reply to Luca Leonardo ScorciaUse the MFD_CELL_* macros to describe sub-devices. No functional changes.
--- drivers/mfd/mt6397-core.c | 207 ++++++++++++-------------------------- 1 file changed, 67 insertions(+), 140 deletions(-)
drivers/mfd/mt6397-core.c +67 -140
@@ -124,165 +124,92 @@ static const struct resource mt6323_pwrc_resources[] = { };static const struct mfd_cell mt6323_devs[] = { - { - .name ="mt6323-auxadc" , - .of_compatible ="mediatek,mt6323-auxadc" , - }, { - .name ="mt6323-efuse" , - .of_compatible ="mediatek,mt6323-efuse" , - }, { - .name ="mt6323-rtc" , - .num_resources =ARRAY_SIZE (mt6323_rtc_resources), - .resources = mt6323_rtc_resources, - .of_compatible ="mediatek,mt6323-rtc" , - }, { - .name ="mt6323-regulator" , - .of_compatible ="mediatek,mt6323-regulator" - }, { - .name ="mt6323-led" , - .of_compatible ="mediatek,mt6323-led" - }, { - .name ="mt6323-keys" , - .num_resources =ARRAY_SIZE (mt6323_keys_resources), - .resources = mt6323_keys_resources, - .of_compatible ="mediatek,mt6323-keys" - }, { - .name ="mt6323-pwrc" , - .num_resources =ARRAY_SIZE (mt6323_pwrc_resources), - .resources = mt6323_pwrc_resources, - .of_compatible ="mediatek,mt6323-pwrc" - }, +MFD_CELL_OF ("mt6323-auxadc" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6323-auxadc" ), +MFD_CELL_OF ("mt6323-efuse" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6323-efuse" ), +MFD_CELL_OF ("mt6323-rtc" , mt6323_rtc_resources,NULL ,0 ,0 , +"mediatek,mt6323-rtc" ), +MFD_CELL_OF ("mt6323-regulator" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6323-regulator" ), +MFD_CELL_OF ("mt6323-led" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6323-led" ), +MFD_CELL_OF ("mt6323-keys" , mt6323_keys_resources,NULL ,0 ,0 , +"mediatek,mt6323-keys" ), +MFD_CELL_OF ("mt6323-pwrc" , mt6323_pwrc_resources,NULL ,0 ,0 , +"mediatek,mt6323-pwrc" ), };static const struct mfd_cell mt6328_devs[] = { - { - .name ="mt6328-regulator" , - .of_compatible ="mediatek,mt6328-regulator" - }, { - .name ="mt6328-keys" , - .num_resources =ARRAY_SIZE (mt6328_keys_resources), - .resources = mt6328_keys_resources, - .of_compatible ="mediatek,mt6328-keys" - }, +MFD_CELL_OF ("mt6328-regulator" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6328-regulator" ), +MFD_CELL_OF ("mt6328-keys" , mt6328_keys_resources,NULL ,0 ,0 , +"mediatek,mt6328-keys" ), };static const struct mfd_cell mt6357_devs[] = { - { - .name ="mt6359-auxadc" , - .of_compatible ="mediatek,mt6357-auxadc" - }, { - .name ="mt6357-regulator" , - }, { - .name ="mt6357-rtc" , - .num_resources =ARRAY_SIZE (mt6357_rtc_resources), - .resources = mt6357_rtc_resources, - .of_compatible ="mediatek,mt6357-rtc" , - }, { - .name ="mt6357-sound" , - .of_compatible ="mediatek,mt6357-sound" - }, { - .name ="mt6357-keys" , - .num_resources =ARRAY_SIZE (mt6357_keys_resources), - .resources = mt6357_keys_resources, - .of_compatible ="mediatek,mt6357-keys" - }, +MFD_CELL_OF ("mt6359-auxadc" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6357-auxadc" ), +MFD_CELL_NAME ("mt6357-regulator" ), +MFD_CELL_OF ("mt6357-rtc" , mt6357_rtc_resources,NULL ,0 ,0 , +"mediatek,mt6357-rtc" ), +MFD_CELL_OF ("mt6357-sound" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6357-sound" ), +MFD_CELL_OF ("mt6357-keys" , mt6357_keys_resources,NULL ,0 ,0 , +"mediatek,mt6357-keys" ), };/* MT6331 is always used in combination with MT6332 */ static const struct mfd_cell mt6331_mt6332_devs[] = { - { - .name ="mt6331-rtc" , - .num_resources =ARRAY_SIZE (mt6331_rtc_resources), - .resources = mt6331_rtc_resources, - .of_compatible ="mediatek,mt6331-rtc" , - }, { - .name ="mt6331-regulator" , - .of_compatible ="mediatek,mt6331-regulator" - }, { - .name ="mt6332-regulator" , - .of_compatible ="mediatek,mt6332-regulator" - }, { - .name ="mt6331-keys" , - .num_resources =ARRAY_SIZE (mt6331_keys_resources), - .resources = mt6331_keys_resources, - .of_compatible ="mediatek,mt6331-keys" - }, +MFD_CELL_OF ("mt6331-rtc" , mt6331_rtc_resources,NULL ,0 ,0 , +"mediatek,mt6331-rtc" ), +MFD_CELL_OF ("mt6331-regulator" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6331-regulator" ), +MFD_CELL_OF ("mt6332-regulator" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6332-regulator" ), +MFD_CELL_OF ("mt6331-keys" , mt6331_keys_resources,NULL ,0 ,0 , +"mediatek,mt6331-keys" ), };static const struct mfd_cell mt6358_devs[] = { - { - .name ="mt6359-auxadc" , - .of_compatible ="mediatek,mt6358-auxadc" - }, { - .name ="mt6358-regulator" , - .of_compatible ="mediatek,mt6358-regulator" - }, { - .name ="mt6358-rtc" , - .num_resources =ARRAY_SIZE (mt6358_rtc_resources), - .resources = mt6358_rtc_resources, - .of_compatible ="mediatek,mt6358-rtc" , - }, { - .name ="mt6358-sound" , - .of_compatible ="mediatek,mt6358-sound" - }, { - .name ="mt6358-keys" , - .num_resources =ARRAY_SIZE (mt6358_keys_resources), - .resources = mt6358_keys_resources, - .of_compatible ="mediatek,mt6358-keys" - }, +MFD_CELL_OF ("mt6359-auxadc" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6358-auxadc" ), +MFD_CELL_OF ("mt6358-regulator" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6358-regulator" ), +MFD_CELL_OF ("mt6358-rtc" , mt6358_rtc_resources,NULL ,0 ,0 , +"mediatek,mt6358-rtc" ), +MFD_CELL_OF ("mt6358-sound" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6358-sound" ), +MFD_CELL_OF ("mt6358-keys" , mt6358_keys_resources,NULL ,0 ,0 , +"mediatek,mt6358-keys" ), };static const struct mfd_cell mt6359_devs[] = { - { - .name ="mt6359-auxadc" , - .of_compatible ="mediatek,mt6359-auxadc" - }, - { .name ="mt6359-regulator" , }, - { - .name ="mt6359-rtc" , - .num_resources =ARRAY_SIZE (mt6358_rtc_resources), - .resources = mt6358_rtc_resources, - .of_compatible ="mediatek,mt6358-rtc" , - }, - { .name ="mt6359-sound" , }, - { - .name ="mt6359-keys" , - .num_resources =ARRAY_SIZE (mt6359_keys_resources), - .resources = mt6359_keys_resources, - .of_compatible ="mediatek,mt6359-keys" - }, - { - .name ="mt6359-accdet" , - .of_compatible ="mediatek,mt6359-accdet" , - .num_resources =ARRAY_SIZE (mt6359_accdet_resources), - .resources = mt6359_accdet_resources, - }, +MFD_CELL_OF ("mt6359-auxadc" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6359-auxadc" ), +MFD_CELL_NAME ("mt6359-regulator" ), +MFD_CELL_OF ("mt6359-rtc" , mt6358_rtc_resources,NULL ,0 ,0 , +"mediatek,mt6358-rtc" ), +MFD_CELL_NAME ("mt6359-sound" ), +MFD_CELL_OF ("mt6359-keys" , mt6359_keys_resources,NULL ,0 ,0 , +"mediatek,mt6359-keys" ), +MFD_CELL_OF ("mt6359-accdet" , mt6359_accdet_resources,NULL ,0 ,0 , +"mediatek,mt6359-accdet" ), };static const struct mfd_cell mt6397_devs[] = { - { - .name ="mt6397-rtc" , - .num_resources =ARRAY_SIZE (mt6397_rtc_resources), - .resources = mt6397_rtc_resources, - .of_compatible ="mediatek,mt6397-rtc" , - }, { - .name ="mt6397-regulator" , - .of_compatible ="mediatek,mt6397-regulator" , - }, { - .name ="mt6397-codec" , - .of_compatible ="mediatek,mt6397-codec" , - }, { - .name ="mt6397-clk" , - .of_compatible ="mediatek,mt6397-clk" , - }, { - .name ="mt6397-pinctrl" , - .of_compatible ="mediatek,mt6397-pinctrl" , - }, { - .name ="mt6397-keys" , - .num_resources =ARRAY_SIZE (mt6397_keys_resources), - .resources = mt6397_keys_resources, - .of_compatible ="mediatek,mt6397-keys" - } +MFD_CELL_OF ("mt6397-rtc" , mt6397_rtc_resources,NULL ,0 ,0 , +"mediatek,mt6397-rtc" ), +MFD_CELL_OF ("mt6397-regulator" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6397-regulator" ), +MFD_CELL_OF ("mt6397-codec" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6397-codec" ), +MFD_CELL_OF ("mt6397-clk" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6397-clk" ), +MFD_CELL_OF ("mt6397-pinctrl" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6397-pinctrl" ), +MFD_CELL_OF ("mt6397-keys" , mt6397_keys_resources,NULL ,0 ,0 , +"mediatek,mt6397-keys" ), };struct chip_data {
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 4/9] mfd: mt6397: Use MFD_CELL_* to describe sub-devices
Sashiko has reviewed this patch and found no issues.
Quoted 3 lines
Use the MFD_CELL_* macros to describe sub-devices. No functional changes.
Signed-off-by Luca Leonardo Scorcia <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH RESEND v10 5/9 mfd: mt6397: Add support for MT6392 PMIC
In reply to Luca Leonardo ScorciaFrom: Fabien Parent <[email protected]>
Align the MT6397 PMIC driver to other MFD drivers by passing only an identifier through mt6397_of_match[*].data and add support for the MT6392 PMIC and its regulator, RTC, keys and pinctrl devices.
The keys device manages two buttons named PWRKEY and FCHR_ENB, the latter is identified as "Force charging disable" in the data sheet but it also says "Merge with HOMEKEY", so call it "Home" for consistency.
--- drivers/mfd/mt6397-core.c | 100 ++++-- drivers/mfd/mt6397-irq.c | 8 + include/linux/mfd/mt6392/core.h | 43 +++ include/linux/mfd/mt6392/registers.h | 488 +++++++++++++++++++++++++++ include/linux/mfd/mt6397/core.h | 1 + 5 files changed, 614 insertions(+), 26 deletions(-) create mode 100644 include/linux/mfd/mt6392/core.h create mode 100644 include/linux/mfd/mt6392/registers.h
drivers/mfd/mt6397-core.c +74 -26
@@ -18,6 +18,7 @@#include <linux/mfd/mt6357/core.h> #include <linux/mfd/mt6358/core.h> #include <linux/mfd/mt6359/core.h> +#include <linux/mfd/mt6392/core.h> #include <linux/mfd/mt6397/core.h> #include <linux/mfd/mt6323/registers.h> #include <linux/mfd/mt6328/registers.h>
@@ -25,6 +26,7 @@#include <linux/mfd/mt6357/registers.h> #include <linux/mfd/mt6358/registers.h> #include <linux/mfd/mt6359/registers.h> +#include <linux/mfd/mt6392/registers.h> #include <linux/mfd/mt6397/registers.h> #define MT6323_RTC_BASE 0x8000
@@ -39,6 +41,9 @@#define MT6358_RTC_BASE 0x0588#define MT6358_RTC_SIZE 0x3c +#define MT6392_RTC_BASE 0x8000 +#define MT6392_RTC_SIZE 0x3e +#define MT6397_RTC_BASE 0xe000#define MT6397_RTC_SIZE 0x3e
@@ -65,6 +70,11 @@ static const struct resource mt6358_rtc_resources[] = { DEFINE_RES_IRQ(MT6358_IRQ_RTC), }; +static const struct resource mt6392_rtc_resources[] = { +DEFINE_RES_MEM (MT6392_RTC_BASE ,MT6392_RTC_SIZE ), +DEFINE_RES_IRQ (MT6392_IRQ_RTC ), +}; +static const struct resource mt6397_rtc_resources[] = {DEFINE_RES_MEM (MT6397_RTC_BASE ,MT6397_RTC_SIZE ),DEFINE_RES_IRQ (MT6397_IRQ_RTC ),
@@ -114,6 +124,13 @@ static const struct resource mt6331_keys_resources[] = { DEFINE_RES_IRQ_NAMED(MT6331_IRQ_STATUS_HOMEKEY, "homekey"), }; +static const struct resource mt6392_keys_resources[] = { +DEFINE_RES_IRQ_NAMED (MT6392_IRQ_PWRKEY ,"powerkey" ), +DEFINE_RES_IRQ_NAMED (MT6392_IRQ_FCHRKEY ,"homekey" ), +DEFINE_RES_IRQ_NAMED (MT6392_IRQ_RELEASE_PWRKEY ,"powerkey_r" ), +DEFINE_RES_IRQ_NAMED (MT6392_IRQ_RELEASE_FCHRKEY ,"homekey_r" ), +}; +static const struct resource mt6397_keys_resources[] = {DEFINE_RES_IRQ_NAMED (MT6397_IRQ_PWRKEY ,"powerkey" ),DEFINE_RES_IRQ_NAMED (MT6397_IRQ_HOMEKEY ,"homekey" ),
@@ -197,6 +214,16 @@ static const struct mfd_cell mt6359_devs[] = { "mediatek,mt6359-accdet"), }; +static const struct mfd_cell mt6392_devs[] = { +MFD_CELL_OF ("mt6392-keys" , mt6392_keys_resources,NULL ,0 ,0 , +"mediatek,mt6392-keys" ), +MFD_CELL_OF ("mt6392-pinctrl" ,NULL ,NULL ,0 ,0 , +"mediatek,mt6392-pinctrl" ), +MFD_CELL_NAME ("mt6392-regulator" ), +MFD_CELL_OF ("mt6392-rtc" , mt6392_rtc_resources,NULL ,0 ,0 , +"mediatek,mt6392-rtc" ), +}; +static const struct mfd_cell mt6397_devs[] = {MFD_CELL_OF ("mt6397-rtc" , mt6397_rtc_resources,NULL ,0 ,0 ,"mediatek,mt6397-rtc" ),
@@ -268,6 +295,14 @@ static const struct chip_data mt6359_core = { .irq_init = mt6358_irq_init, }; +static const struct chip_data mt6392_core = { + .cid_addr =MT6392_CID , + .cid_shift =0 , + .cells = mt6392_devs, + .cell_size =ARRAY_SIZE (mt6392_devs), + .irq_init = mt6397_irq_init, +}; +static const struct chip_data mt6397_core = { .cid_addr =MT6397_CID , .cid_shift =0 ,
@@ -282,6 +317,7 @@ static int mt6397_probe(struct platform_device *pdev)unsigned int id =0 ;struct mt6397_chip *pmic;const struct chip_data *pmic_core; +int chip_variant; pmic =devm_kzalloc (&pdev->dev,sizeof (*pmic),GFP_KERNEL );if (!pmic)
@@ -297,9 +333,36 @@ static int mt6397_probe(struct platform_device *pdev)if (!pmic->regmap)return -ENODEV ; - pmic_core =of_device_get_match_data (&pdev->dev); -if (!pmic_core) + chip_variant = (unsigned int )(uintptr_t )device_get_match_data (&pdev->dev); +switch (chip_variant) { +case MT6323_CHIP_ID : + pmic_core = &mt6323_core; +break ; +case MT6328_CHIP_ID : + pmic_core = &mt6328_core; +break ; +case MT6331_CHIP_ID : + pmic_core = &mt6331_mt6332_core; +break ; +case MT6357_CHIP_ID : + pmic_core = &mt6357_core; +break ; +case MT6358_CHIP_ID : + pmic_core = &mt6358_core; +break ; +case MT6359_CHIP_ID : + pmic_core = &mt6359_core; +break ; +case MT6392_CHIP_ID : + pmic_core = &mt6392_core; +break ; +case MT6397_CHIP_ID : + pmic_core = &mt6397_core; +break ; +default : +dev_err (&pdev->dev,"Device not supported\n" );return -ENODEV ; + } ret =regmap_read (pmic->regmap, pmic_core->cid_addr, &id);if (ret) {
@@ -331,30 +394,15 @@ static int mt6397_probe(struct platform_device *pdev) }static const struct of_device_id mt6397_of_match[] = { - { - .compatible ="mediatek,mt6323" , - .data = &mt6323_core, - }, { - .compatible ="mediatek,mt6328" , - .data = &mt6328_core, - }, { - .compatible ="mediatek,mt6331" , - .data = &mt6331_mt6332_core, - }, { - .compatible ="mediatek,mt6357" , - .data = &mt6357_core, - }, { - .compatible ="mediatek,mt6358" , - .data = &mt6358_core, - }, { - .compatible ="mediatek,mt6359" , - .data = &mt6359_core, - }, { - .compatible ="mediatek,mt6397" , - .data = &mt6397_core, - }, { -/* sentinel */ - } + { .compatible ="mediatek,mt6323" , .data = (void *)MT6323_CHIP_ID , }, + { .compatible ="mediatek,mt6328" , .data = (void *)MT6328_CHIP_ID , }, + { .compatible ="mediatek,mt6331" , .data = (void *)MT6331_CHIP_ID , }, + { .compatible ="mediatek,mt6357" , .data = (void *)MT6357_CHIP_ID , }, + { .compatible ="mediatek,mt6358" , .data = (void *)MT6358_CHIP_ID , }, + { .compatible ="mediatek,mt6359" , .data = (void *)MT6359_CHIP_ID , }, + { .compatible ="mediatek,mt6392" , .data = (void *)MT6392_CHIP_ID , }, + { .compatible ="mediatek,mt6397" , .data = (void *)MT6397_CHIP_ID , }, + {/* sentinel */ } };MODULE_DEVICE_TABLE (of, mt6397_of_match);
drivers/mfd/mt6397-irq.c +8 -0
@@ -15,6 +15,8 @@#include <linux/mfd/mt6328/registers.h> #include <linux/mfd/mt6331/core.h> #include <linux/mfd/mt6331/registers.h> +#include <linux/mfd/mt6392/core.h> +#include <linux/mfd/mt6392/registers.h> #include <linux/mfd/mt6397/core.h> #include <linux/mfd/mt6397/registers.h>
@@ -203,6 +205,12 @@ int mt6397_irq_init(struct mt6397_chip *chip) chip->int_status[0 ] =MT6397_INT_STATUS0 ; chip->int_status[1 ] =MT6397_INT_STATUS1 ;break ; +case MT6392_CHIP_ID : + chip->int_con[0 ] =MT6392_INT_CON0 ; + chip->int_con[1 ] =MT6392_INT_CON1 ; + chip->int_status[0 ] =MT6392_INT_STATUS0 ; + chip->int_status[1 ] =MT6392_INT_STATUS1 ; +break ;default :dev_err (chip->dev,"unsupported chip: 0x%x\n" , chip->chip_id);
include/linux/mfd/mt6392/core.h new file +43 -0
43 lines not on this page · raw message
include/linux/mfd/mt6392/registers.h new file +488 -0
488 lines not on this page · raw message
include/linux/mfd/mt6397/core.h +1 -0
@@ -20,6 +20,7 @@ enum chip_id {MT6359_CHIP_ID =0x59 ,MT6366_CHIP_ID =0x66 ,MT6391_CHIP_ID =0x91 , +MT6392_CHIP_ID =0x92 , MT6397_CHIP_ID = 0x97, };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 5/9] mfd: mt6397: Add support for MT6392 PMIC
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
From: Fabien Parent <[email protected]>
Align the MT6397 PMIC driver to other MFD drivers by passing only an identifier through mt6397_of_match[*].data and add support for the MT6392 PMIC and its regulator, RTC, keys and pinctrl devices.
Quoted 7 lines
The keys device manages two buttons named PWRKEY and
FCHR_ENB, the latter is identified as "Force charging disable" in the data sheet but it also says "Merge with HOMEKEY", so call it "Home" for consistency.Signed-off-by Fabien Parent <[email protected]>Signed-off-by Val Packett <[email protected]>Signed-off-by Luca Leonardo Scorcia <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH RESEND v10 6/9 input: keyboard: mtk-pmic-keys: Add MT6392 support
In reply to Luca Leonardo ScorciaFrom: Val Packett <[email protected]>
Add support for the MT6392 PMIC to the keys driver.
--- drivers/input/keyboard/mtk-pmic-keys.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/input/keyboard/mtk-pmic-keys.c +18 -0
@@ -13,6 +13,7 @@#include <linux/mfd/mt6357/registers.h> #include <linux/mfd/mt6358/registers.h> #include <linux/mfd/mt6359/registers.h> +#include <linux/mfd/mt6392/registers.h> #include <linux/mfd/mt6397/core.h> #include <linux/mfd/mt6397/registers.h> #include <linux/module.h>
@@ -69,6 +70,20 @@ static const struct mtk_pmic_regs mt6397_regs = { .rst_lprst_mask = MTK_PMIC_RST_DU_MASK, }; +static const struct mtk_pmic_regs mt6392_regs = { + .keys_regs[MTK_PMIC_PWRKEY_INDEX ] = +MTK_PMIC_KEYS_REGS (MT6392_CHRSTATUS ,0x2 , +MT6392_INT_MISC_CON ,0x10 , +MTK_PMIC_PWRKEY_RST ), + .keys_regs[MTK_PMIC_HOMEKEY_INDEX ] = +MTK_PMIC_KEYS_REGS (MT6392_CHRSTATUS ,0x4 , +MT6392_INT_MISC_CON ,0x8 , +MTK_PMIC_HOMEKEY_RST ), + .pmic_rst_reg =MT6392_TOP_RST_MISC , + .rst_lprst_mask =MTK_PMIC_RST_DU_MASK , + .key_release_irq = true, +}; +static const struct mtk_pmic_regs mt6323_regs = { .keys_regs[MTK_PMIC_PWRKEY_INDEX ] = MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
@@ -301,6 +316,9 @@ static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = { { .compatible = "mediatek,mt6397-keys", .data = &mt6397_regs, + }, { + .compatible = "mediatek,mt6392-keys", + .data = &mt6392_regs, }, { .compatible = "mediatek,mt6323-keys", .data = &mt6323_regs,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 6/9] input: keyboard: mtk-pmic-keys: Add MT6392 support
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
From: Val Packett <[email protected]>
Add support for the MT6392 PMIC to the keys driver.
Signed-off-by Val Packett <[email protected]>Signed-off-by Luca Leonardo Scorcia <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
PATCH RESEND v10 7/9 pinctrl: mediatek: mt6397: Add MediaTek MT6392
In reply to Luca Leonardo ScorciaAdd support for the MT6392 pinctrl device, which is very similar to MT6397 with a handful of different property values and its own pins definition.
Update the MT6397 driver to retrieve device data from the match table and use it for driver init.
--- drivers/pinctrl/mediatek/pinctrl-mt6397.c | 37 ++++++++++- drivers/pinctrl/mediatek/pinctrl-mtk-mt6392.h | 64 +++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt6392.h
drivers/pinctrl/mediatek/pinctrl-mt6397.c +35 -2
@@ -12,10 +12,32 @@#include <linux/mfd/mt6397/core.h> #include "pinctrl-mtk-common.h" +#include "pinctrl-mtk-mt6392.h" #include "pinctrl-mtk-mt6397.h" #define MT6397_PIN_REG_BASE 0xc000 +static const struct mtk_pinctrl_devdata mt6392_pinctrl_data = { + .pins = mtk_pins_mt6392, + .npins =ARRAY_SIZE (mtk_pins_mt6392), + .dir_offset = (MT6397_PIN_REG_BASE +0x000 ), + .ies_offset =MTK_PINCTRL_NOT_SUPPORT , + .smt_offset =MTK_PINCTRL_NOT_SUPPORT , + .pullen_offset = (MT6397_PIN_REG_BASE +0x020 ), + .pullsel_offset = (MT6397_PIN_REG_BASE +0x040 ), + .dout_offset = (MT6397_PIN_REG_BASE +0x080 ), + .din_offset = (MT6397_PIN_REG_BASE +0x0a0 ), + .pinmux_offset = (MT6397_PIN_REG_BASE +0x0c0 ), + .type1_start =7 , + .type1_end =7 , + .port_shf =3 , + .port_mask =0x3 , + .port_align =2 , + .mode_mask =0xf , + .mode_per_reg =5 , + .mode_shf =4 , +}; +static const struct mtk_pinctrl_devdata mt6397_pinctrl_data = { .pins = mtk_pins_mt6397, .npins =ARRAY_SIZE (mtk_pins_mt6397),
@@ -40,13 +62,24 @@ static const struct mtk_pinctrl_devdata mt6397_pinctrl_data = {static int mt6397_pinctrl_probe (struct platform_device *pdev) {struct mt6397_chip *mt6397; +const struct mtk_pinctrl_devdata *data; + + data =device_get_match_data (&pdev->dev); +if (!data) +return -ENOENT ; mt6397 =dev_get_drvdata (pdev->dev.parent); -return mtk_pctrl_init (pdev, &mt6397_pinctrl_data, mt6397->regmap); +return mtk_pctrl_init (pdev, data, mt6397->regmap); }static const struct of_device_id mt6397_pctrl_match[] = { - { .compatible ="mediatek,mt6397-pinctrl" , }, + { + .compatible ="mediatek,mt6392-pinctrl" , + .data = &mt6392_pinctrl_data + }, { + .compatible ="mediatek,mt6397-pinctrl" , + .data = &mt6397_pinctrl_data + }, { } };MODULE_DEVICE_TABLE (of, mt6397_pctrl_match);
drivers/pinctrl/mediatek/pinctrl-mtk-mt6392.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 7/9] pinctrl: mediatek: mt6397: Add MediaTek MT6392
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
Add support for the MT6392 pinctrl device, which is very similar to MT6397 with a handful of different property values and its own pins definition.
Update the MT6397 driver to retrieve device data from the match table and use it for driver init.
Signed-off-by Luca Leonardo Scorcia <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
PATCH RESEND v10 8/9 regulator: Add MediaTek MT6392 regulator
In reply to Luca Leonardo ScorciaFrom: Fabien Parent <[email protected]>
The MT6392 is a regulator found on boards based on the MediaTek MT8167, MT8516, and probably other SoCs. It is a so called PMIC and connects as a slave to a SoC using SPI, wrapped inside PWRAP.
--- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/mt6392-regulator.c | 764 +++++++++++++++++++++ include/linux/regulator/mt6392-regulator.h | 42 ++ 4 files changed, 816 insertions(+) create mode 100644 drivers/regulator/mt6392-regulator.c create mode 100644 include/linux/regulator/mt6392-regulator.h
drivers/regulator/Kconfig +9 -0
@@ -1001,6 +1001,15 @@ config REGULATOR_MT6380 This driver supports the control of different power rails of device through regulator interface. +config REGULATOR_MT6392 + tristate "MediaTek MT6392 PMIC" + depends on MFD_MT6397 + help + Say y here to select this option to enable the power regulator of + MediaTek MT6392 PMIC. + This driver supports the control of different power rails of device + through regulator interface. + config REGULATOR_MT6397 tristate "MediaTek MT6397 PMIC" depends on MFD_MT6397
drivers/regulator/Makefile +1 -0
@@ -118,6 +118,7 @@ obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o obj-$(CONFIG_REGULATOR_MT6363) += mt6363-regulator.o obj-$(CONFIG_REGULATOR_MT6370) += mt6370-regulator.o obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o +obj-$(CONFIG_REGULATOR_MT6392) += mt6392-regulator.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o obj-$(CONFIG_REGULATOR_MTK_DVFSRC) += mtk-dvfsrc-regulator.o obj-$(CONFIG_REGULATOR_QCOM_LABIBB) += qcom-labibb-regulator.o
drivers/regulator/mt6392-regulator.c new file +764 -0
764 lines not on this page · raw message
include/linux/regulator/mt6392-regulator.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 8/9] regulator: Add MediaTek MT6392 regulator
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] regulator: mt6392: OF node reference leak in mt6392_regulator_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] regulator: mt6392: OF node reference leak in mt6392_regulator_probe() --
commit 04b22037bb949a80f26c6f5651752d61ee106b28
Author: Fabien Parent <[email protected]>
regulator: Add MediaTek MT6392 regulator
This commit adds a regulator driver for the MediaTek MT6392 PMIC.
Quoted 6 lines
drivers/regulator/mt6392-regulator.c new file +0
-0@@ -0,0 +1,764 @@
[ ... ]
Quoted 5 lines
drivers/regulator/mt6392-regulator.c new file +5
-0+static int mt6392_regulator_probe (struct platform_device *pdev) +{ +struct mt6397_chip *mt6392 =dev_get_drvdata (pdev->dev.parent); +struct regulator_config config = {}; +struct regulator_dev *rdev;
drivers/regulator/mt6392-regulator.c line 728
Quoted 10 lines
drivers/regulator/mt6392-regulator.c new file +10
-0+int i; + +device_set_of_node_from_dev (&pdev->dev, pdev->dev.parent); + +// Initialize the bucks' vsel_reg and vsel_mask according to current HW state +if (mt6392_set_buck_vsel_reg (pdev)) +return -EIO ; + + config.dev = mt6392->dev; + config.regmap = mt6392->regmap;
[Severity: Medium]
Does calling device_set_of_node_from_dev() here leak a reference on pdev->dev.parent->of_node when the platform device is released?
In drivers/mfd/mt6397-core.c, the mt6392-regulator cell is defined without an of_compatible string, so mfd_add_device() allocates the child device via platform_device_alloc() with pdev->dev.of_node and pdev->dev.fwnode set to NULL.
Calling device_set_of_node_from_dev() in mt6392_regulator_probe() increments the reference count on pdev->dev.parent->of_node and assigns it to pdev->dev.of_node, without setting pdev->dev.fwnode:
drivers/base/core.c:device_set_of_node_from_dev() {
of_node_put(dev->of_node);
dev->of_node = of_node_get(dev2->of_node);
dev_set_of_node_reused(dev);
}When the platform device is later torn down, platform_device_release() only puts pa->pdev.dev.fwnode:
drivers/base/platform.c:platform_device_release() {
...
if (!is_software_node(dev_fwnode(dev)))
fwnode_handle_put(pa->pdev.dev.fwnode);
...
}Since pdev->dev.fwnode remains NULL, fwnode_handle_put() is a no-op and the reference on pdev->dev.of_node is never dropped.
Also, since config.dev is already set to mt6392->dev (the parent device), which the regulator core uses for DT node and supply lookups, could the device_set_of_node_from_dev() call simply be dropped (or replaced with platform_device_set_of_node_from_dev() if needed)?
[ ... ]
Quoted 2 lines
drivers/regulator/mt6392-regulator.c new file +2
-0+return 0 ; +}
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
PATCH RESEND v10 9/9 arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi
In reply to Luca Leonardo ScorciaFrom: Val Packett <[email protected]>
Add the dtsi to be included by all boards using the MT6392 PMIC, providing support for regulator, keys, pinctrl and RTC.
Import the new file in the shared device tree for the Pumpkin boards.
--- arch/arm64/boot/dts/mediatek/mt6392.dtsi | 145 ++++++++++++++++++ .../boot/dts/mediatek/pumpkin-common.dtsi | 7 + 2 files changed, 152 insertions(+) create mode 100644 arch/arm64/boot/dts/mediatek/mt6392.dtsi
arch/arm64/boot/dts/mediatek/mt6392.dtsi new file +145 -0
@@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + * Copyright (c) 2024 Val Packett <[email protected]> + * Copyright (c) 2026 Luca Leonardo Scorcia <[email protected]> + */ + +#include <dt-bindings/input/input.h> +#include <dt-bindings/regulator/mediatek,mt6392-regulator.h> + +&pwrap { + pmic: pmic { + compatible = "mediatek,mt6392"; + interrupt-controller; + #interrupt-cells = <2>; + + mt6392keys: keys { + compatible = "mediatek,mt6392-keys"; + + key-power { + linux,keycodes = <KEY_POWER>; + wakeup-source; + }; + + key-home { + linux,keycodes = <KEY_HOME>; + wakeup-source; + }; + }; + + mt6392pio: pinctrl { + compatible = "mediatek,mt6392-pinctrl"; + + gpio-controller; + #gpio-cells = <2>; + }; + + mt6392regulators: regulators { + compatible = "mediatek,mt6392-regulator"; + + /* Fixed supply defined in the data sheet */ + avddldo-supply = <&mt6392_vsys_reg>; + + mt6392_vcore_reg: vcore { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_BUCK_MODE_FORCE_PWM>; + }; + mt6392_vproc_reg: vproc { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_BUCK_MODE_FORCE_PWM>; + }; + mt6392_vsys_reg: vsys { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_BUCK_MODE_FORCE_PWM>; + }; + mt6392_vaud28_reg: vaud28 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vxo22_reg: vxo22 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vaud22_reg: vaud22 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vadc18_reg: vadc18 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vcama_reg: vcama { }; + mt6392_vcn35_reg: vcn35 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vio28_reg: vio28 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vusb_reg: vusb { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vmc_reg: vmc { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vmch_reg: vmch { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vemc3v3_reg: vemc3v3 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vcamaf_reg: vcamaf { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vgp1_reg: vgp1 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vgp2_reg: vgp2 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vefuse_reg: vefuse { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vm25_reg: vm25 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vdig18_reg: vdig18 { }; + mt6392_vm_reg: vm { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vio18_reg: vio18 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vcn18_reg: vcn18 { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vcamd_reg: vcamd { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vcamio_reg: vcamio { + regulator-allowed-modes = <MT6392_REGULATOR_MODE_NORMAL + MT6392_LDO_MODE_LP>; + }; + mt6392_vrtc_reg: vrtc { }; + }; + + mt6392rtc: rtc { + compatible = "mediatek,mt6392-rtc", "mediatek,mt6323-rtc"; + }; + }; +};
arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi +7 -0
@@ -6,6 +6,8 @@ #include <dt-bindings/gpio/gpio.h> +#include "mt6392.dtsi" + / { aliases { serial0 = &uart0;
@@ -160,6 +162,11 @@ &i2c2 { status = "okay"; }; +&pmic { + interrupt-parent = <&pio>; + interrupts = <28 IRQ_TYPE_LEVEL_HIGH>; +}; + &uart0 { status = "okay"; };
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH RESEND v10 9/9] arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] arm64: dts: mediatek: mt6392 pmic fails pwrap_probe() due to missing ID --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] arm64: dts: mediatek: mt6392 pmic fails pwrap_probe() due to missing ID --
commit 36e8cdb3fad1df2fc1833ecbab6f1f641807e610
Author: Val Packett <[email protected]>
arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi
This commit adds the mt6392.dtsi device tree include file for the MediaTek MT6392 PMIC (providing regulator, keys, pinctrl, and RTC nodes) and includes it in pumpkin-common.dtsi.
Quoted 11 lines
arch/arm64/boot/dts/mediatek/mt6392.dtsi new file +5
-0@@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + * Copyright (c) 2024 Val Packett <[email protected]> + * Copyright (c) 2026 Luca Leonardo Scorcia <[email protected]>
arch/arm64/boot/dts/mediatek/mt6392.dtsi line 15
Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt6392.dtsi new file +10
-0+ */ + +#include <dt-bindings/input/input.h> +#include <dt-bindings/regulator/mediatek,mt6392-regulator.h> + +&pwrap { + pmic: pmic { + compatible = "mediatek,mt6392"; + interrupt-controller; + #interrupt-cells = <2>;
[Severity: High]
Will pwrap_probe() fail with -EINVAL on boards that include mt6392.dtsi?
In drivers/soc/mediatek/mtk-pmic-wrap.c, pwrap_probe() matches the child PMIC node of pwrap against of_slave_match_tbl:
drivers/soc/mediatek/mtk-pmic-wrap.c:pwrap_probe() {
...
if (np->child)
of_slave_id = of_match_node(of_slave_match_tbl, np->child);
if (!of_slave_id) {
dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
return -EINVAL;
}
...
}However, of_slave_match_tbl in drivers/soc/mediatek/mtk-pmic-wrap.c only lists:
static const struct of_device_id of_slave_match_tbl[] = {
{ .compatible = "mediatek,mt6323", .data = &pmic_mt6323 },
{ .compatible = "mediatek,mt6331", .data = &pmic_mt6331 },
{ .compatible = "mediatek,mt6351", .data = &pmic_mt6351 },
{ .compatible = "mediatek,mt6357", .data = &pmic_mt6357 },
{ .compatible = "mediatek,mt6358", .data = &pmic_mt6358 },
{ .compatible = "mediatek,mt6359", .data = &pmic_mt6359 },
{ .compatible = "mediatek,mt6380-regulator", .data = &pmic_mt6380 },
{ .compatible = "mediatek,mt6397", .data = &pmic_mt6397 },
{ /* sentinel */ }
};Because there is no "mediatek,mt6392" entry in of_slave_match_tbl (and the pmic node has no fallback compatible string), of_slave_id is NULL and pwrap_probe() aborts before initializing the regmap or calling of_platform_populate() for the PMIC and its subdevices.
[ ... ]
Quoted 11 lines
arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi +2
-0@@ -6,6 +6,8 @@ #include <dt-bindings/gpio/gpio.h> +#include "mt6392.dtsi" + / {
[ ... ]
Quoted 12 lines
arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi +5
-0@@ -160,6 +162,11 @@ &i2c2 { status = "okay"; }; +&pmic { + interrupt-parent = <&pio>; + interrupts = <28 IRQ_TYPE_LEVEL_HIGH>; +}; + &uart0 { status = "okay"; };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9