Lines Matching refs:smem
399 static int qcom_smem_alloc_private(struct qcom_smem *smem, in qcom_smem_alloc_private() argument
435 dev_err(smem->dev, "Out of memory\n"); in qcom_smem_alloc_private()
455 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_alloc_private()
461 static int qcom_smem_alloc_global(struct qcom_smem *smem, in qcom_smem_alloc_global() argument
468 header = smem->regions[0].virt_base; in qcom_smem_alloc_global()
543 static void *qcom_smem_get_global(struct qcom_smem *smem, in qcom_smem_get_global() argument
555 header = smem->regions[0].virt_base; in qcom_smem_get_global()
562 for (i = 0; i < smem->num_regions; i++) { in qcom_smem_get_global()
563 region = &smem->regions[i]; in qcom_smem_get_global()
582 static void *qcom_smem_get_private(struct qcom_smem *smem, in qcom_smem_get_private() argument
666 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_get_private()
835 static int qcom_smem_get_sbl_version(struct qcom_smem *smem) in qcom_smem_get_sbl_version() argument
840 header = smem->regions[0].virt_base; in qcom_smem_get_sbl_version()
846 static struct smem_ptable *qcom_smem_get_ptable(struct qcom_smem *smem) in qcom_smem_get_ptable() argument
851 ptable = smem->ptable; in qcom_smem_get_ptable()
857 dev_err(smem->dev, in qcom_smem_get_ptable()
864 static u32 qcom_smem_get_item_count(struct qcom_smem *smem) in qcom_smem_get_item_count() argument
869 ptable = qcom_smem_get_ptable(smem); in qcom_smem_get_item_count()
886 qcom_smem_partition_header(struct qcom_smem *smem, in qcom_smem_partition_header() argument
893 phys_addr = smem->regions[0].aux_base + le32_to_cpu(entry->offset); in qcom_smem_partition_header()
894 header = devm_ioremap_wc(smem->dev, phys_addr, le32_to_cpu(entry->size)); in qcom_smem_partition_header()
900 dev_err(smem->dev, "bad partition magic %4ph\n", header->magic); in qcom_smem_partition_header()
905 dev_err(smem->dev, "bad host0 (%hu != %hu)\n", in qcom_smem_partition_header()
910 dev_err(smem->dev, "bad host1 (%hu != %hu)\n", in qcom_smem_partition_header()
917 dev_err(smem->dev, "bad partition size (%u != %u)\n", in qcom_smem_partition_header()
923 dev_err(smem->dev, "bad partition free uncached (%u > %u)\n", in qcom_smem_partition_header()
931 static int qcom_smem_set_global_partition(struct qcom_smem *smem) in qcom_smem_set_global_partition() argument
939 if (smem->global_partition.virt_base) { in qcom_smem_set_global_partition()
940 dev_err(smem->dev, "Already found the global partition\n"); in qcom_smem_set_global_partition()
944 ptable = qcom_smem_get_ptable(smem); in qcom_smem_set_global_partition()
965 dev_err(smem->dev, "Missing entry for global partition\n"); in qcom_smem_set_global_partition()
969 header = qcom_smem_partition_header(smem, entry, in qcom_smem_set_global_partition()
974 smem->global_partition.virt_base = (void __iomem *)header; in qcom_smem_set_global_partition()
975 smem->global_partition.phys_base = smem->regions[0].aux_base + in qcom_smem_set_global_partition()
977 smem->global_partition.size = le32_to_cpu(entry->size); in qcom_smem_set_global_partition()
978 smem->global_partition.cacheline = le32_to_cpu(entry->cacheline); in qcom_smem_set_global_partition()
984 qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host) in qcom_smem_enumerate_partitions() argument
993 ptable = qcom_smem_get_ptable(smem); in qcom_smem_enumerate_partitions()
1014 dev_err(smem->dev, "bad host %u\n", remote_host); in qcom_smem_enumerate_partitions()
1018 if (smem->partitions[remote_host].virt_base) { in qcom_smem_enumerate_partitions()
1019 dev_err(smem->dev, "duplicate host %u\n", remote_host); in qcom_smem_enumerate_partitions()
1023 header = qcom_smem_partition_header(smem, entry, host0, host1); in qcom_smem_enumerate_partitions()
1027 smem->partitions[remote_host].virt_base = (void __iomem *)header; in qcom_smem_enumerate_partitions()
1028 smem->partitions[remote_host].phys_base = smem->regions[0].aux_base + in qcom_smem_enumerate_partitions()
1030 smem->partitions[remote_host].size = le32_to_cpu(entry->size); in qcom_smem_enumerate_partitions()
1031 smem->partitions[remote_host].cacheline = le32_to_cpu(entry->cacheline); in qcom_smem_enumerate_partitions()
1037 static int qcom_smem_map_toc(struct qcom_smem *smem, struct smem_region *region) in qcom_smem_map_toc() argument
1042 region->virt_base = devm_ioremap_wc(smem->dev, region->aux_base, SZ_4K); in qcom_smem_map_toc()
1045 smem->ptable = devm_ioremap_wc(smem->dev, ptable_start, SZ_4K); in qcom_smem_map_toc()
1047 if (!region->virt_base || !smem->ptable) in qcom_smem_map_toc()
1053 static int qcom_smem_map_global(struct qcom_smem *smem, u32 size) in qcom_smem_map_global() argument
1057 phys_addr = smem->regions[0].aux_base; in qcom_smem_map_global()
1059 smem->regions[0].size = size; in qcom_smem_map_global()
1060 smem->regions[0].virt_base = devm_ioremap_wc(smem->dev, phys_addr, size); in qcom_smem_map_global()
1062 if (!smem->regions[0].virt_base) in qcom_smem_map_global()
1068 static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name, in qcom_smem_resolve_mem() argument
1071 struct device *dev = smem->dev; in qcom_smem_resolve_mem()
1097 struct qcom_smem *smem; in qcom_smem_probe() local
1110 smem = devm_kzalloc(&pdev->dev, struct_size(smem, regions, num_regions), in qcom_smem_probe()
1112 if (!smem) in qcom_smem_probe()
1115 smem->dev = &pdev->dev; in qcom_smem_probe()
1116 smem->num_regions = num_regions; in qcom_smem_probe()
1120 smem->regions[0].aux_base = rmem->base; in qcom_smem_probe()
1121 smem->regions[0].size = rmem->size; in qcom_smem_probe()
1127 ret = qcom_smem_resolve_mem(smem, "memory-region", &smem->regions[0]); in qcom_smem_probe()
1133 ret = qcom_smem_resolve_mem(smem, "qcom,rpm-msg-ram", &smem->regions[1]); in qcom_smem_probe()
1139 ret = qcom_smem_map_toc(smem, &smem->regions[0]); in qcom_smem_probe()
1144 smem->regions[i].virt_base = devm_ioremap_wc(&pdev->dev, in qcom_smem_probe()
1145 smem->regions[i].aux_base, in qcom_smem_probe()
1146 smem->regions[i].size); in qcom_smem_probe()
1147 if (!smem->regions[i].virt_base) { in qcom_smem_probe()
1148 dev_err(&pdev->dev, "failed to remap %pa\n", &smem->regions[i].aux_base); in qcom_smem_probe()
1153 header = smem->regions[0].virt_base; in qcom_smem_probe()
1167 smem->hwlock = hwspin_lock_request_specific(hwlock_id); in qcom_smem_probe()
1168 if (!smem->hwlock) in qcom_smem_probe()
1171 ret = hwspin_lock_timeout_irqsave(smem->hwlock, HWSPINLOCK_TIMEOUT, &flags); in qcom_smem_probe()
1175 hwspin_unlock_irqrestore(smem->hwlock, &flags); in qcom_smem_probe()
1177 version = qcom_smem_get_sbl_version(smem); in qcom_smem_probe()
1183 devm_iounmap(smem->dev, smem->regions[0].virt_base); in qcom_smem_probe()
1186 ret = qcom_smem_set_global_partition(smem); in qcom_smem_probe()
1189 smem->item_count = qcom_smem_get_item_count(smem); in qcom_smem_probe()
1192 qcom_smem_map_global(smem, size); in qcom_smem_probe()
1193 smem->item_count = SMEM_ITEM_COUNT; in qcom_smem_probe()
1201 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS); in qcom_smem_probe()
1205 __smem = smem; in qcom_smem_probe()
1207 smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo", in qcom_smem_probe()
1210 if (IS_ERR(smem->socinfo)) in qcom_smem_probe()