From patchwork Tue Oct 1 00:58:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "RAVULAPATI, VISHNU VARDHAN RAO" X-Patchwork-Id: 11166761 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50C9816B1 for ; Mon, 30 Sep 2019 14:06:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BB6F216F4 for ; Mon, 30 Sep 2019 14:06:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="DbxDOM3X"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="TsZVYuIQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BB6F216F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0B476829; Mon, 30 Sep 2019 16:05:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0B476829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1569852405; bh=vcB4eCxK2KB+r75KdoUnXKzwp/ZlgMKknQJkBec2bm4=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=DbxDOM3XeM01WIcCj2i3WU3LkOJmePjdYToiUhKfspm18eKc9wgPLXzdNANMwULD+ EnrWnfJPlKsm3DcDZao/ELffqSHcZTBN5wfrrLNiIC+Q8raUjV+JATydiJIMJHUX5+ CY6APrJHH2jlpt1o8bDC6pmYui3I9/54RmVqCKMk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8E512F800DE; Mon, 30 Sep 2019 16:05:54 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 83EEBF8036E; Mon, 30 Sep 2019 16:05:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,SPF_NONE autolearn=disabled version=3.4.0 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-eopbgr800078.outbound.protection.outlook.com [40.107.80.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3B60AF801A4 for ; Mon, 30 Sep 2019 16:05:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3B60AF801A4 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="TsZVYuIQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DYW76Bz222ZSXVcTPLRrhphM2lF6GtlNKVD4jRCjBhlAZpAxvzcn0B6bXEIp5MwA4NFA/S+RGVwV37l+6IHnDqREOLCa8pRp0fqdGryU0LssmahBMLLtrU1uzSzABKyxNML54JpMK4UnojHD1bO0EMX+Qx+Taru0n6mPwo2NCvmaJof2teg8k6ehyBTSREwPVRSqNeTYSHdyjgW4OcTPYIEXqJ65W8vQKb5jWVTmJdQJ2tONDwk6HVrVfATpf4Yge3stQrJlGz05Dabw/d51/5DPW1esMPebzfa5jLFx9HFXT2QllYNKT97J6bZ6X1ypttHd+SDHV6wUP+JYoMjYPA== 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=nQz4KewW0jjJaHgm/tkT+fG1prUhUjrgh0AAmeiBq5I=; b=d2Ou03VpBuZS65i5x7dvNXeM2+J3rHqs2hrJmZqcfcMCWr9ufh5TxMTUiz9E8VeExkHgpwLoHq4vNW/tMHhDiJ7JTNodinTTevctRQk5vCfKuvek1o02vEVRg0QzU7SFVv32X3LoLO1/+li1LalEywbwlBdJVoK8lH1rHE3//zaYJoL3Mc6nPRkj939vwUDE2HKMzH5IXdOE67xeH2Zj6ZfEOCtwiJCRwmc+rMqtr9U4B1H5yWTiYZfwA1zT9GDBTsToy6QcJFIyAcYHq+pvd1czqRo6xHOvMvIqwnXLOpJvCFTPJFxrvmFC9yqon/IPWSAY2vAWB7PPYGXrapJg4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=oracle.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nQz4KewW0jjJaHgm/tkT+fG1prUhUjrgh0AAmeiBq5I=; b=TsZVYuIQZEiHse0grgVU3psNJNbco/K8almMVtTCp5Blx/3ZYPNpR80D30F8gLMsLmVPzutr1hw163cVMEyQDTZVGW0TyVST97oZDDqoi3RywRsXQsoFZdAKhcigLTeTi4oyMkSSeMwjKIjRlb36SBmW54OemcmQEnhfeNQgfPg= Received: from DM3PR12CA0110.namprd12.prod.outlook.com (2603:10b6:0:55::30) by CY4PR12MB1223.namprd12.prod.outlook.com (2603:10b6:903:38::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 14:05:44 +0000 Received: from CO1NAM03FT023.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by DM3PR12CA0110.outlook.office365.com (2603:10b6:0:55::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.17 via Frontend Transport; Mon, 30 Sep 2019 14:05:44 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; oracle.com; dkim=none (message not signed) header.d=none;oracle.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT023.mail.protection.outlook.com (10.152.80.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 14:05:43 +0000 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 30 Sep 2019 09:05:41 -0500 From: Ravulapati Vishnu vardhan rao To: Date: Tue, 1 Oct 2019 06:28:09 +0530 Message-ID: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(396003)(39860400002)(136003)(428003)(199004)(189003)(109986005)(336012)(476003)(126002)(426003)(47776003)(53416004)(2616005)(81156014)(8676002)(4326008)(486006)(478600001)(7696005)(51416003)(36756003)(8936002)(86362001)(50226002)(2906002)(316002)(50466002)(54906003)(5660300002)(70206006)(70586007)(186003)(305945005)(81166006)(16586007)(6666004)(1671002)(48376002)(356004)(26005)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1223; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c3143d3c-bcea-44f8-5a03-08d745af48f7 X-MS-TrafficTypeDiagnostic: CY4PR12MB1223: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-Forefront-PRVS: 01762B0D64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UxzZGzEHl6Htj2m7qKN3g3Q3ecx130oPX7/AUvFbERuu7FUi7yhECwDD7TuK9TJEU5yXYFiw9m1hBCTqNAhbx39Qm5TTDp35F+kVKZXBrcskQ9z/cfPe5ouw6wohCyROYV+bSXE+l0D9mA5Kx/HA55JkfyNTD0a8HHJiqFFx2Of7FcOPTy9xg0PujwV/nFUG5LSpxzPiAC57Ba3K3KXGw33BXlbBmFq0mwU0GRd2c/U/DUOGIeV01AyQ5C2JLjmQMiS1/M5rdvRMNW+WMPvR+1/auM0sE6Dv02RIvtyr0E5rrevRTQYiqnsDN1/T1RQdvcXFomrxc3VJ/ewTcLWBifj3ADNiFKg0w7bMRnOine5Ndv4NGaCHoF7tEchpErYQc9MYanCpQvIbo0VfxBgpoG/+GsaeA0cqf0NXabnpQ3Q= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 14:05:43.8214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3143d3c-bcea-44f8-5a03-08d745af48f7 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1223 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Maruthi Srinivas Bayyavarapu , open list , Takashi Iwai , Liam Girdwood , Ravulapati Vishnu vardhan rao , Mark Brown , Vijendar Mukunda , Alex Deucher , Colin Ian King , Dan Carpenter Subject: [alsa-devel] [PATCH 1/7] ASoC: amd: No need PCI-MSI interrupts X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ACP-PCI controller driver does not depends msi interrupts. So removed msi related pci functions which have no use and does not impact on existing functionality. Signed-off-by: Ravulapati Vishnu vardhan rao --- sound/soc/amd/raven/pci-acp3x.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c index facec24..8f6bf00 100644 --- a/sound/soc/amd/raven/pci-acp3x.c +++ b/sound/soc/amd/raven/pci-acp3x.c @@ -46,14 +46,7 @@ static int snd_acp3x_probe(struct pci_dev *pci, goto release_regions; } - /* check for msi interrupt support */ - ret = pci_enable_msi(pci); - if (ret) - /* msi is not enabled */ - irqflags = IRQF_SHARED; - else - /* msi is enabled */ - irqflags = 0; + irqflags = 0; addr = pci_resource_start(pci, 0); adata->acp3x_base = ioremap(addr, pci_resource_len(pci, 0)); @@ -112,7 +105,6 @@ static int snd_acp3x_probe(struct pci_dev *pci, return 0; unmap_mmio: - pci_disable_msi(pci); iounmap(adata->acp3x_base); release_regions: pci_release_regions(pci); @@ -129,7 +121,6 @@ static void snd_acp3x_remove(struct pci_dev *pci) platform_device_unregister(adata->pdev); iounmap(adata->acp3x_base); - pci_disable_msi(pci); pci_release_regions(pci); pci_disable_device(pci); } From patchwork Tue Oct 1 00:58:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "RAVULAPATI, VISHNU VARDHAN RAO" X-Patchwork-Id: 11166763 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C5EC16B1 for ; Mon, 30 Sep 2019 14:07:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1104C218AC for ; Mon, 30 Sep 2019 14:07:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="L3zWK3VT"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="nD3bD/6q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1104C218AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0EBB5166C; Mon, 30 Sep 2019 16:06:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0EBB5166C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1569852461; bh=6/7r1+pwdcu5sJh2rgQ3csNtF3rpxkNy0Bba0K7O5m0=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=L3zWK3VTqkGuCSBUD2PY+e3MWsmbJ+A/bYwH53ybDlWdXBUtrL6m8aYu0Nwtro6t1 l/AxzLPgFJJy00to8HUvxTMYLbsuKRLYY1sqQnMuadUBUY1pGBzbjfXNFnRkf7MWtq gvtHD91KUyzgnm3w7eV4yF1X8D/uA/mY4cDmsuuo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AD21CF8036D; Mon, 30 Sep 2019 16:06:06 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5CD15F80528; Mon, 30 Sep 2019 16:06:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE autolearn=disabled version=3.4.0 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710042.outbound.protection.outlook.com [40.107.71.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4DCDF803F3 for ; Mon, 30 Sep 2019 16:06:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4DCDF803F3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="nD3bD/6q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iUkTtppUSMqGLiJlk4rgXhApqTPZ0QUpW6GN4UUuGPBU33l7IBAsZUEFOnL5RFWyfyueGsFmqw1tj/djVaF9XlUrqKziwqNdgIIEy2OzxKwoKPd+jEuChJBoK+JEvQupaxCNc76nnt/mwudA3X3ImiE1S0Nlqk/pWGNeHFacSbnd9GmB45ngovsUULw0hnZCAxHBXG5M9Nws7ID1sFAd/Ngp8dKIM0vQvw2CjBAp2fLxjuxoNJgdIC4PL8H4NROYATOFkDVGBCbzlfZj4P2Y4xgcuducEXmWu2N5T7/BoTkfZ9O0kjfnQFS3a7B8SrnDmENtUZujqbRXlT5fFlG+aA== 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=2zj4J1monzztHvLn/9/E6Oprs41hNIAObi+6+n23KcE=; b=HGgaH+gI7Ac0gxPWMseEWw95PiS5E/fAkEK78Ua8lH0cRItbEZeQyjbstgExEz0Eoo6Fsa2zzfQJkmsm6xcrFQmbpTYaV3ivR/5BZ6XNcn8XF1VQAzEH4f7PZcoVV+cG6AdCajBC9Hpei1ynVqjc/S936D+I/1BR5U1iKh2Gm9uT2vPeULqFel+I/eDKydCCIBUIv7cX+J/q5xvHraawlXAtU7peYV/Ed2ueGFpczUPU3D0/Tw03Q4QwvIkF1lB0AF1h4ybYkvedo3bgfWNUVEOQhF0yzi6sj0/UbD3siIyqTQIBcS/q3K3fQt00PueDPL/sMuBXxyI7iX3v/5c9Vg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=oracle.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2zj4J1monzztHvLn/9/E6Oprs41hNIAObi+6+n23KcE=; b=nD3bD/6qE1lz/DMhzWlZM45dTm8viCmsSkzszV8dlS8AlP0tTrugFIenbyPi4GfyEes7Ub62rUteOb4ctg8RnsBOVabV/U+Noz7gYQM6zfU/gKXX71+7WVVqXlFNt6yzDRX8mAedJQ5jiIwTaJAQjy3tf4+rQV9kb4QoKuT/sWI= Received: from DM6PR12CA0007.namprd12.prod.outlook.com (2603:10b6:5:1c0::20) by BYAPR12MB2821.namprd12.prod.outlook.com (2603:10b6:a03:96::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.18; Mon, 30 Sep 2019 14:05:56 +0000 Received: from CO1NAM03FT016.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::207) by DM6PR12CA0007.outlook.office365.com (2603:10b6:5:1c0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.19 via Frontend Transport; Mon, 30 Sep 2019 14:05:56 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; oracle.com; dkim=none (message not signed) header.d=none;oracle.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT016.mail.protection.outlook.com (10.152.80.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 14:05:56 +0000 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 30 Sep 2019 09:05:54 -0500 From: Ravulapati Vishnu vardhan rao To: Date: Tue, 1 Oct 2019 06:28:10 +0530 Message-ID: <1569891524-18875-2-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> References: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(346002)(136003)(376002)(39860400002)(428003)(199004)(189003)(86362001)(47776003)(486006)(426003)(76176011)(356004)(50466002)(4326008)(50226002)(51416003)(7696005)(305945005)(6666004)(48376002)(1671002)(109986005)(5660300002)(16586007)(316002)(26005)(336012)(186003)(54906003)(53416004)(36756003)(2906002)(81156014)(81166006)(446003)(70206006)(478600001)(70586007)(2616005)(8676002)(11346002)(476003)(8936002)(126002)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR12MB2821; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a143658-4d27-4978-c545-08d745af5031 X-MS-TrafficTypeDiagnostic: BYAPR12MB2821: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:108; X-Forefront-PRVS: 01762B0D64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oV239+70idZI47zaBxmD/5R3NenEXPmC0CKkWtczdE6aJr9MvjQRrqbQvlfKOi6nnXZq+anWXjji4DW/fEwXutxMw/K7HSFy3YxZluHvUdq2g/4PVWSkT6KTjhHWvou/FX0BwsB2EOyNzDeTWEHMk8RmSEIcZnRJ2MmNlFDhE86Do6EQKGjivZy+ymz0/QE1cc+e9gi2ACi13x37vTVXsNUNyVLNHwWfKUn9nzKue6TmKUOJOWFkMa5g3emTt5RtafOWUGQgMQ76u63W/cNUna3qiVRCwONs0wU6dQ9UadSbYJvQ9LCWTzckMcBMBwhypCGJ5URPCyAYVATywZUZd1nz7KPCqvm8GT2m9bDWNkj9v8udeBC7w0d42+KPTfy9IxHFvTsZ98oWZu9b+v0nfR6yB1s4pffR1tSUqQYNUfM= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 14:05:56.1375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a143658-4d27-4978-c545-08d745af5031 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2821 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Maruthi Srinivas Bayyavarapu , open list , Takashi Iwai , Liam Girdwood , Sanju R Mehta , Ravulapati Vishnu vardhan rao , Mark Brown , Vijendar Mukunda , Alex Deucher , Colin Ian King , Dan Carpenter Subject: [alsa-devel] [PATCH 2/7] ASoC: amd: Registering device endpoints using MFD framework X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Removed platform based endpoint registering in ACP-PCI driver. Now Registering PCM DMA and multiple I2S instances: SP and BT endpoint devices automatically by using MFD framework. Signed-off-by: Ravulapati Vishnu vardhan rao --- sound/soc/amd/raven/acp3x.h | 8 +++ sound/soc/amd/raven/pci-acp3x.c | 123 ++++++++++++++++++++++++++-------------- 2 files changed, 90 insertions(+), 41 deletions(-) diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index 4f2cadd..c122dc6 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -7,13 +7,21 @@ #include "chip_offset_byte.h" +#define ACP3x_DEVS 3 #define ACP3x_PHY_BASE_ADDRESS 0x1240000 #define ACP3x_I2S_MODE 0 #define ACP3x_REG_START 0x1240000 #define ACP3x_REG_END 0x1250200 +#define ACP3x_I2STDM_REG_START 0x1242400 +#define ACP3x_I2STDM_REG_END 0x1242410 +#define ACP3x_BT_TDM_REG_START 0x1242800 +#define ACP3x_BT_TDM_REG_END 0x1242810 #define I2S_MODE 0x04 +#define I2S_RX_THRESHOLD 27 +#define I2S_TX_THRESHOLD 28 #define BT_TX_THRESHOLD 26 #define BT_RX_THRESHOLD 25 +#define ACP_ERR_INTR_MASK 29 #define ACP3x_POWER_ON 0x00 #define ACP3x_POWER_ON_IN_PROGRESS 0x01 #define ACP3x_POWER_OFF 0x02 diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c index 8f6bf00..d9f5bc0 100644 --- a/sound/soc/amd/raven/pci-acp3x.c +++ b/sound/soc/amd/raven/pci-acp3x.c @@ -9,13 +9,21 @@ #include #include #include +#include #include "acp3x.h" +struct i2s_platform_data { + unsigned int cap; + int channel; + u32 snd_rates; +}; struct acp3x_dev_data { + struct device *parent; + struct mfd_cell *cell; + struct resource *res; void __iomem *acp3x_base; bool acp3x_audio_mode; - struct resource *res; struct platform_device *pdev; }; @@ -23,9 +31,11 @@ static int snd_acp3x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { int ret; - u32 addr, val; + resource_size_t addr; + int val, i, r; struct acp3x_dev_data *adata; - struct platform_device_info pdevinfo; + struct device *dev; + struct i2s_platform_data *i2s_pdata; unsigned int irqflags; if (pci_enable_device(pci)) { @@ -56,55 +66,87 @@ static int snd_acp3x_probe(struct pci_dev *pci, } pci_set_master(pci); pci_set_drvdata(pci, adata); - + adata->parent = &pci->dev; val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG); switch (val) { case I2S_MODE: adata->res = devm_kzalloc(&pci->dev, - sizeof(struct resource) * 2, - GFP_KERNEL); - if (!adata->res) { + sizeof(struct resource) * 4, + GFP_KERNEL); + adata->cell = devm_kzalloc(&pci->dev, + sizeof(struct mfd_cell) * ACP3x_DEVS, + GFP_KERNEL); + if (!adata->cell) { ret = -ENOMEM; goto unmap_mmio; } - adata->res[0].name = "acp3x_i2s_iomem"; - adata->res[0].flags = IORESOURCE_MEM; - adata->res[0].start = addr; - adata->res[0].end = addr + (ACP3x_REG_END - ACP3x_REG_START); - - adata->res[1].name = "acp3x_i2s_irq"; - adata->res[1].flags = IORESOURCE_IRQ; - adata->res[1].start = pci->irq; - adata->res[1].end = pci->irq; - - adata->acp3x_audio_mode = ACP3x_I2S_MODE; - - memset(&pdevinfo, 0, sizeof(pdevinfo)); - pdevinfo.name = "acp3x_rv_i2s"; - pdevinfo.id = 0; - pdevinfo.parent = &pci->dev; - pdevinfo.num_res = 2; - pdevinfo.res = adata->res; - pdevinfo.data = &irqflags; - pdevinfo.size_data = sizeof(irqflags); - - adata->pdev = platform_device_register_full(&pdevinfo); - if (IS_ERR(adata->pdev)) { - dev_err(&pci->dev, "cannot register %s device\n", - pdevinfo.name); - ret = PTR_ERR(adata->pdev); - goto unmap_mmio; + i2s_pdata = devm_kzalloc(&pci->dev, + sizeof(struct i2s_platform_data) * ACP3x_DEVS, + GFP_KERNEL); + if (i2s_pdata == NULL) { + kfree(adata->res); + kfree(adata->cell); + return -ENOMEM; } + adata->res[0].name = "acp3x_i2s_iomem"; + adata->res[0].flags = IORESOURCE_MEM; + adata->res[0].start = addr; + adata->res[0].end = addr + + (ACP3x_REG_END - ACP3x_REG_START); + i2s_pdata[0].cap = 0; + i2s_pdata[0].snd_rates = SNDRV_PCM_RATE_8000_96000; + + adata->res[1].name = "acp3x_i2s_sp_play_cap"; + adata->res[1].flags = IORESOURCE_MEM; + adata->res[1].start = addr + ACP3x_I2STDM_REG_START; + adata->res[1].end = addr + ACP3x_I2STDM_REG_END; + i2s_pdata[1].cap = 0; + i2s_pdata[1].snd_rates = SNDRV_PCM_RATE_8000_96000; + + adata->res[2].name = "acp3x_i2s_bt_play_cap"; + adata->res[2].flags = IORESOURCE_MEM; + adata->res[2].start = addr + ACP3x_BT_TDM_REG_START; + adata->res[2].end = addr + ACP3x_BT_TDM_REG_END; + i2s_pdata[2].cap = 0; + i2s_pdata[2].snd_rates = SNDRV_PCM_RATE_8000_96000; + + adata->res[3].name = "acp3x_i2s_irq"; + adata->res[3].flags = IORESOURCE_IRQ; + adata->res[3].start = pci->irq; + adata->res[3].end = adata->res[3].start; + + adata->acp3x_audio_mode = ACP3x_I2S_MODE; + + adata->cell[0].name = "acp3x_rv_i2s_dma"; + adata->cell[0].num_resources = 4; + adata->cell[0].resources = &adata->res[0]; + adata->cell[0].platform_data = &irqflags; + adata->cell[0].pdata_size = sizeof(irqflags); + + adata->cell[1].name = "acp3x_i2s_playcap"; + adata->cell[1].num_resources = 1; + adata->cell[1].resources = &adata->res[1]; + adata->cell[1].platform_data = &i2s_pdata[0]; + adata->cell[1].pdata_size = + sizeof(struct i2s_platform_data); + + adata->cell[2].name = "acp3x_i2s_playcap"; + adata->cell[2].num_resources = 1; + adata->cell[2].resources = &adata->res[2]; + adata->cell[2].platform_data = &i2s_pdata[1]; + adata->cell[2].pdata_size = + sizeof(struct i2s_platform_data); + r = mfd_add_hotplug_devices(adata->parent, + adata->cell, ACP3x_DEVS); break; - default: - dev_err(&pci->dev, "Invalid ACP audio mode : %d\n", val); - ret = -ENODEV; - goto unmap_mmio; } return 0; unmap_mmio: + mfd_remove_devices(adata->parent); + kfree(adata->res); + kfree(adata->cell); iounmap(adata->acp3x_base); release_regions: pci_release_regions(pci); @@ -117,10 +159,8 @@ static int snd_acp3x_probe(struct pci_dev *pci, static void snd_acp3x_remove(struct pci_dev *pci) { struct acp3x_dev_data *adata = pci_get_drvdata(pci); - - platform_device_unregister(adata->pdev); + mfd_remove_devices(adata->parent); iounmap(adata->acp3x_base); - pci_release_regions(pci); pci_disable_device(pci); } @@ -142,6 +182,7 @@ static struct pci_driver acp3x_driver = { module_pci_driver(acp3x_driver); +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com"); MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com"); MODULE_DESCRIPTION("AMD ACP3x PCI driver"); MODULE_LICENSE("GPL v2"); From patchwork Tue Oct 1 00:58:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "RAVULAPATI, VISHNU VARDHAN RAO" X-Patchwork-Id: 11166765 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1A6716B1 for ; Mon, 30 Sep 2019 14:08:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 449FB20842 for ; Mon, 30 Sep 2019 14:08:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="B8+/d9UQ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="O+TMU7Ma" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 449FB20842 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8F7CF1663; Mon, 30 Sep 2019 16:07:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8F7CF1663 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1569852506; bh=lqlBYKA4NMiK4ML8Y8Ta9GweQZD9h1zGRgLcgR+lXMg=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=B8+/d9UQ4yrD2r4WfEyHr6Bxxw0Iz9b1gBiNMx7E6ptPwFZluAJSax9DXsF99cyzL LL1TQB9e6YIbsfCt7MepU5wJJWAJdU8MEg4NSMIUdFQrLaHAy/DRiHOc2HuASQy+d+ O1NP1wUeR3UmZuaFZHd7npdK0C48MtY1N+4ttB28= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BD6F0F805F9; Mon, 30 Sep 2019 16:06:31 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 108FBF805FA; Mon, 30 Sep 2019 16:06:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE autolearn=disabled version=3.4.0 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680047.outbound.protection.outlook.com [40.107.68.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 716DCF805F8 for ; Mon, 30 Sep 2019 16:06:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 716DCF805F8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="O+TMU7Ma" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DD4ECTcqYE8KTU7DmfMnWXrmJsK6VoXIoB/lBQJ1plX1VHmFKBCe//7AdNiVYcM/G884wGp0tmyEfpgPzp/P0sQDYR0a0r5jEEdF5p8t+yqU0Gn1dX8UDTAe80j4sauupXpRc8TH7CGGdE1KJFN6rkdBa/DB79AOuN4uymSymx3GzQ4Vvo6YUEdMZZJ9qeu8eQh+WFGsqs7Sit6EotnHuejfI71m0cSilsZ+BW9fXOWYT3sjXpHBntUjmBv8n0Hh+ZxbYx/a33IRRYhQkIDI+BblGYxZnI2ldWB1AlAQbrygaank5gfKXRdgJHBafpoNUeEWMZbo7/ufVV7Z9xO/hA== 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=ooJO9TNsymauNcHwmLMjjVdg/llk3uqI/tb/nNVOLbs=; b=jk9JsGAZPX2vmSDh5cUMgZeIV683entp1u2T5rNPtgbCZuzrP5Why/ftSilSKN/2klVuHdTb5C6DUIScKpQwtLRf+I7GZ950132b4JrnvYyGUeLNQ7k5XRU6xqeSnKPFtbstZgIVYBA+5DduiKY3mG2yXgq28xtaf4pLhpPYK5NttMFk1JUV5hRQC+rtOGe9LLb6uMUomN7OlMOCxH1LhMiLyslIfLXLXSnhvkaaMSxWQAQlV3JGi6/0nr60ppwW3cW1adNFK71L5zaSRq0D8/t7kxwOL6BUYgDQJA6Xwrcx1tcxJq2fyw4d0aLBXvY3Zx8zDK+5cX9BlZp3vYEDvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=huawei.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ooJO9TNsymauNcHwmLMjjVdg/llk3uqI/tb/nNVOLbs=; b=O+TMU7MacoJUGCgbPIjjTNugX10bDyYsngZmU0hayc0FvQbMv+o4Pbk9dXfv3etQuzL7JRJAZn5WiuJmFBS2lqzs457JSAEUdPT/6ntYcAxg8z/0KWB8cvY8UCUjg0bod5zWnJ7/+oqWuVL81iSfJHwwMgZy6VgntHw0aS1dDJs= Received: from MWHPR12CA0071.namprd12.prod.outlook.com (2603:10b6:300:103::33) by CH2PR12MB4135.namprd12.prod.outlook.com (2603:10b6:610:7c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 14:06:12 +0000 Received: from CO1NAM03FT035.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::202) by MWHPR12CA0071.outlook.office365.com (2603:10b6:300:103::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.17 via Frontend Transport; Mon, 30 Sep 2019 14:06:12 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT035.mail.protection.outlook.com (10.152.80.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 14:06:11 +0000 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 30 Sep 2019 09:06:09 -0500 From: Ravulapati Vishnu vardhan rao To: Date: Tue, 1 Oct 2019 06:28:11 +0530 Message-ID: <1569891524-18875-3-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> References: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(376002)(136003)(39860400002)(346002)(428003)(199004)(189003)(486006)(426003)(81166006)(356004)(76176011)(7696005)(47776003)(6666004)(51416003)(8676002)(109986005)(2906002)(11346002)(81156014)(305945005)(2616005)(476003)(186003)(446003)(30864003)(50226002)(8936002)(126002)(336012)(1671002)(86362001)(4326008)(54906003)(5660300002)(70206006)(70586007)(316002)(53416004)(50466002)(16586007)(36756003)(48376002)(26005)(478600001)(14444005)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:CH2PR12MB4135; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17b86a97-6c96-4426-10f8-08d745af59ae X-MS-TrafficTypeDiagnostic: CH2PR12MB4135:|CH2PR12MB4135: X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-MS-Oob-TLC-OOBClassifiers: OLM:46; X-Forefront-PRVS: 01762B0D64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kDCx7yDtYsEBK4nYnHHM4QBoy/eLcILP2WT+ig2m16f52SjenRdVI61ZBlIYw0TLHfT2qAfqO4Bru6VfVhhCG6e7N+SinMBm0J0T7IAoBSmFOcViQaumlgnQEQQmuQMOE4nTPqT3E7Fedtt9igNkfI2oEF3qM5Rv8OmbAYhD0VmtSeVL5v+lnZ4PbleOoJwVOQTOnzFF1LX9DANhSwObbQQZD5AlPJQ5rUBsje5cOH6Y41G6/1ibwEvYwg5QwDtUFYdBLj7MwFEh5O0ahUGYlxhjo4fpeXGYW5+GYnJxNldTnaKgns57C7B1U59hBETD+dJP1ySxiJVKnUp/VCvn50xylaFIV8jexf3i5Z4EGBs4s6R+QyRzLPQW5PizHyomnKV6RJuA6gTYaZk0fyBXU+Zr1mSC57IQdWodLBoYJmA= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 14:06:11.8384 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17b86a97-6c96-4426-10f8-08d745af59ae 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4135 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Maruthi Bayyavarapu , open list , YueHaibing , Takashi Iwai , Liam Girdwood , Sanju R Mehta , Ravulapati Vishnu vardhan rao , Mark Brown , Vijendar Mukunda , Alexander.Deucher@amd.com Subject: [alsa-devel] [PATCH 3/7] ASoC: amd: Refactoring of DAI from DMA driver X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Asoc: PCM DMA driver should only have dma ops. So Removed all DAI related functionality. Refactoring the PCM DMA diver code. Added new file containing only DAI ops. Signed-off-by: Ravulapati Vishnu vardhan rao --- sound/soc/amd/raven/acp3x-i2s.c | 289 ++++++++++++++++++++++++++++++++++++ sound/soc/amd/raven/acp3x-pcm-dma.c | 211 +------------------------- sound/soc/amd/raven/acp3x.h | 23 +++ 3 files changed, 320 insertions(+), 203 deletions(-) create mode 100644 sound/soc/amd/raven/acp3x-i2s.c diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c new file mode 100644 index 0000000..7420928 --- /dev/null +++ b/sound/soc/amd/raven/acp3x-i2s.c @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// AMD ALSA SoC PCM Driver +// +//Copyright 2016 Advanced Micro Devices, Inc. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "acp3x.h" + +#define DRV_NAME "acp3x-i2s" + +static u64 acp_get_byte_count(struct i2s_stream_instance *rtd, int direction) +{ + u64 byte_count; + + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); + } else { + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); + } + return byte_count; +} + +static int acp3x_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) +{ + + struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + + case SND_SOC_DAIFMT_I2S: + adata->tdm_mode = false; + break; + case SND_SOC_DAIFMT_DSP_A: + adata->tdm_mode = true; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, + u32 rx_mask, int slots, int slot_width) +{ + u32 val = 0; + u16 slot_len; + + struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); + + switch (slot_width) { + case SLOT_WIDTH_8: + slot_len = 8; + break; + case SLOT_WIDTH_16: + slot_len = 16; + break; + case SLOT_WIDTH_24: + slot_len = 24; + break; + case SLOT_WIDTH_32: + slot_len = 0; + break; + default: + return -EINVAL; + } + + val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER); + rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_ITER); + val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER); + rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_IRER); + + val = (FRM_LEN | (slots << 15) | (slot_len << 18)); + rv_writel(val, adata->acp3x_base + mmACP_BTTDM_TXFRMT); + rv_writel(val, adata->acp3x_base + mmACP_BTTDM_RXFRMT); + + adata->tdm_fmt = val; + return 0; +} + +static int acp3x_i2s_hwparams(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + u32 val = 0; + struct i2s_stream_instance *rtd = substream->runtime->private_data; + + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_U8: + case SNDRV_PCM_FORMAT_S8: + rtd->xfer_resolution = 0x0; + break; + case SNDRV_PCM_FORMAT_S16_LE: + rtd->xfer_resolution = 0x02; + break; + case SNDRV_PCM_FORMAT_S24_LE: + rtd->xfer_resolution = 0x04; + break; + case SNDRV_PCM_FORMAT_S32_LE: + rtd->xfer_resolution = 0x05; + break; + default: + return -EINVAL; + } + val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); + val = val | (rtd->xfer_resolution << 3); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); + else + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); + + return 0; +} + +static int acp3x_i2s_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + int ret = 0; + struct i2s_stream_instance *rtd = substream->runtime->private_data; + u32 val, period_bytes; + + period_bytes = frames_to_bytes(substream->runtime, + substream->runtime->period_size); + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + rtd->bytescount = acp_get_byte_count(rtd, + substream->stream); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + rv_writel(period_bytes, rtd->acp3x_base + + mmACP_BT_TX_INTR_WATERMARK_SIZE); + val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); + val = val | BIT(0); + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); + } else { + rv_writel(period_bytes, rtd->acp3x_base + + mmACP_BT_RX_INTR_WATERMARK_SIZE); + val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); + val = val | BIT(0); + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); + } + rv_writel(1, rtd->acp3x_base + mmACP_BTTDM_IER); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); + val = val & ~BIT(0); + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); + } else { + val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); + val = val & ~BIT(0); + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); + } + rv_writel(0, rtd->acp3x_base + mmACP_BTTDM_IER); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static struct snd_soc_dai_ops acp3x_i2s_dai_ops = { + .hw_params = acp3x_i2s_hwparams, + .trigger = acp3x_i2s_trigger, + .set_fmt = acp3x_i2s_set_fmt, + .set_tdm_slot = acp3x_i2s_set_tdm_slot, +}; + +static const struct snd_soc_component_driver acp3x_dai_component = { + .name = "acp3x-i2s", +}; + +static struct snd_soc_dai_driver acp3x_i2s_dai = { + .playback = { + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 8, + + .rate_min = 8000, + .rate_max = 96000, + }, + .capture = { + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &acp3x_i2s_dai_ops, +}; + + +static int acp3x_dai_probe(struct platform_device *pdev) +{ + int status; + struct resource *res; + struct i2s_dev_data *adata; + + if (!pdev->dev.platform_data) { + dev_err(&pdev->dev, "platform_data not retrieved\n"); + return -ENODEV; + } + + adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data), + GFP_KERNEL); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n"); + return -ENODEV; + } + + adata->acp3x_base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); + if (IS_ERR(adata->acp3x_base)) + return PTR_ERR(adata->acp3x_base); + + + + adata->i2s_irq = res->start; + adata->play_stream = NULL; + adata->capture_stream = NULL; + + dev_set_drvdata(&pdev->dev, adata); + status = devm_snd_soc_register_component(&pdev->dev, + &acp3x_dai_component, + &acp3x_i2s_dai, 1); + if (status) { + dev_err(&pdev->dev, "Fail to register acp i2s dai\n"); + goto dev_err; + } + + pm_runtime_set_autosuspend_delay(&pdev->dev, 10000); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_enable(&pdev->dev); + return 0; +dev_err: + /*ignore device status and return driver probe error*/ + return -ENODEV; +} + +static int acp3x_dai_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); + return 0; +} +static struct platform_driver acp3x_dai_driver = { + .probe = acp3x_dai_probe, + .remove = acp3x_dai_remove, + .driver = { + .name = "acp3x_i2s_playcap", + }, +}; + +module_platform_driver(acp3x_dai_driver); + +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com"); +MODULE_DESCRIPTION("AMD ACP 3.x PCM Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index bc4dfaf..e14ec55 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -18,24 +18,6 @@ #define DRV_NAME "acp3x-i2s-audio" -struct i2s_dev_data { - bool tdm_mode; - unsigned int i2s_irq; - u32 tdm_fmt; - void __iomem *acp3x_base; - struct snd_pcm_substream *play_stream; - struct snd_pcm_substream *capture_stream; -}; - -struct i2s_stream_instance { - u16 num_pages; - u16 channels; - u32 xfer_resolution; - u64 bytescount; - dma_addr_t dma_addr; - void __iomem *acp3x_base; -}; - static const struct snd_pcm_hardware acp3x_pcm_hardware_playback = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -432,183 +414,6 @@ static struct snd_pcm_ops acp3x_dma_ops = { .mmap = acp3x_dma_mmap, }; - -static int acp3x_dai_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) -{ - - struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); - - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_I2S: - adata->tdm_mode = false; - break; - case SND_SOC_DAIFMT_DSP_A: - adata->tdm_mode = true; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int acp3x_dai_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, - u32 rx_mask, int slots, int slot_width) -{ - u32 val = 0; - u16 slot_len; - - struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); - - switch (slot_width) { - case SLOT_WIDTH_8: - slot_len = 8; - break; - case SLOT_WIDTH_16: - slot_len = 16; - break; - case SLOT_WIDTH_24: - slot_len = 24; - break; - case SLOT_WIDTH_32: - slot_len = 0; - break; - default: - return -EINVAL; - } - - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER); - rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_ITER); - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER); - rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_IRER); - - val = (FRM_LEN | (slots << 15) | (slot_len << 18)); - rv_writel(val, adata->acp3x_base + mmACP_BTTDM_TXFRMT); - rv_writel(val, adata->acp3x_base + mmACP_BTTDM_RXFRMT); - - adata->tdm_fmt = val; - return 0; -} - -static int acp3x_dai_i2s_hwparams(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - u32 val = 0; - struct i2s_stream_instance *rtd = substream->runtime->private_data; - - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_U8: - case SNDRV_PCM_FORMAT_S8: - rtd->xfer_resolution = 0x0; - break; - case SNDRV_PCM_FORMAT_S16_LE: - rtd->xfer_resolution = 0x02; - break; - case SNDRV_PCM_FORMAT_S24_LE: - rtd->xfer_resolution = 0x04; - break; - case SNDRV_PCM_FORMAT_S32_LE: - rtd->xfer_resolution = 0x05; - break; - default: - return -EINVAL; - } - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val | (rtd->xfer_resolution << 3); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); - else - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); - - return 0; -} - -static int acp3x_dai_i2s_trigger(struct snd_pcm_substream *substream, - int cmd, struct snd_soc_dai *dai) -{ - int ret = 0; - struct i2s_stream_instance *rtd = substream->runtime->private_data; - u32 val, period_bytes; - - period_bytes = frames_to_bytes(substream->runtime, - substream->runtime->period_size); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - rtd->bytescount = acp_get_byte_count(rtd, substream->stream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - rv_writel(period_bytes, rtd->acp3x_base + - mmACP_BT_TX_INTR_WATERMARK_SIZE); - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val | BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); - } else { - rv_writel(period_bytes, rtd->acp3x_base + - mmACP_BT_RX_INTR_WATERMARK_SIZE); - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); - val = val | BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); - } - rv_writel(1, rtd->acp3x_base + mmACP_BTTDM_IER); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val & ~BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); - } else { - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); - val = val & ~BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); - } - rv_writel(0, rtd->acp3x_base + mmACP_BTTDM_IER); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static struct snd_soc_dai_ops acp3x_dai_i2s_ops = { - .hw_params = acp3x_dai_i2s_hwparams, - .trigger = acp3x_dai_i2s_trigger, - .set_fmt = acp3x_dai_i2s_set_fmt, - .set_tdm_slot = acp3x_dai_set_tdm_slot, -}; - -static struct snd_soc_dai_driver acp3x_i2s_dai_driver = { - .playback = { - .rates = SNDRV_PCM_RATE_8000_96000, - .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | - SNDRV_PCM_FMTBIT_U8 | - SNDRV_PCM_FMTBIT_S24_LE | - SNDRV_PCM_FMTBIT_S32_LE, - .channels_min = 2, - .channels_max = 8, - - .rate_min = 8000, - .rate_max = 96000, - }, - .capture = { - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | - SNDRV_PCM_FMTBIT_U8 | - SNDRV_PCM_FMTBIT_S24_LE | - SNDRV_PCM_FMTBIT_S32_LE, - .channels_min = 2, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &acp3x_dai_i2s_ops, -}; - static const struct snd_soc_component_driver acp3x_i2s_component = { .name = DRV_NAME, .ops = &acp3x_dma_ops, @@ -627,17 +432,16 @@ static int acp3x_audio_probe(struct platform_device *pdev) return -ENODEV; } irqflags = *((unsigned int *)(pdev->dev.platform_data)); + adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL); + if (!adata) + return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n"); + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n"); return -ENODEV; } - adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL); - if (!adata) - return -ENOMEM; - adata->acp3x_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); @@ -658,9 +462,9 @@ static int acp3x_audio_probe(struct platform_device *pdev) return -ENODEV; status = devm_snd_soc_register_component(&pdev->dev, &acp3x_i2s_component, - &acp3x_i2s_dai_driver, 1); + NULL, 0); if (status) { - dev_err(&pdev->dev, "Fail to register acp i2s dai\n"); + dev_err(&pdev->dev, "Fail to register acp i2s component\n"); goto dev_err; } status = devm_request_irq(&pdev->dev, adata->i2s_irq, i2s_irq_handler, @@ -782,13 +586,14 @@ static struct platform_driver acp3x_dma_driver = { .probe = acp3x_audio_probe, .remove = acp3x_audio_remove, .driver = { - .name = "acp3x_rv_i2s", + .name = "acp3x_rv_i2s_dma", .pm = &acp3x_pm_ops, }, }; module_platform_driver(acp3x_dma_driver); +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com"); MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com"); MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); MODULE_DESCRIPTION("AMD ACP 3.x PCM Driver"); diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index c122dc6..baa76cd 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -54,6 +54,29 @@ #define SLOT_WIDTH_24 0x18 #define SLOT_WIDTH_32 0x20 +struct acp3x_platform_info { + u16 play_i2s_instance; + u16 cap_i2s_instance; + u16 capture_channel; +}; + +struct i2s_dev_data { + bool tdm_mode; + unsigned int i2s_irq; + u32 tdm_fmt; + void __iomem *acp3x_base; + struct snd_pcm_substream *play_stream; + struct snd_pcm_substream *capture_stream; +}; + +struct i2s_stream_instance { + u16 num_pages; + u16 channels; + u32 xfer_resolution; + u64 bytescount; + dma_addr_t dma_addr; + void __iomem *acp3x_base; +}; static inline u32 rv_readl(void __iomem *base_addr) { From patchwork Tue Oct 1 00:58:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "RAVULAPATI, VISHNU VARDHAN RAO" X-Patchwork-Id: 11166767 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6123016B1 for ; Mon, 30 Sep 2019 14:09:19 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8DEB218AC for ; Mon, 30 Sep 2019 14:09:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="i4NnyDbz"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="nztyjjDg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8DEB218AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2D566166C; Mon, 30 Sep 2019 16:08:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2D566166C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1569852557; bh=zBYo1Bn1KUa/7a5Ay5zXKOa6tnSP/0Vfp4h++E9QXRY=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=i4NnyDbzE/2KB7pKwhpyqw5DLP7Yxnz8Y37oKeMB4JvclZpSNT7X5GrhyJaiysY/H 5MpDIuYcaORz9bT9Swl8Pnc+IXa/XMV63v61Lff4o74j9S2/egOaNapRkABksNCawM fXV1s20Da9jh1H0A1ddaoiEBzm3zXsgJfbFkbWHw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7816CF80611; Mon, 30 Sep 2019 16:06:41 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 64B8EF80611; Mon, 30 Sep 2019 16:06:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE autolearn=disabled version=3.4.0 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730041.outbound.protection.outlook.com [40.107.73.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9C4C1F8060E for ; Mon, 30 Sep 2019 16:06:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9C4C1F8060E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="nztyjjDg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mHOcemOefedZWIha5Ad9XWGywYv/E4a7wSUgWlprxJpzAV4cwuJZ84qNEtsScnESWxDs2dOzXvKhdZGwaRB92UlkboRKxmKwzau3VsjD+t9tR47KHQP9SyDQSYSWfFOq3hL1UMiBLa/Rm1DuN5z2DPK1uia9hGx1xr/yALpZzw+ro2RLZbfKZx7bJu1gDF4u8Q1COTZw7GlpUjNbtVsc7SAFAFQJgUHphtUOkkvK6mUiSZQegaW1dvQYnfgLUaQYgAWf1jYc0OIA1kDyuS3Hmi7T60POLH7xgQtXZjg8PEq7XvwyrAB8elBvLxtP25jUY4v43/4X1OFdwFPWv60bmg== 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=qllx4vReL+hDpx3KSejP3D8ofxeJV8B0G54qclhXU2Y=; b=EWIcsVePhH/xyzUXn5XfdSBhZBxjbX2Yz9AHzZue+6HtsH0pVg8F4Vf/YLTU1JgGn1u/+OukXCFGQBFSbJiHtWX0Kv13SevcqxvrDJJZbojC8yb0pf50lhvWAtky1rxZ2eDloCUWYwsQ501z6NAQgfy++nmfMiKIykD9I76dkXRu1koKwvHnWf8kSMLMr/y75Bya8ZNk0Sgp3GHCoYCy25cgZk9jztPgDwOtQnWfnTenFUhsscJmElZqJTqEngIQychyX7jp7RfATprP4lS0GnLkqs8EO8Tdpmg75pkh65Kk3fUV3xnGP2lVrSfRnjKJGGPlD4t45YlP+RoP1IHMSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=huawei.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qllx4vReL+hDpx3KSejP3D8ofxeJV8B0G54qclhXU2Y=; b=nztyjjDghgzsWfqnacmwnTDJRmUywkQzc2Ocw9EfENpf040eNjV/do7uDUajpEzMlRMAfRX/jxOjmJFVA8QYEVRvf+EccP5E4R6ZnvISE6GqGs4Xqj9V6X3paachN0ux5sbj3lklBm+H+g4KyoKZ2eOiwnjb1nNi215os1VkX7k= Received: from MWHPR1201CA0021.namprd12.prod.outlook.com (2603:10b6:301:4a::31) by DM6PR12MB3915.namprd12.prod.outlook.com (2603:10b6:5:1ca::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 14:06:31 +0000 Received: from CO1NAM03FT057.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by MWHPR1201CA0021.outlook.office365.com (2603:10b6:301:4a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.16 via Frontend Transport; Mon, 30 Sep 2019 14:06:31 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT057.mail.protection.outlook.com (10.152.81.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 14:06:30 +0000 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 30 Sep 2019 09:06:26 -0500 From: Ravulapati Vishnu vardhan rao To: Date: Tue, 1 Oct 2019 06:28:12 +0530 Message-ID: <1569891524-18875-4-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> References: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(39860400002)(396003)(136003)(428003)(199004)(189003)(7696005)(50226002)(86362001)(51416003)(8936002)(8676002)(81156014)(81166006)(478600001)(76176011)(14444005)(5660300002)(2906002)(54906003)(6666004)(356004)(19627235002)(305945005)(50466002)(48376002)(70586007)(70206006)(26005)(53416004)(2616005)(336012)(1671002)(426003)(16586007)(186003)(36756003)(4326008)(47776003)(11346002)(446003)(316002)(30864003)(126002)(476003)(109986005)(486006)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3915; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bc1b02d-f7b4-416d-2208-08d745af64ea X-MS-TrafficTypeDiagnostic: DM6PR12MB3915:|DM6PR12MB3915: X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-Forefront-PRVS: 01762B0D64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ctoBQ3yOMIsp+ATl9IgcTIWgLEH2sxleoJgegjsaEdbbxTeJQpyFasf2G5IwxPp7xSNdLXMZhhfUic4VJcg/b+MQam8fJuL0xjtCduLf4ugne2CIMjiKRMy9/t933G7Zp98PuPf+Prxv4v7zOgNcP2p+pn4vUGGeJ7H05VtVG9y1m/XBAo3NoMLmeBxe25BLOFjjMqNF+E6KM8Sm1DwFLRMs2VEk+lp0eBPUn7bAtQFpjqL5von75vF+8aNb63DModOYzhDlh4SbQUwIAGRGVI5yZv4pKWAO6gi/deenMnNNNlgsVuYGthRdHUzGtWTdqLnwTCJPJQWfXPJ6vo+9DAowCTKUpa8jXdLHcSLGOu0H0s86JzJUDjqvmOJlwn2FSYDJmUYVlfiVWAwKSi50K68eUc90fy49j0bqk6OfYAE= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 14:06:30.8862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bc1b02d-f7b4-416d-2208-08d745af64ea 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Maruthi Bayyavarapu , open list , YueHaibing , Takashi Iwai , Liam Girdwood , Ravulapati Vishnu vardhan rao , Mark Brown , Vijendar Mukunda , Alex Deucher Subject: [alsa-devel] [PATCH 4/7] ASoC: amd: Enabling I2S instance in DMA and DAI X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This patch adds I2S SP support in ACP PCM DMA and DAI. Added I2S support in DMA and DAI probe,its hw_params handling its open and close functionalities. This enable to open and close on the SP instance for playback and capture. Signed-off-by: Ravulapati Vishnu vardhan rao --- sound/soc/amd/raven/Makefile | 2 + sound/soc/amd/raven/acp3x-i2s.c | 181 +++++++++++++++++++++++------- sound/soc/amd/raven/acp3x-pcm-dma.c | 218 +++++++++++++++++++++++++----------- sound/soc/amd/raven/acp3x.h | 75 +++++++++++-- 4 files changed, 358 insertions(+), 118 deletions(-) diff --git a/sound/soc/amd/raven/Makefile b/sound/soc/amd/raven/Makefile index 108d1ac..8eef292 100644 --- a/sound/soc/amd/raven/Makefile +++ b/sound/soc/amd/raven/Makefile @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0+ # Raven Ridge platform Support snd-pci-acp3x-objs := pci-acp3x.o +snd-acp3x-i2s-objs := acp3x-i2s.o snd-acp3x-pcm-dma-objs := acp3x-pcm-dma.o obj-$(CONFIG_SND_SOC_AMD_ACP3x) += snd-pci-acp3x.o +obj-$(CONFIG_SND_SOC_AMD_ACP3x) += snd-acp3x-i2s.o obj-$(CONFIG_SND_SOC_AMD_ACP3x) += snd-acp3x-pcm-dma.o diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c index 7420928..4511b9b 100644 --- a/sound/soc/amd/raven/acp3x-i2s.c +++ b/sound/soc/amd/raven/acp3x-i2s.c @@ -19,24 +19,6 @@ #define DRV_NAME "acp3x-i2s" -static u64 acp_get_byte_count(struct i2s_stream_instance *rtd, int direction) -{ - u64 byte_count; - - if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); - } else { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); - } - return byte_count; -} - static int acp3x_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { @@ -100,8 +82,18 @@ static int acp3x_i2s_hwparams(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { u32 val = 0; + struct snd_soc_pcm_runtime *prtd = substream->private_data; + struct snd_soc_card *card = prtd->card; + struct acp3x_platform_info *pinfo = snd_soc_card_get_drvdata(card); struct i2s_stream_instance *rtd = substream->runtime->private_data; + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + } + switch (params_format(params)) { case SNDRV_PCM_FORMAT_U8: case SNDRV_PCM_FORMAT_S8: @@ -119,12 +111,33 @@ static int acp3x_i2s_hwparams(struct snd_pcm_substream *substream, default: return -EINVAL; } - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val | (rtd->xfer_resolution << 3); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); - else - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); + val = val | (rtd->xfer_resolution << 3); + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); + break; + case I2S_SP_INSTANCE: + default: + val = rv_readl(rtd->acp3x_base + mmACP_I2STDM_ITER); + val = val | (rtd->xfer_resolution << 3); + rv_writel(val, rtd->acp3x_base + mmACP_I2STDM_ITER); + } + } else { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); + val = val | (rtd->xfer_resolution << 3); + rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); + break; + case I2S_SP_INSTANCE: + default: + val = rv_readl(rtd->acp3x_base + mmACP_I2STDM_IRER); + val = val | (rtd->xfer_resolution << 3); + rv_writel(val, rtd->acp3x_base + mmACP_I2STDM_IRER); + } + } return 0; } @@ -135,7 +148,16 @@ static int acp3x_i2s_trigger(struct snd_pcm_substream *substream, int ret = 0; struct i2s_stream_instance *rtd = substream->runtime->private_data; u32 val, period_bytes; - + struct snd_soc_pcm_runtime *prtd = substream->private_data; + struct snd_soc_card *card = prtd->card; + struct acp3x_platform_info *pinfo = snd_soc_card_get_drvdata(card); + + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + } period_bytes = frames_to_bytes(substream->runtime, substream->runtime->period_size); switch (cmd) { @@ -145,34 +167,105 @@ static int acp3x_i2s_trigger(struct snd_pcm_substream *substream, rtd->bytescount = acp_get_byte_count(rtd, substream->stream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - rv_writel(period_bytes, rtd->acp3x_base + + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + rv_writel(period_bytes, rtd->acp3x_base + mmACP_BT_TX_INTR_WATERMARK_SIZE); - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val | BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); + val = rv_readl(rtd->acp3x_base + + mmACP_BTTDM_ITER); + val = val | BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_BTTDM_ITER); + rv_writel(1, rtd->acp3x_base + + mmACP_BTTDM_IER); + break; + case I2S_SP_INSTANCE: + default: + rv_writel(period_bytes, rtd->acp3x_base + + mmACP_I2S_TX_INTR_WATERMARK_SIZE); + val = rv_readl(rtd->acp3x_base + + mmACP_I2STDM_ITER); + val = val | BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_I2STDM_ITER); + rv_writel(1, rtd->acp3x_base + + mmACP_I2STDM_IER); + } } else { - rv_writel(period_bytes, rtd->acp3x_base + + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + rv_writel(period_bytes, rtd->acp3x_base + mmACP_BT_RX_INTR_WATERMARK_SIZE); - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); - val = val | BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); + val = rv_readl(rtd->acp3x_base + + mmACP_BTTDM_IRER); + val = val | BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_BTTDM_IRER); + rv_writel(1, rtd->acp3x_base + + mmACP_BTTDM_IER); + break; + case I2S_SP_INSTANCE: + default: + rv_writel(period_bytes, rtd->acp3x_base + + mmACP_I2S_RX_INTR_WATERMARK_SIZE); + val = rv_readl(rtd->acp3x_base + + mmACP_I2STDM_IRER); + val = val | BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_I2STDM_IRER); + rv_writel(1, rtd->acp3x_base + + mmACP_I2STDM_IER); + } } - rv_writel(1, rtd->acp3x_base + mmACP_BTTDM_IER); - break; + break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val & ~BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = rv_readl(rtd->acp3x_base + + mmACP_BTTDM_ITER); + val = val & ~BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_BTTDM_ITER); + rv_writel(0, rtd->acp3x_base + + mmACP_BTTDM_IER); + break; + case I2S_SP_INSTANCE: + default: + val = rv_readl(rtd->acp3x_base + + mmACP_I2STDM_ITER); + val = val & ~BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_I2STDM_ITER); + rv_writel(0, rtd->acp3x_base + + mmACP_I2STDM_IER); + } + } else { - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); - val = val & ~BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = rv_readl(rtd->acp3x_base + + mmACP_BTTDM_IRER); + val = val & ~BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_BTTDM_IRER); + rv_writel(0, rtd->acp3x_base + + mmACP_BTTDM_IER); + break; + case I2S_SP_INSTANCE: + default: + val = rv_readl(rtd->acp3x_base + + mmACP_I2STDM_IRER); + val = val & ~BIT(0); + rv_writel(val, rtd->acp3x_base + + mmACP_I2STDM_IRER); + rv_writel(0, rtd->acp3x_base + + mmACP_I2STDM_IER); + } } - rv_writel(0, rtd->acp3x_base + mmACP_BTTDM_IER); - break; + break; default: ret = -EINVAL; break; @@ -249,6 +342,8 @@ static int acp3x_dai_probe(struct platform_device *pdev) adata->i2s_irq = res->start; adata->play_stream = NULL; adata->capture_stream = NULL; + adata->i2ssp_play_stream = NULL; + adata->i2ssp_capture_stream = NULL; dev_set_drvdata(&pdev->dev, adata); status = devm_snd_soc_register_component(&pdev->dev, diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index e14ec55..6fa892a 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -193,20 +193,35 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id) static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction) { u16 page_idx; - u32 low, high, val, acp_fifo_addr; - dma_addr_t addr = rtd->dma_addr; + uint64_t low, high, val, acp_fifo_addr; + dma_addr_t addr; - /* 8 scratch registers used to map one 64 bit address */ - if (direction == SNDRV_PCM_STREAM_PLAYBACK) - val = 0; - else - val = rtd->num_pages * 8; + addr = rtd->dma_addr; + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = ACP_SRAM_BT_PB_PTE_OFFSET; + break; + case I2S_SP_INSTANCE: + default: + val = ACP_SRAM_SP_PB_PTE_OFFSET; + } + } else { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = ACP_SRAM_BT_CP_PTE_OFFSET; + break; + case I2S_SP_INSTANCE: + default: + val = ACP_SRAM_SP_CP_PTE_OFFSET; + } + } /* Group Enable */ rv_writel(ACP_SRAM_PTE_OFFSET | BIT(31), rtd->acp3x_base + - mmACPAXI2AXI_ATU_BASE_ADDR_GRP_1); + mmACPAXI2AXI_ATU_BASE_ADDR_GRP_1); rv_writel(PAGE_SIZE_4K_ENABLE, rtd->acp3x_base + - mmACPAXI2AXI_ATU_PAGE_SIZE_GRP_1); + mmACPAXI2AXI_ATU_PAGE_SIZE_GRP_1); for (page_idx = 0; page_idx < rtd->num_pages; page_idx++) { /* Load the low address of page int ACP SRAM through SRBM */ @@ -223,38 +238,95 @@ static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction) } if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - /* Config ringbuffer */ - rv_writel(MEM_WINDOW_START, rtd->acp3x_base + - mmACP_BT_TX_RINGBUFADDR); - rv_writel(MAX_BUFFER, rtd->acp3x_base + - mmACP_BT_TX_RINGBUFSIZE); - rv_writel(DMA_SIZE, rtd->acp3x_base + mmACP_BT_TX_DMA_SIZE); - - /* Config audio fifo */ - acp_fifo_addr = ACP_SRAM_PTE_OFFSET + (rtd->num_pages * 8) - + PLAYBACK_FIFO_ADDR_OFFSET; - rv_writel(acp_fifo_addr, rtd->acp3x_base + - mmACP_BT_TX_FIFOADDR); - rv_writel(FIFO_SIZE, rtd->acp3x_base + mmACP_BT_TX_FIFOSIZE); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + /* Config ringbuffer */ + rv_writel(I2S_BT_TX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_BT_TX_RINGBUFADDR); + rv_writel(MAX_BUFFER, rtd->acp3x_base + + mmACP_BT_TX_RINGBUFSIZE); + rv_writel(DMA_SIZE, + rtd->acp3x_base + mmACP_BT_TX_DMA_SIZE); + + /* Config audio fifo */ + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + BT_PB_FIFO_ADDR_OFFSET; + rv_writel(acp_fifo_addr, + rtd->acp3x_base + mmACP_BT_TX_FIFOADDR); + rv_writel(FIFO_SIZE, + rtd->acp3x_base + mmACP_BT_TX_FIFOSIZE); + /* Enable watermark/period interrupt to host */ + rv_writel(BIT(BT_TX_THRESHOLD), + rtd->acp3x_base + mmACP_EXTERNAL_INTR_CNTL); + break; + + case I2S_SP_INSTANCE: + default: + /* Config ringbuffer */ + rv_writel(I2S_SP_TX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_I2S_TX_RINGBUFADDR); + rv_writel(MAX_BUFFER, + rtd->acp3x_base + mmACP_I2S_TX_RINGBUFSIZE); + rv_writel(DMA_SIZE, + rtd->acp3x_base + mmACP_I2S_TX_DMA_SIZE); + + /* Config audio fifo */ + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + SP_PB_FIFO_ADDR_OFFSET; + rv_writel(acp_fifo_addr, + rtd->acp3x_base + mmACP_I2S_TX_FIFOADDR); + rv_writel(FIFO_SIZE, + rtd->acp3x_base + mmACP_I2S_TX_FIFOSIZE); + /* Enable watermark/period interrupt to host */ + rv_writel(BIT(I2S_TX_THRESHOLD), + rtd->acp3x_base + mmACP_EXTERNAL_INTR_CNTL); + } } else { - /* Config ringbuffer */ - rv_writel(MEM_WINDOW_START + MAX_BUFFER, rtd->acp3x_base + - mmACP_BT_RX_RINGBUFADDR); - rv_writel(MAX_BUFFER, rtd->acp3x_base + - mmACP_BT_RX_RINGBUFSIZE); - rv_writel(DMA_SIZE, rtd->acp3x_base + mmACP_BT_RX_DMA_SIZE); - - /* Config audio fifo */ - acp_fifo_addr = ACP_SRAM_PTE_OFFSET + - (rtd->num_pages * 8) + CAPTURE_FIFO_ADDR_OFFSET; - rv_writel(acp_fifo_addr, rtd->acp3x_base + - mmACP_BT_RX_FIFOADDR); - rv_writel(FIFO_SIZE, rtd->acp3x_base + mmACP_BT_RX_FIFOSIZE); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + /* Config ringbuffer */ + rv_writel(I2S_BT_RX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_BT_RX_RINGBUFADDR); + rv_writel(MAX_BUFFER, + rtd->acp3x_base + mmACP_BT_RX_RINGBUFSIZE); + rv_writel(DMA_SIZE, + rtd->acp3x_base + mmACP_BT_RX_DMA_SIZE); + + /* Config audio fifo */ + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + BT_CAPT_FIFO_ADDR_OFFSET; + rv_writel(acp_fifo_addr, + rtd->acp3x_base + mmACP_BT_RX_FIFOADDR); + rv_writel(FIFO_SIZE, + rtd->acp3x_base + mmACP_BT_RX_FIFOSIZE); + /* Enable watermark/period interrupt to host */ + rv_writel(BIT(BT_RX_THRESHOLD), + rtd->acp3x_base + mmACP_EXTERNAL_INTR_CNTL); + break; + + case I2S_SP_INSTANCE: + default: + /* Config ringbuffer */ + rv_writel(I2S_SP_RX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_I2S_RX_RINGBUFADDR); + rv_writel(MAX_BUFFER, + rtd->acp3x_base + mmACP_I2S_RX_RINGBUFSIZE); + rv_writel(DMA_SIZE, + rtd->acp3x_base + mmACP_I2S_RX_DMA_SIZE); + + /* Config audio fifo */ + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + SP_CAPT_FIFO_ADDR_OFFSET; + rv_writel(acp_fifo_addr, + rtd->acp3x_base + mmACP_I2S_RX_FIFOADDR); + rv_writel(FIFO_SIZE, + rtd->acp3x_base + mmACP_I2S_RX_FIFOSIZE); + /* Enable watermark/period interrupt to host */ + rv_writel(BIT(I2S_RX_THRESHOLD), + rtd->acp3x_base + mmACP_EXTERNAL_INTR_CNTL); + } } - /* Enable watermark/period interrupt to host */ - rv_writel(BIT(BT_TX_THRESHOLD) | BIT(BT_RX_THRESHOLD), - rtd->acp3x_base + mmACP_EXTERNAL_INTR_CNTL); } static int acp3x_dma_open(struct snd_pcm_substream *substream) @@ -285,48 +357,45 @@ static int acp3x_dma_open(struct snd_pcm_substream *substream) return ret; } - if (!adata->play_stream && !adata->capture_stream) + if (!adata->play_stream && !adata->capture_stream && + adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { adata->play_stream = substream; - else + adata->i2ssp_play_stream = substream; + } else { adata->capture_stream = substream; + adata->i2ssp_capture_stream = substream; + } i2s_data->acp3x_base = adata->acp3x_base; runtime->private_data = i2s_data; return 0; } -static u64 acp_get_byte_count(struct i2s_stream_instance *rtd, int direction) -{ - u64 byte_count; - - if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); - } else { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); - } - return byte_count; -} - static int acp3x_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { int status; - u64 size; - struct snd_pcm_runtime *runtime = substream->runtime; - struct i2s_stream_instance *rtd = runtime->private_data; + uint64_t size; + struct snd_soc_pcm_runtime *prtd = substream->private_data; + struct snd_soc_card *card = prtd->card; + struct acp3x_platform_info *pinfo = snd_soc_card_get_drvdata(card); + struct i2s_stream_instance *rtd = substream->runtime->private_data; if (!rtd) return -EINVAL; + + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + } else + pr_err("pinfo failed\n"); + size = params_buffer_bytes(params); status = snd_pcm_lib_malloc_pages(substream, size); if (status < 0) @@ -349,8 +418,17 @@ static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_pcm_substream *substream) u32 pos = 0; u32 buffersize = 0; u64 bytescount = 0; - struct i2s_stream_instance *rtd = - substream->runtime->private_data; + struct snd_soc_pcm_runtime *prtd = substream->private_data; + struct snd_soc_card *card = prtd->card; + struct acp3x_platform_info *pinfo = snd_soc_card_get_drvdata(card); + struct i2s_stream_instance *rtd = substream->runtime->private_data; + + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + } buffersize = frames_to_bytes(substream->runtime, substream->runtime->buffer_size); @@ -390,15 +468,19 @@ static int acp3x_dma_close(struct snd_pcm_substream *substream) DRV_NAME); struct i2s_dev_data *adata = dev_get_drvdata(component->dev); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { adata->play_stream = NULL; - else + adata->i2ssp_play_stream = NULL; + } else { adata->capture_stream = NULL; + adata->i2ssp_capture_stream = NULL; + } /* Disable ACP irq, when the current stream is being closed and * another stream is also not active. */ - if (!adata->play_stream && !adata->capture_stream) + if (!adata->play_stream && !adata->capture_stream && + !adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); kfree(rtd); return 0; @@ -454,6 +536,8 @@ static int acp3x_audio_probe(struct platform_device *pdev) adata->i2s_irq = res->start; adata->play_stream = NULL; adata->capture_stream = NULL; + adata->i2ssp_play_stream = NULL; + adata->i2ssp_capture_stream = NULL; dev_set_drvdata(&pdev->dev, adata); /* Initialize ACP */ diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index baa76cd..d97d7d5 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -7,6 +7,9 @@ #include "chip_offset_byte.h" +#define I2S_SP_INSTANCE 0x01 +#define I2S_BT_INSTANCE 0x02 + #define ACP3x_DEVS 3 #define ACP3x_PHY_BASE_ADDRESS 0x1240000 #define ACP3x_I2S_MODE 0 @@ -29,19 +32,28 @@ #define ACP3x_SOFT_RESET__SoftResetAudDone_MASK 0x00010001 #define ACP_SRAM_PTE_OFFSET 0x02050000 +#define ACP_SRAM_SP_PB_PTE_OFFSET 0x0 +#define ACP_SRAM_SP_CP_PTE_OFFSET 0x100 +#define ACP_SRAM_BT_PB_PTE_OFFSET 0x200 +#define ACP_SRAM_BT_CP_PTE_OFFSET 0x300 #define PAGE_SIZE_4K_ENABLE 0x2 -#define MEM_WINDOW_START 0x4000000 -#define PLAYBACK_FIFO_ADDR_OFFSET 0x400 -#define CAPTURE_FIFO_ADDR_OFFSET 0x500 +#define I2S_SP_TX_MEM_WINDOW_START 0x4000000 +#define I2S_SP_RX_MEM_WINDOW_START 0x4020000 +#define I2S_BT_TX_MEM_WINDOW_START 0x4040000 +#define I2S_BT_RX_MEM_WINDOW_START 0x4060000 +#define SP_PB_FIFO_ADDR_OFFSET 0x500 +#define SP_CAPT_FIFO_ADDR_OFFSET 0x700 +#define BT_PB_FIFO_ADDR_OFFSET 0x900 +#define BT_CAPT_FIFO_ADDR_OFFSET 0xB00 #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 8 -#define PLAYBACK_MAX_PERIOD_SIZE 16384 -#define PLAYBACK_MIN_PERIOD_SIZE 4096 +#define PLAYBACK_MAX_PERIOD_SIZE 8192 +#define PLAYBACK_MIN_PERIOD_SIZE 1024 #define CAPTURE_MIN_NUM_PERIODS 2 #define CAPTURE_MAX_NUM_PERIODS 8 -#define CAPTURE_MAX_PERIOD_SIZE 16384 -#define CAPTURE_MIN_PERIOD_SIZE 4096 +#define CAPTURE_MAX_PERIOD_SIZE 8192 +#define CAPTURE_MIN_PERIOD_SIZE 1024 #define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS) #define MIN_BUFFER MAX_BUFFER @@ -67,14 +79,20 @@ struct i2s_dev_data { void __iomem *acp3x_base; struct snd_pcm_substream *play_stream; struct snd_pcm_substream *capture_stream; + struct snd_pcm_substream *i2ssp_play_stream; + struct snd_pcm_substream *i2ssp_capture_stream; }; struct i2s_stream_instance { u16 num_pages; + u16 i2s_instance; + u16 capture_channel; + u16 direction; u16 channels; u32 xfer_resolution; - u64 bytescount; + u32 val; dma_addr_t dma_addr; + u64 bytescount; void __iomem *acp3x_base; }; @@ -87,3 +105,44 @@ static inline void rv_writel(u32 val, void __iomem *base_addr) { writel(val, base_addr - ACP3x_PHY_BASE_ADDRESS); } + +static inline u64 acp_get_byte_count(struct i2s_stream_instance *rtd, + int direction) +{ + u64 byte_count; + + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); + break; + case I2S_SP_INSTANCE: + default: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_I2S_TX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_I2S_TX_LINEARPOSITIONCNTR_LOW); + } + + } else { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); + break; + case I2S_SP_INSTANCE: + default: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_I2S_RX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_I2S_RX_LINEARPOSITIONCNTR_LOW); + } + } + return byte_count; +} + From patchwork Tue Oct 1 00:58:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "RAVULAPATI, VISHNU VARDHAN RAO" X-Patchwork-Id: 11166769 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA40A16B1 for ; Mon, 30 Sep 2019 14:09:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BAAF218DE for ; Mon, 30 Sep 2019 14:09:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="am0rdPCh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="VcqA0erf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BAAF218DE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 973141672; Mon, 30 Sep 2019 16:08:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 973141672 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1569852582; bh=qFxx5snwaEvQyvg85fVGFrwS2bxu69VCEnFzEQPvMJw=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=am0rdPCh59md+XserLnixp9KqzkI+4mhE1fzkbxd1RcS/0ZqlM6dVWhUjyZeoC9hf 95NLsy73PX1p5jnOHhzb31ZRXBnHaRiqKmzAcdgPLdjB/cy3gWvaNTTrUxLcBE9AvG zlLVLF5iw4xdiHojStIqfWkkKj/EW3AWxbMf/9Us= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 65ED2F80635; Mon, 30 Sep 2019 16:06:44 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id C76CEF80636; Mon, 30 Sep 2019 16:06:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,SPF_NONE autolearn=disabled version=3.4.0 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680084.outbound.protection.outlook.com [40.107.68.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E0AFCF8060F for ; Mon, 30 Sep 2019 16:06:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E0AFCF8060F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="VcqA0erf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GWCrzq5v3hOTd5DPcAJVEFC7XkE5Pia33Isk3h0ERmblu0y2uzXKbwpD74ezEutn3jCShwpiMDBpwhbylw8bOMN0QAJmSCK5Pqs/uk8nEo36Co6r5g27fUj+7ZV6oJqArNHRINME5tApKo1fQsT9OoWfd3xPdpgR3beo9+f3v9y4p+eAe7I+CG4rxF24cx/BxR7J7opLmv/brjP9sSEQvqS8e5NjZ4tYX9QUslD1LshOq5nT0prq25PUNyuQU+4DzE/CeBEWK9rYkOPZ/0cS8h6YXo9kokl4rp/4Qiw/oQ+xbMLSQLo2w/foigDJB4qRiqeb4KsFmIKNphcxE6Q0iA== 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=9HwaZNHJWTn6R628ftR9IqNktaa/JznS0bTzhRXsP08=; b=Fdk87rQfiIlthJV99X2jvHkdu7EgvA3ZyEMnb+S1/eOysi1FMV9jGqFR5j/MhDGOsi2NmTBrns2lxySGXefA8cnm/zuNMjFwO/2iHzRAJuFeB3uTQqz1g1T1d2Ozwjt1hRcjq5mJ+RISbDfNAb+5am5QIAiNEtWR5gFSv32T7q9TQGWP+bb/H3G/TCtSPXQnrpb23SR09NopHS34IEyIiuZcvRbHqteLMAzi+XAKL1muSg8mYSVIU1w9Pt4IyDzneUWbVUYDTt+536k7h89Fo2ibVAtfm5BW47w8Uy9hcyvKUhUDw+qveNwqws1WBU+Gzh1FQte/WU8tbVgmrZRZQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9HwaZNHJWTn6R628ftR9IqNktaa/JznS0bTzhRXsP08=; b=VcqA0erfY/E35fGjI8XrWRf78oCs8E4JoktVlLAKnfQLQispOHT4zWZT/DCdqFD7RDvwjdv1nXthHF/ty0kbill8FQrtJCCr0KDr7SOJyANPPnpr6qkI2VfXVBPeTXGnWbWPk851e1/6etr/ziQIwiLQxkLciiVedU2tRqysi0Y= Received: from MWHPR1201CA0021.namprd12.prod.outlook.com (2603:10b6:301:4a::31) by MWHPR1201MB2477.namprd12.prod.outlook.com (2603:10b6:300:e6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.20; Mon, 30 Sep 2019 14:06:33 +0000 Received: from CO1NAM03FT057.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by MWHPR1201CA0021.outlook.office365.com (2603:10b6:301:4a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.16 via Frontend Transport; Mon, 30 Sep 2019 14:06:33 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT057.mail.protection.outlook.com (10.152.81.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 14:06:33 +0000 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 30 Sep 2019 09:06:31 -0500 From: Ravulapati Vishnu vardhan rao To: Date: Tue, 1 Oct 2019 06:28:13 +0530 Message-ID: <1569891524-18875-5-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> References: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(376002)(39860400002)(346002)(428003)(199004)(189003)(305945005)(53416004)(26005)(81166006)(50466002)(426003)(336012)(8676002)(50226002)(48376002)(2906002)(1671002)(81156014)(4326008)(186003)(76176011)(5660300002)(47776003)(356004)(316002)(126002)(51416003)(6666004)(16586007)(109986005)(478600001)(2616005)(446003)(11346002)(8936002)(70586007)(70206006)(486006)(54906003)(86362001)(7696005)(36756003)(476003)(266003)(32563001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB2477; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c9bb06db-bd7d-478b-5a83-08d745af6640 X-MS-TrafficTypeDiagnostic: MWHPR1201MB2477: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 01762B0D64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 35Evd6gJvV6SACGY6pY/6OVTlb8vG3jMUMzQGF/cR6wDsmEdqHS3paejT4u7wFlN3C2myV0w3EcHGlP8EP4q9bQb/PGLsw7yR1AiYiK+mKyL1jZTdRBo2AuUW5eVEPFFRg6VWhAOvsaKPWpV9yHM7MOfLqAQ9cdFCVDFudlIcZ3K7y5VVuokc/PnEtEcnD/w7YHltS5vAHHBxZXThbvpH1J6JPbXBYjgVn9ucl6/jX210lICwt7jKbiZzft0mN/BK9sVmWBmRabHLNfkj7JJR1ZZ8kCg6x7UyQpMXc+bXMpCAQZd9qCugN6z486G5oX8Ij9va/bG7MJcyYiZuf1nPY5akbmDIdVb4K08VvQq8SpWt7r3TvxyFbbp+kMQoE3I2hI1XlfXhVk4zzUhOZdNUumDKUQm5Z+R5phwXM/OLa8= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 14:06:33.1399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9bb06db-bd7d-478b-5a83-08d745af6640 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB2477 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , Takashi Iwai , Liam Girdwood , Ravulapati Vishnu vardhan rao , Mark Brown , Alexander.Deucher@amd.com Subject: [alsa-devel] [PATCH 5/7] ASoC: amd: add ACP3x TDM mode support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ACP3x I2S (CPU DAI) can act in normal I2S and TDM modes. Added support for TDM mode. Desired mode can be selected from ASoC machine driver. Signed-off-by: Ravulapati Vishnu vardhan rao --- sound/soc/amd/raven/acp3x-i2s.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c index 4511b9b..312207b 100644 --- a/sound/soc/amd/raven/acp3x-i2s.c +++ b/sound/soc/amd/raven/acp3x-i2s.c @@ -43,7 +43,8 @@ static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, u32 rx_mask, int slots, int slot_width) { u32 val = 0; - u16 slot_len; + u32 mode = 0; + u16 slot_len, flen; struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); @@ -64,16 +65,31 @@ static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, return -EINVAL; } - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER); - rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_ITER); - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER); - rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_IRER); - - val = (FRM_LEN | (slots << 15) | (slot_len << 18)); - rv_writel(val, adata->acp3x_base + mmACP_BTTDM_TXFRMT); - rv_writel(val, adata->acp3x_base + mmACP_BTTDM_RXFRMT); + /* Enable I2S / BT channels TDM and respective + * I2S/BT`s TX/RX Formats frame lengths. + */ + flen = (FRM_LEN | (slots << 15) | (slot_len << 18)); + + mode = rv_readl(adata->acp3x_base + mmACP_BTTDM_IER); + if (mode) { + val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER); + rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_ITER); + rv_writel(flen, adata->acp3x_base + mmACP_BTTDM_TXFRMT); + val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER); + rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_IRER); + rv_writel(flen, adata->acp3x_base + mmACP_BTTDM_RXFRMT); + } - adata->tdm_fmt = val; + mode = rv_readl(adata->acp3x_base + mmACP_I2STDM_IER); + if (mode) { + val = rv_readl(adata->acp3x_base + mmACP_I2STDM_ITER); + rv_writel((val | 0x2), adata->acp3x_base + mmACP_I2STDM_ITER); + rv_writel(flen, adata->acp3x_base + mmACP_I2STDM_TXFRMT); + val = rv_readl(adata->acp3x_base + mmACP_I2STDM_IRER); + rv_writel((val | 0x2), adata->acp3x_base + mmACP_I2STDM_IRER); + rv_writel(flen, adata->acp3x_base + mmACP_I2STDM_RXFRMT); + } + adata->tdm_fmt = flen; return 0; } From patchwork Tue Oct 1 00:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "RAVULAPATI, VISHNU VARDHAN RAO" X-Patchwork-Id: 11166771 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA9A516B1 for ; Mon, 30 Sep 2019 14:10:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C0E1218AC for ; Mon, 30 Sep 2019 14:10:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="X7cLlOvC"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="SCsjOXPW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C0E1218AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 79D8E1660; Mon, 30 Sep 2019 16:09:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 79D8E1660 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1569852637; bh=f/DjAdWUXM57mabfd6K0u9o0SwhyjqqlH5OLgf/sAfg=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=X7cLlOvCAqNmLPDLC5zKkzjWct3067k3JKK0iWNaaB2JHKHazC76laFie6i81pPPR PdICgbj5jnznyoKuDC8i687n5Br4jQQ9hdhFmQR/cOtJQLZEFGHLPZHoHsAArvL5y4 K/Fg67JxWprKodjaSda5g9Gztlwg+jLNL60l2cyA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D0B82F8063E; Mon, 30 Sep 2019 16:06:52 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6D359F80642; Mon, 30 Sep 2019 16:06:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,SPF_HELO_PASS,SPF_NONE autolearn=disabled version=3.4.0 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-eopbgr750058.outbound.protection.outlook.com [40.107.75.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 36262F800DE for ; Mon, 30 Sep 2019 16:06:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 36262F800DE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="SCsjOXPW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rkbhhxlnjv0HcXHgU5mGSuDr7QnDk+X7zwy/i0pbCp3HFArxge8DZixPAim0fziWt0BKb7gnlBDqulOyxJ38Tqb3tJpm42kxiqSVpRK1dAgfLng/pl+bmh3x3Ngrz7+cble/v2K41ANh1nsJqe6M1P0eYFIjaMxlKlxh3YApiMMn590C3DsGeCvLZAjkw0Q79RwoQYWpDD7Gr71+1esUs3jlChILoYtVBVHnbRuopFmqZi/X5kSqlcD8+s4BA9SrliVsrtZ2ki2aFcdO7RhaOq72JNMWGYrSpGOsQlAiVXXerOt5FJUDEDo4VeekcGdC4qfuSxeUk4CzuuRg1wu5yw== 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=z72Gb8xh+zH2VaK2bqc1+WBNdSjmEIiqOhkNjFaB6Zk=; b=gUAqrS/xZz26hA/T4/NrFe4zLwtCJAo3p1JTks6gN3I970Bf5e+dqaRjkiGuUl9AWjNxszys+sQI34keBQY5VsUxQGiPKPVZvZU3lPZsihklF6a5On9RZDvNj+IL/Gz82WGTPbYyBznC6cBovBjRTMGiZ+P6YESlnbdciVPCst1kLXhu0tkl1/vF48gqsd+zsRqO9Fnige1EwjIlI/d0BbpSfPTepTDgMRGvXSF+0quLuYKdZWAr/BPsn6eOvXKAHfDhC7mKPwfTE/i1VQXT42K3WHYzA8U/m9up6PA89+uvXdAOfg0/ddIuM+REWLA40oKEJ7K9G6M70WSYMa3kQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=huawei.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z72Gb8xh+zH2VaK2bqc1+WBNdSjmEIiqOhkNjFaB6Zk=; b=SCsjOXPW2L9nNQhouBEf430p2w2WW8NgjkK9EFG8GWKhIhCHyLnHHKvGnuR5yyjMZIx/4qahVJQe+hcZ337pYN+IXKasYbyf9zjSDcAieBPahSdQLEVpyxkVrrMplgh4uycdnAusr6YKeWy+/eDYBCYLpEb3poMH4jJafTD9ehE= Received: from SN1PR12CA0106.namprd12.prod.outlook.com (2603:10b6:802:21::41) by DM6PR12MB3996.namprd12.prod.outlook.com (2603:10b6:5:1cd::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Mon, 30 Sep 2019 14:06:44 +0000 Received: from CO1NAM03FT046.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::204) by SN1PR12CA0106.outlook.office365.com (2603:10b6:802:21::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18 via Frontend Transport; Mon, 30 Sep 2019 14:06:44 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT046.mail.protection.outlook.com (10.152.81.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 14:06:44 +0000 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 30 Sep 2019 09:06:38 -0500 From: Ravulapati Vishnu vardhan rao To: Date: Tue, 1 Oct 2019 06:28:14 +0530 Message-ID: <1569891524-18875-6-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> References: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(136003)(346002)(376002)(428003)(189003)(199004)(53416004)(336012)(426003)(4326008)(54906003)(50466002)(11346002)(446003)(70206006)(16586007)(36756003)(70586007)(2616005)(476003)(126002)(486006)(109986005)(478600001)(5660300002)(6666004)(8676002)(81156014)(81166006)(356004)(47776003)(51416003)(2906002)(305945005)(186003)(86362001)(1671002)(26005)(8936002)(50226002)(76176011)(7696005)(48376002)(316002)(266003)(32563001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3996; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58d9eeb4-755c-41ab-0cbc-08d745af6cc9 X-MS-TrafficTypeDiagnostic: DM6PR12MB3996:|DM6PR12MB3996: X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-MS-Oob-TLC-OOBClassifiers: OLM:431; X-Forefront-PRVS: 01762B0D64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: paQ45teMZu+AGLgfwsy2fikhBQz37tbRo0LzPQV5u3gIuSVOsoZP+zySWZP7glP/BuKUkyWuO7Cs3Hb14H94MMm5/5yXtQ04O6YTB4NTuOsAz4Yvmwx3tYCUaRqTeIfocy+6tzcKztQCTguh2odAjhUVOAcd4NzI8dikeDtgM3uIW9LiDoXOSVPC+gD4mkFC1grYCZ2DLlYzvgQrwI8f365rjtbpXHUoWSX6UWc0o0Ek4OFJJgxDEoxA29xavn8QezF4rhPzrURmDtE9P1iavnxcRqePdlc2Rk37EJdp/LTPWw8WDyvAyhwzYkapjAi27PUcJJI04ocAWQF9OM8sERqg39Nb7u6m/mgyZGz+glpdjbRXpCN71kYuZ2WHwidNqH3l87BpT3aNWkRkQWD8V8TJtA3lKjsZnT+5W7P+6sk= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 14:06:44.1001 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58d9eeb4-755c-41ab-0cbc-08d745af6cc9 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3996 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Maruthi Bayyavarapu , open list , YueHaibing , Takashi Iwai , Liam Girdwood , Ravulapati Vishnu vardhan rao , Mark Brown , Vijendar Mukunda , Alexander.Deucher@amd.com Subject: [alsa-devel] [PATCH 6/7] ASoC: AMD: handle ACP3x i2s-sp watermark interrupt X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Whenever audio data equal to I2S-SP fifo watermark level is produced/consumed, interrupt is generated. Signed-off-by: Ravulapati Vishnu vardhan rao --- sound/soc/amd/raven/acp3x-pcm-dma.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 6fa892a..49f640f 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -176,6 +176,13 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id) snd_pcm_period_elapsed(rv_i2s_data->play_stream); play_flag = 1; } + if ((val & BIT(I2S_TX_THRESHOLD)) && + rv_i2s_data->i2ssp_play_stream) { + rv_writel(BIT(I2S_TX_THRESHOLD), + rv_i2s_data->acp3x_base + mmACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(rv_i2s_data->i2ssp_play_stream); + play_flag = 1; + } if ((val & BIT(BT_RX_THRESHOLD)) && rv_i2s_data->capture_stream) { rv_writel(BIT(BT_RX_THRESHOLD), rv_i2s_data->acp3x_base + @@ -183,6 +190,13 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id) snd_pcm_period_elapsed(rv_i2s_data->capture_stream); cap_flag = 1; } + if ((val & BIT(I2S_RX_THRESHOLD)) && + rv_i2s_data->i2ssp_capture_stream) { + rv_writel(BIT(I2S_RX_THRESHOLD), + rv_i2s_data->acp3x_base + mmACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(rv_i2s_data->i2ssp_capture_stream); + cap_flag = 1; + } if (play_flag | cap_flag) return IRQ_HANDLED; From patchwork Tue Oct 1 00:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "RAVULAPATI, VISHNU VARDHAN RAO" X-Patchwork-Id: 11166773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3613814DB for ; Mon, 30 Sep 2019 14:11:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC797216F4 for ; Mon, 30 Sep 2019 14:11:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="s37Hq4eV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="SbYmxjoZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC797216F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0FB63168A; Mon, 30 Sep 2019 16:10:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0FB63168A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1569852671; bh=SBAJHsTr+NhOV2s72Pm4gvMD+PZ7pO+RA1zum7W+DK0=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=s37Hq4eV5gGjr3U9J4gN1x+f10/SrTDo+h1I9VJrWWaZ39wzIee5y56GTBMz7w+uj eQhgwoRakTMI8I+Aav6CN2EdvjjBLSRfJtsaMEDxTA0+l6kU5/7RGPypriGorGST/L Xk2pS+Cn5lbyeMhP4CR+8bYUIfSnLpo074tVP7o8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B0D9FF80659; Mon, 30 Sep 2019 16:07:07 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 34B80F803F3; Mon, 30 Sep 2019 16:07:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE autolearn=disabled version=3.4.0 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770077.outbound.protection.outlook.com [40.107.77.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 464D0F803F3 for ; Mon, 30 Sep 2019 16:07:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 464D0F803F3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="SbYmxjoZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RR5Aa93aEK8UCKII/IWC3TCdzepdgF3fhR8+ZZpnLQyWn1ijME3RpOQDi2Q8k4q7mg/loOYC3UAyh7Xvvrc/UOjuzubQJI/bSJ5qKNhOOfN9ULI/CZL201kszMf9MJQzh0WdhwLy4fNeN6+mzGNbbU1yPvS5KruXlYmXSLOY1AD8SPOS14ftgqgSFFt9hrkBg4HvvuLY+V6NjVE93Tetj+UlLHjngOK3BW9J5d9OuBOdwHiyYOp0pxVmuiMUHSzU3M47CoXno6m7dZGyUVic9bBw7IvtohAA/zD3Js38oissiYW7y085PHIDa0xxfm8OsFOW2f3J32ZQfufthwB3vQ== 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=41mimW94ELZCqFOtKsh89Si6C0x+vxR5n8irJqfWfKE=; b=Q6iqkiivG7wbPcJ2fnOgd/zr06a/lshtzXivt5NWGkbutz3GgUra9I3r3YITQKQzhUSJwNQA3jn8NDJxq4O1Ych/z20ZsXzEXngLaHDHQA0MPj4IpLcHhV0qH7kikoW0p4SOd5Jlu+BY/8hDRH8o7hg48DDdbb+k9G8UnELYENNpREaFLIFc7kYEDDIiPF5vnsgrddLFcEIIRVH+ONa8WMEXnbvnVxOWbn5QJgs8GUjnWPDC+SnHp4A8jIStIqypLRGx8d/Cap94W80n5yZyshN8x6RA57h+TFFD9Alhg7ZsnheBeCGwpf4V8nOJzaRQB9+NE1OPznpLcmr6nnO+cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=oracle.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=41mimW94ELZCqFOtKsh89Si6C0x+vxR5n8irJqfWfKE=; b=SbYmxjoZzFFXJcum1mqIfJ3Bx2Iff7CIAnOX63PJRJsCadU4jwCikLsEkN+ucmEr976Wd8eeM5ARWAyj38xB0rWUNntBv9sV8oe21gFuTUyCmRF81ertgzXK4YX/RmmiN5iYPs6ZxGcM48Tu3pmzftEByD+J+uNXGzgKtztoVF8= Received: from SN1PR12CA0106.namprd12.prod.outlook.com (2603:10b6:802:21::41) by MN2PR12MB4000.namprd12.prod.outlook.com (2603:10b6:208:16b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Mon, 30 Sep 2019 14:06:56 +0000 Received: from CO1NAM03FT046.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by SN1PR12CA0106.outlook.office365.com (2603:10b6:802:21::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18 via Frontend Transport; Mon, 30 Sep 2019 14:06:55 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; oracle.com; dkim=none (message not signed) header.d=none;oracle.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT046.mail.protection.outlook.com (10.152.81.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Mon, 30 Sep 2019 14:06:55 +0000 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 30 Sep 2019 09:06:53 -0500 From: Ravulapati Vishnu vardhan rao To: Date: Tue, 1 Oct 2019 06:28:15 +0530 Message-ID: <1569891524-18875-7-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> References: <1569891524-18875-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(396003)(39860400002)(346002)(136003)(428003)(199004)(189003)(14444005)(16586007)(1671002)(36756003)(316002)(11346002)(446003)(126002)(476003)(486006)(356004)(6666004)(48376002)(305945005)(426003)(70206006)(336012)(70586007)(47776003)(50226002)(30864003)(2906002)(7696005)(109986005)(86362001)(53416004)(8676002)(8936002)(81166006)(81156014)(5660300002)(2616005)(51416003)(76176011)(4326008)(186003)(50466002)(54906003)(26005)(478600001)(266003)(32563001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB4000; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f0fe140-bfa3-412f-6e41-08d745af73a0 X-MS-TrafficTypeDiagnostic: MN2PR12MB4000:|MN2PR12MB4000: X-Microsoft-Antispam-PRVS: X-MS-Exchange-Transport-Forked: True X-MS-Oob-TLC-OOBClassifiers: OLM:42; X-Forefront-PRVS: 01762B0D64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KZdgIUfjz7zs1v7M28DcWIGTmx31DOZutwa9TGi4oxOLNTQOTRzIuu5lAdfBV/X1dH4p47b5UIbABMkIvi7iDiLzB7+d5TDE22H8lQvPvdN86UMPhHvMRqDmjP3Cwc4Perl3ZlPT4JEavvlCkul6uKLR0U46dxBIyNTpFbUNSEnGoso5Bd2rwJm+xFHfJxeel10s61iYJjrTGuiCNKzeYR+Th0DJ1NWFvQozyE/P0+rCclfn6gSYajiK37YTfyL4rB8WMTN1tLcHf1BxC82sgu5nCnhOQhMCDFrP/ebR8lFCMIWeWgGSowI4mZBMKis2QjTYwH6MzI/OnmnUpNCNKhoNGIIom2q6nD+sf0EKx/QDwraDsnvA1XeAK/rhglWlX96FMx0A811ZAB1YG+i9fz9V1fqMoPfonBq7Kd6YG6Q= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2019 14:06:55.5779 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f0fe140-bfa3-412f-6e41-08d745af73a0 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4000 Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Maruthi Bayyavarapu , open list , YueHaibing , Takashi Iwai , Liam Girdwood , Ravulapati Vishnu vardhan rao , Mark Brown , Vijendar Mukunda , Alex Deucher , Colin Ian King , Dan Carpenter Subject: [alsa-devel] [PATCH 7/7] ASoc: amd: Added ACP3x system resume and runtime pm ops X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" When audio usecase in progress and system wide suspend happens, ACP will be powered off and when system resumes, for audio usecase to continue, all the runtime configuration data needs to be programmed again. Added 'resume'pm call back to ACP pm ops and also Added runtime PM operations for ACP3x PCM platform device. Device will be powered on/off based on device is in use or not. Signed-off-by: Ravulapati Vishnu vardhan rao --- sound/soc/amd/raven/acp3x-pcm-dma.c | 160 +++------------------------- sound/soc/amd/raven/acp3x.h | 7 ++ sound/soc/amd/raven/pci-acp3x.c | 204 +++++++++++++++++++++++++++++++++++- 3 files changed, 223 insertions(+), 148 deletions(-) diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 49f640f..4011c78 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -58,106 +58,6 @@ static const struct snd_pcm_hardware acp3x_pcm_hardware_capture = { .periods_max = CAPTURE_MAX_NUM_PERIODS, }; -static int acp3x_power_on(void __iomem *acp3x_base, bool on) -{ - u16 val, mask; - u32 timeout; - - if (on == true) { - val = 1; - mask = ACP3x_POWER_ON; - } else { - val = 0; - mask = ACP3x_POWER_OFF; - } - - rv_writel(val, acp3x_base + mmACP_PGFSM_CONTROL); - timeout = 0; - while (true) { - val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); - if ((val & ACP3x_POWER_OFF_IN_PROGRESS) == mask) - break; - if (timeout > 100) { - pr_err("ACP3x power state change failure\n"); - return -ENODEV; - } - timeout++; - cpu_relax(); - } - return 0; -} - -static int acp3x_reset(void __iomem *acp3x_base) -{ - u32 val, timeout; - - rv_writel(1, acp3x_base + mmACP_SOFT_RESET); - timeout = 0; - while (true) { - val = rv_readl(acp3x_base + mmACP_SOFT_RESET); - if ((val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) || - timeout > 100) { - if (val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) - break; - return -ENODEV; - } - timeout++; - cpu_relax(); - } - - rv_writel(0, acp3x_base + mmACP_SOFT_RESET); - timeout = 0; - while (true) { - val = rv_readl(acp3x_base + mmACP_SOFT_RESET); - if (!val || timeout > 100) { - if (!val) - break; - return -ENODEV; - } - timeout++; - cpu_relax(); - } - return 0; -} - -static int acp3x_init(void __iomem *acp3x_base) -{ - int ret; - - /* power on */ - ret = acp3x_power_on(acp3x_base, true); - if (ret) { - pr_err("ACP3x power on failed\n"); - return ret; - } - /* Reset */ - ret = acp3x_reset(acp3x_base); - if (ret) { - pr_err("ACP3x reset failed\n"); - return ret; - } - return 0; -} - -static int acp3x_deinit(void __iomem *acp3x_base) -{ - int ret; - - /* Reset */ - ret = acp3x_reset(acp3x_base); - if (ret) { - pr_err("ACP3x reset failed\n"); - return ret; - } - /* power off */ - ret = acp3x_power_on(acp3x_base, false); - if (ret) { - pr_err("ACP3x power off failed\n"); - return ret; - } - return 0; -} - static irqreturn_t i2s_irq_handler(int irq, void *dev_id) { u16 play_flag, cap_flag; @@ -554,75 +454,52 @@ static int acp3x_audio_probe(struct platform_device *pdev) adata->i2ssp_capture_stream = NULL; dev_set_drvdata(&pdev->dev, adata); - /* Initialize ACP */ - status = acp3x_init(adata->acp3x_base); - if (status) - return -ENODEV; status = devm_snd_soc_register_component(&pdev->dev, &acp3x_i2s_component, NULL, 0); if (status) { dev_err(&pdev->dev, "Fail to register acp i2s component\n"); - goto dev_err; + return -ENODEV; } status = devm_request_irq(&pdev->dev, adata->i2s_irq, i2s_irq_handler, irqflags, "ACP3x_I2S_IRQ", adata); if (status) { dev_err(&pdev->dev, "ACP3x I2S IRQ request failed\n"); - goto dev_err; + return -ENODEV; } pm_runtime_set_autosuspend_delay(&pdev->dev, 10000); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; -dev_err: - status = acp3x_deinit(adata->acp3x_base); - if (status) - dev_err(&pdev->dev, "ACP de-init failed\n"); - else - dev_info(&pdev->dev, "ACP de-initialized\n"); - /*ignore device status and return driver probe error*/ - return -ENODEV; } static int acp3x_audio_remove(struct platform_device *pdev) { - int ret; - struct i2s_dev_data *adata = dev_get_drvdata(&pdev->dev); - - ret = acp3x_deinit(adata->acp3x_base); - if (ret) - dev_err(&pdev->dev, "ACP de-init failed\n"); - else - dev_info(&pdev->dev, "ACP de-initialized\n"); - pm_runtime_disable(&pdev->dev); return 0; } static int acp3x_resume(struct device *dev) { - int status; u32 val; struct i2s_dev_data *adata = dev_get_drvdata(dev); - status = acp3x_init(adata->acp3x_base); - if (status) - return -ENODEV; - if (adata->play_stream && adata->play_stream->runtime) { struct i2s_stream_instance *rtd = adata->play_stream->runtime->private_data; config_acp3x_dma(rtd, SNDRV_PCM_STREAM_PLAYBACK); rv_writel((rtd->xfer_resolution << 3), - rtd->acp3x_base + mmACP_BTTDM_ITER); + rtd->acp3x_base + mmACP_BTTDM_ITER); + val = rv_readl(rtd->acp3x_base + mmACP_I2STDM_ITER); + val = val | (rtd->xfer_resolution << 3); + rv_writel(val, rtd->acp3x_base + mmACP_I2STDM_ITER); if (adata->tdm_mode == true) { rv_writel(adata->tdm_fmt, adata->acp3x_base + - mmACP_BTTDM_TXFRMT); + mmACP_BTTDM_TXFRMT); val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER); rv_writel((val | 0x2), adata->acp3x_base + - mmACP_BTTDM_ITER); + mmACP_BTTDM_ITER); } } @@ -631,13 +508,17 @@ static int acp3x_resume(struct device *dev) adata->capture_stream->runtime->private_data; config_acp3x_dma(rtd, SNDRV_PCM_STREAM_CAPTURE); rv_writel((rtd->xfer_resolution << 3), - rtd->acp3x_base + mmACP_BTTDM_IRER); + rtd->acp3x_base + mmACP_BTTDM_IRER); + val = rv_readl(rtd->acp3x_base + mmACP_I2STDM_ITER); + val = val | (rtd->xfer_resolution << 3); + rv_writel(val, rtd->acp3x_base + mmACP_I2STDM_ITER); + if (adata->tdm_mode == true) { rv_writel(adata->tdm_fmt, adata->acp3x_base + - mmACP_BTTDM_RXFRMT); + mmACP_BTTDM_RXFRMT); val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER); rv_writel((val | 0x2), adata->acp3x_base + - mmACP_BTTDM_IRER); + mmACP_BTTDM_IRER); } } @@ -648,15 +529,8 @@ static int acp3x_resume(struct device *dev) static int acp3x_pcm_runtime_suspend(struct device *dev) { - int status; struct i2s_dev_data *adata = dev_get_drvdata(dev); - status = acp3x_deinit(adata->acp3x_base); - if (status) - dev_err(dev, "ACP de-init failed\n"); - else - dev_info(dev, "ACP de-initialized\n"); - rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); return 0; @@ -664,12 +538,8 @@ static int acp3x_pcm_runtime_suspend(struct device *dev) static int acp3x_pcm_runtime_resume(struct device *dev) { - int status; struct i2s_dev_data *adata = dev_get_drvdata(dev); - status = acp3x_init(adata->acp3x_base); - if (status) - return -ENODEV; rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); return 0; } diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index d97d7d5..21c3109 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -65,6 +65,13 @@ #define SLOT_WIDTH_16 0x10 #define SLOT_WIDTH_24 0x18 #define SLOT_WIDTH_32 0x20 +#define ACP_PGFSM_CNTL_POWER_ON_MASK 0x01 +#define ACP_PGFSM_CNTL_POWER_OFF_MASK 0x00 +#define ACP_PGFSM_STATUS_MASK 0x03 +#define ACP_POWERED_ON 0x00 +#define ACP_POWER_ON_IN_PROGRESS 0x01 +#define ACP_POWERED_OFF 0x02 +#define ACP_POWER_OFF_IN_PROGRESS 0x03 struct acp3x_platform_info { u16 play_i2s_instance; diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c index d9f5bc0..8386c4a 100644 --- a/sound/soc/amd/raven/pci-acp3x.c +++ b/sound/soc/amd/raven/pci-acp3x.c @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include "acp3x.h" @@ -27,12 +30,141 @@ struct acp3x_dev_data { struct platform_device *pdev; }; +static int acp3x_power_on(void __iomem *acp3x_base) +{ + u32 val; + u32 timeout = 0; + int ret = 0; + + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); + if (val) { + if (!((val & ACP_PGFSM_STATUS_MASK) == + ACP_POWER_ON_IN_PROGRESS)) + rv_writel(ACP_PGFSM_CNTL_POWER_ON_MASK, + acp3x_base + mmACP_PGFSM_CONTROL); + while (true) { + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); + if (!val) + break; + udelay(1); + if (timeout > 500) { + pr_err("ACP is Not Powered ON\n"); + ret = -ETIMEDOUT; + break; + } + timeout++; + } + if (ret) { + pr_err("ACP is not powered on status:%d\n", ret); + return ret; + } + } + return ret; +} + +static int acp3x_power_off(void __iomem *acp3x_base) +{ + u32 val; + u32 timeout = 0; + int ret = 0; + + val = rv_readl(acp3x_base + mmACP_PGFSM_CONTROL); + rv_writel(ACP_PGFSM_CNTL_POWER_OFF_MASK, + acp3x_base + mmACP_PGFSM_CONTROL); + while (true) { + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); + if ((val & ACP_PGFSM_STATUS_MASK) == ACP_POWERED_OFF) + break; + udelay(1); + if (timeout > 500) { + pr_err("ACP is Not Powered OFF\n"); + ret = -ETIMEDOUT; + break; + } + timeout++; + } + if (ret) + pr_err("ACP is not powered off status:%d\n", ret); + return ret; +} + + +static int acp3x_reset(void __iomem *acp3x_base) +{ + u32 val, timeout; + + rv_writel(1, acp3x_base + mmACP_SOFT_RESET); + timeout = 0; + while (true) { + val = rv_readl(acp3x_base + mmACP_SOFT_RESET); + if ((val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) || + timeout > 100) { + if (val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) + break; + return -ENODEV; + } + timeout++; + cpu_relax(); + } + rv_writel(0, acp3x_base + mmACP_SOFT_RESET); + timeout = 0; + while (true) { + val = rv_readl(acp3x_base + mmACP_SOFT_RESET); + if (!val || timeout > 100) { + if (!val) + break; + return -ENODEV; + } + timeout++; + cpu_relax(); + } + return 0; +} + +static int acp3x_init(void __iomem *acp3x_base) +{ + int ret; + + /* power on */ + ret = acp3x_power_on(acp3x_base); + if (ret) { + pr_err("ACP3x power on failed\n"); + return ret; + } + /* Reset */ + ret = acp3x_reset(acp3x_base); + if (ret) { + pr_err("ACP3x reset failed\n"); + return ret; + } + return 0; +} + +static int acp3x_deinit(void __iomem *acp3x_base) +{ + int ret; + + /* Reset */ + ret = acp3x_reset(acp3x_base); + if (ret) { + pr_err("ACP3x reset failed\n"); + return ret; + } + /* power off */ + ret = acp3x_power_off(acp3x_base); + if (ret) { + pr_err("ACP3x power off failed\n"); + return ret; + } + return 0; +} + static int snd_acp3x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { int ret; resource_size_t addr; - int val, i, r; + int val, i, r, status; struct acp3x_dev_data *adata; struct device *dev; struct i2s_platform_data *i2s_pdata; @@ -46,7 +178,7 @@ static int snd_acp3x_probe(struct pci_dev *pci, ret = pci_request_regions(pci, "AMD ACP3x audio"); if (ret < 0) { dev_err(&pci->dev, "pci_request_regions failed\n"); - goto disable_pci; + goto release_regions; } adata = devm_kzalloc(&pci->dev, sizeof(struct acp3x_dev_data), @@ -67,6 +199,10 @@ static int snd_acp3x_probe(struct pci_dev *pci, pci_set_master(pci); pci_set_drvdata(pci, adata); adata->parent = &pci->dev; + status = acp3x_init(adata->acp3x_base); + if (status) + return -ENODEV; + val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG); switch (val) { case I2S_MODE: @@ -141,26 +277,85 @@ static int snd_acp3x_probe(struct pci_dev *pci, adata->cell, ACP3x_DEVS); break; } + pm_runtime_set_autosuspend_delay(&pci->dev, 10000); + pm_runtime_use_autosuspend(&pci->dev); + pm_runtime_set_active(&pci->dev); + pm_runtime_put_noidle(&pci->dev); + pm_runtime_enable(&pci->dev); return 0; unmap_mmio: + status = acp3x_deinit(adata->acp3x_base); + if (status) + dev_err(&pci->dev, "ACP de-init failed\n"); + else + dev_info(&pci->dev, "ACP de-initialized\n"); mfd_remove_devices(adata->parent); kfree(adata->res); kfree(adata->cell); iounmap(adata->acp3x_base); release_regions: pci_release_regions(pci); -disable_pci: pci_disable_device(pci); + status = acp3x_deinit(adata->acp3x_base); + if (status) + dev_err(&pci->dev, "ACP de-init failed\n"); + else + dev_info(&pci->dev, "ACP de-initialized\n"); return ret; } + + +static int snd_acp3x_suspend(struct device *dev) +{ + + int status; + struct acp3x_dev_data *adata = dev_get_drvdata(dev); + + status = acp3x_deinit(adata->acp3x_base); + if (status) + dev_err(dev, "ACP de-init failed\n"); + else + dev_info(dev, "ACP de-initialized\n"); + + return 0; +} +static int snd_acp3x_resume(struct device *dev) +{ + + int status; + struct acp3x_dev_data *adata = dev_get_drvdata(dev); + + status = acp3x_init(adata->acp3x_base); + if (status) + return -ENODEV; + + return 0; +} + +static const struct dev_pm_ops acp3x_pm = { + .runtime_suspend = snd_acp3x_suspend, + .runtime_resume = snd_acp3x_resume, + .resume = snd_acp3x_resume, + +}; + static void snd_acp3x_remove(struct pci_dev *pci) { + int i; struct acp3x_dev_data *adata = pci_get_drvdata(pci); mfd_remove_devices(adata->parent); + i = acp3x_deinit(adata->acp3x_base); + if (i) + dev_err(&pci->dev, "ACP de-init failed\n"); + else + dev_info(&pci->dev, "ACP de-initialized\n"); iounmap(adata->acp3x_base); + pm_runtime_disable(&pci->dev); + pm_runtime_get_noresume(&pci->dev); + pci_disable_msi(pci); pci_release_regions(pci); pci_disable_device(pci); } @@ -178,6 +373,9 @@ static struct pci_driver acp3x_driver = { .id_table = snd_acp3x_ids, .probe = snd_acp3x_probe, .remove = snd_acp3x_remove, + .driver = { + .pm = &acp3x_pm, + } }; module_pci_driver(acp3x_driver);