Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1587684pxv; Fri, 16 Jul 2021 12:44:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPuP+Uz8wODnfueL/AlCRNJoYb9wlQHtimNO5SpKYV1BCmpAB70P7JzDa3pCdF7Iu1d35n X-Received: by 2002:a02:a69a:: with SMTP id j26mr10289830jam.9.1626464646827; Fri, 16 Jul 2021 12:44:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626464646; cv=pass; d=google.com; s=arc-20160816; b=XDVW53apcETeRgT/RayaMnnC1uxoeQhlIunTT3MDvYIAoyr4MJkJzkpTkHiBbWxj77 AEdVJpDFUuBybnl5hgGPi/qULye2SwIkhEnoTXu1OP/+8SXXRZ/j8Ey9txkC3tBT6npJ 9dQ7M0j7BVY7VhwEorWvGmKgTuYj2QHB+3uEuyDyYWhpfed5DPj/E2toMhe9yE27ad24 ovjzKfzTkkyYnFr81MdbWwkJ/VqqWKGxctx4qRELUQd/pm4cYfNzsly37VWQc0EXWsE2 pR5O+df0Qq8McgUdQ4wIUzjqDdi9zYX4l0xzyNy+23MdxUi9Qyi+ZeZfLgrAWW7lhDrp eO9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+51jIDHGyeDnhRRcYsOfv22hO5bQsSxdJJ5wpCqDLWs=; b=WohV1CbSME0Kdhz2GpGh61Mb4UkeA3O6n7tOZ0kFbGHEUyZjvNAGJIyxabOozEg+yy vnUEW0r2975CYH8AC8ylejDYBUBBEefM6DbOBtx+0Uh9Gwt1pvD4YjsxryCtKvhrFqzP +BqoO6Gnvm6ZCCdfnTPWEavoLVrfOlw4igGvY5+eyywpl66iGUFxb2uEDwzDxPLrHehb UmS5xd8CQQ1uPVjaydrDNXzqEW9ybkUb6C3JEKay+1iQ0CGK4e8fWBFcC3b4WF4FF0lC e7rTt5xjR6tEg57LM0xswGQkHokJduV5W9iUSDbD//SqBFdYdkeAilP4R3TqoYPOGOuW 3bLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="CiF/D0wZ"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id az23si827627jab.13.2021.07.16.12.43.55; Fri, 16 Jul 2021 12:44:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="CiF/D0wZ"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232896AbhGPTp2 (ORCPT + 99 others); Fri, 16 Jul 2021 15:45:28 -0400 Received: from mail-mw2nam12on2048.outbound.protection.outlook.com ([40.107.244.48]:24544 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232661AbhGPTp1 (ORCPT ); Fri, 16 Jul 2021 15:45:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nh/dTxBUcmHc6sp0lfvtQQc04kwM8GUV2p4H1DR87t14tvH72vkUQw4HRPyx0HQhr5UJQv6vOzW0+5gH8Z6NPJwnSVTdGzJmTTggtshRn4S3Uj8+wO5JGF04ngXunrLwSFtDtZuQ1bVuurCPot0OhOCU3zM/PeQ1gRj/5tIS/BgdM5phh0P8nCAoYv+ZiVUU2OcWTMs6sbTEyJUiKrLse9ANc1WwDh7yAddtb3Bt/6Xk9IfIzjV9uYDeeAKP0oZ9ljeORaPQkTPs2F+ly7izXRTvP8F/3xLHJJCe0tU8EQLt9uY5xwvldT7FrrOt232hGzOv4NGypTPubhgkKs+hyw== 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=+51jIDHGyeDnhRRcYsOfv22hO5bQsSxdJJ5wpCqDLWs=; b=RwCouTC4rglxg0qwmOuiPsptCERc5g5lKJpmkuOKyufO96+WVg+hQPVFF6dHIL+nfq92rmkacGOwrupQp7ns11DNvTuuw0ALmpgF7/gUlWGZ8t6RdRmSAT2Pa866vrEXiy0T2zbXjd8mSrU+u4+5yTgYv8o5lHD8cGkLF72yg+eA5gMlEZsGPGr1SOFYbe95thb+tsWuTjsyisvvDo0dICHRqiQ4e2J69n6Ck4sxIlrn5lRlxaC37WTdd9EMPZ2NtvkIY6hOx5AYxysXKUVw5JuTVBRQatbRhIIwth3abvzCx3VYzmY8P3Xfu5mzLntTWXL/DAjUI3WbEwfEGi/CUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+51jIDHGyeDnhRRcYsOfv22hO5bQsSxdJJ5wpCqDLWs=; b=CiF/D0wZB0s5wmRBpd50VaIEEpJlkKbDwEFyghSht5LbbYTiqJXSVBkA5NY+i4ElZaQztBY37aizcaqIgbd5eyM1+7qT4gmKaS7Zf8nbLkLQkl1FpN8XYPa/yB+VZr/idr0Oa/25iwugMWpwtlM+6jqok44un+Q4I8cQFBt8Xic= Received: from MW4PR03CA0338.namprd03.prod.outlook.com (2603:10b6:303:dc::13) by CY4PR1201MB0199.namprd12.prod.outlook.com (2603:10b6:910:1c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Fri, 16 Jul 2021 19:42:30 +0000 Received: from CO1NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::6b) by MW4PR03CA0338.outlook.office365.com (2603:10b6:303:dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 19:42:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT058.mail.protection.outlook.com (10.13.174.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 19:42:30 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Fri, 16 Jul 2021 14:42:29 -0500 Received: from vijendar-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Fri, 16 Jul 2021 14:42:20 -0500 From: Vijendar Mukunda To: , CC: , , , Vijendar Mukunda , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , open list Subject: [PATCH RESEND V2 03/12] ASoc: amd: add acp5x init/de-init functions Date: Sat, 17 Jul 2021 09:30:50 +0530 Message-ID: <20210717040059.310410-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210717040059.310410-1-Vijendar.Mukunda@amd.com> References: <20210717040059.310410-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1cd8c31-1702-4c44-cf7e-08d94891d955 X-MS-TrafficTypeDiagnostic: CY4PR1201MB0199: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:88; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T6+2sKg2AGsi1ZwueEoSzSIt5bPfbTTglvcm0W8jQ3kujQvAiin4TVsGOzOKAD+mtis/XSBpJ+9ajwbws+Fa96l7R0AVq0aE2nGpBB/iLyO11wHBX538msuWGWoGMGiBCBCHi2vtOeago5zkkwfk3Lb6uOQZR1oeRz3ZCVuQsGOYqIM9WIRlqpK0xTIt2QSa3eB9OHuVdyk1XKtQovYEF97jYCBA2rQX9kRtNTKizCC+7U9U/UcbNArfvdj+L4JNIvix4DhoURJo1pwEUrHpXLSzgl4PvzjaRMUI3WNWYW3Kt4EeOVMg5t4lrHG1jC7JwoDBKdRKE188aqu2ykPOSyrR7LAS5mkqwx8cJfHE4t3UtERnBfyBPo8CWXxld6AM7rI4PbAdd9lgzNtKgXgrThbgQP4np0rhRgrRSWpmHUlp5guaIMa/un1SYTenAmQMqMGoe4jQIDyuPIMU+eVB95ImBbUw3PWmWSNWNusFQmnqEfQ9oiMg4UfKfElWTdNWZ04KmAf+t4X42VuYvtPRFRi6Y/waPh3Ql5n6ARfzeqiJ0h33heurOywS3XbP0jBbB+PK0vmcATzInrxvd5MUv/HhT0Xgot4ypHorKqqcWTwFfqzyVCqmFGxXU3oaoIKR7IgMSyqzyX3EqDN4aSY5UxYjxEQx4l8tELzzM+pRmX/5ZZsKP3DmHUfgTPa21lknPKoYiix+ZajlCNl9XEl0m2k/bi7aTpGqii+tYBaDgbapmhSWAE91exxDh+6fFBewHXjHKlSP8KxVupaCKid9VkPHyxwAZfk/9wrgi7Kn7xQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(136003)(376002)(39860400002)(346002)(396003)(46966006)(36840700001)(186003)(478600001)(36756003)(1076003)(81166007)(2906002)(86362001)(7696005)(70206006)(83380400001)(26005)(6666004)(47076005)(316002)(82740400003)(5660300002)(82310400003)(8936002)(4326008)(356005)(70586007)(8676002)(110136005)(336012)(2616005)(54906003)(36860700001)(426003)(42413003)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 19:42:30.1694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1cd8c31-1702-4c44-cf7e-08d94891d955 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0199 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vijendar Mukunda Add Vangogh ACP PCI driver init/deinit functions. Signed-off-by: Vijendar Mukunda --- v1 ->v2: add amd: tag in commit message modify condition check in acp5x_power_on() removed acp_power_gating flag related code --- sound/soc/amd/vangogh/acp5x.h | 12 ++++ sound/soc/amd/vangogh/pci-acp5x.c | 106 ++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/sound/soc/amd/vangogh/acp5x.h b/sound/soc/amd/vangogh/acp5x.h index 8afa8144af4e..708586109315 100644 --- a/sound/soc/amd/vangogh/acp5x.h +++ b/sound/soc/amd/vangogh/acp5x.h @@ -9,6 +9,18 @@ #define ACP5x_PHY_BASE_ADDRESS 0x1240000 #define ACP_DEVICE_ID 0x15E2 +#define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 + +#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 + +#define ACP_ERR_INTR_MASK 0x20000000 +#define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF /* common header file uses exact offset rather than relative * offset which requires substraction logic from base_addr diff --git a/sound/soc/amd/vangogh/pci-acp5x.c b/sound/soc/amd/vangogh/pci-acp5x.c index e56d060a5cb9..523b962fe35e 100644 --- a/sound/soc/amd/vangogh/pci-acp5x.c +++ b/sound/soc/amd/vangogh/pci-acp5x.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "acp5x.h" @@ -14,6 +15,101 @@ struct acp5x_dev_data { void __iomem *acp5x_base; }; +static int acp5x_power_on(void __iomem *acp5x_base) +{ + u32 val; + int timeout; + + val = acp_readl(acp5x_base + ACP_PGFSM_STATUS); + + if (val == 0) + return val; + + if ((val & ACP_PGFSM_STATUS_MASK) != + ACP_POWER_ON_IN_PROGRESS) + acp_writel(ACP_PGFSM_CNTL_POWER_ON_MASK, + acp5x_base + ACP_PGFSM_CONTROL); + timeout = 0; + while (++timeout < 500) { + val = acp_readl(acp5x_base + ACP_PGFSM_STATUS); + if ((val & ACP_PGFSM_STATUS_MASK) == ACP_POWERED_ON) + return 0; + udelay(1); + } + return -ETIMEDOUT; +} + +static int acp5x_reset(void __iomem *acp5x_base) +{ + u32 val; + int timeout; + + acp_writel(1, acp5x_base + ACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = acp_readl(acp5x_base + ACP_SOFT_RESET); + if (val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK) + break; + cpu_relax(); + } + acp_writel(0, acp5x_base + ACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = acp_readl(acp5x_base + ACP_SOFT_RESET); + if (!val) + return 0; + cpu_relax(); + } + return -ETIMEDOUT; +} + +static void acp5x_enable_interrupts(void __iomem *acp5x_base) +{ + acp_writel(0x01, acp5x_base + ACP_EXTERNAL_INTR_ENB); +} + +static void acp5x_disable_interrupts(void __iomem *acp5x_base) +{ + acp_writel(ACP_EXT_INTR_STAT_CLEAR_MASK, acp5x_base + + ACP_EXTERNAL_INTR_STAT); + acp_writel(0x00, acp5x_base + ACP_EXTERNAL_INTR_CNTL); + acp_writel(0x00, acp5x_base + ACP_EXTERNAL_INTR_ENB); +} + +static int acp5x_init(void __iomem *acp5x_base) +{ + int ret; + + /* power on */ + ret = acp5x_power_on(acp5x_base); + if (ret) { + pr_err("ACP5x power on failed\n"); + return ret; + } + /* Reset */ + ret = acp5x_reset(acp5x_base); + if (ret) { + pr_err("ACP5x reset failed\n"); + return ret; + } + acp5x_enable_interrupts(acp5x_base); + return 0; +} + +static int acp5x_deinit(void __iomem *acp5x_base) +{ + int ret; + + acp5x_disable_interrupts(acp5x_base); + /* Reset */ + ret = acp5x_reset(acp5x_base); + if (ret) { + pr_err("ACP5x reset failed\n"); + return ret; + } + return 0; +} + static int snd_acp5x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -50,6 +146,9 @@ static int snd_acp5x_probe(struct pci_dev *pci, } pci_set_master(pci); pci_set_drvdata(pci, adata); + ret = acp5x_init(adata->acp5x_base); + if (ret) + goto release_regions; release_regions: pci_release_regions(pci); @@ -61,6 +160,13 @@ static int snd_acp5x_probe(struct pci_dev *pci, static void snd_acp5x_remove(struct pci_dev *pci) { + struct acp5x_dev_data *adata; + int ret; + + adata = pci_get_drvdata(pci); + ret = acp5x_deinit(adata->acp5x_base); + if (ret) + dev_err(&pci->dev, "ACP de-init failed\n"); pci_release_regions(pci); pci_disable_device(pci); } -- 2.25.1