nvdla: kmd: add support for ACPI

Bug 4988970
Jira DLA-7673

Change-Id: I8d611932cf7b7af107f135e9ae44caad9032a6c0
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3272418
Signed-off-by: Amit Sharma <amisharma@nvidia.com>
(cherry picked from commit e01c86ebdf123d6e9a40986c16f7f3ccbb989cc1)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3270720
Reviewed-by: Ayush Kumar <ayushk@nvidia.com>
Reviewed-by: Arvind M <am@nvidia.com>
Reviewed-by: Vishal Thoke <vthoke@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mitch Harwell <mharwell@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
This commit is contained in:
Arvind M
2024-12-18 06:18:12 -08:00
committed by Jon Hunter
parent f0404e50f6
commit 7f006193a3
7 changed files with 74 additions and 21 deletions

View File

@@ -29,6 +29,7 @@ ccflags-y += -DNVDLA_HAVE_CONFIG_HSIERRINJ=0
ccflags-y += -DBUG_4942853=1
ccflags-y += -DBUG_4960393=1
ccflags-y += -DBUG_4972382=1
ccflags-y += -DBUG_5054810=1
NVDLA_OBJS := \
$(NVDLA_COMMON_OBJS) \

View File

@@ -6,6 +6,7 @@
#include <nvidia/conftest.h>
#include <linux/acpi.h>
#include <linux/arm64-barrier.h>
#include <linux/module.h>
#include <linux/fs.h>
@@ -928,6 +929,20 @@ static struct of_device_id tegra_nvdla_of_match[] = {
.data = (struct nvhost_device_data *)&t264_sim_nvdla0_info },
{ },
};
static struct acpi_device_id tegra_nvdla_acpi_match[] = {
{
.id = "NVDA200A",
.driver_data = 0x0,
},
{ },
};
static void *acpi_data[] = {
/*0x0*/ &t25x_nvdla0_info,
NULL,
};
#else
static struct of_device_id tegra_nvdla_of_match[] = {
{
@@ -948,8 +963,18 @@ static struct of_device_id tegra_nvdla_of_match[] = {
.data = (struct nvhost_device_data *)&t23x_nvdla1_info },
{ },
};
static struct acpi_device_id tegra_nvdla_acpi_match[] = {
{ },
};
static void *acpi_data[] = {
NULL,
};
#endif /* NVDLA_HAVE_CONFIG_AXI */
MODULE_DEVICE_TABLE(of, tegra_nvdla_of_match);
MODULE_DEVICE_TABLE(acpi, tegra_nvdla_acpi_match);
static uint32_t num_enabled_dla_instances(uint32_t soft_fuse_ret,
int hw_reg_fuse_ret)
@@ -999,6 +1024,13 @@ static int nvdla_probe(struct platform_device *pdev)
match = of_match_device(tegra_nvdla_of_match, dev);
if (match)
pdata = (struct nvhost_device_data *)match->data;
} else if (ACPI_HANDLE(&pdev->dev)) {
const struct acpi_device_id *match;
match = acpi_match_device(tegra_nvdla_acpi_match, dev);
if (match)
pdata = (struct nvhost_device_data *)
acpi_data[match->driver_data];
} else {
pdata = (struct nvhost_device_data *)pdev->dev.platform_data;
}
@@ -1074,10 +1106,12 @@ static int nvdla_probe(struct platform_device *pdev)
goto err_alloc_nvdla;
}
nvdla_dev->icc_write = devm_of_icc_get(dev, "write");
if (IS_ERR(nvdla_dev->icc_write))
return dev_err_probe(&pdev->dev, PTR_ERR(nvdla_dev->icc_write),
if (pdev->dev.of_node) {
nvdla_dev->icc_write = devm_of_icc_get(dev, "write");
if (IS_ERR(nvdla_dev->icc_write))
return dev_err_probe(&pdev->dev, PTR_ERR(nvdla_dev->icc_write),
"failed to get icc write handle\n");
}
nvdla_dev->dev = dev;
nvdla_dev->pdev = pdev;
@@ -1098,7 +1132,10 @@ static int nvdla_probe(struct platform_device *pdev)
if (pdata->version == FIRMWARE_ENCODE_VERSION(T23X)) {
if (num_enabled_dla_instances(soft_fuse_ret, fuse_register_ret) == 1) {
pdev->dev.of_node->name = "nvdla0";
if (pdev->dev.of_node)
pdev->dev.of_node->name = "nvdla0";
else
pdata->devfs_name = "nvdla0";
}
}
@@ -1349,6 +1386,9 @@ static struct platform_driver nvdla_driver = {
#ifdef CONFIG_OF
.of_match_table = tegra_nvdla_of_match,
#endif
#ifdef CONFIG_ACPI
.acpi_match_table = ACPI_PTR(tegra_nvdla_acpi_match),
#endif
#ifdef CONFIG_PM
.pm = &nvdla_module_pm_ops,
#endif

View File

@@ -15,6 +15,7 @@
#include "dla_t19x_fw_version.h"
static struct nvhost_device_data t19_nvdla0_info = {
.devfs_name = "nvdla0",
.devfs_name_family = "nvdla",
.class = NV_DLA0_CLASS_ID,
.clocks = {
@@ -29,7 +30,7 @@ static struct nvhost_device_data t19_nvdla0_info = {
.resource_policy = RESOURCE_PER_CHANNEL_INSTANCE,
.finalize_poweron = nvdla_finalize_poweron,
.prepare_poweroff = nvdla_prepare_poweroff,
.flcn_isr = nvdla_flcn_isr,
.flcn_isr = nvdla_flcn_isr,
.self_config_flcn_isr = true,
.vm_regs = {{0x30, true}, {0x34, false} },
.firmware_name = NV_DLA_TEGRA194_FW,
@@ -55,6 +56,7 @@ static struct nvhost_device_data t19_nvdla0_info = {
};
static struct nvhost_device_data t19_nvdla1_info = {
.devfs_name = "nvdla1",
.devfs_name_family = "nvdla",
.class = NV_DLA1_CLASS_ID,
.clocks = {
@@ -67,7 +69,7 @@ static struct nvhost_device_data t19_nvdla1_info = {
.resource_policy = RESOURCE_PER_CHANNEL_INSTANCE,
.finalize_poweron = nvdla_finalize_poweron,
.prepare_poweroff = nvdla_prepare_poweroff,
.flcn_isr = nvdla_flcn_isr,
.flcn_isr = nvdla_flcn_isr,
.self_config_flcn_isr = true,
.vm_regs = {{0x30, true}, {0x34, false} },
.firmware_name = NV_DLA_TEGRA194_FW,

View File

@@ -15,6 +15,7 @@
#include "dla_t23x_fw_version.h"
static struct nvhost_device_data t23x_nvdla0_info = {
.devfs_name = "nvdla0",
.devfs_name_family = "nvdla",
.class = NV_DLA0_CLASS_ID,
.clocks = {
@@ -24,7 +25,7 @@ static struct nvhost_device_data t23x_nvdla0_info = {
.resource_policy = RESOURCE_PER_CHANNEL_INSTANCE,
.finalize_poweron = nvdla_finalize_poweron,
.prepare_poweroff = nvdla_prepare_poweroff,
.flcn_isr = nvdla_flcn_isr,
.flcn_isr = nvdla_flcn_isr,
.self_config_flcn_isr = true,
.vm_regs = {{0x30, true}, {0x34, false} },
.firmware_name = NV_DLA_TEGRA234_FW,
@@ -50,6 +51,7 @@ static struct nvhost_device_data t23x_nvdla0_info = {
};
static struct nvhost_device_data t23x_nvdla1_info = {
.devfs_name = "nvdla1",
.devfs_name_family = "nvdla",
.class = NV_DLA1_CLASS_ID,
.clocks = {
@@ -59,7 +61,7 @@ static struct nvhost_device_data t23x_nvdla1_info = {
.resource_policy = RESOURCE_PER_CHANNEL_INSTANCE,
.finalize_poweron = nvdla_finalize_poweron,
.prepare_poweroff = nvdla_prepare_poweroff,
.flcn_isr = nvdla_flcn_isr,
.flcn_isr = nvdla_flcn_isr,
.self_config_flcn_isr = true,
.vm_regs = {{0x30, true}, {0x34, false} },
.firmware_name = NV_DLA_TEGRA234_FW,

View File

@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* Device data for T25X simulator
*/
@@ -14,6 +14,7 @@
#include "dla_t25x_fw_version.h"
static struct nvhost_device_data t25x_nvdla0_info = {
.devfs_name = "nvdla0",
.devfs_name_family = "nvdla",
#if defined(BUG_4972382) && (BUG_4972382 == 1)
.class = NV_DLA0_SIM_CLASS_ID,
@@ -27,7 +28,7 @@ static struct nvhost_device_data t25x_nvdla0_info = {
.resource_policy = RESOURCE_PER_CHANNEL_INSTANCE,
.finalize_poweron = nvdla_finalize_poweron,
.prepare_poweroff = nvdla_prepare_poweroff,
.flcn_isr = nvdla_flcn_isr,
.flcn_isr = nvdla_flcn_isr,
.self_config_flcn_isr = true,
.vm_regs = {{0x30, true}, {0x34, false} },
.firmware_name = NV_DLA_TEGRA25X_FW,
@@ -48,6 +49,7 @@ static struct nvhost_device_data t25x_nvdla0_info = {
};
static struct nvhost_device_data t25x_nvdla1_info = {
.devfs_name = "nvdla1",
.devfs_name_family = "nvdla",
#if defined(BUG_4972382) && (BUG_4972382 == 1)
.class = NV_DLA1_SIM_CLASS_ID,
@@ -61,7 +63,7 @@ static struct nvhost_device_data t25x_nvdla1_info = {
.resource_policy = RESOURCE_PER_CHANNEL_INSTANCE,
.finalize_poweron = nvdla_finalize_poweron,
.prepare_poweroff = nvdla_prepare_poweroff,
.flcn_isr = nvdla_flcn_isr,
.flcn_isr = nvdla_flcn_isr,
.self_config_flcn_isr = true,
.vm_regs = {{0x30, true}, {0x34, false} },
.firmware_name = NV_DLA_TEGRA25X_FW,

View File

@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* Device data for T264 simulator
* Device data for t264 simulator
*/
#ifndef __NVHOST_NVDLA_T264_SIM_H__
@@ -14,6 +14,7 @@
#include "dla_t25x_fw_version.h"
static struct nvhost_device_data t264_sim_nvdla0_info = {
.devfs_name = "nvdla0",
.devfs_name_family = "nvdla",
.class = NV_DLA0_SIM_CLASS_ID,
.clocks = {
@@ -23,7 +24,7 @@ static struct nvhost_device_data t264_sim_nvdla0_info = {
.resource_policy = RESOURCE_PER_CHANNEL_INSTANCE,
.finalize_poweron = nvdla_finalize_poweron,
.prepare_poweroff = nvdla_prepare_poweroff,
.flcn_isr = nvdla_flcn_isr,
.flcn_isr = nvdla_flcn_isr,
.self_config_flcn_isr = true,
.vm_regs = {{0x30, true}, {0x34, false} },
.firmware_name = NV_DLA_TEGRA25X_FW,

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/* SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* NVDLA device implementation as AXI client.
*/
@@ -70,7 +70,12 @@ static int32_t s_nvdla_module_get_platform_resources(
regs = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(regs)) {
err = PTR_ERR(regs);
#if defined(BUG_5054810) && (BUG_5054810 == 1)
nvdla_dbg_err(pdev, "Failed to map the resources. Continuing as WAR.\n");
continue;
#else
goto fail;
#endif
}
pdata->aperture[i] = regs;
@@ -181,16 +186,16 @@ static int32_t s_nvdla_module_device_create(struct platform_device *pdev)
struct class *dla_class;
dev_t devno;
err = alloc_chrdev_region(&devno, 0, NVDLA_NUM_CDEV, "nvhost");
err = alloc_chrdev_region(&devno, 0, NVDLA_NUM_CDEV, "nvdla");
if (err < 0) {
nvdla_dbg_err(pdev, "failed to reserve chrdev region\n");
goto fail;
}
#if defined(NV_CLASS_CREATE_HAS_NO_OWNER_ARG) /* Linux v6.4 */
dla_class = class_create(pdev->dev.of_node->name);
dla_class = class_create(pdata->devfs_name);
#else
dla_class = class_create(THIS_MODULE, pdev->dev.of_node->name);
dla_class = class_create(THIS_MODULE, pdata->devfs_name);
#endif
if (IS_ERR(dla_class)) {
nvdla_dbg_err(pdev, "failed to create class\n");
@@ -212,10 +217,10 @@ static int32_t s_nvdla_module_device_create(struct platform_device *pdev)
devno,
NULL,
"nvhost-ctrl-%s",
pdev->dev.of_node->name);
pdata->devfs_name);
if (IS_ERR(dev)) {
nvdla_dbg_err(pdev, "failed to create nvhost-ctrl-%s device\n",
pdev->dev.of_node->name);
pdata->devfs_name);
err = PTR_ERR(dev);
goto delete_cdev;
}
@@ -272,7 +277,7 @@ int32_t nvdla_module_init(struct platform_device *pdev)
goto disable_pm;
}
pdata->debugfs = debugfs_create_dir(pdev->dev.of_node->name, NULL);
pdata->debugfs = debugfs_create_dir(pdata->devfs_name, NULL);
return 0;