Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 627b033c authored by Chris Lew's avatar Chris Lew
Browse files

soc: qcom: smem: Add support to get physical addr



An SMEM item can be handed off to a DMA engine. Add a function to
retrieve the physical address of an smem item.

Change-Id: Ic4137700ad308a5da13aa943e564102f547fadb2
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 83569191
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -647,6 +647,34 @@ int qcom_smem_get_free_space(unsigned host)
}
EXPORT_SYMBOL(qcom_smem_get_free_space);

/**
 * qcom_smem_virt_to_phys() - Convert SMEM address to physical address.
 * @smem_address	Address of SMEM item (returned by qcom_smem_get())

 * This function should only be used if an SMEM item needs to be handed off
 * to a DMA engine.
 */
phys_addr_t qcom_smem_virt_to_phys(void *addr)
{
	phys_addr_t phys_addr = 0;
	struct smem_region *area;
	void *end;
	int i;

	if (!__smem)
		return phys_addr;

	for (i = 0; i < __smem->num_regions; i++) {
		area = &__smem->regions[i];
		end = area->virt_base + area->size;
		if (addr >= area->virt_base && addr < end)
			phys_addr = addr - area->virt_base + area->aux_base;
	}

	return phys_addr;
}
EXPORT_SYMBOL(qcom_smem_virt_to_phys);

static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
{
	struct smem_header *header;
+3 −0
Original line number Diff line number Diff line
#ifndef __QCOM_SMEM_H__
#define __QCOM_SMEM_H__

#include <linux/types.h>

#define QCOM_SMEM_HOST_ANY -1

int qcom_smem_alloc(unsigned host, unsigned item, size_t size);
void *qcom_smem_get(unsigned host, unsigned item, size_t *size);

int qcom_smem_get_free_space(unsigned host);
phys_addr_t qcom_smem_virt_to_phys(void *addr);

#endif