Commit 794d78fe authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

drivers: sh: late disabling of clocks V2

This V2 patch changes the clock disabling behavior during boot.
Two different changes are made:

1) Delay disabling of clocks until late in the boot process.
   This fixes an existing issue where in-use clocks without
   software reference are disabled by mistake during boot.
   One example of this is the handling of the Mackerel serial
   console output that shares clock with the I2C controller.

2) Write out the "disabled" state to the hardware for clocks
   that not have been used by the kernel. In other words,
   make sure so far unused clocks actually get turned off.
Signed-off-by: default avatarMagnus Damm <>
Acked-by: default avatarSimon Horman <>
Signed-off-by: default avatarPaul Mundt <>
parent bccaeafd
......@@ -34,6 +34,9 @@ static LIST_HEAD(clock_list);
static DEFINE_SPINLOCK(clock_lock);
static DEFINE_MUTEX(clock_list_sem);
/* clock disable operations are not passed on to hardware during boot */
static int allow_disable;
void clk_rate_table_build(struct clk *clk,
struct cpufreq_frequency_table *freq_table,
int nr_freqs,
......@@ -228,7 +231,7 @@ static void __clk_disable(struct clk *clk)
if (!(--clk->usecount)) {
if (likely(clk->ops && clk->ops->disable))
if (likely(allow_disable && clk->ops && clk->ops->disable))
if (likely(clk->parent))
......@@ -747,3 +750,25 @@ err_out:
return err;
static int __init clk_late_init(void)
unsigned long flags;
struct clk *clk;
/* disable all clocks with zero use count */
spin_lock_irqsave(&clock_lock, flags);
list_for_each_entry(clk, &clock_list, node)
if (!clk->usecount && clk->ops && clk->ops->disable)
/* from now on allow clock disable operations */
allow_disable = 1;
spin_unlock_irqrestore(&clock_lock, flags);
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment