Merge commit '33ea77356f47c6c596c8505ca90307fc1245ef3f' into audio-kernel-5-4.lnx.1.0

Change-Id: Iacb389506a643a1ac70a3d51c2dfc1eeb47f690c
This commit is contained in:
Phani Kumar Uppalapati
2020-07-21 18:31:26 -07:00
committed by Ashish Jain
60 changed files with 2849 additions and 1073 deletions

View File

@@ -28,6 +28,7 @@ enum apr_subsys_state {
APR_SUBSYS_DOWN,
APR_SUBSYS_UP,
APR_SUBSYS_LOADED,
APR_SUBSYS_UNKNOWN,
};
static ssize_t adsp_boot_store(struct kobject *kobj,
@@ -61,6 +62,53 @@ static struct work_struct adsp_ldr_work;
static struct platform_device *adsp_private;
static void adsp_loader_unload(struct platform_device *pdev);
static int adsp_restart_subsys(void)
{
struct subsys_device *adsp_dev = NULL;
struct platform_device *pdev = adsp_private;
struct adsp_loader_private *priv = NULL;
int rc = -EINVAL;
priv = platform_get_drvdata(pdev);
if (!priv)
return rc;
adsp_dev = (struct subsys_device *)priv->pil_h;
if (!adsp_dev)
return rc;
/* subsystem_restart_dev has worker queue to handle */
rc = subsystem_restart_dev(adsp_dev);
if (rc) {
dev_err(&pdev->dev, "subsystem_restart_dev failed\n");
return rc;
}
pr_debug("%s :: Restart Success %d\n", __func__, rc);
return rc;
}
#if 0
static void adsp_load_state_notify_cb(enum apr_subsys_state state,
void *phandle)
{
struct platform_device *pdev = adsp_private;
struct adsp_loader_private *priv = NULL;
priv = platform_get_drvdata(pdev);
if (!priv)
return;
if (phandle != adsp_private) {
pr_err("%s:callback is not for adsp-loader client\n", __func__);
return;
}
pr_debug("%s:: Received cb for ADSP restart\n", __func__);
if (state == APR_SUBSYS_UNKNOWN)
adsp_restart_subsys();
else
pr_debug("%s:Ignore restart request for ADSP", __func__);
}
#endif
static void adsp_load_fw(struct work_struct *adsp_ldr_work)
{
struct platform_device *pdev = adsp_private;
@@ -69,6 +117,7 @@ static void adsp_load_fw(struct work_struct *adsp_ldr_work)
int rc = 0;
u32 adsp_state;
const char *img_name;
// void *padsp_restart_cb = &adsp_load_state_notify_cb;
if (!pdev) {
dev_err(&pdev->dev, "%s: Platform device null\n", __func__);
@@ -125,7 +174,7 @@ static void adsp_load_fw(struct work_struct *adsp_ldr_work)
}
dev_dbg(&pdev->dev, "%s: Q6/MDSP image is loaded\n", __func__);
return;
goto success;
}
load_adsp:
@@ -159,10 +208,13 @@ load_adsp:
}
dev_dbg(&pdev->dev, "%s: Q6/ADSP image is loaded\n", __func__);
return;
// apr_register_adsp_state_cb(padsp_restart_cb, adsp_private);
goto success;
}
fail:
dev_err(&pdev->dev, "%s: Q6 image loading failed\n", __func__);
success:
return;
}
static void adsp_loader_do(struct platform_device *pdev)
@@ -176,37 +228,24 @@ static ssize_t adsp_ssr_store(struct kobject *kobj,
size_t count)
{
int ssr_command = 0;
struct subsys_device *adsp_dev = NULL;
struct platform_device *pdev = adsp_private;
struct adsp_loader_private *priv = NULL;
int rc;
int rc = -EINVAL;
dev_dbg(&pdev->dev, "%s: going to call adsp ssr\n ", __func__);
priv = platform_get_drvdata(pdev);
if (!priv)
return rc;
if (kstrtoint(buf, 10, &ssr_command) < 0)
return -EINVAL;
if (ssr_command != SSR_RESET_CMD)
return -EINVAL;
priv = platform_get_drvdata(pdev);
if (!priv)
return -EINVAL;
adsp_dev = (struct subsys_device *)priv->pil_h;
if (!adsp_dev)
return -EINVAL;
dev_err(&pdev->dev, "requesting for ADSP restart\n");
/* subsystem_restart_dev has worker queue to handle */
rc = subsystem_restart_dev(adsp_dev);
if (rc) {
dev_err(&pdev->dev, "subsystem_restart_dev failed\n");
return rc;
}
dev_dbg(&pdev->dev, "ADSP restarted\n");
adsp_restart_subsys();
dev_dbg(&pdev->dev, "%s :: ADSP restarted\n", __func__);
return count;
}
@@ -339,6 +378,8 @@ static int adsp_loader_probe(struct platform_device *pdev)
int fw_name_size;
u32 adsp_var_idx = 0;
int ret = 0;
u32 adsp_fuse_not_supported = 0;
const char *adsp_fw_name;
ret = adsp_loader_init_sysfs(pdev);
if (ret != 0) {
@@ -350,15 +391,58 @@ static int adsp_loader_probe(struct platform_device *pdev)
/* get adsp variant idx */
cell = nvmem_cell_get(&pdev->dev, "adsp_variant");
if (IS_ERR_OR_NULL(cell)) {
dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n", __func__);
dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n",
__func__);
/*
* When ADSP variant read from fuse register is not
* supported, check if image with different fw image
* name needs to be loaded
*/
ret = of_property_read_u32(pdev->dev.of_node,
"adsp-fuse-not-supported",
&adsp_fuse_not_supported);
if (ret) {
dev_dbg(&pdev->dev,
"%s: adsp_fuse_not_supported prop not found",
__func__, ret);
goto wqueue;
}
if (adsp_fuse_not_supported) {
/* Read ADSP firmware image name */
ret = of_property_read_string(pdev->dev.of_node,
"adsp-fw-name",
&adsp_fw_name);
if (ret < 0) {
dev_dbg(&pdev->dev, "%s: unable to read fw-name\n",
__func__);
goto wqueue;
}
fw_name_size = strlen(adsp_fw_name) + 1;
priv->adsp_fw_name = devm_kzalloc(&pdev->dev,
fw_name_size,
GFP_KERNEL);
if (!priv->adsp_fw_name)
goto wqueue;
strlcpy(priv->adsp_fw_name, adsp_fw_name,
fw_name_size);
}
goto wqueue;
}
buf = nvmem_cell_read(cell, &len);
nvmem_cell_put(cell);
if (IS_ERR_OR_NULL(buf) || len <= 0 || len > sizeof(u32)) {
if (IS_ERR_OR_NULL(buf)) {
dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell \n", __func__);
goto wqueue;
}
if (len <= 0 || len > sizeof(u32)) {
dev_dbg(&pdev->dev, "%s: nvmem cell length out of range: %d\n",
__func__, len);
kfree(buf);
goto wqueue;
}
memcpy(&adsp_var_idx, buf, len);
kfree(buf);