Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp12750pxv; Wed, 21 Jul 2021 14:05:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuwK7Bg4B69/lIbQAXCB+hLxwC+6bgBrucXRtE9Tt+g6648JUM234mXwwl0aod6Q4Lsca8 X-Received: by 2002:a5d:9b9a:: with SMTP id r26mr28263421iom.34.1626901456866; Wed, 21 Jul 2021 14:04:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626901456; cv=pass; d=google.com; s=arc-20160816; b=YD8FyoRZy/hr6K7fWaVP8vpGELqTA/fBtFE/5iq4v/tx5iFmm486/Adjw6Fji8L8VF /gNcfkeYwUpBGca4adEpRVTdDqvmItS7dg3RdmmZAK+mZsN58P1Bq50EGyyVVuuBh2Y8 ITYxKzX6LbNQbI4wDRspb+z7WX/CHkKIBIurg79DcSUkcZCI+zfKXLML9c9AMj4XyxgC HegF+WY5EojGbmqhWbXmsqA5X1U427QlwY012RoM0ZSdCkjj7jVYF7iPcueE6G4+Ww1j oK9Nao0wfa5Vd2DGvHYMnb878nN8XohD/tuZh/ewIMcalm365sfitp95G4TrOFN55B9r owwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1c5XQfrGRwfTTFJvWE3jNs7CMNf/9fKjNwJ2qRkwFGo=; b=xzB+igRSvZIIjs5st36xbIWNgJgdvXFVJ2HhypNQQ47OWdBkWFMuZrEbTDsd0/RAmW hoLoqrB6Jj0Ba/o79JEoUlkOoElEqOQL5xvrIpS1Yf2XF0urevrNszSG+QI0UFUKx7q0 /5irJLbOLRVdPamE5zzkNMRErnobUM8jodR4l52vKfS58tIxQRZPifwCEdoPLXmUYRM5 +OM6HFgHGuSUlMWQoqEm7ACBuvTV30/oAPGuPZZpTMG2GlvVCCtbqWCDB25o82b+FwQ4 NJNWg25g2hBxQ41oTi25wUx/bWW9K9z7rSzspoAvXlbLjaUHxZNnJAtd3VYT4YrUUoGD RRNw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=g8Dj2OzN; 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 q41si25965471jav.74.2021.07.21.14.04.05; Wed, 21 Jul 2021 14:04:16 -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=g8Dj2OzN; 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 S236715AbhGURHT (ORCPT + 99 others); Wed, 21 Jul 2021 13:07:19 -0400 Received: from mail-sn1anam02on2048.outbound.protection.outlook.com ([40.107.96.48]:26721 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230111AbhGURHS (ORCPT ); Wed, 21 Jul 2021 13:07:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J7EBSl6alGjmryp/7NTo0N8Nm/45K8FS6N2Np0DXNsExRJSvbeqm4o1TPxJmls6bZwLlIRi8NUPDx4uXVlBpX+WIFnYpOqHXWLeBBeeIEIKBIivJz53DkDRkPddCk4RBXixEQGj3GqbxsPqgsXY3g2d5gmmJKdKZGyo4dndzvpxM+ULWaY7v6Pk3Y3eAN9mWJtoUBLlFmBfORN+8dhg3SzLBJ2LrySrYnmHuq/vTZqbYCGfANRnWXjXBwFezHAd0C9/DWfcWKbx2uDC+sOdiij7UHTFztr1u/fV8s5j5cBPtENsFcu1R2+5YxJduXJNpAjWE2lq/b2pdtTbGoFoIrw== 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=1c5XQfrGRwfTTFJvWE3jNs7CMNf/9fKjNwJ2qRkwFGo=; b=RydDUwVk0xp9XSKEh2bYq4csSrDZvG8vPNWQgEPmpdythTphF68QqSBN4vIhAEPdy37pZYeXU9yKBNSXMFB5qbTNs269oiivmhJMoEGdgQLJWs+pvZcvhIrZ+PQI7PDhJJrsYYZU0hkYPl/upvZepBThDBB9rzaT8s9f8I9iHjPCRhrK+eGKbHQLopviOA6EYKzoz4jWW0S532MKsNjHHt9lgfsNZrc7e1+M8rvBqY7GBRxOJOhZOUJowJFu5naqJHVNrS5GTfnTSuwQM/FKl87H2LZMTJAtEQdJTdOOxu8HzTw8RaSJIANaqdtqg5S3OyrUelJ9ATRUXWnyEjpoYw== 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=1c5XQfrGRwfTTFJvWE3jNs7CMNf/9fKjNwJ2qRkwFGo=; b=g8Dj2OzN/3LuQaUErD6KsoCrzSB/XHDupbXQHqG949PDcG8hnujqgobwFGYJV8v0Vr2/Mmps+uypVR8Wm7UI3LmPa+T3MFBhap1+XXwRGJoGQaLK8Z4dB8JVvaLh6qn59jJdyxL0QbdeGI10LW+qHgaFLXVjALKmPCOuevAVNXs= Received: from DM6PR17CA0032.namprd17.prod.outlook.com (2603:10b6:5:1b3::45) by MN2PR12MB3918.namprd12.prod.outlook.com (2603:10b6:208:162::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Wed, 21 Jul 2021 17:47:53 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::c4) by DM6PR17CA0032.outlook.office365.com (2603:10b6:5:1b3::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Wed, 21 Jul 2021 17:47:53 +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 DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 17:47:53 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 21 Jul 2021 12:47:52 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 21 Jul 2021 12:47:52 -0500 Received: from LinuxHost.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; Wed, 21 Jul 2021 12:47:48 -0500 From: Vijendar Mukunda To: , CC: , , , , Vijendar Mukunda , Liam Girdwood , "Jaroslav Kysela" , Takashi Iwai , open list Subject: [PATCH v5 03/12] ASoc: amd: add acp5x init/de-init functions Date: Wed, 21 Jul 2021 23:34:19 +0530 Message-ID: <20210721180430.11571-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210721180430.11571-1-Vijendar.Mukunda@amd.com> References: <20210721180430.11571-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 51e70463-ae66-44c8-29ed-08d94c6faa53 X-MS-TrafficTypeDiagnostic: MN2PR12MB3918: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:175; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XbCqUG1dEDQHNjwGIKMXas6x7mZ+7WGkySpMYSczb/Qp71nPhdvqBnimi0V5BHrIzJpL80o2Ugfe3TZ80S47MNzQ+HSu6PREjELaV1bWKPhVIBnEv9cWHeZL5o803cBkIyDHFPEGyOjCAv5ID3gStAU3lbzEeSBjhu66yv5oACDLanUqngR/1Bk0n1Qer/kXWnnOJ3GE3h7WOZ0VUhnoPTSgQ5GUi5jXc+ym1G/zkcEFByKQqyDv90t32U4ZyNLBuW2ajPpZdm1IhI4L/CdK3tLDhvlhighl4uy2T1wNRvSBUNYqOTPfF1C5joaRQIxO0gC3PfTz1qgzFK2PnXHCkgmTFNPNvn3hW+rWW8TmZy8qgh74k761yZ+nhVyA7jP3RTHVhsBlSdJIgKoZ95JsI98iJ6E8fk2r2F4kUMfiflhqHnuAYI5fIDqRvyCDjDyo+atcGP72LfPDZw62BEXWUmggnZFQF9vi0+mhnr7ywAPMy14ubgakk1hPevEvpt/D0OqsFzsrSYf2NZoE+/5ErytWK33dNzFq74y/UyA3ZhC4dat7izAHQsWKA7gs1BTWTsKm+COiVcXZUMCF3RasCmDBe0K+x4HMByxqg9hZkTNpP19tmKFa2pUbN4X+sjOvyVKZeN+XAsq+TFOxhIO+XjgZUaEoy/JBRhEp1viGNwydVB2OEdOX1x6fL+iFnlNCsKoZhJUAIKfvdnP4JYA33p6AAFEGhe3Ngy9WA9nYzg9DEl3ReKR8e4LgchujQ8hCvkYLS/UavVR9bKR1TeIQ+4xtXbMhJ2YJHZJiTK4S8jk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(2616005)(82310400003)(1076003)(8676002)(47076005)(81166007)(70586007)(356005)(316002)(54906003)(186003)(70206006)(426003)(508600001)(36860700001)(36756003)(336012)(4326008)(6666004)(26005)(7696005)(110136005)(2906002)(8936002)(5660300002)(86362001)(42413003)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 17:47:53.1134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51e70463-ae66-44c8-29ed-08d94c6faa53 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: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3918 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Vangogh ACP PCI driver init/deinit functions. Reviewed-by: Pierre-Louis Bossart Signed-off-by: Vijendar Mukunda --- 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 251a7e0347a7..db23fffce9a0 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 subtraction 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.17.1