/*
 * include/asm-arm/arch-cxd4115/regs-gpio.h
 *
 * GPIO registers
 *
 * Copyright 2007,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 __REGS_GPIO_H__
#define __REGS_GPIO_H__

#define GPIO_DIR		0x00
#define GPIO_DATA_READ		0x04
#define GPIO_DATA_SET		0x08
#define GPIO_DATA_CLEAR		0x0c
#define GPIO_INEN		0x10
#define GPIO_PORTSEL		0x14
#define GPIO_PORTSEL_SET	0x18
#define GPIO_PORTSEL_CLR	0x1c

#ifndef __ASSEMBLY__
# include <asm/io.h>
static inline void gpio_set(int nr, int reg, int bitnr)
{
	u32 dat;

	dat = readl(VA_GPIO(nr)+reg);
	dat |= 1 << bitnr;
	writel(dat, VA_GPIO(nr)+reg);
}

static inline void gpio_clr(int nr, int reg, int bitnr)
{
	u32 dat;

	dat = readl(VA_GPIO(nr)+reg);
	dat &= ~(1 << bitnr);
	writel(dat, VA_GPIO(nr)+reg);
}
#endif /* !__ASSEMBLY__ */

/* XPOWER_OFF  = GPIO_S[12] pin = GPIO0 bit12 */
#define GPIO_POWEROFF	0
#ifdef CONFIG_ARCH_CXD4120
#define XPOWER_OFF_BIT 23
#else
#define XPOWER_OFF_BIT 12
#endif
#define XPOWER_OFF     (1 << XPOWER_OFF_BIT)

/* STABULE_RUN = GPIO_E[0] pin  = GPIO0 bit16 */
#define GPIO_STABLERUN	0
#define STABLE_RUN 0x00010000

#endif /* __REGS_GPIO_H__ */
