Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-arm/arch-ixp2000/ixp2000-gpio.h |
| 3 | * |
| 4 | * Copyright (C) 2002 Intel Corporation. |
| 5 | * |
| 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 | */ |
| 10 | |
| 11 | /* |
| 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) |
| 18 | */ |
| 19 | #ifndef _ASM_ARCH_IXP2000_GPIO_H_ |
| 20 | #define _ASM_ARCH_IXP2000_GPIO_H_ |
| 21 | |
| 22 | #ifndef __ASSEMBLY__ |
| 23 | #define GPIO_OUT 0x0 |
| 24 | #define GPIO_IN 0x80 |
| 25 | |
| 26 | #define IXP2000_GPIO_LOW 0 |
| 27 | #define IXP2000_GPIO_HIGH 1 |
| 28 | |
| 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 |
| 35 | |
| 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); |
| 39 | |
| 40 | static inline int gpio_line_get(int line) |
| 41 | { |
| 42 | return (((*IXP2000_GPIO_PLR) >> line) & 1); |
| 43 | } |
| 44 | |
| 45 | static inline void gpio_line_set(int line, int value) |
| 46 | { |
| 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)); |
| 51 | } |
| 52 | |
| 53 | #endif /* !__ASSEMBLY__ */ |
| 54 | #endif /* ASM_ARCH_IXP2000_GPIO_H_ */ |
| 55 | |