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)) {