blob: de4cc2ab84acd2926f5bb552bc6c7ef7819adda2 [file] [log] [blame]
Steve Sakoman1ad21582010-06-08 13:07:46 -07001/*
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>
Aneesh V04bd2b92010-09-12 10:32:55 +053033#include <asm/sizes.h>
Steve Sakoman1ad21582010-06-08 13:07:46 -070034
Nishanth Menon4e5dd662010-11-19 11:19:40 -050035DECLARE_GLOBAL_DATA_PTR;
36
Steve Sakoman1ad21582010-06-08 13:07:46 -070037/*
38 * Routine: s_init
39 * Description: Does early system init of muxing and clocks.
40 * - Called path is with SRAM stack.
41 */
42void s_init(void)
43{
44 watchdog_init();
45}
46
47/*
48 * Routine: wait_for_command_complete
49 * Description: Wait for posting to finish on watchdog
50 */
51void wait_for_command_complete(struct watchdog *wd_base)
52{
53 int pending = 1;
54 do {
55 pending = readl(&wd_base->wwps);
56 } while (pending);
57}
58
59/*
60 * Routine: watchdog_init
61 * Description: Shut down watch dogs
62 */
63void watchdog_init(void)
64{
65 struct watchdog *wd2_base = (struct watchdog *)WDT2_BASE;
66
67 writel(WD_UNLOCK1, &wd2_base->wspr);
68 wait_for_command_complete(wd2_base);
69 writel(WD_UNLOCK2, &wd2_base->wspr);
70}
71
Aneesh V04bd2b92010-09-12 10:32:55 +053072
73/*
74 * This function finds the SDRAM size available in the system
75 * based on DMM section configurations
76 * This is needed because the size of memory installed may be
77 * different on different versions of the board
78 */
79u32 sdram_size(void)
80{
81 u32 section, i, total_size = 0, size, addr;
82 for (i = 0; i < 4; i++) {
83 section = __raw_readl(DMM_LISA_MAP_BASE + i*4);
84 addr = section & DMM_LISA_MAP_SYS_ADDR_MASK;
85 /* See if the address is valid */
86 if ((addr >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
87 (addr < OMAP44XX_DRAM_ADDR_SPACE_END)) {
88 size = ((section & DMM_LISA_MAP_SYS_SIZE_MASK) >>
89 DMM_LISA_MAP_SYS_SIZE_SHIFT);
90 size = 1 << size;
91 size *= SZ_16M;
92 total_size += size;
93 }
94 }
95 return total_size;
96}
97
98
Steve Sakoman1ad21582010-06-08 13:07:46 -070099/*
100 * Routine: dram_init
101 * Description: sets uboots idea of sdram size
102 */
103int dram_init(void)
104{
Steve Sakoman1ad21582010-06-08 13:07:46 -0700105
Steve Sakoman97c57f12010-09-29 20:59:51 -0700106 gd->ram_size = sdram_size();
Steve Sakoman97c57f12010-09-29 20:59:51 -0700107
Steve Sakoman1ad21582010-06-08 13:07:46 -0700108 return 0;
109}
110
111/*
112 * Print board information
113 */
114int checkboard(void)
115{
116 puts(sysinfo.board_string);
117 return 0;
118}
119
Steve Sakoman9bb65b52010-07-15 13:43:10 -0700120/*
121* This function is called by start_armboot. You can reliably use static
122* data. Any boot-time function that require static data should be
123* called from here
124*/
125int arch_cpu_init(void)
126{
127 set_muxconf_regs();
128 return 0;
129}
Aneesh Ve3405bd2011-06-16 23:30:52 +0000130
131#ifndef CONFIG_SYS_L2CACHE_OFF
132void v7_outer_cache_enable(void)
133{
134 set_pl310_ctrl_reg(1);
135}
136
137void v7_outer_cache_disable(void)
138{
139 set_pl310_ctrl_reg(0);
140}
141#endif