From patchwork Wed Oct 11 17:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13417649 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 0C130CDB46A for ; Wed, 11 Oct 2023 17:08:01 +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=A3qJwlmCb3bqthnQHq+xF7VwtaDBA6im5e7l6KOuxP4=; b=kkL Vi4W/ZLdbw/N5D7AQozmGB7esJmqJUNudx3/OLxmnMXYjbPsmqWDy0F/JTiCwoXM2rODrogd6Abgp q/WzZWqdvh6JetmG5cSMp5LtoYMoOx7IwB4j/keH8F9Ktx6yhRnPNnSY2XtFN9dJ1KcpSDLR9ZzCP gEE3n9UmEskzRMT7hq1FOKcph46d9zLUPEV+iWUN8Vpd2E8jrq+wFlcZt9xA2FGsDaQsOuR1n/Al5 7cxX0JO/HnV5dFfWO/k+HmIqHTIC0vGEs/dPlIMPMdxnED07EjMHWXAS0lSBg/9BN5mlQ8Y68JM0d ifhYqqrsqjOpjK3SJ1w0Q69jl0DSuLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqcgD-00GJXk-1I; Wed, 11 Oct 2023 17:07:29 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqcgA-00GJVl-07 for linux-arm-kernel@lists.infradead.org; Wed, 11 Oct 2023 17:07:27 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c737d61a00so199655ad.3 for ; Wed, 11 Oct 2023 10:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1697044040; x=1697648840; darn=lists.infradead.org; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=ayM8Phnozx3dkuOOvwyweoUGjMbWKrFVQL5yMUubUs4=; b=iQ8k7GuqY5MAk4CAwcaSsYUMBjzUY2lptYD11qkBIIu853VZtF7GS+e+Lr95uemrSk eyHPnkrk5mmAiVsatkawwgN7zqMaHihQjNsep1p4l4jXzWJ0dAz6OMJyCSkUG00pX+Ds bi3PWEIWqZ6p+M5Rr3JDWT+gFdm+NlvPGgRyo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697044040; x=1697648840; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ayM8Phnozx3dkuOOvwyweoUGjMbWKrFVQL5yMUubUs4=; b=kWnC3zfJqs0PlddrgohctaXlPrnXk0por7Bt66vcJCizWsQ/zyXTX40xjcPWfcWNWd JtVSECUnhzpqgJcLrRa0Za7Csb081NJcq5f6X+HrQYsIdtuRH/kSpX4Zg06eeKpNDW10 w90jV6sbtGnAiiWjqG0nnIfMs/qn4r6/VPcgzF2oxiBlMjTdG2w+W/i840yB1EZOdVnN tTLBiCkRcgVBAFcEMICBiwg/Sg8R93OMTJ510NecvoZTFTE6MZBowjbFSEZC/63dcaJS /sPhDwIYzBByBEGYa7fSSom42O7lKjhaO6dpH6vg4eOo6bqEk6LXxGEhXk3fZT+dwTeF MTuQ== X-Gm-Message-State: AOJu0YzoM8hiNyapYP31UVMkOClFyVWP1aXqnPEtc/35FKsWeAoW3+Eq qO0CimXvE1ea3QqpNQglS2JcMg== X-Google-Smtp-Source: AGHT+IGFIoD6cw81AoZHWrB0W82iGosieyFGM5kpZVeulD8u0rHAaTEvjtKzgvkjUkm4YgaGsaIcjg== X-Received: by 2002:a17:902:d883:b0:1c9:aac5:df1a with SMTP id b3-20020a170902d88300b001c9aac5df1amr6375926plz.51.1697044040521; Wed, 11 Oct 2023 10:07:20 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id p6-20020a170902e74600b001c9c5a1b477sm68658plf.169.2023.10.11.10.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 10:07:19 -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 v3] pwm: bcm2835: Add support for suspend/resume Date: Wed, 11 Oct 2023 10:07:17 -0700 Message-Id: <20231011170717.3738712-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-20231011_100726_096195_85902161 X-CRM114-Status: GOOD ( 16.60 ) 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 Reviewed-by: Uwe Kleine-König --- Changes in v3: - removed __maybe_unused and use pm_ptr() 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..21ed2f2ebdd0 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 bcm2835_pwm_suspend(struct device *dev) +{ + struct bcm2835_pwm *pc = dev_get_drvdata(dev); + + clk_disable_unprepare(pc->clk); + + return 0; +} + +static int 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 = pm_ptr(&bcm2835_pwm_pm_ops), }, .probe = bcm2835_pwm_probe, .remove_new = bcm2835_pwm_remove,