Lines Matching full:smsm
62 * struct qcom_smsm - smsm driver context
63 * @dev: smsm device pointer
95 * @smsm: back-reference to driver context
106 struct qcom_smsm *smsm; member
132 * @data: smsm context pointer
141 struct qcom_smsm *smsm = data; in smsm_update_bits() local
149 spin_lock_irqsave(&smsm->lock, flags); in smsm_update_bits()
152 val = orig = readl(smsm->local_state); in smsm_update_bits()
159 spin_unlock_irqrestore(&smsm->lock, flags); in smsm_update_bits()
164 writel(val, smsm->local_state); in smsm_update_bits()
165 spin_unlock_irqrestore(&smsm->lock, flags); in smsm_update_bits()
171 for (host = 0; host < smsm->num_hosts; host++) { in smsm_update_bits()
172 hostp = &smsm->hosts[host]; in smsm_update_bits()
174 val = readl(smsm->subscription + host); in smsm_update_bits()
191 * smsm_intr() - cascading IRQ handler for SMSM
240 struct qcom_smsm *smsm = entry->smsm; in smsm_mask_irq() local
244 val = readl(entry->subscription + smsm->local_host); in smsm_mask_irq()
246 writel(val, entry->subscription + smsm->local_host); in smsm_mask_irq()
263 struct qcom_smsm *smsm = entry->smsm; in smsm_unmask_irq() local
275 val = readl(entry->subscription + smsm->local_host); in smsm_unmask_irq()
277 writel(val, entry->subscription + smsm->local_host); in smsm_unmask_irq()
324 .name = "smsm",
357 * @smsm: smsm driver context
363 static int smsm_parse_ipc(struct qcom_smsm *smsm, unsigned host_id) in smsm_parse_ipc() argument
366 struct device_node *node = smsm->dev->of_node; in smsm_parse_ipc()
367 struct smsm_host *host = &smsm->hosts[host_id]; in smsm_parse_ipc()
383 dev_err(smsm->dev, "no offset in %s\n", key); in smsm_parse_ipc()
389 dev_err(smsm->dev, "no bit in %s\n", key); in smsm_parse_ipc()
398 * @smsm: smsm driver context
402 static int smsm_inbound_entry(struct qcom_smsm *smsm, in smsm_inbound_entry() argument
411 dev_err(smsm->dev, "failed to parse smsm interrupt\n"); in smsm_inbound_entry()
415 ret = devm_request_threaded_irq(smsm->dev, irq, in smsm_inbound_entry()
418 "smsm", (void *)entry); in smsm_inbound_entry()
420 dev_err(smsm->dev, "failed to request interrupt\n"); in smsm_inbound_entry()
426 dev_err(smsm->dev, "failed to add irq_domain\n"); in smsm_inbound_entry()
435 * @smsm: smsm driver context
444 static int smsm_get_size_info(struct qcom_smsm *smsm) in smsm_get_size_info() argument
457 dev_err(smsm->dev, "unable to retrieve smsm size info\n"); in smsm_get_size_info()
460 dev_warn(smsm->dev, "no smsm size info, using defaults\n"); in smsm_get_size_info()
461 smsm->num_entries = SMSM_DEFAULT_NUM_ENTRIES; in smsm_get_size_info()
462 smsm->num_hosts = SMSM_DEFAULT_NUM_HOSTS; in smsm_get_size_info()
466 smsm->num_entries = info->num_entries; in smsm_get_size_info()
467 smsm->num_hosts = info->num_hosts; in smsm_get_size_info()
469 dev_dbg(smsm->dev, in smsm_get_size_info()
470 "found custom size of smsm: %d entries %d hosts\n", in smsm_get_size_info()
471 smsm->num_entries, smsm->num_hosts); in smsm_get_size_info()
481 struct qcom_smsm *smsm; in qcom_smsm_probe() local
488 smsm = devm_kzalloc(&pdev->dev, sizeof(*smsm), GFP_KERNEL); in qcom_smsm_probe()
489 if (!smsm) in qcom_smsm_probe()
491 smsm->dev = &pdev->dev; in qcom_smsm_probe()
492 spin_lock_init(&smsm->lock); in qcom_smsm_probe()
494 ret = smsm_get_size_info(smsm); in qcom_smsm_probe()
498 smsm->entries = devm_kcalloc(&pdev->dev, in qcom_smsm_probe()
499 smsm->num_entries, in qcom_smsm_probe()
502 if (!smsm->entries) in qcom_smsm_probe()
505 smsm->hosts = devm_kcalloc(&pdev->dev, in qcom_smsm_probe()
506 smsm->num_hosts, in qcom_smsm_probe()
509 if (!smsm->hosts) in qcom_smsm_probe()
523 &smsm->local_host); in qcom_smsm_probe()
526 for (id = 0; id < smsm->num_hosts; id++) { in qcom_smsm_probe()
527 ret = smsm_parse_ipc(smsm, id); in qcom_smsm_probe()
532 /* Acquire the main SMSM state vector */ in qcom_smsm_probe()
534 smsm->num_entries * sizeof(u32)); in qcom_smsm_probe()
548 size = smsm->num_entries * smsm->num_hosts * sizeof(u32); in qcom_smsm_probe()
551 dev_err(&pdev->dev, "unable to allocate smsm interrupt mask\n"); in qcom_smsm_probe()
563 smsm->local_state = states + smsm->local_host; in qcom_smsm_probe()
564 smsm->subscription = intr_mask + smsm->local_host * smsm->num_hosts; in qcom_smsm_probe()
567 smsm->state = qcom_smem_state_register(local_node, &smsm_state_ops, smsm); in qcom_smsm_probe()
568 if (IS_ERR(smsm->state)) { in qcom_smsm_probe()
569 dev_err(smsm->dev, "failed to register qcom_smem_state\n"); in qcom_smsm_probe()
570 ret = PTR_ERR(smsm->state); in qcom_smsm_probe()
580 if (ret || id >= smsm->num_entries) { in qcom_smsm_probe()
586 entry = &smsm->entries[id]; in qcom_smsm_probe()
588 entry->smsm = smsm; in qcom_smsm_probe()
592 entry->subscription = intr_mask + id * smsm->num_hosts; in qcom_smsm_probe()
593 writel(0, entry->subscription + smsm->local_host); in qcom_smsm_probe()
595 ret = smsm_inbound_entry(smsm, entry, node); in qcom_smsm_probe()
600 platform_set_drvdata(pdev, smsm); in qcom_smsm_probe()
607 for (id = 0; id < smsm->num_entries; id++) in qcom_smsm_probe()
608 if (smsm->entries[id].domain) in qcom_smsm_probe()
609 irq_domain_remove(smsm->entries[id].domain); in qcom_smsm_probe()
611 qcom_smem_state_unregister(smsm->state); in qcom_smsm_probe()
619 struct qcom_smsm *smsm = platform_get_drvdata(pdev); in qcom_smsm_remove() local
622 for (id = 0; id < smsm->num_entries; id++) in qcom_smsm_remove()
623 if (smsm->entries[id].domain) in qcom_smsm_remove()
624 irq_domain_remove(smsm->entries[id].domain); in qcom_smsm_remove()
626 qcom_smem_state_unregister(smsm->state); in qcom_smsm_remove()
632 { .compatible = "qcom,smsm" },
641 .name = "qcom-smsm",