From patchwork Sun Nov 24 17:29:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11259239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA31D112B for ; Sun, 24 Nov 2019 17:30:22 +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 97E89207FD for ; Sun, 24 Nov 2019 17:30:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UjCwR6D8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R4nVdGmb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97E89207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wHCexr86yLU1a56uutSWDEapNK+WldmzLsJtgV5eHek=; b=UjCwR6D8oM4tyW 0+6d9x1wP+DbQQC8+bv/dPTefippvMbYHS3+OYGIbU45smwViff/DzbY+IwdmgmNEXW5U3svzp4hJ EjhEX7n19nO0wPDX1fJYVKa5Tv6QAdNr4F9iS7Lf25SHl3bEgQeTA2mns3xo7yharad2zSq7JV7KB fKelEMxbwgFm8xXH/QLwGYrmTtzYB4Lz74WV3mxRO6tdMrCn7K5csXVlBpBDXRenWNmvxFktvNC/0 M5OEeP0Q4QtFgRAmBzJ6D2kvCy3OOTUxw18z73sae2SRZARWpxrA6VjI0RMFacIgVoUTkr7Hg+h9k RHGUbr14aFJ6VHFns2cw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYviC-0005vG-Oc; Sun, 24 Nov 2019 17:30:16 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvhz-0004aa-Ed for linux-arm-kernel@lists.infradead.org; Sun, 24 Nov 2019 17:30:04 +0000 Received: by mail-wr1-x441.google.com with SMTP id b18so14667583wrj.8 for ; Sun, 24 Nov 2019 09:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZYFwEIE1V4FYviy3HfGWOu1YC137BU6qFV2JCNaspsM=; b=R4nVdGmbxb/sU9t4pMb9ieOCb0Ig3onMEUMKW67rm055djQFNNus9F8m6tppSUZrKf 7k1DLC0T1bLyQAvrNNYM7A3w8a/7USxIeMNo+2zv3Sznhunnkxz9IAtkXkqbJJMBH+mI GKbvmeFuf+wwge4w4XFh+Ycuh7Adx5t3+Etr0qgz5WRDb81N3CJ07M+/lzuL5t1y5q6E ERyec0nPt5gDm90ld+tuD8rtRoPJpb9eEDMt1uHwbSw4fu/0rl9deUSLH5YcT8OtErfS qJbExGUdP0ZbHFoDoyhu5xK/mPSty0f3qtIeHxEFYk6RpO+LYRob54X/OJD1bBnX6gk7 zUvQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZYFwEIE1V4FYviy3HfGWOu1YC137BU6qFV2JCNaspsM=; b=uPlwAnp7WJLkMI7pkIbQWciaVwRiSPqIxw6UQXdsDs/dkUAMo6LhT6hGCPLjrAgcmR yU0jwjCkjAGXo2d88Meg25uSaDtEobxnPf787Gx6X4ZAJspBlCWl6uj/i6qDl2QxZJKT GJh8tzY8T9aqjTDXHJ2r0JP8mf2K1VDjJ+spS6ePE42h2Q/VlOGzakflWTKhoR5p9RBr 7UwXP4fikfhF4eiAhcnTgNLDbfjMp0aj4/6PPkQ01IWPlWIhM2A4MrGbaIUECqM/V2AQ aFI7AHa3HXCjexhlkUMh6zzdSYXPEBSxPzFVSQ3gWAn+omzwavdUb0PUZPd4wcxo4YUD 2S/g== X-Gm-Message-State: APjAAAV4O947QcXl6UQXVjlYb6VlJNLDsbI3lWoMHyjRT5An8gYwPxe9 UBvLZJCFGo81ebpj4oSX8Eo= X-Google-Smtp-Source: APXvYqy28wuYUH31pkTeF6gqI821J6tzCh9ACuT8BpF1tD5bYMQvaf6TVGG/7ORii+bAKQDExzXHmQ== X-Received: by 2002:adf:e550:: with SMTP id z16mr4175991wrm.315.1574616601645; Sun, 24 Nov 2019 09:30:01 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::4e2b:d7ca]) by smtp.gmail.com with ESMTPSA id n13sm5537275wmi.25.2019.11.24.09.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 09:30:01 -0800 (PST) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel Subject: [PATCH v9 1/6] pwm: sun4i: Add an optional probe for reset line Date: Sun, 24 Nov 2019 18:29:03 +0100 Message-Id: <20191124172908.10804-2-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191124172908.10804-1-peron.clem@gmail.com> References: <20191124172908.10804-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191124_093003_501046_2E851EDB X-CRM114-Status: GOOD ( 16.71 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (peron.clem[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Jernej Skrabec , linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, =?utf-8?b?Q2w=?= =?utf-8?b?w6ltZW50IFDDqXJvbg==?= , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Jernej Skrabec H6 PWM core needs deasserted reset line in order to work. Add an optional probe for it. Signed-off-by: Jernej Skrabec Reviewed-by: Uwe Kleine-König Signed-off-by: Clément Péron --- drivers/pwm/pwm-sun4i.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 581d23287333..487899d4cc3f 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -78,6 +79,7 @@ struct sun4i_pwm_data { struct sun4i_pwm_chip { struct pwm_chip chip; struct clk *clk; + struct reset_control *rst; void __iomem *base; spinlock_t ctrl_lock; const struct sun4i_pwm_data *data; @@ -364,6 +366,22 @@ static int sun4i_pwm_probe(struct platform_device *pdev) if (IS_ERR(pwm->clk)) return PTR_ERR(pwm->clk); + pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL); + if (IS_ERR(pwm->rst)) { + if (PTR_ERR(pwm->rst) != -EPROBE_DEFER) + dev_err(&pdev->dev, "get reset failed %pe\n", + pwm->rst); + return PTR_ERR(pwm->rst); + } + + /* Deassert reset */ + ret = reset_control_deassert(pwm->rst); + if (ret) { + dev_err(&pdev->dev, "cannot deassert reset control: %pe\n", + ERR_PTR(ret)); + return ret; + } + pwm->chip.dev = &pdev->dev; pwm->chip.ops = &sun4i_pwm_ops; pwm->chip.base = -1; @@ -376,19 +394,31 @@ static int sun4i_pwm_probe(struct platform_device *pdev) ret = pwmchip_add(&pwm->chip); if (ret < 0) { dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret); - return ret; + goto err_pwm_add; } platform_set_drvdata(pdev, pwm); return 0; + +err_pwm_add: + reset_control_assert(pwm->rst); + + return ret; } static int sun4i_pwm_remove(struct platform_device *pdev) { struct sun4i_pwm_chip *pwm = platform_get_drvdata(pdev); + int ret; + + ret = pwmchip_remove(&pwm->chip); + if (ret) + return ret; + + reset_control_assert(pwm->rst); - return pwmchip_remove(&pwm->chip); + return 0; } static struct platform_driver sun4i_pwm_driver = { From patchwork Sun Nov 24 17:29:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11259241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A985C112B for ; Sun, 24 Nov 2019 17:30:37 +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 86CA8207FD for ; Sun, 24 Nov 2019 17:30:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="s7zj2u+a"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JxvIqrQs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86CA8207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V4C12M1m7Ahf4ap1yDIxpNKDGtqR3nZM7RZ7ctpslAg=; b=s7zj2u+akWK37W 1+pdebldHYwqCTxqVom3qQwMiq3Ug01Qx65ddNAOdfW/7EAwRcQhkZHuUGZcMfdEdhGrO8X+jxFsG A0sm21r0ZWj5cKgGVHJVEwRhfkt4fOZrnVbJ9zcOezgWnogt+jqnaxKB5L7SqFllgePIWYrXYRKNe RlU25mgr3NS1DS1wi3ttHEs3ryrQt/qMWoLMhXOeki83UfX65XdRBSvPhPOkvvYvYe4fx9Paa9jCk qqqoqOTWGxVhZYer22/vZA9qv9csJDKki6XBgTH8IFyddcTUjLd+iQ2p8e3HGTtuTKyaezLqlN1eT t1vLlEUwPQE1aGJ+9zXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYviV-0006EF-Ay; Sun, 24 Nov 2019 17:30:35 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvi1-0004kV-GG for linux-arm-kernel@lists.infradead.org; Sun, 24 Nov 2019 17:30:06 +0000 Received: by mail-wm1-x344.google.com with SMTP id b11so12697201wmb.5 for ; Sun, 24 Nov 2019 09:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=11OJgFf0c1fRpm2QKhR90dd74bTjmn3YLFrj0+iDgME=; b=JxvIqrQsR3EH7tVEg3Mt/EsgCifsBPlln+APafYJtr99HPNoUtYqSCBEkFbeyc9wZt X97dKcORrbfwyvlS4808HTu/f031TGUSxsGrbitSrqk1xKGMHlywKBKZjQTAo53+SSAr 4AnJtK1d3ENQerbwCjewLj2UDU+9fSHMniqXxpjJg2ME6TKq8N16wqEcqnfezw7o/p4/ DxvPqwiqHS+fBB8vUsFpSNCTw3DtE5KrZHz+joqDk/1VFhevOT5XuKXdu4ZtQmz/T+UV HXDVHStVlHpDndteZ1icmtJyGiWFwS6B/BkRpBVS6XGJdijuTXb/LXqN4EW615naEmB9 wtZA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=11OJgFf0c1fRpm2QKhR90dd74bTjmn3YLFrj0+iDgME=; b=jdJI+QedslmbxUcR/wOnzWTfHC9MiPPCkfXgmdAOKJwKs5bPoc3D924KBUQzbu9n5m FHP1bDnx0c0NrxchWdEUbCvABi7Tu2iMZkEXm3HiGrvTklk+T5Qerrj7Iuvf3zExaeWm V8MJukzo/8EXtkHH6Zg8WrJN3aNq4shYJSHq8x1pKE5L7iFVybFBh9dG5l7R4PCIa+3K krzrpynrzdRZRzYpsl6CZvMqCST3pb7/rpuRfoutg0Xsl5wSsgK4HxpywltLOG+EdQQC YsMSklq++wvNsUlK5WpVUvfDGWo7GSnorjUWRKwWMVSn3QNCHhFwe2lTl6U9FBlKJwXz Pmbw== X-Gm-Message-State: APjAAAXFpMu4N/PKF1NpXsHes+uqz4myLO6YCaLva+TbCnomVcUVtvB4 uMCe7EBE97WfaxoHQjZpeBY= X-Google-Smtp-Source: APXvYqxCILgcleo6Lk2jlnRahagfAhZ8VPpjVIezqiUklQ+tzkHAg3+u75onarnPMn0IhMj0G1Nqkg== X-Received: by 2002:a7b:cd86:: with SMTP id y6mr12934898wmj.30.1574616603668; Sun, 24 Nov 2019 09:30:03 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::4e2b:d7ca]) by smtp.gmail.com with ESMTPSA id n13sm5537275wmi.25.2019.11.24.09.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 09:30:03 -0800 (PST) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel Subject: [PATCH v9 2/6] pwm: sun4i: Prefer "mod" clock to unnamed Date: Sun, 24 Nov 2019 18:29:04 +0100 Message-Id: <20191124172908.10804-3-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191124172908.10804-1-peron.clem@gmail.com> References: <20191124172908.10804-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191124_093005_560289_586D2920 X-CRM114-Status: GOOD ( 15.98 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (peron.clem[at]gmail.com) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-sunxi@googlegroups.com, =?utf-8?b?Q2w=?= =?utf-8?b?w6ltZW50IFDDqXJvbg==?= , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org New device tree bindings called the source clock of the module "mod" when several clocks are defined. Try to get a clock called "mod" if nothing is found try to get an unnamed clock. Reviewed-by: Uwe Kleine-König Signed-off-by: Clément Péron --- drivers/pwm/pwm-sun4i.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 487899d4cc3f..80026167044b 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -362,9 +362,34 @@ static int sun4i_pwm_probe(struct platform_device *pdev) if (IS_ERR(pwm->base)) return PTR_ERR(pwm->base); - pwm->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(pwm->clk)) + /* + * All hardware variants need a source clock that is divided and + * then feeds the counter that defines the output wave form. In the + * device tree this clock is either unnamed or called "mod". + * Some variants (e.g. H6) need another clock to access the + * hardware registers; this is called "bus". + * So we request "mod" first (and ignore the corner case that a + * parent provides a "mod" clock while the right one would be the + * unnamed one of the PWM device) and if this is not found we fall + * back to the first clock of the PWM. + */ + pwm->clk = devm_clk_get_optional(&pdev->dev, "mod"); + if (IS_ERR(pwm->clk)) { + if (PTR_ERR(pwm->rst) != -EPROBE_DEFER) + dev_err(&pdev->dev, "get mod clock failed %pe\n", + pwm->clk); return PTR_ERR(pwm->clk); + } + + if (!pwm->clk) { + pwm->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(pwm->clk)) { + if (PTR_ERR(pwm->rst) != -EPROBE_DEFER) + dev_err(&pdev->dev, "get unnamed clock failed %pe\n", + pwm->clk); + return PTR_ERR(pwm->clk); + } + } pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL); if (IS_ERR(pwm->rst)) { From patchwork Sun Nov 24 17:29:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11259243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD227913 for ; Sun, 24 Nov 2019 17:30:55 +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 8A8A5207FC for ; Sun, 24 Nov 2019 17:30:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OnHGStlw"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UqEa69xK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A8A5207FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eMwcJAM8xzMCwhNr5/amxCwpsltLlLyvapitDqamjzg=; b=OnHGStlwwBqM4c tQcLeih6enVzTKatUWDyKzu/CeuYx8geM6DcEsnuSSJjtg6pH3Yv/OJarMoYDR2E7cxYxWUZ6R/Gg yJAjDuV7IEtqWC35ldV2zKr/wvRgKDxC3d6d1Rg5oe7HYi8YKCg9ob+EnExtJStfGC5Pu8YNlMcbw DrUbOFQh6xMrhktHehGMxzwul3jp4hTwCeNHdQpCcElj1q6T657LDmdGr6UkU5aSKRAUzjG7wvRq4 fMdo5aTGmSUbiUKwz3WFqJL4ydW09SHAwsyKmG6367ylMoRkX7oZ9UCdgVZEUaDL3noF4W52EDTfw k16PKfK5aSQ3iZVe+qCg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvij-0006R9-Ik; Sun, 24 Nov 2019 17:30:49 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvi2-0004y7-Rd for linux-arm-kernel@lists.infradead.org; Sun, 24 Nov 2019 17:30:08 +0000 Received: by mail-wm1-x341.google.com with SMTP id t26so13121338wmi.4 for ; Sun, 24 Nov 2019 09:30:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sr+7BNL0b4tCp1MqDsXudPxzWoZbpaPXSrRxNlurcYk=; b=UqEa69xKeg3cqB4VbMFljhQGtuxAd10jRTcPE0LGk4j/hSErxDTUllZ/GrJa/FbIXG ZVT2g7Iv0pXgaqBE3UOEnoydCDGbMzmteXCcELyEpn+smCmGGRiT2J8/oW/+cacN7VnC zTzpErhnp/KBF7MCToR0Zdrk0C1rAOdg9fACXZEh9BFypwjVuXFPEKW/N0ZHME5X4l7n eX4kXDzdAA6JeSzhLoWOm3XEEazDC6+/lbCzA1bVcUUYvZ7tGQQ5OdD8lk56bsETe6eY YMm00Y9+IuadMtL4FawcIBSBWvHNbHtqgVoCsurLldWkwT4PL6f6QZyOJXhJXcOg/z7d HXuA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sr+7BNL0b4tCp1MqDsXudPxzWoZbpaPXSrRxNlurcYk=; b=uLIfCMaAP6wZAmJjXBfaR4POLLLBfSeqCimKVO1rQRylrj1PuUZh9Vj/s/OblRyuPK rnBIA1Yz9oOPa9Q0RcYv/sHySNIu8ezCjPPGejIREqpSGjrbQtwAHCvQZNARMhAleTpQ ozFETkIURt4tUsOp2VLcZ5U57tnKfNPdl3aLy5rRtvL1rVOuGX/2Xgvu7JDdMl1Hs5EW Q6ur/S/H8voHFQDIIUwK9QaBkiSTOCobVVe3wnn6QbwiBEOgiZTwhN7GwFA0tSVBEbZP 8A/w6BUDIQaE6PAPZwS9u6Oewmu/bLaZxNeonIMiLJC5puHbRIf8OrPKMI7/3VOYT4bS MHbA== X-Gm-Message-State: APjAAAWRiVYu8foI/JgRh8Yvr/zMhajH1zeeBGGK6xKUVw50W8LM9a2K SPiTE57gwkxQ6P8XbqU4vmI= X-Google-Smtp-Source: APXvYqwb7kqkYB4bJbTmfa2R2ggNhznLIfWi1+2SWPBX/8mre7n4Sp7dEOjIC8bHGA4RcFkWR4cteA== X-Received: by 2002:a7b:c416:: with SMTP id k22mr7117238wmi.10.1574616605112; Sun, 24 Nov 2019 09:30:05 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::4e2b:d7ca]) by smtp.gmail.com with ESMTPSA id n13sm5537275wmi.25.2019.11.24.09.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 09:30:04 -0800 (PST) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel Subject: [PATCH v9 3/6] pwm: sun4i: Add an optional probe for bus clock Date: Sun, 24 Nov 2019 18:29:05 +0100 Message-Id: <20191124172908.10804-4-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191124172908.10804-1-peron.clem@gmail.com> References: <20191124172908.10804-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191124_093006_919988_E79BF389 X-CRM114-Status: GOOD ( 13.89 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (peron.clem[at]gmail.com) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Jernej Skrabec , linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, =?utf-8?b?Q2w=?= =?utf-8?b?w6ltZW50IFDDqXJvbg==?= , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Jernej Skrabec H6 PWM core needs bus clock to be enabled in order to work. Add an optional probe for it. Signed-off-by: Jernej Skrabec Signed-off-by: Clément Péron Reviewed-by: Uwe Kleine-König --- drivers/pwm/pwm-sun4i.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 80026167044b..a6727dd89e28 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -78,6 +78,7 @@ struct sun4i_pwm_data { struct sun4i_pwm_chip { struct pwm_chip chip; + struct clk *bus_clk; struct clk *clk; struct reset_control *rst; void __iomem *base; @@ -391,6 +392,14 @@ static int sun4i_pwm_probe(struct platform_device *pdev) } } + pwm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus"); + if (IS_ERR(pwm->bus_clk)) { + if (PTR_ERR(pwm->rst) != -EPROBE_DEFER) + dev_err(&pdev->dev, "get bus clock failed %pe\n", + pwm->bus_clk); + return PTR_ERR(pwm->bus_clk); + } + pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL); if (IS_ERR(pwm->rst)) { if (PTR_ERR(pwm->rst) != -EPROBE_DEFER) @@ -407,6 +416,17 @@ static int sun4i_pwm_probe(struct platform_device *pdev) return ret; } + /* + * We're keeping the bus clock on for the sake of simplicity. + * Actually it only needs to be on for hardware register accesses. + */ + ret = clk_prepare_enable(pwm->bus_clk); + if (ret) { + dev_err(&pdev->dev, "cannot prepare and enable bus_clk %pe\n", + ERR_PTR(ret)); + goto err_bus; + } + pwm->chip.dev = &pdev->dev; pwm->chip.ops = &sun4i_pwm_ops; pwm->chip.base = -1; @@ -427,6 +447,8 @@ static int sun4i_pwm_probe(struct platform_device *pdev) return 0; err_pwm_add: + clk_disable_unprepare(pwm->bus_clk); +err_bus: reset_control_assert(pwm->rst); return ret; @@ -441,6 +463,7 @@ static int sun4i_pwm_remove(struct platform_device *pdev) if (ret) return ret; + clk_disable_unprepare(pwm->bus_clk); reset_control_assert(pwm->rst); return 0; From patchwork Sun Nov 24 17:29:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11259245 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 969CE112B for ; Sun, 24 Nov 2019 17:31:05 +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 73E0A207FC for ; Sun, 24 Nov 2019 17:31:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="d+OtIBVG"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BNXw7SGy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73E0A207FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=egR5Yx8Fbs8Uu3yzupVg+B9GYpknZZeRpmLzBRsVYqk=; b=d+OtIBVGYJjS0H nH30sg+t2ngk4hN9Kz0RLNywjMDSC5EFwE0q82aLPQ9OTWiiJBn1l6qA+qDUiP1YRzib0lerWF9Vu ukOm9nNHksF6t5ECa2I2rZ0w7OBnxio31WfA6WZ8saQWXSRvU/OKdpKiD5PXFmjRSjOufCFdom4Pe l2snxXkCkdl2smS598lQdt+9xI52Axhws/d0UPmjszgCUkpy2mBe2RvWhrUcoVxxx54WSu/TyBc8J YRc8RhwRw3G8zQA0CaSS33L+4iQovHHe8BiNfDcJj2wFc4yxQ2L2wXS5TTc65G4i7JZT1EAFopKbU 5Q31BqLqy0wMfuWR0faQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvix-0006eo-2n; Sun, 24 Nov 2019 17:31:03 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvi5-0005Gs-U4 for linux-arm-kernel@lists.infradead.org; Sun, 24 Nov 2019 17:30:11 +0000 Received: by mail-wr1-x442.google.com with SMTP id t2so14726309wrr.1 for ; Sun, 24 Nov 2019 09:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kBIOZ347etSnW61gnUIaBM64Cedw0cl5jNO3eKEASaI=; b=BNXw7SGybu8K/BnOo/JmbYr3H+qeKULqXTZlFkPQeXtapTFXumcRzWWa5szX8gIRPp l7uDSFr5mU//Kl4U1JBwkwBjsK02e0mNwuLEk2pVhO40nb5ajspahtr7bqep6axQwhEi gzxBVD9Ec9ZOrVxntjnXGO7qAhgNPSeB/sxaiJrNudcMIFeRvMfLGrgl+Mu2kNQDOACB ArL/wo5SGjbWfA6sc7bDNvXpx20xYDg4U2ml/G8QWLADeK20UgsMFIgpjrtSRLj/J/oI yBW3k8s/2isjfXEOwqii/tWcnLSqOJBKgs2pQxGy6weYm6URBoVaUUFzdnry/7ToZdGL 9vIQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=kBIOZ347etSnW61gnUIaBM64Cedw0cl5jNO3eKEASaI=; b=j9E/umAaK5zpwsMkuEP3mmpuFchQyURGEg+ZP/bwtNgp2T/czQZ5PqFMQS7zNxMPTh Di6zSvvxGBmE00yBTNj4DlFkBLixMhA69iHeLDGOmk2eQRB/LArD48vH1o6hWKKowIXc E+zRq0iTH3yLgF4JH0z4I7/HJSV6/e8f4/z8wePZes73v8iVTDqL+SSz6aZ8H+lkorYm C+Rz29m36kjL+IQ+OrscSvvpggLZu5snHC0xCHSL4gJhyF3kt1YmdX++ni+HTtbc1tTf f4W4tLI3gSI+BvaFm9XRGdQHctEZVV9gmYpQDIo0qEGJMj5SCoK4cMoTnGJSXKg9/hDr mckQ== X-Gm-Message-State: APjAAAUVHxR0tWSC6hKL/2q25KzhWhQ77GlbrOOHIC7XckF0mn3q1Qf5 8HKWVYFrBqupHPi3jReq6yU= X-Google-Smtp-Source: APXvYqzn2w6E+vLemwZDNa1gBjr8f2SWkG2H6wnWdo2EcpqrquGJr5ycgzX0pUhtms7s/GZ6Vx7wGg== X-Received: by 2002:a5d:55c5:: with SMTP id i5mr29179656wrw.385.1574616607934; Sun, 24 Nov 2019 09:30:07 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::4e2b:d7ca]) by smtp.gmail.com with ESMTPSA id n13sm5537275wmi.25.2019.11.24.09.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 09:30:07 -0800 (PST) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel Subject: [PATCH v9 4/6] pwm: sun4i: Always calculate params when applying new parameters Date: Sun, 24 Nov 2019 18:29:06 +0100 Message-Id: <20191124172908.10804-5-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191124172908.10804-1-peron.clem@gmail.com> References: <20191124172908.10804-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191124_093010_176135_02AF70FA X-CRM114-Status: GOOD ( 15.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (peron.clem[at]gmail.com) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-sunxi@googlegroups.com, =?utf-8?b?Q2w=?= =?utf-8?b?w6ltZW50IFDDqXJvbg==?= , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Bypass mode will require to be re-calculated when the pwm state is changed. Remove the condition so pwm_sun4i_calculate is always called. Reviewed-by: Uwe Kleine-König Signed-off-by: Clément Péron --- drivers/pwm/pwm-sun4i.c | 52 ++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index a6727dd89e28..e369b5a398f4 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -202,9 +202,9 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, { struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip); struct pwm_state cstate; - u32 ctrl; + u32 ctrl, duty, period, val; int ret; - unsigned int delay_us; + unsigned int delay_us, prescaler; unsigned long now; pwm_get_state(pwm, &cstate); @@ -220,43 +220,37 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, spin_lock(&sun4i_pwm->ctrl_lock); ctrl = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG); - if ((cstate.period != state->period) || - (cstate.duty_cycle != state->duty_cycle)) { - u32 period, duty, val; - unsigned int prescaler; - - ret = sun4i_pwm_calculate(sun4i_pwm, state, - &duty, &period, &prescaler); - if (ret) { - dev_err(chip->dev, "period exceeds the maximum value\n"); - spin_unlock(&sun4i_pwm->ctrl_lock); - if (!cstate.enabled) - clk_disable_unprepare(sun4i_pwm->clk); - return ret; - } - - if (PWM_REG_PRESCAL(ctrl, pwm->hwpwm) != prescaler) { - /* Prescaler changed, the clock has to be gated */ - ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm); - sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG); + ret = sun4i_pwm_calculate(sun4i_pwm, state, &duty, &period, &prescaler); + if (ret) { + dev_err(chip->dev, "period exceeds the maximum value\n"); + spin_unlock(&sun4i_pwm->ctrl_lock); + if (!cstate.enabled) + clk_disable_unprepare(sun4i_pwm->clk); + return ret; + } - ctrl &= ~BIT_CH(PWM_PRESCAL_MASK, pwm->hwpwm); - ctrl |= BIT_CH(prescaler, pwm->hwpwm); - } + if (PWM_REG_PRESCAL(ctrl, pwm->hwpwm) != prescaler) { + /* Prescaler changed, the clock has to be gated */ + ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm); + sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG); - val = (duty & PWM_DTY_MASK) | PWM_PRD(period); - sun4i_pwm_writel(sun4i_pwm, val, PWM_CH_PRD(pwm->hwpwm)); - sun4i_pwm->next_period[pwm->hwpwm] = jiffies + - usecs_to_jiffies(cstate.period / 1000 + 1); - sun4i_pwm->needs_delay[pwm->hwpwm] = true; + ctrl &= ~BIT_CH(PWM_PRESCAL_MASK, pwm->hwpwm); + ctrl |= BIT_CH(prescaler, pwm->hwpwm); } + val = (duty & PWM_DTY_MASK) | PWM_PRD(period); + sun4i_pwm_writel(sun4i_pwm, val, PWM_CH_PRD(pwm->hwpwm)); + sun4i_pwm->next_period[pwm->hwpwm] = jiffies + + usecs_to_jiffies(cstate.period / 1000 + 1); + sun4i_pwm->needs_delay[pwm->hwpwm] = true; + if (state->polarity != PWM_POLARITY_NORMAL) ctrl &= ~BIT_CH(PWM_ACT_STATE, pwm->hwpwm); else ctrl |= BIT_CH(PWM_ACT_STATE, pwm->hwpwm); ctrl |= BIT_CH(PWM_CLK_GATING, pwm->hwpwm); + if (state->enabled) { ctrl |= BIT_CH(PWM_EN, pwm->hwpwm); } else if (!sun4i_pwm->needs_delay[pwm->hwpwm]) { From patchwork Sun Nov 24 17:29:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11259247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56E2E112B for ; Sun, 24 Nov 2019 17:31:29 +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 F0182207FD for ; Sun, 24 Nov 2019 17:31:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AzXdp5vB"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kkUrmLRk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0182207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SZUAh5ehzkWuIR8d5aCwR/18XhtIX7lNPqZThR7cOlI=; b=AzXdp5vBjikjzq V9obBBxm+0JjsyirGnoPfbHY0bVzzdbHqJfxsJiUAelgeUsKeXsVtDUWW+oFvHOPLdyyXZia8U/NR /Zv/6UygeCHyqM+QUO0p0/YWOTLJpQ9Jzy3mKElitvZ4E3bEtX+TcgNE6IJnP6rTCKKFJ6B+Bj8Fy NYHrDJGTGy7Vbi1LSbiymiI7SgOnPFi2il6tO3kI7xgWJW4N6EDAFNo8CEj12r+W7IL0JiTlV9xnF 5rixqpXMN9EyJt7YImI+JO3GOli2xhLr3EIo4M1ObT7GSYjKSjo32HyMvyYKbqux4S+KlhZTQAOBJ Yn6M+0pdGAaPlzQ2C0CQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvjJ-0006zd-JA; Sun, 24 Nov 2019 17:31:25 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvi7-0005PX-CY for linux-arm-kernel@lists.infradead.org; Sun, 24 Nov 2019 17:30:13 +0000 Received: by mail-wr1-x441.google.com with SMTP id 4so11361519wro.7 for ; Sun, 24 Nov 2019 09:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cYsxEdpSqsCpJgRGtsBvxG3DA2QGQ1mItmXFyJ8ZZGg=; b=kkUrmLRkmIfdWLL6w/h0QyoF7udOjF3phgyUsR+YWArdacOGLGdCniDOksWCVoZFSy z6yU7bDpx1uEdjUt8IvXO6g3OUdA2zdV4YEJzkLsuobQljI032YhhdHOl69Txf/OSjLY 1FwOk7zQt1gV9mYfE5zUmTQfGnUWB0A8VgYrJfj6h7AzyRzbDg5B7Js4Ez8PCWZ1rZUp Bn1H8ZCv3x3q9TPisf87WZhjQUxsYJuwya7coKvvE3mMOPM/SptkOQOy9qFHYZEdOXcL XPjMc/f2tbWRGDCl9RTWr/7qmDal2bfHqZLCiV11/RzjwFAf9nr6hHuyNPc0FYb5joLa Oigg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=cYsxEdpSqsCpJgRGtsBvxG3DA2QGQ1mItmXFyJ8ZZGg=; b=DXa9RF+QBU/MrQfzlevY7PjnRSzfeG2QreaOq4Vnq2k/V3trZZVQxJ+n3IGK1e4xgj Bk7UKZu+MqcM2i7UItCWuiwzA3JKbzk2oPOp0/QlVko1I92MiGK6b+tPa2zVVcDBMt9+ zAW85xbiPc+daSIg1aLU27QI4WlVTi49No4fcVoJrXB9nscUFeqAP4V3NKLQUXCckzk9 dduSFD7FP9zz5aeqvZhPkDglPWaV0bue6FeIMaJlVSmgfaCRrW/Oi+N+vClQ16r+rfEF 8PhMa+wcDIw6e0UEmuAFI6/RP2uCFNgV7gcXGUXbW2gzsFAH+eiSploF7VMSL7YuQkLR tFaQ== X-Gm-Message-State: APjAAAU6esM8djbGhumljGJ6r8aGP2Dk/EtOInO+NOQRMqOMPxYpp0qp j1yDp/YqdmhDTcg8i86L4h+i3vjfueP7aA== X-Google-Smtp-Source: APXvYqwCZi9drjwqTATokBd8OlqQMDrv0PDPmqd39pwuNlCSVUPsD7CLPyfOCfi/vBeE0I29ZxUZTg== X-Received: by 2002:adf:afc2:: with SMTP id y2mr9835759wrd.254.1574616609723; Sun, 24 Nov 2019 09:30:09 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::4e2b:d7ca]) by smtp.gmail.com with ESMTPSA id n13sm5537275wmi.25.2019.11.24.09.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 09:30:09 -0800 (PST) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel Subject: [PATCH v9 5/6] pwm: sun4i: Add support to output source clock directly Date: Sun, 24 Nov 2019 18:29:07 +0100 Message-Id: <20191124172908.10804-6-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191124172908.10804-1-peron.clem@gmail.com> References: <20191124172908.10804-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191124_093011_493562_C2BFE35D X-CRM114-Status: GOOD ( 18.44 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (peron.clem[at]gmail.com) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Jernej Skrabec , linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, =?utf-8?b?Q2w=?= =?utf-8?b?w6ltZW50IFDDqXJvbg==?= , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Jernej Skrabec PWM core has an option to bypass whole logic and output unchanged source clock as PWM output. This is achieved by enabling bypass bit. Note that when bypass is enabled, no other setting has any meaning, not even enable bit. This mode of operation is needed to achieve high enough frequency to serve as clock source for AC200 chip which is integrated into same package as H6 SoC. Signed-off-by: Jernej Skrabec Signed-off-by: Clément Péron Reviewed-by: Uwe Kleine-König --- drivers/pwm/pwm-sun4i.c | 48 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index e369b5a398f4..07bf7be6074b 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -3,6 +3,10 @@ * Driver for Allwinner sun4i Pulse Width Modulation Controller * * Copyright (C) 2014 Alexandre Belloni + * + * Limitations: + * - When outputing the source clock directly, the PWM logic will be bypassed + * and the currently running period is not guaranteed to be completed */ #include @@ -73,6 +77,7 @@ static const u32 prescaler_table[] = { struct sun4i_pwm_data { bool has_prescaler_bypass; + bool has_direct_mod_clk_output; unsigned int npwm; }; @@ -118,6 +123,20 @@ static void sun4i_pwm_get_state(struct pwm_chip *chip, val = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG); + /* + * PWM chapter in H6 manual has a diagram which explains that if bypass + * bit is set, no other setting has any meaning. Even more, experiment + * proved that also enable bit is ignored in this case. + */ + if ((val & BIT_CH(PWM_BYPASS, pwm->hwpwm)) && + sun4i_pwm->data->has_direct_mod_clk_output) { + state->period = DIV_ROUND_UP_ULL(NSEC_PER_SEC, clk_rate); + state->duty_cycle = DIV_ROUND_UP_ULL(state->period, 2); + state->polarity = PWM_POLARITY_NORMAL; + state->enabled = true; + return; + } + if ((PWM_REG_PRESCAL(val, pwm->hwpwm) == PWM_PRESCAL_MASK) && sun4i_pwm->data->has_prescaler_bypass) prescaler = 1; @@ -149,13 +168,24 @@ static void sun4i_pwm_get_state(struct pwm_chip *chip, static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm, const struct pwm_state *state, - u32 *dty, u32 *prd, unsigned int *prsclr) + u32 *dty, u32 *prd, unsigned int *prsclr, + bool *bypass) { u64 clk_rate, div = 0; unsigned int pval, prescaler = 0; clk_rate = clk_get_rate(sun4i_pwm->clk); + *bypass = sun4i_pwm->data->has_direct_mod_clk_output && + state->enabled && + (state->period * clk_rate >= NSEC_PER_SEC) && + (state->period * clk_rate < 2 * NSEC_PER_SEC) && + (state->duty_cycle * clk_rate * 2 >= NSEC_PER_SEC); + + /* Skip calculation of other parameters if we bypass them */ + if (*bypass) + return 0; + if (sun4i_pwm->data->has_prescaler_bypass) { /* First, test without any prescaler when available */ prescaler = PWM_PRESCAL_MASK; @@ -206,6 +236,7 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, int ret; unsigned int delay_us, prescaler; unsigned long now; + bool bypass; pwm_get_state(pwm, &cstate); @@ -220,7 +251,8 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, spin_lock(&sun4i_pwm->ctrl_lock); ctrl = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG); - ret = sun4i_pwm_calculate(sun4i_pwm, state, &duty, &period, &prescaler); + ret = sun4i_pwm_calculate(sun4i_pwm, state, &duty, &period, &prescaler, + &bypass); if (ret) { dev_err(chip->dev, "period exceeds the maximum value\n"); spin_unlock(&sun4i_pwm->ctrl_lock); @@ -229,6 +261,18 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } + if (sun4i_pwm->data->has_direct_mod_clk_output) { + if (bypass) { + ctrl |= BIT_CH(PWM_BYPASS, pwm->hwpwm); + /* We can skip other parameter */ + sun4i_pwm_writel(sun4i_pwm, ctrl, PWM_CTRL_REG); + spin_unlock(&sun4i_pwm->ctrl_lock); + return 0; + } else { + ctrl &= ~BIT_CH(PWM_BYPASS, pwm->hwpwm); + } + } + if (PWM_REG_PRESCAL(ctrl, pwm->hwpwm) != prescaler) { /* Prescaler changed, the clock has to be gated */ ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm); From patchwork Sun Nov 24 17:29:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11259249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35D72913 for ; Sun, 24 Nov 2019 17:31:38 +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 100872075E for ; Sun, 24 Nov 2019 17:31:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="usHfb0KT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OYiNMLLI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 100872075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gjD2fmClQOfo8vhqJDdtrH0/2qIzFRZylyGkZtN3mPI=; b=usHfb0KTQjGRHz xUqa02suRy14eyYSzYEQcHjk0fW4S6sGg1x2zkqqA/Gl59RG31bvinIi/6O0SF/MJ9t3pFBsv4YGl 4iZ2xBhvXsJuYZdszBxN1J9snxg0mfxIiA66T75hxjwfTvfT55FrAR9692zinc1yOV1Lr4coQO9B5 A1xBJBii3UTZYfPFBxPJLZw6YrnmSX4MIRQfL3pg7GyfbGDBpcouNnMfaOUFevrTfJ+0Hyx18/z60 4ePUFGb43dNj0aOtXxJJxInv0cJKF9iLvJj9wv3pWdZqr7m52Q50zi9SCNtra8/EXLNXfy5LXHKtR etgKEEnrSLYKiKUaduzw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYvjT-0007As-59; Sun, 24 Nov 2019 17:31:35 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iYviG-0005zH-Hg for linux-arm-kernel@lists.infradead.org; Sun, 24 Nov 2019 17:30:22 +0000 Received: by mail-wm1-x341.google.com with SMTP id b11so12697566wmb.5 for ; Sun, 24 Nov 2019 09:30:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sjixo6ht7XiGZb8/LNb/8Q06mHVbU6wMmziG5mNnwig=; b=OYiNMLLI89jLaAYadwdPkm8CYT0XjYMPJ5j0/PepSiMjSKL7Ho/STOqUc4r2yA8SgD 2fSXE/uyQsx58Q93mYXDEGPk1joPHtLRGHOdJ4FeMWPiJ/Mz5s+nNY9k8w34jfVOHDB2 dKBcOKD5ar5yZfmeIF5ega5MCRvWQ5a7ma73aWzbjbCo7U5UqtEbi7cah2IIH2JIpsp0 wW8s/eHJzP1xxh3uz3xN/wK1V4wtL1z47YoZmCPDHOu7UI+eVUpKzClJ/LHqjFYekFJ4 93YidniTK30G3JkwscNuRpPRJKI3jFrQ8s8Z0PY3UkDKY2+izKO9Bf2LekGq7zrBjrRG C00w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sjixo6ht7XiGZb8/LNb/8Q06mHVbU6wMmziG5mNnwig=; b=r/jVjVYamUKF8VX0ttKBp8Zeuos882NTxfMUOrDn2IBJcUIk0l9J0t6/g5iXGJgacn NrhgEqc5L08UtBtsxibzCXTK22dsW2XJQw93j/G9yRZQ/ZRU9fcmeAQRvuXpv9FvUAcC eZFszpFywYyGknmIf0K+WLrBkbsL6Fc4cq+niHs/vSK6KS9wxI9e80lb4SRwkCKA6txD DeFvmU28Kt/Fuyq2SYLK4MpsTSqFjTcrEBNxgzEB1vVg+j9Z1cv6liFqhNKOpa8ffvZn U9kxro4tjHoyZvPzW03gxaHVpZoOWxtoEjVZFi0Z452UNgXAoBA1qTxTlyS5IDwAEzgT 1C2A== X-Gm-Message-State: APjAAAXRJp/wsuVjRSNqF/CmsDSiCgRd0Yza2vEKBc9FV1L4s3EGGKIr CO/O4W19i809n5DX0wJyNhQ= X-Google-Smtp-Source: APXvYqzdwq6I0QuiWDS1GB2PvZLPk9+ENLHHn5zVHJOxjm5uJwP+lPkagFhiQeWjWwyFSGT7X09ZbQ== X-Received: by 2002:a7b:c1d3:: with SMTP id a19mr6652300wmj.127.1574616618566; Sun, 24 Nov 2019 09:30:18 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::4e2b:d7ca]) by smtp.gmail.com with ESMTPSA id n13sm5537275wmi.25.2019.11.24.09.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 09:30:18 -0800 (PST) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel Subject: [PATCH v9 6/6] pwm: sun4i: Add support for H6 PWM Date: Sun, 24 Nov 2019 18:29:08 +0100 Message-Id: <20191124172908.10804-7-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191124172908.10804-1-peron.clem@gmail.com> References: <20191124172908.10804-1-peron.clem@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191124_093020_957975_90A5D0E9 X-CRM114-Status: GOOD ( 12.68 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (peron.clem[at]gmail.com) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Jernej Skrabec , linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, =?utf-8?b?Q2w=?= =?utf-8?b?w6ltZW50IFDDqXJvbg==?= , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Jernej Skrabec Now that sun4i PWM driver supports deasserting reset line and enabling bus clock, support for H6 PWM can be added. Note that while H6 PWM has two channels, only first one is wired to output pin. Second channel is used as a clock source to companion AC200 chip which is bundled into same package. Signed-off-by: Jernej Skrabec Acked-by: Uwe Kleine-König Signed-off-by: Clément Péron --- drivers/pwm/pwm-sun4i.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 07bf7be6074b..c394878c7e5d 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -360,6 +360,12 @@ static const struct sun4i_pwm_data sun4i_pwm_single_bypass = { .npwm = 1, }; +static const struct sun4i_pwm_data sun50i_h6_pwm_data = { + .has_prescaler_bypass = true, + .has_direct_mod_clk_output = true, + .npwm = 2, +}; + static const struct of_device_id sun4i_pwm_dt_ids[] = { { .compatible = "allwinner,sun4i-a10-pwm", @@ -376,6 +382,9 @@ static const struct of_device_id sun4i_pwm_dt_ids[] = { }, { .compatible = "allwinner,sun8i-h3-pwm", .data = &sun4i_pwm_single_bypass, + }, { + .compatible = "allwinner,sun50i-h6-pwm", + .data = &sun50i_h6_pwm_data, }, { /* sentinel */ },