Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5260065pxv; Tue, 6 Jul 2021 22:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9oheCjImnVU1tv8N41myD1QMYIZy1XIKHN7dDZVZdTI36Cj0m/PAWG4GQW1Jergl9zwt3 X-Received: by 2002:a17:906:4882:: with SMTP id v2mr22700400ejq.134.1625636499907; Tue, 06 Jul 2021 22:41:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1625636499; cv=pass; d=google.com; s=arc-20160816; b=kHzuppeu2oDK6c1OOVZ5SBYNbU8HdPgY4Rt76lghLwhcC88AOnSs6y4vmfe06OiGzQ jwGMkAm4OIp/RaGQo99pseu0ob7nm0ULDARBXMgbozr6A1uWuwoPOXS9lOfG0ZrSSs6f kYu7Ha2Lv77KQ6J3t14yyqF6e0fMOxWn8crhws4m7teLggixpWEijDeak3C2xALpgRfJ 0nICUVqcbz7iLG4eFe4PwHa9jG9wtqQS38B5pDzGp0PcYStIAC/BlLBN0LJR5wTb3EGx WUrez6S+XP4BACpPakgIb1P/hycKTgUUB93+G6zaLU8tb4L8ufwjydUQPN5GhiiUKNgT H6jw== 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=PU2mKuwQXdBVos+DMKe46QGy6YeizEUhYmEPIaBZrQk=; b=jzhuHyN1g88cjTRb5kAxhVrHYFD/jVU/HQmhBhHRYT1d4BnEInCyc4Cj3kABBILlN1 cxx2NWUIwx9zllFWd/iivGt1HbZ8WB/rfpJ6+5504rqoyqZAWVrniQEofqtd0FPnozB9 AFyXZbvvKTz/XW2qOBVibDoaP7RrBkTngi4ClUdPLTjt8A2ANg/JCdDKfBjBLGyPWE2D o1K0mKtyroOGrhDQtmzjNg8clA19ak4401BARfty5qOBOYXwnTUhzbCGI5QswmYBPRrk 1oH95NMrUh+PY1MuMiAT8nwITiPOnGEOkKfPMFqO3iUdi2pbnE8hTdakHtxsAoilZ5GV LteQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=nShwStSa; 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 p4si17570086edq.225.2021.07.06.22.41.17; Tue, 06 Jul 2021 22:41:39 -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=nShwStSa; 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 S230280AbhGGFm0 (ORCPT + 99 others); Wed, 7 Jul 2021 01:42:26 -0400 Received: from mail-bn7nam10on2052.outbound.protection.outlook.com ([40.107.92.52]:60896 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230250AbhGGFm0 (ORCPT ); Wed, 7 Jul 2021 01:42:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l9DRrC5GQgoc4L2u5ddobVwPeltB/HFa9C3jXghxMiGZHG3gqY4hGjALhhbBWbekxYlWN1urHwa/RUcrhiBqIS454tKogPzzSZditWoDmerBA7xHHpM5k09pc4IfGzIJ2sMgC7S5/zAH2Q4b90TTAhQB/eqt87YeDFJLrH0SnDVjFAM9D0RNihwg/BTfFoBNzqjIxSz1CKLo+76j1fIfzclVk49RKR4C5hUI384s8UxeYLNsG3GxSRRjJdi3Mlt+MoIeXkRYGU38z1Lz+WMAHQ7D7PCCJqeKZGrRY3gYk1xELtCCZopDCqQjLa5+Dt9meoh0lx1T2DO5qUKNBbSK7g== 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=PU2mKuwQXdBVos+DMKe46QGy6YeizEUhYmEPIaBZrQk=; b=a5B196IywyJA2XtZWRXWaS69T5GpJQZRgfFE7+cTpavBGnv3stSSuZQtpj3WKmZFCILNUg89damfBiBUHxkGWDMegWKYn4dOox4mFV1HuGf6VXD5A+hJFOvWDuqZb0xTk4PhH3KbL/yZdEIl1I/IrA7fc5MtizjIsdrqQs/34B/lMzNc7BTf/jjfcsbhXUZKNMjv/t8Lsa1D+Vi0QMg0KdwmP258ahIxnHeIOBOLp+gfDMTKnxtsybwoR3YPAehXElrt4dWS5TV6i0Nl2MFoEsVHtza6D4WVhIT3y9LxlKM8z/cIvMNh4SqdvktSwov/YSD6OY485s9zt1we1zWvYg== 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=PU2mKuwQXdBVos+DMKe46QGy6YeizEUhYmEPIaBZrQk=; b=nShwStSayvuI8M4B3+XBzs/vcEjjR3ZB2rRHT98+QwyByXiyQMdOOKEDVYfkg18RA1fvQooy9djx5E68Agpccn1tZT5RNzJP2kfeAbuyWibZFi2rol/xeHcPV6I25+BHk3Jd9lB5j8wwMpSgzYuEpBqrarLTPdTz2HQGTdniXvk= Received: from BN6PR2001CA0004.namprd20.prod.outlook.com (2603:10b6:404:b4::14) by MW2PR12MB2508.namprd12.prod.outlook.com (2603:10b6:907:9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 05:39:43 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::79) by BN6PR2001CA0004.outlook.office365.com (2603:10b6:404:b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Wed, 7 Jul 2021 05:39:43 +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=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4308.20 via Frontend Transport; Wed, 7 Jul 2021 05:39:43 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 7 Jul 2021 00:39:43 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 6 Jul 2021 22:39:42 -0700 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; Wed, 7 Jul 2021 00:39:31 -0500 From: Vijendar Mukunda To: , CC: , , "Vijendar Mukunda" , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , "Vijendar Mukunda" , open list Subject: [PATCH 02/12] ASoC: amd: add Vangogh ACP PCI driver Date: Wed, 7 Jul 2021 11:26:13 +0530 Message-ID: <20210707055623.27371-3-vijendar.mukunda@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707055623.27371-1-vijendar.mukunda@amd.com> References: <20210707055623.27371-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: d450bc19-5aff-427e-f37c-08d941099f70 X-MS-TrafficTypeDiagnostic: MW2PR12MB2508: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:565; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x5Kh53vbvbp3FrAW9an8SqMRkVQMGeBIwhcYbfIHpwuQ22KWP6ukZcjCZt9rXTrTXowWcTGSAURRB58Iwg5sKAl2FK2MkRwoan/cfT6jQxfvxsoaDrZJM4KI/0D0Kh+Y4w4iChKZI6vcYsFxhfijlYVuhaSfWz5CEB1KFKFbm7NcLyjdZHvrLLrXu5UJd8XW3U0TMiWqtgs2GHE9KmLcjQyJUvXQN40ihJOYoreJTCT1Nmd9/wGW0SPhpMExp4co2m8PGU/hh8kS6qqnel4yYNf4qjUKggWSwSlhTTxGSVJ8ZykJ0WN2Mn3zUISRNPPL4T9S871RIk+QHXHG0BuBLxujNq82+RlhkqDmLaRYPi+9fepNt67lbbvYhw6bFcFC3KBri9FuYrSMWOVkaYzCv0WSERg1gwFmrZjT4hg/Rj9Gfmt28bgVS1PXwVohShwNbFYhvrHv3Bx44fnI7/qD5JoJ0h7oqn2XaKetKBujLphT/AdeiYbkn+MSgztfoglrMPO6h3nAc8m6g7O7P2IZvxx/lEwjfwFJLMVi3nv1aDpP0+w6Pt+sd5P4PMigsLqzomyZ8WNGNaEcPPDDTJhlkEElaHNvgG3WIghRmHZxRoqRJxRZYUQzYJux9frAGFTXey48wV/xquG9ce+1SsH9Zf9u7X1Y2ycI5xSACvhla1G0z/ib24YBBiKO42xsTLbrIJTroAEfF3z9K3CkY+9FlxLtkCmee9YCj6ieqy29TCw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(136003)(39860400002)(346002)(396003)(376002)(46966006)(36840700001)(47076005)(110136005)(316002)(44832011)(5660300002)(36756003)(356005)(82310400003)(82740400003)(36860700001)(83380400001)(81166007)(86362001)(2616005)(1076003)(6666004)(54906003)(478600001)(70586007)(4326008)(426003)(26005)(186003)(2906002)(70206006)(336012)(8936002)(8676002)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 05:39:43.4586 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d450bc19-5aff-427e-f37c-08d941099f70 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2508 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vijendar Mukunda ACP is a PCI audio device. This patch adds PCI driver to bind to this device and get PCI resources. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/vangogh/acp5x.h | 21 ++++++++ sound/soc/amd/vangogh/pci-acp5x.c | 87 +++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 sound/soc/amd/vangogh/acp5x.h create mode 100644 sound/soc/amd/vangogh/pci-acp5x.c diff --git a/sound/soc/amd/vangogh/acp5x.h b/sound/soc/amd/vangogh/acp5x.h new file mode 100644 index 000000000000..a5e7f7cb65a1 --- /dev/null +++ b/sound/soc/amd/vangogh/acp5x.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * AMD ALSA SoC PCM Driver + * + * Copyright (C) 2021 Advanced Micro Devices, Inc. All rights reserved. + */ + +#include "vg_chip_offset_byte.h" + +#define ACP5x_PHY_BASE_ADDRESS 0x1240000 +#define ACP_DEVICE_ID 0x15E2 + +static inline u32 acp_readl(void __iomem *base_addr) +{ + return readl(base_addr - ACP5x_PHY_BASE_ADDRESS); +} + +static inline void acp_writel(u32 val, void __iomem *base_addr) +{ + writel(val, base_addr - ACP5x_PHY_BASE_ADDRESS); +} diff --git a/sound/soc/amd/vangogh/pci-acp5x.c b/sound/soc/amd/vangogh/pci-acp5x.c new file mode 100644 index 000000000000..e56d060a5cb9 --- /dev/null +++ b/sound/soc/amd/vangogh/pci-acp5x.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// AMD Vangogh ACP PCI Driver +// +// Copyright (C) 2021 Advanced Micro Devices, Inc. All rights reserved. + +#include +#include +#include + +#include "acp5x.h" + +struct acp5x_dev_data { + void __iomem *acp5x_base; +}; + +static int snd_acp5x_probe(struct pci_dev *pci, + const struct pci_device_id *pci_id) +{ + struct acp5x_dev_data *adata; + int ret; + u32 addr; + + if (pci->revision != 0x50) + return -ENODEV; + + if (pci_enable_device(pci)) { + dev_err(&pci->dev, "pci_enable_device failed\n"); + return -ENODEV; + } + + ret = pci_request_regions(pci, "AMD ACP5x audio"); + if (ret < 0) { + dev_err(&pci->dev, "pci_request_regions failed\n"); + goto disable_pci; + } + + adata = devm_kzalloc(&pci->dev, sizeof(struct acp5x_dev_data), + GFP_KERNEL); + if (!adata) { + ret = -ENOMEM; + goto release_regions; + } + addr = pci_resource_start(pci, 0); + adata->acp5x_base = devm_ioremap(&pci->dev, addr, + pci_resource_len(pci, 0)); + if (!adata->acp5x_base) { + ret = -ENOMEM; + goto release_regions; + } + pci_set_master(pci); + pci_set_drvdata(pci, adata); + +release_regions: + pci_release_regions(pci); +disable_pci: + pci_disable_device(pci); + + return ret; +} + +static void snd_acp5x_remove(struct pci_dev *pci) +{ + pci_release_regions(pci); + pci_disable_device(pci); +} + +static const struct pci_device_id snd_acp5x_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_DEVICE_ID), + .class = PCI_CLASS_MULTIMEDIA_OTHER << 8, + .class_mask = 0xffffff }, + { 0, }, +}; +MODULE_DEVICE_TABLE(pci, snd_acp5x_ids); + +static struct pci_driver acp5x_driver = { + .name = KBUILD_MODNAME, + .id_table = snd_acp5x_ids, + .probe = snd_acp5x_probe, + .remove = snd_acp5x_remove, +}; + +module_pci_driver(acp5x_driver); + +MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); +MODULE_DESCRIPTION("AMD Vangogh ACP PCI driver"); +MODULE_LICENSE("GPL v2"); -- 2.17.1