xref: /rk3399_rockchip-uboot/arch/arm/include/asm/arch-omap4/sys_proto.h (revision 78f455c055ddf55a1a2dd6ae5e2d060ed2e5bd0e)
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 
30d34efc76SSteve Sakoman struct omap_sysinfo {
31d34efc76SSteve Sakoman 	char *board_string;
32d34efc76SSteve Sakoman };
33d2f18c27SAneesh V extern const struct omap_sysinfo sysinfo;
34d34efc76SSteve Sakoman 
3527952014SSteve Sakoman void gpmc_init(void);
36d34efc76SSteve Sakoman void watchdog_init(void);
37d34efc76SSteve Sakoman u32 get_device_type(void);
38469ec1e3SAneesh V void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
39508a58faSSricharan void set_muxconf_regs_essential(void);
40469ec1e3SAneesh V void set_muxconf_regs_non_essential(void);
410e7b6217SSteve Sakoman void sr32(void *, u32, u32, u32);
420e7b6217SSteve Sakoman u32 wait_on_value(u32, u32, void *, u32);
430e7b6217SSteve Sakoman void sdelay(unsigned long);
448b457fa8SAneesh V void set_pl310_ctrl_reg(u32 val);
45508a58faSSricharan void omap_rev_string(char *omap_rev_string);
46bcae7211SAneesh V void setup_clocks_for_console(void);
473776801dSAneesh V void prcm_init(void);
483776801dSAneesh V void bypass_dpll(u32 *const base);
493776801dSAneesh V void freq_update_core(void);
503776801dSAneesh V u32 get_sys_clk_freq(void);
513776801dSAneesh V u32 omap4_ddr_clk(void);
52095aea29SAneesh V void cancel_out(u32 *num, u32 *den, u32 den_limit);
532ae610f0SAneesh V void sdram_init(void);
54508a58faSSricharan u32 omap_sdram_size(void);
55508a58faSSricharan u32 cortex_rev(void);
56508a58faSSricharan void init_omap_revision(void);
57508a58faSSricharan void do_io_settings(void);
58*78f455c0SSricharan /*
59*78f455c0SSricharan  * This is used to verify if the configuration header
60*78f455c0SSricharan  * was executed by Romcode prior to control of transfer
61*78f455c0SSricharan  * to the bootloader. SPL is responsible for saving and
62*78f455c0SSricharan  * passing this to the u-boot.
63*78f455c0SSricharan  */
64*78f455c0SSricharan extern struct omap_boot_parameters boot_params;
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 	/*
77*78f455c0SSricharan 	 * u-boot can be running from sdram either because of configuration
78*78f455c0SSricharan 	 * Header or by SPL. If because of CH, then the romcode sets the
79*78f455c0SSricharan 	 * CHSETTINGS executed bit to true in the boot parameter structure that
80*78f455c0SSricharan 	 * it passes to the bootloader.This parameter is stored in the ch_flags
81*78f455c0SSricharan 	 * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
82*78f455c0SSricharan 	 * mandatory section if CH is present.
83d2f18c27SAneesh V 	 */
84*78f455c0SSricharan 	if ((boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
85*78f455c0SSricharan 		return 0;
86*78f455c0SSricharan 	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 
115ad577c8aSAneesh V static inline u32 omap_revision(void)
116ad577c8aSAneesh V {
117ad577c8aSAneesh V 	extern u32 *const omap4_revision;
118ad577c8aSAneesh V 	return *omap4_revision;
119ad577c8aSAneesh V }
120ad577c8aSAneesh V 
121d34efc76SSteve Sakoman #endif
122