Lines Matching +full:entry +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
26 * of a single 32-bit value between two processors. Each value has a single
33 * processor. By using two separate SMEM items that are single-reader and
34 * single-writer, SMP2P does not require any remote locking mechanisms.
37 * GPIO for each outbound entry and a virtual interrupt controller for each
38 * inbound entry.
52 * struct smp2p_smem_item - in memory communication structure
54 * @version: version - must be 1
55 * @features: features flag - currently unused
58 * @total_entries: number of entries - always SMP2P_MAX_ENTRY
62 * @entries.name: name of the entry
63 * @entries.value: content of the entry
76 u8 name[SMP2P_MAX_ENTRY_NAME]; member
82 * struct smp2p_entry - driver context matching one entry
83 * @node: list entry to keep track of allocated entries
85 * @name: name of the entry, to match against smp2p_smem_item
86 * @value: pointer to smp2p_smem_item entry value
93 * @lock: spinlock to protect read-modify-write of the value
99 const char *name; member
117 * struct qcom_smp2p - device driver context
165 #include "trace-smp2p.h"
172 if (smp2p->mbox_chan) { in qcom_smp2p_kick()
173 mbox_send_message(smp2p->mbox_chan, NULL); in qcom_smp2p_kick()
174 mbox_client_txdone(smp2p->mbox_chan, 0); in qcom_smp2p_kick()
176 regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit)); in qcom_smp2p_kick()
182 struct smp2p_smem_item *in = smp2p->in; in qcom_smp2p_check_ssr()
185 if (!smp2p->ssr_ack_enabled) in qcom_smp2p_check_ssr()
188 restart = in->flags & BIT(SMP2P_FLAGS_RESTART_DONE_BIT); in qcom_smp2p_check_ssr()
190 return restart != smp2p->ssr_ack; in qcom_smp2p_check_ssr()
195 struct smp2p_smem_item *out = smp2p->out; in qcom_smp2p_do_ssr_ack()
198 trace_smp2p_ssr_ack(smp2p->dev); in qcom_smp2p_do_ssr_ack()
199 smp2p->ssr_ack = !smp2p->ssr_ack; in qcom_smp2p_do_ssr_ack()
201 val = out->flags & ~BIT(SMP2P_FLAGS_RESTART_ACK_BIT); in qcom_smp2p_do_ssr_ack()
202 if (smp2p->ssr_ack) in qcom_smp2p_do_ssr_ack()
204 out->flags = val; in qcom_smp2p_do_ssr_ack()
211 struct smp2p_smem_item *out = smp2p->out; in qcom_smp2p_negotiate()
212 struct smp2p_smem_item *in = smp2p->in; in qcom_smp2p_negotiate()
214 if (in->version == out->version) { in qcom_smp2p_negotiate()
215 out->features &= in->features; in qcom_smp2p_negotiate()
217 if (out->features & SMP2P_FEATURE_SSR_ACK) in qcom_smp2p_negotiate()
218 smp2p->ssr_ack_enabled = true; in qcom_smp2p_negotiate()
220 smp2p->negotiation_done = true; in qcom_smp2p_negotiate()
221 trace_smp2p_negotiate(smp2p->dev, out->features); in qcom_smp2p_negotiate()
228 struct smp2p_entry *entry; in qcom_smp2p_notify_in() local
235 in = smp2p->in; in qcom_smp2p_notify_in()
238 for (i = smp2p->valid_entries; i < in->valid_entries; i++) { in qcom_smp2p_notify_in()
239 list_for_each_entry(entry, &smp2p->inbound, node) { in qcom_smp2p_notify_in()
240 memcpy(buf, in->entries[i].name, sizeof(buf)); in qcom_smp2p_notify_in()
241 if (!strcmp(buf, entry->name)) { in qcom_smp2p_notify_in()
242 entry->value = &in->entries[i].value; in qcom_smp2p_notify_in()
247 smp2p->valid_entries = i; in qcom_smp2p_notify_in()
250 list_for_each_entry(entry, &smp2p->inbound, node) { in qcom_smp2p_notify_in()
252 if (!entry->value) in qcom_smp2p_notify_in()
255 val = readl(entry->value); in qcom_smp2p_notify_in()
257 status = val ^ entry->last_value; in qcom_smp2p_notify_in()
258 entry->last_value = val; in qcom_smp2p_notify_in()
260 trace_smp2p_notify_in(entry, status, val); in qcom_smp2p_notify_in()
262 /* No changes of this entry? */ in qcom_smp2p_notify_in()
266 for_each_set_bit(i, entry->irq_enabled, 32) { in qcom_smp2p_notify_in()
270 if ((val & BIT(i) && test_bit(i, entry->irq_rising)) || in qcom_smp2p_notify_in()
271 (!(val & BIT(i)) && test_bit(i, entry->irq_falling))) { in qcom_smp2p_notify_in()
272 irq_pin = irq_find_mapping(entry->domain, i); in qcom_smp2p_notify_in()
280 * qcom_smp2p_intr() - interrupt handler for incoming notifications
293 unsigned int smem_id = smp2p->smem_items[SMP2P_INBOUND]; in qcom_smp2p_intr()
294 unsigned int pid = smp2p->remote_pid; in qcom_smp2p_intr()
298 in = smp2p->in; in qcom_smp2p_intr()
304 dev_err(smp2p->dev, in qcom_smp2p_intr()
309 smp2p->in = in; in qcom_smp2p_intr()
312 if (!smp2p->negotiation_done) in qcom_smp2p_intr()
315 if (smp2p->negotiation_done) { in qcom_smp2p_intr()
329 struct smp2p_entry *entry = irq_data_get_irq_chip_data(irqd); in smp2p_mask_irq() local
332 clear_bit(irq, entry->irq_enabled); in smp2p_mask_irq()
337 struct smp2p_entry *entry = irq_data_get_irq_chip_data(irqd); in smp2p_unmask_irq() local
340 set_bit(irq, entry->irq_enabled); in smp2p_unmask_irq()
345 struct smp2p_entry *entry = irq_data_get_irq_chip_data(irqd); in smp2p_set_irq_type() local
349 return -EINVAL; in smp2p_set_irq_type()
352 set_bit(irq, entry->irq_rising); in smp2p_set_irq_type()
354 clear_bit(irq, entry->irq_rising); in smp2p_set_irq_type()
357 set_bit(irq, entry->irq_falling); in smp2p_set_irq_type()
359 clear_bit(irq, entry->irq_falling); in smp2p_set_irq_type()
366 struct smp2p_entry *entry = irq_data_get_irq_chip_data(irqd); in smp2p_irq_print_chip() local
368 seq_printf(p, "%8s", dev_name(entry->smp2p->dev)); in smp2p_irq_print_chip()
372 .name = "smp2p",
383 struct smp2p_entry *entry = d->host_data; in smp2p_irq_map() local
386 irq_set_chip_data(irq, entry); in smp2p_irq_map()
399 struct smp2p_entry *entry, in qcom_smp2p_inbound_entry() argument
402 entry->domain = irq_domain_add_linear(node, 32, &smp2p_irq_ops, entry); in qcom_smp2p_inbound_entry()
403 if (!entry->domain) { in qcom_smp2p_inbound_entry()
404 dev_err(smp2p->dev, "failed to add irq_domain\n"); in qcom_smp2p_inbound_entry()
405 return -ENOMEM; in qcom_smp2p_inbound_entry()
413 struct smp2p_entry *entry = data; in smp2p_update_bits() local
418 spin_lock_irqsave(&entry->lock, flags); in smp2p_update_bits()
419 val = orig = readl(entry->value); in smp2p_update_bits()
422 writel(val, entry->value); in smp2p_update_bits()
423 spin_unlock_irqrestore(&entry->lock, flags); in smp2p_update_bits()
425 trace_smp2p_update_bits(entry, orig, val); in smp2p_update_bits()
428 qcom_smp2p_kick(entry->smp2p); in smp2p_update_bits()
438 struct smp2p_entry *entry, in qcom_smp2p_outbound_entry() argument
441 struct smp2p_smem_item *out = smp2p->out; in qcom_smp2p_outbound_entry()
444 /* Allocate an entry from the smem item */ in qcom_smp2p_outbound_entry()
445 strscpy(buf, entry->name, SMP2P_MAX_ENTRY_NAME); in qcom_smp2p_outbound_entry()
446 memcpy(out->entries[out->valid_entries].name, buf, SMP2P_MAX_ENTRY_NAME); in qcom_smp2p_outbound_entry()
448 /* Make the logical entry reference the physical value */ in qcom_smp2p_outbound_entry()
449 entry->value = &out->entries[out->valid_entries].value; in qcom_smp2p_outbound_entry()
451 out->valid_entries++; in qcom_smp2p_outbound_entry()
453 entry->state = qcom_smem_state_register(node, &smp2p_state_ops, entry); in qcom_smp2p_outbound_entry()
454 if (IS_ERR(entry->state)) { in qcom_smp2p_outbound_entry()
455 dev_err(smp2p->dev, "failed to register qcom_smem_state\n"); in qcom_smp2p_outbound_entry()
456 return PTR_ERR(entry->state); in qcom_smp2p_outbound_entry()
465 unsigned smem_id = smp2p->smem_items[SMP2P_OUTBOUND]; in qcom_smp2p_alloc_outbound_item()
466 unsigned pid = smp2p->remote_pid; in qcom_smp2p_alloc_outbound_item()
470 if (ret < 0 && ret != -EEXIST) in qcom_smp2p_alloc_outbound_item()
471 return dev_err_probe(smp2p->dev, ret, in qcom_smp2p_alloc_outbound_item()
476 dev_err(smp2p->dev, "Unable to acquire local smp2p item\n"); in qcom_smp2p_alloc_outbound_item()
481 out->magic = SMP2P_MAGIC; in qcom_smp2p_alloc_outbound_item()
482 out->local_pid = smp2p->local_pid; in qcom_smp2p_alloc_outbound_item()
483 out->remote_pid = smp2p->remote_pid; in qcom_smp2p_alloc_outbound_item()
484 out->total_entries = SMP2P_MAX_ENTRY; in qcom_smp2p_alloc_outbound_item()
485 out->valid_entries = 0; in qcom_smp2p_alloc_outbound_item()
486 out->features = SMP2P_ALL_FEATURES; in qcom_smp2p_alloc_outbound_item()
493 out->version = 1; in qcom_smp2p_alloc_outbound_item()
497 smp2p->out = out; in qcom_smp2p_alloc_outbound_item()
505 struct device *dev = smp2p->dev; in smp2p_parse_ipc()
509 syscon = of_parse_phandle(dev->of_node, "qcom,ipc", 0); in smp2p_parse_ipc()
512 return -ENODEV; in smp2p_parse_ipc()
515 smp2p->ipc_regmap = syscon_node_to_regmap(syscon); in smp2p_parse_ipc()
517 if (IS_ERR(smp2p->ipc_regmap)) in smp2p_parse_ipc()
518 return PTR_ERR(smp2p->ipc_regmap); in smp2p_parse_ipc()
521 ret = of_property_read_u32_index(dev->of_node, key, 1, &smp2p->ipc_offset); in smp2p_parse_ipc()
524 return -EINVAL; in smp2p_parse_ipc()
527 ret = of_property_read_u32_index(dev->of_node, key, 2, &smp2p->ipc_bit); in smp2p_parse_ipc()
530 return -EINVAL; in smp2p_parse_ipc()
538 struct smp2p_entry *entry; in qcom_smp2p_probe() local
544 smp2p = devm_kzalloc(&pdev->dev, sizeof(*smp2p), GFP_KERNEL); in qcom_smp2p_probe()
546 return -ENOMEM; in qcom_smp2p_probe()
548 smp2p->dev = &pdev->dev; in qcom_smp2p_probe()
549 INIT_LIST_HEAD(&smp2p->inbound); in qcom_smp2p_probe()
550 INIT_LIST_HEAD(&smp2p->outbound); in qcom_smp2p_probe()
555 ret = of_property_read_u32_array(pdev->dev.of_node, key, in qcom_smp2p_probe()
556 smp2p->smem_items, 2); in qcom_smp2p_probe()
560 key = "qcom,local-pid"; in qcom_smp2p_probe()
561 ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->local_pid); in qcom_smp2p_probe()
565 key = "qcom,remote-pid"; in qcom_smp2p_probe()
566 ret = of_property_read_u32(pdev->dev.of_node, key, &smp2p->remote_pid); in qcom_smp2p_probe()
574 smp2p->mbox_client.dev = &pdev->dev; in qcom_smp2p_probe()
575 smp2p->mbox_client.knows_txdone = true; in qcom_smp2p_probe()
576 smp2p->mbox_chan = mbox_request_channel(&smp2p->mbox_client, 0); in qcom_smp2p_probe()
577 if (IS_ERR(smp2p->mbox_chan)) { in qcom_smp2p_probe()
578 if (PTR_ERR(smp2p->mbox_chan) != -ENODEV) in qcom_smp2p_probe()
579 return PTR_ERR(smp2p->mbox_chan); in qcom_smp2p_probe()
581 smp2p->mbox_chan = NULL; in qcom_smp2p_probe()
592 for_each_available_child_of_node_scoped(pdev->dev.of_node, node) { in qcom_smp2p_probe()
593 entry = devm_kzalloc(&pdev->dev, sizeof(*entry), GFP_KERNEL); in qcom_smp2p_probe()
594 if (!entry) { in qcom_smp2p_probe()
595 ret = -ENOMEM; in qcom_smp2p_probe()
599 entry->smp2p = smp2p; in qcom_smp2p_probe()
600 spin_lock_init(&entry->lock); in qcom_smp2p_probe()
602 ret = of_property_read_string(node, "qcom,entry-name", &entry->name); in qcom_smp2p_probe()
606 if (of_property_read_bool(node, "interrupt-controller")) { in qcom_smp2p_probe()
607 ret = qcom_smp2p_inbound_entry(smp2p, entry, node); in qcom_smp2p_probe()
611 list_add(&entry->node, &smp2p->inbound); in qcom_smp2p_probe()
613 ret = qcom_smp2p_outbound_entry(smp2p, entry, node); in qcom_smp2p_probe()
617 list_add(&entry->node, &smp2p->outbound); in qcom_smp2p_probe()
624 ret = devm_request_threaded_irq(&pdev->dev, irq, in qcom_smp2p_probe()
629 dev_err(&pdev->dev, "failed to request interrupt\n"); in qcom_smp2p_probe()
642 device_set_wakeup_capable(&pdev->dev, true); in qcom_smp2p_probe()
644 ret = dev_pm_set_wake_irq(&pdev->dev, irq); in qcom_smp2p_probe()
651 dev_pm_clear_wake_irq(&pdev->dev); in qcom_smp2p_probe()
654 list_for_each_entry(entry, &smp2p->inbound, node) in qcom_smp2p_probe()
655 irq_domain_remove(entry->domain); in qcom_smp2p_probe()
657 list_for_each_entry(entry, &smp2p->outbound, node) in qcom_smp2p_probe()
658 qcom_smem_state_unregister(entry->state); in qcom_smp2p_probe()
660 smp2p->out->valid_entries = 0; in qcom_smp2p_probe()
663 mbox_free_channel(smp2p->mbox_chan); in qcom_smp2p_probe()
668 dev_err(&pdev->dev, "failed to read %s\n", key); in qcom_smp2p_probe()
669 return -EINVAL; in qcom_smp2p_probe()
675 struct smp2p_entry *entry; in qcom_smp2p_remove() local
677 dev_pm_clear_wake_irq(&pdev->dev); in qcom_smp2p_remove()
679 list_for_each_entry(entry, &smp2p->inbound, node) in qcom_smp2p_remove()
680 irq_domain_remove(entry->domain); in qcom_smp2p_remove()
682 list_for_each_entry(entry, &smp2p->outbound, node) in qcom_smp2p_remove()
683 qcom_smem_state_unregister(entry->state); in qcom_smp2p_remove()
685 mbox_free_channel(smp2p->mbox_chan); in qcom_smp2p_remove()
687 smp2p->out->valid_entries = 0; in qcom_smp2p_remove()
700 .name = "qcom_smp2p",