Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2899560pxb; Mon, 18 Oct 2021 04:24:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRK1X/iwQ4mWzWZhAVl2gAetXENbzGu8pRYpjS3o2kFOLgCFMhCFQMj50MlS8UOKJ45Zfu X-Received: by 2002:a50:bf07:: with SMTP id f7mr43630903edk.288.1634556258811; Mon, 18 Oct 2021 04:24:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1634556258; cv=pass; d=google.com; s=arc-20160816; b=hsVEGEByOSKCb4E32ySWkHSvUxIJ4hIjdQTHlQEFd8txm7WofqY9suu9Jl0d/YcSBY /SeRv1ebW6RqJAqKlf6t7YkwjPt/J2JSJ8PClSNRLZ57VEoGvYh6wmlbdVP5io6Gsn/G u2JyBxwPliypZUt5bf1/8NWJYHF6kAByPUZflqq66z/63uBEuAKvCXSqKHB7PGPobk1b zji0s5oBMGBfv2QGdSKrZSiPf+w6vF5pZ10X5+dVFrlLzWEId1iOEQgddgET0bIlLdwi fKTV4RUAZ3Nwd41+Iw9G9QkWSesxo0EHHgzxXOjFf/uDPh+FeOGPfQdnieC5pQtBtZDX sYcg== 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=uFIN5JyUAgnCxWs5dyuOArOJvr2XRRyiJeh16La8sOQ=; b=O8+vwgqbitJkMMhvAcydO6J2nJv5Ob0s/FVM4fLZzrsuQkyMaWuAYpXX54lGsmEy3N zPREcj43Z35pmr/wr2hnBgerjRf92ASEO+iMjEZaaU24xdzhMZdV4qcY/9pCXYUZNXRA cd0ye/n0+3yZlYBmAp1B2318KLvd8XSCbR2DCyAX9x7HZMXuPcQu9E+tSSqxrOZ5Qgmb tWcRXSlovWwbBm+dGqXa+vafivfKu5yv/cUiXBd0f9z0F+vz19ndPjg3pECkxCHD8BB2 HYsTzZAsXRvhJa48qi1Gdn01XmEMfecQq1kwknwPzVnSXXyC7irArYOdbC/rlwJXC0KD lWZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fokR46y+; 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 g13si26918438edz.599.2021.10.18.04.23.54; Mon, 18 Oct 2021 04:24:18 -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=fokR46y+; 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 S230114AbhJRLYK (ORCPT + 99 others); Mon, 18 Oct 2021 07:24:10 -0400 Received: from mail-mw2nam12on2046.outbound.protection.outlook.com ([40.107.244.46]:30273 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229581AbhJRLYJ (ORCPT ); Mon, 18 Oct 2021 07:24:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dXlFNS8BqiP3cbe3rNFbuQiQbLm6e5gNnZG+be5cWM1sYsXCQo8KtXYZ7Dt1DxipO2edskR5qggceL+UDOlty0T4BLaF0RaVbQjyqGHUQWXMlc5roMGOU/JjZqzeEiN+gDALblJ8Q9s/cCh050ESImo3ejbAEnYT6jmv2Bh11dSObuy8ab+cjpEc4HH4+vwJ+1tZD7+6IDaC3wtDR/BCSHmkCirfhxPYfek5lgMLKFKn1dueQouvvFjbIR/u2kglUrGbLbDrxWYYyIq1N25bw63ABXfsTY/MXtYIEsZo0Cd7TGXgmEBaCrtOoJm9uIc1Znmm1A3O2cP9l9fxwJMjmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uFIN5JyUAgnCxWs5dyuOArOJvr2XRRyiJeh16La8sOQ=; b=m1BFgKsxcDxTnNgkk9DRo6h9LCOv+yfKzuMo/Y4bBDK/uACxecN9MHinI5P2ZiWscuzCpDwO/V4Mh75xqd3WX7sNss/Eu88SsWPjPdcaKL9q261GwajVSN8g12tqmp3cPTRk2/2PlHuzhDIyrwmHLi1TRTsMsFfY8HKiKTtFQwecUvgU4AL8wPxvAhoYInHYSqrukWn7s0vYQVZ57mqwaWHksNmFN6EQUM98AAKlXS4YdRL1hC7Ui9IF/j5CGZDMBSWb0IndXAU5dqmah30o4+12DQIXm/KCfqav5Pnx3bSaiIjjhHkehX4ff885PSeuzwCBOaC14YFL06V94TP/rA== 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=uFIN5JyUAgnCxWs5dyuOArOJvr2XRRyiJeh16La8sOQ=; b=fokR46y+vDiFejUwotrrySoGEh2CaLCY/Utl8VnVoQiZng/cs1FqTf7AWYxluq7WIRKxag+Rr1enV09b+N0tHudOKjfJ3kkb64x93EKEgSFylIA7irLxfZiHvLHa/L92UrU+cV6f/Q+OCF5mCV7qpo984gZmYPE4d8/EKd7G4/Q= Received: from DS7PR07CA0021.namprd07.prod.outlook.com (2603:10b6:5:3af::23) by DM6PR12MB2603.namprd12.prod.outlook.com (2603:10b6:5:49::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Mon, 18 Oct 2021 11:21:55 +0000 Received: from DM6NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::b1) by DS7PR07CA0021.outlook.office365.com (2603:10b6:5:3af::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Mon, 18 Oct 2021 11:21:55 +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 DM6NAM11FT014.mail.protection.outlook.com (10.13.173.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Mon, 18 Oct 2021 11:21:55 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Mon, 18 Oct 2021 06:21:52 -0500 Received: from vijendar-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.15 via Frontend Transport; Mon, 18 Oct 2021 06:21:48 -0500 From: Vijendar Mukunda To: , CC: , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , open list Subject: [PATCH V2 03/13] ASoC: amd: add acp6x init/de-init functions Date: Mon, 18 Oct 2021 16:50:34 +0530 Message-ID: <20211018112044.1705805-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018112044.1705805-1-Vijendar.Mukunda@amd.com> References: <20211018112044.1705805-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b8c23f6-39b1-424e-6c74-08d992297e26 X-MS-TrafficTypeDiagnostic: DM6PR12MB2603: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:160; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TiGrKnhQLUVmu89+GbuB56jbTmoYR23+ojsBhJ7iS/rmhxwVDstypdt+fqQz6y7lYEts2/Nh7+3IpMNg7Q3siL+9R/wGA4erglWgKUTFPkR5Iv37YkokEVtrUmZLgDN8lyXD0wMNlXHvcChZ+rjxwmb9UH0URau/qlnHU6eUldMmzbEJ83uvSCQvHjiMmXWURC0zu+zeU2N/mV6EsRd8DrAA/ts1i2dtF+XM9Mrj2UU3WA/TMIK0rGaRxvdIPMHaoHooayghC4Zk+YEUEHtiz8hMJi5vKk/0YWnJzD7PIJqHs8/h/RkduhmVjzM7ETwMHoP5z7IYwez4EjLE+wXskYrZtJi1rJs2jzdO6XGCtimTgstF31K4+MSSzDO2y696vJhn+i276wa/kxW5LZjXOOEEYT0AITMpbltAuJmV2KkB/OhHG5Ic2bKnl3J4my1O7FCcRjR28Ojqz1F78+IlNkr9TiOjoNrbq/L7BRwLGan2Gnyv+ouQyfOH/AsBWbBFe/HoA4ylGDSFqwWPxyrnyyMfVVVqyI05Y2eQnMeT0fd4V44Pg63rWdzXDndylHu63LudtmzaXZR+6zEyultokboZphXPsy7tGzEc2CMBWUDKU3bPeC6WPvDfIY1hDu2S8IpoAfdFBUiXA1BTbO2G7IunGAQNbC9d9SXKIWWt1lfFStcoZC37M63lMwBlXqDTQCBYjtmTw917pwn/mKFIVCK2GyAEcEo6TTZkh3YbH9JOm99Tmx++HD3lSmIxgu0TOlajPShj1hKX8Cp3+u+BUA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(36860700001)(82310400003)(426003)(356005)(26005)(186003)(36756003)(8936002)(6666004)(508600001)(86362001)(4326008)(81166007)(336012)(5660300002)(2616005)(110136005)(54906003)(70586007)(8676002)(7696005)(316002)(70206006)(2906002)(1076003)(47076005)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2021 11:21:55.6549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b8c23f6-39b1-424e-6c74-08d992297e26 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: DM6NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2603 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Yellow Carp platform ACP6x PCI driver init/deinit functions. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/yc/acp6x.h | 12 ++++ sound/soc/amd/yc/pci-acp6x.c | 109 +++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/sound/soc/amd/yc/acp6x.h b/sound/soc/amd/yc/acp6x.h index 62a05db5e34c..76e9e860e9bb 100644 --- a/sound/soc/amd/yc/acp6x.h +++ b/sound/soc/amd/yc/acp6x.h @@ -10,6 +10,18 @@ #define ACP_DEVICE_ID 0x15E2 #define ACP6x_PHY_BASE_ADDRESS 0x1240000 +#define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 +#define ACP_PGFSM_CNTL_POWER_ON_MASK 1 +#define ACP_PGFSM_CNTL_POWER_OFF_MASK 0 +#define ACP_PGFSM_STATUS_MASK 3 +#define ACP_POWERED_ON 0 +#define ACP_POWER_ON_IN_PROGRESS 1 +#define ACP_POWERED_OFF 2 +#define ACP_POWER_OFF_IN_PROGRESS 3 + +#define ACP_ERROR_MASK 0x20000000 +#define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF + static inline u32 acp6x_readl(void __iomem *base_addr) { return readl(base_addr - ACP6x_PHY_BASE_ADDRESS); diff --git a/sound/soc/amd/yc/pci-acp6x.c b/sound/soc/amd/yc/pci-acp6x.c index 5c118328ea21..03af3476a97c 100644 --- a/sound/soc/amd/yc/pci-acp6x.c +++ b/sound/soc/amd/yc/pci-acp6x.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "acp6x.h" @@ -15,6 +16,103 @@ struct acp6x_dev_data { void __iomem *acp6x_base; }; +static int acp6x_power_on(void __iomem *acp_base) +{ + u32 val; + int timeout; + + val = acp6x_readl(acp_base + ACP_PGFSM_STATUS); + + if (!val) + return val; + + if ((val & ACP_PGFSM_STATUS_MASK) != ACP_POWER_ON_IN_PROGRESS) + acp6x_writel(ACP_PGFSM_CNTL_POWER_ON_MASK, acp_base + ACP_PGFSM_CONTROL); + timeout = 0; + while (++timeout < 500) { + val = acp6x_readl(acp_base + ACP_PGFSM_STATUS); + if (!val) + return 0; + udelay(1); + } + return -ETIMEDOUT; +} + +static int acp6x_reset(void __iomem *acp_base) +{ + u32 val; + int timeout; + + acp6x_writel(1, acp_base + ACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = acp6x_readl(acp_base + ACP_SOFT_RESET); + if (val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK) + break; + cpu_relax(); + } + acp6x_writel(0, acp_base + ACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = acp6x_readl(acp_base + ACP_SOFT_RESET); + if (!val) + return 0; + cpu_relax(); + } + return -ETIMEDOUT; +} + +static void acp6x_enable_interrupts(void __iomem *acp_base) +{ + acp6x_writel(0x01, acp_base + ACP_EXTERNAL_INTR_ENB); +} + +static void acp6x_disable_interrupts(void __iomem *acp_base) +{ + acp6x_writel(ACP_EXT_INTR_STAT_CLEAR_MASK, acp_base + + ACP_EXTERNAL_INTR_STAT); + acp6x_writel(0x00, acp_base + ACP_EXTERNAL_INTR_CNTL); + acp6x_writel(0x00, acp_base + ACP_EXTERNAL_INTR_ENB); +} + +static int acp6x_init(void __iomem *acp_base) +{ + int ret; + + /* power on */ + ret = acp6x_power_on(acp_base); + if (ret) { + pr_err("ACP power on failed\n"); + return ret; + } + acp6x_writel(0x01, acp_base + ACP_CONTROL); + /* Reset */ + ret = acp6x_reset(acp_base); + if (ret) { + pr_err("ACP reset failed\n"); + return ret; + } + acp6x_writel(0x03, acp_base + ACP_CLKMUX_SEL); + acp6x_enable_interrupts(acp_base); + return 0; +} + +static int acp6x_deinit(void __iomem *acp_base) +{ + int ret; + + acp6x_disable_interrupts(acp_base); + /* Reset */ + ret = acp6x_reset(acp_base); + if (ret) { + pr_err("ACP reset failed\n"); + return ret; + } + acp6x_writel(0x00, acp_base + ACP_CLKMUX_SEL); + acp6x_writel(0x00, acp_base + ACP_CONTROL); + return 0; +} + static int snd_acp6x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -53,6 +151,10 @@ static int snd_acp6x_probe(struct pci_dev *pci, } pci_set_master(pci); pci_set_drvdata(pci, adata); + ret = acp6x_init(adata->acp6x_base); + if (ret) + goto release_regions; + return 0; release_regions: pci_release_regions(pci); @@ -64,6 +166,13 @@ static int snd_acp6x_probe(struct pci_dev *pci, static void snd_acp6x_remove(struct pci_dev *pci) { + struct acp6x_dev_data *adata; + int ret; + + adata = pci_get_drvdata(pci); + ret = acp6x_deinit(adata->acp6x_base); + if (ret) + dev_err(&pci->dev, "ACP de-init failed\n"); pci_release_regions(pci); pci_disable_device(pci); } -- 2.25.1