* [PATCH v3 0/4] input: MT6358 PMIC button support
@ 2021-07-02 13:43 Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 1/4] Input: mtk-pmic-keys - use get_irq_byname() instead of index Mattijs Korpershoek
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2021-07-02 13:43 UTC (permalink / raw
To: Dmitry Torokhov, Matthias Brugger, Rob Herring
Cc: Fabien Parent, linux-input, devicetree, 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.
Changes since original v2 at [1]:
* added 4th patch with device tree enable
* cover letter title prefixed with 'input'
This series depends on [2]
[1] https://lore.kernel.org/r/20210512152648.39961-1-mkorpershoek@baylibre.com
[2] https://lore.kernel.org/r/20210506094116.638527-1-mkorpershoek@baylibre.com
This has been tested with evtest on mt8183-pumpkin
using for-mfd-next as base tree.
Mattijs Korpershoek (4):
Input: mtk-pmic-keys - use get_irq_byname() instead of index
dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition
Input: mtk-pmic-keys - add support for MT6358
arm64: dts: mt6358: add mt6358-keys node
.../bindings/input/mtk-pmic-keys.txt | 5 +-
arch/arm64/boot/dts/mediatek/mt6358.dtsi | 12 ++++
drivers/input/keyboard/mtk-pmic-keys.c | 56 +++++++++++++++++--
3 files changed, 68 insertions(+), 5 deletions(-)
base-commit: 495fb48dbd9bcbe15859e086edd24519a6bd2961
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/4] Input: mtk-pmic-keys - use get_irq_byname() instead of index
2021-07-02 13:43 [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
@ 2021-07-02 13:43 ` Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 2/4] dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition Mattijs Korpershoek
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2021-07-02 13:43 UTC (permalink / raw
To: Dmitry Torokhov, Matthias Brugger, Rob Herring
Cc: Fabien Parent, linux-input, devicetree, 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.
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
drivers/input/keyboard/mtk-pmic-keys.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index 62391d6c7da6..d1abf95d5701 100644
--- a/drivers/input/keyboard/mtk-pmic-keys.c
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -241,6 +241,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
unsigned int keycount;
struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent);
struct device_node *node = pdev->dev.of_node, *child;
+ static const char *const irqnames[] = { "powerkey", "homekey" };
struct mtk_pmic_keys *keys;
const struct mtk_pmic_regs *mtk_pmic_regs;
struct input_dev *input_dev;
@@ -268,7 +269,8 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
input_dev->id.version = 0x0001;
keycount = of_get_available_child_count(node);
- if (keycount > MTK_PMIC_MAX_KEY_COUNT) {
+ if (keycount > MTK_PMIC_MAX_KEY_COUNT ||
+ keycount > ARRAY_SIZE(irqnames)) {
dev_err(keys->dev, "too many keys defined (%d)\n", keycount);
return -EINVAL;
}
@@ -276,7 +278,8 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
for_each_child_of_node(node, child) {
keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index];
- keys->keys[index].irq = platform_get_irq(pdev, index);
+ keys->keys[index].irq =
+ platform_get_irq_byname(pdev, irqnames[index]);
if (keys->keys[index].irq < 0) {
of_node_put(child);
return keys->keys[index].irq;
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/4] dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition
2021-07-02 13:43 [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 1/4] Input: mtk-pmic-keys - use get_irq_byname() instead of index Mattijs Korpershoek
@ 2021-07-02 13:43 ` Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 3/4] Input: mtk-pmic-keys - add support for MT6358 Mattijs Korpershoek
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2021-07-02 13:43 UTC (permalink / raw
To: Dmitry Torokhov, Matthias Brugger, Rob Herring
Cc: Fabien Parent, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, Mattijs Korpershoek, Rob Herring
Add the binding documentation of the mtk-pmic-keys for the MT6358 PMICs.
MT6358 is a little different since it used separate IRQs for the
release key (_r) event
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Acked-by: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/input/mtk-pmic-keys.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
index 535d92885372..9d00f2a8e13a 100644
--- a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
+++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
@@ -9,7 +9,10 @@ For MT6397/MT6323 MFD bindings see:
Documentation/devicetree/bindings/mfd/mt6397.txt
Required properties:
-- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
+- compatible: Should be one of:
+ - "mediatek,mt6397-keys"
+ - "mediatek,mt6323-keys"
+ - "mediatek,mt6358-keys"
- linux,keycodes: See Documentation/devicetree/bindings/input/input.yaml
Optional Properties:
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/4] Input: mtk-pmic-keys - add support for MT6358
2021-07-02 13:43 [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 1/4] Input: mtk-pmic-keys - use get_irq_byname() instead of index Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 2/4] dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition Mattijs Korpershoek
@ 2021-07-02 13:43 ` Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 4/4] arm64: dts: mt6358: add mt6358-keys node Mattijs Korpershoek
2021-07-23 13:23 ` [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
4 siblings, 0 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2021-07-02 13:43 UTC (permalink / raw
To: Dmitry Torokhov, Matthias Brugger, Rob Herring
Cc: Fabien Parent, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, Mattijs Korpershoek
MT6358 pmic keys behave differently than mt6397 and mt6323: there are
two interrupts per key: one for press, the other one for release (_r)
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
drivers/input/keyboard/mtk-pmic-keys.c | 49 ++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index d1abf95d5701..5496a7020104 100644
--- a/drivers/input/keyboard/mtk-pmic-keys.c
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -9,6 +9,7 @@
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/mfd/mt6323/registers.h>
+#include <linux/mfd/mt6358/registers.h>
#include <linux/mfd/mt6397/core.h>
#include <linux/mfd/mt6397/registers.h>
#include <linux/module.h>
@@ -74,11 +75,22 @@ static const struct mtk_pmic_regs mt6323_regs = {
.pmic_rst_reg = MT6323_TOP_RST_MISC,
};
+static const struct mtk_pmic_regs mt6358_regs = {
+ .keys_regs[MTK_PMIC_PWRKEY_INDEX] =
+ MTK_PMIC_KEYS_REGS(MT6358_TOPSTATUS,
+ 0x2, MT6358_PSC_TOP_INT_CON0, 0x5),
+ .keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
+ MTK_PMIC_KEYS_REGS(MT6358_TOPSTATUS,
+ 0x8, MT6358_PSC_TOP_INT_CON0, 0xa),
+ .pmic_rst_reg = MT6358_TOP_RST_MISC,
+};
+
struct mtk_pmic_keys_info {
struct mtk_pmic_keys *keys;
const struct mtk_pmic_keys_regs *regs;
unsigned int keycode;
int irq;
+ int irq_r; /* optional: release irq if different */
bool wakeup:1;
};
@@ -188,6 +200,19 @@ static int mtk_pmic_key_setup(struct mtk_pmic_keys *keys,
return ret;
}
+ if (info->irq_r > 0) {
+ ret = devm_request_threaded_irq(
+ keys->dev, info->irq_r, NULL,
+ mtk_pmic_keys_irq_handler_thread,
+ IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mtk-pmic-keys",
+ info);
+ if (ret) {
+ dev_err(keys->dev, "Failed to request IRQ_r: %d: %d\n",
+ info->irq, ret);
+ return ret;
+ }
+ }
+
input_set_capability(keys->input_dev, EV_KEY, info->keycode);
return 0;
@@ -199,8 +224,11 @@ static int __maybe_unused mtk_pmic_keys_suspend(struct device *dev)
int index;
for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) {
- if (keys->keys[index].wakeup)
+ if (keys->keys[index].wakeup) {
enable_irq_wake(keys->keys[index].irq);
+ if (keys->keys[index].irq_r > 0)
+ enable_irq_wake(keys->keys[index].irq_r);
+ }
}
return 0;
@@ -212,8 +240,11 @@ static int __maybe_unused mtk_pmic_keys_resume(struct device *dev)
int index;
for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) {
- if (keys->keys[index].wakeup)
+ if (keys->keys[index].wakeup) {
disable_irq_wake(keys->keys[index].irq);
+ if (keys->keys[index].irq_r > 0)
+ disable_irq_wake(keys->keys[index].irq_r);
+ }
}
return 0;
@@ -229,6 +260,9 @@ static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = {
}, {
.compatible = "mediatek,mt6323-keys",
.data = &mt6323_regs,
+ }, {
+ .compatible = "mediatek,mt6358-keys",
+ .data = &mt6358_regs,
}, {
/* sentinel */
}
@@ -242,6 +276,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent);
struct device_node *node = pdev->dev.of_node, *child;
static const char *const irqnames[] = { "powerkey", "homekey" };
+ static const char *const irqnames_r[] = { "powerkey_r", "homekey_r" };
struct mtk_pmic_keys *keys;
const struct mtk_pmic_regs *mtk_pmic_regs;
struct input_dev *input_dev;
@@ -285,6 +320,16 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
return keys->keys[index].irq;
}
+ if (of_device_is_compatible(node, "mediatek,mt6358-keys")) {
+ keys->keys[index].irq_r = platform_get_irq_byname(
+ pdev, irqnames_r[index]);
+
+ if (keys->keys[index].irq_r < 0) {
+ of_node_put(child);
+ return keys->keys[index].irq_r;
+ }
+ }
+
error = of_property_read_u32(child,
"linux,keycodes", &keys->keys[index].keycode);
if (error) {
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 4/4] arm64: dts: mt6358: add mt6358-keys node
2021-07-02 13:43 [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
` (2 preceding siblings ...)
2021-07-02 13:43 ` [PATCH v3 3/4] Input: mtk-pmic-keys - add support for MT6358 Mattijs Korpershoek
@ 2021-07-02 13:43 ` Mattijs Korpershoek
2021-07-23 13:23 ` [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
4 siblings, 0 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2021-07-02 13:43 UTC (permalink / raw
To: Dmitry Torokhov, Matthias Brugger, Rob Herring
Cc: Fabien Parent, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, Mattijs Korpershoek
This enables the power,home keys on MediaTek boards with a mt6358 pmic.
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
arch/arm64/boot/dts/mediatek/mt6358.dtsi | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt6358.dtsi b/arch/arm64/boot/dts/mediatek/mt6358.dtsi
index fa159b20379e..a1b017a6a751 100644
--- a/arch/arm64/boot/dts/mediatek/mt6358.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt6358.dtsi
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2020 MediaTek Inc.
*/
+#include <dt-bindings/input/input.h>
&pwrap {
pmic: mt6358 {
@@ -356,5 +357,16 @@ mt6358_vsim2_reg: ldo_vsim2 {
mt6358rtc: mt6358rtc {
compatible = "mediatek,mt6358-rtc";
};
+
+ mt6358keys: mt6358keys {
+ compatible = "mediatek,mt6358-keys";
+ power {
+ linux,keycodes = <KEY_POWER>;
+ wakeup-source;
+ };
+ home {
+ linux,keycodes = <KEY_HOME>;
+ };
+ };
};
};
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/4] input: MT6358 PMIC button support
2021-07-02 13:43 [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
` (3 preceding siblings ...)
2021-07-02 13:43 ` [PATCH v3 4/4] arm64: dts: mt6358: add mt6358-keys node Mattijs Korpershoek
@ 2021-07-23 13:23 ` Mattijs Korpershoek
4 siblings, 0 replies; 6+ messages in thread
From: Mattijs Korpershoek @ 2021-07-23 13:23 UTC (permalink / raw
To: Dmitry Torokhov, Matthias Brugger, Rob Herring
Cc: Fabien Parent, Kevin Hilman, linux-input, devicetree,
linux-arm-kernel, linux-mediatek, linux-kernel
Dear maintainers,
Gentle ping for this series
Mattijs Korpershoek <mkorpershoek@baylibre.com> writes:
> 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.
>
> Changes since original v2 at [1]:
> * added 4th patch with device tree enable
> * cover letter title prefixed with 'input'
>
> This series depends on [2]
>
> [1] https://lore.kernel.org/r/20210512152648.39961-1-mkorpershoek@baylibre.com
> [2] https://lore.kernel.org/r/20210506094116.638527-1-mkorpershoek@baylibre.com
The MFD dependency has been merged in linux-next.
>
> This has been tested with evtest on mt8183-pumpkin
> using for-mfd-next as base tree.
>
> Mattijs Korpershoek (4):
> Input: mtk-pmic-keys - use get_irq_byname() instead of index
> dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition
> Input: mtk-pmic-keys - add support for MT6358
> arm64: dts: mt6358: add mt6358-keys node
>
> .../bindings/input/mtk-pmic-keys.txt | 5 +-
> arch/arm64/boot/dts/mediatek/mt6358.dtsi | 12 ++++
> drivers/input/keyboard/mtk-pmic-keys.c | 56 +++++++++++++++++--
> 3 files changed, 68 insertions(+), 5 deletions(-)
>
>
> base-commit: 495fb48dbd9bcbe15859e086edd24519a6bd2961
> --
> 2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-07-23 13:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-02 13:43 [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 1/4] Input: mtk-pmic-keys - use get_irq_byname() instead of index Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 2/4] dt-bindings: input: mtk-pmic-keys: add MT6358 binding definition Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 3/4] Input: mtk-pmic-keys - add support for MT6358 Mattijs Korpershoek
2021-07-02 13:43 ` [PATCH v3 4/4] arm64: dts: mt6358: add mt6358-keys node Mattijs Korpershoek
2021-07-23 13:23 ` [PATCH v3 0/4] input: MT6358 PMIC button support Mattijs Korpershoek
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 read-only IMAP folder(s) and NNTP newsgroup(s).