* Coupled clk/reset
@ 2017-07-18 10:23 Joel Stanley
2017-07-18 10:56 ` Benjamin Herrenschmidt
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Joel Stanley @ 2017-07-18 10:23 UTC (permalink / raw)
To: Philipp Zabel, Michael Turquette, Stephen Boyd
Cc: linux-clk, Ryan Chen, Linus Walleij, Benjamin Herrenschmidt,
Andrew Jeffery, Jeremy Kerr
Hello!
I'm taking a stab at a clk and reset driver for the Aspeed SoCs. I've
used the Gemini driver for inspiration so far, which looks to be a
good fit for the clock gating and important clocks (those we need in
order to get the uart and timer source going).
One tricky bit is the datasheet specifies the following for enabling
an IP block ('engine'), whenever the engine is started from the
clocked stopped state:
1. Enable engine reset
2. Delay 100us
3. Enable clock
4. Delay 10ms
5. Disable engine reset
How does this dance fit into the reset/clock framework? I need to show
that there is this dependency when enabling a clock.
Cheers,
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Coupled clk/reset
2017-07-18 10:23 Coupled clk/reset Joel Stanley
@ 2017-07-18 10:56 ` Benjamin Herrenschmidt
2017-07-18 14:25 ` Philipp Zabel
2017-07-18 14:06 ` Philipp Zabel
2017-07-19 8:10 ` Peter De Schrijver
2 siblings, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2017-07-18 10:56 UTC (permalink / raw)
To: Joel Stanley, Philipp Zabel, Michael Turquette, Stephen Boyd
Cc: linux-clk, Ryan Chen, Linus Walleij, Andrew Jeffery, Jeremy Kerr
On Tue, 2017-07-18 at 19:53 +0930, Joel Stanley wrote:
> Hello!
>
> I'm taking a stab at a clk and reset driver for the Aspeed SoCs. I've
> used the Gemini driver for inspiration so far, which looks to be a
> good fit for the clock gating and important clocks (those we need in
> order to get the uart and timer source going).
>
> One tricky bit is the datasheet specifies the following for enabling
> an IP block ('engine'), whenever the engine is started from the
> clocked stopped state:
>
> 1. Enable engine reset
> 2. Delay 100us
> 3. Enable clock
> 4. Delay 10ms
> 5. Disable engine reset
>
> How does this dance fit into the reset/clock framework? I need to show
> that there is this dependency when enabling a clock.
My gut feeling is that I would have a single driver exposing both clock
and reset interfaces.
It keeps a "reset state" for each device.
The reset API just changes that internal (SW) state, and adjusts the HW
reset if and only if the clock is on.
When the clock is turned off, we force the reset, disable the clock.
When the clock is turned on, we force the reset if not already set,
enable the clock, then only lift the reset if the "user" reset is
not asserted.
That being said, I think for the aspeed SoC, the argument could be made
that we don't actually need a reset driver. We yet have to encounter a
single device that needs to control it's own reset line for anything
other than enabling/disabling its clock/IP block.
So I suspect sticking to just a clock API that does the underlying
reset manipulations as needed is sufficient and we can "upgrade" to the
above proposal if it ends up being needed (which I doubt).
Cheers,
Ben.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Coupled clk/reset
2017-07-18 10:23 Coupled clk/reset Joel Stanley
2017-07-18 10:56 ` Benjamin Herrenschmidt
@ 2017-07-18 14:06 ` Philipp Zabel
2017-07-18 21:14 ` Benjamin Herrenschmidt
2017-07-19 8:10 ` Peter De Schrijver
2 siblings, 1 reply; 7+ messages in thread
From: Philipp Zabel @ 2017-07-18 14:06 UTC (permalink / raw)
To: Joel Stanley
Cc: Michael Turquette, Stephen Boyd, linux-clk, Ryan Chen,
Linus Walleij, Benjamin Herrenschmidt, Andrew Jeffery,
Jeremy Kerr
Hi Joel,
On Tue, 2017-07-18 at 19:53 +0930, Joel Stanley wrote:
> Hello!
>
> I'm taking a stab at a clk and reset driver for the Aspeed SoCs. I've
> used the Gemini driver for inspiration so far, which looks to be a
> good fit for the clock gating and important clocks (those we need in
> order to get the uart and timer source going).
>
> One tricky bit is the datasheet specifies the following for enabling
> an IP block ('engine'), whenever the engine is started from the
> clocked stopped state:
>
> 1. Enable engine reset
> 2. Delay 100us
> 3. Enable clock
> 4. Delay 10ms
> 5. Disable engine reset
>
> How does this dance fit into the reset/clock framework? I need to show
> that there is this dependency when enabling a clock.
If this is some special treatment for a single IP block, I'd just open
code this in the driver:
reset_control_assert(rstc);
usleep_range(100, 200);
clk_prepare_enable(clk);
usleep_range(10000, 20000);
reset_control_deassert(rstc);
If this is a common pattern needed for multiple clocks, you could
investigate hiding this in the clock driver and not export the resets to
the 'engine' driver at all.
regards
Philipp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Coupled clk/reset
2017-07-18 10:56 ` Benjamin Herrenschmidt
@ 2017-07-18 14:25 ` Philipp Zabel
0 siblings, 0 replies; 7+ messages in thread
From: Philipp Zabel @ 2017-07-18 14:25 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Joel Stanley, Michael Turquette, Stephen Boyd, linux-clk,
Ryan Chen, Linus Walleij, Andrew Jeffery, Jeremy Kerr
On Tue, 2017-07-18 at 20:56 +1000, Benjamin Herrenschmidt wrote:
[...]
> My gut feeling is that I would have a single driver exposing both clock
> and reset interfaces.
Agreed.
> It keeps a "reset state" for each device.
>
> The reset API just changes that internal (SW) state, and adjusts the HW
> reset if and only if the clock is on.
>
> When the clock is turned off, we force the reset, disable the clock.
>
> When the clock is turned on, we force the reset if not already set,
> enable the clock, then only lift the reset if the "user" reset is
> not asserted.
Please let's not do this. If a reset line is controlled by the clocks
like this, I'd rather not have it exported via the reset API at the same
time.
Both shared and exclusive reset control API are incompatible with
another controlling instance forcing the reset line into asserted state:
the exclusive reset API promises full control over the reset line, and
the shared reset API guarantees deassertion while requested (just like
the clk API can't be used to force-disable a clock).
> That being said, I think for the aspeed SoC, the argument could be made
> that we don't actually need a reset driver. We yet have to encounter a
> single device that needs to control it's own reset line for anything
> other than enabling/disabling its clock/IP block.
>
> So I suspect sticking to just a clock API that does the underlying
> reset manipulations as needed is sufficient and we can "upgrade" to the
> above proposal if it ends up being needed (which I doubt).
I agree with hiding the whole mechanism in the clock driver. If that
can't be done in the clock driver, I would prefer to give control to the
IP block drivers instead.
regards
Philipp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Coupled clk/reset
2017-07-18 14:06 ` Philipp Zabel
@ 2017-07-18 21:14 ` Benjamin Herrenschmidt
2017-07-19 3:08 ` Joel Stanley
0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2017-07-18 21:14 UTC (permalink / raw)
To: Philipp Zabel, Joel Stanley
Cc: Michael Turquette, Stephen Boyd, linux-clk, Ryan Chen,
Linus Walleij, Andrew Jeffery, Jeremy Kerr
On Tue, 2017-07-18 at 16:06 +0200, Philipp Zabel wrote:
> If this is some special treatment for a single IP block, I'd just open
> code this in the driver:
> reset_control_assert(rstc);
> usleep_range(100, 200);
> clk_prepare_enable(clk);
> usleep_range(10000, 20000);
> reset_control_deassert(rstc);
>
> If this is a common pattern needed for multiple clocks, you could
> investigate hiding this in the clock driver and not export the resets to
> the 'engine' driver at all.
Right, it's a common pattern for all the IP blocks in that SoC. I agree
with your proposal, it would keep things simpler.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Coupled clk/reset
2017-07-18 21:14 ` Benjamin Herrenschmidt
@ 2017-07-19 3:08 ` Joel Stanley
0 siblings, 0 replies; 7+ messages in thread
From: Joel Stanley @ 2017-07-19 3:08 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Philipp Zabel, Michael Turquette, Stephen Boyd, linux-clk,
Ryan Chen, Linus Walleij, Andrew Jeffery, Jeremy Kerr
On Wed, Jul 19, 2017 at 6:44 AM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Tue, 2017-07-18 at 16:06 +0200, Philipp Zabel wrote:
>> If this is some special treatment for a single IP block, I'd just open
>> code this in the driver:
>> reset_control_assert(rstc);
>> usleep_range(100, 200);
>> clk_prepare_enable(clk);
>> usleep_range(10000, 20000);
>> reset_control_deassert(rstc);
>>
>> If this is a common pattern needed for multiple clocks, you could
>> investigate hiding this in the clock driver and not export the resets to
>> the 'engine' driver at all.
>
> Right, it's a common pattern for all the IP blocks in that SoC. I agree
> with your proposal, it would keep things simpler.
Thanks Philipp and Ben. I'll go ahead with a clock driver that does
the right things, and drop the reset controller parts.
Cheers,
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Coupled clk/reset
2017-07-18 10:23 Coupled clk/reset Joel Stanley
2017-07-18 10:56 ` Benjamin Herrenschmidt
2017-07-18 14:06 ` Philipp Zabel
@ 2017-07-19 8:10 ` Peter De Schrijver
2 siblings, 0 replies; 7+ messages in thread
From: Peter De Schrijver @ 2017-07-19 8:10 UTC (permalink / raw)
To: Joel Stanley
Cc: Philipp Zabel, Michael Turquette, Stephen Boyd, linux-clk,
Ryan Chen, Linus Walleij, Benjamin Herrenschmidt, Andrew Jeffery,
Jeremy Kerr
On Tue, Jul 18, 2017 at 07:53:09PM +0930, Joel Stanley wrote:
> Hello!
>
> I'm taking a stab at a clk and reset driver for the Aspeed SoCs. I've
> used the Gemini driver for inspiration so far, which looks to be a
> good fit for the clock gating and important clocks (those we need in
> order to get the uart and timer source going).
>
> One tricky bit is the datasheet specifies the following for enabling
> an IP block ('engine'), whenever the engine is started from the
> clocked stopped state:
>
> 1. Enable engine reset
> 2. Delay 100us
> 3. Enable clock
> 4. Delay 10ms
> 5. Disable engine reset
>
This is a pretty standard sequence. The reset is synchronous, so the module
clock needs to be running for the reset toggling to take effect. And it takes
some time for the reset propagate through all the logic, hence the second
delay, although 10ms seems large to me.
Peter.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-07-19 8:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-18 10:23 Coupled clk/reset Joel Stanley
2017-07-18 10:56 ` Benjamin Herrenschmidt
2017-07-18 14:25 ` Philipp Zabel
2017-07-18 14:06 ` Philipp Zabel
2017-07-18 21:14 ` Benjamin Herrenschmidt
2017-07-19 3:08 ` Joel Stanley
2017-07-19 8:10 ` Peter De Schrijver
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.