Skip to content

Commit 8c9cce9

Browse files
kcxtdtor
authored andcommitted
Input: pm8941-powerkey - fix debounce on gen2+ PMICs
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: 68c581d ("Input: add Qualcomm PM8941 power key driver") Signed-off-by: Caleb Connolly <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 60b7ae3 commit 8c9cce9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

drivers/input/misc/pm8941-pwrkey.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
#define PON_RESIN_PULL_UP BIT(0)
5151

5252
#define PON_DBC_CTL 0x71
53-
#define PON_DBC_DELAY_MASK 0x7
53+
#define PON_DBC_DELAY_MASK_GEN1 0x7
54+
#define PON_DBC_DELAY_MASK_GEN2 0xf
55+
#define PON_DBC_SHIFT_GEN1 6
56+
#define PON_DBC_SHIFT_GEN2 14
5457

5558
struct pm8941_data {
5659
unsigned int pull_up_bit;
@@ -247,7 +250,7 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev)
247250
struct device *parent;
248251
struct device_node *regmap_node;
249252
const __be32 *addr;
250-
u32 req_delay;
253+
u32 req_delay, mask, delay_shift;
251254
int error;
252255

253256
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)
336339
pwrkey->input->phys = pwrkey->data->phys;
337340

338341
if (pwrkey->data->supports_debounce_config) {
339-
req_delay = (req_delay << 6) / USEC_PER_SEC;
342+
if (pwrkey->subtype >= PON_SUBTYPE_GEN2_PRIMARY) {
343+
mask = PON_DBC_DELAY_MASK_GEN2;
344+
delay_shift = PON_DBC_SHIFT_GEN2;
345+
} else {
346+
mask = PON_DBC_DELAY_MASK_GEN1;
347+
delay_shift = PON_DBC_SHIFT_GEN1;
348+
}
349+
350+
req_delay = (req_delay << delay_shift) / USEC_PER_SEC;
340351
req_delay = ilog2(req_delay);
341352

342353
error = regmap_update_bits(pwrkey->regmap,
343354
pwrkey->baseaddr + PON_DBC_CTL,
344-
PON_DBC_DELAY_MASK,
355+
mask,
345356
req_delay);
346357
if (error) {
347358
dev_err(&pdev->dev, "failed to set debounce: %d\n",

0 commit comments

Comments
 (0)