From patchwork Mon Feb 27 15:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 61983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2498876wrd; Mon, 27 Feb 2023 07:59:02 -0800 (PST) X-Google-Smtp-Source: AK7set9StVIx3PZtypdqNj6JvB07GAJJi1TerZwjpVLUBT+QivI/aApiqzpMFQKQDIOV/OLGCjUa X-Received: by 2002:a17:902:f708:b0:19c:da68:337b with SMTP id h8-20020a170902f70800b0019cda68337bmr7514041plo.16.1677513542237; Mon, 27 Feb 2023 07:59:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677513542; cv=pass; d=google.com; s=arc-20160816; b=hLRlS/k39pYgUqfyjpEdMGF4rMddBVrkDgJT2LabNkdzrNc99TcuSrs8cq8j5bC4yB kJlLCHzHp3vPqbY9sq8yZ7MptrhCoDRIW5tVxgPzS/3mXJ+HMv+gy6a+I4JKxb3yLFJ0 qfR5eXhE1/H6vviTFRKbPZE8hio+sw3tusnnxyqbYJbnbsR4nmOP02Iq83fN+D3Nbv8v BFPJZ32B1b9AM31dvVtRY/dU7mlcDCiHoNKuFA5ISiSoHM8vi4XDMuB+vloK7Bp8gN5y 0mL7WFCz9FOAfhmTpqYfUHItBLJZO0d11Vg4DeFDZcY3JxP09igRa6ZabHMKXlfahaz4 l81w== 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=KGuK2A21PcQk/hePfSLS2V3o9jnU3+Pp+VAFZ49FMz4=; b=fiWvWqPWuaVJykjlAFTqzVt7mJ3w0lbirbR+g2W1fbdYBDWoJRgblCvrYYTtixyH3+ DP00U/6hhp8awogoxUMVV5Jkhk2P9Yl/jMMPXlBPJIacdBV33j+3qTsGm6YWX/DbmIgV hWV4IROnGKD4P5SrkjInc3CYyyGKvJbV8ywIMZyEcrT6wPkwoZC8I/8nvooSf221YxFY C7/uwk52bZHQveshPY/C1YwumTqgG/7hJeLGcMlzR6Gx8uukw8WFdn4kyAiMwQYsCYzo j69RCKTfuQiVN4QNN5raN26Y1l6hsCV6m2LQ63y5Si8kD5/eAEP+yiNMudqNiO2x5Bvi 4HmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ku7X3Nkf; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a170902b78200b0019aa6c46413si6833150pls.345.2023.02.27.07.58.49; Mon, 27 Feb 2023 07:59:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ku7X3Nkf; 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 2620:137:e000::1:20 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 S229941AbjB0PpO (ORCPT + 99 others); Mon, 27 Feb 2023 10:45:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjB0Pop (ORCPT ); Mon, 27 Feb 2023 10:44:45 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2073.outbound.protection.outlook.com [40.107.223.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FDEF16AED for ; Mon, 27 Feb 2023 07:44:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f2iN8UaPnvJmmHMcc4vPF18fKEFK6rQ2gxIlP7fLhXomX4kABwCey0PujsbhMW3Uy1I5uNGzXOFxbRUjGlJHAnMtUEc8rhe1eg3vAjH6aMiShxfovWHUyerdK8fLdRs8oGaUPa6kSqhKs/DZRsAmIgx64KKTCGjtPzOslPM5DQTb+9VTwzxDAuQnucF7AmwBQkH8QGKRSH022dsHuBhePWbk8Jf5U/SCq2o5VxN9gtqEbFKc/YgLNXNJkjIcgV1/HyB6BTWWI/nJ+G+WleECyBIOcPY7xL7aKolKK/iBMzGNyfxMNucmCwBrH/muyMbI89Y8y0EQ9VDeh5l2LFhJkQ== 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=KGuK2A21PcQk/hePfSLS2V3o9jnU3+Pp+VAFZ49FMz4=; b=meSkpaI+MCoXYyQVIEkXE7i6rauAvdmvWh1FK1D/L6cPi381QjueagH5pMg40aKWkwlt98aUTr/PZM7x8BaTtjHJTs06MFINhduWVHLo5h8VHZp5baZXhf4GGCmjnuek3vSY81wFTbH2q+y+/tOG8FW5l1SMAfpr++lKFgIFn48XPL8oexZokrXVrmwI6PIaP6TDtG83JX+NERmuXYJHdM1AqO+3dOVzFEhkDqG/QqroxTPD5kWQMvDyPaEMD8VksmECM/qDhXmm570HJdnY5EA2VM7fvSLUbpVQCh3saP8G70ARN5Yb0NueqcyCuCShH6Pu1Vw/ofFHh1Uhvsp5dg== 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=KGuK2A21PcQk/hePfSLS2V3o9jnU3+Pp+VAFZ49FMz4=; b=ku7X3Nkf8hvbPbHZ7yIOfh0JCKXrJfxJUsrHRc3SO5AMiP/DG3iR0XHFeyrlOIweRbUzz12g4MZdcgPkwKx9nP8DS9FcKcDSn4VRBV1/0b2N5EnI0SKZSK2bO35gQwN9Zr0knnA5TBqnSPI12Ks5BEx0GxdEfkxvaw9LFrQNvKE= Received: from MW4PR03CA0340.namprd03.prod.outlook.com (2603:10b6:303:dc::15) by SJ0PR12MB6760.namprd12.prod.outlook.com (2603:10b6:a03:44c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 15:44:26 +0000 Received: from CO1NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::2c) by MW4PR03CA0340.outlook.office365.com (2603:10b6:303:dc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29 via Frontend Transport; Mon, 27 Feb 2023 15:44:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;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; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT044.mail.protection.outlook.com (10.13.175.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.14 via Frontend Transport; Mon, 27 Feb 2023 15:44:25 +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.2375.34; Mon, 27 Feb 2023 09:44:25 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 27 Feb 2023 09:44:21 -0600 From: Vijendar Mukunda To: CC: , , , , , , , , Vijendar Mukunda , Bard Liao , Sanyog Kale , open list Subject: [PATCH V4 6/8] soundwire: amd: add runtime pm ops for AMD SoundWire manager driver Date: Mon, 27 Feb 2023 21:17:59 +0530 Message-ID: <20230227154801.50319-7-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230227154801.50319-1-Vijendar.Mukunda@amd.com> References: <20230227154801.50319-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT044:EE_|SJ0PR12MB6760:EE_ X-MS-Office365-Filtering-Correlation-Id: 666b7522-7819-4d08-1879-08db18d98165 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VXf6cjyr5wdpvXUjkhqMnQX21j14iWTR1clzpsxfF1pbdKoR0yhc2mL8SO5bE6tLrdomxgsyXBvKOZgUqYfY9eLEs8dGduWUjslmC0yN13QkBlqdvRgbcBn7pVRTvD06zfPZDrgX4puACD12q9/2mWisoj0aJ1f8+GrIpdCVybC4tdFLkvQbVuZ52kUzy69urVIXEJusfXykItjdiq45SZo9HdRl/ShbONlDARpLljeryjdBeXnxtDxcOKhIea/n/Ac2+IveQGiSrWKUpjCskpJitahInX1mMMwd3/nURXFQ/IGhQkNHA4xz0moqwq1q/7P7OJ+f9AJHW2JMFEU2POVxpTXSB/HT9ytPhcDZk9aBGrEsMPpA9pWh43FE09iG2WaLB4h82pmm24Dd6+vrkjN2ihs9jdxxUvBtivKKdgSAfvtZwilfy4224i1q+b9e+z7AKb8GFpWfZJ0hUyy3WQY7cumb9jczeTGwg84UKuOfQbPaRPnNK4LxdxfoRSxblAGldbDoIuA4XaPdqILc9ZiTlkz6gwTdKZY8u2m/4wGJvvF1LEYVDuw7ON7VDc7KUebaXblunQuCoXiBom+vsfm0wiN83Sf33LHPH+6Skuof90OgaG0U96HJTbAQ3qe3rR1dJl2eYnU4hGdtrlu/cddUJLw3JhNn0G+k29WTIkfp5IxMFQq+M+XwJW5sRDOlpJ5DlSm4yOnjWfTpZjebQaFpg61c2HdY2A1sIoyA/aE= 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:(13230025)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199018)(36840700001)(40470700004)(46966006)(8936002)(2906002)(5660300002)(41300700001)(70586007)(70206006)(4326008)(6916009)(8676002)(316002)(54906003)(478600001)(7696005)(6666004)(36860700001)(426003)(47076005)(82310400005)(26005)(186003)(1076003)(336012)(2616005)(40480700001)(86362001)(81166007)(36756003)(356005)(83380400001)(40460700003)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 15:44:25.9350 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 666b7522-7819-4d08-1879-08db18d98165 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: CO1NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6760 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759000440485527875?= X-GMAIL-MSGID: =?utf-8?q?1759000440485527875?= Add support for runtime pm ops for AMD SoundWire manager driver. Signed-off-by: Vijendar Mukunda Signed-off-by: Mastan Katragadda Reviewed-by: Pierre-Louis Bossart --- drivers/soundwire/amd_manager.c | 161 ++++++++++++++++++++++++++++++ drivers/soundwire/amd_manager.h | 3 + include/linux/soundwire/sdw_amd.h | 17 ++++ 3 files changed, 181 insertions(+) diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index 7bb2300f16b3..12345077c395 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -178,6 +179,12 @@ static void amd_disable_sdw_interrupts(struct amd_sdw_manager *amd_manager) acp_reg_writel(0x00, amd_manager->mmio + ACP_SW_ERROR_INTR_MASK); } +static int amd_deinit_sdw_manager(struct amd_sdw_manager *amd_manager) +{ + amd_disable_sdw_interrupts(amd_manager); + return amd_disable_sdw_manager(amd_manager); +} + static void amd_sdw_set_frameshape(struct amd_sdw_manager *amd_manager) { u32 frame_size; @@ -957,6 +964,12 @@ static void amd_sdw_probe_work(struct work_struct *work) return; amd_sdw_set_frameshape(amd_manager); } + /* Enable runtime PM */ + pm_runtime_set_autosuspend_delay(amd_manager->dev, AMD_SDW_MASTER_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(amd_manager->dev); + pm_runtime_mark_last_busy(amd_manager->dev); + pm_runtime_set_active(amd_manager->dev); + pm_runtime_enable(amd_manager->dev); } static int amd_sdw_manager_probe(struct platform_device *pdev) @@ -1040,17 +1053,165 @@ static int amd_sdw_manager_remove(struct platform_device *pdev) { struct amd_sdw_manager *amd_manager = dev_get_drvdata(&pdev->dev); + pm_runtime_disable(&pdev->dev); cancel_work_sync(&amd_manager->probe_work); amd_disable_sdw_interrupts(amd_manager); sdw_bus_master_delete(&amd_manager->bus); return amd_disable_sdw_manager(amd_manager); } +static int amd_sdw_clock_stop(struct amd_sdw_manager *amd_manager) +{ + u32 val; + u32 retry_count = 0; + int ret; + + ret = sdw_bus_prep_clk_stop(&amd_manager->bus); + if (ret < 0 && ret != -ENODATA) { + dev_err(amd_manager->dev, "prepare clock stop failed %d", ret); + return 0; + } + ret = sdw_bus_clk_stop(&amd_manager->bus); + if (ret < 0 && ret != -ENODATA) { + dev_err(amd_manager->dev, "bus clock stop failed %d", ret); + return 0; + } + + do { + val = acp_reg_readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + if (val & AMD_SDW_CLK_STOP_DONE) { + amd_manager->clk_stopped = true; + break; + } + usleep_range(10, 20); + } while (retry_count++ < AMD_SDW_CLK_STOP_MAX_RETRY_COUNT); + + if (!amd_manager->clk_stopped) { + dev_err(amd_manager->dev, "SDW%x clock stop failed\n", amd_manager->instance); + return 0; + } + + if (amd_manager->wake_en_mask) + acp_reg_writel(0x01, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance)); + + dev_dbg(amd_manager->dev, "SDW%x clock stop successful\n", amd_manager->instance); + return 0; +} + +static int amd_sdw_clock_stop_exit(struct amd_sdw_manager *amd_manager) +{ + int ret; + u32 val; + u32 retry_count = 0; + + if (amd_manager->clk_stopped) { + val = acp_reg_readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + val |= AMD_SDW_CLK_RESUME_REQ; + acp_reg_writel(val, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + do { + val = acp_reg_readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + if (val & AMD_SDW_CLK_RESUME_DONE) + break; + usleep_range(10, 20); + } while (retry_count++ < AMD_SDW_CLK_STOP_MAX_RETRY_COUNT); + if (val & AMD_SDW_CLK_RESUME_DONE) { + acp_reg_writel(0, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + ret = sdw_bus_exit_clk_stop(&amd_manager->bus); + if (ret < 0) + dev_err(amd_manager->dev, "bus failed to exit clock stop %d\n", + ret); + amd_manager->clk_stopped = false; + } + } + if (amd_manager->clk_stopped) { + dev_err(amd_manager->dev, "SDW%x clock stop exit failed\n", amd_manager->instance); + return 0; + } + dev_dbg(amd_manager->dev, "SDW%x clock stop exit successful\n", amd_manager->instance); + return 0; +} + +static int __maybe_unused amd_suspend_runtime(struct device *dev) +{ + struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev); + struct sdw_bus *bus = &amd_manager->bus; + int ret; + + if (bus->prop.hw_disabled) { + dev_dbg(bus->dev, "SoundWire manager %d is disabled,\n", + bus->link_id); + return 0; + } + if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { + ret = amd_sdw_clock_stop(amd_manager); + if (ret) + return ret; + } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { + ret = amd_sdw_clock_stop(amd_manager); + if (ret) + return ret; + ret = amd_deinit_sdw_manager(amd_manager); + if (ret) + return ret; + } + return 0; +} + +static int __maybe_unused amd_resume_runtime(struct device *dev) +{ + struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev); + struct sdw_bus *bus = &amd_manager->bus; + int ret; + u32 val; + u32 retry_count = 0; + + if (bus->prop.hw_disabled) { + dev_dbg(bus->dev, "SoundWire manager %d is disabled, ignoring\n", + bus->link_id); + return 0; + } + + if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { + ret = amd_sdw_clock_stop_exit(amd_manager); + if (ret) + return ret; + } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { + val = acp_reg_readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + if (val) { + val |= AMD_SDW_CLK_RESUME_REQ; + acp_reg_writel(val, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + do { + val = acp_reg_readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + if (val & AMD_SDW_CLK_RESUME_DONE) + break; + usleep_range(10, 20); + } while (retry_count++ < AMD_SDW_CLK_STOP_MAX_RETRY_COUNT); + if (val & AMD_SDW_CLK_RESUME_DONE) { + acp_reg_writel(0, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); + amd_manager->clk_stopped = false; + } + } + sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET); + amd_init_sdw_manager(amd_manager); + amd_enable_sdw_interrupts(amd_manager); + ret = amd_enable_sdw_manager(amd_manager); + if (ret) + return ret; + amd_sdw_set_frameshape(amd_manager); + } + return 0; +} + +static const struct dev_pm_ops amd_pm = { + SET_RUNTIME_PM_OPS(amd_suspend_runtime, amd_resume_runtime, NULL) +}; + static struct platform_driver amd_sdw_driver = { .probe = &amd_sdw_manager_probe, .remove = &amd_sdw_manager_remove, .driver = { .name = "amd_sdw_manager", + .pm = &amd_pm, } }; module_platform_driver(amd_sdw_driver); diff --git a/drivers/soundwire/amd_manager.h b/drivers/soundwire/amd_manager.h index 3920648fdc52..93022a325598 100644 --- a/drivers/soundwire/amd_manager.h +++ b/drivers/soundwire/amd_manager.h @@ -187,6 +187,9 @@ #define AMD_SDW0_PAD_KEEPER_DISABLE_MASK 0x1E #define AMD_SDW1_PAD_KEEPER_DISABLE_MASK 0xF #define AMD_SDW_PREQ_INTR_STAT BIT(19) +#define AMD_SDW_CLK_STOP_DONE 1 +#define AMD_SDW_CLK_RESUME_REQ 2 +#define AMD_SDW_CLK_RESUME_DONE 3 enum amd_sdw_cmd_type { AMD_SDW_CMD_PING = 0, diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index df60bc0de6fc..ceecad74aef9 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -8,6 +8,21 @@ #include +/* AMD pm_runtime quirk definitions */ + +/* + * Force the clock to stop(ClockStopMode0) when suspend callback + * is invoked. + */ +#define AMD_SDW_CLK_STOP_MODE 1 + +/* + * Stop the bus when runtime suspend/system level suspend callback + * is invoked. If set, a complete bus reset and re-enumeration will + * be performed when the bus restarts. In-band wake interrupts are + * not supported in this mode. + */ +#define AMD_SDW_POWER_OFF_MODE 2 #define ACP_SDW0 0 #define ACP_SDW1 1 @@ -57,6 +72,7 @@ struct sdw_amd_dai_runtime { * @instance: SoundWire manager instance * @quirks: SoundWire manager quirks * @wake_en_mask: wake enable mask per SoundWire manager + * @clk_stopped: flag set to true when clock is stopped * @power_mode_mask: flag interprets amd SoundWire manager power mode * @dai_runtime_array: dai runtime array */ @@ -86,6 +102,7 @@ struct amd_sdw_manager { u32 quirks; u32 wake_en_mask; u32 power_mode_mask; + bool clk_stopped; struct sdw_amd_dai_runtime **dai_runtime_array; };