2021-05-06 10:08:44

by Mattijs Korpershoek

[permalink] [raw]
Subject: [PATCH 0/3] MT6358 PMIC button support

The MediaTek MT6358 PMIC has support for two buttons: PWR and HOME.

The interrupt logic is a little different than other PMICs from the
same family:
* for MT6323 and MT6397, we have one interrupt source per button
* for MT6358, we have two interrupts lines per button: the press and
* release interrupts are distinct sources.

This series depends on [1]

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/

Mattijs Korpershoek (3):
mfd: mt6397: add mt6358 register definitions for power key
mfd: mt6397: keys: use named IRQs instead of index
mfd: mt6397: add PMIC keys for MT6358

drivers/mfd/mt6397-core.c | 20 ++++++++++++++++----
include/linux/mfd/mt6358/registers.h | 2 ++
2 files changed, 18 insertions(+), 4 deletions(-)

--
2.27.0


2021-05-06 10:08:50

by Mattijs Korpershoek

[permalink] [raw]
Subject: [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index

Some pmics of the mt6397 family (such as MT6358), have two IRQs per
physical key: one for press event, another for release event.

The mtk-pmic-keys driver assumes that each key only has one
IRQ. The key index and the RES_IRQ resource index have a 1/1 mapping.

This won't work for MT6358, as we have multiple resources (2) for one key.

To prepare mtk-pmic-keys to support MT6358, retrieve IRQs by name
instead of by index.

Note: The keys_resources are not part of the device-tree bindings so
this won't break any DT schemas.

Signed-off-by: Mattijs Korpershoek <[email protected]>
---
drivers/mfd/mt6397-core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index a83fbc486d26..5818e0c328c9 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -46,13 +46,13 @@ static const struct resource mt6397_rtc_resources[] = {
};

static const struct resource mt6323_keys_resources[] = {
- DEFINE_RES_IRQ(MT6323_IRQ_STATUS_PWRKEY),
- DEFINE_RES_IRQ(MT6323_IRQ_STATUS_FCHRKEY),
+ DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_PWRKEY, "powerkey"),
+ DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_FCHRKEY, "homekey"),
};

static const struct resource mt6397_keys_resources[] = {
- DEFINE_RES_IRQ(MT6397_IRQ_PWRKEY),
- DEFINE_RES_IRQ(MT6397_IRQ_HOMEKEY),
+ DEFINE_RES_IRQ_NAMED(MT6397_IRQ_PWRKEY, "powerkey"),
+ DEFINE_RES_IRQ_NAMED(MT6397_IRQ_HOMEKEY, "homekey"),
};

static const struct resource mt6323_pwrc_resources[] = {
--
2.27.0

2021-05-06 11:47:45

by Mattijs Korpershoek

[permalink] [raw]
Subject: [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358

Add compatible strings and interrupts for pmic keys
which serves as child device of MFD.

MT6358 has two interrupts per key: one for press, another one for
release (_R)

Signed-off-by: Mattijs Korpershoek <[email protected]>
---
drivers/mfd/mt6397-core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 5818e0c328c9..f882c76b4f88 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -45,6 +45,13 @@ static const struct resource mt6397_rtc_resources[] = {
DEFINE_RES_IRQ(MT6397_IRQ_RTC),
};

+static const struct resource mt6358_keys_resources[] = {
+ DEFINE_RES_IRQ_NAMED(MT6358_IRQ_PWRKEY, "powerkey"),
+ DEFINE_RES_IRQ_NAMED(MT6358_IRQ_HOMEKEY, "homekey"),
+ DEFINE_RES_IRQ_NAMED(MT6358_IRQ_PWRKEY_R, "powerkey_r"),
+ DEFINE_RES_IRQ_NAMED(MT6358_IRQ_HOMEKEY_R, "homekey_r"),
+};
+
static const struct resource mt6323_keys_resources[] = {
DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_PWRKEY, "powerkey"),
DEFINE_RES_IRQ_NAMED(MT6323_IRQ_STATUS_FCHRKEY, "homekey"),
@@ -96,6 +103,11 @@ static const struct mfd_cell mt6358_devs[] = {
}, {
.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"
},
};

--
2.27.0

2021-05-06 11:47:55

by Mattijs Korpershoek

[permalink] [raw]
Subject: [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key

To support power/home key detection, add definitions for
two more MT6358 PMIC registers:

- TOPSTATUS: homekey and powerkey debounce status
- TOP_RST_MISC: controls homekey,powerkey long press reset time

Signed-off-by: Mattijs Korpershoek <[email protected]>
---
include/linux/mfd/mt6358/registers.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/linux/mfd/mt6358/registers.h b/include/linux/mfd/mt6358/registers.h
index 2ad0b312aa28..201139b12140 100644
--- a/include/linux/mfd/mt6358/registers.h
+++ b/include/linux/mfd/mt6358/registers.h
@@ -8,6 +8,8 @@

/* PMIC Registers */
#define MT6358_SWCID 0xa
+#define MT6358_TOPSTATUS 0x28
+#define MT6358_TOP_RST_MISC 0x14c
#define MT6358_MISC_TOP_INT_CON0 0x188
#define MT6358_MISC_TOP_INT_STATUS0 0x194
#define MT6358_TOP_INT_STATUS0 0x19e
--
2.27.0

2021-05-19 19:28:09

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key

On Thu, 06 May 2021, Mattijs Korpershoek wrote:

> To support power/home key detection, add definitions for
> two more MT6358 PMIC registers:
>
> - TOPSTATUS: homekey and powerkey debounce status
> - TOP_RST_MISC: controls homekey,powerkey long press reset time
>
> Signed-off-by: Mattijs Korpershoek <[email protected]>
> ---
> include/linux/mfd/mt6358/registers.h | 2 ++
> 1 file changed, 2 insertions(+)

Applied, thanks.

--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

2021-05-19 19:29:24

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index

On Thu, 06 May 2021, Mattijs Korpershoek wrote:

> Some pmics of the mt6397 family (such as MT6358), have two IRQs per
> physical key: one for press event, another for release event.
>
> The mtk-pmic-keys driver assumes that each key only has one
> IRQ. The key index and the RES_IRQ resource index have a 1/1 mapping.
>
> This won't work for MT6358, as we have multiple resources (2) for one key.
>
> To prepare mtk-pmic-keys to support MT6358, retrieve IRQs by name
> instead of by index.
>
> Note: The keys_resources are not part of the device-tree bindings so
> this won't break any DT schemas.
>
> Signed-off-by: Mattijs Korpershoek <[email protected]>
> ---
> drivers/mfd/mt6397-core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks.

--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

2021-05-19 19:29:51

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358

On Thu, 06 May 2021, Mattijs Korpershoek wrote:

> Add compatible strings and interrupts for pmic keys
> which serves as child device of MFD.
>
> MT6358 has two interrupts per key: one for press, another one for
> release (_R)
>
> Signed-off-by: Mattijs Korpershoek <[email protected]>
> ---
> drivers/mfd/mt6397-core.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)

Applied, thanks.

--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog