Input: mtk-pmic-keys: Add support for MT6359 PMIC
Subsystems (5)
cover Input: mtk-pmic-keys: Add support for MT6359 PMIC
This patch serie adds support for the MT6359 PMIC keyboard driver.
The last commit has a dependency on:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
Fabien Parent (7):
dt-bindings: input: mtk-pmic-keys: add MT6359 binding definition
mfd: add missing defines necessary for mtk-pmic-keys support
mfd: mt6397-core: add resources for PMIC keys for MT6359
Input: mtk-pmic-keys: rename platform data struct
Input: mtk-pmic-keys: add field to store if PMIC has key release IRQs
Input: keyboard: mtk-pmic-keys: add support for MT6359
arm64: dts: mediatek: mt6359: add node for PMIC keys support
.../bindings/input/mtk-pmic-keys.txt | 1 + arch/arm64/boot/dts/mediatek/mt6359.dtsi | 15 +++++++ drivers/input/keyboard/mtk-pmic-keys.c | 41 +++++++++++++------ drivers/mfd/mt6397-core.c | 13 ++++++ include/linux/mfd/mt6359/registers.h | 2 + 5 files changed, 60 insertions(+), 12 deletions(-)
Signature · 7 lines
2.35.2 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 1/7 dt-bindings: input: mtk-pmic-keys: add MT6359 binding definition
Add binding definition for the support of the MT6359 keyboard driver.
--- Documentation/devicetree/bindings/input/mtk-pmic-keys.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/input/mtk-pmic-keys.txt +1 -0
@@ -13,6 +13,7 @@ Required properties: - "mediatek,mt6397-keys" - "mediatek,mt6323-keys" - "mediatek,mt6358-keys" + - "mediatek,mt6359-keys" - linux,keycodes: See Documentation/devicetree/bindings/input/input.yaml Optional Properties:
Signature · 1 line
2.35.2
PATCH 2/7 mfd: add missing defines necessary for mtk-pmic-keys support
In reply to Fabien ParentAdd 2 missing MT6359 registers that are needed to implement the keyboard driver.
--- include/linux/mfd/mt6359/registers.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/mfd/mt6359/registers.h +2 -0
@@ -8,6 +8,8 @@/* PMIC Registers */ #define MT6359_SWCID 0xa +#define MT6359_TOPSTATUS 0x2a +#define MT6359_TOP_RST_MISC 0x14c#define MT6359_MISC_TOP_INT_CON0 0x188#define MT6359_MISC_TOP_INT_STATUS0 0x194#define MT6359_TOP_INT_STATUS0 0x19e
Signature · 1 line
2.35.2
Re: [PATCH 2/7] mfd: add missing defines necessary for mtk-pmic-keys support
Quoted 7 lines · Fabien Parent
Add 2 missing MT6359 registers that are needed to implement the keyboard driver.
Signed-off-by Fabien Parent <[email protected]>--- include/linux/mfd/mt6359/registers.h | 2 ++ 1 file changed, 2 insertions(+)
I fixed the subject line for you and applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 3/7 mfd: mt6397-core: add resources for PMIC keys for MT6359
In reply to Fabien ParentAdd the MFD resources in order to be able to probe and use the keyboard driver for the MT6359 PMIC.
--- drivers/mfd/mt6397-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/mfd/mt6397-core.c +13 -0
@@ -54,6 +54,13 @@ static const struct resource mt6358_keys_resources[] = { DEFINE_RES_IRQ_NAMED(MT6358_IRQ_HOMEKEY_R, "homekey_r"), }; +static const struct resource mt6359_keys_resources[] = { +DEFINE_RES_IRQ_NAMED (MT6359_IRQ_PWRKEY ,"powerkey" ), +DEFINE_RES_IRQ_NAMED (MT6359_IRQ_HOMEKEY ,"homekey" ), +DEFINE_RES_IRQ_NAMED (MT6359_IRQ_PWRKEY_R ,"powerkey_r" ), +DEFINE_RES_IRQ_NAMED (MT6359_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" ),
@@ -122,6 +129,12 @@ static const struct mfd_cell mt6359_devs[] = { .of_compatible = "mediatek,mt6358-rtc", }, { .name = "mt6359-sound", }, + { + .name = "mtk-pmic-keys", + .num_resources = ARRAY_SIZE(mt6359_keys_resources), + .resources = mt6359_keys_resources, + .of_compatible = "mediatek,mt6359-keys" + }, }; static const struct mfd_cell mt6397_devs[] = {
Signature · 1 line
2.35.2
Lee Jones
AppliedRe: [PATCH 3/7] mfd: mt6397-core: add resources for PMIC keys for MT6359
Quoted 7 lines · Fabien Parent
Add the MFD resources in order to be able to probe and use the keyboard driver for the MT6359 PMIC.
Signed-off-by Fabien Parent <[email protected]>--- drivers/mfd/mt6397-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 4/7 Input: mtk-pmic-keys: rename platform data struct
In reply to Fabien ParentRename the struct that is given to the .data field of the of_device_id entries to reflect that this structure will not only contain register definitions but also other platform data.
--- drivers/input/keyboard/mtk-pmic-keys.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/input/keyboard/mtk-pmic-keys.c +11 -11
@@ -50,12 +50,12 @@ struct mtk_pmic_keys_regs { .intsel_mask = _intsel_mask, \ } -struct mtk_pmic_regs { +struct mtk_pmic_keys_pdata {const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT ];u32 pmic_rst_reg; }; -static const struct mtk_pmic_regs mt6397_regs = { +static const struct mtk_pmic_keys_pdata mt6397_pdata = { .keys_regs[MTK_PMIC_PWRKEY_INDEX ] =MTK_PMIC_KEYS_REGS (MT6397_CHRSTATUS ,0x8 ,MT6397_INT_RSV ,0x10 ),
@@ -65,7 +65,7 @@ static const struct mtk_pmic_regs mt6397_regs = { .pmic_rst_reg = MT6397_TOP_RST_MISC, }; -static const struct mtk_pmic_regs mt6323_regs = { +static const struct mtk_pmic_keys_pdata mt6323_pdata = { .keys_regs[MTK_PMIC_PWRKEY_INDEX ] =MTK_PMIC_KEYS_REGS (MT6323_CHRSTATUS ,0x2 ,MT6323_INT_MISC_CON ,0x10 ),
@@ -75,7 +75,7 @@ static const struct mtk_pmic_regs mt6323_regs = { .pmic_rst_reg = MT6323_TOP_RST_MISC, }; -static const struct mtk_pmic_regs mt6358_regs = { +static const struct mtk_pmic_keys_pdata mt6358_pdata = { .keys_regs[MTK_PMIC_PWRKEY_INDEX ] =MTK_PMIC_KEYS_REGS (MT6358_TOPSTATUS ,0x2 ,MT6358_PSC_TOP_INT_CON0 ,0x5 ),
@@ -255,13 +255,13 @@ static SIMPLE_DEV_PM_OPS(mtk_pmic_keys_pm_ops, mtk_pmic_keys_suspend,static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = { { .compatible ="mediatek,mt6397-keys" , - .data = &mt6397_regs, + .data = &mt6397_pdata, }, { .compatible ="mediatek,mt6323-keys" , - .data = &mt6323_regs, + .data = &mt6323_pdata, }, { .compatible ="mediatek,mt6358-keys" , - .data = &mt6358_regs, + .data = &mt6358_pdata, }, {/* sentinel */ }
@@ -277,7 +277,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)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; +const struct mtk_pmic_keys_pdata *mtk_pmic_keys_pdata;struct input_dev *input_dev;const struct of_device_id *of_id =of_match_device (of_mtk_pmic_keys_match_tbl, &pdev->dev);
@@ -288,7 +288,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) keys->dev = &pdev->dev; keys->regmap = pmic_chip->regmap; - mtk_pmic_regs = of_id->data; + mtk_pmic_keys_pdata = of_id->data; keys->input_dev = input_dev =devm_input_allocate_device (keys->dev);if (!input_dev) {
@@ -310,7 +310,7 @@ 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].regs = &mtk_pmic_keys_pdata->keys_regs[index]; keys->keys[index].irq =platform_get_irq_byname (pdev, irqnames[index]);
@@ -358,7 +358,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)return error; } -mtk_pmic_keys_lp_reset_setup (keys, mtk_pmic_regs->pmic_rst_reg); +mtk_pmic_keys_lp_reset_setup (keys, mtk_pmic_keys_pdata->pmic_rst_reg);platform_set_drvdata (pdev, keys);
Signature · 1 line
2.35.2
Re: [PATCH 4/7] Input: mtk-pmic-keys: rename platform data struct
Quoted 5 lines · Fabien Parent
Rename the struct that is given to the .data field of the
of_device_identries to reflect that this structure will not only contain register definitions but also other platform data.Signed-off-by Fabien Parent <[email protected]>
Quoted 96 lines
--- drivers/input/keyboard/mtk-pmic-keys.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)drivers/input/keyboard/mtk-pmic-keys.c +11
-11@@ -50,12 +50,12 @@ struct mtk_pmic_keys_regs { .intsel_mask = _intsel_mask, \ } -struct mtk_pmic_regs { +struct mtk_pmic_keys_pdata {const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT ];u32 pmic_rst_reg; }; -static const struct mtk_pmic_regs mt6397_regs = { +static const struct mtk_pmic_keys_pdata mt6397_pdata = { .keys_regs[MTK_PMIC_PWRKEY_INDEX ] =MTK_PMIC_KEYS_REGS (MT6397_CHRSTATUS ,0x8 ,MT6397_INT_RSV ,0x10 ),@@ -65,7 +65,7 @@ static const struct mtk_pmic_regs mt6397_regs = { .pmic_rst_reg = MT6397_TOP_RST_MISC, }; -static const struct mtk_pmic_regs mt6323_regs = { +static const struct mtk_pmic_keys_pdata mt6323_pdata = { .keys_regs[MTK_PMIC_PWRKEY_INDEX ] =MTK_PMIC_KEYS_REGS (MT6323_CHRSTATUS ,0x2 ,MT6323_INT_MISC_CON ,0x10 ),@@ -75,7 +75,7 @@ static const struct mtk_pmic_regs mt6323_regs = { .pmic_rst_reg = MT6323_TOP_RST_MISC, }; -static const struct mtk_pmic_regs mt6358_regs = { +static const struct mtk_pmic_keys_pdata mt6358_pdata = { .keys_regs[MTK_PMIC_PWRKEY_INDEX ] =MTK_PMIC_KEYS_REGS (MT6358_TOPSTATUS ,0x2 ,MT6358_PSC_TOP_INT_CON0 ,0x5 ),@@ -255,13 +255,13 @@ static SIMPLE_DEV_PM_OPS(mtk_pmic_keys_pm_ops, mtk_pmic_keys_suspend,static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = { { .compatible ="mediatek,mt6397-keys" , - .data = &mt6397_regs, + .data = &mt6397_pdata, }, { .compatible ="mediatek,mt6323-keys" , - .data = &mt6323_regs, + .data = &mt6323_pdata, }, { .compatible ="mediatek,mt6358-keys" , - .data = &mt6358_regs, + .data = &mt6358_pdata, }, {/* sentinel */ }@@ -277,7 +277,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)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; +const struct mtk_pmic_keys_pdata *mtk_pmic_keys_pdata;struct input_dev *input_dev;const struct of_device_id *of_id =of_match_device (of_mtk_pmic_keys_match_tbl, &pdev->dev);@@ -288,7 +288,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) keys->dev = &pdev->dev; keys->regmap = pmic_chip->regmap; - mtk_pmic_regs = of_id->data; + mtk_pmic_keys_pdata = of_id->data; keys->input_dev = input_dev =devm_input_allocate_device (keys->dev);if (!input_dev) {@@ -310,7 +310,7 @@ 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].regs = &mtk_pmic_keys_pdata->keys_regs[index]; keys->keys[index].irq =platform_get_irq_byname (pdev, irqnames[index]);@@ -358,7 +358,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)return error; } -mtk_pmic_keys_lp_reset_setup (keys, mtk_pmic_regs->pmic_rst_reg); +mtk_pmic_keys_lp_reset_setup (keys, mtk_pmic_keys_pdata->pmic_rst_reg);platform_set_drvdata (pdev, keys);Signature · 1 line
2.35.2
PATCH 5/7 Input: mtk-pmic-keys: add field to store if PMIC has key release IRQs
In reply to Fabien ParentThe MT6358 PMIC is not the only PMIC to have release IRQs. In order to support more PMIC that supports release IRQs, such as MT6357, MT6359, and possibly others, let's add some field in the platform data to indicate whether a PMIC support release keys.
--- drivers/input/keyboard/mtk-pmic-keys.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/keyboard/mtk-pmic-keys.c +3 -1
@@ -53,6 +53,7 @@ struct mtk_pmic_keys_regs {struct mtk_pmic_keys_pdata {const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT ];u32 pmic_rst_reg; +bool has_key_release_irqs; };static const struct mtk_pmic_keys_pdata mt6397_pdata = {
@@ -83,6 +84,7 @@ static const struct mtk_pmic_keys_pdata mt6358_pdata = {MTK_PMIC_KEYS_REGS (MT6358_TOPSTATUS , 0x8, MT6358_PSC_TOP_INT_CON0, 0xa), .pmic_rst_reg = MT6358_TOP_RST_MISC, + .has_key_release_irqs = true, };struct mtk_pmic_keys_info {
@@ -319,7 +321,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)return keys->keys[index].irq; } -if (of_device_is_compatible (node,"mediatek,mt6358-keys" )) { +if (mtk_pmic_keys_pdata->has_key_release_irqs) { keys->keys[index].irq_r =platform_get_irq_byname (pdev, irqnames_r[index]);
Signature · 1 line
2.35.2
Re: [PATCH 5/7] Input: mtk-pmic-keys: add field to store if PMIC has key release IRQs
Quoted 6 lines · Fabien Parent
The MT6358 PMIC is not the only PMIC to have release IRQs. In order to support more PMIC that supports release IRQs, such as MT6357, MT6359, and possibly others, let's add some field in the platform data to indicate whether a PMIC support release keys.
Signed-off-by Fabien Parent <[email protected]>
Quoted 35 lines
--- drivers/input/keyboard/mtk-pmic-keys.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/input/keyboard/mtk-pmic-keys.c +3
-1@@ -53,6 +53,7 @@ struct mtk_pmic_keys_regs {struct mtk_pmic_keys_pdata {const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT ];u32 pmic_rst_reg; +bool has_key_release_irqs; };static const struct mtk_pmic_keys_pdata mt6397_pdata = {@@ -83,6 +84,7 @@ static const struct mtk_pmic_keys_pdata mt6358_pdata = {MTK_PMIC_KEYS_REGS (MT6358_TOPSTATUS , 0x8, MT6358_PSC_TOP_INT_CON0, 0xa), .pmic_rst_reg = MT6358_TOP_RST_MISC, + .has_key_release_irqs = true, };struct mtk_pmic_keys_info {@@ -319,7 +321,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)return keys->keys[index].irq; } -if (of_device_is_compatible (node,"mediatek,mt6358-keys" )) { +if (mtk_pmic_keys_pdata->has_key_release_irqs) { keys->keys[index].irq_r =platform_get_irq_byname (pdev, irqnames_r[index]);Signature · 1 line
2.35.2
PATCH 6/7 Input: keyboard: mtk-pmic-keys: add support for MT6359
In reply to Fabien ParentAdd support for the MT6359 PMIC.
--- drivers/input/keyboard/mtk-pmic-keys.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/input/keyboard/mtk-pmic-keys.c +15 -0
@@ -10,6 +10,7 @@#include <linux/kernel.h> #include <linux/mfd/mt6323/registers.h> #include <linux/mfd/mt6358/registers.h> +#include <linux/mfd/mt6359/registers.h> #include <linux/mfd/mt6397/core.h> #include <linux/mfd/mt6397/registers.h> #include <linux/module.h>
@@ -87,6 +88,17 @@ static const struct mtk_pmic_keys_pdata mt6358_pdata = { .has_key_release_irqs = true, }; +static const struct mtk_pmic_keys_pdata mt6359_pdata = { + .keys_regs[MTK_PMIC_PWRKEY_INDEX ] = +MTK_PMIC_KEYS_REGS (MT6359_TOPSTATUS , +0x2 ,MT6359_PSC_TOP_INT_CON0 ,0x5 ), + .keys_regs[MTK_PMIC_HOMEKEY_INDEX ] = +MTK_PMIC_KEYS_REGS (MT6359_TOPSTATUS , +0x8 ,MT6359_PSC_TOP_INT_CON0 ,0xa ), + .pmic_rst_reg =MT6359_TOP_RST_MISC , + .has_key_release_irqs = true, +}; +struct mtk_pmic_keys_info {struct mtk_pmic_keys *keys;const struct mtk_pmic_keys_regs *regs;
@@ -264,6 +276,9 @@ static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = { }, { .compatible = "mediatek,mt6358-keys", .data = &mt6358_pdata, + }, { + .compatible = "mediatek,mt6359-keys", + .data = &mt6359_pdata, }, { /* sentinel */ }
Signature · 1 line
2.35.2
PATCH 7/7 arm64: dts: mediatek: mt6359: add node for PMIC keys support
In reply to Fabien ParentAdd node for the MT6359 PMIC keyboard in mt6359.dtsi.
---
Dependency on:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
arch/arm64/boot/dts/mediatek/mt6359.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/mediatek/mt6359.dtsi +15 -0
@@ -3,6 +3,8 @@ * Copyright (c) 2021 MediaTek Inc. */ +#include <dt-bindings/input/input.h> + &pwrap { pmic: pmic { compatible = "mediatek,mt6359";
@@ -294,5 +296,18 @@ mt6359_vsram_others_sshub_ldo: ldo_vsram_others_sshub { mt6359rtc: mt6359rtc { compatible = "mediatek,mt6358-rtc"; }; + + mt6359keys: keyboard { + compatible = "mediatek,mt6359-keys"; + + key-0 { + linux,keycodes = <KEY_POWER>; + wakeup-source; + }; + + key-1 { + linux,keycodes = <KEY_HOME>; + }; + }; }; };
Signature · 1 line
2.35.2
AngeloGioacchino Del Regno
maintainerRe: [PATCH 7/7] arm64: dts: mediatek: mt6359: add node for PMIC keys support
Il 15/04/22 17:36, Fabien Parent ha scritto:
Quoted 3 lines
Add node for the MT6359 PMIC keyboard in
mt6359.dtsi.Signed-off-by Fabien Parent <[email protected]>
Hello Fabien,
I agree that all MT6359 PMICs do support pmic-keys, but not all devices using this PMIC have physical keys connected to that.
Besides, even if all of them did, it wouldn't be guaranteed that key-0 would be always KEY_POWER, as much as it wouldn't be guaranteed that key-1 would be always KEY_HOME.
In my opinion, it *is* correct to add mediatek,mt6359-keys to the PMIC dtsi, but you should do that without declaring any key, hence it's enough to do:
mt6359_keys: mtk-pmic-keys {
compatible = "mediatek,mt6359-keys";
};... then, any machine that *actually does* have these keys connected and manageable in Linux should declare its own keys in its own dts/dtsi.
Of course, this means that you'll have to remove your input.h inclusion as well.
Regards,
Angelo