Update source to Armbian-dev-202610.A311Y3

This commit is contained in:
2026-11-11 08:50:43 +08:00
parent 3428a94f6b
commit f459ef6a9e
12514 changed files with 2264376 additions and 468481 deletions
@@ -140,6 +140,8 @@ static int host_dump_memory(const void *buf, unsigned int bytes, int col)
char str[256];
char a_str[24];
if (!buf)
return -EINVAL;
pdata = (u8 *)buf;
size = bytes;
memset(a_str, '\0', sizeof(a_str));
@@ -297,6 +299,9 @@ static int host_clk_enable(struct host_module *host)
static void host_boot_prepare(struct host_module *host)
{
if (!host->misc || !host->misc->name)
return;
if (!strstr(host->misc->name, "bl40"))
host_clk_enable(host);
if (strstr(host->misc->name, "bl40")) {
@@ -319,6 +324,9 @@ static void host_bootup(struct host_module *host)
if (!IS_ERR_OR_NULL(host->init_mbox_chan) && !IS_ERR_OR_NULL(host->host_dsp)) {
host_mbox_transfer(host);
} else {
if (!host->misc || !host->misc->name)
return;
if (strstr(host->misc->name, "bl40"))
smc_subid = SMC_SUBID_MFH_V1_BOOT;
else if (strstr(host->misc->name, "mfh"))
@@ -337,6 +345,9 @@ static int host_fw_copy_to_memory(const struct firmware *fw,
const struct host_module *host,
void *fw_dst, const char *name)
{
if (!fw || !fw->data || !fw_dst || fw->size < 32)
return -EINVAL;
host_dump_memory(fw->data, 32, 16);
host_dump_memory(fw->data + fw->size - 32, 32, 16);
pr_debug("%s fw_src:0x%p, pdata_dst=0x%p, size=%zu bytes\n",
@@ -437,10 +448,19 @@ static void *mm_vmap(phys_addr_t phys, unsigned long size, pgprot_t pgprotattr)
void host_core_reset(struct host_module *host)
{
int ret;
if (host->core_reset) {
if (!host->health_reg) {
pr_err("dsp health reg is null or error\n");
return;
}
pr_info("[%s][%s will be reset!!!!]\n", __func__, host->host_data->name);
host_psci_smc(host, SMC_SUBID_HIFI_DSP_RESET_HIGH);
pm_runtime_put_sync(host->dev);
ret = pm_runtime_put_sync(host->dev);
if (ret < 0)
dev_err(host->dev, "Failed to power off: %d\n", ret);
writel(0, host->health_reg);
if (host->start_pos == PURE_SRAM) {
memset_io((void *)host->sram_addr, '\0', (host->phys_sram_size));
@@ -451,7 +471,12 @@ void host_core_reset(struct host_module *host)
memset((void *)host->ddr_addr, '\0', (host->phys_ddr_size));
}
host->firmware_load = 0;
pm_runtime_get_sync(host->dev);
ret = pm_runtime_get_sync(host->dev);
if (ret < 0) {
pm_runtime_put_noidle(host->dev);
dev_err(host->dev, "Failed to power on: %d\n", ret);
return;
}
} else {
pr_err("core reset is not supported\n");
}
@@ -464,6 +489,8 @@ static int __maybe_unused host_runtime_suspend(struct device *dev)
if (IS_ERR_OR_NULL(host))
return -EINVAL;
if (!host->misc || !host->misc->name)
return -EINVAL;
host_health_monitor_stop(host);
if (strstr(host->misc->name, "mfh"))
@@ -486,6 +513,9 @@ static int __maybe_unused host_runtime_suspend(struct device *dev)
clk_disable_unprepare(host->clk);
host->hang = true;
host_set_hang_sts_to_mbox(host);
#ifdef CONFIG_AMLOGIC_HOST_SEAMLESS
writel(0, host->health_reg);
#endif
host_logbuff_stop(host);
if (strstr(host->misc->name, "hifi4dsp") && host->host_dsp->pm_support_ffv)
host_dsp_ffv_wq_stop(host->host_dsp);
@@ -499,16 +529,26 @@ static int __maybe_unused host_runtime_resume(struct device *dev)
struct host_module *host = dev_get_drvdata(dev);
int ret;
if (!host->firmware_load) {
ret = host_firmware_load(host);
if (ret) {
dev_err(dev, "Load firmware fail\n");
return ret;
#ifdef CONFIG_AMLOGIC_HOST_SEAMLESS
if (host->health_reg && readl(host->health_reg) == 0) {
#endif
if (!host->firmware_load) {
ret = host_firmware_load(host);
if (ret) {
dev_err(dev, "Load firmware fail\n");
return ret;
}
}
#ifdef CONFIG_AMLOGIC_HOST_SEAMLESS
}
#endif
host_boot_prepare(host);
host_bootup(host);
#ifdef CONFIG_AMLOGIC_HOST_SEAMLESS
if (host->health_reg && readl(host->health_reg) == 0)
#endif
host_bootup(host);
host->hang = false;
host_set_hang_sts_to_mbox(host);
host_health_monitor_start(host);
@@ -533,6 +573,23 @@ static void host_mbox_callback_from_dev(struct mbox_client *cl, void *msg)
}
}
static void host_wakeup_dsp_set(struct host_module *host)
{
u32 val;
if (IS_ERR_OR_NULL(host->host_dsp->wakeup_count_reg) ||
IS_ERR_OR_NULL(host->host_dsp->wakeup_ctrl_reg))
return;
writel(WAKE_TIMER_COUNT, host->host_dsp->wakeup_count_reg);
val = readl(host->host_dsp->wakeup_ctrl_reg);
val &= ~(WAKE_TIMER_EN | WAKE_TIMER_CLK_SEL_100US);
val |= WAKE_TIMER_CFG;
writel(val, host->host_dsp->wakeup_ctrl_reg);
mdelay(5);
}
#ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND
static void host_early_suspend(struct early_suspend *h)
{
@@ -601,6 +658,7 @@ static void host_late_resume(struct early_suspend *h)
pr_info("late resume: switch dsp clk to %d Hz\n", host->clk_rate * 1000);
pr_debug("late resume: AP send resume cmd to dsp...\n");
host_wakeup_dsp_set(host);
strncpy(message, "HIFI_LATE_RESUME_WITH_FFV", sizeof(message));
aml_mbox_transfer_data(host->mbox_chan_to_dev,
MBOX_CMD_HIFI4RESUME,
@@ -684,6 +742,7 @@ static int host_resume(struct device *dev)
clk_set_rate(host->clk, (unsigned long)host->clk_rate * 1000);
pr_debug("AP send resume cmd to dsp...\n");
host_wakeup_dsp_set(host);
strncpy(message, "HIFI_RESUME", sizeof(message));
aml_mbox_transfer_data(host->mbox_chan_to_dev,
MBOX_CMD_HIFI4RESUME,
@@ -707,8 +766,16 @@ static int host_resume(struct device *dev)
static int host_miscdev_open(struct inode *inode, struct file *fp)
{
struct miscdevice *misc = fp->private_data;
struct host_data *host_data = container_of(misc, struct host_data, misc);
struct miscdevice *misc;
struct host_data *host_data;
if (!fp->private_data)
return -EINVAL;
misc = fp->private_data;
host_data = container_of(misc, struct host_data, misc);
if (!host_data || !host_data->host)
return -EINVAL;
fp->private_data = host_data->host;
@@ -756,11 +823,18 @@ static long host_miscdev_unlocked_ioctl(struct file *fp, unsigned int cmd,
pr_err("%s error: HOST_LOAD is error", __func__);
goto err;
}
host->host_dsp->usrinfo->fw_name[31] = '\0';
host->host_dsp->usrinfo->fw_name[HOSTFW_NAME_LEN - 1] = '\0';
/*
* fw_name[HOSTFW_NAME_LEN - 1] = '\0' guarantees that host->fname0 and
* host->fname1 will be null-terminated after strncpy with
* HOSTFW_NAME_LEN bytes.
*/
/* coverity[BUFFER_SIZE] */
if (host->start_pos == PURE_SRAM)
strcpy(host->fname1, host->host_dsp->usrinfo->fw_name);
strncpy(host->fname1, host->host_dsp->usrinfo->fw_name, HOSTFW_NAME_LEN);
else
strcpy(host->fname0, host->host_dsp->usrinfo->fw_name);
strncpy(host->fname0, host->host_dsp->usrinfo->fw_name, HOSTFW_NAME_LEN);
host_firmware_load(host);
host->firmware_load = 1;
break;
@@ -772,10 +846,18 @@ static long host_miscdev_unlocked_ioctl(struct file *fp, unsigned int cmd,
pr_err("%s error: HOST_2LOAD is error", __func__);
goto err;
}
host->host_dsp->usrinfo->fw1_name[31] = '\0';
host->host_dsp->usrinfo->fw2_name[31] = '\0';
strcpy(host->fname0, host->host_dsp->usrinfo->fw1_name);
strcpy(host->fname1, host->host_dsp->usrinfo->fw2_name);
host->host_dsp->usrinfo->fw1_name[HOSTFW_NAME_LEN - 1] = '\0';
host->host_dsp->usrinfo->fw2_name[HOSTFW_NAME_LEN - 1] = '\0';
/*
* fw1_name[HOSTFW_NAME_LEN - 1] = '\0' and
* fw2_name[HOSTFW_NAME_LEN - 1] = '\0' guarantees that
* host->fname0 and host->fname1 will be null-terminated
* after strncpy with HOSTFW_NAME_LEN bytes.
*/
/* coverity[BUFFER_SIZE] */
strncpy(host->fname0, host->host_dsp->usrinfo->fw1_name, HOSTFW_NAME_LEN);
strncpy(host->fname1, host->host_dsp->usrinfo->fw2_name, HOSTFW_NAME_LEN);
host_firmware_load(host);
host->firmware_load = 1;
break;
@@ -787,7 +869,12 @@ static long host_miscdev_unlocked_ioctl(struct file *fp, unsigned int cmd,
pr_err("%s error: HOST_START is error", __func__);
goto err;
}
pm_runtime_get_sync(dev);
ret = pm_runtime_get_sync(dev);
if (ret < 0) {
pm_runtime_put_noidle(dev);
dev_err(dev, "Failed to power on: %d\n", ret);
goto err;
}
host->firmware_started = 1;
break;
case HOST_STOP:
@@ -798,7 +885,11 @@ static long host_miscdev_unlocked_ioctl(struct file *fp, unsigned int cmd,
pr_err("%s error: HOST_STOP is error", __func__);
goto err;
}
pm_runtime_put_sync(dev);
ret = pm_runtime_put_sync(dev);
if (ret < 0) {
dev_err(dev, "Failed to power off: %d\n", ret);
goto err;
}
host->firmware_started = 0;
break;
case HOST_GET_INFO:
@@ -810,7 +901,7 @@ static long host_miscdev_unlocked_ioctl(struct file *fp, unsigned int cmd,
goto err;
}
strncpy(host->host_dsp->usrinfo->fw_name, host->host_data->name,
sizeof(host->host_dsp->usrinfo->fw_name));
sizeof(host->host_dsp->usrinfo->fw_name) - 1);
host->host_dsp->usrinfo->phy_addr = host->phys_ddr_addr;
host->host_dsp->usrinfo->size = host->phys_ddr_size;
ret = copy_to_user(argp, host->host_dsp->usrinfo,
@@ -866,7 +957,7 @@ static long host_miscdev_unlocked_ioctl(struct file *fp, unsigned int cmd,
if (ret < 0)
goto err;
host->host_mfh->mfh_info.name[29] = '\0';
strcpy(host->fname0, host->host_mfh->mfh_info.name);
strncpy(host->fname0, host->host_mfh->mfh_info.name, HOSTFW_NAME_LEN - 1);
host_runtime_resume(dev);
break;
default:
@@ -1099,6 +1190,9 @@ static int host_parse_devtree(struct platform_device *pdev, struct host_module *
struct mbox_chan *mbox_chan;
int ret;
if (!host->misc || !host->misc->name)
return -EINVAL;
resource = platform_get_resource_byname(pdev, IORESOURCE_MEM, "device-support-reg");
if (!IS_ERR_OR_NULL(resource)) {
host->device_spt_reg = devm_ioremap(dev,
@@ -1167,6 +1261,15 @@ static int host_parse_devtree(struct platform_device *pdev, struct host_module *
host->host_dsp->pm_support_suspend = PM_SUPPORT_DSP_SUSPEND(host->pm_support);
host->host_dsp->pm_support_always_on = PM_SUPPORT_DSP_ALWAYS_ON(host->pm_support);
host->host_dsp->pm_support_ffv = PM_SUPPORT_DSP_FFV(host->pm_support);
host->host_dsp->wakeup_ctrl_reg =
devm_platform_ioremap_resource_byname(pdev, "timeri-ctrl-reg");
if (IS_ERR_OR_NULL(host->host_dsp->wakeup_ctrl_reg))
dev_err(dev, "Not support dsp wake up ctrl reg\n");
host->host_dsp->wakeup_count_reg =
devm_platform_ioremap_resource_byname(pdev, "timeri-count-reg");
if (IS_ERR_OR_NULL(host->host_dsp->wakeup_count_reg))
dev_err(dev, "Not support dsp wake up count reg\n");
}
if (!of_property_read_string_index(dev->of_node, "clock-names", 0, &clk_name)) {
@@ -1207,10 +1310,15 @@ static int host_parse_devtree(struct platform_device *pdev, struct host_module *
else
host->mbox_chan_from_dev->cl->rx_callback = host_mbox_callback_from_dev;
host->core_reset = of_property_read_bool(dev->of_node, "core-reset");
of_property_read_u32(dev->of_node, "logbuff-polling-ms",
ret = of_property_read_u32(dev->of_node, "logbuff-polling-ms",
&host->logbuff_polling_ms);
of_property_read_u32(dev->of_node, "health-polling-ms",
if (ret)
dev_err(dev, "dsp log buffer not supported\n");
ret = of_property_read_u32(dev->of_node, "health-polling-ms",
&host->health_polling_ms);
if (ret)
dev_warn(dev, "can't find health polling\n");
ret = of_property_read_u8(dev->of_node, "startup-position", &host->start_pos);
if (ret) {
@@ -1280,7 +1388,6 @@ static int host_platform_probe(struct platform_device *pdev)
return ret;
}
pm_runtime_enable(dev);
host_create_debugfs_files(host);
host_create_device_files(&pdev->dev);
device_init_wakeup(&pdev->dev, 1);
@@ -1308,8 +1415,14 @@ static int host_platform_probe(struct platform_device *pdev)
else if (strstr(host_data->name, "dspbootb"))
mbox_set_dsp_hang_status(true, DSPB_ID);
host->hang = true;
host_p[host->hostid] = host;
pm_runtime_enable(dev);
#ifdef CONFIG_AMLOGIC_HOST_SEAMLESS
pm_runtime_get_sync(dev);
#endif
return 0;
}