Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3899740pxv; Mon, 19 Jul 2021 11:28:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNzOqIlrliPVRm/rolQ9TX5w5+oOu1susBGU0pXki2Qp+ssZj9L1p4E17b0YEjq9Jw2yR7 X-Received: by 2002:a92:dc4a:: with SMTP id x10mr17616909ilq.166.1626719316841; Mon, 19 Jul 2021 11:28:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626719316; cv=pass; d=google.com; s=arc-20160816; b=tTA0igw62/SYkGSO55MpBbU6gf1lH9T2ANleDwgxSdL5Q8a/SFTjpxhJBuM3llk93V zBvfhHhvrIzFcBEgBrtLCVFam2R7RnJsrFawbSlQXiudN8Qidejtle0TWpwwWddcIUY3 G+kgh1ZysZ6lUMwHoHdcm/MFEjnK26hXKQQK3p7NTTm3kdHZgnfvBXj87Eeh5gr36Z9d xbwfXUPAxH878fPhiDvxQLl9Rr+RMP0eDMPlJuEY0ialobvdihurilwgXUhI21JSNcL5 1FLTJpFgXiMF+0zlKRapG32h2YpgftI7nSYGAp6l3fLtHlA5ro4zCXevVUIdQnEV7614 2Lyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=l2/jxCJkE0XAdeEzUkmyD7xCbQvWBCiLfJMyp7DZt8A=; b=dFz+RSEAu2j82+icyD0wFjgsvrAtVz72HE9cXnl++X1wNU4OL7fF3UTgjMEB07gM7u OTB7UlSoOcP0O95NgEhhKek31oOiXIm/CeY0rBPLLP9yIedeVulzBu14n8pU403SGWrb OqNulPo3I+XonCjjI5kMMZlnBN/ETCNBLamvUnf9uIMskrmI+rv8ABEM6CvRZnS88lcr WdpXlMdxJXVi4NWaYcoZhIm606u01SWS4M9jBo2kDmngigpNFctCC6b3wC7nCjLWNeRB YAYVAbI/4MymFi/v7ZaspeDJOQg3UCj/moBOIPUrwHOI5N1X+CWxSt6JS6RAyOl1/IdV tF6w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=VRw5yKrR; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p10si13896123iov.66.2021.07.19.11.28.24; Mon, 19 Jul 2021 11:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=VRw5yKrR; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381857AbhGSRiw (ORCPT + 99 others); Mon, 19 Jul 2021 13:38:52 -0400 Received: from mail-bn8nam11on2066.outbound.protection.outlook.com ([40.107.236.66]:22817 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1351239AbhGSPyY (ORCPT ); Mon, 19 Jul 2021 11:54:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IkaHU4BR2irPpZ9Y72RjrCbdc65i8MB2oRK2hUGKmzdWxYoap2JewvK7Osn3MsM68B1xHkSiyYvubn0Lq9rlE9Wzd0+AjPrjcgtr0BqXpwRPhS0yxTIHlqXX9WinTJysKMkgs69/CPPftuefRRHJJUY+Rtxh68FGa9TOozh9j1d3VWnv9oc40k8T24yNFptGcvz9XDCXYYxa1tcbCkj8prfx8kOixtdFM++II80bJINNRUN7a0MWO+PVBOuSmvcBGPjVeHdGU7hlVr6S6vEy71166sPGURGv0Pf9enu6MDw6FzTY+QVN71BsglFgHwOuL/9P+mlfopb7AAE0YOB9GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l2/jxCJkE0XAdeEzUkmyD7xCbQvWBCiLfJMyp7DZt8A=; b=iMFhdvVnD3TEq+KPV+ax3cjhbWeOomxqB1LuHsX6r0qsZ0bayK99r1oFwTUbdmWne7LJo0cEL6HMJ977k4Hv9jRiP16fYc4Bc93coqM4H3EawdcO5+75af9M1o3EGQ6VA4tTnWyFChlfqZjMwOWf6N25XrU+Jk0lQAT1FxgWWIrbAqJwIHxP0S0ZB56tYRWUdJcP1QH17j+etZuxaU3t7KfAWwIvPFzCf2gqeJ2chX3Y7bxQpJaZDCqFkzMPgoNxoIWoOqrH9nFXtVCqPBEfW2TvDbkpxEOMCbItFdCgq2ANsxdc+x3NDnvHtu+xkgWcVhQDDGUrRB0czWqwzkMGPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l2/jxCJkE0XAdeEzUkmyD7xCbQvWBCiLfJMyp7DZt8A=; b=VRw5yKrR7/ND5GjECzJM1OLh9shNueMmZNMlFa2bPJ57qyB56mFO5iuBujUNqgpBUZ5n3lFeF6UcyxhjNXBS6asL9t9P0uXgFiLGB22QjY5/4/Bcrjw8nH6U2tolKUefBBKA/JNkPpWRCIEPXGG1SejJqEeTSThqIYpCRv+Li3s= Received: from DS7PR03CA0101.namprd03.prod.outlook.com (2603:10b6:5:3b7::16) by PH0PR12MB5402.namprd12.prod.outlook.com (2603:10b6:510:ef::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Mon, 19 Jul 2021 16:35:01 +0000 Received: from DM6NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::c7) by DS7PR03CA0101.outlook.office365.com (2603:10b6:5:3b7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 16:35:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT056.mail.protection.outlook.com (10.13.173.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 16:35:01 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 19 Jul 2021 11:35:00 -0500 Received: from LinuxHost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 19 Jul 2021 11:34:51 -0500 From: Vijendar Mukunda To: , CC: , , , Vijendar Mukunda , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , open list Subject: [PATCH V3 03/12] ASoc: amd: add acp5x init/de-init functions Date: Mon, 19 Jul 2021 22:21:31 +0530 Message-ID: <20210719165140.16143-4-vijendar.mukunda@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210719165140.16143-1-vijendar.mukunda@amd.com> References: <20210719165140.16143-1-vijendar.mukunda@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ca58542-542e-4f8d-04db-08d94ad327bf X-MS-TrafficTypeDiagnostic: PH0PR12MB5402: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:175; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WtE4YwxKlM82p0F1QM47+O9MHV/1mD4K8WKetZCAcfxw1RTzyjWGTZKwDaPUOdhPc5kyaJC+kybo/hGBr1SXdGkZZDQeRk/xf6waIcZ4bgyOCXNgARltxJQMyW39k+ExS3fzE3MrT3DQBlU4Ph4Db8BqriWl+zxdhwo4Yy4TFUqBcd9PnPVNBpCEAShIM7VHNYgs2+JPt0h2q/mrJSzZXjgs0elLc1UR2lsYkUuM7NTDfpeNQZNQp+dhhCYraZHQRcU9dOEkIOLvz2NfAATL+nZ7HgWNFkcMf3U2C0agD60zoNvWwzHSjirxFQz3/PoDRQk1+aDNg7LO+5tpZ7/pfqxlXIr43XyiPd8TOhsuTDUR1yQyZ9FedWsqQ7WplSTmEuWg4M1/sWfHWEOd4E9VNKGwRmCyV5m9V86qWaslKZd872bmHrbavoPIA0Dbq91vGBSJNu3eQoAlBenFUdU+Dwa9qlHqimjwdPw5WTWDc0YjyFWQPtZooM+30jEMkqqvsza5ILZJaKKgfRJLtXtw4MobDpZ5UhpkCW0tuKCLpbYS1ZB6kpcQW6IBpmt1xo8dnMTb5PIRe9O3DqkSbv/MKSo2AXPWf3y3RZWMeBIBG4QvOQTNkL/4/jcJfI6oYQ3uc8ZDdggK+uPfoAPDoKlS6biqxtLwB6NlhUjroQRzJIP77jiDvVjhZkVdvPPvpdaeRmsqD4MOOYY88I+cmuXOEU6iSWQlysC0HWdsHQet5Pn54h+yS8nOC6vxVphLKWrI53cmyphu6V16/mETUoL/UNyhG+kTcp63NLqYZjg2gN8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(186003)(26005)(8936002)(82310400003)(81166007)(356005)(70206006)(316002)(86362001)(70586007)(7696005)(6666004)(47076005)(8676002)(508600001)(36756003)(336012)(54906003)(110136005)(36860700001)(4326008)(426003)(5660300002)(2906002)(1076003)(2616005)(44832011)(42413003)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 16:35:01.3941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ca58542-542e-4f8d-04db-08d94ad327bf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5402 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Vangogh ACP PCI driver init/deinit functions. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/vangogh/acp5x.h | 12 ++++ sound/soc/amd/vangogh/pci-acp5x.c | 106 ++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/sound/soc/amd/vangogh/acp5x.h b/sound/soc/amd/vangogh/acp5x.h index 8afa8144af4e..708586109315 100644 --- a/sound/soc/amd/vangogh/acp5x.h +++ b/sound/soc/amd/vangogh/acp5x.h @@ -9,6 +9,18 @@ #define ACP5x_PHY_BASE_ADDRESS 0x1240000 #define ACP_DEVICE_ID 0x15E2 +#define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 + +#define ACP_PGFSM_CNTL_POWER_ON_MASK 0x01 +#define ACP_PGFSM_CNTL_POWER_OFF_MASK 0x00 +#define ACP_PGFSM_STATUS_MASK 0x03 +#define ACP_POWERED_ON 0x00 +#define ACP_POWER_ON_IN_PROGRESS 0x01 +#define ACP_POWERED_OFF 0x02 +#define ACP_POWER_OFF_IN_PROGRESS 0x03 + +#define ACP_ERR_INTR_MASK 0x20000000 +#define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF /* common header file uses exact offset rather than relative * offset which requires substraction logic from base_addr diff --git a/sound/soc/amd/vangogh/pci-acp5x.c b/sound/soc/amd/vangogh/pci-acp5x.c index e56d060a5cb9..523b962fe35e 100644 --- a/sound/soc/amd/vangogh/pci-acp5x.c +++ b/sound/soc/amd/vangogh/pci-acp5x.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "acp5x.h" @@ -14,6 +15,101 @@ struct acp5x_dev_data { void __iomem *acp5x_base; }; +static int acp5x_power_on(void __iomem *acp5x_base) +{ + u32 val; + int timeout; + + val = acp_readl(acp5x_base + ACP_PGFSM_STATUS); + + if (val == 0) + return val; + + if ((val & ACP_PGFSM_STATUS_MASK) != + ACP_POWER_ON_IN_PROGRESS) + acp_writel(ACP_PGFSM_CNTL_POWER_ON_MASK, + acp5x_base + ACP_PGFSM_CONTROL); + timeout = 0; + while (++timeout < 500) { + val = acp_readl(acp5x_base + ACP_PGFSM_STATUS); + if ((val & ACP_PGFSM_STATUS_MASK) == ACP_POWERED_ON) + return 0; + udelay(1); + } + return -ETIMEDOUT; +} + +static int acp5x_reset(void __iomem *acp5x_base) +{ + u32 val; + int timeout; + + acp_writel(1, acp5x_base + ACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = acp_readl(acp5x_base + ACP_SOFT_RESET); + if (val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK) + break; + cpu_relax(); + } + acp_writel(0, acp5x_base + ACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = acp_readl(acp5x_base + ACP_SOFT_RESET); + if (!val) + return 0; + cpu_relax(); + } + return -ETIMEDOUT; +} + +static void acp5x_enable_interrupts(void __iomem *acp5x_base) +{ + acp_writel(0x01, acp5x_base + ACP_EXTERNAL_INTR_ENB); +} + +static void acp5x_disable_interrupts(void __iomem *acp5x_base) +{ + acp_writel(ACP_EXT_INTR_STAT_CLEAR_MASK, acp5x_base + + ACP_EXTERNAL_INTR_STAT); + acp_writel(0x00, acp5x_base + ACP_EXTERNAL_INTR_CNTL); + acp_writel(0x00, acp5x_base + ACP_EXTERNAL_INTR_ENB); +} + +static int acp5x_init(void __iomem *acp5x_base) +{ + int ret; + + /* power on */ + ret = acp5x_power_on(acp5x_base); + if (ret) { + pr_err("ACP5x power on failed\n"); + return ret; + } + /* Reset */ + ret = acp5x_reset(acp5x_base); + if (ret) { + pr_err("ACP5x reset failed\n"); + return ret; + } + acp5x_enable_interrupts(acp5x_base); + return 0; +} + +static int acp5x_deinit(void __iomem *acp5x_base) +{ + int ret; + + acp5x_disable_interrupts(acp5x_base); + /* Reset */ + ret = acp5x_reset(acp5x_base); + if (ret) { + pr_err("ACP5x reset failed\n"); + return ret; + } + return 0; +} + static int snd_acp5x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -50,6 +146,9 @@ static int snd_acp5x_probe(struct pci_dev *pci, } pci_set_master(pci); pci_set_drvdata(pci, adata); + ret = acp5x_init(adata->acp5x_base); + if (ret) + goto release_regions; release_regions: pci_release_regions(pci); @@ -61,6 +160,13 @@ static int snd_acp5x_probe(struct pci_dev *pci, static void snd_acp5x_remove(struct pci_dev *pci) { + struct acp5x_dev_data *adata; + int ret; + + adata = pci_get_drvdata(pci); + ret = acp5x_deinit(adata->acp5x_base); + if (ret) + dev_err(&pci->dev, "ACP de-init failed\n"); pci_release_regions(pci); pci_disable_device(pci); } -- 2.17.1