import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / drivers / char / xilinx_gpio / xgpio.h
1 /* $Id: xgpio.h,v 1.1.1.1 2005/04/11 02:50:21 jack Exp $ */
2 /******************************************************************************
3 *
4 *     Author: Xilinx, Inc.
5 *     
6 *     
7 *     This program is free software; you can redistribute it and/or modify it
8 *     under the terms of the GNU General Public License as published by the
9 *     Free Software Foundation; either version 2 of the License, or (at your
10 *     option) any later version.
11 *     
12 *     
13 *     XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
14 *     COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
15 *     ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
16 *     XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
17 *     FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR
18 *     OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
19 *     XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
20 *     THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
21 *     WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
22 *     CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
23 *     FITNESS FOR A PARTICULAR PURPOSE.
24 *     
25 *     
26 *     Xilinx products are not intended for use in life support appliances,
27 *     devices, or systems. Use in such applications is expressly prohibited.
28 *     
29 *     
30 *     (c) Copyright 2002 Xilinx Inc.
31 *     All rights reserved.
32 *     
33 *     
34 *     You should have received a copy of the GNU General Public License along
35 *     with this program; if not, write to the Free Software Foundation, Inc.,
36 *     675 Mass Ave, Cambridge, MA 02139, USA.
37 *
38 ******************************************************************************/
39 /*****************************************************************************/
40 /**
41 * @file xgpio.h
42 *
43 * This file contains the software API definition of the Xilinx General Purpose
44 * I/O (XGpio) component.
45 *
46 * The Xilinx GPIO controller is a soft IP core designed for  Xilinx FPGAs and
47 * contains the following general features:
48 *   - Support for 8, 16, or 32 I/O discretes
49 *   - Each of the discretes can be configured for input or output.
50 *
51 * @note
52 *
53 * This API utilizes 32 bit I/O to the GPIO registers. With 16 and 8 bit GPIO
54 * components, the unused bits from registers are read as zero and written as
55 * don't cares.
56 *
57 * <pre>
58 * MODIFICATION HISTORY:
59 *
60 * Ver   Who  Date     Changes
61 * ----- ---- -------- -----------------------------------------------
62 * 1.00a rmm  03/13/02 First release
63 * </pre>
64 *****************************************************************************/
65
66 #ifndef XGPIO_H                 /* prevent circular inclusions */
67 #define XGPIO_H                 /* by using protection macros */
68
69 /***************************** Include Files ********************************/
70
71 #include "xbasic_types.h"
72 #include "xstatus.h"
73 #include "xgpio_l.h"
74
75 /************************** Constant Definitions ****************************/
76
77 /**************************** Type Definitions ******************************/
78
79 /*
80  * This typedef contains configuration information for the device.
81  */
82 typedef struct {
83         u16 DeviceId;           /* Unique ID  of device */
84         u32 BaseAddress;        /* Device base address */
85 } XGpio_Config;
86
87 /**
88  * The XGpio driver instance data. The user is required to allocate a
89  * variable of this type for every GPIO device in the system. A pointer
90  * to a variable of this type is then passed to the driver API functions.
91  */
92 typedef struct {
93         u32 BaseAddress;        /* Device base address */
94         u32 IsReady;            /* Device is initialized and ready */
95 } XGpio;
96
97 /***************** Macros (Inline Functions) Definitions ********************/
98
99 /************************** Function Prototypes *****************************/
100
101 /*
102  * API Basic functions implemented in xgpio.c
103  */
104 XStatus XGpio_Initialize(XGpio * InstancePtr, u16 DeviceId);
105 void XGpio_SetDataDirection(XGpio * InstancePtr, u32 DirectionMask);
106 u32 XGpio_DiscreteRead(XGpio * InstancePtr);
107 void XGpio_DiscreteWrite(XGpio * InstancePtr, u32 Mask);
108
109 XGpio_Config *XGpio_LookupConfig(u16 DeviceId);
110
111 /*
112  * API Functions implemented in xgpio_extra.c
113  */
114 void XGpio_DiscreteSet(XGpio * InstancePtr, u32 Mask);
115 void XGpio_DiscreteClear(XGpio * InstancePtr, u32 Mask);
116
117 /*
118  * API Functions implemented in xgpio_selftest.c
119  */
120 XStatus XGpio_SelfTest(XGpio * InstancePtr);
121 #endif                          /* end of protection macro */