Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2899299pxb; Mon, 18 Oct 2021 04:24:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8igdECjd2ke8gJj4d6cPPa7b7bTqjL1UNavRcWh9KFwpX2lUu/TzGcWRdRjlxbJ04Do5p X-Received: by 2002:a17:90b:1049:: with SMTP id gq9mr43260605pjb.180.1634556241371; Mon, 18 Oct 2021 04:24:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1634556241; cv=pass; d=google.com; s=arc-20160816; b=tpbkcaTZbYYdIfouMW6O3J99HLcyukWOt6h9L6dre0QeKN4hlx2/DN5JZzDipRRvMB 3AAM1OqYAjvQChJRoxnM0ns8B/Mig21EA8/eeTdXj6fGJFzQgdwof3G5A0BNVPnD78Mo 4RKa1dZKVlMoNaiV2zAwSHUE8msjNmNeq2++fzCB4bV2KsEvah74BeI205gPJcjASrYn yxrHBUp/DzBll0ZoAtucgfIws4bpMfUVByRJai6Ld9LkZSgBfdZ0umOthERHvsLQYU3J v9UiUM85dpguOeRCUuA2v5Jg6zuJCKs/TwJDqlB0nVKIUUoLGFpOzgAXVZYGOVowQbSa o4Qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CJ+cw1WAdRIFJ22kr7K9dsdMu5wtwOeahQrXLF4+jrk=; b=qrAM4xR0cBHgV3quS/7zOFgBzSFdpzuIuUpjMk53SPwRGXqaB3Ny0VwLaZ6sh0VnWV qVE4vGOLWVX+w6W7TjCRsJBteojCRWVf+qhwEBHfYEoyWLj8MEG77ifNGjcTpJZEKD2L hEwmoi79Z/Flq5SwH2MOdCxCiSjCaUqoIXdXT71Xn/matrB2RqRP/hnFIjuEYsA8kibd XvnZCkSvRH8XTnZZyTuiZhWVTzHxY6xHuiDHlsRDJ1jA9SCmlp1Dy+rF7qsYq58qm1FV EUW1HR9I7dLuYIQUgfiOUapol4VC83nDBPAlVP1pgST81KkQpa5Q87dRJoIke566zTC6 R4ug== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=IvOS1cBz; 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 q4si12295684pfu.123.2021.10.18.04.23.24; Mon, 18 Oct 2021 04:24:01 -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=IvOS1cBz; 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 S230381AbhJRLYR (ORCPT + 99 others); Mon, 18 Oct 2021 07:24:17 -0400 Received: from mail-dm6nam10on2047.outbound.protection.outlook.com ([40.107.93.47]:59682 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230350AbhJRLYQ (ORCPT ); Mon, 18 Oct 2021 07:24:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gE87Dr0ziTQaYHyokvMFaMee/n7zyz2/eazifIIFB4xKyreaUONKzKswjUg82ph/ADWawcCHLZPPIL7v+mhH2xKgdRh+uCBFTbOTOqizRYoLwW3BAR6Fz9kkuGKmDrLhzrVk9MgmfP0fPyKP41vlNSBIS1Y4DrSZh0dminNkPueNG1GX0EjWX8XpkK/oGoz+VrxmG3FrsdxBDEzVitvOG887BxcxfzE2q7iKkmXMvk9Xb2+J83ogXevjVwAmf4knpXc9ygafcUSVPbbFdIka5DeGynGAQ34gGP9QQ7g4TY9vFp9l7Sa3JrRgEpt8LJQbQbCGzBJhbyi/PYlZNZ48OA== 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=CJ+cw1WAdRIFJ22kr7K9dsdMu5wtwOeahQrXLF4+jrk=; b=HUV58w0sOwDzcDGsS+qtndf0t8D2D76Siq6jv7sBP+uXOhXa0PeDWIJQfoe85bCRiZTk9W+QrMkOlHB7xC96J1AE0Mo+unavvta/2UwKFCEYsWaW/pablMdRxUKWdu5V7zBEtlS63sY6vJ9Nc05hqndBgSA1DgvgvFghn1AK72mJBUA3pM4XWCp+i09/6JGYouoJAW8ZYBISt3CeGCKARLZ9V01qZBXaLxZdufsaYFZP5s+zo6EDfEZaTpqVTeTLhhLWBsJPhGqL6aPMA/sDbqxKI5bjSgYlN3jFeMmLVouEjcx0mMuAQVCRDUqxcpaZokuwzEEVdxuNPTPJ5Jv74w== 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=CJ+cw1WAdRIFJ22kr7K9dsdMu5wtwOeahQrXLF4+jrk=; b=IvOS1cBz8wHkKAgg8wpbF7Dco0nFDa098jvYSKijJsl6GPOIaaIOiBH0RjzHDPgWXtMK1drirHHqg+h2pyyZFzMI/UkXdKskP8E5NAIfNs+Xjpxe4bRROEAZ281ZyZa3ZEHZw26M8UgQl0YWeAdY9/JOoqxOhhK6duKK9dfX/7c= Received: from DM3PR14CA0138.namprd14.prod.outlook.com (2603:10b6:0:53::22) by BY5PR12MB5543.namprd12.prod.outlook.com (2603:10b6:a03:1d1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Mon, 18 Oct 2021 11:22:02 +0000 Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:0:53:cafe::b8) by DM3PR14CA0138.outlook.office365.com (2603:10b6:0:53::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Mon, 18 Oct 2021 11:22:02 +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 DM6NAM11FT039.mail.protection.outlook.com (10.13.172.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Mon, 18 Oct 2021 11:22:02 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.15; Mon, 18 Oct 2021 06:22:01 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Mon, 18 Oct 2021 06:22:01 -0500 Received: from vijendar-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.15 via Frontend Transport; Mon, 18 Oct 2021 06:21:57 -0500 From: Vijendar Mukunda To: , CC: , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , open list Subject: [PATCH V2 04/13] ASoC: amd: add platform devices for acp6x pdm driver and dmic driver Date: Mon, 18 Oct 2021 16:50:35 +0530 Message-ID: <20211018112044.1705805-5-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018112044.1705805-1-Vijendar.Mukunda@amd.com> References: <20211018112044.1705805-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20b5df2c-85bc-4a55-c75f-08d99229821b X-MS-TrafficTypeDiagnostic: BY5PR12MB5543: 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: lFwMC+so961ea0f1s/tbUFVcUpILDPsM0InkrtMi61HM2k574ZyF0tCXHXHmfeBNO3Clwo0IjMP8cLWXpowtbSnkKBARQ+KSMBtpKE4PS7fSuHG4i7gVnwmvpYH0N9DL9vg6B6Frcke35QG+CrV67ODVIhVfdg2VpUSR8GwANygdhETKhu5iwCoS0RssjHFUdvFkJ/ptDEWt4dmnWIYVsBjx4eEC3Ehm3jfkhO+Bs/MCWhQmZZHkCyRLiIj9V9k4jztJsQtvF8GC8s2AO0xmwxYTpE+X+5g/nORjJX0eG2y6B3ZkuAK2FfUIoPUhhewsZrBF6cxN1w8piUbasUorNu/IsTQ7zCEvY53ieVR8yTg6v46hxSxcSjw470RJFMwkQx9HByCbHwvBDtMPWd0eaVl0eZZkGNK9bfxVIF18NnhPzjhak/2m7iQXLEzI5+2gtNW1nk/TxxXTqRmGetxntefK/Xq/vwZZaegzMNH+BsBGFinvLjs29lbS3bVXkAafeqZKthwBb8841BdHdRA+kTTE9A5U43gSKUgNH9m8l2RCILyiPT6KWpaUq8bnJq+fRTeLGpR4UUbN6vRs6cJkcDsN0AF+ZB7Sq/YgjT9gvdbwyd6o2K6skPNCaCcwAAfTm6A/Z55Z1xRHweRM5DF8iYNNtncq972GjSudVBhiqJ1Vw10XytuVajRU32Re30lPtY/OkW+HQoF85R1qjHItGhkEuuxmGN6tW7rk5r0thdIdCDWbrKhHAxyNIrxrg3tJ 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)(36840700001)(46966006)(2906002)(8936002)(36860700001)(54906003)(1076003)(47076005)(26005)(316002)(6666004)(508600001)(5660300002)(70586007)(81166007)(110136005)(8676002)(70206006)(356005)(7696005)(86362001)(336012)(83380400001)(82310400003)(36756003)(426003)(4326008)(2616005)(186003)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2021 11:22:02.2959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20b5df2c-85bc-4a55-c75f-08d99229821b 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: DM6NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB5543 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 03af3476a97c..bb66b4c670cd 100644 --- a/sound/soc/amd/yc/pci-acp6x.c +++ b/sound/soc/amd/yc/pci-acp6x.c @@ -9,11 +9,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) @@ -117,7 +121,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 */ @@ -154,8 +160,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: @@ -167,9 +227,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