Steve Sakoman | 1ad2158 | 2010-06-08 13:07:46 -0700 | [diff] [blame] | 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> |
Aneesh V | 04bd2b9 | 2010-09-12 10:32:55 +0530 | [diff] [blame] | 33 | #include <asm/sizes.h> |
Steve Sakoman | 1ad2158 | 2010-06-08 13:07:46 -0700 | [diff] [blame] | 34 | |
Nishanth Menon | 4e5dd66 | 2010-11-19 11:19:40 -0500 | [diff] [blame^] | 35 | DECLARE_GLOBAL_DATA_PTR; |
| 36 | |
Steve Sakoman | 1ad2158 | 2010-06-08 13:07:46 -0700 | [diff] [blame] | 37 | /* |
| 38 | * Routine: s_init |
| 39 | * Description: Does early system init of muxing and clocks. |
| 40 | * - Called path is with SRAM stack. |
| 41 | */ |
| 42 | void 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 | */ |
| 51 | void 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 | */ |
| 63 | void 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 V | 04bd2b9 | 2010-09-12 10:32:55 +0530 | [diff] [blame] | 72 | |
| 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 | */ |
| 79 | u32 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 Sakoman | 1ad2158 | 2010-06-08 13:07:46 -0700 | [diff] [blame] | 99 | /* |
| 100 | * Routine: dram_init |
| 101 | * Description: sets uboots idea of sdram size |
| 102 | */ |
| 103 | int dram_init(void) |
| 104 | { |
Steve Sakoman | 1ad2158 | 2010-06-08 13:07:46 -0700 | [diff] [blame] | 105 | |
Steve Sakoman | 97c57f1 | 2010-09-29 20:59:51 -0700 | [diff] [blame] | 106 | gd->ram_size = sdram_size(); |
Steve Sakoman | 97c57f1 | 2010-09-29 20:59:51 -0700 | [diff] [blame] | 107 | |
Steve Sakoman | 1ad2158 | 2010-06-08 13:07:46 -0700 | [diff] [blame] | 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | * Print board information |
| 113 | */ |
| 114 | int checkboard(void) |
| 115 | { |
| 116 | puts(sysinfo.board_string); |
| 117 | return 0; |
| 118 | } |
| 119 | |
Steve Sakoman | 9bb65b5 | 2010-07-15 13:43:10 -0700 | [diff] [blame] | 120 | /* |
| 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 | */ |
| 125 | int arch_cpu_init(void) |
| 126 | { |
| 127 | set_muxconf_regs(); |
| 128 | return 0; |
| 129 | } |