mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-16 09:48:16 +00:00
7a0a550c7f
divider is calculated based on SCCR_DFBRG, with: SCCR_DFBRG 00 => divider 1 = 1 << 0 SCCR_DFBRG 01 => divider 4 = 1 << 2 SCCR_DFBRG 10 => divider 16 = 1 << 4 SCCR_DFBRG 11 => divider 64 = 1 << 6 This can be easily converted to a single shift operation: divider = 1 << (SCCR_DFBRG * 2) Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
44 lines
1 KiB
C
44 lines
1 KiB
C
/*
|
|
* (C) Copyright 2000-2004
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <mpc8xx.h>
|
|
#include <asm/processor.h>
|
|
#include <asm/io.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
/*
|
|
* get_clocks() fills in gd->cpu_clock depending on CONFIG_8xx_GCLK_FREQ
|
|
*/
|
|
int get_clocks(void)
|
|
{
|
|
uint immr = get_immr(0); /* Return full IMMR contents */
|
|
immap_t __iomem *immap = (immap_t __iomem *)(immr & 0xFFFF0000);
|
|
uint sccr = in_be32(&immap->im_clkrst.car_sccr);
|
|
uint divider = 1 << (((sccr & SCCR_DFBRG11) >> 11) * 2);
|
|
|
|
/*
|
|
* If for some reason measuring the gclk frequency won't
|
|
* work, we return the hardwired value.
|
|
* (For example, the cogent CMA286-60 CPU module has no
|
|
* separate oscillator for PITRTCLK)
|
|
*/
|
|
gd->cpu_clk = CONFIG_8xx_GCLK_FREQ;
|
|
|
|
if ((sccr & SCCR_EBDF11) == 0) {
|
|
/* No Bus Divider active */
|
|
gd->bus_clk = gd->cpu_clk;
|
|
} else {
|
|
/* The MPC8xx has only one BDF: half clock speed */
|
|
gd->bus_clk = gd->cpu_clk / 2;
|
|
}
|
|
|
|
gd->arch.brg_clk = gd->cpu_clk / divider;
|
|
|
|
return 0;
|
|
}
|