From dfc3347d287dbe4b6ee972b7dc6c23c083e92ca6 Mon Sep 17 00:00:00 2001 From: Hariharan Sivaraman Date: Tue, 7 May 2019 15:31:33 +0530 Subject: [PATCH] adsp: add support for ivc based adsp reset control For virtualized configurations, ADSP reset will be owned only by Audio server. - Moving tegra-virt-alt-ivc to drivers/.../nvaudio_ivc/ to enable Audio IVC to be built as part of Image - Adding support in nvadsp driver to communicate with Audio server for asserting or deasserting ADSP. Jira EMA-1208 Change-Id: I6773c35edf2c646aa9fd7ec0aa5eceb992dffa35 Signed-off-by: Hariharan Sivaraman Reviewed-on: https://git-master.nvidia.com/r/2113661 Reviewed-by: Uday Gupta GVS: Gerrit_Virtual_Submit Reviewed-by: Mohan Kumar D Reviewed-by: Nitin Pai Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/platform/tegra/nvadsp/Makefile | 4 ++ drivers/platform/tegra/nvadsp/dev-t18x.c | 71 +++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/platform/tegra/nvadsp/Makefile b/drivers/platform/tegra/nvadsp/Makefile index fec9a585..948e9eff 100644 --- a/drivers/platform/tegra/nvadsp/Makefile +++ b/drivers/platform/tegra/nvadsp/Makefile @@ -36,3 +36,7 @@ endif ifeq ($(CONFIG_TEGRA_ADSP_LPTHREAD),y) nvadsp-objs += adsp_lpthread.o endif + +ifeq ($(CONFIG_TEGRA_VIRT_AUDIO_IVC),y) +ccflags-y += -I$(srctree.nvidia)/drivers/platform/tegra/nvaudio_ivc/ +endif diff --git a/drivers/platform/tegra/nvadsp/dev-t18x.c b/drivers/platform/tegra/nvadsp/dev-t18x.c index d002e840..0f417a33 100644 --- a/drivers/platform/tegra/nvadsp/dev-t18x.c +++ b/drivers/platform/tegra/nvadsp/dev-t18x.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2015-2019, NVIDIA Corporation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -18,6 +18,12 @@ #include #include +#include + +#ifdef CONFIG_TEGRA_VIRT_AUDIO_IVC +#include "tegra_virt_alt_ivc_common.h" +#include "tegra_virt_alt_ivc.h" +#endif #include "dev.h" #include "dev-t18x.h" @@ -199,12 +205,75 @@ static int __deassert_t18x_adsp(struct nvadsp_drv_data *d) return ret; } +#ifdef CONFIG_TEGRA_VIRT_AUDIO_IVC +static int __virt_assert_t18x_adsp(struct nvadsp_drv_data *d) +{ + int err; + struct nvaudio_ivc_msg msg; + struct nvaudio_ivc_ctxt *hivc_client = nvaudio_get_ivc_alloc_ctxt(); + + if (!hivc_client) { + pr_err("%s: Failed to allocate IVC context\n", __func__); + return -ENODEV; + } + + memset(&msg, 0, sizeof(struct nvaudio_ivc_msg)); + msg.cmd = NVAUDIO_ADSP_RESET; + msg.params.adsp_reset_info.reset_req = ASSERT; + msg.ack_required = true; + + err = nvaudio_ivc_send_receive(hivc_client, + &msg, + sizeof(struct nvaudio_ivc_msg)); + if (err < 0) + pr_err("%s: error on ivc_send_receive\n", __func__); + + return 0; +} + +static int __virt_deassert_t18x_adsp(struct nvadsp_drv_data *d) +{ + int err; + struct nvaudio_ivc_msg msg; + struct nvaudio_ivc_ctxt *hivc_client = nvaudio_get_ivc_alloc_ctxt(); + + if (!hivc_client) { + pr_err("%s: Failed to allocate IVC context\n", __func__); + return -ENODEV; + } + + memset(&msg, 0, sizeof(struct nvaudio_ivc_msg)); + msg.cmd = NVAUDIO_ADSP_RESET; + msg.params.adsp_reset_info.reset_req = DEASSERT; + msg.ack_required = true; + + err = nvaudio_ivc_send_receive(hivc_client, + &msg, + sizeof(struct nvaudio_ivc_msg)); + if (err < 0) + pr_err("%s: error on ivc_send_receive\n", __func__); + + return 0; +} +#endif + int nvadsp_reset_t18x_init(struct platform_device *pdev) { struct nvadsp_drv_data *d = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; int ret = 0; +#ifdef CONFIG_TEGRA_VIRT_AUDIO_IVC + struct device_node *node = dev->of_node; + + if (of_device_is_compatible(node, "nvidia,tegra18x-adsp-hv")) { + d->assert_adsp = __virt_assert_t18x_adsp; + d->deassert_adsp = __virt_deassert_t18x_adsp; + d->adspall_rst = NULL; + return 0; + } +#endif + d->assert_adsp = __assert_t18x_adsp; d->deassert_adsp = __deassert_t18x_adsp; d->adspall_rst = devm_reset_control_get(dev, "adspall");