Lines Matching refs:ec_dev

36 	struct cros_ec_device *ec_dev = data;  in ec_irq_thread()  local
40 ret = cros_ec_get_next_event(ec_dev, &wake_event); in ec_irq_thread()
47 if (wake_event && device_may_wakeup(ec_dev->dev)) in ec_irq_thread()
48 pm_wakeup_event(ec_dev->dev, 0); in ec_irq_thread()
51 blocking_notifier_call_chain(&ec_dev->event_notifier, in ec_irq_thread()
52 0, ec_dev); in ec_irq_thread()
56 static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) in cros_ec_sleep_event() argument
70 if (ec_dev->host_sleep_v1) { in cros_ec_sleep_event()
89 ret = cros_ec_cmd_xfer(ec_dev, &buf.msg); in cros_ec_sleep_event()
92 if (ret >= 0 && ec_dev->host_sleep_v1 && in cros_ec_sleep_event()
94 ec_dev->last_resume_result = in cros_ec_sleep_event()
107 int cros_ec_register(struct cros_ec_device *ec_dev) in cros_ec_register() argument
109 struct device *dev = ec_dev->dev; in cros_ec_register()
112 BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier); in cros_ec_register()
114 ec_dev->max_request = sizeof(struct ec_params_hello); in cros_ec_register()
115 ec_dev->max_response = sizeof(struct ec_response_get_protocol_info); in cros_ec_register()
116 ec_dev->max_passthru = 0; in cros_ec_register()
118 ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL); in cros_ec_register()
119 if (!ec_dev->din) in cros_ec_register()
122 ec_dev->dout = devm_kzalloc(dev, ec_dev->dout_size, GFP_KERNEL); in cros_ec_register()
123 if (!ec_dev->dout) in cros_ec_register()
126 mutex_init(&ec_dev->lock); in cros_ec_register()
128 err = cros_ec_query_all(ec_dev); in cros_ec_register()
134 if (ec_dev->irq) { in cros_ec_register()
135 err = devm_request_threaded_irq(dev, ec_dev->irq, NULL, in cros_ec_register()
137 "chromeos-ec", ec_dev); in cros_ec_register()
140 ec_dev->irq, err); in cros_ec_register()
146 ec_dev->ec = platform_device_register_data(ec_dev->dev, "cros-ec-dev", in cros_ec_register()
149 if (IS_ERR(ec_dev->ec)) { in cros_ec_register()
150 dev_err(ec_dev->dev, in cros_ec_register()
152 return PTR_ERR(ec_dev->ec); in cros_ec_register()
155 if (ec_dev->max_passthru) { in cros_ec_register()
164 ec_dev->pd = platform_device_register_data(ec_dev->dev, in cros_ec_register()
168 if (IS_ERR(ec_dev->pd)) { in cros_ec_register()
169 dev_err(ec_dev->dev, in cros_ec_register()
171 platform_device_unregister(ec_dev->ec); in cros_ec_register()
172 return PTR_ERR(ec_dev->pd); in cros_ec_register()
179 platform_device_unregister(ec_dev->pd); in cros_ec_register()
180 platform_device_unregister(ec_dev->ec); in cros_ec_register()
190 err = cros_ec_sleep_event(ec_dev, 0); in cros_ec_register()
192 dev_dbg(ec_dev->dev, "Error %d clearing sleep event to ec", in cros_ec_register()
201 int cros_ec_unregister(struct cros_ec_device *ec_dev) in cros_ec_unregister() argument
203 if (ec_dev->pd) in cros_ec_unregister()
204 platform_device_unregister(ec_dev->pd); in cros_ec_unregister()
205 platform_device_unregister(ec_dev->ec); in cros_ec_unregister()
212 int cros_ec_suspend(struct cros_ec_device *ec_dev) in cros_ec_suspend() argument
214 struct device *dev = ec_dev->dev; in cros_ec_suspend()
222 ret = cros_ec_sleep_event(ec_dev, sleep_event); in cros_ec_suspend()
224 dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec", in cros_ec_suspend()
228 ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq); in cros_ec_suspend()
230 disable_irq(ec_dev->irq); in cros_ec_suspend()
231 ec_dev->was_wake_device = ec_dev->wake_enabled; in cros_ec_suspend()
232 ec_dev->suspended = true; in cros_ec_suspend()
238 static void cros_ec_report_events_during_suspend(struct cros_ec_device *ec_dev) in cros_ec_report_events_during_suspend() argument
240 while (ec_dev->mkbp_event_supported && in cros_ec_report_events_during_suspend()
241 cros_ec_get_next_event(ec_dev, NULL) > 0) in cros_ec_report_events_during_suspend()
242 blocking_notifier_call_chain(&ec_dev->event_notifier, in cros_ec_report_events_during_suspend()
243 1, ec_dev); in cros_ec_report_events_during_suspend()
246 int cros_ec_resume(struct cros_ec_device *ec_dev) in cros_ec_resume() argument
251 ec_dev->suspended = false; in cros_ec_resume()
252 enable_irq(ec_dev->irq); in cros_ec_resume()
258 ret = cros_ec_sleep_event(ec_dev, sleep_event); in cros_ec_resume()
260 dev_dbg(ec_dev->dev, "Error %d sending resume event to ec", in cros_ec_resume()
263 if (ec_dev->wake_enabled) { in cros_ec_resume()
264 disable_irq_wake(ec_dev->irq); in cros_ec_resume()
265 ec_dev->wake_enabled = 0; in cros_ec_resume()
271 cros_ec_report_events_during_suspend(ec_dev); in cros_ec_resume()