Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-arm / arch-ixp2000 / gpio.h
blob84634af5cc644ff1ef8d40ba298e17d6746eee17
1 /*
2 * include/asm-arm/arch-ixp2000/ixp2000-gpio.h
4 * Copyright (C) 2002 Intel Corporation.
6 * This program is free software, you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
12 * IXP2000 GPIO in/out, edge/level detection for IRQs:
13 * IRQs are generated on Falling-edge, Rising-Edge, Level-low, Level-High
14 * or both Falling-edge and Rising-edge.
15 * This must be called *before* the corresponding IRQ is registerd.
16 * Use this instead of directly setting the GPIO registers.
17 * GPIOs may also be used as GPIOs (e.g. for emulating i2c/smb)
19 #ifndef _ASM_ARCH_IXP2000_GPIO_H_
20 #define _ASM_ARCH_IXP2000_GPIO_H_
22 #ifndef __ASSEMBLY__
23 #define GPIO_OUT 0x0
24 #define GPIO_IN 0x80
26 #define IXP2000_GPIO_LOW 0
27 #define IXP2000_GPIO_HIGH 1
29 #define GPIO_NO_EDGES 0
30 #define GPIO_FALLING_EDGE 1
31 #define GPIO_RISING_EDGE 2
32 #define GPIO_BOTH_EDGES 3
33 #define GPIO_LEVEL_LOW 4
34 #define GPIO_LEVEL_HIGH 8
36 extern void set_GPIO_IRQ_edge(int gpio_nr, int edge);
37 extern void set_GPIO_IRQ_level(int gpio_nr, int level);
38 extern void gpio_line_config(int line, int style);
40 static inline int gpio_line_get(int line)
42 return (((*IXP2000_GPIO_PLR) >> line) & 1);
45 static inline void gpio_line_set(int line, int value)
47 if (value == IXP2000_GPIO_HIGH) {
48 ixp_reg_write(IXP2000_GPIO_POSR, BIT(line));
49 } else if (value == IXP2000_GPIO_LOW)
50 ixp_reg_write(IXP2000_GPIO_POCR, BIT(line));
53 #endif /* !__ASSEMBLY__ */
54 #endif /* ASM_ARCH_IXP2000_GPIO_H_ */