From patchwork Mon May 31 04:46:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Beranek X-Patchwork-Id: 12288643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80C05C47082 for ; Mon, 31 May 2021 04:48:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 438F9610C9 for ; Mon, 31 May 2021 04:48:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 438F9610C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=prusa3d.cz Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding: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-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RGSZvg2PrMSUc5oy48CUH2Zi/2dvH58S8AVt1a9EwZM=; b=lup8ypTDPqNJ8v HUEjVznoj9FS6PLDdFWJbgyiNWBhf2x4vCYuJrXHadjwhe2S1jAJqHkGe92DWfKN8q28E93FYzb3p 2Cb4ZleJset0ARAp8KdetyTwyYfxAcsM8xe4ozHv/U6J1tyvRckeo6s81GOtUDcQpEVOkIEA/6ztG h+lDZlL7NLfQLVGqxJweJIE0iUbYsVLjWm/16URJLXBg6tPAjTsp2s0c04I6pObyHEHSKMdnCkmMU qdsPwEWFinTfUDUkOStsHw1MIq4/CeZNBwWwCV76N+gt1F6s3apR46+EAqtkeyDwLSV6TYz5hm1WW Wb3UFHSa9I9MvNvgwYKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lnZp8-00AjL1-BK; Mon, 31 May 2021 04:46:46 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lnZoj-00AjHZ-NH for linux-arm-kernel@lists.infradead.org; Mon, 31 May 2021 04:46:24 +0000 Received: by mail-ed1-x530.google.com with SMTP id i13so11932595edb.9 for ; Sun, 30 May 2021 21:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prusa3d-cz.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sz+n+z6h/C9i8J/WRfdsHfGpM50TGPrsItNGlwXy1L0=; b=LmP92wi5WKi+0qVT40ulpznUIqIDGJ4m9797edYzDaLvKu+6u4GcG4OMf1ICTG1geL Vxjf9R2J8uzxgN4NsXTsDJpc4LnytncaQgYVcibxU9N0V2y1DDZFVrrq/hFs/LaZBVCN bZWc3cI1VbuZZbpxE40WlgTz1+jSO9IvWSoA4aMRY+sH3N37x327l/NJa2f6WMFh2518 5owiw+PchTO5T0rxfWI1LptyTzWWOGkIACTjg4kqHQyMWmorxyIwc4udFfPNsQOT+Cyp ZE0tYVQXBnHuKHrG7gDRkt93MUW7c8U/GeWwAys3thG5FEoeJ5TdgrWUXQDX8hZ5bUIH EHWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sz+n+z6h/C9i8J/WRfdsHfGpM50TGPrsItNGlwXy1L0=; b=ppcuegpv1dmWuO/q5s4zqB49hGwoqs8xNbCgKHjVf0CiOmF/mQTPfrDvl8Gesvk9hl Gm5/8Om5DPlB2CA2av82sdRtvwpe2OPZh9aajJJTwQp5tRkTz9fKDBEIFpRmtp66HkP2 F4LjVUXHmC911EL74Xwi9Tga3OJswhZsGD18DQynoyBxZ38i4jJsxvo92VWxVktwvMlq cyq92+DtmYCiNEzLIsWbgf8EjQIQes3TTBJxxZJYPIK7cqDxciANIBC+PsgOBgVDjDUz 6TjpigrtIvRAXM6R7pAYgo9vLogFmHbiVm+bNPROxCGTRWHUnUM2n6U8n3ImjmW8fSDy qysg== X-Gm-Message-State: AOAM531nbubO4S5niefroSP/XkJiEsFZEjeMsrmQjN+Qe3gGXtCTWrUv fzlF6CFbz5EmWbBvtbOlBflq2Q== X-Google-Smtp-Source: ABdhPJzgvk3vLxLu+lNopZjiX2qNGlPgmTIubkdp4O/wIzkbFIDKHP+EWojv/tcrirKPk9eUHUELTg== X-Received: by 2002:aa7:c349:: with SMTP id j9mr15402010edr.48.1622436377511; Sun, 30 May 2021 21:46:17 -0700 (PDT) Received: from zen.local (ip-89-103-215-157.net.upcbroadband.cz. [89.103.215.157]) by smtp.gmail.com with ESMTPSA id h9sm6238376edt.18.2021.05.30.21.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 21:46:16 -0700 (PDT) From: Roman Beranek X-Google-Original-From: Roman Beranek To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Thierry Reding , Emil Lenngren , Pascal Roeleven , Lee Jones , Maxime Ripard , Chen-Yu Tsai , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-sunxi@googlegroups.com Subject: [PATCH 0/6] pwm: sun4i: only wait 2 cycles prior to disabling Date: Mon, 31 May 2021 06:46:02 +0200 Message-Id: <20210531044608.1006024-1-roman.beranek@prusa3d.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210530_214621_779487_F4F55144 X-CRM114-Status: UNSURE ( 9.83 ) X-CRM114-Notice: Please train this message. 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 As Emil Lenngren has previously shown [1], actually only 1-2 cycles of the prescaler-divided clock are necessary to pass before the PWM turns off, not a full period. To avoid having the PWM re-enabled from another thread while asleep, ctrl_lock spinlock was converted to a mutex so that it can be released only after the clock gate has finally been turned on. [1] https://linux-sunxi.org/PWM_Controller_Register_Guide Roman Beranek (6): pwm: sun4i: enable clk prior to getting its rate pwm: sun4i: disable EN bit prior to the delay pwm: sun4i: replace spinlock with a mutex pwm: sun4i: simplify calculation of the delay time pwm: sun4i: shorten the delay to 2 cycles pwm: sun4i: don't delay if the PWM is already off drivers/pwm/pwm-sun4i.c | 56 +++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 30 deletions(-)