Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp829398imm; Fri, 1 Jun 2018 10:12:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL0EJluuKcJaJk0dUE+BMd+4tNWlKXJrPf+nThHKsUKfm8kH3U7UARoH+LNgeNmIg5WeRha X-Received: by 2002:a65:4aca:: with SMTP id c10-v6mr994875pgu.244.1527873152809; Fri, 01 Jun 2018 10:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527873152; cv=none; d=google.com; s=arc-20160816; b=XehhC/Zro++XT4d4T+eH8K+IpooWVe5npeAHQPX6oEqWcAcuHnQbCVLzm/kMEz+ot6 1vP+5CGFUFX415lLn+itI9SpDYIRbwvYQNnKpedm0z8AxBeBU8dCh88aqlGjyKL1ln5K vKjgSrvITF6rWplsycoBjPid0jzqmptXk1Yk78tMWJg2sshcUlXIEV7gWJPXGLjtkXYa bmDM/MsOtD/8tTBB33Md/4ji1njC084eMDJslsGxiCrvQvmXJmTUKtHLStVlFGwLbEeQ 45u47GCTscfASLR2c96JyhMBzXzuql7STt4GYfrx+Yw6LCxKnRPLtWKZ3BWqeSlqBF3B VxKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=sRXUb+G/01w1KSvYgwQIYQY+D8O29uSr/TGi6skFdNk=; b=jPCyeq1NU+rS8L11clgm1v+E7cMWVVgJjeK6DJEwBu0enTWwi7JzFqwsVj0HiN9kMk x1cBc6ELiwkLBkfFpgFF9FmG57vkw4dFJRuj8LHuosroqrGF6Yil4qmb87m87xrzSRWh kbZKYZwTkE3D+sag9StdadGEZXGBG8Ss2ubfiwlDRKqC43MchpwedQq1yoyXYtsBGUHu E1lzMAgGxNM/H9JtH/Bt02cwjuKpS/PZwYgEigdZKPIhrHFvUAUFlTiWXCce6INBhSYl dj8svVi98oYVGBgVESw6oAtfhOgJhyljiK80BRF5SDUTiSGXk3DH8on9U1wX/QZLBzav rIJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M69+7HuE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w89-v6si16029550pfi.88.2018.06.01.10.12.18; Fri, 01 Jun 2018 10:12:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M69+7HuE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753125AbeFARLY (ORCPT + 99 others); Fri, 1 Jun 2018 13:11:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751964AbeFARLV (ORCPT ); Fri, 1 Jun 2018 13:11:21 -0400 Received: from localhost (unknown [104.132.1.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 616A720874; Fri, 1 Jun 2018 17:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527873080; bh=XThh+QxIJ/mgM5uwqMiHuYm7MLxXh4FKweDhQDuFXl0=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=M69+7HuE300tYVd2SdS/yLsFNQVvwjqNMpHD16BjBy9VErLDtkcHVnmcGtQbvYK90 lPm+tTmD+8bo8G2bO4/dr/0aspddAnjgrD+A6KicbiI1pE9WgljYZ2nC5jB9Db4WwT P5hAkc40ffQ7TU6Ytw+44BZjAqYES+41PgEJBZOI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Matti Vaittinen From: Stephen Boyd In-Reply-To: <20180601073156.GC5150@localhost.localdomain> Cc: Matti Vaittinen , broonie@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, mark.rutland@arm.com, mazziesaccount@gmail.com, mturquette@baylibre.com, robh+dt@kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mikko.mutanen@fi.rohmeurope.com, heikki.haikola@fi.rohmeurope.com References: <3d9d7239331c30826a237ae55db28d918155d504.1527669443.git.matti.vaittinen@fi.rohmeurope.com> <152777943977.144038.10971658990200651749@swboyd.mtv.corp.google.com> <20180601073156.GC5150@localhost.localdomain> Message-ID: <152787307968.144038.530443034026242491@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v4 5/6] clk: bd71837: Add driver for BD71837 PMIC clock Date: Fri, 01 Jun 2018 10:11:19 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Matti Vaittinen (2018-06-01 00:31:56) > First of all - Thanks for looking at this! > = > On Thu, May 31, 2018 at 08:10:39AM -0700, Stephen Boyd wrote: > > Quoting Matti Vaittinen (2018-05-30 01:43:19) > > > diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig > > > index 41492e980ef4..4b045699bb5e 100644 > > > --- a/drivers/clk/Kconfig > > > +++ b/drivers/clk/Kconfig > > > @@ -279,6 +279,15 @@ config COMMON_CLK_STM32H7 > > > ---help--- > > > Support for stm32h7 SoC family clocks > > > = > > > +config COMMON_CLK_BD71837 > > > + tristate "Clock driver for ROHM BD71837 PMIC MFD" > > > + depends on MFD_BD71837 > > > + depends on I2C=3Dy > > = > > Why depend on I2C=3Dy? > = > I added this because the PMIC is connected via i2c. But as you ask this > - and as you probably knew my answer - I guess this is not correct. So > I guess depends on MFD_BD71837 should be sufficient and the MFD portion > should hide the fact we sit on I2C? If this is the case - I will remove > this. Sounds right. > > = > > > + > > > +static int bd71837_clk_set(struct clk_hw *hw, int status) > > > +{ > > > + struct bd71837_clk *c =3D container_of(hw, struct bd71837_clk= , hw); > > > + > > > + return bd71837_update_bits(c->mfd, c->reg, c->mask, status); > > > +} > > > + > > > +static void bd71837_clk_disable(struct clk_hw *hw) > > > +{ > > > + int rv; > > > + struct bd71837_clk *c =3D container_of(hw, struct bd71837_clk= , hw); > > > + > > > + rv =3D bd71837_clk_set(hw, 0); > > > + if (rv) > > > + dev_err(&c->pdev->dev, "Failed to disable 32K clk (%d= )\n", rv); > > = > > Why is a disable error message more important than an enable error > > message? Please drop this message and rely on callers to indicate if > > enabling their clk didn't work for some reason. > = > Reason is that the disable function is not returning error. So if I drop > the print there will be no indication of error, right? I'm not sure anyone cares if disable fails, which is why we have it marked as void. The end user probably can't do anything about it, and it isn't actually causing some sort of problem besides lost power so if you really want to keep it please move it to dev_dbg(), or just remove it and add it in when you're debugging. > = > > = > > > +} > > > + > > > +static unsigned long bd71837_clk_recalc_rate(struct clk_hw *hw, > > > + unsigned long parent_rat= e) > > > +{ > > > + struct bd71837_clk *c =3D container_of(hw, struct bd71837_clk= , hw); > > > + > > > + return c->rate; > > = > > Recalc rate should read the hardware instead of returning a cached rate > > unless it can't actually read hardware. > = > We can't read the rate from HW. And actually, as this is fixed rate > clock generator - is the recalc_rate needed at all? Yes recalc_rate is still needed in this case. Thanks for pointing it out. This is fine. > = > > = > > > + if (!c) > > > + goto err_out; > > > + > > > + c->reg =3D BD71837_REG_OUT32K; > > > + c->mask =3D BD71837_OUT32K_EN; > > > + c->rate =3D BD71837_CLK_RATE; > > = > > Is the plan to have more clks supported by this driver in the future? > > Because right now it seems to make a structure up and then hardcode the > > members for a single clk so I'm not sure why those registers aren't just > > hardcoded in the clk_ops functions that use them. > = > (At least) one more chip from this series is coming and I am planning to > support it with this driver. I am not sure if the registers will stay > the same. Hence I rather not hardcode the register values. Ok. > = > > = > > > + of_property_read_string_index(pdev->dev.of_node, > > > + "clock-output-names", 0, > > > + &init.name); > > > + > > > + c->hw.init =3D &init; > > > + > > > + errstr =3D "failed to register 32K clk"; > > = > > The 'errstr' thing is not standard. Please just call dev_err() directly > > with the string you want to print. And consider not printing anything at > > all. > = > I think this technique is actually used in many places at net side. I > guess i have adobted this habit from some netlink message handling code. > I can change this to in-place prints if it fits environment better > though. Ok. > = > > = > > > + rval =3D clk_hw_register(&pdev->dev, &c->hw); > > > + if (rval) > > > + goto err_free; > > > + > > > + errstr =3D "failed to register clkdev for bd71837"; > > > + rval =3D clk_hw_register_clkdev(&c->hw, init.name, NULL); > > = > > Are you using the clkdev lookup? Or this is just added for backup > > purposes? If this is a mostly DT driver then please drop this part of > > the patch and rely on of_clk_hw_add_provider() to handle the lookup > > instead. > = > I did this because this is how I get the clk_get to work in my test > driver. Problem is that I don't know how this clock is going to be used > - and I lack of knowledge how these things are usually done. I don't > know the clock consumer code so this was best I could think of. But if > this is not how things are usually handled I can remove the clkdev and > rely on of_clk_add_hw_provider. Would this be correct then: There isn't any example code inserted, but yes, usually clkdev is used when a non-DT enabled platform wants to use the clk. That typically only happens on x86 platforms because we don't have a way in ACPI to express clk handles. If this is never used with an x86 platform then clkdev is not needed. Either way, adding an OF provider would be good to support DT platforms. Having a clkdev lookup would also be good to support non-DT platforms.