dsp: support mdf memory share cmd
Add support for MultiDSP framework (MDF) memory share command in q6core driver. Change-Id: Iff0da10fe835f1fce50d2725960ded5c96237955 Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
This commit is contained in:
637
dsp/msm_mdf.c
Normal file
637
dsp/msm_mdf.c
Normal file
@@ -0,0 +1,637 @@
|
||||
/*
|
||||
* Copyright (c) 2018, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/dma-buf.h>
|
||||
#include <linux/iommu.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/ion_kernel.h>
|
||||
#include <linux/msm_ion.h>
|
||||
#include <dsp/msm_audio_ion.h>
|
||||
#include <ipc/apr.h>
|
||||
#include <dsp/msm_mdf.h>
|
||||
#include <asm/dma-iommu.h>
|
||||
#include <soc/qcom/secure_buffer.h>
|
||||
#include <soc/qcom/subsystem_notif.h>
|
||||
#include <soc/qcom/subsystem_restart.h>
|
||||
#include <dsp/q6audio-v2.h>
|
||||
#include <dsp/q6core.h>
|
||||
|
||||
#define VMID_SSC_Q6 5
|
||||
#define VMID_LPASS 6
|
||||
#define VMID_MSS_MSA 15
|
||||
#define VMID_CDSP 8
|
||||
|
||||
#define MSM_MDF_PROBED (1 << 0)
|
||||
#define MSM_MDF_INITIALIZED (1 << 1)
|
||||
#define MSM_MDF_MEM_ALLOCATED (1 << 2)
|
||||
#define MSM_MDF_MEM_MAPPED (1 << 3)
|
||||
#define MSM_MDF_MEM_PERMISSION (1 << 4) /* 0 - HLOS, 1 - Subsys */
|
||||
|
||||
/* TODO: Update IOVA range for subsys SMMUs */
|
||||
#define MSM_MDF_IOVA_START 0x80000000
|
||||
#define MSM_MDF_IOVA_LEN 0x800000
|
||||
|
||||
#define MSM_MDF_SMMU_SID_OFFSET 32
|
||||
|
||||
#define ADSP_STATE_READY_TIMEOUT_MS 3000
|
||||
|
||||
enum {
|
||||
SUBSYS_ADSP, /* Audio DSP must have index 0 */
|
||||
SUBSYS_SCC, /* Sensor DSP */
|
||||
SUBSYS_MSS, /* Modem DSP */
|
||||
SUBSYS_CDSP, /* Compute DSP */
|
||||
SUBSYS_MAX,
|
||||
};
|
||||
|
||||
struct msm_mdf_mem {
|
||||
struct device *dev;
|
||||
uint8_t device_status;
|
||||
uint32_t map_handle;
|
||||
struct dma_buf *dma_buf;
|
||||
dma_addr_t dma_addr;
|
||||
size_t size;
|
||||
void *va;
|
||||
};
|
||||
|
||||
static struct msm_mdf_mem mdf_mem_data = {NULL,};
|
||||
|
||||
struct msm_mdf_smmu {
|
||||
bool enabled;
|
||||
char *subsys;
|
||||
int vmid;
|
||||
uint32_t proc_id;
|
||||
struct device *cb_dev;
|
||||
uint8_t device_status;
|
||||
uint64_t sid;
|
||||
struct dma_iommu_mapping *mapping;
|
||||
dma_addr_t pa;
|
||||
size_t pa_len;
|
||||
};
|
||||
|
||||
static struct msm_mdf_smmu mdf_smmu_data[SUBSYS_MAX] = {
|
||||
{
|
||||
.subsys = "adsp",
|
||||
.vmid = VMID_LPASS,
|
||||
},
|
||||
{
|
||||
.subsys = "dsps",
|
||||
.vmid = VMID_SSC_Q6,
|
||||
.proc_id = AVS_MDF_SSC_PROC_ID,
|
||||
},
|
||||
{
|
||||
.subsys = "modem",
|
||||
.vmid = VMID_MSS_MSA,
|
||||
.proc_id = AVS_MDF_MDSP_PROC_ID,
|
||||
},
|
||||
{
|
||||
.subsys = "cdsp",
|
||||
.vmid = VMID_CDSP,
|
||||
.proc_id = AVS_MDF_CDSP_PROC_ID,
|
||||
},
|
||||
};
|
||||
|
||||
static void *ssr_handle;
|
||||
|
||||
static inline uint64_t buf_page_start(uint64_t buf)
|
||||
{
|
||||
uint64_t start = (uint64_t) buf & PAGE_MASK;
|
||||
return start;
|
||||
}
|
||||
|
||||
static inline uint64_t buf_page_offset(uint64_t buf)
|
||||
{
|
||||
uint64_t offset = (uint64_t) buf & (PAGE_SIZE - 1);
|
||||
return offset;
|
||||
}
|
||||
|
||||
static inline int buf_num_pages(uint64_t buf, ssize_t len)
|
||||
{
|
||||
uint64_t start = buf_page_start(buf) >> PAGE_SHIFT;
|
||||
uint64_t end = (((uint64_t) buf + len - 1) & PAGE_MASK) >> PAGE_SHIFT;
|
||||
int nPages = end - start + 1;
|
||||
return nPages;
|
||||
}
|
||||
|
||||
static inline uint64_t buf_page_size(uint32_t size)
|
||||
{
|
||||
uint64_t sz = (size + (PAGE_SIZE - 1)) & PAGE_MASK;
|
||||
|
||||
return sz > PAGE_SIZE ? sz : PAGE_SIZE;
|
||||
}
|
||||
|
||||
static inline void *uint64_to_ptr(uint64_t addr)
|
||||
{
|
||||
void *ptr = (void *)((uintptr_t)addr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static inline uint64_t ptr_to_uint64(void *ptr)
|
||||
{
|
||||
uint64_t addr = (uint64_t)((uintptr_t)ptr);
|
||||
return addr;
|
||||
}
|
||||
|
||||
static int msm_mdf_dma_buf_map(struct msm_mdf_mem *mem,
|
||||
struct msm_mdf_smmu *smmu)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (!smmu)
|
||||
return -EINVAL;
|
||||
if (smmu->device_status & MSM_MDF_MEM_MAPPED)
|
||||
return 0;
|
||||
if (smmu->enabled) {
|
||||
if (smmu->cb_dev == NULL) {
|
||||
pr_err("%s: cb device is not initialized\n",
|
||||
__func__);
|
||||
/* Retry if LPASS cb device is not ready
|
||||
* from audio ION during probing.
|
||||
*/
|
||||
if (!strcmp("adsp", smmu->subsys)) {
|
||||
rc = msm_audio_ion_get_smmu_info(&smmu->cb_dev,
|
||||
&smmu->sid);
|
||||
if (rc) {
|
||||
pr_err("%s: msm_audio_ion_get_smmu_info failed, rc = %d\n",
|
||||
__func__, rc);
|
||||
goto err;
|
||||
}
|
||||
} else
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
smmu->pa = dma_map_single(smmu->cb_dev, mem->va,
|
||||
mem->size, DMA_BIDIRECTIONAL);
|
||||
if (dma_mapping_error(smmu->cb_dev, smmu->pa)) {
|
||||
rc = -ENOMEM;
|
||||
pr_err("%s: failed to map single, rc = %d\n",
|
||||
__func__, rc);
|
||||
goto err;
|
||||
}
|
||||
smmu->pa_len = mem->size;
|
||||
|
||||
/* Append the SMMU SID information to the IOVA address */
|
||||
if (smmu->sid)
|
||||
smmu->pa |= smmu->sid;
|
||||
} else {
|
||||
smmu->pa = mem->dma_addr;
|
||||
smmu->pa_len = mem->size;
|
||||
}
|
||||
pr_err("%s: pa=%pa, pa_len=%zd\n", __func__,
|
||||
&smmu->pa, smmu->pa_len);
|
||||
|
||||
smmu->device_status |= MSM_MDF_MEM_MAPPED;
|
||||
|
||||
return 0;
|
||||
err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_mdf_alloc_dma_buf(struct msm_mdf_mem *mem)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (!mem)
|
||||
return -EINVAL;
|
||||
|
||||
if (mem->device_status & MSM_MDF_MEM_ALLOCATED)
|
||||
return 0;
|
||||
|
||||
if (mem->dev == NULL) {
|
||||
pr_err("%s: device is not initialized\n",
|
||||
__func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
mem->va = dma_alloc_coherent(mem->dev, mem->size,
|
||||
&mem->dma_addr, GFP_KERNEL);
|
||||
if (IS_ERR_OR_NULL(mem->va)) {
|
||||
pr_err("%s: failed to allocate dma memory, rc = %d\n",
|
||||
__func__, rc);
|
||||
return -ENOMEM;
|
||||
}
|
||||
mem->va = phys_to_virt(mem->dma_addr);
|
||||
mem->device_status |= MSM_MDF_MEM_ALLOCATED;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_mdf_free_dma_buf(struct msm_mdf_mem *mem)
|
||||
{
|
||||
if (!mem)
|
||||
return -EINVAL;
|
||||
|
||||
if (mem->dev == NULL) {
|
||||
pr_err("%s: device is not initialized\n",
|
||||
__func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
//dma_free_coherent(mem->dev, mem->size, mem->va,
|
||||
// mem->dma_addr);
|
||||
|
||||
mem->device_status &= ~MSM_MDF_MEM_ALLOCATED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_mdf_dma_buf_unmap(struct msm_mdf_mem *mem,
|
||||
struct msm_mdf_smmu *smmu)
|
||||
{
|
||||
if (!smmu)
|
||||
return -EINVAL;
|
||||
|
||||
if (smmu->enabled) {
|
||||
if (smmu->cb_dev == NULL) {
|
||||
pr_err("%s: cb device is not initialized\n",
|
||||
__func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
//if (smmu->pa && mem->size)
|
||||
//dma_unmap_single(smmu->cb_dev, smmu->pa,
|
||||
// mem->size, DMA_BIDIRECTIONAL);
|
||||
}
|
||||
|
||||
smmu->device_status &= ~MSM_MDF_MEM_MAPPED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_mdf_map_memory_to_subsys(struct msm_mdf_mem *mem,
|
||||
struct msm_mdf_smmu *smmu)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (!mem || !smmu)
|
||||
return -EINVAL;
|
||||
|
||||
/* Map mdf shared memory to ADSP */
|
||||
if (!strcmp("adsp", smmu->subsys)) {
|
||||
rc = q6core_map_memory_regions((phys_addr_t *)&smmu->pa,
|
||||
ADSP_MEMORY_MAP_MDF_SHMEM_4K_POOL,
|
||||
(uint32_t *)&smmu->pa_len, 1, &mem->map_handle);
|
||||
if (rc) {
|
||||
pr_err("%s: q6core_map_memory_regions failed, rc = %d\n",
|
||||
__func__, rc);
|
||||
}
|
||||
} else {
|
||||
if (mem->map_handle) {
|
||||
/* Map mdf shared memory to remote DSPs */
|
||||
rc = q6core_map_mdf_shared_memory(mem->map_handle,
|
||||
(phys_addr_t *)&smmu->pa, smmu->proc_id,
|
||||
(uint32_t *)&smmu->pa_len, 1);
|
||||
if (rc) {
|
||||
pr_err("%s: q6core_map_mdf_shared_memory failed, rc = %d\n",
|
||||
__func__, rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void msm_mdf_unmap_memory_to_subsys(struct msm_mdf_mem *mem,
|
||||
struct msm_mdf_smmu *smmu)
|
||||
{
|
||||
if (!mem || !smmu)
|
||||
return;
|
||||
|
||||
if (!strcmp("adsp", smmu->subsys)) {
|
||||
if (mem->map_handle)
|
||||
q6core_memory_unmap_regions(mem->map_handle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* msm_mdf_mem_init - Initializes MDF memory pool and
|
||||
* map memory to subsystem
|
||||
*
|
||||
* Returns 0 on success or ret on failure.
|
||||
*/
|
||||
|
||||
int msm_mdf_mem_init(void)
|
||||
{
|
||||
int rc = 0, i, j;
|
||||
struct msm_mdf_mem *mem = &mdf_mem_data;
|
||||
struct msm_mdf_smmu *smmu;
|
||||
unsigned long timeout = jiffies +
|
||||
msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
|
||||
int adsp_ready = 0;
|
||||
|
||||
if (!(mdf_mem_data.device_status & MSM_MDF_PROBED))
|
||||
return -ENODEV;
|
||||
|
||||
if (mdf_mem_data.device_status & MSM_MDF_INITIALIZED)
|
||||
return 0;
|
||||
|
||||
/* TODO: pulling may not be needed as Q6 Core state should be
|
||||
* checked during machine driver probing.
|
||||
*/
|
||||
do {
|
||||
if (!q6core_is_adsp_ready()) {
|
||||
pr_err("%s: ADSP Audio NOT Ready\n",
|
||||
__func__);
|
||||
/* ADSP will be coming up after subsystem restart and
|
||||
* it might not be fully up when the control reaches
|
||||
* here. So, wait for 50msec before checking ADSP state
|
||||
*/
|
||||
msleep(50);
|
||||
} else {
|
||||
pr_debug("%s: ADSP Audio Ready\n",
|
||||
__func__);
|
||||
adsp_ready = 1;
|
||||
break;
|
||||
}
|
||||
} while (time_after(timeout, jiffies));
|
||||
|
||||
if (!adsp_ready) {
|
||||
pr_err("%s: timed out waiting for ADSP Audio\n",
|
||||
__func__);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
if (mem->device_status & MSM_MDF_MEM_ALLOCATED) {
|
||||
for (i = 0; i < SUBSYS_MAX; i++) {
|
||||
smmu = &mdf_smmu_data[i];
|
||||
rc = msm_mdf_dma_buf_map(mem, smmu);
|
||||
if (rc) {
|
||||
pr_err("%s: msm_mdf_dma_buf_map failed, rc = %d\n",
|
||||
__func__, rc);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < SUBSYS_MAX; j++) {
|
||||
smmu = &mdf_smmu_data[j];
|
||||
rc = msm_mdf_map_memory_to_subsys(mem, smmu);
|
||||
if (rc) {
|
||||
pr_err("%s: msm_mdf_map_memory_to_subsys failed\n",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
mdf_mem_data.device_status |= MSM_MDF_INITIALIZED;
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_mdf_mem_init);
|
||||
|
||||
int msm_mdf_mem_deinit(void)
|
||||
{
|
||||
int rc = 0, i;
|
||||
struct msm_mdf_mem *mem = &mdf_mem_data;
|
||||
struct msm_mdf_smmu *smmu;
|
||||
|
||||
if (!(mdf_mem_data.device_status & MSM_MDF_INITIALIZED))
|
||||
return -ENODEV;
|
||||
|
||||
for (i = SUBSYS_MAX - 1; i >= 0; i--) {
|
||||
smmu = &mdf_smmu_data[i];
|
||||
msm_mdf_unmap_memory_to_subsys(mem, smmu);
|
||||
}
|
||||
|
||||
if (!rc) {
|
||||
for (i = SUBSYS_MAX - 1; i >= 0; i--) {
|
||||
smmu = &mdf_smmu_data[i];
|
||||
msm_mdf_dma_buf_unmap(mem, smmu);
|
||||
}
|
||||
|
||||
msm_mdf_free_dma_buf(mem);
|
||||
mem->device_status &= ~MSM_MDF_MEM_ALLOCATED;
|
||||
}
|
||||
|
||||
mdf_mem_data.device_status &= ~MSM_MDF_INITIALIZED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_mdf_mem_deinit);
|
||||
|
||||
static int msm_mdf_restart_notifier_cb(struct notifier_block *this,
|
||||
unsigned long code,
|
||||
void *_cmd)
|
||||
{
|
||||
static int boot_count = 3;
|
||||
|
||||
/* During LPASS boot, HLOS receives events:
|
||||
* SUBSYS_BEFORE_POWERUP
|
||||
* SUBSYS_PROXY_VOTE
|
||||
* SUBSYS_AFTER_POWERUP - need skip
|
||||
* SUBSYS_PROXY_UNVOTE
|
||||
*/
|
||||
if (boot_count) {
|
||||
boot_count--;
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
switch (code) {
|
||||
case SUBSYS_BEFORE_SHUTDOWN:
|
||||
pr_debug("Subsys Notify: Shutdown Started\n");
|
||||
/* Unmap and free memory upon restart event. */
|
||||
msm_mdf_mem_deinit();
|
||||
break;
|
||||
case SUBSYS_AFTER_SHUTDOWN:
|
||||
pr_debug("Subsys Notify: Shutdown Completed\n");
|
||||
break;
|
||||
case SUBSYS_BEFORE_POWERUP:
|
||||
pr_debug("Subsys Notify: Bootup Started\n");
|
||||
break;
|
||||
case SUBSYS_AFTER_POWERUP:
|
||||
pr_debug("Subsys Notify: Bootup Completed\n");
|
||||
/* Allocate and map memory after restart complete. */
|
||||
if (msm_mdf_mem_init())
|
||||
pr_err("msm_mdf_mem_init failed\n");
|
||||
break;
|
||||
default:
|
||||
pr_err("Subsys Notify: Generel: %lu\n", code);
|
||||
break;
|
||||
}
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static const struct of_device_id msm_mdf_match_table[] = {
|
||||
{ .compatible = "qcom,msm-mdf", },
|
||||
{ .compatible = "qcom,msm-mdf-mem-region", },
|
||||
{ .compatible = "qcom,msm-mdf-cb", },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, msm_mdf_match_table);
|
||||
|
||||
static int msm_mdf_cb_probe(struct device *dev)
|
||||
{
|
||||
struct msm_mdf_smmu *smmu;
|
||||
const char *subsys;
|
||||
int rc = 0, i;
|
||||
|
||||
subsys = of_get_property(dev->of_node, "label", NULL);
|
||||
if (!subsys) {
|
||||
dev_err(dev, "%s: could not get label\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < SUBSYS_MAX; i++) {
|
||||
if (!mdf_smmu_data[i].subsys)
|
||||
continue;
|
||||
if (!strcmp(subsys, mdf_smmu_data[i].subsys))
|
||||
break;
|
||||
}
|
||||
if (i >= SUBSYS_MAX) {
|
||||
dev_err(dev, "%s: subsys %s not supported\n",
|
||||
__func__, subsys);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
smmu = &mdf_smmu_data[i];
|
||||
|
||||
smmu->enabled = of_property_read_bool(dev->of_node,
|
||||
"qcom,smmu-enabled");
|
||||
|
||||
dev_info(dev, "%s: SMMU is %s for %s\n", __func__,
|
||||
(smmu->enabled) ? "enabled" : "disabled",
|
||||
smmu->subsys);
|
||||
|
||||
if (smmu->enabled) {
|
||||
if (!strcmp("adsp", smmu->subsys)) {
|
||||
/* Get SMMU info from audio ION */
|
||||
rc = msm_audio_ion_get_smmu_info(&smmu->cb_dev,
|
||||
&smmu->sid);
|
||||
if (rc) {
|
||||
dev_err(dev, "%s: msm_audio_ion_get_smmu_info failed, rc = %d\n",
|
||||
__func__, rc);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Setup SMMU CB if enabled for subsys other than ADSP */
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_mdf_remove(struct platform_device *pdev)
|
||||
{
|
||||
int rc = 0, i;
|
||||
|
||||
for (i = 0; i < SUBSYS_MAX; i++) {
|
||||
if (!IS_ERR_OR_NULL(mdf_smmu_data[i].cb_dev))
|
||||
arm_iommu_detach_device(mdf_smmu_data[i].cb_dev);
|
||||
if (!IS_ERR_OR_NULL(mdf_smmu_data[i].mapping))
|
||||
arm_iommu_release_mapping(mdf_smmu_data[i].mapping);
|
||||
mdf_smmu_data[i].enabled = 0;
|
||||
}
|
||||
mdf_mem_data.device_status = 0;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int msm_mdf_probe(struct platform_device *pdev)
|
||||
{
|
||||
int rc = 0;
|
||||
enum apr_subsys_state q6_state;
|
||||
struct device *dev = &pdev->dev;
|
||||
uint32_t mdf_mem_data_size = 0;
|
||||
|
||||
/* TODO: MDF probing should have no dependency
|
||||
* on ADSP Q6 state.
|
||||
*/
|
||||
q6_state = apr_get_q6_state();
|
||||
if (q6_state == APR_SUBSYS_DOWN) {
|
||||
dev_dbg(dev, "defering %s, adsp_state %d\n",
|
||||
__func__, q6_state);
|
||||
rc = -EPROBE_DEFER;
|
||||
goto err;
|
||||
} else
|
||||
dev_dbg(dev, "%s: adsp is ready\n", __func__);
|
||||
|
||||
if (of_device_is_compatible(dev->of_node,
|
||||
"qcom,msm-mdf-cb"))
|
||||
return msm_mdf_cb_probe(dev);
|
||||
|
||||
if (of_device_is_compatible(dev->of_node,
|
||||
"qcom,msm-mdf-mem-region")) {
|
||||
mdf_mem_data.dev = dev;
|
||||
|
||||
rc = of_property_read_u32(dev->of_node,
|
||||
"qcom,msm-mdf-mem-data-size",
|
||||
&mdf_mem_data_size);
|
||||
if (rc) {
|
||||
dev_dbg(&pdev->dev, "MDF mem data size entry not found\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
mdf_mem_data.size = mdf_mem_data_size;
|
||||
dev_info(dev, "%s: mem region size %zd\n",
|
||||
__func__, mdf_mem_data.size);
|
||||
msm_mdf_alloc_dma_buf(&mdf_mem_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = of_platform_populate(pdev->dev.of_node,
|
||||
msm_mdf_match_table,
|
||||
NULL, &pdev->dev);
|
||||
if (rc) {
|
||||
dev_err(&pdev->dev, "%s: failed to populate child nodes",
|
||||
__func__);
|
||||
goto err;
|
||||
}
|
||||
mdf_mem_data.device_status |= MSM_MDF_PROBED;
|
||||
|
||||
err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static struct platform_driver msm_mdf_driver = {
|
||||
.probe = msm_mdf_probe,
|
||||
.remove = msm_mdf_remove,
|
||||
.driver = {
|
||||
.name = "msm-mdf",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = msm_mdf_match_table,
|
||||
},
|
||||
};
|
||||
|
||||
static struct notifier_block nb = {
|
||||
.priority = 0,
|
||||
.notifier_call = msm_mdf_restart_notifier_cb,
|
||||
};
|
||||
|
||||
int __init msm_mdf_init(void)
|
||||
{
|
||||
/* Only need to monitor SSR from ADSP, which
|
||||
* is the master DSP managing MDF memory.
|
||||
*/
|
||||
ssr_handle = subsys_notif_register_notifier("adsp", &nb);
|
||||
return platform_driver_register(&msm_mdf_driver);
|
||||
}
|
||||
|
||||
void __exit msm_mdf_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&msm_mdf_driver);
|
||||
|
||||
if (ssr_handle)
|
||||
subsys_notif_unregister_notifier(ssr_handle, &nb);
|
||||
}
|
||||
|
||||
MODULE_DESCRIPTION("MSM MDF Module");
|
||||
MODULE_LICENSE("GPL v2");
|
Reference in New Issue
Block a user