mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
ADSP host driver is enhanced to be multi-instance
capable and reentrant:
- Trailing unique identifier string in compatible DT property, like
"adsp", "adsp1" or "aon", is used to identify the driver instances
- Each probed driver instance is inserted into a global list, from
which the handle can be fetched using 'nvadsp_get_handle' API
(passing the above unique identifier as argument)
- Above unique identifier is also used as name for the DBFS
directory (containing files like adsp_console, adsp_logger, etc.)
- 'nvadsp_get_handle' is the only exported API; all other APIs are
accessible via function pointers within 'struct nvadsp_handle'
- APIs above maintain one-is-to-one correspondence with all
legacy APIs, with the addition of a new argument
'struct nvadsp_handle *' at the beginning
- Legacy APIs continue to be supported, but they are hardwired to
work only if the kernel probes just one driver instance
- All driver files are cleaned up to not use any global state
variables (necessary for reentrancy)
Bug 3682950
Change-Id: Id5db49e861b2f81716ae8352b36b406654da2bbd
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3092701
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
102 lines
2.4 KiB
C
102 lines
2.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/**
|
|
* Copyright (c) 2015-2024, NVIDIA CORPORATION. All rights reserved.
|
|
*/
|
|
|
|
#include <linux/version.h>
|
|
#include <soc/tegra/fuse.h>
|
|
#include <soc/tegra/virt/hv-ivc.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/tegra_nvadsp.h>
|
|
#include <linux/tegra-hsp.h>
|
|
|
|
#include "dev.h"
|
|
#include "hwmailbox.h"
|
|
#include "os.h"
|
|
#include "dev-t18x.h"
|
|
|
|
#if IS_ENABLED(CONFIG_TEGRA_HSP)
|
|
static void nvadsp_dbell_handler(void *data)
|
|
{
|
|
struct platform_device *pdev = data;
|
|
struct device *dev = &pdev->dev;
|
|
|
|
dev_info(dev, "APE DBELL handler\n");
|
|
}
|
|
#endif
|
|
|
|
|
|
/* Function to return the ADMA page number (0 indexed) used by guest */
|
|
static int tegra_adma_query_dma_page(void)
|
|
{
|
|
struct device_node *np = NULL;
|
|
int adma_page = 0, ret = 0, i = 0;
|
|
|
|
static const char *compatible[] = {
|
|
"nvidia,tegra210-adma",
|
|
"nvidia,tegra210-adma-hv",
|
|
"nvidia,tegra186-adma",
|
|
"nvidia,tegra194-adma-hv",
|
|
};
|
|
|
|
for (i = 0; i < ARRAY_SIZE(compatible); i++) {
|
|
np = of_find_compatible_node(NULL, NULL, compatible[i]);
|
|
if (np == NULL)
|
|
continue;
|
|
|
|
/*
|
|
* In DT, "adma-page" property is 1 indexed
|
|
* If property is present, update return value to be 0 indexed
|
|
* If property is absent, return default value as page 0
|
|
*/
|
|
ret = of_property_read_u32(np, "adma-page", &adma_page);
|
|
if (ret == 0)
|
|
adma_page = adma_page - 1;
|
|
|
|
break;
|
|
}
|
|
|
|
pr_info("%s: adma-page %d\n", __func__, adma_page);
|
|
return adma_page;
|
|
}
|
|
|
|
int nvadsp_os_t18x_init(struct platform_device *pdev)
|
|
{
|
|
struct nvadsp_drv_data *drv_data = platform_get_drvdata(pdev);
|
|
int ret = 0, adma_ch_page, val = 0;
|
|
|
|
if (is_tegra_hypervisor_mode()) {
|
|
|
|
adma_ch_page = tegra_adma_query_dma_page();
|
|
|
|
/* Set ADSP to do decompression again */
|
|
val = ADSP_CONFIG_DECOMPRESS_EN << ADSP_CONFIG_DECOMPRESS_SHIFT;
|
|
|
|
/* Set ADSP to know its virtualized configuration */
|
|
val = val | (ADSP_CONFIG_VIRT_EN << ADSP_CONFIG_VIRT_SHIFT);
|
|
|
|
/* Encode DMA Page Bits with DMA page information */
|
|
val = val | (adma_ch_page << ADSP_CONFIG_DMA_PAGE_SHIFT);
|
|
|
|
/* Write to HWMBOX5 */
|
|
hwmbox_writel(drv_data, val,
|
|
drv_data->chip_data->adsp_os_config_hwmbox);
|
|
|
|
/* Clear HWMBOX0 for ADSP Guest reset handling */
|
|
hwmbox_writel(drv_data, 0,
|
|
drv_data->chip_data->hwmb.hwmbox0_reg);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#if IS_ENABLED(CONFIG_TEGRA_HSP)
|
|
ret = tegra_hsp_db_add_handler(HSP_MASTER_APE,
|
|
nvadsp_dbell_handler, pdev);
|
|
if (ret)
|
|
dev_err(&pdev->dev,
|
|
"failed to add HSP_MASTER_APE DB handler\n");
|
|
#endif
|
|
|
|
return ret;
|
|
}
|