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 24508a58faSSricharan #include <asm/arch/omap.h> 253776801dSAneesh V #include <asm/arch/clocks.h> 26d34efc76SSteve Sakoman #include <asm/io.h> 27d2f18c27SAneesh V #include <asm/omap_common.h> 28469ec1e3SAneesh V #include <asm/arch/mux_omap4.h> 29d34efc76SSteve Sakoman 304a0eb757SSRICHARAN R DECLARE_GLOBAL_DATA_PTR; 314a0eb757SSRICHARAN R 32d34efc76SSteve Sakoman struct omap_sysinfo { 33d34efc76SSteve Sakoman char *board_string; 34d34efc76SSteve Sakoman }; 35d2f18c27SAneesh V extern const struct omap_sysinfo sysinfo; 36d34efc76SSteve Sakoman 3727952014SSteve Sakoman void gpmc_init(void); 38d34efc76SSteve Sakoman void watchdog_init(void); 39d34efc76SSteve Sakoman u32 get_device_type(void); 40469ec1e3SAneesh V void do_set_mux(u32 base, struct pad_conf_entry const *array, int size); 41508a58faSSricharan void set_muxconf_regs_essential(void); 42469ec1e3SAneesh V void set_muxconf_regs_non_essential(void); 430e7b6217SSteve Sakoman void sr32(void *, u32, u32, u32); 440e7b6217SSteve Sakoman u32 wait_on_value(u32, u32, void *, u32); 450e7b6217SSteve Sakoman void sdelay(unsigned long); 468b457fa8SAneesh V void set_pl310_ctrl_reg(u32 val); 47bcae7211SAneesh V void setup_clocks_for_console(void); 483776801dSAneesh V void prcm_init(void); 4901b753ffSSRICHARAN R void bypass_dpll(u32 const base); 503776801dSAneesh V void freq_update_core(void); 513776801dSAneesh V u32 get_sys_clk_freq(void); 523776801dSAneesh V u32 omap4_ddr_clk(void); 53095aea29SAneesh V void cancel_out(u32 *num, u32 *den, u32 den_limit); 542ae610f0SAneesh V void sdram_init(void); 55508a58faSSricharan u32 omap_sdram_size(void); 56508a58faSSricharan u32 cortex_rev(void); 57*4596dcc1STom Rini void save_omap_boot_params(void); 58508a58faSSricharan void init_omap_revision(void); 59508a58faSSricharan void do_io_settings(void); 60a78274b2SNishanth Menon void omap_vc_init(u16 speed_khz); 61a78274b2SNishanth Menon int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data); 6270239507SLokesh Vutla u32 warm_reset(void); 6338f25b12SLokesh Vutla void force_emif_self_refresh(void); 640b1b60c7SLokesh Vutla void setup_warmreset_time(void); 65d34efc76SSteve Sakoman 66d2f18c27SAneesh V static inline u32 running_from_sdram(void) 67d2f18c27SAneesh V { 68d2f18c27SAneesh V u32 pc; 69d2f18c27SAneesh V asm volatile ("mov %0, pc" : "=r" (pc)); 70d2f18c27SAneesh V return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) && 71d2f18c27SAneesh V (pc < OMAP44XX_DRAM_ADDR_SPACE_END)); 72d2f18c27SAneesh V } 73d2f18c27SAneesh V 74d2f18c27SAneesh V static inline u8 uboot_loaded_by_spl(void) 75d2f18c27SAneesh V { 76d2f18c27SAneesh V /* 7778f455c0SSricharan * u-boot can be running from sdram either because of configuration 7878f455c0SSricharan * Header or by SPL. If because of CH, then the romcode sets the 7978f455c0SSricharan * CHSETTINGS executed bit to true in the boot parameter structure that 8078f455c0SSricharan * it passes to the bootloader.This parameter is stored in the ch_flags 8178f455c0SSricharan * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a 8278f455c0SSricharan * mandatory section if CH is present. 83d2f18c27SAneesh V */ 844a0eb757SSRICHARAN R if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS)) 8578f455c0SSricharan return 0; 8678f455c0SSricharan else 87d2f18c27SAneesh V return running_from_sdram(); 88d2f18c27SAneesh V } 89d2f18c27SAneesh V /* 90d2f18c27SAneesh V * The basic hardware init of OMAP(s_init()) can happen in 4 91d2f18c27SAneesh V * different contexts: 92d2f18c27SAneesh V * 1. SPL running from SRAM 93d2f18c27SAneesh V * 2. U-Boot running from FLASH 94d2f18c27SAneesh V * 3. Non-XIP U-Boot loaded to SDRAM by SPL 95d2f18c27SAneesh V * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the 96d2f18c27SAneesh V * Configuration Header feature 97d2f18c27SAneesh V * 98d2f18c27SAneesh V * This function finds this context. 99d2f18c27SAneesh V * Defining as inline may help in compiling out unused functions in SPL 100d2f18c27SAneesh V */ 101508a58faSSricharan static inline u32 omap_hw_init_context(void) 102d2f18c27SAneesh V { 103d2f18c27SAneesh V #ifdef CONFIG_SPL_BUILD 104d2f18c27SAneesh V return OMAP_INIT_CONTEXT_SPL; 105d2f18c27SAneesh V #else 106d2f18c27SAneesh V if (uboot_loaded_by_spl()) 107d2f18c27SAneesh V return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL; 108d2f18c27SAneesh V else if (running_from_sdram()) 109d2f18c27SAneesh V return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH; 110d2f18c27SAneesh V else 111d2f18c27SAneesh V return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR; 112d2f18c27SAneesh V #endif 113d2f18c27SAneesh V } 114d34efc76SSteve Sakoman 115d34efc76SSteve Sakoman #endif 116