/*
 * include/asm-arm/arch-cxd4115/regs-bridge.h
 *
 * Bridge registers
 *
 * Copyright 2008,2009 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.
 * 
 */
#ifndef __CXD4115_REGS_BRIDGE_H__
#define __CXD4115_REGS_BRIDGE_H__

/* register offset */
#define LINEBUF_MODE		0x80
# define LINEBUF_OO		 0x40
# define LINEBUF_FULLREAD	 0x20
# define LINEBUF_ENABLE		 0x10
# define LINEBUF_INV		 0x00 /* bit3..0 */

#ifdef __ASSEMBLY__
	.macro	lcache_init, rx, ry
	ldr	\rx, =CXD4115_BRIDGE(0)
	mrc	p15, 0, \ry, c0, c0, 5	@ CPUID
	and	\ry, \ry, #0x0f
	orr	\rx, \ry, lsl #13	@ cpuid * 0x2000
#ifdef CONFIG_CXD4115_LINECACHE
	mov	\ry, #(LINEBUF_ENABLE|LINEBUF_INV)
#else
	mov	\ry, #0
#endif
	str	\ry, [\rx, #LINEBUF_MODE]
	.endm

	@ for PHYS
	.macro	lcache_phys_inv, rx, ry
#ifdef CONFIG_CXD4115_LINECACHE
	ldr	\rx, =CXD4115_BRIDGE(0)
	mrc	p15, 0, \ry, c0, c0, 5	@ CPUID
	and	\ry, \ry, #0x0f
	orr	\rx, \ry, lsl #13	@ cpuid * 0x2000
	mov	\ry, #(LINEBUF_ENABLE|LINEBUF_INV)
	str	\ry, [\rx, #LINEBUF_MODE]
#endif
	.endm

	@ for VIRT
	.macro	lcache_inv, rx, ry
#ifdef CONFIG_CXD4115_LINECACHE
	ldr	\rx, =VA_BRIDGE(0)
	mrc	p15, 0, \ry, c0, c0, 5	@ CPUID
	and	\ry, \ry, #0x0f
	orr	\rx, \ry, lsl #13	@ cpuid * 0x2000
	mov	\ry, #(LINEBUF_ENABLE|LINEBUF_INV)
	str	\ry, [\rx, #LINEBUF_MODE]
#endif
	.endm
#endif /* __ASSEMBLY__ */
#endif /* __CXD4115_REGS_BRIDGE_H__ */
