Lines Matching refs:ec_dev
58 static int cros_ec_cmd_xfer_rpmsg(struct cros_ec_device *ec_dev, in cros_ec_cmd_xfer_rpmsg() argument
72 static int cros_ec_pkt_xfer_rpmsg(struct cros_ec_device *ec_dev, in cros_ec_pkt_xfer_rpmsg() argument
75 struct cros_ec_rpmsg *ec_rpmsg = ec_dev->priv; in cros_ec_pkt_xfer_rpmsg()
84 len = cros_ec_prepare_tx(ec_dev, ec_msg); in cros_ec_pkt_xfer_rpmsg()
85 dev_dbg(ec_dev->dev, "prepared, len=%d\n", len); in cros_ec_pkt_xfer_rpmsg()
88 ret = rpmsg_send(ec_rpmsg->ept, ec_dev->dout, len); in cros_ec_pkt_xfer_rpmsg()
90 dev_err(ec_dev->dev, "rpmsg send failed\n"); in cros_ec_pkt_xfer_rpmsg()
97 dev_err(ec_dev->dev, "rpmsg send timeout\n"); in cros_ec_pkt_xfer_rpmsg()
102 response = (struct ec_host_response *)ec_dev->din; in cros_ec_pkt_xfer_rpmsg()
105 ret = cros_ec_check_result(ec_dev, ec_msg); in cros_ec_pkt_xfer_rpmsg()
110 dev_err(ec_dev->dev, "packet too long (%d bytes, expected %d)", in cros_ec_pkt_xfer_rpmsg()
117 memcpy(ec_msg->data, ec_dev->din + sizeof(*response), in cros_ec_pkt_xfer_rpmsg()
122 sum += ec_dev->din[i]; in cros_ec_pkt_xfer_rpmsg()
125 dev_err(ec_dev->dev, "bad packet checksum, calculated %x\n", in cros_ec_pkt_xfer_rpmsg()
145 struct cros_ec_device *ec_dev = dev_get_drvdata(&ec_rpmsg->rpdev->dev); in cros_ec_rpmsg_host_event_function() local
149 ret = cros_ec_get_next_event(ec_dev, &wake_event); in cros_ec_rpmsg_host_event_function()
156 if (wake_event && device_may_wakeup(ec_dev->dev)) in cros_ec_rpmsg_host_event_function()
157 pm_wakeup_event(ec_dev->dev, 0); in cros_ec_rpmsg_host_event_function()
160 blocking_notifier_call_chain(&ec_dev->event_notifier, in cros_ec_rpmsg_host_event_function()
161 0, ec_dev); in cros_ec_rpmsg_host_event_function()
167 struct cros_ec_device *ec_dev = dev_get_drvdata(&rpdev->dev); in cros_ec_rpmsg_callback() local
168 struct cros_ec_rpmsg *ec_rpmsg = ec_dev->priv; in cros_ec_rpmsg_callback()
172 dev_warn(ec_dev->dev, "rpmsg received empty response"); in cros_ec_rpmsg_callback()
179 if (len > ec_dev->din_size) { in cros_ec_rpmsg_callback()
180 dev_warn(ec_dev->dev, in cros_ec_rpmsg_callback()
182 len, ec_dev->din_size); in cros_ec_rpmsg_callback()
183 len = ec_dev->din_size; in cros_ec_rpmsg_callback()
186 memcpy(ec_dev->din, resp->data, len); in cros_ec_rpmsg_callback()
191 dev_warn(ec_dev->dev, "rpmsg received invalid type = %d", in cros_ec_rpmsg_callback()
215 struct cros_ec_device *ec_dev; in cros_ec_rpmsg_probe() local
218 ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); in cros_ec_rpmsg_probe()
219 if (!ec_dev) in cros_ec_rpmsg_probe()
226 ec_dev->dev = dev; in cros_ec_rpmsg_probe()
227 ec_dev->priv = ec_rpmsg; in cros_ec_rpmsg_probe()
228 ec_dev->cmd_xfer = cros_ec_cmd_xfer_rpmsg; in cros_ec_rpmsg_probe()
229 ec_dev->pkt_xfer = cros_ec_pkt_xfer_rpmsg; in cros_ec_rpmsg_probe()
230 ec_dev->phys_name = dev_name(&rpdev->dev); in cros_ec_rpmsg_probe()
231 ec_dev->din_size = sizeof(struct ec_host_response) + in cros_ec_rpmsg_probe()
233 ec_dev->dout_size = sizeof(struct ec_host_request); in cros_ec_rpmsg_probe()
234 dev_set_drvdata(dev, ec_dev); in cros_ec_rpmsg_probe()
245 ret = cros_ec_register(ec_dev); in cros_ec_rpmsg_probe()
257 struct cros_ec_device *ec_dev = dev_get_drvdata(&rpdev->dev); in cros_ec_rpmsg_remove() local
258 struct cros_ec_rpmsg *ec_rpmsg = ec_dev->priv; in cros_ec_rpmsg_remove()
260 cros_ec_unregister(ec_dev); in cros_ec_rpmsg_remove()
268 struct cros_ec_device *ec_dev = dev_get_drvdata(dev); in cros_ec_rpmsg_suspend() local
270 return cros_ec_suspend(ec_dev); in cros_ec_rpmsg_suspend()
275 struct cros_ec_device *ec_dev = dev_get_drvdata(dev); in cros_ec_rpmsg_resume() local
277 return cros_ec_resume(ec_dev); in cros_ec_rpmsg_resume()