
/*****************************************************************************
* Copyright (c) 2003 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
*
*****************************************************************************/

/*
 * $Log: processorgpio.h,v $
 * Revision 1.6.20.1  2008/09/17 16:23:09  lzhen
 * Use HW RTS toggle to support CRTSTOGGLE when predelay and postdelay are both zero,
 * in this case, the RTS pin has to use the default GPIO function for RTS. Vantive:        27819
 *
 * Revision 1.6.28.1  2008/09/17 15:56:26  lzhen
 * Use HW RTS toggle to support CRTSTOGGLE when predelay and postdelay are both zero,
 * in this case, the RTS pin has to use the default GPIO function for RTS. Vantive:        27819
 *
 * Revision 1.7  2008/09/17 15:16:12  lzhen
 * Use HW RTS toggle to support CRTSTOGGLE when predelay and postdelay are both zero,
 * in this case, the RTS pin has to use the default GPIO function for RTS. Vantive:        27819
 *
 * Revision 1.6  2006/03/17 19:28:28  vshankar
 * Updated for powersave enhancement
 *
 * Revision 1.5  2005/06/20 14:51:11  jwolf
 * Vantive 15988. Removed references to mercury from code base
 *
 * Revision 1.4  2005/05/02 19:45:50  jfu
 * Added register access macros.
 *
 * Revision 1.1.2.3  2005/05/02 19:43:43  jfu
 * Added register access macros.
 *
 * Revision 1.1.2.2  2005/04/28 11:39:35  jfu
 * Added new GPIO API related files
 *
 * Revision 1.1.2.1  2005/04/27 22:22:04  jfu
 * newly added GPIO API related files
 *
 * Revision 1.1  2005/04/27 22:19:48  jfu
 * newly added GPIO API related files
 *
 * Revision 1.1.4.1  2004/07/01 21:15:00  jamesp
 * Moved gpio.c and gpio.h into drivers/gpio.  Moved "arch"
 * high level declarations for gpio stuff into arch/include.
 * Removed obsolete NET+OS header "gpio.h".  Fixed Makefiles
 * to use files from new locations.
 *
 * Revision 1.1.2.1  2004/06/14 21:06:35  markw
 * Gpio abstraction for ns7520 products and Amsterdam products.  Now you request
 * gpio pin actions using a function name (e.g. GPIO_MFGO), and this is mapped
 * in a platform-specific way to a processor gpio pin, or an I2C pin, or ....
 *
 * Revision 1.1.2.1  2004/01/08 23:22:06  markw
 * Check in changes for running NDS on NS9750.
 *
 */

#ifndef PROCESSORGPIO_H_
#define PROCESSORGPIO_H_

#ifdef __cplusplus
extern "C" {
#endif


/* reg = data */

#define WriteReg(reg, data) \
    ((*(volatile unsigned long *)(reg)) = (data))

/* reg = (reg & ~mask) | (mask & data); */

#define WriteRegMaskData(reg, mask, data) \
    ((*(volatile unsigned long *)(reg)) = ((*(volatile unsigned long *)(reg)) & ~(mask)) | \
	((mask) & (data)))

/* return reg; */

#define ReadReg(reg) \
    (*(volatile unsigned long *)(reg))

/* return reg & mask; */

#define ReadRegMask(reg, mask) \
    (*(volatile unsigned long *)(reg) & (mask))



extern int ProcessorGpioSetInput(unsigned long addr, unsigned long gpio_pin);

extern int ProcessorGpioSetOutput(unsigned long addr, unsigned long gpio_pin, unsigned long default_value);

/* Returns 0 or non-zero. */
extern unsigned long ProcessorGpioGetValue(unsigned long addr, unsigned long gpio_pin);

/* value is zero or non-zero.  GPIO pin will be set based on it. */
extern int ProcessorGpioSetOutputValue(unsigned long addr, unsigned long gpio_pin, unsigned long value);

extern int ProcessorGpioPin(int pin, unsigned long *addr, unsigned long *gpio_pin);

extern int ProcessorGpioSetInterrupt(unsigned long addr, unsigned long bit, int level, int edge_trigger);

#ifdef BSP_ARM9
extern int ProcessorGpioGetAddress(unsigned long *addr, unsigned long *pin);
extern int ProcessorGpioSetFunction(unsigned long addr, unsigned long bit, int gpio_function);
#endif

#ifdef __cplusplus
}
#endif

#endif /* PROCESSORGPIO_H_ */

