Merge branch 'next' of git://git.denx.de/u-boot-video
[platform/kernel/u-boot.git] / arch / arm / cpu / armv7 / omap4 / board.c
1 /*
2  *
3  * Common functions for OMAP4 based boards
4  *
5  * (C) Copyright 2010
6  * Texas Instruments, <www.ti.com>
7  *
8  * Author :
9  *      Aneesh V        <aneesh@ti.com>
10  *      Steve Sakoman   <steve@sakoman.com>
11  *
12  * See file CREDITS for list of people who contributed to this
13  * project.
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License as
17  * published by the Free Software Foundation; either version 2 of
18  * the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28  * MA 02111-1307 USA
29  */
30 #include <common.h>
31 #include <asm/arch/cpu.h>
32 #include <asm/arch/sys_proto.h>
33 #include <asm/sizes.h>
34
35 /*
36  * Routine: s_init
37  * Description: Does early system init of muxing and clocks.
38  *              - Called path is with SRAM stack.
39  */
40 void s_init(void)
41 {
42         watchdog_init();
43 }
44
45 /*
46  * Routine: wait_for_command_complete
47  * Description: Wait for posting to finish on watchdog
48  */
49 void wait_for_command_complete(struct watchdog *wd_base)
50 {
51         int pending = 1;
52         do {
53                 pending = readl(&wd_base->wwps);
54         } while (pending);
55 }
56
57 /*
58  * Routine: watchdog_init
59  * Description: Shut down watch dogs
60  */
61 void watchdog_init(void)
62 {
63         struct watchdog *wd2_base = (struct watchdog *)WDT2_BASE;
64
65         writel(WD_UNLOCK1, &wd2_base->wspr);
66         wait_for_command_complete(wd2_base);
67         writel(WD_UNLOCK2, &wd2_base->wspr);
68 }
69
70
71 /*
72  * This function finds the SDRAM size available in the system
73  * based on DMM section configurations
74  * This is needed because the size of memory installed may be
75  * different on different versions of the board
76  */
77 u32 sdram_size(void)
78 {
79         u32 section, i, total_size = 0, size, addr;
80         for (i = 0; i < 4; i++) {
81                 section = __raw_readl(DMM_LISA_MAP_BASE + i*4);
82                 addr = section & DMM_LISA_MAP_SYS_ADDR_MASK;
83                 /* See if the address is valid */
84                 if ((addr >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
85                     (addr < OMAP44XX_DRAM_ADDR_SPACE_END)) {
86                         size    = ((section & DMM_LISA_MAP_SYS_SIZE_MASK) >>
87                                     DMM_LISA_MAP_SYS_SIZE_SHIFT);
88                         size    = 1 << size;
89                         size    *= SZ_16M;
90                         total_size += size;
91                 }
92         }
93         return total_size;
94 }
95
96
97 /*
98  * Routine: dram_init
99  * Description: sets uboots idea of sdram size
100  */
101 int dram_init(void)
102 {
103         DECLARE_GLOBAL_DATA_PTR;
104
105         gd->bd->bi_dram[0].start = 0x80000000;
106         gd->bd->bi_dram[0].size = sdram_size();
107         return 0;
108 }
109
110 /*
111  * Print board information
112  */
113 int checkboard(void)
114 {
115         puts(sysinfo.board_string);
116         return 0;
117 }
118
119 /*
120 * This function is called by start_armboot. You can reliably use static
121 * data. Any boot-time function that require static data should be
122 * called from here
123 */
124 int arch_cpu_init(void)
125 {
126         set_muxconf_regs();
127         return 0;
128 }