1907208c4SChristophe Leroy /* 2907208c4SChristophe Leroy * (C) Copyright 2000-2004 3907208c4SChristophe Leroy * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4907208c4SChristophe Leroy * 5907208c4SChristophe Leroy * SPDX-License-Identifier: GPL-2.0+ 6907208c4SChristophe Leroy */ 7907208c4SChristophe Leroy 8907208c4SChristophe Leroy #include <common.h> 9907208c4SChristophe Leroy #include <mpc8xx.h> 10907208c4SChristophe Leroy #include <asm/processor.h> 11ba3da734SChristophe Leroy #include <asm/io.h> 12907208c4SChristophe Leroy 13907208c4SChristophe Leroy DECLARE_GLOBAL_DATA_PTR; 14907208c4SChristophe Leroy 15907208c4SChristophe Leroy /* 16907208c4SChristophe Leroy * get_clocks() fills in gd->cpu_clock depending on CONFIG_8xx_GCLK_FREQ 17907208c4SChristophe Leroy */ get_clocks(void)18907208c4SChristophe Leroyint get_clocks(void) 19907208c4SChristophe Leroy { 20907208c4SChristophe Leroy uint immr = get_immr(0); /* Return full IMMR contents */ 21ba3da734SChristophe Leroy immap_t __iomem *immap = (immap_t __iomem *)(immr & 0xFFFF0000); 22ba3da734SChristophe Leroy uint sccr = in_be32(&immap->im_clkrst.car_sccr); 23*7a0a550cSChristophe Leroy uint divider = 1 << (((sccr & SCCR_DFBRG11) >> 11) * 2); 24*7a0a550cSChristophe Leroy 25907208c4SChristophe Leroy /* 26907208c4SChristophe Leroy * If for some reason measuring the gclk frequency won't 27907208c4SChristophe Leroy * work, we return the hardwired value. 28907208c4SChristophe Leroy * (For example, the cogent CMA286-60 CPU module has no 29907208c4SChristophe Leroy * separate oscillator for PITRTCLK) 30907208c4SChristophe Leroy */ 31907208c4SChristophe Leroy gd->cpu_clk = CONFIG_8xx_GCLK_FREQ; 32907208c4SChristophe Leroy 33907208c4SChristophe Leroy if ((sccr & SCCR_EBDF11) == 0) { 34907208c4SChristophe Leroy /* No Bus Divider active */ 35907208c4SChristophe Leroy gd->bus_clk = gd->cpu_clk; 36907208c4SChristophe Leroy } else { 37907208c4SChristophe Leroy /* The MPC8xx has only one BDF: half clock speed */ 38907208c4SChristophe Leroy gd->bus_clk = gd->cpu_clk / 2; 39907208c4SChristophe Leroy } 40907208c4SChristophe Leroy 41*7a0a550cSChristophe Leroy gd->arch.brg_clk = gd->cpu_clk / divider; 42907208c4SChristophe Leroy 4370fd0710SChristophe Leroy return 0; 44907208c4SChristophe Leroy } 45