linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philippe Schenker <philippe.schenker@toradex.com>
To: "broonie@kernel.org" <broonie@kernel.org>
Cc: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH 1/2] Regulator: Core: Add clock-enable to fixed-regulator
Date: Tue, 30 Jul 2019 21:00:01 +0000	[thread overview]
Message-ID: <b5e1cc3fb5838d9ea4160078402bff95903ba0da.camel@toradex.com> (raw)
In-Reply-To: <20190730181038.GK4264@sirena.org.uk>

On Tue, 2019-07-30 at 19:10 +0100, Mark Brown wrote:
> On Tue, Jul 30, 2019 at 07:30:04PM +0200, Philippe Schenker wrote:
> > From: Philippe Schenker <philippe.schenker@toradex.com>
> > 
> > This adds the possibility to enable a fixed-regulator with a clock.
> 
> Why?  What does the hardware which makes this make sense look like?

Tomorrow I can provide some schematics if needed. But its just a simple
switch that is switched by a clock (on when clock is on and off when
clock is off). This clock is the RGMII 50MHz clock for the ethernet
PHY.

That switch switches power rail of a KSZ8041 ethernet PHY. So the power
rail of the KSZ8041 PHY is switched by its own clock.

> Your cover letter didn't explain at all clearly, it just said that
> there's a circuit that is connected to a clock which somehow switches
> something but it's not clear.  It's certainly not clear that this
> should
> be in the core, the circuit doesn't sound like a good idea at all.

Sorry if I didn't explain it clear enough. I hope the hardware part is
clear now from the explanation above. Otherwise let me know I will
provide further explanations/schematics.

To your other questions, I will split those for better understanding:

Why is a regulator even needed?
- On power up of the PHY there is a huge time I have to wait for
voltage rail to settle. In the range of 100ms.
- Because there is a switch in the circuit I abstract it with a
regulator-fixed in devicetree to make use of the startup-delay.
- This regulator/switch is enabled with a clock. So to be able to use
the startup delay I need an enable-by-clock on regulator-fixed.

Why do I think this should be in core?
- Normally this task is done with gpio that is already in regulator-
core.
- Because that is already there I added the functionality for enabled-
by-clock-functionality.
- I thought of creating a new regulator-clock driver but that would
hold a lot of code duplication from regulator-fixed.

Why is this a good Idea at all?
- Well I'm here for the software part and should just support our
hardware. If that is a good Idea at all I don't know, for sure it is
not a solution that is from some school-book. But I tried it and
measured it out and it seems to work pretty fine.
- The reason behind all of that is limited GPIO availability from the
iMX6ULL.

> 
> > Signed-off-by: <philippe.schenker@toradex.com>
> > Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
> 
> This needs a cleanup.

Of course, sorry I didn't saw that beforehand. Some mess created with
cherry-picking...

> 
> >  
> >  	/* cares about last_off_jiffy only if off_on_delay is required
> > by
> > @@ -2796,6 +2805,9 @@ static int _regulator_is_enabled(struct
> > regulator_dev *rdev)
> >  	if (rdev->ena_pin)
> >  		return rdev->ena_gpio_state;
> >  
> > +	if (rdev->ena_clk)
> > +		return (rdev->ena_clk_state > 0) ? 1 : 0;
> > +
> 
> Please write normal conditional statements, this isn't helping
> legibility.  Though in this case the ternery operator is totally
> redundant anyway...

Yeah now that I look at it you're right. I have in mind that I copied
that from somewhere to get the same coding style. I developed that in
an old kernel so could be that it's from there.
Anyway, this is just a concept for now and would need some more
thinking...
With this patch I want to put off a discussion, how we can support our
hardware in mainline Linux. This is my first proposal for that.

Philippe

  reply	other threads:[~2019-07-30 21:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 17:30 [RFC PATCH 0/2] Hello Philippe Schenker
2019-07-30 17:30 ` [RFC PATCH 1/2] Regulator: Core: Add clock-enable to fixed-regulator Philippe Schenker
2019-07-30 18:10   ` Mark Brown
2019-07-30 21:00     ` Philippe Schenker [this message]
2019-07-31 21:23       ` Mark Brown
2019-08-05 11:07         ` Philippe Schenker
2019-08-05 16:37           ` Mark Brown
2019-08-06 12:57             ` Philippe Schenker
2019-08-06 18:26               ` Mark Brown
2019-08-07  6:46                 ` Philippe Schenker
2019-07-30 17:30 ` [RFC PATCH 2/2] ARM: dts: imx6ull: Add phy-supply to fec Philippe Schenker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5e1cc3fb5838d9ea4160078402bff95903ba0da.camel@toradex.com \
    --to=philippe.schenker@toradex.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).