drivers/mfd/mt6397-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Do not use "mtk-pmic-keys" when creating sub-device for the keypad to
make sure the keypad driver will only bind to the sub-device if it has
support for the variant/has matching compatible.
Reported-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
Fixes: 6e31bb8d3a63 ("mfd: mt6397: Add initial support for MT6328")
Fixes: de58cee8c6b8 ("mfd: mt6397-core: Add MT6357 PMIC support")
Fixes: 4a901e305011 ("mfd: mt6397-core: Add resources for PMIC keys for MT6359")
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
This is not tested so if someone with hardware could try it out that
would be great. I *think* it should work...
drivers/mfd/mt6397-core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 5f8ed8988907..3e58d0764c7e 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -136,7 +136,7 @@ static const struct mfd_cell mt6323_devs[] = {
.name = "mt6323-led",
.of_compatible = "mediatek,mt6323-led"
}, {
- .name = "mtk-pmic-keys",
+ .name = "mt6323-keys",
.num_resources = ARRAY_SIZE(mt6323_keys_resources),
.resources = mt6323_keys_resources,
.of_compatible = "mediatek,mt6323-keys"
@@ -153,7 +153,7 @@ static const struct mfd_cell mt6328_devs[] = {
.name = "mt6328-regulator",
.of_compatible = "mediatek,mt6328-regulator"
}, {
- .name = "mtk-pmic-keys",
+ .name = "mt6328-keys",
.num_resources = ARRAY_SIZE(mt6328_keys_resources),
.resources = mt6328_keys_resources,
.of_compatible = "mediatek,mt6328-keys"
@@ -175,7 +175,7 @@ static const struct mfd_cell mt6357_devs[] = {
.name = "mt6357-sound",
.of_compatible = "mediatek,mt6357-sound"
}, {
- .name = "mtk-pmic-keys",
+ .name = "mt6357-keys",
.num_resources = ARRAY_SIZE(mt6357_keys_resources),
.resources = mt6357_keys_resources,
.of_compatible = "mediatek,mt6357-keys"
@@ -196,7 +196,7 @@ static const struct mfd_cell mt6331_mt6332_devs[] = {
.name = "mt6332-regulator",
.of_compatible = "mediatek,mt6332-regulator"
}, {
- .name = "mtk-pmic-keys",
+ .name = "mt6331-keys",
.num_resources = ARRAY_SIZE(mt6331_keys_resources),
.resources = mt6331_keys_resources,
.of_compatible = "mediatek,mt6331-keys"
@@ -240,7 +240,7 @@ static const struct mfd_cell mt6359_devs[] = {
},
{ .name = "mt6359-sound", },
{
- .name = "mtk-pmic-keys",
+ .name = "mt6359-keys",
.num_resources = ARRAY_SIZE(mt6359_keys_resources),
.resources = mt6359_keys_resources,
.of_compatible = "mediatek,mt6359-keys"
@@ -272,7 +272,7 @@ static const struct mfd_cell mt6397_devs[] = {
.name = "mt6397-pinctrl",
.of_compatible = "mediatek,mt6397-pinctrl",
}, {
- .name = "mtk-pmic-keys",
+ .name = "mt6397-keys",
.num_resources = ARRAY_SIZE(mt6397_keys_resources),
.resources = mt6397_keys_resources,
.of_compatible = "mediatek,mt6397-keys"
--
2.50.0.727.gbf7dc18ff4-goog
--
Dmitry
On Mon, 30 Jun 2025 16:01:06 -0700, Dmitry Torokhov wrote: > Do not use "mtk-pmic-keys" when creating sub-device for the keypad to > make sure the keypad driver will only bind to the sub-device if it has > support for the variant/has matching compatible. > > Applied, thanks! [1/1] MFD: mt6397: do not use generic name for keypad sub-devices commit: aea2ceab5917b72d37a2b2008e9e2489877737a9 -- Lee Jones [李琼斯]
Hi Dmitry, On Mon, 2025-06-30 at 16:01 -0700, Dmitry Torokhov wrote: > Do not use "mtk-pmic-keys" when creating sub-device for the keypad to > make sure the keypad driver will only bind to the sub-device if it > has > support for the variant/has matching compatible. > > Reported-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> > Fixes: 6e31bb8d3a63 ("mfd: mt6397: Add initial support for MT6328") > Fixes: de58cee8c6b8 ("mfd: mt6397-core: Add MT6357 PMIC support") > Fixes: 4a901e305011 ("mfd: mt6397-core: Add resources for PMIC keys > for MT6359") > Cc: stable@vger.kernel.org > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> > --- > > This is not tested so if someone with hardware could try it out that > would be great. I *think* it should work... > > drivers/mfd/mt6397-core.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c > index 5f8ed8988907..3e58d0764c7e 100644 > --- a/drivers/mfd/mt6397-core.c > +++ b/drivers/mfd/mt6397-core.c > @@ -136,7 +136,7 @@ static const struct mfd_cell mt6323_devs[] = { > .name = "mt6323-led", > .of_compatible = "mediatek,mt6323-led" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6323-keys", > .num_resources = ARRAY_SIZE(mt6323_keys_resources), > .resources = mt6323_keys_resources, > .of_compatible = "mediatek,mt6323-keys" > @@ -153,7 +153,7 @@ static const struct mfd_cell mt6328_devs[] = { > .name = "mt6328-regulator", > .of_compatible = "mediatek,mt6328-regulator" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6328-keys", > .num_resources = ARRAY_SIZE(mt6328_keys_resources), > .resources = mt6328_keys_resources, > .of_compatible = "mediatek,mt6328-keys" > @@ -175,7 +175,7 @@ static const struct mfd_cell mt6357_devs[] = { > .name = "mt6357-sound", > .of_compatible = "mediatek,mt6357-sound" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6357-keys", > .num_resources = ARRAY_SIZE(mt6357_keys_resources), > .resources = mt6357_keys_resources, > .of_compatible = "mediatek,mt6357-keys" > @@ -196,7 +196,7 @@ static const struct mfd_cell mt6331_mt6332_devs[] > = { > .name = "mt6332-regulator", > .of_compatible = "mediatek,mt6332-regulator" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6331-keys", > .num_resources = ARRAY_SIZE(mt6331_keys_resources), > .resources = mt6331_keys_resources, > .of_compatible = "mediatek,mt6331-keys" > @@ -240,7 +240,7 @@ static const struct mfd_cell mt6359_devs[] = { > }, > { .name = "mt6359-sound", }, > { > - .name = "mtk-pmic-keys", > + .name = "mt6359-keys", > .num_resources = ARRAY_SIZE(mt6359_keys_resources), > .resources = mt6359_keys_resources, > .of_compatible = "mediatek,mt6359-keys" > @@ -272,7 +272,7 @@ static const struct mfd_cell mt6397_devs[] = { > .name = "mt6397-pinctrl", > .of_compatible = "mediatek,mt6397-pinctrl", > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6397-keys", > .num_resources = ARRAY_SIZE(mt6397_keys_resources), > .resources = mt6397_keys_resources, > .of_compatible = "mediatek,mt6397-keys" > -- > 2.50.0.727.gbf7dc18ff4-goog > Thanks for the patch. I've tested it with a kernel based on next-20250702 on both Mediatek Genio 350-EVK and Genio 1200-EVK boards with mtk-pmic-keys driver enabled either as builtin or module. With the Genio 350-EVK, the mtk-pmic-keys driver probes OK: ``` [ 0.601874] input: mtk-pmic-keys as /devices/platform/soc/1000d000.pwrap/1000d000.pwrap:pmic/mt6357- keys/input/input0 ``` The keys work too. For the Genio 1200-EVK, it fails to probe as expected (because 'mediatek,mt6359-keys' compatible is missing) and there is indeed no kernel panic in the builtin case (the issue I reported with my patch) ``` [ 0.459178] mt6359-keys: Failed to locate of_node [id: -1] ``` Tested-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> # on Mediatek Genio 350-EVK and Genio 1200-EVK Regards, Louis-Alexis
On Mon, 30 Jun 2025, Dmitry Torokhov wrote: > Do not use "mtk-pmic-keys" when creating sub-device for the keypad to > make sure the keypad driver will only bind to the sub-device if it has > support for the variant/has matching compatible. > > Reported-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> > Fixes: 6e31bb8d3a63 ("mfd: mt6397: Add initial support for MT6328") > Fixes: de58cee8c6b8 ("mfd: mt6397-core: Add MT6357 PMIC support") > Fixes: 4a901e305011 ("mfd: mt6397-core: Add resources for PMIC keys for MT6359") > Cc: stable@vger.kernel.org > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> > --- > > This is not tested so if someone with hardware could try it out that > would be great. I *think* it should work... My suspicion is that this will not work. Providing compatible strings here is only for device to node matching. I do not believe the drivers will probe using them. You don't need H/W to test this theory. You can just feed in a DTB and see if it probes. QEMU should be good enough for this. > drivers/mfd/mt6397-core.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c > index 5f8ed8988907..3e58d0764c7e 100644 > --- a/drivers/mfd/mt6397-core.c > +++ b/drivers/mfd/mt6397-core.c > @@ -136,7 +136,7 @@ static const struct mfd_cell mt6323_devs[] = { > .name = "mt6323-led", > .of_compatible = "mediatek,mt6323-led" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6323-keys", > .num_resources = ARRAY_SIZE(mt6323_keys_resources), > .resources = mt6323_keys_resources, > .of_compatible = "mediatek,mt6323-keys" > @@ -153,7 +153,7 @@ static const struct mfd_cell mt6328_devs[] = { > .name = "mt6328-regulator", > .of_compatible = "mediatek,mt6328-regulator" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6328-keys", > .num_resources = ARRAY_SIZE(mt6328_keys_resources), > .resources = mt6328_keys_resources, > .of_compatible = "mediatek,mt6328-keys" > @@ -175,7 +175,7 @@ static const struct mfd_cell mt6357_devs[] = { > .name = "mt6357-sound", > .of_compatible = "mediatek,mt6357-sound" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6357-keys", > .num_resources = ARRAY_SIZE(mt6357_keys_resources), > .resources = mt6357_keys_resources, > .of_compatible = "mediatek,mt6357-keys" > @@ -196,7 +196,7 @@ static const struct mfd_cell mt6331_mt6332_devs[] = { > .name = "mt6332-regulator", > .of_compatible = "mediatek,mt6332-regulator" > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6331-keys", > .num_resources = ARRAY_SIZE(mt6331_keys_resources), > .resources = mt6331_keys_resources, > .of_compatible = "mediatek,mt6331-keys" > @@ -240,7 +240,7 @@ static const struct mfd_cell mt6359_devs[] = { > }, > { .name = "mt6359-sound", }, > { > - .name = "mtk-pmic-keys", > + .name = "mt6359-keys", > .num_resources = ARRAY_SIZE(mt6359_keys_resources), > .resources = mt6359_keys_resources, > .of_compatible = "mediatek,mt6359-keys" > @@ -272,7 +272,7 @@ static const struct mfd_cell mt6397_devs[] = { > .name = "mt6397-pinctrl", > .of_compatible = "mediatek,mt6397-pinctrl", > }, { > - .name = "mtk-pmic-keys", > + .name = "mt6397-keys", > .num_resources = ARRAY_SIZE(mt6397_keys_resources), > .resources = mt6397_keys_resources, > .of_compatible = "mediatek,mt6397-keys" > -- > 2.50.0.727.gbf7dc18ff4-goog > > > -- > Dmitry -- Lee Jones [李琼斯]
On Tue, Jul 01, 2025 at 11:58:11AM +0100, Lee Jones wrote: > On Mon, 30 Jun 2025, Dmitry Torokhov wrote: > > > Do not use "mtk-pmic-keys" when creating sub-device for the keypad to > > make sure the keypad driver will only bind to the sub-device if it has > > support for the variant/has matching compatible. > > > > Reported-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> > > Fixes: 6e31bb8d3a63 ("mfd: mt6397: Add initial support for MT6328") > > Fixes: de58cee8c6b8 ("mfd: mt6397-core: Add MT6357 PMIC support") > > Fixes: 4a901e305011 ("mfd: mt6397-core: Add resources for PMIC keys for MT6359") > > Cc: stable@vger.kernel.org > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> > > --- > > > > This is not tested so if someone with hardware could try it out that > > would be great. I *think* it should work... > > My suspicion is that this will not work. Providing compatible strings > here is only for device to node matching. I do not believe the drivers > will probe using them. Actually it should. If we check the drivers for "mt6323-rtc" you will see that MFD core defines a sub-device with this name and similar compatible, but the RTC platform driver only lists compatible: dtor@dtor-ws:~/kernel/work $ git grep mt6323-rtc -- drivers/ drivers/mfd/mt6397-core.c: .name = "mt6323-rtc", drivers/mfd/mt6397-core.c: .of_compatible = "mediatek,mt6323-rtc", drivers/rtc/rtc-mt6397.c: { .compatible = "mediatek,mt6323-rtc", .data = &mt6397_rtc_data }, Driver name that is defined in drivers/rtc/rtc-mt6397.c is "mt6397-rtc" not "mt6323-rtc". And if we look into MFD core we can see how it works: mfd_add_device() scans the main (parent) device tree node children, locates devices with matching compatibles, and calls mfd_match_of_node_to_dev() for them. The latter essentially copies/assigns device tree node to the platform device that is being created, compatibles and all. From that point normal binding rules will work and they take into account OF compatibles; we no longer need to have matching platform driver name to match. Thanks. -- Dmitry
© 2016 - 2025 Red Hat, Inc.