Lines Matching refs:pwrkey

89 	struct pm8941_pwrkey *pwrkey = container_of(nb, struct pm8941_pwrkey,  in pm8941_reboot_notify()  local
96 if (pwrkey->revision == 0) in pm8941_reboot_notify()
101 error = regmap_update_bits(pwrkey->regmap, in pm8941_reboot_notify()
102 pwrkey->baseaddr + enable_reg, in pm8941_reboot_notify()
106 dev_err(pwrkey->dev, in pm8941_reboot_notify()
130 error = regmap_update_bits(pwrkey->regmap, in pm8941_reboot_notify()
131 pwrkey->baseaddr + PON_PS_HOLD_RST_CTL, in pm8941_reboot_notify()
135 dev_err(pwrkey->dev, "unable to set ps hold reset type: %d\n", in pm8941_reboot_notify()
138 error = regmap_update_bits(pwrkey->regmap, in pm8941_reboot_notify()
139 pwrkey->baseaddr + enable_reg, in pm8941_reboot_notify()
143 dev_err(pwrkey->dev, "unable to re-set enable: %d\n", error); in pm8941_reboot_notify()
150 struct pm8941_pwrkey *pwrkey = _data; in pm8941_pwrkey_irq() local
154 if (pwrkey->sw_debounce_time_us) { in pm8941_pwrkey_irq()
155 if (ktime_before(ktime_get(), pwrkey->sw_debounce_end_time)) { in pm8941_pwrkey_irq()
156 dev_dbg(pwrkey->dev, in pm8941_pwrkey_irq()
158 pwrkey->sw_debounce_end_time); in pm8941_pwrkey_irq()
163 err = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_RT_STS, &sts); in pm8941_pwrkey_irq()
167 sts &= pwrkey->data->status_bit; in pm8941_pwrkey_irq()
169 if (pwrkey->sw_debounce_time_us && !sts) in pm8941_pwrkey_irq()
170 pwrkey->sw_debounce_end_time = ktime_add_us(ktime_get(), in pm8941_pwrkey_irq()
171 pwrkey->sw_debounce_time_us); in pm8941_pwrkey_irq()
177 if (!pwrkey->last_status && !sts) { in pm8941_pwrkey_irq()
178 input_report_key(pwrkey->input, pwrkey->code, 1); in pm8941_pwrkey_irq()
179 input_sync(pwrkey->input); in pm8941_pwrkey_irq()
181 pwrkey->last_status = sts; in pm8941_pwrkey_irq()
183 input_report_key(pwrkey->input, pwrkey->code, sts); in pm8941_pwrkey_irq()
184 input_sync(pwrkey->input); in pm8941_pwrkey_irq()
189 static int pm8941_pwrkey_sw_debounce_init(struct pm8941_pwrkey *pwrkey) in pm8941_pwrkey_sw_debounce_init() argument
194 if (pwrkey->data->has_pon_pbs && !pwrkey->pon_pbs_baseaddr) { in pm8941_pwrkey_sw_debounce_init()
195 dev_err(pwrkey->dev, in pm8941_pwrkey_sw_debounce_init()
200 if (pwrkey->pon_pbs_baseaddr) in pm8941_pwrkey_sw_debounce_init()
201 addr = pwrkey->pon_pbs_baseaddr + PON_DBC_CTL; in pm8941_pwrkey_sw_debounce_init()
203 addr = pwrkey->baseaddr + PON_DBC_CTL; in pm8941_pwrkey_sw_debounce_init()
204 error = regmap_read(pwrkey->regmap, addr, &val); in pm8941_pwrkey_sw_debounce_init()
208 if (pwrkey->subtype >= PON_SUBTYPE_GEN2_PRIMARY) in pm8941_pwrkey_sw_debounce_init()
213 pwrkey->sw_debounce_time_us = in pm8941_pwrkey_sw_debounce_init()
216 dev_dbg(pwrkey->dev, "SW debounce time = %u us\n", in pm8941_pwrkey_sw_debounce_init()
217 pwrkey->sw_debounce_time_us); in pm8941_pwrkey_sw_debounce_init()
224 struct pm8941_pwrkey *pwrkey = dev_get_drvdata(dev); in pm8941_pwrkey_suspend() local
227 enable_irq_wake(pwrkey->irq); in pm8941_pwrkey_suspend()
234 struct pm8941_pwrkey *pwrkey = dev_get_drvdata(dev); in pm8941_pwrkey_resume() local
237 disable_irq_wake(pwrkey->irq); in pm8941_pwrkey_resume()
247 struct pm8941_pwrkey *pwrkey; in pm8941_pwrkey_probe() local
265 pwrkey = devm_kzalloc(&pdev->dev, sizeof(*pwrkey), GFP_KERNEL); in pm8941_pwrkey_probe()
266 if (!pwrkey) in pm8941_pwrkey_probe()
269 pwrkey->dev = &pdev->dev; in pm8941_pwrkey_probe()
270 pwrkey->data = of_device_get_match_data(&pdev->dev); in pm8941_pwrkey_probe()
274 pwrkey->regmap = dev_get_regmap(parent, NULL); in pm8941_pwrkey_probe()
275 if (!pwrkey->regmap) { in pm8941_pwrkey_probe()
282 pwrkey->regmap = dev_get_regmap(parent->parent, NULL); in pm8941_pwrkey_probe()
283 if (!pwrkey->regmap) { in pm8941_pwrkey_probe()
294 pwrkey->baseaddr = be32_to_cpup(addr); in pm8941_pwrkey_probe()
296 if (pwrkey->data->has_pon_pbs) { in pm8941_pwrkey_probe()
300 pwrkey->pon_pbs_baseaddr = be32_to_cpup(addr); in pm8941_pwrkey_probe()
303 pwrkey->irq = platform_get_irq(pdev, 0); in pm8941_pwrkey_probe()
304 if (pwrkey->irq < 0) in pm8941_pwrkey_probe()
305 return pwrkey->irq; in pm8941_pwrkey_probe()
307 error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_REV2, in pm8941_pwrkey_probe()
308 &pwrkey->revision); in pm8941_pwrkey_probe()
314 error = regmap_read(pwrkey->regmap, pwrkey->baseaddr + PON_SUBTYPE, in pm8941_pwrkey_probe()
315 &pwrkey->subtype); in pm8941_pwrkey_probe()
322 &pwrkey->code); in pm8941_pwrkey_probe()
326 pwrkey->code = KEY_POWER; in pm8941_pwrkey_probe()
329 pwrkey->input = devm_input_allocate_device(&pdev->dev); in pm8941_pwrkey_probe()
330 if (!pwrkey->input) { in pm8941_pwrkey_probe()
335 input_set_capability(pwrkey->input, EV_KEY, pwrkey->code); in pm8941_pwrkey_probe()
337 pwrkey->input->name = pwrkey->data->name; in pm8941_pwrkey_probe()
338 pwrkey->input->phys = pwrkey->data->phys; in pm8941_pwrkey_probe()
340 if (pwrkey->data->supports_debounce_config) { in pm8941_pwrkey_probe()
341 if (pwrkey->subtype >= PON_SUBTYPE_GEN2_PRIMARY) { in pm8941_pwrkey_probe()
352 error = regmap_update_bits(pwrkey->regmap, in pm8941_pwrkey_probe()
353 pwrkey->baseaddr + PON_DBC_CTL, in pm8941_pwrkey_probe()
363 error = pm8941_pwrkey_sw_debounce_init(pwrkey); in pm8941_pwrkey_probe()
367 if (pwrkey->data->pull_up_bit) { in pm8941_pwrkey_probe()
368 error = regmap_update_bits(pwrkey->regmap, in pm8941_pwrkey_probe()
369 pwrkey->baseaddr + PON_PULL_CTL, in pm8941_pwrkey_probe()
370 pwrkey->data->pull_up_bit, in pm8941_pwrkey_probe()
371 pull_up ? pwrkey->data->pull_up_bit : in pm8941_pwrkey_probe()
379 error = devm_request_threaded_irq(&pdev->dev, pwrkey->irq, in pm8941_pwrkey_probe()
382 pwrkey->data->name, pwrkey); in pm8941_pwrkey_probe()
388 error = input_register_device(pwrkey->input); in pm8941_pwrkey_probe()
395 if (pwrkey->data->supports_ps_hold_poff_config) { in pm8941_pwrkey_probe()
396 pwrkey->reboot_notifier.notifier_call = pm8941_reboot_notify; in pm8941_pwrkey_probe()
397 error = register_reboot_notifier(&pwrkey->reboot_notifier); in pm8941_pwrkey_probe()
405 platform_set_drvdata(pdev, pwrkey); in pm8941_pwrkey_probe()
413 struct pm8941_pwrkey *pwrkey = platform_get_drvdata(pdev); in pm8941_pwrkey_remove() local
415 if (pwrkey->data->supports_ps_hold_poff_config) in pm8941_pwrkey_remove()
416 unregister_reboot_notifier(&pwrkey->reboot_notifier); in pm8941_pwrkey_remove()