xref: /rk3399_rockchip-uboot/arch/arm/include/asm/arch-omap4/sys_proto.h (revision ad577c8a487ac0ab277540f5fe2ea654d98d8e9f)
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>
26d2f18c27SAneesh V #include <asm/omap_common.h>
27469ec1e3SAneesh V #include <asm/arch/mux_omap4.h>
28d34efc76SSteve Sakoman 
29d34efc76SSteve Sakoman struct omap_sysinfo {
30d34efc76SSteve Sakoman 	char *board_string;
31d34efc76SSteve Sakoman };
32d2f18c27SAneesh V extern const struct omap_sysinfo sysinfo;
33d34efc76SSteve Sakoman 
3427952014SSteve Sakoman void gpmc_init(void);
35d34efc76SSteve Sakoman void watchdog_init(void);
36d34efc76SSteve Sakoman u32 get_device_type(void);
37469ec1e3SAneesh V void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
38469ec1e3SAneesh V void set_muxconf_regs_non_essential(void);
390e7b6217SSteve Sakoman void sr32(void *, u32, u32, u32);
400e7b6217SSteve Sakoman u32 wait_on_value(u32, u32, void *, u32);
410e7b6217SSteve Sakoman void sdelay(unsigned long);
428b457fa8SAneesh V void set_pl310_ctrl_reg(u32 val);
43*ad577c8aSAneesh V void omap_rev_string(char *omap4_rev_string);
44d34efc76SSteve Sakoman 
45d2f18c27SAneesh V static inline u32 running_from_sdram(void)
46d2f18c27SAneesh V {
47d2f18c27SAneesh V 	u32 pc;
48d2f18c27SAneesh V 	asm volatile ("mov %0, pc" : "=r" (pc));
49d2f18c27SAneesh V 	return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
50d2f18c27SAneesh V 	    (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
51d2f18c27SAneesh V }
52d2f18c27SAneesh V 
53d2f18c27SAneesh V static inline u8 uboot_loaded_by_spl(void)
54d2f18c27SAneesh V {
55d2f18c27SAneesh V 	/*
56d2f18c27SAneesh V 	 * Configuration Header is not supported yet, so u-boot init running
57d2f18c27SAneesh V 	 * from SDRAM implies that it was loaded by SPL. When this situation
58d2f18c27SAneesh V 	 * changes one of these approaches could be taken:
59d2f18c27SAneesh V 	 * i.  Pass a magic from SPL to U-Boot and U-Boot save it at a known
60d2f18c27SAneesh V 	 *     location.
61d2f18c27SAneesh V 	 * ii. Check the OPP. CH can support only 50% OPP while SPL initializes
62d2f18c27SAneesh V 	 *     the DPLLs at 100% OPP.
63d2f18c27SAneesh V 	 */
64d2f18c27SAneesh V 	return running_from_sdram();
65d2f18c27SAneesh V }
66d2f18c27SAneesh V /*
67d2f18c27SAneesh V  * The basic hardware init of OMAP(s_init()) can happen in 4
68d2f18c27SAneesh V  * different contexts:
69d2f18c27SAneesh V  *  1. SPL running from SRAM
70d2f18c27SAneesh V  *  2. U-Boot running from FLASH
71d2f18c27SAneesh V  *  3. Non-XIP U-Boot loaded to SDRAM by SPL
72d2f18c27SAneesh V  *  4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
73d2f18c27SAneesh V  *     Configuration Header feature
74d2f18c27SAneesh V  *
75d2f18c27SAneesh V  * This function finds this context.
76d2f18c27SAneesh V  * Defining as inline may help in compiling out unused functions in SPL
77d2f18c27SAneesh V  */
78d2f18c27SAneesh V static inline u32 omap4_hw_init_context(void)
79d2f18c27SAneesh V {
80d2f18c27SAneesh V #ifdef CONFIG_SPL_BUILD
81d2f18c27SAneesh V 	return OMAP_INIT_CONTEXT_SPL;
82d2f18c27SAneesh V #else
83d2f18c27SAneesh V 	if (uboot_loaded_by_spl())
84d2f18c27SAneesh V 		return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
85d2f18c27SAneesh V 	else if (running_from_sdram())
86d2f18c27SAneesh V 		return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
87d2f18c27SAneesh V 	else
88d2f18c27SAneesh V 		return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
89d2f18c27SAneesh V #endif
90d2f18c27SAneesh V }
91d34efc76SSteve Sakoman 
92*ad577c8aSAneesh V static inline u32 omap_revision(void)
93*ad577c8aSAneesh V {
94*ad577c8aSAneesh V 	extern u32 *const omap4_revision;
95*ad577c8aSAneesh V 	return *omap4_revision;
96*ad577c8aSAneesh V }
97*ad577c8aSAneesh V 
98d34efc76SSteve Sakoman #endif
99