blob: 3df6143d74884c60460639b5a7d3df6e62cb8e51 [file] [log] [blame]
Bo Shen3225f342013-05-12 22:40:54 +00001/*
2 * (C) Copyright 2010
3 * Reinhard Meyer, reinhard.meyer@emk-elektronik.de
4 * (C) Copyright 2009
5 * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
6 * (C) Copyright 2013
7 * Bo Shen <voice.shen@atmel.com>
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <common.h>
29#include <asm/io.h>
30#include <asm/arch/hardware.h>
31#include <asm/arch/at91_dbu.h>
32#include <asm/arch/at91_pmc.h>
33#include <asm/arch/at91_pit.h>
34#include <asm/arch/at91_gpbr.h>
35#include <asm/arch/clk.h>
36
37#ifndef CONFIG_SYS_AT91_MAIN_CLOCK
38#define CONFIG_SYS_AT91_MAIN_CLOCK 0
39#endif
40
41int arch_cpu_init(void)
42{
43 return at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
44}
45
46void arch_preboot_os(void)
47{
48 ulong cpiv;
49 at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT;
50
51 cpiv = AT91_PIT_MR_PIV_MASK(readl(&pit->piir));
52
53 /*
54 * Disable PITC
55 * Add 0x1000 to current counter to stop it faster
56 * without waiting for wrapping back to 0
57 */
58 writel(cpiv + 0x1000, &pit->mr);
59}
60
61#if defined(CONFIG_DISPLAY_CPUINFO)
62int print_cpuinfo(void)
63{
64 char buf[32];
65
66 printf("CPU: %s\n", get_cpu_name());
67 printf("Crystal frequency: %8s MHz\n",
68 strmhz(buf, get_main_clk_rate()));
69 printf("CPU clock : %8s MHz\n",
70 strmhz(buf, get_cpu_clk_rate()));
71 printf("Master clock : %8s MHz\n",
72 strmhz(buf, get_mck_clk_rate()));
73
74 return 0;
75}
76#endif
77
78void enable_caches(void)
79{
80}
81
82unsigned int get_chip_id(void)
83{
84 return readl(ATMEL_BASE_DBGU + AT91_DBU_CIDR) & ~AT91_DBU_CIDR_MASK;
85}
86
87unsigned int get_extension_chip_id(void)
88{
89 return readl(ATMEL_BASE_DBGU + AT91_DBU_EXID);
90}