From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
dmitry.torokhov@gmail.com
Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
linux-input@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] Input: mtk-pmic-keys - Move long press debounce mask to mtk_pmic_regs
Date: Tue, 24 May 2022 14:05:14 +0200 [thread overview]
Message-ID: <87k0abdtl1.fsf@baylibre.com> (raw)
In-Reply-To: <20220524093505.85438-3-angelogioacchino.delregno@collabora.com>
On mar., mai 24, 2022 at 11:35, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
> As the second and last step of preparation to add support for more
> PMICs in this driver, move the long press debounce mask to struct
> mtk_pmic_regs and use that in mtk_pmic_keys_lp_reset_setup() instead
> of directly using the definition.
>
> While at it, remove the definition for MTK_PMIC_RST_DU_SHIFT as we
> are able to calculate it dynamically and spares us some unnecessary
> new definitions around for future per-PMIC variations of RST_DU_MASK.
>
> Lastly, it was necessary to change the function signature of
> mtk_pmic_keys_lp_reset_setup() to now pass a pointer to the main
> mtk_pmic_regs structure, since that's where the reset debounce
> mask now resides.
>
> This commit brings no functional changes.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> drivers/input/keyboard/mtk-pmic-keys.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index 2509a349a173..6404081253ea 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -19,7 +19,6 @@
> #include <linux/regmap.h>
>
> #define MTK_PMIC_RST_DU_MASK GENMASK(9, 8)
> -#define MTK_PMIC_RST_DU_SHIFT 8
> #define MTK_PMIC_PWRKEY_RST BIT(6)
> #define MTK_PMIC_HOMEKEY_RST BIT(5)
>
> @@ -48,6 +47,7 @@ struct mtk_pmic_keys_regs {
> struct mtk_pmic_regs {
> const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT];
> u32 pmic_rst_reg;
> + u32 rst_lprst_mask; /* Long-press reset timeout bitmask */
> };
>
> static const struct mtk_pmic_regs mt6397_regs = {
> @@ -58,6 +58,7 @@ static const struct mtk_pmic_regs mt6397_regs = {
> MTK_PMIC_KEYS_REGS(MT6397_OCSTATUS2,
> 0x10, MT6397_INT_RSV, 0x8, MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6397_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> static const struct mtk_pmic_regs mt6323_regs = {
> @@ -68,6 +69,7 @@ static const struct mtk_pmic_regs mt6323_regs = {
> MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
> 0x4, MT6323_INT_MISC_CON, 0x8, MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6323_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> static const struct mtk_pmic_regs mt6358_regs = {
> @@ -80,6 +82,7 @@ static const struct mtk_pmic_regs mt6358_regs = {
> 0x8, MT6358_PSC_TOP_INT_CON0, 0xa,
> MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6358_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> struct mtk_pmic_keys_info {
> @@ -105,7 +108,7 @@ enum mtk_pmic_keys_lp_mode {
> };
>
> static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> - u32 pmic_rst_reg)
> + const struct mtk_pmic_regs *regs)
> {
> const struct mtk_pmic_keys_regs *kregs_home, *kregs_pwr;
> u32 long_press_mode, long_press_debounce;
> @@ -120,8 +123,8 @@ static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> if (error)
> long_press_debounce = 0;
>
> - mask = MTK_PMIC_RST_DU_MASK;
> - value = long_press_debounce << MTK_PMIC_RST_DU_SHIFT;
> + mask = regs->rst_lprst_mask;
> + value = long_press_debounce << (ffs(regs->rst_lprst_mask) - 1);
>
> error = of_property_read_u32(keys->dev->of_node,
> "mediatek,long-press-mode",
> @@ -147,7 +150,7 @@ static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> break;
> }
>
> - regmap_update_bits(keys->regmap, pmic_rst_reg, mask, value);
> + regmap_update_bits(keys->regmap, regs->pmic_rst_reg, mask, value);
> }
>
> static irqreturn_t mtk_pmic_keys_irq_handler_thread(int irq, void *data)
> @@ -351,7 +354,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_regs);
>
> platform_set_drvdata(pdev, keys);
>
> --
> 2.35.1
WARNING: multiple messages have this Message-ID (diff)
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
dmitry.torokhov@gmail.com
Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
linux-input@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] Input: mtk-pmic-keys - Move long press debounce mask to mtk_pmic_regs
Date: Tue, 24 May 2022 14:05:14 +0200 [thread overview]
Message-ID: <87k0abdtl1.fsf@baylibre.com> (raw)
In-Reply-To: <20220524093505.85438-3-angelogioacchino.delregno@collabora.com>
On mar., mai 24, 2022 at 11:35, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
> As the second and last step of preparation to add support for more
> PMICs in this driver, move the long press debounce mask to struct
> mtk_pmic_regs and use that in mtk_pmic_keys_lp_reset_setup() instead
> of directly using the definition.
>
> While at it, remove the definition for MTK_PMIC_RST_DU_SHIFT as we
> are able to calculate it dynamically and spares us some unnecessary
> new definitions around for future per-PMIC variations of RST_DU_MASK.
>
> Lastly, it was necessary to change the function signature of
> mtk_pmic_keys_lp_reset_setup() to now pass a pointer to the main
> mtk_pmic_regs structure, since that's where the reset debounce
> mask now resides.
>
> This commit brings no functional changes.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> drivers/input/keyboard/mtk-pmic-keys.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index 2509a349a173..6404081253ea 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -19,7 +19,6 @@
> #include <linux/regmap.h>
>
> #define MTK_PMIC_RST_DU_MASK GENMASK(9, 8)
> -#define MTK_PMIC_RST_DU_SHIFT 8
> #define MTK_PMIC_PWRKEY_RST BIT(6)
> #define MTK_PMIC_HOMEKEY_RST BIT(5)
>
> @@ -48,6 +47,7 @@ struct mtk_pmic_keys_regs {
> struct mtk_pmic_regs {
> const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT];
> u32 pmic_rst_reg;
> + u32 rst_lprst_mask; /* Long-press reset timeout bitmask */
> };
>
> static const struct mtk_pmic_regs mt6397_regs = {
> @@ -58,6 +58,7 @@ static const struct mtk_pmic_regs mt6397_regs = {
> MTK_PMIC_KEYS_REGS(MT6397_OCSTATUS2,
> 0x10, MT6397_INT_RSV, 0x8, MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6397_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> static const struct mtk_pmic_regs mt6323_regs = {
> @@ -68,6 +69,7 @@ static const struct mtk_pmic_regs mt6323_regs = {
> MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
> 0x4, MT6323_INT_MISC_CON, 0x8, MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6323_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> static const struct mtk_pmic_regs mt6358_regs = {
> @@ -80,6 +82,7 @@ static const struct mtk_pmic_regs mt6358_regs = {
> 0x8, MT6358_PSC_TOP_INT_CON0, 0xa,
> MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6358_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> struct mtk_pmic_keys_info {
> @@ -105,7 +108,7 @@ enum mtk_pmic_keys_lp_mode {
> };
>
> static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> - u32 pmic_rst_reg)
> + const struct mtk_pmic_regs *regs)
> {
> const struct mtk_pmic_keys_regs *kregs_home, *kregs_pwr;
> u32 long_press_mode, long_press_debounce;
> @@ -120,8 +123,8 @@ static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> if (error)
> long_press_debounce = 0;
>
> - mask = MTK_PMIC_RST_DU_MASK;
> - value = long_press_debounce << MTK_PMIC_RST_DU_SHIFT;
> + mask = regs->rst_lprst_mask;
> + value = long_press_debounce << (ffs(regs->rst_lprst_mask) - 1);
>
> error = of_property_read_u32(keys->dev->of_node,
> "mediatek,long-press-mode",
> @@ -147,7 +150,7 @@ static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> break;
> }
>
> - regmap_update_bits(keys->regmap, pmic_rst_reg, mask, value);
> + regmap_update_bits(keys->regmap, regs->pmic_rst_reg, mask, value);
> }
>
> static irqreturn_t mtk_pmic_keys_irq_handler_thread(int irq, void *data)
> @@ -351,7 +354,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_regs);
>
> platform_set_drvdata(pdev, keys);
>
> --
> 2.35.1
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
WARNING: multiple messages have this Message-ID (diff)
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
dmitry.torokhov@gmail.com
Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
linux-input@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] Input: mtk-pmic-keys - Move long press debounce mask to mtk_pmic_regs
Date: Tue, 24 May 2022 14:05:14 +0200 [thread overview]
Message-ID: <87k0abdtl1.fsf@baylibre.com> (raw)
In-Reply-To: <20220524093505.85438-3-angelogioacchino.delregno@collabora.com>
On mar., mai 24, 2022 at 11:35, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:
> As the second and last step of preparation to add support for more
> PMICs in this driver, move the long press debounce mask to struct
> mtk_pmic_regs and use that in mtk_pmic_keys_lp_reset_setup() instead
> of directly using the definition.
>
> While at it, remove the definition for MTK_PMIC_RST_DU_SHIFT as we
> are able to calculate it dynamically and spares us some unnecessary
> new definitions around for future per-PMIC variations of RST_DU_MASK.
>
> Lastly, it was necessary to change the function signature of
> mtk_pmic_keys_lp_reset_setup() to now pass a pointer to the main
> mtk_pmic_regs structure, since that's where the reset debounce
> mask now resides.
>
> This commit brings no functional changes.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> drivers/input/keyboard/mtk-pmic-keys.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index 2509a349a173..6404081253ea 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -19,7 +19,6 @@
> #include <linux/regmap.h>
>
> #define MTK_PMIC_RST_DU_MASK GENMASK(9, 8)
> -#define MTK_PMIC_RST_DU_SHIFT 8
> #define MTK_PMIC_PWRKEY_RST BIT(6)
> #define MTK_PMIC_HOMEKEY_RST BIT(5)
>
> @@ -48,6 +47,7 @@ struct mtk_pmic_keys_regs {
> struct mtk_pmic_regs {
> const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT];
> u32 pmic_rst_reg;
> + u32 rst_lprst_mask; /* Long-press reset timeout bitmask */
> };
>
> static const struct mtk_pmic_regs mt6397_regs = {
> @@ -58,6 +58,7 @@ static const struct mtk_pmic_regs mt6397_regs = {
> MTK_PMIC_KEYS_REGS(MT6397_OCSTATUS2,
> 0x10, MT6397_INT_RSV, 0x8, MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6397_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> static const struct mtk_pmic_regs mt6323_regs = {
> @@ -68,6 +69,7 @@ static const struct mtk_pmic_regs mt6323_regs = {
> MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
> 0x4, MT6323_INT_MISC_CON, 0x8, MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6323_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> static const struct mtk_pmic_regs mt6358_regs = {
> @@ -80,6 +82,7 @@ static const struct mtk_pmic_regs mt6358_regs = {
> 0x8, MT6358_PSC_TOP_INT_CON0, 0xa,
> MTK_PMIC_HOMEKEY_RST),
> .pmic_rst_reg = MT6358_TOP_RST_MISC,
> + .rst_lprst_mask = MTK_PMIC_RST_DU_MASK,
> };
>
> struct mtk_pmic_keys_info {
> @@ -105,7 +108,7 @@ enum mtk_pmic_keys_lp_mode {
> };
>
> static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> - u32 pmic_rst_reg)
> + const struct mtk_pmic_regs *regs)
> {
> const struct mtk_pmic_keys_regs *kregs_home, *kregs_pwr;
> u32 long_press_mode, long_press_debounce;
> @@ -120,8 +123,8 @@ static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> if (error)
> long_press_debounce = 0;
>
> - mask = MTK_PMIC_RST_DU_MASK;
> - value = long_press_debounce << MTK_PMIC_RST_DU_SHIFT;
> + mask = regs->rst_lprst_mask;
> + value = long_press_debounce << (ffs(regs->rst_lprst_mask) - 1);
>
> error = of_property_read_u32(keys->dev->of_node,
> "mediatek,long-press-mode",
> @@ -147,7 +150,7 @@ static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
> break;
> }
>
> - regmap_update_bits(keys->regmap, pmic_rst_reg, mask, value);
> + regmap_update_bits(keys->regmap, regs->pmic_rst_reg, mask, value);
> }
>
> static irqreturn_t mtk_pmic_keys_irq_handler_thread(int irq, void *data)
> @@ -351,7 +354,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_regs);
>
> platform_set_drvdata(pdev, keys);
>
> --
> 2.35.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-05-24 12:05 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-24 9:35 [PATCH v2 0/3] MediaTek Helio X10 MT6795 - MT6331 PMIC Keys AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-24 9:35 ` [PATCH v2 1/3] Input: mtk-pmic-keys - Transfer per-key bit in mtk_pmic_keys_regs AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-24 12:05 ` Mattijs Korpershoek
2022-05-24 12:05 ` Mattijs Korpershoek
2022-05-24 12:05 ` Mattijs Korpershoek
2022-05-27 5:34 ` Dmitry Torokhov
2022-05-27 5:34 ` Dmitry Torokhov
2022-05-27 5:34 ` Dmitry Torokhov
2022-05-30 9:00 ` AngeloGioacchino Del Regno
2022-05-30 9:00 ` AngeloGioacchino Del Regno
2022-05-30 9:00 ` AngeloGioacchino Del Regno
2022-05-24 9:35 ` [PATCH v2 2/3] Input: mtk-pmic-keys - Move long press debounce mask to mtk_pmic_regs AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-24 12:05 ` Mattijs Korpershoek [this message]
2022-05-24 12:05 ` Mattijs Korpershoek
2022-05-24 12:05 ` Mattijs Korpershoek
2022-05-24 9:35 ` [PATCH v2 3/3] Input: mtk-pmic-keys - Add support for MT6331 PMIC keys AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-24 9:35 ` AngeloGioacchino Del Regno
2022-05-26 11:08 ` [PATCH v2 0/3] MediaTek Helio X10 MT6795 - MT6331 PMIC Keys Pavel Machek
2022-05-26 11:08 ` Pavel Machek
2022-05-26 11:08 ` Pavel Machek
2022-05-30 9:47 ` AngeloGioacchino Del Regno
2022-05-30 9:47 ` AngeloGioacchino Del Regno
2022-05-30 9:47 ` AngeloGioacchino Del Regno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k0abdtl1.fsf@baylibre.com \
--to=mkorpershoek@baylibre.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.