Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1197624pxb; Mon, 11 Oct 2021 00:03:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKxP3t6VM+4Bkx+KkoRM7AHOAatvmSIN8MNzvAxHyMUYz8kdDvA/L2z0giy8GgsqghTASF X-Received: by 2002:a17:906:480a:: with SMTP id w10mr24225224ejq.262.1633935817129; Mon, 11 Oct 2021 00:03:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1633935817; cv=pass; d=google.com; s=arc-20160816; b=Sw3mWaP45k8Jus3dGnKndQtkTCHX3pGc6t/ehDGpxJ4EuJgcYVKJdbTiWF03znMC5X eemrgPPQ5Ne01bjvg2PYqVdwbt1ak94iQYHMRAC+xq7Zh11fekBIvAUsHk2L0TmZw2WS roRehpSVuVIvtG5nuLESdfB7hL5hnrXKbf3Al0jzRtFojSM5m+DKfArrIfUl29eEV5uu 16PmgK4EFg4lFm2vVV4kgx82hyyVKHal0neJ+oWKeN53MfRM7DYBQQ4YZttCeWgRMyym UdZZRP0r95xDjK+F3rrEIZwJrSO5/TcBALBlLudTJozdRXQgiJk/VLKU4bZ0XJc5Q0PR 9ypw== 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=PTorS6TE1MOUe5xzZCe5FwZ1vWNzb4SqytDu1K4+878=; b=vM0zd1DCXMm33yWPUMMru4cD0YdQPVitjKUbDMahIHiOaBWUPTbVzUoOY+05gjEjQ2 vtC98TO8Ryf+KRCiKrQXHT0Y5ORhPmd6FPVlOPIYjF3tscVLYQUNxlgSccDelksiE1y9 b8RT0iypTdvV6B9lzGvrfAPFIC7cJknFmVf+VYIIDnNI9k2RBLudfs7ejQIlbwqhOkiq e1PWPSl/APqwLS2ofwgnJqFMayxlf2vBDl14v7gAjZDUPND9PqmqjTBjzPkT9p2EvT5/ PRDZFhhLFMBMQ6Ln5VuJQv/BrJOg+AM9xmkTaTyj4ajgIcTX033teKSJCslbkUD1ZmNT fRPg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=v31nQW1y; 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 e10si10519150edl.461.2021.10.11.00.03.13; Mon, 11 Oct 2021 00:03:37 -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=v31nQW1y; 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 S233677AbhJKFk6 (ORCPT + 99 others); Mon, 11 Oct 2021 01:40:58 -0400 Received: from mail-bn1nam07on2085.outbound.protection.outlook.com ([40.107.212.85]:14062 "EHLO NAM02-BN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233933AbhJKFkx (ORCPT ); Mon, 11 Oct 2021 01:40:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GeIh2zaOP1mUo1XZ0Jk3ppYLzEJaHslXcMYuOCymrAQm5rJAbb5xPdFpsjnqox/ZY2MYQ/OJA2OW/twUzbz0GyPKwMCmxL4bxHwVm1PzCjI7vHbqW10rOCUdrJG7Sy6oJgKqqNKbJGmTMdSWata0xNwfrnwx+5O0hhPUR73ixwDqIwfvWbxNikMC/ChB2Q7sINGnrmDatpm3WszE5VzxsIQLVIK1adBscszwG+4ioKiAb5T3A4V2a1chOWIFyYV5kbXfs1mI7cUbAD669lGFFVIlBxH+3I0lLgHkMCYZEcpBmvezfIsc1jV4tcSnzsnwrajp+rzg4OPPA+fIGBZJmA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PTorS6TE1MOUe5xzZCe5FwZ1vWNzb4SqytDu1K4+878=; b=au7HnVPs3HSxddsM/zKHwQf3reKmbVUBMNpSvJz72J6jjQYdQjq5cXruqPf20mBz2Z2Qau5JPHF7qa4crcIBCjLnzyUu9U56si1geh8m2aSe9cwx4kc36+2s2EMzJQQR5KElm2ytefGtZFXEiFimQUk8kzHTE5zMNXDtBprMlkdblYozGyOcMufiPdLzC5c6OsGey64g4eV45pcdvo1U3c7/LeXHAGjtkbfZGPfdRR4SQ9RC0kjpUBIye3aE/IOjpO59hwvgHw/YUmrE4ud4ChHcE6rKuq5FdCfyZWG7huCtszo17PwU0nUZN7vRUeJ8xsEA9K3uVR0ladNLq8es+A== 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=PTorS6TE1MOUe5xzZCe5FwZ1vWNzb4SqytDu1K4+878=; b=v31nQW1yfCE403N2tLxsHogbDsK+pUdZ3uJxgjCZVXLgxXziecMOhpwQ745BcOGDhSbDX/Yb63l4wz01u9R50SVNYvMPbjc3NUJuEka/b3LM+1XGA/BBGb2eBnnFZchiV8/AlB+Vt+LCk9xNdqy+lRuMudv4k/o6/NeEskefiwk= Received: from DM5PR19CA0045.namprd19.prod.outlook.com (2603:10b6:3:9a::31) by DM4PR12MB5295.namprd12.prod.outlook.com (2603:10b6:5:39f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Mon, 11 Oct 2021 05:38:52 +0000 Received: from DM6NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:3:9a:cafe::48) by DM5PR19CA0045.outlook.office365.com (2603:10b6:3:9a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Mon, 11 Oct 2021 05:38:52 +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 DM6NAM11FT068.mail.protection.outlook.com (10.13.173.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4587.18 via Frontend Transport; Mon, 11 Oct 2021 05:38:51 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.2308.8; Mon, 11 Oct 2021 00:38:50 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2308.8; Sun, 10 Oct 2021 22:38:50 -0700 Received: from LinuxHost.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Mon, 11 Oct 2021 00:38:46 -0500 From: Vijendar Mukunda To: , CC: , , , , , Vijendar Mukunda , "Liam Girdwood" , Jaroslav Kysela , "Takashi Iwai" , open list Subject: [PATCH 04/13] ASoC: amd: add platform devices for acp6x pdm driver and dmic driver Date: Mon, 11 Oct 2021 11:26:12 +0530 Message-ID: <20211011055621.13240-5-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211011055621.13240-1-Vijendar.Mukunda@amd.com> References: <20211011055621.13240-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: ec7f8962-a5b1-4bec-ec1d-08d98c796858 X-MS-TrafficTypeDiagnostic: DM4PR12MB5295: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZFkzVWHKjfUNBd/cDSHuhkNngIPqMSmwdvN8YLwStbBkDM3sgwtEnr7EXg9PWJyHw6ikr83PJPozr2e8lssPwltGngfGZmdKi5Tc6a2D55YercZ25h9Ch0HTKLFGkSRaHkjIYtB24SU8ZVC6gGS6bMbGCIhiF9DjQOvuLnwcHyoi0JkioM+Juwoql/ZG1LDBl7CrG70O5FTgeWkCgNovhMUPDZwEWUmuUYBU9w3QeCd0Gbsgrbo0AUA61zjmrK2qhM8Gd9Q52IDdpfJONnv5KiV8A+qgl4GA75gszHPUwGMsVXfE4uwTtTF29rF3HqYST0ixRlHsVIc0V8U92rHMn9y/zK2sa9pzXQ3KRP7yKEG0Q3aOnEaQoZY2wDtlGRFtleNeV2hTwTu2FHazTLEJmK8G9PeZDN5yG3ox/a+Cl0v/1Kg9kHJtQIPksYZlGMgUBI/EWaZN6pSh1b3QLl5rzid8G8Mr4et/YXAxwgzmyUIs+khewYF4dtT5EWzsgeSzWY3geaLnRlrSE7KpMYFcBuVOCUtCmGaKv4h67QLfa8l4pPew4NiZ80BsQrUUDuuB9N903aw3zPASvUUugZ824Y7e5HqmBW+aLHUEFyV+sTcInCqRjapgHNj9jtSSzvVDtunIgLv7tbWVX2c3sOkQz7HxMAmLbY/IktwrQQutghnEh3PBGEZtLDkn0BP7SmaZr9dDaCyil4iwAbdrlcT3iMFgeXChh0ZP0meGPbkoY6YPieeRrVJTJlpaD/pKSB6sdjEAdIHFvu3ZHJShuaCLVg== 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)(8676002)(110136005)(8936002)(86362001)(4326008)(54906003)(36756003)(316002)(83380400001)(82310400003)(47076005)(1076003)(6666004)(36860700001)(81166007)(2906002)(356005)(70206006)(70586007)(426003)(186003)(336012)(26005)(508600001)(2616005)(5660300002)(7696005)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2021 05:38:51.8435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec7f8962-a5b1-4bec-ec1d-08d98c796858 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: DM6NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5295 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ACP6.x IP has PDM decoder block. Create a platform device for it, so that the PDM platform driver can be bound to this device. Pass PCI resources like MMIO to this platform device. Create a platform device for generic dmic codec driver. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/yc/acp6x.h | 23 ++++++++++++ sound/soc/amd/yc/pci-acp6x.c | 68 ++++++++++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/yc/acp6x.h b/sound/soc/amd/yc/acp6x.h index 76e9e860e9bb..63bdea3188ea 100644 --- a/sound/soc/amd/yc/acp6x.h +++ b/sound/soc/amd/yc/acp6x.h @@ -9,6 +9,10 @@ #define ACP_DEVICE_ID 0x15E2 #define ACP6x_PHY_BASE_ADDRESS 0x1240000 +#define ACP6x_REG_START 0x1240000 +#define ACP6x_REG_END 0x1250200 +#define ACP6x_DEVS 2 +#define ACP6x_PDM_MODE 1 #define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 #define ACP_PGFSM_CNTL_POWER_ON_MASK 1 @@ -22,6 +26,25 @@ #define ACP_ERROR_MASK 0x20000000 #define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF +enum acp_config { + ACP_CONFIG_0 = 0, + ACP_CONFIG_1, + ACP_CONFIG_2, + ACP_CONFIG_3, + ACP_CONFIG_4, + ACP_CONFIG_5, + ACP_CONFIG_6, + ACP_CONFIG_7, + ACP_CONFIG_8, + ACP_CONFIG_9, + ACP_CONFIG_10, + ACP_CONFIG_11, + ACP_CONFIG_12, + ACP_CONFIG_13, + ACP_CONFIG_14, + ACP_CONFIG_15, +}; + static inline u32 acp6x_readl(void __iomem *base_addr) { return readl(base_addr - ACP6x_PHY_BASE_ADDRESS); diff --git a/sound/soc/amd/yc/pci-acp6x.c b/sound/soc/amd/yc/pci-acp6x.c index 56fd7cdbc442..26c8d652fd08 100644 --- a/sound/soc/amd/yc/pci-acp6x.c +++ b/sound/soc/amd/yc/pci-acp6x.c @@ -8,11 +8,15 @@ #include #include #include +#include #include "acp6x.h" struct acp6x_dev_data { void __iomem *acp6x_base; + struct resource *res; + bool acp6x_audio_mode; + struct platform_device *pdev[ACP6x_DEVS]; }; static int acp6x_power_on(void __iomem *acp_base) @@ -116,7 +120,9 @@ static int snd_acp6x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { struct acp6x_dev_data *adata; - int ret; + struct platform_device_info pdevinfo[ACP6x_DEVS]; + int ret, index; + int val = 0x00; u32 addr; /* Yellow Carp device check */ @@ -153,8 +159,62 @@ static int snd_acp6x_probe(struct pci_dev *pci, ret = acp6x_init(adata->acp6x_base); if (ret) goto release_regions; + val = acp6x_readl(adata->acp6x_base + ACP_PIN_CONFIG); + switch (val) { + case ACP_CONFIG_0: + case ACP_CONFIG_1: + case ACP_CONFIG_2: + case ACP_CONFIG_3: + case ACP_CONFIG_9: + case ACP_CONFIG_15: + dev_info(&pci->dev, "Audio Mode %d\n", val); + break; + default: + adata->res = devm_kzalloc(&pci->dev, + sizeof(struct resource), + GFP_KERNEL); + if (!adata->res) { + ret = -ENOMEM; + goto de_init; + } + + adata->res->name = "acp_iomem"; + adata->res->flags = IORESOURCE_MEM; + adata->res->start = addr; + adata->res->end = addr + (ACP6x_REG_END - ACP6x_REG_START); + + adata->acp6x_audio_mode = ACP6x_PDM_MODE; + + memset(&pdevinfo, 0, sizeof(pdevinfo)); + pdevinfo[0].name = "acp_yc_pdm_dma"; + pdevinfo[0].id = 0; + pdevinfo[0].parent = &pci->dev; + pdevinfo[0].num_res = 1; + pdevinfo[0].res = adata->res; + + pdevinfo[1].name = "dmic-codec"; + pdevinfo[1].id = 0; + pdevinfo[1].parent = &pci->dev; + for (index = 0; index < ACP6x_DEVS; index++) { + adata->pdev[index] = + platform_device_register_full(&pdevinfo[index]); + if (IS_ERR(adata->pdev[index])) { + dev_err(&pci->dev, "cannot register %s device\n", + pdevinfo[index].name); + ret = PTR_ERR(adata->pdev[index]); + goto unregister_devs; + } + } + break; + } return 0; +unregister_devs: + for (--index; index >= 0; index--) + platform_device_unregister(adata->pdev[index]); +de_init: + if (acp6x_deinit(adata->acp6x_base)) + dev_err(&pci->dev, "ACP de-init failed\n"); release_regions: pci_release_regions(pci); disable_pci: @@ -166,9 +226,13 @@ static int snd_acp6x_probe(struct pci_dev *pci, static void snd_acp6x_remove(struct pci_dev *pci) { struct acp6x_dev_data *adata; - int ret; + int ret, index; adata = pci_get_drvdata(pci); + if (adata->acp6x_audio_mode == ACP6x_PDM_MODE) { + for (index = 0; index < ACP6x_DEVS; index++) + platform_device_unregister(adata->pdev[index]); + } ret = acp6x_deinit(adata->acp6x_base); if (ret) dev_err(&pci->dev, "ACP de-init failed\n"); -- 2.25.1