From patchwork Thu Nov 11 03:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1553740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=mZ4OnVV7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HqS471dBPz9s0r for ; Thu, 11 Nov 2021 14:33:43 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ml0qB-000180-D2; Thu, 11 Nov 2021 03:33:31 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1ml0q4-00012g-7V for kernel-team@lists.ubuntu.com; Thu, 11 Nov 2021 03:33:24 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 0AEA23F1A7 for ; Thu, 11 Nov 2021 03:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1636601604; bh=x4HRTga6b9vU5LrB5cxBKS4Mkya0aMB2sBemir5h7kU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mZ4OnVV7y5/BPVb5uR7SD0uuhYmhm9aPnhwzZLs+ES6cpB3fimwbbGSkGDxHSb50d 8IKEBbv2fcIHEhSm8vg24c7j5lXvYkqvMZYosbhlZPTi1YtA3Q38H01jPHFJ9I7Ijf JZj2XXc7wtxqhv0DholjYWCofuuJowqnNanPH/RavU29GH+ChBO8+nyn1qpiEmiTNs TboANpZZRu1Q2pGIT4gi9SYnxJXYN6h7wVCMrnNcbHcugVFH+mROoUwL5r6FrVq/OA Ws8gFooKX0tG0+9yW1MHZOxgC8mXgfk8x8UCmKRiFPq+4a3drERndDSrT1N6zLcLDQ 9m3PWQ/to+C/g== Received: by mail-pg1-f198.google.com with SMTP id h35-20020a63f923000000b002d5262fdfc4so2622881pgi.2 for ; Wed, 10 Nov 2021 19:33:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x4HRTga6b9vU5LrB5cxBKS4Mkya0aMB2sBemir5h7kU=; b=QUSqJLEIOTve5HMmROiVOanVgUY0TTnnTFCG61F+AUsjwsK6wM8NNucF85N1GcMJZM whDF7CzJ/su3PSv/JUeGnVY82qOIprumvAeushw62XEv1XG9GnROvI63iDy3QLI62f0Y efxMfqt34SV5cYZiAf9kgzPOS9lkEpEuqapmgsDfSsatOjZEp2QZavidocCxl6Z90zkl qxiWxy43uap3dcChOQmGhctyHwaqALO0flCszOHUt8QZ2535N2y5uOglgxl1Vr40siIx a+59MBBhBsYEYNj/fry8p8mKJFZQ12wwpVI11+ZsVLnbr60VRfW5Kd6NWJNRnF9pnPv/ kiJw== X-Gm-Message-State: AOAM5300LhWveGiInPR0Dx6jh9r1t7cCx58czZJ/iippXWKMUQBbPFyT 7687NlSTdUcB4Op8UBnxs1sbNCGPOdXo5tcOx4+kQUIgWNGVvXpZqJ9TdRqVWq9jt4JVMexze29 zRPcgdmF75u3ytO9lKzgSATzHLOC/f5W+Q92fOKUzgQ== X-Received: by 2002:a17:90a:f002:: with SMTP id bt2mr4554470pjb.221.1636601602433; Wed, 10 Nov 2021 19:33:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjrFADaeFOPPj8X/1cnB8LJEwnqBc9MAHtykAAG0EPSbDs0ThhWSsrF+/noCuRteM65f6Puw== X-Received: by 2002:a17:90a:f002:: with SMTP id bt2mr4554444pjb.221.1636601602157; Wed, 10 Nov 2021 19:33:22 -0800 (PST) Received: from canonical.com (node-1w7jr9yebujeq5th4a1ypmet6.ipv6.telus.net. [2001:56a:78ed:fb00::57a]) by smtp.gmail.com with ESMTPSA id np16sm891175pjb.6.2021.11.10.19.33.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 19:33:21 -0800 (PST) From: Alex Hung To: kernel-team@lists.ubuntu.com Subject: [PATCH 02/14][SRU][UNSTABLE] ASoC: amd: add Yellow Carp ACP PCI driver Date: Wed, 10 Nov 2021 20:33:06 -0700 Message-Id: <20211111033318.1200557-3-alex.hung@canonical.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211111033318.1200557-1-alex.hung@canonical.com> References: <20211111033318.1200557-1-alex.hung@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Vijendar Mukunda BugLink: https://bugs.launchpad.net/bugs/1949245 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 Link: https://lore.kernel.org/r/20211018112044.1705805-3-Vijendar.Mukunda@amd.com Signed-off-by: Mark Brown (cherry picked from commit c62442bd5d9f86575d74c77b891ef0df9e3cb6dd linux-next) Signed-off-by: Alex Hung --- sound/soc/amd/yc/acp6x.h | 21 +++++++++++ sound/soc/amd/yc/pci-acp6x.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 sound/soc/amd/yc/acp6x.h create mode 100644 sound/soc/amd/yc/pci-acp6x.c diff --git a/sound/soc/amd/yc/acp6x.h b/sound/soc/amd/yc/acp6x.h new file mode 100644 index 0000000..62a05db --- /dev/null +++ b/sound/soc/amd/yc/acp6x.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * AMD ALSA SoC PDM Driver + * + * Copyright (C) 2021 Advanced Micro Devices, Inc. All rights reserved. + */ + +#include "acp6x_chip_offset_byte.h" + +#define ACP_DEVICE_ID 0x15E2 +#define ACP6x_PHY_BASE_ADDRESS 0x1240000 + +static inline u32 acp6x_readl(void __iomem *base_addr) +{ + return readl(base_addr - ACP6x_PHY_BASE_ADDRESS); +} + +static inline void acp6x_writel(u32 val, void __iomem *base_addr) +{ + writel(val, base_addr - ACP6x_PHY_BASE_ADDRESS); +} diff --git a/sound/soc/amd/yc/pci-acp6x.c b/sound/soc/amd/yc/pci-acp6x.c new file mode 100644 index 0000000..5c11832 --- /dev/null +++ b/sound/soc/amd/yc/pci-acp6x.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * AMD Yellow Carp ACP PCI Driver + * + * Copyright 2021 Advanced Micro Devices, Inc. + */ + +#include +#include +#include + +#include "acp6x.h" + +struct acp6x_dev_data { + void __iomem *acp6x_base; +}; + +static int snd_acp6x_probe(struct pci_dev *pci, + const struct pci_device_id *pci_id) +{ + struct acp6x_dev_data *adata; + int ret; + u32 addr; + + /* Yellow Carp device check */ + if (pci->revision != 0x60) + return -ENODEV; + + if (pci_enable_device(pci)) { + dev_err(&pci->dev, "pci_enable_device failed\n"); + return -ENODEV; + } + + ret = pci_request_regions(pci, "AMD ACP3x audio"); + if (ret < 0) { + dev_err(&pci->dev, "pci_request_regions failed\n"); + goto disable_pci; + } + + adata = devm_kzalloc(&pci->dev, sizeof(struct acp6x_dev_data), + GFP_KERNEL); + if (!adata) { + ret = -ENOMEM; + goto release_regions; + } + + addr = pci_resource_start(pci, 0); + adata->acp6x_base = devm_ioremap(&pci->dev, addr, + pci_resource_len(pci, 0)); + if (!adata->acp6x_base) { + ret = -ENOMEM; + goto release_regions; + } + pci_set_master(pci); + pci_set_drvdata(pci, adata); + return 0; +release_regions: + pci_release_regions(pci); +disable_pci: + pci_disable_device(pci); + + return ret; +} + +static void snd_acp6x_remove(struct pci_dev *pci) +{ + pci_release_regions(pci); + pci_disable_device(pci); +} + +static const struct pci_device_id snd_acp6x_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_acp6x_ids); + +static struct pci_driver yc_acp6x_driver = { + .name = KBUILD_MODNAME, + .id_table = snd_acp6x_ids, + .probe = snd_acp6x_probe, + .remove = snd_acp6x_remove, +}; + +module_pci_driver(yc_acp6x_driver); + +MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); +MODULE_DESCRIPTION("AMD ACP Yellow Carp PCI driver"); +MODULE_LICENSE("GPL v2");