From patchwork Thu Oct 5 17:15:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13410504 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 B4444E92719 for ; Thu, 5 Oct 2023 17:17:47 +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=SaOC7jUmKV72ArnU2ePdHwchMhum/b8GAu9gc3ujOAw=; b=oo9 ANg22ArUriq0YVP4ZQb986868aYsgNj0PDvp1MBbFFan1Eno0iEweMEap0Fo7OadzOnvmKAsmvfn4 dnvunARJyjk082QyVME8rTZ+NU0x5US/iIy24JCULmJ9IrwyYgCkhbMUfva3s0IaqNyOq6n/l1Sv+ CbgVEa5DVdW3or7srFqbv9OpVyHNpayMkB2L/WMAIU1tFKKbeABF57RJjfcmhomwLyJRrK26Wwi5o 98MYN2JFjsdol7Xed8WQfvLPF2htnYr3S0XK1dOIqHhqCmiQtVCzrXHZdMcS779TgBOyYg7E/s3rj xbrjQZaWEY6ue70XtZj7Lnsp/zAbDdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoRyS-004C7j-2Q; Thu, 05 Oct 2023 17:17:20 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoRyQ-004C6j-1G for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 17:17:19 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-690b7cb71aeso990411b3a.0 for ; Thu, 05 Oct 2023 10:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1696526236; x=1697131036; darn=lists.infradead.org; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=VqWSRly1fu24dv8afaGJ7mZpBFd7A1AzCA4+gyir6ko=; b=c/UQ5n2QaJ9xY4wS1UAJMLZNB3cm/wAOt4S2cqR9pC5a36DFFCi8E7KRGEEriOWwb3 r07TZ7q7toxVGnsisNtaVHqCXJduLwYvnsfnNGRyg1tD9JsLLMC/6vygAqggY4Rh3MXk c9JBU++IekdKK47yv3a6slYI0g94jtaGTSQn0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696526236; x=1697131036; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VqWSRly1fu24dv8afaGJ7mZpBFd7A1AzCA4+gyir6ko=; b=ab0gd9tIykx8CioWfvh16J4ZbdlUOSC2atAynzVR3P91XdqAQAHt2I5DQMM+R8k1rn +EErAAWV4u+jOuAumsBvcyJWz0mUSw1FJWXu0yD3zb0PV8cS1ehLOwmsXEkiolRftPZn fqxbagPYfoRMQDmoEbxN6eI6KM6E/Tn87NSbnt8HmPsGcslcOTPOPcp7lbACydwsX9X1 iOXCsakZRGWbxM4lJny8WvUouBEfeliARYmqB8CqNcwrzjjAcSSUW9GJ0uZG08MLGrsD TtwMtrS1yG/Cxjq+/Uf4BQdhO7IFl6tjQM5bCAapytfzZbWh2GHd+oJ6Uph+HnmAK8KK X95g== X-Gm-Message-State: AOJu0YzpUybyrtU9H0AC2e4itE1JJVmSvXe3CMGDCoXgVVMqNXj/lYzG 7QikfNl4tLKh5AxgKedqzhRq0g== X-Google-Smtp-Source: AGHT+IFU2mE+hCk0C4C4wsXX3q7KJ1yEKZ1f0UW3sESJgVBHIzdwPq4vVBQ75id+MBakyFjYmj6/1w== X-Received: by 2002:a05:6a00:a1b:b0:68f:cbd3:5b01 with SMTP id p27-20020a056a000a1b00b0068fcbd35b01mr3106904pfh.13.1696526236428; Thu, 05 Oct 2023 10:17:16 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y36-20020a056a001ca400b0069b772c4325sm189888pfw.87.2023.10.05.10.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:17:15 -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?= , Ray Jui , Scott Branden , Broadcom internal kernel review list , 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] pwm: bcm2835: Add support for suspend/resume Date: Thu, 5 Oct 2023 10:15:15 -0700 Message-Id: <20231005171516.2908961-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-20231005_101718_430758_F3262FAA X-CRM114-Status: GOOD ( 15.56 ) 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 --- 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..46c59317ba54 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 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,