summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6/cpu/spc300/masterclk.c
blob: c86e2c8a6932d2d1947063176aec3231a47a6714 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * 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 <common.h>
#include <config.h>
#include <asm/arch/nvram.h>

/**
 * 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;

    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_FEATURE_FIXED_MASTER_CLOCK */

    return masterclk;
}