Skip to content

Commit d1d797b

Browse files
anholtpopcornmix
authored andcommitted
clk: bcm2835: Allow reparenting leaf clocks while they're running.
This falls under the same "we can reprogram glitch-free as long as we pause generation" rule as updating the div/frac fields. This can be used for runtime reclocking of V3D to manage power leakage. Signed-off-by: Eric Anholt <eric@anholt.net>
1 parent c4d5ef6 commit d1d797b

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎drivers/clk/bcm/clk-bcm2835.c‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,10 @@ static int bcm2835_clock_on(struct clk_hw *hw)
11041104
return 0;
11051105
}
11061106

1107-
static int bcm2835_clock_set_rate(struct clk_hw *hw,
1108-
unsigned long rate, unsigned long parent_rate)
1107+
static int bcm2835_clock_set_rate_and_parent(struct clk_hw *hw,
1108+
unsigned long rate,
1109+
unsigned long parent_rate,
1110+
u8 parent)
11091111
{
11101112
struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
11111113
struct bcm2835_cprman *cprman = clock->cprman;
@@ -1127,6 +1129,11 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw,
11271129
bcm2835_clock_wait_busy(clock);
11281130
}
11291131

1132+
if (parent != 0xff) {
1133+
ctl &= ~(CM_SRC_MASK << CM_SRC_SHIFT);
1134+
ctl |= parent << CM_SRC_SHIFT;
1135+
}
1136+
11301137
ctl &= ~CM_FRAC;
11311138
ctl |= (div & CM_DIV_FRAC_MASK) ? CM_FRAC : 0;
11321139
cprman_write(cprman, data->ctl_reg, ctl);
@@ -1138,6 +1145,12 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw,
11381145
return 0;
11391146
}
11401147

1148+
static int bcm2835_clock_set_rate(struct clk_hw *hw,
1149+
unsigned long rate, unsigned long parent_rate)
1150+
{
1151+
return bcm2835_clock_set_rate_and_parent(hw, rate, parent_rate, 0xff);
1152+
}
1153+
11411154
static bool
11421155
bcm2835_clk_is_pllc(struct clk_hw *hw)
11431156
{
@@ -1321,6 +1334,7 @@ static const struct clk_ops bcm2835_clock_clk_ops = {
13211334
.unprepare = bcm2835_clock_off,
13221335
.recalc_rate = bcm2835_clock_get_rate,
13231336
.set_rate = bcm2835_clock_set_rate,
1337+
.set_rate_and_parent = bcm2835_clock_set_rate_and_parent,
13241338
.determine_rate = bcm2835_clock_determine_rate,
13251339
.set_parent = bcm2835_clock_set_parent,
13261340
.get_parent = bcm2835_clock_get_parent,
@@ -1503,7 +1517,6 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
15031517
init.ops = &bcm2835_vpu_clock_clk_ops;
15041518
} else {
15051519
init.ops = &bcm2835_clock_clk_ops;
1506-
init.flags |= CLK_SET_PARENT_GATE;
15071520

15081521
/* If the clock wasn't actually enabled at boot, it's not
15091522
* critical.

0 commit comments

Comments
 (0)