linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] MT6358 PMIC button support
@ 2021-05-06  9:41 Mattijs Korpershoek
  2021-05-06  9:41 ` [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key Mattijs Korpershoek
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mattijs Korpershoek @ 2021-05-06  9:41 UTC (permalink / raw)
  To: Lee Jones, Matthias Brugger
  Cc: Fabien Parent, linux-arm-kernel, linux-mediatek, linux-kernel,
	Mattijs Korpershoek

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/20210429143811.2030717-1-mkorpershoek@baylibre.com/

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key
  2021-05-06  9:41 [PATCH 0/3] MT6358 PMIC button support Mattijs Korpershoek
@ 2021-05-06  9:41 ` Mattijs Korpershoek
  2021-05-19 10:53   ` Lee Jones
  2021-05-06  9:41 ` [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index Mattijs Korpershoek
  2021-05-06  9:41 ` [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358 Mattijs Korpershoek
  2 siblings, 1 reply; 7+ messages in thread
From: Mattijs Korpershoek @ 2021-05-06  9:41 UTC (permalink / raw)
  To: Lee Jones, Matthias Brugger
  Cc: Fabien Parent, linux-arm-kernel, linux-mediatek, linux-kernel,
	Mattijs Korpershoek

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 <mkorpershoek@baylibre.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index
  2021-05-06  9:41 [PATCH 0/3] MT6358 PMIC button support Mattijs Korpershoek
  2021-05-06  9:41 ` [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key Mattijs Korpershoek
@ 2021-05-06  9:41 ` Mattijs Korpershoek
  2021-05-19 10:55   ` Lee Jones
  2021-05-06  9:41 ` [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358 Mattijs Korpershoek
  2 siblings, 1 reply; 7+ messages in thread
From: Mattijs Korpershoek @ 2021-05-06  9:41 UTC (permalink / raw)
  To: Lee Jones, Matthias Brugger
  Cc: Fabien Parent, linux-arm-kernel, linux-mediatek, linux-kernel,
	Mattijs Korpershoek

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 <mkorpershoek@baylibre.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358
  2021-05-06  9:41 [PATCH 0/3] MT6358 PMIC button support Mattijs Korpershoek
  2021-05-06  9:41 ` [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key Mattijs Korpershoek
  2021-05-06  9:41 ` [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index Mattijs Korpershoek
@ 2021-05-06  9:41 ` Mattijs Korpershoek
  2021-05-19 11:03   ` Lee Jones
  2 siblings, 1 reply; 7+ messages in thread
From: Mattijs Korpershoek @ 2021-05-06  9:41 UTC (permalink / raw)
  To: Lee Jones, Matthias Brugger
  Cc: Fabien Parent, linux-arm-kernel, linux-mediatek, linux-kernel,
	Mattijs Korpershoek

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 <mkorpershoek@baylibre.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key
  2021-05-06  9:41 ` [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key Mattijs Korpershoek
@ 2021-05-19 10:53   ` Lee Jones
  0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2021-05-19 10:53 UTC (permalink / raw)
  To: Mattijs Korpershoek
  Cc: Matthias Brugger, Fabien Parent, linux-arm-kernel,
	linux-mediatek, linux-kernel

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 <mkorpershoek@baylibre.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index
  2021-05-06  9:41 ` [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index Mattijs Korpershoek
@ 2021-05-19 10:55   ` Lee Jones
  0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2021-05-19 10:55 UTC (permalink / raw)
  To: Mattijs Korpershoek
  Cc: Matthias Brugger, Fabien Parent, linux-arm-kernel,
	linux-mediatek, linux-kernel

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 <mkorpershoek@baylibre.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358
  2021-05-06  9:41 ` [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358 Mattijs Korpershoek
@ 2021-05-19 11:03   ` Lee Jones
  0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2021-05-19 11:03 UTC (permalink / raw)
  To: Mattijs Korpershoek
  Cc: Matthias Brugger, Fabien Parent, linux-arm-kernel,
	linux-mediatek, linux-kernel

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 <mkorpershoek@baylibre.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-19 11:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  9:41 [PATCH 0/3] MT6358 PMIC button support Mattijs Korpershoek
2021-05-06  9:41 ` [PATCH 1/3] mfd: mt6397: add mt6358 register definitions for power key Mattijs Korpershoek
2021-05-19 10:53   ` Lee Jones
2021-05-06  9:41 ` [PATCH 2/3] mfd: mt6397: keys: use named IRQs instead of index Mattijs Korpershoek
2021-05-19 10:55   ` Lee Jones
2021-05-06  9:41 ` [PATCH 3/3] mfd: mt6397: add PMIC keys for MT6358 Mattijs Korpershoek
2021-05-19 11:03   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).