Skip to content

Commit 95ea0cf

Browse files
iangehcdtor
authored andcommitted
Input: snvs_pwrkey - support power-off-time-sec
The power-off time is configured in LPCR[17:16] BTN_PRESS_TIME: * b00: 5 seconds (SoC default) * b01: 10 seconds * b10: 15 seconds * b11: PMIC is not disabled Signed-off-by: Ian Ray <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent fe315d6 commit 95ea0cf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/input/keyboard/snvs_pwrkey.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define SNVS_HPSR_BTN BIT(6)
2828
#define SNVS_LPSR_SPO BIT(18)
2929
#define SNVS_LPCR_DEP_EN BIT(5)
30+
#define SNVS_LPCR_BPT_SHIFT 16
31+
#define SNVS_LPCR_BPT_MASK (3 << SNVS_LPCR_BPT_SHIFT)
3032

3133
#define DEBOUNCE_TIME 30
3234
#define REPEAT_INTERVAL 60
@@ -114,6 +116,8 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
114116
struct device_node *np;
115117
struct clk *clk;
116118
int error;
119+
unsigned int val;
120+
unsigned int bpt;
117121
u32 vid;
118122

119123
/* Get SNVS register Page */
@@ -148,6 +152,27 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
148152
if (pdata->irq < 0)
149153
return -EINVAL;
150154

155+
error = of_property_read_u32(np, "power-off-time-sec", &val);
156+
if (!error) {
157+
switch (val) {
158+
case 0:
159+
bpt = 0x3;
160+
break;
161+
case 5:
162+
case 10:
163+
case 15:
164+
bpt = (val / 5) - 1;
165+
break;
166+
default:
167+
dev_err(&pdev->dev,
168+
"power-off-time-sec %d out of range\n", val);
169+
return -EINVAL;
170+
}
171+
172+
regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_BPT_MASK,
173+
bpt << SNVS_LPCR_BPT_SHIFT);
174+
}
175+
151176
regmap_read(pdata->snvs, SNVS_HPVIDR1_REG, &vid);
152177
pdata->minor_rev = vid & 0xff;
153178

0 commit comments

Comments
 (0)