177b55e8cSThomas Abraham /*
277b55e8cSThomas Abraham * Common APIs for EXYNOS based board
377b55e8cSThomas Abraham *
477b55e8cSThomas Abraham * Copyright (C) 2013 Samsung Electronics
577b55e8cSThomas Abraham * Rajeshwari Shinde <rajeshwari.s@samsung.com>
677b55e8cSThomas Abraham *
777b55e8cSThomas Abraham * See file CREDITS for list of people who contributed to this
877b55e8cSThomas Abraham * project.
977b55e8cSThomas Abraham *
1077b55e8cSThomas Abraham * This program is free software; you can redistribute it and/or
1177b55e8cSThomas Abraham * modify it under the terms of the GNU General Public License as
1277b55e8cSThomas Abraham * published by the Free Software Foundation; either version 2 of
1377b55e8cSThomas Abraham * the License, or (at your option) any later version.
1477b55e8cSThomas Abraham *
1577b55e8cSThomas Abraham * This program is distributed in the hope that it will be useful,
1677b55e8cSThomas Abraham * but WITHOUT ANY WARRANTY; without even the implied warranty of
1777b55e8cSThomas Abraham * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1877b55e8cSThomas Abraham * GNU General Public License for more details.
1977b55e8cSThomas Abraham *
2077b55e8cSThomas Abraham * You should have received a copy of the GNU General Public License
2177b55e8cSThomas Abraham * along with this program; if not, write to the Free Software
2277b55e8cSThomas Abraham * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2377b55e8cSThomas Abraham * MA 02111-1307 USA
2477b55e8cSThomas Abraham */
2577b55e8cSThomas Abraham
2677b55e8cSThomas Abraham #include <asm/arch/system.h>
2777b55e8cSThomas Abraham
2877b55e8cSThomas Abraham #define DMC_OFFSET 0x10000
2977b55e8cSThomas Abraham
3077b55e8cSThomas Abraham /*
3177b55e8cSThomas Abraham * Memory initialization
3277b55e8cSThomas Abraham *
3377b55e8cSThomas Abraham * @param reset Reset PHY during initialization.
3477b55e8cSThomas Abraham */
3577b55e8cSThomas Abraham void mem_ctrl_init(int reset);
3677b55e8cSThomas Abraham
3777b55e8cSThomas Abraham /* System Clock initialization */
3877b55e8cSThomas Abraham void system_clock_init(void);
3977b55e8cSThomas Abraham
4077b55e8cSThomas Abraham /*
4177b55e8cSThomas Abraham * Init subsystems according to the reset status
4277b55e8cSThomas Abraham *
4377b55e8cSThomas Abraham * @return 0 for a normal boot, non-zero for a resume
4477b55e8cSThomas Abraham */
4577b55e8cSThomas Abraham int do_lowlevel_init(void);
4677b55e8cSThomas Abraham
4777b55e8cSThomas Abraham void sdelay(unsigned long);
4877b55e8cSThomas Abraham
4977b55e8cSThomas Abraham enum l2_cache_params {
5077b55e8cSThomas Abraham CACHE_DATA_RAM_LATENCY_2_CYCLES = (2 << 0),
5177b55e8cSThomas Abraham CACHE_DATA_RAM_LATENCY_3_CYCLES = (3 << 0),
5277b55e8cSThomas Abraham CACHE_DISABLE_CLEAN_EVICT = (1 << 3),
5377b55e8cSThomas Abraham CACHE_DATA_RAM_SETUP = (1 << 5),
5477b55e8cSThomas Abraham CACHE_TAG_RAM_LATENCY_2_CYCLES = (2 << 6),
5577b55e8cSThomas Abraham CACHE_TAG_RAM_LATENCY_3_CYCLES = (3 << 6),
5677b55e8cSThomas Abraham CACHE_ENABLE_HAZARD_DETECT = (1 << 7),
5777b55e8cSThomas Abraham CACHE_TAG_RAM_SETUP = (1 << 9),
5877b55e8cSThomas Abraham CACHE_ECC_AND_PARITY = (1 << 21),
5977b55e8cSThomas Abraham CACHE_ENABLE_FORCE_L2_LOGIC = (1 << 27)
6077b55e8cSThomas Abraham };
6177b55e8cSThomas Abraham
6277b55e8cSThomas Abraham
6314a66afeSThomas Abraham #if !defined(CONFIG_SYS_L2CACHE_OFF) && defined(CONFIG_EXYNOS5420)
6477b55e8cSThomas Abraham /*
6577b55e8cSThomas Abraham * Configure L2CTLR to get timings that keep us from hanging/crashing.
6677b55e8cSThomas Abraham *
6777b55e8cSThomas Abraham * Must be inline here since low_power_start() is called without a
6877b55e8cSThomas Abraham * stack (!).
6977b55e8cSThomas Abraham */
configure_l2_ctlr(void)7077b55e8cSThomas Abraham static inline void configure_l2_ctlr(void)
7177b55e8cSThomas Abraham {
7277b55e8cSThomas Abraham uint32_t val;
7377b55e8cSThomas Abraham
7477b55e8cSThomas Abraham mrc_l2_ctlr(val);
7577b55e8cSThomas Abraham
7677b55e8cSThomas Abraham val |= CACHE_TAG_RAM_SETUP |
7777b55e8cSThomas Abraham CACHE_DATA_RAM_SETUP |
7877b55e8cSThomas Abraham CACHE_TAG_RAM_LATENCY_2_CYCLES |
7977b55e8cSThomas Abraham CACHE_DATA_RAM_LATENCY_2_CYCLES;
8077b55e8cSThomas Abraham
81*cf9007ceSSimon Glass if (proid_is_exynos542x()) {
8277b55e8cSThomas Abraham val |= CACHE_ECC_AND_PARITY |
8377b55e8cSThomas Abraham CACHE_TAG_RAM_LATENCY_3_CYCLES |
8477b55e8cSThomas Abraham CACHE_DATA_RAM_LATENCY_3_CYCLES;
8577b55e8cSThomas Abraham }
8677b55e8cSThomas Abraham
8777b55e8cSThomas Abraham mcr_l2_ctlr(val);
8877b55e8cSThomas Abraham }
8977b55e8cSThomas Abraham
9077b55e8cSThomas Abraham /*
9177b55e8cSThomas Abraham * Configure L2ACTLR.
9277b55e8cSThomas Abraham *
9377b55e8cSThomas Abraham * Must be inline here since low_power_start() is called without a
9477b55e8cSThomas Abraham * stack (!).
9577b55e8cSThomas Abraham */
configure_l2_actlr(void)9677b55e8cSThomas Abraham static inline void configure_l2_actlr(void)
9777b55e8cSThomas Abraham {
9877b55e8cSThomas Abraham uint32_t val;
9977b55e8cSThomas Abraham
100*cf9007ceSSimon Glass if (proid_is_exynos542x()) {
10177b55e8cSThomas Abraham mrc_l2_aux_ctlr(val);
10277b55e8cSThomas Abraham val |= CACHE_ENABLE_FORCE_L2_LOGIC |
10377b55e8cSThomas Abraham CACHE_DISABLE_CLEAN_EVICT;
10477b55e8cSThomas Abraham mcr_l2_aux_ctlr(val);
10577b55e8cSThomas Abraham }
10677b55e8cSThomas Abraham }
10777b55e8cSThomas Abraham #endif
108