Skip to content

Commit f34e465

Browse files
Nicolas Saenz Juliennebebarino
authored andcommitted
clk: bcm2835: Do not use prediv with bcm2711's PLLs
Contrary to previous SoCs, bcm2711 doesn't have a prescaler in the PLL feedback loop. Bypass it by zeroing fb_prediv_mask when running on bcm2711. Note that, since the prediv configuration bits were re-purposed, this was triggering miscalculations on all clocks hanging from the VPU clock, notably the aux UART, making its output unintelligible. Fixes: 42de9ad ("clk: bcm2835: Add BCM2711_CLOCK_EMMC2 support") Reported-by: Nathan Chancellor <[email protected]> Signed-off-by: Nicolas Saenz Julienne <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 2a08a92 commit f34e465

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

drivers/clk/bcm/clk-bcm2835.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ struct bcm2835_cprman {
314314
struct device *dev;
315315
void __iomem *regs;
316316
spinlock_t regs_lock; /* spinlock for all clocks */
317+
unsigned int soc;
317318

318319
/*
319320
* Real names of cprman clock parents looked up through
@@ -526,6 +527,20 @@ static int bcm2835_pll_is_on(struct clk_hw *hw)
526527
A2W_PLL_CTRL_PRST_DISABLE;
527528
}
528529

530+
static u32 bcm2835_pll_get_prediv_mask(struct bcm2835_cprman *cprman,
531+
const struct bcm2835_pll_data *data)
532+
{
533+
/*
534+
* On BCM2711 there isn't a pre-divisor available in the PLL feedback
535+
* loop. Bits 13:14 of ANA1 (PLLA,PLLB,PLLC,PLLD) have been re-purposed
536+
* for to for VCO RANGE bits.
537+
*/
538+
if (cprman->soc & SOC_BCM2711)
539+
return 0;
540+
541+
return data->ana->fb_prediv_mask;
542+
}
543+
529544
static void bcm2835_pll_choose_ndiv_and_fdiv(unsigned long rate,
530545
unsigned long parent_rate,
531546
u32 *ndiv, u32 *fdiv)
@@ -583,7 +598,7 @@ static unsigned long bcm2835_pll_get_rate(struct clk_hw *hw,
583598
ndiv = (a2wctrl & A2W_PLL_CTRL_NDIV_MASK) >> A2W_PLL_CTRL_NDIV_SHIFT;
584599
pdiv = (a2wctrl & A2W_PLL_CTRL_PDIV_MASK) >> A2W_PLL_CTRL_PDIV_SHIFT;
585600
using_prediv = cprman_read(cprman, data->ana_reg_base + 4) &
586-
data->ana->fb_prediv_mask;
601+
bcm2835_pll_get_prediv_mask(cprman, data);
587602

588603
if (using_prediv) {
589604
ndiv *= 2;
@@ -666,6 +681,7 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw,
666681
struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
667682
struct bcm2835_cprman *cprman = pll->cprman;
668683
const struct bcm2835_pll_data *data = pll->data;
684+
u32 prediv_mask = bcm2835_pll_get_prediv_mask(cprman, data);
669685
bool was_using_prediv, use_fb_prediv, do_ana_setup_first;
670686
u32 ndiv, fdiv, a2w_ctl;
671687
u32 ana[4];
@@ -683,7 +699,7 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw,
683699
for (i = 3; i >= 0; i--)
684700
ana[i] = cprman_read(cprman, data->ana_reg_base + i * 4);
685701

686-
was_using_prediv = ana[1] & data->ana->fb_prediv_mask;
702+
was_using_prediv = ana[1] & prediv_mask;
687703

688704
ana[0] &= ~data->ana->mask0;
689705
ana[0] |= data->ana->set0;
@@ -693,10 +709,10 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw,
693709
ana[3] |= data->ana->set3;
694710

695711
if (was_using_prediv && !use_fb_prediv) {
696-
ana[1] &= ~data->ana->fb_prediv_mask;
712+
ana[1] &= ~prediv_mask;
697713
do_ana_setup_first = true;
698714
} else if (!was_using_prediv && use_fb_prediv) {
699-
ana[1] |= data->ana->fb_prediv_mask;
715+
ana[1] |= prediv_mask;
700716
do_ana_setup_first = false;
701717
} else {
702718
do_ana_setup_first = true;
@@ -2262,6 +2278,7 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
22622278
platform_set_drvdata(pdev, cprman);
22632279

22642280
cprman->onecell.num = asize;
2281+
cprman->soc = pdata->soc;
22652282
hws = cprman->onecell.hws;
22662283

22672284
for (i = 0; i < asize; i++) {

0 commit comments

Comments
 (0)