/*
 * Common APIs for EXYNOS based board
 *
 * Copyright (C) 2013 Samsung Electronics
 * Rajeshwari Shinde <rajeshwari.s@samsung.com>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <linux/types.h>
#include <mach/cpu.h>
#include <asm/arch/system.h>

#define DMC_OFFSET	0x10000

/*
 * Memory initialization
 *
 * @param reset     Reset PHY during initialization.
 */
void mem_ctrl_init(int reset);

 /* System Clock initialization */
void system_clock_init(void);

/*
 * Init subsystems according to the reset status
 *
 * Return: 0 for a normal boot, non-zero for a resume
 */
int do_lowlevel_init(void);

void sdelay(unsigned long);

enum l2_cache_params {
	CACHE_DATA_RAM_LATENCY_2_CYCLES = (2 << 0),
	CACHE_DATA_RAM_LATENCY_3_CYCLES = (3 << 0),
	CACHE_DISABLE_CLEAN_EVICT = (1 << 3),
	CACHE_DATA_RAM_SETUP = (1 << 5),
	CACHE_TAG_RAM_LATENCY_2_CYCLES = (2 << 6),
	CACHE_TAG_RAM_LATENCY_3_CYCLES = (3 << 6),
	CACHE_ENABLE_HAZARD_DETECT = (1 << 7),
	CACHE_TAG_RAM_SETUP = (1 << 9),
	CACHE_ECC_AND_PARITY = (1 << 21),
	CACHE_ENABLE_FORCE_L2_LOGIC = (1 << 27)
};

#if !defined(CONFIG_SYS_L2CACHE_OFF) && defined(CONFIG_EXYNOS5420)
/*
 * Configure L2CTLR to get timings that keep us from hanging/crashing.
 *
 * Must be inline here since low_power_start() is called without a
 * stack (!).
 */
static inline void configure_l2_ctlr(void)
{
	uint32_t val;

	mrc_l2_ctlr(val);

	val |= CACHE_TAG_RAM_SETUP |
		CACHE_DATA_RAM_SETUP |
		CACHE_TAG_RAM_LATENCY_2_CYCLES |
		CACHE_DATA_RAM_LATENCY_2_CYCLES;

	if (proid_is_exynos542x()) {
		val |= CACHE_ECC_AND_PARITY |
			CACHE_TAG_RAM_LATENCY_3_CYCLES |
			CACHE_DATA_RAM_LATENCY_3_CYCLES;
	}

	mcr_l2_ctlr(val);
}

/*
 * Configure L2ACTLR.
 *
 * Must be inline here since low_power_start() is called without a
 * stack (!).
 */
static inline void configure_l2_actlr(void)
{
	uint32_t val;

	if (proid_is_exynos542x()) {
		mrc_l2_aux_ctlr(val);
		val |= CACHE_ENABLE_FORCE_L2_LOGIC |
			CACHE_DISABLE_CLEAN_EVICT;
		mcr_l2_aux_ctlr(val);
	}
}
#endif
