Lines Matching +full:rpmsg +full:- +full:channel +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
14 #include <linux/rpmsg.h>
27 * struct wcnss_ctrl - driver context
29 * @channel: SMD channel handle
37 struct rpmsg_endpoint *channel; member
64 * struct wcnss_msg_hdr - common packet header for requests and responses
74 * struct wcnss_version_resp - version request response
85 * struct wcnss_download_nv_req - firmware fragment request
101 * struct wcnss_download_nv_resp - firmware download response
111 * wcnss_ctrl_smd_callback() - handler from SMD responses
126 struct wcnss_ctrl *wcnss = dev_get_drvdata(&rpdev->dev); in wcnss_ctrl_smd_callback()
131 switch (hdr->type) { in wcnss_ctrl_smd_callback()
134 dev_err(wcnss->dev, in wcnss_ctrl_smd_callback()
140 dev_info(wcnss->dev, "WCNSS Version %d.%d %d.%d\n", in wcnss_ctrl_smd_callback()
141 version->major, version->minor, in wcnss_ctrl_smd_callback()
142 version->version, version->revision); in wcnss_ctrl_smd_callback()
144 complete(&wcnss->ack); in wcnss_ctrl_smd_callback()
148 dev_err(wcnss->dev, in wcnss_ctrl_smd_callback()
154 wcnss->ack_status = nvresp->status; in wcnss_ctrl_smd_callback()
155 complete(&wcnss->ack); in wcnss_ctrl_smd_callback()
158 dev_dbg(wcnss->dev, "cold boot complete\n"); in wcnss_ctrl_smd_callback()
159 complete(&wcnss->cbc); in wcnss_ctrl_smd_callback()
162 dev_info(wcnss->dev, "unknown message type %d\n", hdr->type); in wcnss_ctrl_smd_callback()
170 * wcnss_request_version() - send a version request to WCNSS
180 ret = rpmsg_send(wcnss->channel, &msg, sizeof(msg)); in wcnss_request_version()
184 ret = wait_for_completion_timeout(&wcnss->ack, WCNSS_CBC_TIMEOUT); in wcnss_request_version()
186 dev_err(wcnss->dev, "timeout waiting for version response\n"); in wcnss_request_version()
187 return -ETIMEDOUT; in wcnss_request_version()
194 * wcnss_download_nv() - send nv binary to WCNSS
203 struct device *dev = wcnss->dev; in wcnss_download_nv()
212 return -ENOMEM; in wcnss_download_nv()
214 ret = of_property_read_string(dev->of_node, "firmware-name", &nvbin); in wcnss_download_nv()
215 if (ret < 0 && ret != -EINVAL) in wcnss_download_nv()
224 data = fw->data; in wcnss_download_nv()
225 left = fw->size; in wcnss_download_nv()
227 req->hdr.type = WCNSS_DOWNLOAD_NV_REQ; in wcnss_download_nv()
228 req->hdr.len = sizeof(*req) + NV_FRAGMENT_SIZE; in wcnss_download_nv()
230 req->last = 0; in wcnss_download_nv()
231 req->frag_size = NV_FRAGMENT_SIZE; in wcnss_download_nv()
233 req->seq = 0; in wcnss_download_nv()
236 req->last = 1; in wcnss_download_nv()
237 req->frag_size = left; in wcnss_download_nv()
238 req->hdr.len = sizeof(*req) + left; in wcnss_download_nv()
241 memcpy(req->fragment, data, req->frag_size); in wcnss_download_nv()
243 ret = rpmsg_send(wcnss->channel, req, req->hdr.len); in wcnss_download_nv()
250 req->seq++; in wcnss_download_nv()
253 left -= NV_FRAGMENT_SIZE; in wcnss_download_nv()
256 ret = wait_for_completion_timeout(&wcnss->ack, WCNSS_REQUEST_TIMEOUT); in wcnss_download_nv()
259 ret = -ETIMEDOUT; in wcnss_download_nv()
261 *expect_cbc = wcnss->ack_status == WCNSS_ACK_COLD_BOOTING; in wcnss_download_nv()
272 * qcom_wcnss_open_channel() - open additional SMD channel to WCNSS
274 * @name: SMD channel name
275 * @cb: callback to handle incoming data on the channel
276 * @priv: private data for use in the call-back
278 struct rpmsg_endpoint *qcom_wcnss_open_channel(void *wcnss, const char *name, rpmsg_rx_cb_t cb, voi… in qcom_wcnss_open_channel() argument
283 strscpy(chinfo.name, name, sizeof(chinfo.name)); in qcom_wcnss_open_channel()
287 return rpmsg_create_ept(_wcnss->channel->rpdev, cb, priv, chinfo); in qcom_wcnss_open_channel()
307 ret = wait_for_completion_timeout(&wcnss->cbc, WCNSS_REQUEST_TIMEOUT); in wcnss_async_probe()
309 dev_err(wcnss->dev, "expected cold boot completion\n"); in wcnss_async_probe()
312 of_platform_populate(wcnss->dev->of_node, NULL, NULL, wcnss->dev); in wcnss_async_probe()
319 wcnss = devm_kzalloc(&rpdev->dev, sizeof(*wcnss), GFP_KERNEL); in wcnss_ctrl_probe()
321 return -ENOMEM; in wcnss_ctrl_probe()
323 wcnss->dev = &rpdev->dev; in wcnss_ctrl_probe()
324 wcnss->channel = rpdev->ept; in wcnss_ctrl_probe()
326 init_completion(&wcnss->ack); in wcnss_ctrl_probe()
327 init_completion(&wcnss->cbc); in wcnss_ctrl_probe()
328 INIT_WORK(&wcnss->probe_work, wcnss_async_probe); in wcnss_ctrl_probe()
330 dev_set_drvdata(&rpdev->dev, wcnss); in wcnss_ctrl_probe()
332 schedule_work(&wcnss->probe_work); in wcnss_ctrl_probe()
339 struct wcnss_ctrl *wcnss = dev_get_drvdata(&rpdev->dev); in wcnss_ctrl_remove()
341 cancel_work_sync(&wcnss->probe_work); in wcnss_ctrl_remove()
342 of_platform_depopulate(&rpdev->dev); in wcnss_ctrl_remove()
356 .name = "qcom_wcnss_ctrl",