
/*****************************************************************************
* Copyright (c) 2004 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/

#ifndef NA_GPIO_H_
#define NA_GPIO_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <processorgpio.h>


/* These are the names of GPIO functions. */
#define GPIO_DIAG	(-1)	    /* DIAG LED */
#define GPIO_SOFTRESET	(-2)	    /* Reset request input */
#define GPIO_MISC0	(-3)	    /* Miscellaneous pin 0 */
#define GPIO_MISC1	(-4)	    /* Miscellaneous pin 1 */
#define GPIO_MISC2	(-5)	    /* Miscellaneous pin 2 */
#define GPIO_MISC3	(-6)	    /* Miscellaneous pin 3 */
#define GPIO_MISC4	(-7)	    /* Miscellaneous pin 4 */
#define GPIO_MISC5	(-8)	    /* Miscellaneous pin 5 */
#define GPIO_MISC6	(-9)	    /* Miscellaneous pin 6 */
#define GPIO_MISC7	(-10)	    /* Miscellaneous pin 7 */
#define GPIO_EINT	(-11)	    /* Ethernet PHY interrupt */
#define GPIO_UINT	(-12)	    /* External UART interrupt */
#define GPIO_POWERLED	(-13)	    /* Powerup LED - comes on at powerup */
#define GPIO_ACTIVITY	(-14)	    /* Eth activity LED */
#define GPIO_RESETLED	(-15)	    /* Reset LED */
#define GPIO_SERIALACT	(-16)	    /* Serial Activity LED pin */
#define GPIO_MFGO	(-17)	    /* Manufacturing Output */
#define GPIO_MFGI	(-18)	    /* Manufacturing Input */
#define GPIO_PCI_RST	(-19)	    /* PCI RST, inverted: High=reset */
#define GPIO_MODE0	(-20)	    /* Amsterdam Mode bit 0 */
#define GPIO_MODE1	(-21)	    /* Amsterdam Mode bit 1 */
#define GPIO_HRESET	(-22)	    /* Amsterdam Hardware reset */
#define GPIO_UNUSED1	(-23)	    /* Unused pin */
#define GPIO_WCTL	(-24)	    /* I2C EE write control pin */
#define GPIO_CELLMDM_RST (-25)      /* Cell modem reset */
#define GPIO_ERROR_LED  (-26)       /* ERROR LED */


/* Here is a list of the different LEDs.  Each is on when the pin is low.
 *
 * GPIO_ERROR_LED
 *  This is the LED that reports failures by blinking a 3 digit
 *  code.  
 * 
 */

/* This function returns TRUE if the specified function exists on the
 * hardware.
 */
extern int naGpioFunctionExists(int function);

/* Set this gpio pin to be an input.
 * Returns TRUE if successful.
 */
extern int naGpioSetInput(int function);

/* Set this gpio pin to be an output.
 * Returns TRUE if successful.
 */
extern int naGpioSetOutput(int function, unsigned int default_value);

/* Set this gpio pin to be an interrupt.
 * level is 1 for high, 0 for low.
 * edge_trigger is 1 for edge-triggered, 0 for level-triggered.
 * Returns TRUE if successful.
 */
extern int naGpioSetInterrupt(int function, int level, int edge_trigger);

/* Returns 0 or non-zero value of pin.
 * Returns (unsigned long)-1 if unable to get value.
 */
extern unsigned long naGpioGetValue(int function);

/* GPIO pin will be set based on value being 0 or non-zero.  Will be ignored
 * if pin is set as input or interrupt.
 * Returns TRUE if successful.
 */
extern int naGpioSetOutputValue(int function, unsigned long value);

/* GPIO pin will be set to an output with an initial value based on value being
 * 0 or non-zero.  Will atomically change to an output with the desired value
 * if possible.  This attempts to avoid a glitch as the pin becomes an output.
 *
 * Obsoletes GpioSetOutput.
 */
extern int naGpioSetOutputWithValue(int function, unsigned long value);

#ifdef __cplusplus
}
#endif

#endif /* GPIO_H_ */

