Lines Matching +full:key +full:- +full:press
1 // SPDX-License-Identifier: GPL-2.0+
17 /* <2s for short press, >2s for long press */
80 reg_bm = onkey->params->long_int_pnd_bm | in atc2603x_onkey_hw_init()
81 onkey->params->short_int_pnd_bm | in atc2603x_onkey_hw_init()
82 onkey->params->kdwn_int_pnd_bm | in atc2603x_onkey_hw_init()
83 onkey->params->press_int_en_bm | in atc2603x_onkey_hw_init()
84 onkey->params->kdwn_int_en_bm; in atc2603x_onkey_hw_init()
87 reg_bm |= onkey->params->press_time_bm; in atc2603x_onkey_hw_init()
90 reg_bm |= onkey->params->reset_en_bm; in atc2603x_onkey_hw_init()
92 reg_bm |= onkey->params->reset_en_bm | in atc2603x_onkey_hw_init()
93 onkey->params->reset_time_bm; in atc2603x_onkey_hw_init()
94 reg_val |= onkey->params->reset_en_bm | reset_time; in atc2603x_onkey_hw_init()
97 return regmap_update_bits(onkey->atc260x->regmap, in atc2603x_onkey_hw_init()
98 onkey->params->reg_int_ctl, reg_bm, reg_val); in atc2603x_onkey_hw_init()
106 ret = regmap_read(onkey->atc260x->regmap, in atc260x_onkey_query()
107 onkey->params->reg_int_ctl, &key_down); in atc260x_onkey_query()
110 dev_err(onkey->atc260x->dev, in atc260x_onkey_query()
113 key_down &= onkey->params->kdwn_state_bm; in atc260x_onkey_query()
122 schedule_delayed_work(&onkey->work, msecs_to_jiffies(200)); in atc260x_onkey_query()
127 * The key-down status bit is cleared when the On/Off button in atc260x_onkey_query()
130 input_report_key(onkey->input_dev, KEY_POWER, 0); in atc260x_onkey_query()
131 input_sync(onkey->input_dev); in atc260x_onkey_query()
133 reg_bits = onkey->params->long_int_pnd_bm | in atc260x_onkey_query()
134 onkey->params->short_int_pnd_bm | in atc260x_onkey_query()
135 onkey->params->kdwn_int_pnd_bm | in atc260x_onkey_query()
136 onkey->params->press_int_en_bm | in atc260x_onkey_query()
137 onkey->params->kdwn_int_en_bm; in atc260x_onkey_query()
139 /* Clear key press pending events and enable key press interrupts. */ in atc260x_onkey_query()
140 regmap_update_bits(onkey->atc260x->regmap, onkey->params->reg_int_ctl, in atc260x_onkey_query()
156 /* Disable key press interrupts. */ in atc260x_onkey_irq()
157 ret = regmap_update_bits(onkey->atc260x->regmap, in atc260x_onkey_irq()
158 onkey->params->reg_int_ctl, in atc260x_onkey_irq()
159 onkey->params->press_int_en_bm | in atc260x_onkey_irq()
160 onkey->params->kdwn_int_en_bm, 0); in atc260x_onkey_irq()
162 dev_err(onkey->atc260x->dev, in atc260x_onkey_irq()
165 input_report_key(onkey->input_dev, KEY_POWER, 1); in atc260x_onkey_irq()
166 input_sync(onkey->input_dev); in atc260x_onkey_irq()
177 enable_irq(onkey->irq); in atc260x_onkey_open()
186 disable_irq(onkey->irq); in atc260x_onkey_close()
187 cancel_delayed_work_sync(&onkey->work); in atc260x_onkey_close()
192 struct atc260x *atc260x = dev_get_drvdata(pdev->dev.parent); in atc260x_onkey_probe()
199 onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL); in atc260x_onkey_probe()
201 return -ENOMEM; in atc260x_onkey_probe()
203 error = device_property_read_u32(pdev->dev.parent, in atc260x_onkey_probe()
204 "reset-time-sec", &val); in atc260x_onkey_probe()
209 dev_err(&pdev->dev, "reset-time-sec out of range\n"); in atc260x_onkey_probe()
210 return -EINVAL; in atc260x_onkey_probe()
214 reset_time = (val - 6) / 2; in atc260x_onkey_probe()
217 dev_dbg(&pdev->dev, "Disabled reset on long-press\n"); in atc260x_onkey_probe()
220 switch (atc260x->ic_type) { in atc260x_onkey_probe()
222 onkey->params = &atc2603c_onkey_params; in atc260x_onkey_probe()
229 onkey->params = &atc2609a_onkey_params; in atc260x_onkey_probe()
236 dev_err(&pdev->dev, in atc260x_onkey_probe()
238 atc260x->ic_type); in atc260x_onkey_probe()
239 return -EINVAL; in atc260x_onkey_probe()
242 input_dev = devm_input_allocate_device(&pdev->dev); in atc260x_onkey_probe()
244 dev_err(&pdev->dev, "Failed to allocate input device\n"); in atc260x_onkey_probe()
245 return -ENOMEM; in atc260x_onkey_probe()
248 onkey->input_dev = input_dev; in atc260x_onkey_probe()
249 onkey->atc260x = atc260x; in atc260x_onkey_probe()
251 input_dev->name = "atc260x-onkey"; in atc260x_onkey_probe()
252 input_dev->phys = "atc260x-onkey/input0"; in atc260x_onkey_probe()
253 input_dev->open = atc260x_onkey_open; in atc260x_onkey_probe()
254 input_dev->close = atc260x_onkey_close; in atc260x_onkey_probe()
259 INIT_DELAYED_WORK(&onkey->work, atc260x_onkey_work); in atc260x_onkey_probe()
261 onkey->irq = platform_get_irq(pdev, 0); in atc260x_onkey_probe()
262 if (onkey->irq < 0) in atc260x_onkey_probe()
263 return onkey->irq; in atc260x_onkey_probe()
265 error = devm_request_threaded_irq(&pdev->dev, onkey->irq, NULL, in atc260x_onkey_probe()
267 dev_name(&pdev->dev), onkey); in atc260x_onkey_probe()
269 dev_err(&pdev->dev, in atc260x_onkey_probe()
270 "Failed to register IRQ %d: %d\n", onkey->irq, error); in atc260x_onkey_probe()
275 disable_irq(onkey->irq); in atc260x_onkey_probe()
279 dev_err(&pdev->dev, in atc260x_onkey_probe()
289 device_init_wakeup(&pdev->dev, true); in atc260x_onkey_probe()
297 .name = "atc260x-onkey",