Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5448859pxb; Sun, 7 Nov 2021 12:32:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwazPveT/6oxOeQ5w01uWNOfUG6wP9yojKikOv7sUjdlkpTr0b4CRoUX3m5yKsBXXo+B5J2 X-Received: by 2002:a17:907:6e8e:: with SMTP id sh14mr20176668ejc.536.1636317159580; Sun, 07 Nov 2021 12:32:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636317159; cv=none; d=google.com; s=arc-20160816; b=AGFWFJkAT5nkdm1wvz1RBTho3gHuls3KkUQ0sIOnNC96DxS8HSAwKoNYN0xnBV2nSs u5RFOxFlBHxXbbQDar7uMkqGQQHBLifuyhUJ6P4qxHx+wGDQMWRFI7OZb6dgFFFcMPMx 3ni9cpwzAKyJn9k6MRmnYsf4IXftONrE5ok89/cYb2TyTIZuJh/WQwyNACScQZ+sJYgq fnoKslx7TRx+ZyxpJrlSeQxLAAD+Brzc6doweCrGwSAkZgrI4oOKYMgkSZP07+qiFhlE V43bp3eNMz4ut4LZUcTEDHb0VCVwtbN8jEWT+XSNbzPkuja/ogTY8pGwJn2MVg0BZjRC Twsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/dUrUhWqyLP8WM0V+cyk5RPHoq6Vsv356iF7D4jd0LU=; b=xaF9ZYc+3grUBcNEaYubDmFLVFklyDgNuxVuQtFUDvwmJmmDTqj0RhGbl1y7GKYJWd /b3Fdj1GIvKa2VJA20XiZT6ChYr/J0jkqCR/bh/xlXbo85wGuzXMWY3Xpm88x1o5pJpi 6b3iBfIK3eLuohGkxS9ReDTAKxIo5C7RYxfPzUoDGKFVNuUXCQkE6RzXoYBb7g1QpvXS Fzv7ry2msCTbWcvuaLFAEoYTtOF1bwxsHjFOuO5fH5wDCY+KuO8ZM0vvW8NP3cf360vu S7DCNsFJU+jJG4R8VblWjlabyfm1wra11ARJsXzn5FvCkYOPBdR5ThJKZl9BGkdc8bPL p39w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xNk/aFt0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nc27si32598839ejc.520.2021.11.07.12.32.16; Sun, 07 Nov 2021 12:32:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xNk/aFt0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234160AbhKGP6w (ORCPT + 99 others); Sun, 7 Nov 2021 10:58:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234767AbhKGP6v (ORCPT ); Sun, 7 Nov 2021 10:58:51 -0500 Received: from mail-ua1-x92c.google.com (mail-ua1-x92c.google.com [IPv6:2607:f8b0:4864:20::92c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9BCC061714 for ; Sun, 7 Nov 2021 07:56:08 -0800 (PST) Received: by mail-ua1-x92c.google.com with SMTP id l43so26877283uad.4 for ; Sun, 07 Nov 2021 07:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/dUrUhWqyLP8WM0V+cyk5RPHoq6Vsv356iF7D4jd0LU=; b=xNk/aFt0nlcqfGZxa8z1NMcoEYaLROEd+q1T/FZqP8iBh8+WMl8V3jM5fojORNqxhu 1pgnYN4goukUI4a/FSQjo7BeC9x2RWrbj1JB86Lb2QHVKBYLfF3K/YnkzDX8zJjtrVi0 CcUwiQ6E+cwI05POa6Qs3OFBoktCVX50dFqFjcmiJ52vilzQclJTC8+D4ipjkWDtLmIb 4k3G8v+O+3HidI58DG5Fh3DWeVimo/9fZeLg/er4lO0LL8VN+4H/mlTCXsYXbAb7PQJ4 bq/5tPTwc5ErPhCwK0kMMUunr2XNBZgVwJBUK7WoqbFEE8Tb2MFuS0Fn7/gSyqUseAKh smpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/dUrUhWqyLP8WM0V+cyk5RPHoq6Vsv356iF7D4jd0LU=; b=FWuYXcjvfFBi9bvz9nFGpuRzwmHJnLWm0nbYWomFVIvjZMpxSyklC/9T0Rqbv6+WoI v1lDw5p0CNVW1kXjMCFb2XWwwXrFDQEi6Depk0ZkAyvY2nj4fw40Fuoo5ag7WulqDWxt D7rKE0kbJgIQr5nQDqBV2gAfESJywwMOKB2Op/FFXm7Xy4t2KawyX2/qwVJnRotY/Wz+ abz/xxo1b/uNAfLw/VIi0d+17JK/goc9OLWI+DscbNlWgX0R9TZn8hPbgrCcMHFF/fiH A0bQWyVJnO1LfgCHvV6H+B3tQwOy8AdYLjVsGO5AckIn3lQqdBzI3daVOxQVxUluiWpW 6KQQ== X-Gm-Message-State: AOAM5323DVuXwnOpBMg6ic9nqko4MFGjnS+O7vsKZn1MjToj8OF0q69v IxEqhsiSUHtYx3Gh/0ly4fthuG2kt0AFYg6v6tfvag== X-Received: by 2002:a67:ab48:: with SMTP id k8mr93028958vsh.30.1636300567660; Sun, 07 Nov 2021 07:56:07 -0800 (PST) MIME-Version: 1.0 References: <20211031122216.30212-1-semen.protsenko@linaro.org> <20211031122216.30212-11-semen.protsenko@linaro.org> In-Reply-To: From: Sam Protsenko Date: Sun, 7 Nov 2021 17:55:55 +0200 Message-ID: Subject: Re: [PATCH v2 10/12] watchdog: s3c2410: Support separate source clock To: Krzysztof Kozlowski Cc: Wim Van Sebroeck , Guenter Roeck , Rob Herring , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2 Nov 2021 at 12:15, Krzysztof Kozlowski wrote: > > On 31/10/2021 13:22, Sam Protsenko wrote: > > Right now all devices supported in the driver have the single clock: it > > acts simultaneously as a bus clock (providing register interface > > clocking) and source clock (driving watchdog counter). Some newer Exynos > > chips, like Exynos850, have two separate clocks for that. In that case > > two clocks will be passed to the driver from the resource provider, e.g. > > Device Tree. Provide necessary infrastructure to support that case: > > - use source clock's rate for all timer related calculations > > - use bus clock to gate/ungate the register interface > > > > All devices that use the single clock are kept intact: if only one clock > > is passed from Device Tree, it will be used for both purposes as before. > > > > Signed-off-by: Sam Protsenko > > --- > > Changes in v2: > > - Reworded commit message to be more formal > > - Used separate "has_src_clk" trait to tell if source clock is present > > - Renamed clock variables to match their purpose > > - Removed caching source clock rate, obtaining it in place each time instead > > - Renamed err labels for more consistency > > > > drivers/watchdog/s3c2410_wdt.c | 52 +++++++++++++++++++++++++--------- > > 1 file changed, 39 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c > > index fdb1a1e9bd04..c733917c5470 100644 > > --- a/drivers/watchdog/s3c2410_wdt.c > > +++ b/drivers/watchdog/s3c2410_wdt.c > > @@ -118,7 +118,9 @@ struct s3c2410_wdt_variant { > > > > struct s3c2410_wdt { > > struct device *dev; > > - struct clk *clock; > > + struct clk *bus_clk; /* for register interface (PCLK) */ > > + struct clk *src_clk; /* for WDT counter */ > > + bool has_src_clk; > > Why do you need the has_src_clk value? If clk_get() fails, just store > there NULL and clk API will handle it. > I've added that 'has_src_clk' field for somewhat different reason. 1. As we discussed earlier, in case when src_clk is not present, I do 'src_clk = bus_clk' in v2. This way I don't have to check if src_clk is NULL every time and use bus_clk to get rate. If I set src_clk = NULL, I'll have to add selector code, which wouldn't be so elegant, and contradicts what we've discussed. 2. On the other hand, I don't want to enable bus_clk twice in case when src_clk is not present, that just doesn't feel right (user would see incorrect refcount value in DebugFS, etc). And if "clk_src = bus_clk', and I haven't enabled it second time, then I shouldn't try to disable it second time, right? The only way I can see to accomplish (1) and (2) together, is to use that 'has_src_clk' flag. For me it still looks better than enabling bus_clk twice, or checking if clk_src is NULL every time we need to get clock rate. Please let me know if you still have a strong opinion on this one. > Best regards, > Krzysztof