From patchwork Mon Oct 9 20:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13414417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F9AECD6136 for ; Mon, 9 Oct 2023 20:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=ISjQDva3l04Fz32IVwwd0dK6pEJ2I7CkZT1m7ADDGf0=; b=D0w yVMdJlWpQK0VkwjDbVJ0NltZzgQNnc3oD5loJCeZ7vjDS+6cgpqcdc+1WJtFvVAq+RL0lrlDhstlY 6pvUXm/h1NsggLWRexKBsK9N5piSPe2dzK/giUHnZY95mMz8y4sxmCLt2FMAOPdCGicg0lRb4i0kT dZOwq8v1cwe/29oJLMf3UDcf+eOzT1FJjsLDVTY1+EUG/kol0vQEF2MoICfTNm+A3tTk4OSua9I5b QiU1kHHnuKRuCofs2Xdlsb3zGb2R5RDrb8TK+BgkRLG1xGyJNzyc9xbIDAf8ED/j3yUPk9Lmxnxwh zU/kCcXu3GX3Pk10pev/zeAXI6Gs2Ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpx5K-00Bb2O-2q; Mon, 09 Oct 2023 20:42:38 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpx5G-00Bb0n-1v for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 20:42:37 +0000 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-4181e268447so32748641cf.1 for ; Mon, 09 Oct 2023 13:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1696884152; x=1697488952; darn=lists.infradead.org; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=J/FBKYxnzLraxUdr81Y8Z3LrlsKphEdG5uodnP+U068=; b=DS7q25DBPrpy7/GrM5VGaKMuTKQYVEiEhP+TMIPUT8KZ6wdQm9DncKysJrgH2hnftt K9sMthN9ISLAXJ5xwY0LXy7LidUgucKD9GifyNhkEiAd3hhzO/MMkNqbXIZagIxNz+SQ wk5w5LFVE1y52Vj+iyitpQpY+kdWf4P/FgenI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696884152; x=1697488952; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=J/FBKYxnzLraxUdr81Y8Z3LrlsKphEdG5uodnP+U068=; b=GDoKym7zW3nFrBqsSXTY80jdWw+TpewwbG+6yul8ryUnP/ihtb2kuPHeKM1lpXuP6Y dLA6vYtQTgujKGRPSZpo0NfgRoU3N7m/SDBHfzdXPSHQ2CFbnWhpwaxzsaidE+AN/OPV HThYM8quEQ10wU2XwzxILO2l6WLYN8I0Oo3krT1skR5rGp0u4Mz1tDaLXtqU1+seqk4n kj5CbmRVPnxa5oJm0rzppFrDLSiPZf8wTfdn0g7LBMfqUSOAg3xfsiMOAhL6DLz3L4d/ IKDm/CSUMQo0vADLbTddJV1L+opRUA1bv82DOZZsG7WIa/LtiAQJkbKBqaVc3EZjx7Xe Entw== X-Gm-Message-State: AOJu0Yzuz+iKZtbxu0+xMbJqul0QySLreGmY5FZc6UMSABgK9ilCWqDk ywDnWmE6IJkkZh2nbqcPOGydlw== X-Google-Smtp-Source: AGHT+IGitQZigQOV8jF0NpM9P7N0RQuLQO5jc3KoXDJU9IxUR/tSVv/R9LVUS1ob0426rAZpq02CGw== X-Received: by 2002:ac8:5b49:0:b0:418:bd5:f682 with SMTP id n9-20020ac85b49000000b004180bd5f682mr24003565qtw.33.1696884152308; Mon, 09 Oct 2023 13:42:32 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id w7-20020ac84d07000000b0040399fb5ef3sm3973703qtv.0.2023.10.09.13.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:42:31 -0700 (PDT) From: Florian Fainelli To: linux-pwm@vger.kernel.org Cc: Florian Fainelli , Angus Clark , Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] pwm: bcm2835: Add support for suspend/resume Date: Mon, 9 Oct 2023 13:42:26 -0700 Message-Id: <20231009204226.3224521-1-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231009_134234_635628_EAFF4BE9 X-CRM114-Status: GOOD ( 16.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Similar to other drivers, we need to make sure that the clock is disabled during suspend and re-enabled during resume. Reported-by: Angus Clark Signed-off-by: Florian Fainelli --- Changes in v2: - use DEFINE_SIMPLE_DEV_PM_OPS as suggested by Uwe drivers/pwm/pwm-bcm2835.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c index bdfc2a5ec0d6..938f993ae746 100644 --- a/drivers/pwm/pwm-bcm2835.c +++ b/drivers/pwm/pwm-bcm2835.c @@ -182,6 +182,25 @@ static void bcm2835_pwm_remove(struct platform_device *pdev) clk_disable_unprepare(pc->clk); } +static int __maybe_unused bcm2835_pwm_suspend(struct device *dev) +{ + struct bcm2835_pwm *pc = dev_get_drvdata(dev); + + clk_disable_unprepare(pc->clk); + + return 0; +} + +static int __maybe_unused bcm2835_pwm_resume(struct device *dev) +{ + struct bcm2835_pwm *pc = dev_get_drvdata(dev); + + return clk_prepare_enable(pc->clk); +} + +static DEFINE_SIMPLE_DEV_PM_OPS(bcm2835_pwm_pm_ops, bcm2835_pwm_suspend, + bcm2835_pwm_resume); + static const struct of_device_id bcm2835_pwm_of_match[] = { { .compatible = "brcm,bcm2835-pwm", }, { /* sentinel */ } @@ -192,6 +211,7 @@ static struct platform_driver bcm2835_pwm_driver = { .driver = { .name = "bcm2835-pwm", .of_match_table = bcm2835_pwm_of_match, + .pm = &bcm2835_pwm_pm_ops, }, .probe = bcm2835_pwm_probe, .remove_new = bcm2835_pwm_remove,