blob: b338a1566c6df3b02bc8c553ca1df7d23eca2991 [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 -070034void sr32(void *, u32, u32, u32);
35u32 wait_on_value(u32, u32, void *, u32);
36void sdelay(unsigned long);
Aneesh Ve3405bd2011-06-16 23:30:52 +000037void set_pl310_ctrl_reg(u32 val);
Aneesh Vb8e60b92011-07-21 09:10:21 -040038void setup_clocks_for_console(void);
Aneesh V0d2628b2011-07-21 09:10:07 -040039void prcm_init(void);
SRICHARAN Rfb6aa1f2013-02-04 04:22:00 +000040void bypass_dpll(u32 const base);
Aneesh V0d2628b2011-07-21 09:10:07 -040041void freq_update_core(void);
42u32 get_sys_clk_freq(void);
43u32 omap4_ddr_clk(void);
Aneesh Vc0e88522011-07-21 09:10:12 -040044void cancel_out(u32 *num, u32 *den, u32 den_limit);
Aneesh Vcc565582011-07-21 09:10:09 -040045void sdram_init(void);
Sricharan9310ff72011-11-15 09:49:55 -050046u32 omap_sdram_size(void);
47u32 cortex_rev(void);
Tom Rini51df26c2013-05-31 12:31:59 -040048void save_omap_boot_params(void);
Sricharan9310ff72011-11-15 09:49:55 -050049void init_omap_revision(void);
50void do_io_settings(void);
Lokesh Vutlaae49f6d2013-05-30 02:54:33 +000051void sri2c_init(void);
Lokesh Vutla36852972013-05-30 03:19:29 +000052void gpi2c_init(void);
Nishanth Menon41d7ab12012-03-01 14:17:37 +000053int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
Lokesh Vutlae89f1542012-05-29 19:26:41 +000054u32 warm_reset(void);
Lokesh Vutlaba873772012-05-29 19:26:43 +000055void force_emif_self_refresh(void);
Lokesh Vutla100c2d82013-04-17 20:49:40 +000056void setup_warmreset_time(void);
Steve Sakoman1ad21582010-06-08 13:07:46 -070057
Aneesh V30679422011-07-21 09:09:59 -040058static inline u32 running_from_sdram(void)
59{
60 u32 pc;
61 asm volatile ("mov %0, pc" : "=r" (pc));
62 return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
63 (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
64}
65
66static inline u8 uboot_loaded_by_spl(void)
67{
68 /*
Sricharan308fe922011-11-15 09:50:03 -050069 * u-boot can be running from sdram either because of configuration
70 * Header or by SPL. If because of CH, then the romcode sets the
71 * CHSETTINGS executed bit to true in the boot parameter structure that
72 * it passes to the bootloader.This parameter is stored in the ch_flags
73 * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
74 * mandatory section if CH is present.
Aneesh V30679422011-07-21 09:09:59 -040075 */
SRICHARAN R3f30b0a2013-04-24 00:41:24 +000076 if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
Sricharan308fe922011-11-15 09:50:03 -050077 return 0;
78 else
79 return running_from_sdram();
Aneesh V30679422011-07-21 09:09:59 -040080}
81/*
82 * The basic hardware init of OMAP(s_init()) can happen in 4
83 * different contexts:
84 * 1. SPL running from SRAM
85 * 2. U-Boot running from FLASH
86 * 3. Non-XIP U-Boot loaded to SDRAM by SPL
87 * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
88 * Configuration Header feature
89 *
90 * This function finds this context.
91 * Defining as inline may help in compiling out unused functions in SPL
92 */
Sricharan9310ff72011-11-15 09:49:55 -050093static inline u32 omap_hw_init_context(void)
Aneesh V30679422011-07-21 09:09:59 -040094{
95#ifdef CONFIG_SPL_BUILD
96 return OMAP_INIT_CONTEXT_SPL;
97#else
98 if (uboot_loaded_by_spl())
99 return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
100 else if (running_from_sdram())
101 return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
102 else
103 return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
104#endif
105}
Minkyu Kangae6f0c62009-07-20 11:40:01 +0900106
Steve Sakoman1ad21582010-06-08 13:07:46 -0700107#endif