blob: 39c531632e089a59747007634a5ca5ffc700f39f [file] [log] [blame]
Minkyu Kangae6f0c62009-07-20 11:40:01 +09001/*
Steve Sakoman1ad21582010-06-08 13:07:46 -07002 * (C) Copyright 2010
3 * Texas Instruments, <www.ti.com>
Minkyu Kangae6f0c62009-07-20 11:40:01 +09004 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Minkyu Kangae6f0c62009-07-20 11:40:01 +09006 */
7
Steve Sakoman1ad21582010-06-08 13:07:46 -07008#ifndef _SYS_PROTO_H_
9#define _SYS_PROTO_H_
10
Sricharan9310ff72011-11-15 09:49:55 -050011#include <asm/arch/omap.h>
Lokesh Vutla61c517f2013-05-30 02:54:32 +000012#include <asm/arch/clock.h>
Steve Sakoman1ad21582010-06-08 13:07:46 -070013#include <asm/io.h>
Aneesh V30679422011-07-21 09:09:59 -040014#include <asm/omap_common.h>
Aneesh Vf908b632011-07-21 09:10:01 -040015#include <asm/arch/mux_omap4.h>
Steve Sakoman1ad21582010-06-08 13:07:46 -070016
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000017DECLARE_GLOBAL_DATA_PTR;
18
Steve Sakoman1ad21582010-06-08 13:07:46 -070019struct omap_sysinfo {
20 char *board_string;
21};
Aneesh V30679422011-07-21 09:09:59 -040022extern const struct omap_sysinfo sysinfo;
Steve Sakoman1ad21582010-06-08 13:07:46 -070023
Steve Sakoman9b8ea4e2010-07-15 16:19:16 -040024void gpmc_init(void);
Steve Sakoman1ad21582010-06-08 13:07:46 -070025void watchdog_init(void);
26u32 get_device_type(void);
Aneesh Vf908b632011-07-21 09:10:01 -040027void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
Sricharan9310ff72011-11-15 09:49:55 -050028void set_muxconf_regs_essential(void);
Aneesh Vf908b632011-07-21 09:10:01 -040029void set_muxconf_regs_non_essential(void);
Steve Sakoman6e09a762010-08-04 09:39:40 -070030void sr32(void *, u32, u32, u32);
31u32 wait_on_value(u32, u32, void *, u32);
32void sdelay(unsigned long);
Aneesh Ve3405bd2011-06-16 23:30:52 +000033void set_pl310_ctrl_reg(u32 val);
Aneesh Vb8e60b92011-07-21 09:10:21 -040034void setup_clocks_for_console(void);
Aneesh V0d2628b2011-07-21 09:10:07 -040035void prcm_init(void);
SRICHARAN Rfb6aa1f2013-02-04 04:22:00 +000036void bypass_dpll(u32 const base);
Aneesh V0d2628b2011-07-21 09:10:07 -040037void freq_update_core(void);
38u32 get_sys_clk_freq(void);
39u32 omap4_ddr_clk(void);
Aneesh Vc0e88522011-07-21 09:10:12 -040040void cancel_out(u32 *num, u32 *den, u32 den_limit);
Aneesh Vcc565582011-07-21 09:10:09 -040041void sdram_init(void);
Sricharan9310ff72011-11-15 09:49:55 -050042u32 omap_sdram_size(void);
43u32 cortex_rev(void);
Tom Rini51df26c2013-05-31 12:31:59 -040044void save_omap_boot_params(void);
Sricharan9310ff72011-11-15 09:49:55 -050045void init_omap_revision(void);
46void do_io_settings(void);
Lokesh Vutlaae49f6d2013-05-30 02:54:33 +000047void sri2c_init(void);
Lokesh Vutla36852972013-05-30 03:19:29 +000048void gpi2c_init(void);
Nishanth Menon41d7ab12012-03-01 14:17:37 +000049int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
Lokesh Vutlae89f1542012-05-29 19:26:41 +000050u32 warm_reset(void);
Lokesh Vutlaba873772012-05-29 19:26:43 +000051void force_emif_self_refresh(void);
Lokesh Vutla100c2d82013-04-17 20:49:40 +000052void setup_warmreset_time(void);
Steve Sakoman1ad21582010-06-08 13:07:46 -070053
Aneesh V30679422011-07-21 09:09:59 -040054static inline u32 running_from_sdram(void)
55{
56 u32 pc;
57 asm volatile ("mov %0, pc" : "=r" (pc));
58 return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
59 (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
60}
61
62static inline u8 uboot_loaded_by_spl(void)
63{
64 /*
Sricharan308fe922011-11-15 09:50:03 -050065 * u-boot can be running from sdram either because of configuration
66 * Header or by SPL. If because of CH, then the romcode sets the
67 * CHSETTINGS executed bit to true in the boot parameter structure that
68 * it passes to the bootloader.This parameter is stored in the ch_flags
69 * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
70 * mandatory section if CH is present.
Aneesh V30679422011-07-21 09:09:59 -040071 */
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000072 if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
Sricharan308fe922011-11-15 09:50:03 -050073 return 0;
74 else
75 return running_from_sdram();
Aneesh V30679422011-07-21 09:09:59 -040076}
77/*
78 * The basic hardware init of OMAP(s_init()) can happen in 4
79 * different contexts:
80 * 1. SPL running from SRAM
81 * 2. U-Boot running from FLASH
82 * 3. Non-XIP U-Boot loaded to SDRAM by SPL
83 * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
84 * Configuration Header feature
85 *
86 * This function finds this context.
87 * Defining as inline may help in compiling out unused functions in SPL
88 */
Sricharan9310ff72011-11-15 09:49:55 -050089static inline u32 omap_hw_init_context(void)
Aneesh V30679422011-07-21 09:09:59 -040090{
91#ifdef CONFIG_SPL_BUILD
92 return OMAP_INIT_CONTEXT_SPL;
93#else
94 if (uboot_loaded_by_spl())
95 return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
96 else if (running_from_sdram())
97 return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
98 else
99 return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
100#endif
101}
Minkyu Kangae6f0c62009-07-20 11:40:01 +0900102
Steve Sakoman1ad21582010-06-08 13:07:46 -0700103#endif