blob: 80172f37945e32a10d02c24d3b8324a14e2aaad4 [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>
pekon gupta5bbb0992013-11-22 16:53:29 +053015#include <linux/mtd/omap_gpmc.h>
Aneesh Vf908b632011-07-21 09:10:01 -040016#include <asm/arch/mux_omap4.h>
Steve Sakoman1ad21582010-06-08 13:07:46 -070017
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000018DECLARE_GLOBAL_DATA_PTR;
19
Hardik Patel8662fc62013-11-27 21:16:21 +053020extern const struct emif_regs emif_regs_elpida_200_mhz_2cs;
21extern const struct emif_regs emif_regs_elpida_380_mhz_1cs;
22extern const struct emif_regs emif_regs_elpida_400_mhz_1cs;
23extern const struct emif_regs emif_regs_elpida_400_mhz_2cs;
Steve Sakoman1ad21582010-06-08 13:07:46 -070024struct omap_sysinfo {
25 char *board_string;
26};
Aneesh V30679422011-07-21 09:09:59 -040027extern const struct omap_sysinfo sysinfo;
Steve Sakoman1ad21582010-06-08 13:07:46 -070028
Steve Sakoman9b8ea4e2010-07-15 16:19:16 -040029void gpmc_init(void);
Steve Sakoman1ad21582010-06-08 13:07:46 -070030void watchdog_init(void);
31u32 get_device_type(void);
Aneesh Vf908b632011-07-21 09:10:01 -040032void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
Sricharan9310ff72011-11-15 09:49:55 -050033void set_muxconf_regs_essential(void);
Steve Sakoman6e09a762010-08-04 09:39:40 -070034u32 wait_on_value(u32, u32, void *, u32);
35void sdelay(unsigned long);
Aneesh Ve3405bd2011-06-16 23:30:52 +000036void set_pl310_ctrl_reg(u32 val);
Aneesh Vb8e60b92011-07-21 09:10:21 -040037void setup_clocks_for_console(void);
Aneesh V0d2628b2011-07-21 09:10:07 -040038void prcm_init(void);
SRICHARAN Rfb6aa1f2013-02-04 04:22:00 +000039void bypass_dpll(u32 const base);
Aneesh V0d2628b2011-07-21 09:10:07 -040040void freq_update_core(void);
41u32 get_sys_clk_freq(void);
42u32 omap4_ddr_clk(void);
Aneesh Vc0e88522011-07-21 09:10:12 -040043void cancel_out(u32 *num, u32 *den, u32 den_limit);
Aneesh Vcc565582011-07-21 09:10:09 -040044void sdram_init(void);
Sricharan9310ff72011-11-15 09:49:55 -050045u32 omap_sdram_size(void);
46u32 cortex_rev(void);
Tom Rini51df26c2013-05-31 12:31:59 -040047void save_omap_boot_params(void);
Sricharan9310ff72011-11-15 09:49:55 -050048void init_omap_revision(void);
49void do_io_settings(void);
Lokesh Vutlaae49f6d2013-05-30 02:54:33 +000050void sri2c_init(void);
Lokesh Vutla36852972013-05-30 03:19:29 +000051void gpi2c_init(void);
Nishanth Menon41d7ab12012-03-01 14:17:37 +000052int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
Lokesh Vutlae89f1542012-05-29 19:26:41 +000053u32 warm_reset(void);
Lokesh Vutlaba873772012-05-29 19:26:43 +000054void force_emif_self_refresh(void);
Lokesh Vutla100c2d82013-04-17 20:49:40 +000055void setup_warmreset_time(void);
Steve Sakoman1ad21582010-06-08 13:07:46 -070056
Aneesh V30679422011-07-21 09:09:59 -040057static inline u32 running_from_sdram(void)
58{
59 u32 pc;
60 asm volatile ("mov %0, pc" : "=r" (pc));
61 return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
62 (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
63}
64
65static inline u8 uboot_loaded_by_spl(void)
66{
67 /*
Sricharan308fe922011-11-15 09:50:03 -050068 * u-boot can be running from sdram either because of configuration
69 * Header or by SPL. If because of CH, then the romcode sets the
70 * CHSETTINGS executed bit to true in the boot parameter structure that
71 * it passes to the bootloader.This parameter is stored in the ch_flags
72 * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
73 * mandatory section if CH is present.
Aneesh V30679422011-07-21 09:09:59 -040074 */
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000075 if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
Sricharan308fe922011-11-15 09:50:03 -050076 return 0;
77 else
78 return running_from_sdram();
Aneesh V30679422011-07-21 09:09:59 -040079}
80/*
81 * The basic hardware init of OMAP(s_init()) can happen in 4
82 * different contexts:
83 * 1. SPL running from SRAM
84 * 2. U-Boot running from FLASH
85 * 3. Non-XIP U-Boot loaded to SDRAM by SPL
86 * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
87 * Configuration Header feature
88 *
89 * This function finds this context.
90 * Defining as inline may help in compiling out unused functions in SPL
91 */
Sricharan9310ff72011-11-15 09:49:55 -050092static inline u32 omap_hw_init_context(void)
Aneesh V30679422011-07-21 09:09:59 -040093{
94#ifdef CONFIG_SPL_BUILD
95 return OMAP_INIT_CONTEXT_SPL;
96#else
97 if (uboot_loaded_by_spl())
98 return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
99 else if (running_from_sdram())
100 return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
101 else
102 return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
103#endif
104}
Minkyu Kangae6f0c62009-07-20 11:40:01 +0900105
Steve Sakoman1ad21582010-06-08 13:07:46 -0700106#endif