/*-----------------------------------------------------------------------------
 * gpio-cxd4105.h
 *
 * a header file for gpio
 *
 * Copyright 2005,2006 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 __GPIO_CXD4105_H__
#define __GPIO_CXD4105_H__

/*[HEAD-START] (for "spec sheet generator")*/
/*=============================================================================
 * cxd4105 original infomation
 *
 *   cxd4105 special define here
 *
 *===========================================================================*/
/*-----------------------------------------------------------------------------
 * Port Number(ID) to GPIO function
 *---------------------------------------------------------------------------*/
/*-----[function]------[port number]-----------------------------------------*/
enum{
/*----[ GPIOsys ]----*/
    GPIO_0,	/* 0 */
    GPIO_1,
    GPIO_2,
    GPIO_3,
    GPIO_4,
    GPIO_5,
    GPIO_6,
    GPIO_7,
    GPIO_8,
    GPIO_9,
    GPIO_10,
    GPIO_11,
    GPIO_12,
    GPIO_13,
    GPIO_14,
    GPIO_15,
/*----[ GPIOeasy ]----*/
    GPIO0_0,	/* 16 */
    GPIO0_1,
    GPIO0_2,
    GPIO0_3,
    GPIO0_4,
    GPIO0_5,
    GPIO0_6,
    GPIO0_7,
    GPIO0_8,
    GPIO0_9,
    GPIO0_10,
    GPIO0_11,
    GPIO0_12,
    GPIO0_13,
    GPIO0_14,
    GPIO0_15,

    GPIO1_0,	/* 32 */
    GPIO1_1,
    GPIO1_2,
    GPIO1_3,
    GPIO1_4,
    GPIO1_5,
    GPIO1_6,
    GPIO1_7,
    GPIO1_8,
    GPIO1_9,
    GPIO1_10,
    GPIO1_11,
    GPIO1_12,
    GPIO1_13,
    GPIO1_14,
    GPIO1_15,

    GPIO2_0,	/* 48 */
    GPIO2_1,
    GPIO2_2,
    GPIO2_3,
    GPIO2_4,
    GPIO2_5,
    GPIO2_6,
    GPIO2_7,
    GPIO2_8,
    GPIO2_9,
    GPIO2_10,
//    GPIO2_11,	/* not used */
//    GPIO2_12,	/* not used */
//    GPIO2_13,	/* not used */
//    GPIO2_14,	/* not used */
//    GPIO2_15,	/* not used */

    GPIO3_0,	/* 59 */
    GPIO3_1,
    GPIO3_2,
    GPIO3_3,
    GPIO3_4,
    GPIO3_5,
    GPIO3_6,
    GPIO3_7,
    GPIO3_8,
    GPIO3_9,
    GPIO3_10,
    GPIO3_11,
    GPIO3_12,
    GPIO3_13,
    GPIO3_14,
    GPIO3_15,

    GPIO4_0,	/* 75 */
    GPIO4_1,
    GPIO4_2,
    GPIO4_3,
    GPIO4_4,
    GPIO4_5,
    GPIO4_6,
    GPIO4_7,
    GPIO4_8,
    GPIO4_9,
    GPIO4_10,
    GPIO4_11,
    GPIO4_12,
    GPIO4_13,
    GPIO4_14,
    GPIO4_15,

    GPIO5_0,	/* 91 */
    GPIO5_1,
    GPIO5_2,
    GPIO5_3,
    GPIO5_4,
    GPIO5_5,
    GPIO5_6,
    GPIO5_7,
    GPIO5_8,
    GPIO5_9,
    GPIO5_10,
    GPIO5_11,
    GPIO5_12,
    GPIO5_13,
    GPIO5_14,
    GPIO5_15,

    GPIO6_0,	/* 107 */
    GPIO6_1,
    GPIO6_2,
    GPIO6_3,
    GPIO6_4,
    GPIO6_5,
    GPIO6_6,
    GPIO6_7,
    GPIO6_8,
    GPIO6_9,
    GPIO6_10,
    GPIO6_11,
    GPIO6_12,
    GPIO6_13,
    GPIO6_14,
    GPIO6_15,

    GPIO7_0,	/* 123 */
    GPIO7_1,
    GPIO7_2,
    GPIO7_3,
    GPIO7_4,
    GPIO7_5,
//    GPIO7_6,	/* not used */
//    GPIO7_7,	/* not used */
//    GPIO7_8,	/* not used */
//    GPIO7_9,	/* not used */
//    GPIO7_10,	/* not used */
//    GPIO7_11,	/* not used */
//    GPIO7_12,	/* not used */
//    GPIO7_13,	/* not used */
//    GPIO7_14,	/* not used */
//    GPIO7_15,	/* not used */

    GPIO8_0,	/* 129 */
    GPIO8_1,
    GPIO8_2,
    GPIO8_3,
    GPIO8_4,
    GPIO8_5,
    GPIO8_6,
    GPIO8_7,
    GPIO8_8,
    GPIO8_9,
    GPIO8_10,
    GPIO8_11,
    GPIO8_12,
    GPIO8_13,
    GPIO8_14,
    GPIO8_15,

    GPIO9_0,	/* 145 */
    GPIO9_1,
    GPIO9_2,
    GPIO9_3,
    GPIO9_4,
    GPIO9_5,
    GPIO9_6,
    GPIO9_7,
    GPIO9_8,
    GPIO9_9,
    GPIO9_10,
    GPIO9_11,
//    GPIO9_12,	/* not used */
//    GPIO9_13,	/* not used */
//    GPIO9_14,	/* not used */
//    GPIO9_15,	/* not used */

    GPIO10_0,	/* 157 */
    GPIO10_1,
//    GPIO10_2,	/* not used */
    GPIO10_3,
    GPIO10_4,
    GPIO10_5,
    GPIO10_6,
    GPIO10_7,
    GPIO10_8,
    GPIO10_9,
//    GPIO10_10,	/* not used */
    GPIO10_11,
    GPIO10_12,
    GPIO10_13,
    GPIO10_14,
    GPIO10_15,

    GPIO11_0,	/* 171 */
    GPIO11_1,
    GPIO11_2,
    GPIO11_3,
    GPIO11_4,
    GPIO11_5,
    GPIO11_6,
    GPIO11_7,
    GPIO11_8,
    GPIO11_9,
    GPIO11_10,
    GPIO11_11,
//    GPIO11_12,	/* not used */
//    GPIO11_13,	/* not used */
//    GPIO11_14,	/* not used */
//    GPIO11_15,	/* not used */

    GPIO12_0,	/* 183 */
    GPIO12_1,
    GPIO12_2,
    GPIO12_3,
    GPIO12_4,
    GPIO12_5,
    GPIO12_6,
    GPIO12_7,
    GPIO12_8,
    GPIO12_9,
    GPIO12_10,
    GPIO12_11,
    GPIO12_12,
    GPIO12_13,
    GPIO12_14,
    GPIO12_15,

    GPIO13_0,	/* 199 */
    GPIO13_1,
    GPIO13_2,
    GPIO13_3,
    GPIO13_4,
    GPIO13_5,
    GPIO13_6,
//    GPIO13_7,	/* not used */
//    GPIO13_8,	/* not used */
//    GPIO13_9,	/* not used */
//    GPIO13_10,	/* not used */
//    GPIO13_11,	/* not used */
//    GPIO13_12,	/* not used */
//    GPIO13_13,	/* not used */
//    GPIO13_14,	/* not used */
//    GPIO13_15,	/* not used */

    GPIO14_0,	/* 206 */
    GPIO14_1,
    GPIO14_2,
    GPIO14_3,
    GPIO14_4,
    GPIO14_5,
    GPIO14_6,
    GPIO14_7,
    GPIO14_8,
    GPIO14_9,
    GPIO14_10,
    GPIO14_11,
    GPIO14_12,
    GPIO14_13,
    GPIO14_14,
    GPIO14_15,

    GPIO15_0,	/* 222 */
    GPIO15_1,
    GPIO15_2,
    GPIO15_3,
    GPIO15_4,
    GPIO15_5,
    GPIO15_6,
    GPIO15_7,
    GPIO15_8,
    GPIO15_9,
    GPIO15_10,
    GPIO15_11,
    GPIO15_12,
    GPIO15_13,
    GPIO15_14,
    GPIO15_15,

    GPIO16_0,	/* 238 */
    GPIO16_1,
    GPIO16_2,
    GPIO16_3,
    GPIO16_4,
    GPIO16_5,
    GPIO16_6,
    GPIO16_7,
//    GPIO16_8,	/* not used */
    GPIO16_9,
    GPIO16_10,
//    GPIO16_11,	/* not used */
//    GPIO16_12,	/* not used */
//    GPIO16_13,	/* not used */
//    GPIO16_14,	/* not used */
//    GPIO16_15,	/* not used */
};

/*-----------------------------------------------------------------------------
 * MAX value
 *---------------------------------------------------------------------------*/
#define PORT_MAX	GPIO16_10	/* 247 */

/*-----------------------------------------------------------------------------
 * IO sel select.  common func define to arch depend function
 *---------------------------------------------------------------------------*/
/* GPIO0 sel */
#define GPIO_FUNC_TPU0			GPIO_FUNC_ARCH	/* 9 */
#define GPIO_FUNC_TPU1			(GPIO_FUNC_ARCH + 1)
#define GPIO_FUNC_TPU2			(GPIO_FUNC_ARCH + 2)
#define GPIO_FUNC_TPU3			(GPIO_FUNC_ARCH + 3)
#define GPIO_FUNC_TPU4			(GPIO_FUNC_ARCH + 4)
#define GPIO_FUNC_SIR			(GPIO_FUNC_ARCH + 5)
#define GPIO_FUNC_JOG0			(GPIO_FUNC_ARCH + 6)
#define GPIO_FUNC_JOG1			(GPIO_FUNC_ARCH + 7)
#define GPIO_FUNC_BOOTMODE		(GPIO_FUNC_ARCH + 8)
/* GPIO1 sel */
#define GPIO_FUNC_UART0			(GPIO_FUNC_ARCH + 9)
#define GPIO_FUNC_UART1			(GPIO_FUNC_ARCH + 10)
#define GPIO_FUNC_UART2			(GPIO_FUNC_ARCH + 11)
#define GPIO_FUNC_UART3			(GPIO_FUNC_ARCH + 12)
/* GPIO2 sel */
#define GPIO_FUNC_SSP0			(GPIO_FUNC_ARCH + 13)
#define GPIO_FUNC_SSP1			(GPIO_FUNC_ARCH + 14)
#define GPIO_FUNC_USBVBUS		(GPIO_FUNC_ARCH + 15)
/* GPIO3 sel */
#define GPIO_FUNC_SIO0			(GPIO_FUNC_ARCH + 16)
#define GPIO_FUNC_SIO1			(GPIO_FUNC_ARCH + 17)
#define GPIO_FUNC_SIO2			(GPIO_FUNC_ARCH + 18)
#define GPIO_FUNC_SIO3			(GPIO_FUNC_ARCH + 19)
/* GPIO4 sel, GPIO5 sel, GPIO6 sel */
#define GPIO_FUNC_PERIHZ		(GPIO_FUNC_ARCH + 20)
#define GPIO_FUNC_PERIPU		(GPIO_FUNC_ARCH + 21)
#define GPIO_FUNC_PERIPD		(GPIO_FUNC_ARCH + 22)
/* GPIO4 sel, GPIO5 sel, ..., GPIO7 sel */
#define GPIO_FUNC_EXIO			(GPIO_FUNC_ARCH + 23)
#define GPIO_FUNC_CF			(GPIO_FUNC_ARCH + 24)
#define GPIO_FUNC_ATA			(GPIO_FUNC_ARCH + 25)
/* GPIO8 sel, GPIO9 sel, ..., GPIO11 sel */
#define GPIO_FUNC_LCD			(GPIO_FUNC_ARCH + 26)
#define GPIO_FUNC_CODEC			(GPIO_FUNC_ARCH + 27)
#define GPIO_FUNC_CK			(GPIO_FUNC_ARCH + 28)
#define GPIO_FUNC_SD			(GPIO_FUNC_ARCH + 29)
#define GPIO_FUNC_CAMPERI		(GPIO_FUNC_ARCH + 30)
/* GPIO12 sel, GPIO13 sel */
#define GPIO_FUNC_VIN			(GPIO_FUNC_ARCH + 31)
#define GPIO_FUNC_IMG			(GPIO_FUNC_ARCH + 32)
#define GPIO_FUNC_EXT			(GPIO_FUNC_ARCH + 33)
/* GPIO14 sel, GPIO15 sel, GPIO16 sel */
#define GPIO_FUNC_STL			(GPIO_FUNC_ARCH + 34)
#define GPIO_FUNC_CCD			(GPIO_FUNC_ARCH + 35)
#define GPIO_FUNC_CLAMP			(GPIO_FUNC_ARCH + 36)

/*-----------------------------------------------------------------[HEAD-END]*/

typedef struct{
    unsigned short dir;
    unsigned short rdata;
    unsigned short ints;
    unsigned short inthe;
    unsigned short intle;
    unsigned short intmask;
    unsigned short inen;
    unsigned short resen;
    unsigned short pupd;
}RegGpioSys;

typedef struct{
    unsigned short dir;
    unsigned short rdata;
    unsigned short inen;
    unsigned short portsel;
    unsigned short holden;
    unsigned short resen;
    unsigned short pupd;
}RegGpioEasy;

typedef struct{
    RegGpioSys sys;
    RegGpioEasy easy[17];
}RegGpio;

#endif /* __GPIO_CXD4105_H__ */
