Lines Matching refs:smp2p
96 struct qcom_smp2p *smp2p; member
163 static void qcom_smp2p_kick(struct qcom_smp2p *smp2p) in qcom_smp2p_kick() argument
168 if (smp2p->mbox_chan) { in qcom_smp2p_kick()
169 mbox_send_message(smp2p->mbox_chan, NULL); in qcom_smp2p_kick()
170 mbox_client_txdone(smp2p->mbox_chan, 0); in qcom_smp2p_kick()
172 regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit)); in qcom_smp2p_kick()
176 static bool qcom_smp2p_check_ssr(struct qcom_smp2p *smp2p) in qcom_smp2p_check_ssr() argument
178 struct smp2p_smem_item *in = smp2p->in; in qcom_smp2p_check_ssr()
181 if (!smp2p->ssr_ack_enabled) in qcom_smp2p_check_ssr()
186 return restart != smp2p->ssr_ack; in qcom_smp2p_check_ssr()
189 static void qcom_smp2p_do_ssr_ack(struct qcom_smp2p *smp2p) in qcom_smp2p_do_ssr_ack() argument
191 struct smp2p_smem_item *out = smp2p->out; in qcom_smp2p_do_ssr_ack()
194 smp2p->ssr_ack = !smp2p->ssr_ack; in qcom_smp2p_do_ssr_ack()
197 if (smp2p->ssr_ack) in qcom_smp2p_do_ssr_ack()
201 qcom_smp2p_kick(smp2p); in qcom_smp2p_do_ssr_ack()
204 static void qcom_smp2p_negotiate(struct qcom_smp2p *smp2p) in qcom_smp2p_negotiate() argument
206 struct smp2p_smem_item *out = smp2p->out; in qcom_smp2p_negotiate()
207 struct smp2p_smem_item *in = smp2p->in; in qcom_smp2p_negotiate()
213 smp2p->ssr_ack_enabled = true; in qcom_smp2p_negotiate()
215 smp2p->negotiation_done = true; in qcom_smp2p_negotiate()
219 static void qcom_smp2p_notify_in(struct qcom_smp2p *smp2p) in qcom_smp2p_notify_in() argument
229 in = smp2p->in; in qcom_smp2p_notify_in()
232 for (i = smp2p->valid_entries; i < in->valid_entries; i++) { in qcom_smp2p_notify_in()
233 list_for_each_entry(entry, &smp2p->inbound, node) { in qcom_smp2p_notify_in()
241 smp2p->valid_entries = i; in qcom_smp2p_notify_in()
244 list_for_each_entry(entry, &smp2p->inbound, node) { in qcom_smp2p_notify_in()
282 struct qcom_smp2p *smp2p = data; in qcom_smp2p_intr() local
283 unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND]; in qcom_smp2p_intr()
284 unsigned int pid = smp2p->remote_pid; in qcom_smp2p_intr()
288 in = smp2p->in; in qcom_smp2p_intr()
294 dev_err(smp2p->dev, in qcom_smp2p_intr()
299 smp2p->in = in; in qcom_smp2p_intr()
302 if (!smp2p->negotiation_done) in qcom_smp2p_intr()
303 qcom_smp2p_negotiate(smp2p); in qcom_smp2p_intr()
305 if (smp2p->negotiation_done) { in qcom_smp2p_intr()
306 ack_restart = qcom_smp2p_check_ssr(smp2p); in qcom_smp2p_intr()
307 qcom_smp2p_notify_in(smp2p); in qcom_smp2p_intr()
310 qcom_smp2p_do_ssr_ack(smp2p); in qcom_smp2p_intr()
380 static int qcom_smp2p_inbound_entry(struct qcom_smp2p *smp2p, in qcom_smp2p_inbound_entry() argument
386 dev_err(smp2p->dev, "failed to add irq_domain\n"); in qcom_smp2p_inbound_entry()
408 qcom_smp2p_kick(entry->smp2p); in smp2p_update_bits()
417 static int qcom_smp2p_outbound_entry(struct qcom_smp2p *smp2p, in qcom_smp2p_outbound_entry() argument
421 struct smp2p_smem_item *out = smp2p->out; in qcom_smp2p_outbound_entry()
435 dev_err(smp2p->dev, "failed to register qcom_smem_state\n"); in qcom_smp2p_outbound_entry()
442 static int qcom_smp2p_alloc_outbound_item(struct qcom_smp2p *smp2p) in qcom_smp2p_alloc_outbound_item() argument
445 unsigned smem_id = smp2p->smem_items[SMP2P_OUTBOUND]; in qcom_smp2p_alloc_outbound_item()
446 unsigned pid = smp2p->remote_pid; in qcom_smp2p_alloc_outbound_item()
452 dev_err(smp2p->dev, in qcom_smp2p_alloc_outbound_item()
459 dev_err(smp2p->dev, "Unable to acquire local smp2p item\n"); in qcom_smp2p_alloc_outbound_item()
465 out->local_pid = smp2p->local_pid; in qcom_smp2p_alloc_outbound_item()
466 out->remote_pid = smp2p->remote_pid; in qcom_smp2p_alloc_outbound_item()
478 qcom_smp2p_kick(smp2p); in qcom_smp2p_alloc_outbound_item()
480 smp2p->out = out; in qcom_smp2p_alloc_outbound_item()
485 static int smp2p_parse_ipc(struct qcom_smp2p *smp2p) in smp2p_parse_ipc() argument
488 struct device *dev = smp2p->dev; in smp2p_parse_ipc()
498 smp2p->ipc_regmap = syscon_node_to_regmap(syscon); in smp2p_parse_ipc()
500 if (IS_ERR(smp2p->ipc_regmap)) in smp2p_parse_ipc()
501 return PTR_ERR(smp2p->ipc_regmap); in smp2p_parse_ipc()
504 ret = of_property_read_u32_index(dev->of_node, key, 1, &smp2p->ipc_offset); in smp2p_parse_ipc()
510 ret = of_property_read_u32_index(dev->of_node, key, 2, &smp2p->ipc_bit); in smp2p_parse_ipc()
523 struct qcom_smp2p *smp2p; in qcom_smp2p_probe() local
528 smp2p = devm_kzalloc(&pdev->dev, sizeof(*smp2p), GFP_KERNEL); in qcom_smp2p_probe()
529 if (!smp2p) in qcom_smp2p_probe()
532 smp2p->dev = &pdev->dev; in qcom_smp2p_probe()
533 INIT_LIST_HEAD(&smp2p->inbound); in qcom_smp2p_probe()
534 INIT_LIST_HEAD(&smp2p->outbound); in qcom_smp2p_probe()
536 platform_set_drvdata(pdev, smp2p); in qcom_smp2p_probe()
540 smp2p->smem_items, 2); in qcom_smp2p_probe()
545 ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->local_pid); in qcom_smp2p_probe()
550 ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->remote_pid); in qcom_smp2p_probe()
558 smp2p->mbox_client.dev = &pdev->dev; in qcom_smp2p_probe()
559 smp2p->mbox_client.knows_txdone = true; in qcom_smp2p_probe()
560 smp2p->mbox_chan = mbox_request_channel(&smp2p->mbox_client, 0); in qcom_smp2p_probe()
561 if (IS_ERR(smp2p->mbox_chan)) { in qcom_smp2p_probe()
562 if (PTR_ERR(smp2p->mbox_chan) != -ENODEV) in qcom_smp2p_probe()
563 return PTR_ERR(smp2p->mbox_chan); in qcom_smp2p_probe()
565 smp2p->mbox_chan = NULL; in qcom_smp2p_probe()
567 ret = smp2p_parse_ipc(smp2p); in qcom_smp2p_probe()
572 ret = qcom_smp2p_alloc_outbound_item(smp2p); in qcom_smp2p_probe()
584 entry->smp2p = smp2p; in qcom_smp2p_probe()
594 ret = qcom_smp2p_inbound_entry(smp2p, entry, node); in qcom_smp2p_probe()
600 list_add(&entry->node, &smp2p->inbound); in qcom_smp2p_probe()
602 ret = qcom_smp2p_outbound_entry(smp2p, entry, node); in qcom_smp2p_probe()
608 list_add(&entry->node, &smp2p->outbound); in qcom_smp2p_probe()
613 qcom_smp2p_kick(smp2p); in qcom_smp2p_probe()
618 "smp2p", (void *)smp2p); in qcom_smp2p_probe()
645 list_for_each_entry(entry, &smp2p->inbound, node) in qcom_smp2p_probe()
648 list_for_each_entry(entry, &smp2p->outbound, node) in qcom_smp2p_probe()
651 smp2p->out->valid_entries = 0; in qcom_smp2p_probe()
654 mbox_free_channel(smp2p->mbox_chan); in qcom_smp2p_probe()
665 struct qcom_smp2p *smp2p = platform_get_drvdata(pdev); in qcom_smp2p_remove() local
670 list_for_each_entry(entry, &smp2p->inbound, node) in qcom_smp2p_remove()
673 list_for_each_entry(entry, &smp2p->outbound, node) in qcom_smp2p_remove()
676 mbox_free_channel(smp2p->mbox_chan); in qcom_smp2p_remove()
678 smp2p->out->valid_entries = 0; in qcom_smp2p_remove()