1d34efc76SSteve Sakoman /* 2d34efc76SSteve Sakoman * (C) Copyright 2010 3d34efc76SSteve Sakoman * Texas Instruments, <www.ti.com> 4d34efc76SSteve Sakoman * 5d34efc76SSteve Sakoman * This program is free software; you can redistribute it and/or 6d34efc76SSteve Sakoman * modify it under the terms of the GNU General Public License as 7d34efc76SSteve Sakoman * published by the Free Software Foundation; either version 2 of 8d34efc76SSteve Sakoman * the License, or (at your option) any later version. 9d34efc76SSteve Sakoman * 10d34efc76SSteve Sakoman * This program is distributed in the hope that it will be useful, 11d34efc76SSteve Sakoman * but WITHOUT ANY WARRANTY; without even the implied warranty of 12d34efc76SSteve Sakoman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13d34efc76SSteve Sakoman * GNU General Public License for more details. 14d34efc76SSteve Sakoman * 15d34efc76SSteve Sakoman * You should have received a copy of the GNU General Public License 16d34efc76SSteve Sakoman * along with this program; if not, write to the Free Software 17d34efc76SSteve Sakoman * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18d34efc76SSteve Sakoman * MA 02111-1307 USA 19d34efc76SSteve Sakoman */ 20d34efc76SSteve Sakoman 21d34efc76SSteve Sakoman #ifndef _SYS_PROTO_H_ 22d34efc76SSteve Sakoman #define _SYS_PROTO_H_ 23d34efc76SSteve Sakoman 24d34efc76SSteve Sakoman #include <asm/arch/omap4.h> 25d34efc76SSteve Sakoman #include <asm/io.h> 26*d2f18c27SAneesh V #include <asm/omap_common.h> 27d34efc76SSteve Sakoman 28d34efc76SSteve Sakoman struct omap_sysinfo { 29d34efc76SSteve Sakoman char *board_string; 30d34efc76SSteve Sakoman }; 31*d2f18c27SAneesh V extern const struct omap_sysinfo sysinfo; 32d34efc76SSteve Sakoman 3327952014SSteve Sakoman void gpmc_init(void); 34d34efc76SSteve Sakoman void watchdog_init(void); 35d34efc76SSteve Sakoman u32 get_device_type(void); 362ad853c3SSteve Sakoman void set_muxconf_regs(void); 370e7b6217SSteve Sakoman void sr32(void *, u32, u32, u32); 380e7b6217SSteve Sakoman u32 wait_on_value(u32, u32, void *, u32); 390e7b6217SSteve Sakoman void sdelay(unsigned long); 408b457fa8SAneesh V void set_pl310_ctrl_reg(u32 val); 41d34efc76SSteve Sakoman 42*d2f18c27SAneesh V static inline u32 running_from_sdram(void) 43*d2f18c27SAneesh V { 44*d2f18c27SAneesh V u32 pc; 45*d2f18c27SAneesh V asm volatile ("mov %0, pc" : "=r" (pc)); 46*d2f18c27SAneesh V return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) && 47*d2f18c27SAneesh V (pc < OMAP44XX_DRAM_ADDR_SPACE_END)); 48*d2f18c27SAneesh V } 49*d2f18c27SAneesh V 50*d2f18c27SAneesh V static inline u8 uboot_loaded_by_spl(void) 51*d2f18c27SAneesh V { 52*d2f18c27SAneesh V /* 53*d2f18c27SAneesh V * Configuration Header is not supported yet, so u-boot init running 54*d2f18c27SAneesh V * from SDRAM implies that it was loaded by SPL. When this situation 55*d2f18c27SAneesh V * changes one of these approaches could be taken: 56*d2f18c27SAneesh V * i. Pass a magic from SPL to U-Boot and U-Boot save it at a known 57*d2f18c27SAneesh V * location. 58*d2f18c27SAneesh V * ii. Check the OPP. CH can support only 50% OPP while SPL initializes 59*d2f18c27SAneesh V * the DPLLs at 100% OPP. 60*d2f18c27SAneesh V */ 61*d2f18c27SAneesh V return running_from_sdram(); 62*d2f18c27SAneesh V } 63*d2f18c27SAneesh V /* 64*d2f18c27SAneesh V * The basic hardware init of OMAP(s_init()) can happen in 4 65*d2f18c27SAneesh V * different contexts: 66*d2f18c27SAneesh V * 1. SPL running from SRAM 67*d2f18c27SAneesh V * 2. U-Boot running from FLASH 68*d2f18c27SAneesh V * 3. Non-XIP U-Boot loaded to SDRAM by SPL 69*d2f18c27SAneesh V * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the 70*d2f18c27SAneesh V * Configuration Header feature 71*d2f18c27SAneesh V * 72*d2f18c27SAneesh V * This function finds this context. 73*d2f18c27SAneesh V * Defining as inline may help in compiling out unused functions in SPL 74*d2f18c27SAneesh V */ 75*d2f18c27SAneesh V static inline u32 omap4_hw_init_context(void) 76*d2f18c27SAneesh V { 77*d2f18c27SAneesh V #ifdef CONFIG_SPL_BUILD 78*d2f18c27SAneesh V return OMAP_INIT_CONTEXT_SPL; 79*d2f18c27SAneesh V #else 80*d2f18c27SAneesh V if (uboot_loaded_by_spl()) 81*d2f18c27SAneesh V return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL; 82*d2f18c27SAneesh V else if (running_from_sdram()) 83*d2f18c27SAneesh V return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH; 84*d2f18c27SAneesh V else 85*d2f18c27SAneesh V return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR; 86*d2f18c27SAneesh V #endif 87*d2f18c27SAneesh V } 88d34efc76SSteve Sakoman 89d34efc76SSteve Sakoman #endif 90