/* * cpu/spc300/masterclk.c * * Copyright (C) 2012 SPiDCOM Technologies * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include #include #include /** * Get master clock from NVRAM * * \return master clock value in Hz. */ ulong get_master_clock(void) { ulong masterclk; #ifdef CONFIG_CHIP_FEATURE_FIXED_MASTER_CLOCK masterclk = CONFIG_CHIP_MAX_MASTER_CLOCK; #else DECLARE_GLOBAL_DATA_PTR; bd_t *bd = gd->bd; spidcom_nvram_t *nvram = (spidcom_nvram_t*)bd->bi_nvram_addr; #ifdef CONFIG_CHIP_MSE500 switch(NVRAM_BFEXT(MSE500_MODE, nvram->pkg_cfg)) { case NVRAM_MSE500_MODE_200: masterclk = 96000000; break; case NVRAM_MSE500_MODE_300: case NVRAM_MSE500_MODE_500: default: masterclk = 246000000; break; } #else switch(NVRAM_BFEXT(FREQ, nvram->pkg_cfg)) { case NVRAM_FREQ_100: masterclk = 100000000; break; case NVRAM_FREQ_125: masterclk = 125000000; break; case NVRAM_FREQ_133: masterclk = 133000000; break; case NVRAM_FREQ_150: default: masterclk = 147000000; break; } #endif /* CONFIG_CHIP_MSE500 */ #endif /* CONFIG_CHIP_FEATURE_FIXED_MASTER_CLOCK */ return masterclk; }