Stefan Roese | 0d974d5 | 2007-03-24 15:57:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 |
| 3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* 4xx PPC's have 2 GPIO controllers */ |
| 25 | #if defined(CONFIG_405EZ) || \ |
| 26 | defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ |
| 27 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
| 28 | #define GPIO_GROUP_MAX 2 |
| 29 | #else |
| 30 | #define GPIO_GROUP_MAX 1 |
| 31 | #endif |
| 32 | |
| 33 | #define GPIO_MAX 32 |
| 34 | #define GPIO_ALT1_SEL 0x40000000 |
| 35 | #define GPIO_ALT2_SEL 0x80000000 |
| 36 | #define GPIO_ALT3_SEL 0xc0000000 |
| 37 | #define GPIO_IN_SEL 0x40000000 |
| 38 | #define GPIO_MASK 0xc0000000 |
| 39 | |
| 40 | #define GPIO_VAL(gpio) (0x80000000 >> (gpio)) |
| 41 | |
| 42 | #ifndef __ASSEMBLY__ |
| 43 | typedef enum gpio_select { GPIO_SEL, GPIO_ALT1, GPIO_ALT2, GPIO_ALT3 } gpio_select_t; |
| 44 | typedef enum gpio_driver { GPIO_DIS, GPIO_IN, GPIO_OUT, GPIO_BI } gpio_driver_t; |
| 45 | typedef enum gpio_out { GPIO_OUT_0, GPIO_OUT_1, GPIO_OUT_NO_CHG } gpio_out_t; |
| 46 | |
| 47 | typedef struct { |
Stefan Roese | 85f7373 | 2007-06-15 07:39:43 +0200 | [diff] [blame] | 48 | unsigned long add; /* gpio core base address */ |
| 49 | gpio_driver_t in_out; /* Driver Setting */ |
| 50 | gpio_select_t alt_nb; /* Selected Alternate */ |
| 51 | gpio_out_t out_val;/* Default Output Value */ |
Stefan Roese | 0d974d5 | 2007-03-24 15:57:09 +0100 | [diff] [blame] | 52 | } gpio_param_s; |
| 53 | #endif |
| 54 | |
| 55 | void gpio_config(int pin, int in_out, int gpio_alt, int out_val); |
| 56 | void gpio_write_bit(int pin, int val); |
Stefan Roese | 85f7373 | 2007-06-15 07:39:43 +0200 | [diff] [blame] | 57 | int gpio_read_out_bit(int pin); |
Stefan Roese | 0d974d5 | 2007-03-24 15:57:09 +0100 | [diff] [blame] | 58 | void gpio_set_chip_configuration(void); |