]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/at91/cpu.c
Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / at91 / cpu.c
1 /*
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
41 int arch_cpu_init(void)
42 {
43         return at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
44 }
45
46 void 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)
62 int 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
78 void enable_caches(void)
79 {
80 }
81
82 unsigned int get_chip_id(void)
83 {
84         return readl(ATMEL_BASE_DBGU + AT91_DBU_CIDR) & ~AT91_DBU_CIDR_MASK;
85 }
86
87 unsigned int get_extension_chip_id(void)
88 {
89         return readl(ATMEL_BASE_DBGU + AT91_DBU_EXID);
90 }