/*
 * arch/arm/mach-cxd4105/timer.S
 *
 * TIMER initialize for cxd4105
 *
 * Copyright 2007 Sony Corporation
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 */

#include <linux/linkage.h>
#include <asm/assembler.h>
#include <asm/hardware.h>
#include <asm/arch/time.h>
#include <asm/arch/regs-timer.h>
#include <asm/arch/regs-clk.h>

	.text				
ENTRY(timer_init)
	@ Preserve r0 and r1
	@ enable CLK
	ldr	r2, =CXD4105_CLKBLK_BASE
	mov	r3, #0x01
	str	r3, [r2, #CLKBLK_PSCKTIM]	@ enable TIMER CLK

	@ clear sched clock
	ldr	r2, =CXD4105_TIMER_BASE(TIMER_FOR_SCHED)
	mov	r3, #0
	str	r3, [r2, #CXD4105_TIMERCTL]
	mov	r3, #TMCLR|TMINTCLR
	str	r3, [r2, #CXD4105_TIMERCLR]

	@ start sched clock
	mov	r3, #TMCK_DIV1|TMCS_FREERUN
	orr	r3, r3, #TMST
	str	r3, [r2, #CXD4105_TIMERCTL]
	
	mov	pc, lr
