* [PATCH 0/2] Fix pm8941-pwrkey debounce programming
@ 2023-05-29 19:55 Caleb Connolly
2023-05-29 19:55 ` [PATCH 1/2] MAINTAINERS: Adjust Qualcomm driver globbing Caleb Connolly
2023-05-29 19:55 ` [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs Caleb Connolly
0 siblings, 2 replies; 7+ messages in thread
From: Caleb Connolly @ 2023-05-29 19:55 UTC (permalink / raw)
To: Dmitry Torokhov, Andy Gross, Bjorn Andersson, Konrad Dybcio
Cc: linux-input, linux-arm-msm, phone-devel, Caleb Connolly
Since PM8998 the pon debounce register was adjusted to support much
lower debounce times however the driver was never changed to reflect
this.
This resulted in the debounce time being set to the minimum ~62us on
PMICs from PM8998/PM660 up until PMk8350.
Set the shift and mask correctly, and adjust MAINTAINERS to include the
driver under Qualcomm support.
---
Caleb Connolly (2):
MAINTAINERS: Adjust Qualcomm driver globbing
Input: pm8941-powerkey - fix debounce on gen2+ PMICs
MAINTAINERS | 2 +-
drivers/input/misc/pm8941-pwrkey.c | 19 +++++++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
---
base-commit: 44c026a73be8038f03dbdeef028b642880cf1511
// Caleb (they/them)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] MAINTAINERS: Adjust Qualcomm driver globbing
2023-05-29 19:55 [PATCH 0/2] Fix pm8941-pwrkey debounce programming Caleb Connolly
@ 2023-05-29 19:55 ` Caleb Connolly
2023-06-06 19:12 ` Dmitry Torokhov
2023-05-29 19:55 ` [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs Caleb Connolly
1 sibling, 1 reply; 7+ messages in thread
From: Caleb Connolly @ 2023-05-29 19:55 UTC (permalink / raw)
To: Dmitry Torokhov, Andy Gross, Bjorn Andersson, Konrad Dybcio
Cc: linux-input, linux-arm-msm, phone-devel, Caleb Connolly
The only drivers matching pm8???-* are two levels deep, adjust the glob
to match them.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
MAINTAINERS | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 27ef11624748..86b7842b44ab 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2577,9 +2577,9 @@ F: arch/arm/boot/dts/qcom-*.dtsi
F: arch/arm/configs/qcom_defconfig
F: arch/arm/mach-qcom/
F: arch/arm64/boot/dts/qcom/
+F: drivers/*/*/pm8???-*
F: drivers/*/*/qcom*
F: drivers/*/*/qcom/
-F: drivers/*/pm8???-*
F: drivers/*/qcom*
F: drivers/*/qcom/
F: drivers/bluetooth/btqcomsmd.c
--
2.40.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs
2023-05-29 19:55 [PATCH 0/2] Fix pm8941-pwrkey debounce programming Caleb Connolly
2023-05-29 19:55 ` [PATCH 1/2] MAINTAINERS: Adjust Qualcomm driver globbing Caleb Connolly
@ 2023-05-29 19:55 ` Caleb Connolly
2023-05-30 9:36 ` Konrad Dybcio
2023-06-06 19:12 ` Dmitry Torokhov
1 sibling, 2 replies; 7+ messages in thread
From: Caleb Connolly @ 2023-05-29 19:55 UTC (permalink / raw)
To: Dmitry Torokhov, Andy Gross, Bjorn Andersson, Konrad Dybcio
Cc: linux-input, linux-arm-msm, phone-devel, Caleb Connolly
Since PM8998/PM660, the power key debounce register was redefined to
support shorter debounce times. On PM8941 the shortest debounce time
(represented by register value 0) was 15625us, on PM8998 the shortest
debounce time is 62us, with the default being 2ms.
Adjust the bit shift to correctly program debounce on PM8998 and newer.
Fixes: 68c581d5e7d8 ("Input: add Qualcomm PM8941 power key driver")
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
This patch shouldn't be backported earlier then 5.4, as that is the
first kernel with support for PM8998.
---
drivers/input/misc/pm8941-pwrkey.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
index b6a27ebae977..74d77d8aaeff 100644
--- a/drivers/input/misc/pm8941-pwrkey.c
+++ b/drivers/input/misc/pm8941-pwrkey.c
@@ -50,7 +50,10 @@
#define PON_RESIN_PULL_UP BIT(0)
#define PON_DBC_CTL 0x71
-#define PON_DBC_DELAY_MASK 0x7
+#define PON_DBC_DELAY_MASK_GEN1 0x7
+#define PON_DBC_DELAY_MASK_GEN2 0xf
+#define PON_DBC_SHIFT_GEN1 6
+#define PON_DBC_SHIFT_GEN2 14
struct pm8941_data {
unsigned int pull_up_bit;
@@ -247,7 +250,7 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
struct device *parent;
struct device_node *regmap_node;
const __be32 *addr;
- u32 req_delay;
+ u32 req_delay, mask, delay_shift;
int error;
if (of_property_read_u32(pdev->dev.of_node, "debounce", &req_delay))
@@ -336,12 +339,20 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
pwrkey->input->phys = pwrkey->data->phys;
if (pwrkey->data->supports_debounce_config) {
- req_delay = (req_delay << 6) / USEC_PER_SEC;
+ if (pwrkey->subtype >= PON_SUBTYPE_GEN2_PRIMARY) {
+ mask = PON_DBC_DELAY_MASK_GEN2;
+ delay_shift = PON_DBC_SHIFT_GEN2;
+ } else {
+ mask = PON_DBC_DELAY_MASK_GEN1;
+ delay_shift = PON_DBC_SHIFT_GEN1;
+ }
+
+ req_delay = (req_delay << delay_shift) / USEC_PER_SEC;
req_delay = ilog2(req_delay);
error = regmap_update_bits(pwrkey->regmap,
pwrkey->baseaddr + PON_DBC_CTL,
- PON_DBC_DELAY_MASK,
+ mask,
req_delay);
if (error) {
dev_err(&pdev->dev, "failed to set debounce: %d\n",
--
2.40.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs
2023-05-29 19:55 ` [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs Caleb Connolly
@ 2023-05-30 9:36 ` Konrad Dybcio
2023-05-30 13:00 ` Caleb Connolly
2023-06-06 19:12 ` Dmitry Torokhov
1 sibling, 1 reply; 7+ messages in thread
From: Konrad Dybcio @ 2023-05-30 9:36 UTC (permalink / raw)
To: Caleb Connolly, Dmitry Torokhov, Andy Gross, Bjorn Andersson
Cc: linux-input, linux-arm-msm, phone-devel
On 29.05.2023 21:55, Caleb Connolly wrote:
> Since PM8998/PM660, the power key debounce register was redefined to
> support shorter debounce times. On PM8941 the shortest debounce time
> (represented by register value 0) was 15625us, on PM8998 the shortest
> debounce time is 62us, with the default being 2ms.
>
> Adjust the bit shift to correctly program debounce on PM8998 and newer.
>
> Fixes: 68c581d5e7d8 ("Input: add Qualcomm PM8941 power key driver")
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
> This patch shouldn't be backported earlier then 5.4, as that is the
> first kernel with support for PM8998.
> ---
> drivers/input/misc/pm8941-pwrkey.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
> index b6a27ebae977..74d77d8aaeff 100644
> --- a/drivers/input/misc/pm8941-pwrkey.c
> +++ b/drivers/input/misc/pm8941-pwrkey.c
> @@ -50,7 +50,10 @@
> #define PON_RESIN_PULL_UP BIT(0)
>
> #define PON_DBC_CTL 0x71
> -#define PON_DBC_DELAY_MASK 0x7
> +#define PON_DBC_DELAY_MASK_GEN1 0x7
> +#define PON_DBC_DELAY_MASK_GEN2 0xf
> +#define PON_DBC_SHIFT_GEN1 6
> +#define PON_DBC_SHIFT_GEN2 14
mask+shift -> field_prep/get?
Nice find!
Konrad
>
> struct pm8941_data {
> unsigned int pull_up_bit;
> @@ -247,7 +250,7 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
> struct device *parent;
> struct device_node *regmap_node;
> const __be32 *addr;
> - u32 req_delay;
> + u32 req_delay, mask, delay_shift;
> int error;
>
> if (of_property_read_u32(pdev->dev.of_node, "debounce", &req_delay))
> @@ -336,12 +339,20 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
> pwrkey->input->phys = pwrkey->data->phys;
>
> if (pwrkey->data->supports_debounce_config) {
> - req_delay = (req_delay << 6) / USEC_PER_SEC;
> + if (pwrkey->subtype >= PON_SUBTYPE_GEN2_PRIMARY) {
> + mask = PON_DBC_DELAY_MASK_GEN2;
> + delay_shift = PON_DBC_SHIFT_GEN2;
> + } else {
> + mask = PON_DBC_DELAY_MASK_GEN1;
> + delay_shift = PON_DBC_SHIFT_GEN1;
> + }
> +
> + req_delay = (req_delay << delay_shift) / USEC_PER_SEC;
> req_delay = ilog2(req_delay);
>
> error = regmap_update_bits(pwrkey->regmap,
> pwrkey->baseaddr + PON_DBC_CTL,
> - PON_DBC_DELAY_MASK,
> + mask,
> req_delay);
> if (error) {
> dev_err(&pdev->dev, "failed to set debounce: %d\n",
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs
2023-05-30 9:36 ` Konrad Dybcio
@ 2023-05-30 13:00 ` Caleb Connolly
0 siblings, 0 replies; 7+ messages in thread
From: Caleb Connolly @ 2023-05-30 13:00 UTC (permalink / raw)
To: Konrad Dybcio, Dmitry Torokhov, Andy Gross, Bjorn Andersson
Cc: linux-input, linux-arm-msm, phone-devel
On 30/05/2023 10:36, Konrad Dybcio wrote:
>
>
> On 29.05.2023 21:55, Caleb Connolly wrote:
>> Since PM8998/PM660, the power key debounce register was redefined to
>> support shorter debounce times. On PM8941 the shortest debounce time
>> (represented by register value 0) was 15625us, on PM8998 the shortest
>> debounce time is 62us, with the default being 2ms.
>>
>> Adjust the bit shift to correctly program debounce on PM8998 and newer.
>>
>> Fixes: 68c581d5e7d8 ("Input: add Qualcomm PM8941 power key driver")
>> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
>> ---
>> This patch shouldn't be backported earlier then 5.4, as that is the
>> first kernel with support for PM8998.
>> ---
>> drivers/input/misc/pm8941-pwrkey.c | 19 +++++++++++++++----
>> 1 file changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
>> index b6a27ebae977..74d77d8aaeff 100644
>> --- a/drivers/input/misc/pm8941-pwrkey.c
>> +++ b/drivers/input/misc/pm8941-pwrkey.c
>> @@ -50,7 +50,10 @@
>> #define PON_RESIN_PULL_UP BIT(0)
>>
>> #define PON_DBC_CTL 0x71
>> -#define PON_DBC_DELAY_MASK 0x7
>> +#define PON_DBC_DELAY_MASK_GEN1 0x7
>> +#define PON_DBC_DELAY_MASK_GEN2 0xf
>> +#define PON_DBC_SHIFT_GEN1 6
>> +#define PON_DBC_SHIFT_GEN2 14
> mask+shift -> field_prep/get?
I figured it was better to keep it consistent and try to minimise the
diff so that backporting is easier.
Migrating over to bitfield helpers probably makes sense to do as a
separate change - maybe if a new platform comes along and requires even
more additional complexity?
>
> Nice find!
>
> Konrad
>>
>> struct pm8941_data {
>> unsigned int pull_up_bit;
>> @@ -247,7 +250,7 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
>> struct device *parent;
>> struct device_node *regmap_node;
>> const __be32 *addr;
>> - u32 req_delay;
>> + u32 req_delay, mask, delay_shift;
>> int error;
>>
>> if (of_property_read_u32(pdev->dev.of_node, "debounce", &req_delay))
>> @@ -336,12 +339,20 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
>> pwrkey->input->phys = pwrkey->data->phys;
>>
>> if (pwrkey->data->supports_debounce_config) {
>> - req_delay = (req_delay << 6) / USEC_PER_SEC;
>> + if (pwrkey->subtype >= PON_SUBTYPE_GEN2_PRIMARY) {
>> + mask = PON_DBC_DELAY_MASK_GEN2;
>> + delay_shift = PON_DBC_SHIFT_GEN2;
>> + } else {
>> + mask = PON_DBC_DELAY_MASK_GEN1;
>> + delay_shift = PON_DBC_SHIFT_GEN1;
>> + }
>> +
>> + req_delay = (req_delay << delay_shift) / USEC_PER_SEC;
>> req_delay = ilog2(req_delay);
>>
>> error = regmap_update_bits(pwrkey->regmap,
>> pwrkey->baseaddr + PON_DBC_CTL,
>> - PON_DBC_DELAY_MASK,
>> + mask,
>> req_delay);
>> if (error) {
>> dev_err(&pdev->dev, "failed to set debounce: %d\n",
>>
--
// Caleb (they/them)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] MAINTAINERS: Adjust Qualcomm driver globbing
2023-05-29 19:55 ` [PATCH 1/2] MAINTAINERS: Adjust Qualcomm driver globbing Caleb Connolly
@ 2023-06-06 19:12 ` Dmitry Torokhov
0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2023-06-06 19:12 UTC (permalink / raw)
To: Caleb Connolly
Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-input,
linux-arm-msm, phone-devel
On Mon, May 29, 2023 at 08:55:06PM +0100, Caleb Connolly wrote:
> The only drivers matching pm8???-* are two levels deep, adjust the glob
> to match them.
>
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs
2023-05-29 19:55 ` [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs Caleb Connolly
2023-05-30 9:36 ` Konrad Dybcio
@ 2023-06-06 19:12 ` Dmitry Torokhov
1 sibling, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2023-06-06 19:12 UTC (permalink / raw)
To: Caleb Connolly
Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-input,
linux-arm-msm, phone-devel
On Mon, May 29, 2023 at 08:55:07PM +0100, Caleb Connolly wrote:
> Since PM8998/PM660, the power key debounce register was redefined to
> support shorter debounce times. On PM8941 the shortest debounce time
> (represented by register value 0) was 15625us, on PM8998 the shortest
> debounce time is 62us, with the default being 2ms.
>
> Adjust the bit shift to correctly program debounce on PM8998 and newer.
>
> Fixes: 68c581d5e7d8 ("Input: add Qualcomm PM8941 power key driver")
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-06-06 19:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-29 19:55 [PATCH 0/2] Fix pm8941-pwrkey debounce programming Caleb Connolly
2023-05-29 19:55 ` [PATCH 1/2] MAINTAINERS: Adjust Qualcomm driver globbing Caleb Connolly
2023-06-06 19:12 ` Dmitry Torokhov
2023-05-29 19:55 ` [PATCH 2/2] Input: pm8941-powerkey - fix debounce on gen2+ PMICs Caleb Connolly
2023-05-30 9:36 ` Konrad Dybcio
2023-05-30 13:00 ` Caleb Connolly
2023-06-06 19:12 ` Dmitry Torokhov
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).