Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Lennert Buytenhek | c498288 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 2 | * include/asm-arm/arch-ixp2000/gpio.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Lennert Buytenhek | c498288 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 19 | #ifndef __ASM_ARCH_GPIO_H |
| 20 | #define __ASM_ARCH_GPIO_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | #ifndef __ASSEMBLY__ |
Lennert Buytenhek | c498288 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 23 | |
| 24 | #define GPIO_IN 0 |
| 25 | #define GPIO_OUT 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #define IXP2000_GPIO_LOW 0 |
| 28 | #define IXP2000_GPIO_HIGH 1 |
| 29 | |
Lennert Buytenhek | c498288 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 30 | extern void gpio_line_config(int line, int direction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | static inline int gpio_line_get(int line) |
| 33 | { |
| 34 | return (((*IXP2000_GPIO_PLR) >> line) & 1); |
| 35 | } |
| 36 | |
| 37 | static inline void gpio_line_set(int line, int value) |
| 38 | { |
| 39 | if (value == IXP2000_GPIO_HIGH) { |
Lennert Buytenhek | c498288 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 40 | ixp2000_reg_write(IXP2000_GPIO_POSR, 1 << line); |
| 41 | } else if (value == IXP2000_GPIO_LOW) { |
| 42 | ixp2000_reg_write(IXP2000_GPIO_POCR, 1 << line); |
| 43 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | #endif /* !__ASSEMBLY__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Lennert Buytenhek | c498288 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 48 | #endif /* ASM_ARCH_IXP2000_GPIO_H_ */ |