Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp11176pxv; Wed, 21 Jul 2021 14:04:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy09UWJy8c2cSAhbiaI6vfpVo+5t/59Xe7+/ruUd7Sg7aWcyMpBWpXsqFmo241a03Hn/2Bg X-Received: by 2002:a92:d78a:: with SMTP id d10mr25355086iln.303.1626901455526; Wed, 21 Jul 2021 14:04:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626901455; cv=pass; d=google.com; s=arc-20160816; b=oqjEuMcVfrflNFoA4tShL6LHaAsl0dfsh39yZ8Mc2p04C1uKgA1sM8sxke0gTSTp7t XS1YmaOVtfLRxnV9VqA0oew63LA8811BguiA6vp1/Oh3/UDUZbVCzL5vV0Qh0VDF/8ax Cm1l99+z5kht8kqGdHhy35bif2X0zTPcIgiUTrdowbQMbS37G6yfEfzmMqinSee0HuW4 v70ZHZbg19+nSg3QMGTGK0xapDrIJj3pb3kGyE1srmnsmUHkQ9ZN7FaihfTn9nO/FB8+ wF0J2XqRtwFg9JJUI8G4zh4Zwrnp4bArb0ZqS+Do7rDpTOY0PN+0UM/FSKDxMgBzhPpd Bc+Q== 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=DN3+i/wY7Jl9O555SPM6wW41d20AWyAk8t4niZzvU/I=; b=FFG7mzdoNl2xdkbUI5rUDD7EuYGl74Cm33f90I5X6TmrD7CQm5BvKvRLuHafKG7qpK erorzhkpglnv9LNeUsIPYQl+SOUoOMNjC095Gqp6/g+ltrnIyiS0ZSinGS1A3B5Ctw/w cKuxGXFuiKlAFE5Yra++SP9kGuDSj7XRJRnWBPyA3xIC44yMnXOVMr/nKHCmix32Xvvn 27wONaxMXDoq6ZaP2GAQtpc13CSZiDUcv1qs8pubCWmYPewv4gndaGz4qsenKcdi9hJa fG6+u3UzWHMIJ6saVQtakAOaAFlOgtcqKr0CdF4SIoG2UwhIwsIZ/c46DCxV8JONbVwA lfRw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=UYB7+uj3; 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 p20si17772534ioo.40.2021.07.21.14.04.04; Wed, 21 Jul 2021 14:04:15 -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=UYB7+uj3; 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 S236930AbhGURHI (ORCPT + 99 others); Wed, 21 Jul 2021 13:07:08 -0400 Received: from mail-mw2nam12on2086.outbound.protection.outlook.com ([40.107.244.86]:19680 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236724AbhGURHH (ORCPT ); Wed, 21 Jul 2021 13:07:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NiX6liyUDtJRxreFRY/FX9lF2/b5gtVixTdBTLCj5mpN9Zv2HZtXSTrwOrdkPKs7WThCExxVNsl3Ucs/kI11XO7VytOULwoHe3h236omyDFcSyfIuHory4GPb5GoSF6u8aGV0j9OpSh0s+uJubfrPFOKja9YdtXvo090jzHTeTfy3veJrKByKeUqhPoWmiUoyZWuSF6S8SFs/+S3Qw6Wzawx7ro2A/Tq/Hh/6JNo2smIV5av9yz3KR909nQT9Hy/+Wc/yGA8k3ccyTBfi35dqCF+f5XnVbkwdWOscfbgHC6lj298ROuna+CsvMlgE+tDuoRD4jMafAvCON31yiO38A== 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=DN3+i/wY7Jl9O555SPM6wW41d20AWyAk8t4niZzvU/I=; b=SMCH8xli50xfzyPXaUGnjZX5zMkPNbUqo++HiI9EwRnH9WEBT7gSrYuS8YE5QPHCiUmB9noH7BACjPSu3D+7BfYV7uCq/iEgFBhRSAdwKm2mSiGD3Ii1iHDstXkhZP/MSG3ZqUDgCHQ4GVnbZOhkcZ98NUw4fzEix4ZjodxdSHi4+7WpzBbT9juW382UUn5loByEUMe+L82p5cKd76i9dcha9DtuoOrd4k7o17Pftkc2chXIGRibUJDIXHhS/5nBXgMFmA0NU+JZmQGfF2LNE2wAXF7RWtbnua4gfvxXVMoHM2WsxqNrbSEYQRf27B2v0Fo+5z1XNQr/RLMf3BFPyQ== 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=DN3+i/wY7Jl9O555SPM6wW41d20AWyAk8t4niZzvU/I=; b=UYB7+uj3wO3wPoAC9O6l/UK3m01VT6BdTFUBRGKg9le087PLCAUug4oqGvMiSJEA1kigLOP29y5+3os9Hw/jJ6eEZh/T2JeyfTs65TniNR6POqJPYd7Ryhy4L0oKSMkp1oNWPGQnqtJ+s1OMaLzBpb6hunialcidbhgggw1CXfg= Received: from DM5PR11CA0003.namprd11.prod.outlook.com (2603:10b6:3:115::13) by DM5PR12MB1881.namprd12.prod.outlook.com (2603:10b6:3:10f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.29; Wed, 21 Jul 2021 17:47:42 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:3:115:cafe::91) by DM5PR11CA0003.outlook.office365.com (2603:10b6:3:115::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Wed, 21 Jul 2021 17:47:42 +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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 17:47:41 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Wed, 21 Jul 2021 12:47:41 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 21 Jul 2021 12:47:40 -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; Wed, 21 Jul 2021 12:47:36 -0500 From: Vijendar Mukunda To: , CC: , , , , Vijendar Mukunda , Liam Girdwood , "Jaroslav Kysela" , Takashi Iwai , open list Subject: [PATCH v5 02/12] ASoC: amd: add Vangogh ACP PCI driver Date: Wed, 21 Jul 2021 23:34:18 +0530 Message-ID: <20210721180430.11571-3-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210721180430.11571-1-Vijendar.Mukunda@amd.com> References: <20210721180430.11571-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: 8ba8a8a4-5ef9-4eed-f983-08d94c6fa395 X-MS-TrafficTypeDiagnostic: DM5PR12MB1881: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mwp8eHX969nBS5huhA5MDbY0iTLH5JvTR8NTqjsLEE0i2SJli+2pvskE+4NyDgvI/UoVZbEB+1VRBOvbqu6rKPFYAbbwITo9Jr+quMQ8zn05rca2tbTpXijjnOUXQeshvYWBuDCOZ1WdsVxwkxPheuyzt6p3Et5rak4GO0x59hoyhYFtyNdUIY25x3nPcpA1HGdRVaCqrYBgJabLfpFyO7EPn6Q3DYrevSijPZRJec82JpdfXm96qB+JBj2u5D2YWD1KRf8YKqHAQirwe8CmgLCxbO/mgqeZ9mEVSZj9xmieiEYITvm4VYDAkeT/DA9hrUFd7pvmfMoy88FuWh1wXGUTPcd7h7+NoaFhoOp1ZCjarieIKbXdWvBF+5M689iPZf9BLwoiXf3ooDqwyPd2bwqDvxn2jtzlLvZ1lJW/MHBsZsOweRdnLHJMT+odprOaeKHl6pqZpSVEBFwiM7oiMYMJsuvI5R/X4tomEjBWB4Gj1CA5hgW8cH9Fe1l56m0kAfjLoQQMrsb3uPL7wNH1gCF0fARmz4Pu2poGtR1nXiKHjqTXK7ziQfl35v1bpBZdXBfVjD//C16xmY3epGWepDdTeApwo5bos67JRLbXcjk+EQ4Zl7ka20NssJ2KPyarBdwqkh70uaM2ebf9kR+0X1SewhdyaOQpMEtROunkcCSKA+WYCScQh9wV8g3mcDEw+oVdfaQZ2vP02SJvev+jtKNNcf6E3yW7I1lrmuFhKwI= 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)(39860400002)(346002)(396003)(376002)(136003)(46966006)(36840700001)(336012)(36860700001)(5660300002)(316002)(6666004)(47076005)(426003)(110136005)(54906003)(70586007)(2616005)(82740400003)(356005)(81166007)(83380400001)(4326008)(8936002)(2906002)(26005)(36756003)(8676002)(7696005)(186003)(1076003)(82310400003)(70206006)(478600001)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 17:47:41.8112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ba8a8a4-5ef9-4eed-f983-08d94c6fa395 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: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1881 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ACP is a PCI audio device. This patch adds PCI driver to bind to this device and get PCI resources. Reviewed-by: Pierre-Louis Bossart Signed-off-by: Vijendar Mukunda --- sound/soc/amd/vangogh/acp5x.h | 25 +++++++++ sound/soc/amd/vangogh/pci-acp5x.c | 87 +++++++++++++++++++++++++++++++ 2 files changed, 112 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..251a7e0347a7 --- /dev/null +++ b/sound/soc/amd/vangogh/acp5x.h @@ -0,0 +1,25 @@ +/* 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 + +/* common header file uses exact offset rather than relative + * offset which requires subtraction logic from base_addr + * for accessing ACP5x MMIO space registers + */ +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