[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <95b21eeaee8025dc430623429273116c35c1b769.camel@fi.rohmeurope.com>
Date: Tue, 29 Oct 2019 06:28:51 +0000
From: "Vaittinen, Matti" <Matti.Vaittinen@...rohmeurope.com>
To: "mazziesaccount@...il.com" <mazziesaccount@...il.com>,
"sboyd@...nel.org" <sboyd@...nel.org>
CC: "dmurphy@...com" <dmurphy@...com>,
"linux-leds@...r.kernel.org" <linux-leds@...r.kernel.org>,
"linux-rtc@...r.kernel.org" <linux-rtc@...r.kernel.org>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"alexandre.belloni@...tlin.com" <alexandre.belloni@...tlin.com>,
"mturquette@...libre.com" <mturquette@...libre.com>,
"lgirdwood@...il.com" <lgirdwood@...il.com>,
"jacek.anaszewski@...il.com" <jacek.anaszewski@...il.com>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"a.zummo@...ertech.it" <a.zummo@...ertech.it>,
"linus.walleij@...aro.org" <linus.walleij@...aro.org>,
"mark.rutland@....com" <mark.rutland@....com>,
"robh+dt@...nel.org" <robh+dt@...nel.org>,
"bgolaszewski@...libre.com" <bgolaszewski@...libre.com>,
"linux-clk@...r.kernel.org" <linux-clk@...r.kernel.org>,
"pavel@....cz" <pavel@....cz>,
"lee.jones@...aro.org" <lee.jones@...aro.org>,
"broonie@...nel.org" <broonie@...nel.org>
Subject: Re: [RFC PATCH v2 05/13] clk: bd718x7: Support ROHM BD71828 clk
block
Hello Stephen,
Thanks for the comments once again :)
On Mon, 2019-10-28 at 16:32 -0700, Stephen Boyd wrote:
> Quoting Matti Vaittinen (2019-10-24 04:44:40)
> > diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c
> > index ae6e5baee330..d17a19e04592 100644
> > --- a/drivers/clk/clk-bd718x7.c
> > +++ b/drivers/clk/clk-bd718x7.c
> > @@ -8,6 +8,7 @@
> > #include <linux/platform_device.h>
> > #include <linux/slab.h>
> > #include <linux/mfd/rohm-bd718x7.h>
> > +#include <linux/mfd/rohm-bd71828.h>
> > #include <linux/mfd/rohm-bd70528.h>
>
> It would be really great to not need to include these random header
> files in this driver and just use raw numbers somehow. Looks like
> maybe
> it can be done by populating a different device name from the mfd
> driver
> depending on the version of the clk controller desired? Then that can
> be
> matched in this clk driver and we can just put the register info in
> this
> file?
I still like keeping the chip type information on one header - no
matter what-ever format the clk-controller type/version information is.
Rationale is that MFD and also few other sub-devices (not only the clk)
need to use it. Currently at least the RTC.
But if we define clk register information for all PMICs in this c-file,
then (I think) we can only include the <linux/mfd/rohm-generic.h> -
which contains the PMIC type defines and the generic MFD data
structure. That would:
-#include <linux/mfd/rohm-bd718x7.h>
-#include <linux/mfd/rohm-bd71828.h>
-#include <linux/mfd/rohm-bd70528.h>
+#include <linux/mfd/rohm-generic.h>
That way the chip-type information could still be same for MFD and all
sub-devices but clk driver would not need to include all the details
for all the PMICs. I understand your point well as clk registers for
these PMICs are really *limited*.
>
> > #include <linux/clk-provider.h>
> > #include <linux/clkdev.h>
> > @@ -21,10 +22,8 @@ struct bd718xx_clk {
> > struct rohm_regmap_dev *mfd;
> > };
> >
> > -static int bd71837_clk_set(struct clk_hw *hw, int status)
> > +static int bd71837_clk_set(struct bd718xx_clk *c, int status)
>
> should it be unsigned int status? Or maybe u32?
>
> > {
> > - struct bd718xx_clk *c = container_of(hw, struct
> > bd718xx_clk, hw);
> > -
> > return regmap_update_bits(c->mfd->regmap, c->reg, c->mask,
> > status);
> > }
> >
> > @@ -33,14 +32,16 @@ static void bd71837_clk_disable(struct clk_hw
> > *hw)
> > int rv;
> > struct bd718xx_clk *c = container_of(hw, struct
> > bd718xx_clk, hw);
> >
> > - rv = bd71837_clk_set(hw, 0);
> > + rv = bd71837_clk_set(c, 0);
> > if (rv)
> > dev_dbg(&c->pdev->dev, "Failed to disable 32K clk
> > (%d)\n", rv);
> > }
> >
> > static int bd71837_clk_enable(struct clk_hw *hw)
> > {
> > - return bd71837_clk_set(hw, 1);
> > + struct bd718xx_clk *c = container_of(hw, struct
> > bd718xx_clk, hw);
> > +
> > + return bd71837_clk_set(c, 0xffffffff);
>
> Because now this is passing -1 to unsigned int taking
> regmap_update_bits()?
I think that bit-wise it is all the same. Currently registers are only
8bits wide so it is enough that lowest 8 bits are set. And 0xffffffff
should work nicely up-to 32bit registers as long as int is 32 bit or
more.
But you are correct that this is not looking good. At first sight
unsigned int is much nicer. I prefer unsigned int over forced u32 to
guarantee natural alignment - which does not really matter in this case
either. unsigned int matches regmap though so I'll switch to it. Thanks
for pointing this out :)
I'll try to include these clk changes in v3.
Br,
Matti Vaittinen
Powered by blists - more mailing lists