Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/kernel/bfin_gpio.c |
| 3 | * Based on: |
| 4 | * Author: Michael Hennerich (hennerich@blackfin.uclinux.org) |
| 5 | * |
| 6 | * Created: |
| 7 | * Description: GPIO Abstraction Layer |
| 8 | * |
| 9 | * Modified: |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 10 | * Copyright 2008 Analog Devices Inc. |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
| 30 | /* |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 31 | * Number BF537/6/4 BF561 BF533/2/1 BF549/8/4/2 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 32 | * |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 33 | * GPIO_0 PF0 PF0 PF0 PA0...PJ13 |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 34 | * GPIO_1 PF1 PF1 PF1 |
| 35 | * GPIO_2 PF2 PF2 PF2 |
| 36 | * GPIO_3 PF3 PF3 PF3 |
| 37 | * GPIO_4 PF4 PF4 PF4 |
| 38 | * GPIO_5 PF5 PF5 PF5 |
| 39 | * GPIO_6 PF6 PF6 PF6 |
| 40 | * GPIO_7 PF7 PF7 PF7 |
| 41 | * GPIO_8 PF8 PF8 PF8 |
| 42 | * GPIO_9 PF9 PF9 PF9 |
| 43 | * GPIO_10 PF10 PF10 PF10 |
| 44 | * GPIO_11 PF11 PF11 PF11 |
| 45 | * GPIO_12 PF12 PF12 PF12 |
| 46 | * GPIO_13 PF13 PF13 PF13 |
| 47 | * GPIO_14 PF14 PF14 PF14 |
| 48 | * GPIO_15 PF15 PF15 PF15 |
| 49 | * GPIO_16 PG0 PF16 |
| 50 | * GPIO_17 PG1 PF17 |
| 51 | * GPIO_18 PG2 PF18 |
| 52 | * GPIO_19 PG3 PF19 |
| 53 | * GPIO_20 PG4 PF20 |
| 54 | * GPIO_21 PG5 PF21 |
| 55 | * GPIO_22 PG6 PF22 |
| 56 | * GPIO_23 PG7 PF23 |
| 57 | * GPIO_24 PG8 PF24 |
| 58 | * GPIO_25 PG9 PF25 |
| 59 | * GPIO_26 PG10 PF26 |
| 60 | * GPIO_27 PG11 PF27 |
| 61 | * GPIO_28 PG12 PF28 |
| 62 | * GPIO_29 PG13 PF29 |
| 63 | * GPIO_30 PG14 PF30 |
| 64 | * GPIO_31 PG15 PF31 |
| 65 | * GPIO_32 PH0 PF32 |
| 66 | * GPIO_33 PH1 PF33 |
| 67 | * GPIO_34 PH2 PF34 |
| 68 | * GPIO_35 PH3 PF35 |
| 69 | * GPIO_36 PH4 PF36 |
| 70 | * GPIO_37 PH5 PF37 |
| 71 | * GPIO_38 PH6 PF38 |
| 72 | * GPIO_39 PH7 PF39 |
| 73 | * GPIO_40 PH8 PF40 |
| 74 | * GPIO_41 PH9 PF41 |
| 75 | * GPIO_42 PH10 PF42 |
| 76 | * GPIO_43 PH11 PF43 |
| 77 | * GPIO_44 PH12 PF44 |
| 78 | * GPIO_45 PH13 PF45 |
| 79 | * GPIO_46 PH14 PF46 |
| 80 | * GPIO_47 PH15 PF47 |
| 81 | */ |
| 82 | |
Mike Frysinger | 168f121 | 2007-10-11 00:22:35 +0800 | [diff] [blame] | 83 | #include <linux/delay.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 84 | #include <linux/module.h> |
| 85 | #include <linux/err.h> |
Mike Frysinger | 1545a11 | 2007-12-24 16:54:48 +0800 | [diff] [blame] | 86 | #include <linux/proc_fs.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 87 | #include <asm/blackfin.h> |
| 88 | #include <asm/gpio.h> |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 89 | #include <asm/portmux.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 90 | #include <linux/irq.h> |
| 91 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 92 | #if ANOMALY_05000311 || ANOMALY_05000323 |
| 93 | enum { |
| 94 | AWA_data = SYSCR, |
| 95 | AWA_data_clear = SYSCR, |
| 96 | AWA_data_set = SYSCR, |
| 97 | AWA_toggle = SYSCR, |
Graf Yang | 6ed8394 | 2008-04-24 04:43:14 +0800 | [diff] [blame] | 98 | AWA_maska = BFIN_UART_SCR, |
| 99 | AWA_maska_clear = BFIN_UART_SCR, |
| 100 | AWA_maska_set = BFIN_UART_SCR, |
| 101 | AWA_maska_toggle = BFIN_UART_SCR, |
| 102 | AWA_maskb = BFIN_UART_GCTL, |
| 103 | AWA_maskb_clear = BFIN_UART_GCTL, |
| 104 | AWA_maskb_set = BFIN_UART_GCTL, |
| 105 | AWA_maskb_toggle = BFIN_UART_GCTL, |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 106 | AWA_dir = SPORT1_STAT, |
| 107 | AWA_polar = SPORT1_STAT, |
| 108 | AWA_edge = SPORT1_STAT, |
| 109 | AWA_both = SPORT1_STAT, |
| 110 | #if ANOMALY_05000311 |
| 111 | AWA_inen = TIMER_ENABLE, |
| 112 | #elif ANOMALY_05000323 |
| 113 | AWA_inen = DMA1_1_CONFIG, |
| 114 | #endif |
| 115 | }; |
| 116 | /* Anomaly Workaround */ |
| 117 | #define AWA_DUMMY_READ(name) bfin_read16(AWA_ ## name) |
| 118 | #else |
| 119 | #define AWA_DUMMY_READ(...) do { } while (0) |
| 120 | #endif |
| 121 | |
Michael Hennerich | dc26aec | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 122 | #if defined(BF533_FAMILY) || defined(BF538_FAMILY) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 123 | static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { |
| 124 | (struct gpio_port_t *) FIO_FLAG_D, |
| 125 | }; |
| 126 | #endif |
| 127 | |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 128 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 129 | static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { |
| 130 | (struct gpio_port_t *) PORTFIO, |
| 131 | (struct gpio_port_t *) PORTGIO, |
| 132 | (struct gpio_port_t *) PORTHIO, |
| 133 | }; |
| 134 | |
| 135 | static unsigned short *port_fer[gpio_bank(MAX_BLACKFIN_GPIOS)] = { |
| 136 | (unsigned short *) PORTF_FER, |
| 137 | (unsigned short *) PORTG_FER, |
| 138 | (unsigned short *) PORTH_FER, |
| 139 | }; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 140 | #endif |
| 141 | |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 142 | #if defined(BF527_FAMILY) || defined(BF518_FAMILY) |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 143 | static unsigned short *port_mux[gpio_bank(MAX_BLACKFIN_GPIOS)] = { |
| 144 | (unsigned short *) PORTF_MUX, |
| 145 | (unsigned short *) PORTG_MUX, |
| 146 | (unsigned short *) PORTH_MUX, |
| 147 | }; |
| 148 | |
| 149 | static const |
| 150 | u8 pmux_offset[][16] = |
| 151 | {{ 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 4, 6, 8, 8, 10, 10 }, /* PORTF */ |
| 152 | { 0, 0, 0, 0, 0, 2, 2, 4, 4, 6, 8, 10, 10, 10, 12, 12 }, /* PORTG */ |
| 153 | { 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 4 }, /* PORTH */ |
| 154 | }; |
| 155 | #endif |
| 156 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 157 | #ifdef BF561_FAMILY |
| 158 | static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { |
| 159 | (struct gpio_port_t *) FIO0_FLAG_D, |
| 160 | (struct gpio_port_t *) FIO1_FLAG_D, |
| 161 | (struct gpio_port_t *) FIO2_FLAG_D, |
| 162 | }; |
| 163 | #endif |
| 164 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 165 | #ifdef BF548_FAMILY |
| 166 | static struct gpio_port_t *gpio_array[gpio_bank(MAX_BLACKFIN_GPIOS)] = { |
| 167 | (struct gpio_port_t *)PORTA_FER, |
| 168 | (struct gpio_port_t *)PORTB_FER, |
| 169 | (struct gpio_port_t *)PORTC_FER, |
| 170 | (struct gpio_port_t *)PORTD_FER, |
| 171 | (struct gpio_port_t *)PORTE_FER, |
| 172 | (struct gpio_port_t *)PORTF_FER, |
| 173 | (struct gpio_port_t *)PORTG_FER, |
| 174 | (struct gpio_port_t *)PORTH_FER, |
| 175 | (struct gpio_port_t *)PORTI_FER, |
| 176 | (struct gpio_port_t *)PORTJ_FER, |
| 177 | }; |
| 178 | #endif |
| 179 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 180 | static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 181 | static unsigned short reserved_peri_map[gpio_bank(MAX_RESOURCES)]; |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 182 | |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 183 | #define RESOURCE_LABEL_SIZE 16 |
| 184 | |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 185 | static struct str_ident { |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 186 | char name[RESOURCE_LABEL_SIZE]; |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 187 | } str_ident[MAX_RESOURCES]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 188 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 189 | #if defined(CONFIG_PM) |
| 190 | #if defined(CONFIG_BF54x) |
| 191 | static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
| 192 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 193 | static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
| 194 | static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS]; |
| 195 | static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
| 196 | |
| 197 | #ifdef BF533_FAMILY |
| 198 | static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG_INTB}; |
| 199 | #endif |
| 200 | |
| 201 | #ifdef BF537_FAMILY |
| 202 | static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX}; |
| 203 | #endif |
| 204 | |
Michael Hennerich | dc26aec | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 205 | #ifdef BF538_FAMILY |
| 206 | static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PORTF_INTB}; |
| 207 | #endif |
| 208 | |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 209 | #if defined(BF527_FAMILY) || defined(BF518_FAMILY) |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 210 | static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PORTF_INTB, IRQ_PORTG_INTB, IRQ_PORTH_INTB}; |
| 211 | #endif |
| 212 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 213 | #ifdef BF561_FAMILY |
| 214 | static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB}; |
| 215 | #endif |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 216 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 217 | #endif /* CONFIG_PM */ |
| 218 | |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 219 | inline int check_gpio(unsigned gpio) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 220 | { |
Mike Frysinger | 27228b2 | 2008-10-28 15:45:42 +0800 | [diff] [blame] | 221 | #if defined(BF548_FAMILY) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 222 | if (gpio == GPIO_PB15 || gpio == GPIO_PC14 || gpio == GPIO_PC15 |
| 223 | || gpio == GPIO_PH14 || gpio == GPIO_PH15 |
Mike Frysinger | 27228b2 | 2008-10-28 15:45:42 +0800 | [diff] [blame] | 224 | || gpio == GPIO_PJ14 || gpio == GPIO_PJ15) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 225 | return -EINVAL; |
Mike Frysinger | 27228b2 | 2008-10-28 15:45:42 +0800 | [diff] [blame] | 226 | #endif |
Michael Hennerich | e7613aa | 2007-06-11 16:37:57 +0800 | [diff] [blame] | 227 | if (gpio >= MAX_BLACKFIN_GPIOS) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 228 | return -EINVAL; |
| 229 | return 0; |
| 230 | } |
| 231 | |
Mike Frysinger | 74c0450 | 2008-10-08 16:13:17 +0800 | [diff] [blame] | 232 | static void gpio_error(unsigned gpio) |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 233 | { |
| 234 | printk(KERN_ERR "bfin-gpio: GPIO %d wasn't requested!\n", gpio); |
| 235 | } |
| 236 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 237 | static void set_label(unsigned short ident, const char *label) |
| 238 | { |
Michael Hennerich | e9fae18 | 2008-10-13 11:35:22 +0800 | [diff] [blame] | 239 | if (label) { |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 240 | strncpy(str_ident[ident].name, label, |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 241 | RESOURCE_LABEL_SIZE); |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 242 | str_ident[ident].name[RESOURCE_LABEL_SIZE - 1] = 0; |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | |
| 246 | static char *get_label(unsigned short ident) |
| 247 | { |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 248 | return (*str_ident[ident].name ? str_ident[ident].name : "UNKNOWN"); |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static int cmp_label(unsigned short ident, const char *label) |
| 252 | { |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 253 | if (label == NULL) { |
| 254 | dump_stack(); |
| 255 | printk(KERN_ERR "Please provide none-null label\n"); |
| 256 | } |
| 257 | |
Michael Hennerich | e9fae18 | 2008-10-13 11:35:22 +0800 | [diff] [blame] | 258 | if (label) |
Mike Frysinger | 1f7d373 | 2008-10-28 15:47:11 +0800 | [diff] [blame] | 259 | return strcmp(str_ident[ident].name, label); |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 260 | else |
| 261 | return -EINVAL; |
| 262 | } |
| 263 | |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 264 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 265 | static void port_setup(unsigned gpio, unsigned short usage) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 266 | { |
Michael Hennerich | cda6a20 | 2007-10-04 00:36:18 +0800 | [diff] [blame] | 267 | if (!check_gpio(gpio)) { |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 268 | if (usage == GPIO_USAGE) |
Michael Hennerich | cda6a20 | 2007-10-04 00:36:18 +0800 | [diff] [blame] | 269 | *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 270 | else |
Michael Hennerich | cda6a20 | 2007-10-04 00:36:18 +0800 | [diff] [blame] | 271 | *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio); |
| 272 | SSYNC(); |
| 273 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 274 | } |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 275 | #elif defined(BF548_FAMILY) |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 276 | static void port_setup(unsigned gpio, unsigned short usage) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 277 | { |
| 278 | if (usage == GPIO_USAGE) |
| 279 | gpio_array[gpio_bank(gpio)]->port_fer &= ~gpio_bit(gpio); |
| 280 | else |
| 281 | gpio_array[gpio_bank(gpio)]->port_fer |= gpio_bit(gpio); |
| 282 | SSYNC(); |
| 283 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 284 | #else |
| 285 | # define port_setup(...) do { } while (0) |
| 286 | #endif |
| 287 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 288 | #ifdef BF537_FAMILY |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 289 | static struct { |
| 290 | unsigned short res; |
| 291 | unsigned short offset; |
| 292 | } port_mux_lut[] = { |
| 293 | {.res = P_PPI0_D13, .offset = 11}, |
| 294 | {.res = P_PPI0_D14, .offset = 11}, |
| 295 | {.res = P_PPI0_D15, .offset = 11}, |
| 296 | {.res = P_SPORT1_TFS, .offset = 11}, |
| 297 | {.res = P_SPORT1_TSCLK, .offset = 11}, |
| 298 | {.res = P_SPORT1_DTPRI, .offset = 11}, |
| 299 | {.res = P_PPI0_D10, .offset = 10}, |
| 300 | {.res = P_PPI0_D11, .offset = 10}, |
| 301 | {.res = P_PPI0_D12, .offset = 10}, |
| 302 | {.res = P_SPORT1_RSCLK, .offset = 10}, |
| 303 | {.res = P_SPORT1_RFS, .offset = 10}, |
| 304 | {.res = P_SPORT1_DRPRI, .offset = 10}, |
| 305 | {.res = P_PPI0_D8, .offset = 9}, |
| 306 | {.res = P_PPI0_D9, .offset = 9}, |
| 307 | {.res = P_SPORT1_DRSEC, .offset = 9}, |
| 308 | {.res = P_SPORT1_DTSEC, .offset = 9}, |
| 309 | {.res = P_TMR2, .offset = 8}, |
| 310 | {.res = P_PPI0_FS3, .offset = 8}, |
| 311 | {.res = P_TMR3, .offset = 7}, |
| 312 | {.res = P_SPI0_SSEL4, .offset = 7}, |
| 313 | {.res = P_TMR4, .offset = 6}, |
| 314 | {.res = P_SPI0_SSEL5, .offset = 6}, |
| 315 | {.res = P_TMR5, .offset = 5}, |
| 316 | {.res = P_SPI0_SSEL6, .offset = 5}, |
| 317 | {.res = P_UART1_RX, .offset = 4}, |
| 318 | {.res = P_UART1_TX, .offset = 4}, |
| 319 | {.res = P_TMR6, .offset = 4}, |
| 320 | {.res = P_TMR7, .offset = 4}, |
| 321 | {.res = P_UART0_RX, .offset = 3}, |
| 322 | {.res = P_UART0_TX, .offset = 3}, |
| 323 | {.res = P_DMAR0, .offset = 3}, |
| 324 | {.res = P_DMAR1, .offset = 3}, |
| 325 | {.res = P_SPORT0_DTSEC, .offset = 1}, |
| 326 | {.res = P_SPORT0_DRSEC, .offset = 1}, |
| 327 | {.res = P_CAN0_RX, .offset = 1}, |
| 328 | {.res = P_CAN0_TX, .offset = 1}, |
| 329 | {.res = P_SPI0_SSEL7, .offset = 1}, |
| 330 | {.res = P_SPORT0_TFS, .offset = 0}, |
| 331 | {.res = P_SPORT0_DTPRI, .offset = 0}, |
| 332 | {.res = P_SPI0_SSEL2, .offset = 0}, |
| 333 | {.res = P_SPI0_SSEL3, .offset = 0}, |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | static void portmux_setup(unsigned short per, unsigned short function) |
| 337 | { |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 338 | u16 y, offset, muxreg; |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 339 | |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 340 | for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) { |
| 341 | if (port_mux_lut[y].res == per) { |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 342 | |
| 343 | /* SET PORTMUX REG */ |
| 344 | |
Michael Hennerich | 8c61362 | 2007-08-03 17:48:09 +0800 | [diff] [blame] | 345 | offset = port_mux_lut[y].offset; |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 346 | muxreg = bfin_read_PORT_MUX(); |
| 347 | |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 348 | if (offset != 1) |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 349 | muxreg &= ~(1 << offset); |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 350 | else |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 351 | muxreg &= ~(3 << 1); |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 352 | |
| 353 | muxreg |= (function << offset); |
| 354 | bfin_write_PORT_MUX(muxreg); |
| 355 | } |
| 356 | } |
| 357 | } |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 358 | #elif defined(BF548_FAMILY) |
| 359 | inline void portmux_setup(unsigned short portno, unsigned short function) |
| 360 | { |
| 361 | u32 pmux; |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 362 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 363 | pmux = gpio_array[gpio_bank(portno)]->port_mux; |
| 364 | |
| 365 | pmux &= ~(0x3 << (2 * gpio_sub_n(portno))); |
| 366 | pmux |= (function & 0x3) << (2 * gpio_sub_n(portno)); |
| 367 | |
| 368 | gpio_array[gpio_bank(portno)]->port_mux = pmux; |
| 369 | } |
| 370 | |
| 371 | inline u16 get_portmux(unsigned short portno) |
| 372 | { |
| 373 | u32 pmux; |
| 374 | |
| 375 | pmux = gpio_array[gpio_bank(portno)]->port_mux; |
| 376 | |
| 377 | return (pmux >> (2 * gpio_sub_n(portno)) & 0x3); |
| 378 | } |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 379 | #elif defined(BF527_FAMILY) || defined(BF518_FAMILY) |
Michael Hennerich | 5900314 | 2007-10-21 16:54:27 +0800 | [diff] [blame] | 380 | inline void portmux_setup(unsigned short portno, unsigned short function) |
| 381 | { |
| 382 | u16 pmux, ident = P_IDENT(portno); |
| 383 | u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)]; |
| 384 | |
| 385 | pmux = *port_mux[gpio_bank(ident)]; |
| 386 | pmux &= ~(3 << offset); |
| 387 | pmux |= (function & 3) << offset; |
| 388 | *port_mux[gpio_bank(ident)] = pmux; |
| 389 | SSYNC(); |
| 390 | } |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 391 | #else |
| 392 | # define portmux_setup(...) do { } while (0) |
| 393 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 394 | |
Mike Frysinger | a161bb0 | 2007-05-21 18:09:14 +0800 | [diff] [blame] | 395 | static int __init bfin_gpio_init(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 396 | { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 397 | printk(KERN_INFO "Blackfin GPIO Controller\n"); |
| 398 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 399 | return 0; |
| 400 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 401 | arch_initcall(bfin_gpio_init); |
| 402 | |
| 403 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 404 | #ifndef BF548_FAMILY |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 405 | /*********************************************************** |
| 406 | * |
| 407 | * FUNCTIONS: Blackfin General Purpose Ports Access Functions |
| 408 | * |
| 409 | * INPUTS/OUTPUTS: |
| 410 | * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS |
| 411 | * |
| 412 | * |
| 413 | * DESCRIPTION: These functions abstract direct register access |
| 414 | * to Blackfin processor General Purpose |
| 415 | * Ports Regsiters |
| 416 | * |
| 417 | * CAUTION: These functions do not belong to the GPIO Driver API |
| 418 | ************************************************************* |
| 419 | * MODIFICATION HISTORY : |
| 420 | **************************************************************/ |
| 421 | |
| 422 | /* Set a specific bit */ |
| 423 | |
| 424 | #define SET_GPIO(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 425 | void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 426 | { \ |
| 427 | unsigned long flags; \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 428 | local_irq_save(flags); \ |
| 429 | if (arg) \ |
| 430 | gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ |
| 431 | else \ |
| 432 | gpio_bankb[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \ |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 433 | AWA_DUMMY_READ(name); \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 434 | local_irq_restore(flags); \ |
| 435 | } \ |
| 436 | EXPORT_SYMBOL(set_gpio_ ## name); |
| 437 | |
| 438 | SET_GPIO(dir) |
| 439 | SET_GPIO(inen) |
| 440 | SET_GPIO(polar) |
| 441 | SET_GPIO(edge) |
| 442 | SET_GPIO(both) |
| 443 | |
| 444 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 445 | #if ANOMALY_05000311 || ANOMALY_05000323 |
| 446 | #define SET_GPIO_SC(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 447 | void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 448 | { \ |
| 449 | unsigned long flags; \ |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 450 | local_irq_save(flags); \ |
| 451 | if (arg) \ |
| 452 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ |
| 453 | else \ |
| 454 | gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \ |
| 455 | AWA_DUMMY_READ(name); \ |
| 456 | local_irq_restore(flags); \ |
| 457 | } \ |
| 458 | EXPORT_SYMBOL(set_gpio_ ## name); |
| 459 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 460 | #define SET_GPIO_SC(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 461 | void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 462 | { \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 463 | if (arg) \ |
| 464 | gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ |
| 465 | else \ |
| 466 | gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \ |
| 467 | } \ |
| 468 | EXPORT_SYMBOL(set_gpio_ ## name); |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 469 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 470 | |
| 471 | SET_GPIO_SC(maska) |
| 472 | SET_GPIO_SC(maskb) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 473 | SET_GPIO_SC(data) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 474 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 475 | #if ANOMALY_05000311 || ANOMALY_05000323 |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 476 | void set_gpio_toggle(unsigned gpio) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 477 | { |
| 478 | unsigned long flags; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 479 | local_irq_save(flags); |
| 480 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 481 | AWA_DUMMY_READ(toggle); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 482 | local_irq_restore(flags); |
| 483 | } |
| 484 | #else |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 485 | void set_gpio_toggle(unsigned gpio) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 486 | { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 487 | gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); |
| 488 | } |
| 489 | #endif |
| 490 | EXPORT_SYMBOL(set_gpio_toggle); |
| 491 | |
| 492 | |
| 493 | /*Set current PORT date (16-bit word)*/ |
| 494 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 495 | #if ANOMALY_05000311 || ANOMALY_05000323 |
| 496 | #define SET_GPIO_P(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 497 | void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \ |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 498 | { \ |
| 499 | unsigned long flags; \ |
| 500 | local_irq_save(flags); \ |
| 501 | gpio_bankb[gpio_bank(gpio)]->name = arg; \ |
| 502 | AWA_DUMMY_READ(name); \ |
| 503 | local_irq_restore(flags); \ |
| 504 | } \ |
| 505 | EXPORT_SYMBOL(set_gpiop_ ## name); |
| 506 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 507 | #define SET_GPIO_P(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 508 | void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 509 | { \ |
| 510 | gpio_bankb[gpio_bank(gpio)]->name = arg; \ |
| 511 | } \ |
| 512 | EXPORT_SYMBOL(set_gpiop_ ## name); |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 513 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 514 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 515 | SET_GPIO_P(data) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 516 | SET_GPIO_P(dir) |
| 517 | SET_GPIO_P(inen) |
| 518 | SET_GPIO_P(polar) |
| 519 | SET_GPIO_P(edge) |
| 520 | SET_GPIO_P(both) |
| 521 | SET_GPIO_P(maska) |
| 522 | SET_GPIO_P(maskb) |
| 523 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 524 | /* Get a specific bit */ |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 525 | #if ANOMALY_05000311 || ANOMALY_05000323 |
| 526 | #define GET_GPIO(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 527 | unsigned short get_gpio_ ## name(unsigned gpio) \ |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 528 | { \ |
| 529 | unsigned long flags; \ |
| 530 | unsigned short ret; \ |
| 531 | local_irq_save(flags); \ |
| 532 | ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \ |
| 533 | AWA_DUMMY_READ(name); \ |
| 534 | local_irq_restore(flags); \ |
| 535 | return ret; \ |
| 536 | } \ |
| 537 | EXPORT_SYMBOL(get_gpio_ ## name); |
| 538 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 539 | #define GET_GPIO(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 540 | unsigned short get_gpio_ ## name(unsigned gpio) \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 541 | { \ |
| 542 | return (0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio))); \ |
| 543 | } \ |
| 544 | EXPORT_SYMBOL(get_gpio_ ## name); |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 545 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 546 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 547 | GET_GPIO(data) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 548 | GET_GPIO(dir) |
| 549 | GET_GPIO(inen) |
| 550 | GET_GPIO(polar) |
| 551 | GET_GPIO(edge) |
| 552 | GET_GPIO(both) |
| 553 | GET_GPIO(maska) |
| 554 | GET_GPIO(maskb) |
| 555 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 556 | /*Get current PORT date (16-bit word)*/ |
| 557 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 558 | #if ANOMALY_05000311 || ANOMALY_05000323 |
| 559 | #define GET_GPIO_P(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 560 | unsigned short get_gpiop_ ## name(unsigned gpio) \ |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 561 | { \ |
| 562 | unsigned long flags; \ |
| 563 | unsigned short ret; \ |
| 564 | local_irq_save(flags); \ |
| 565 | ret = (gpio_bankb[gpio_bank(gpio)]->name); \ |
| 566 | AWA_DUMMY_READ(name); \ |
| 567 | local_irq_restore(flags); \ |
| 568 | return ret; \ |
| 569 | } \ |
| 570 | EXPORT_SYMBOL(get_gpiop_ ## name); |
| 571 | #else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 572 | #define GET_GPIO_P(name) \ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 573 | unsigned short get_gpiop_ ## name(unsigned gpio) \ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 574 | { \ |
| 575 | return (gpio_bankb[gpio_bank(gpio)]->name);\ |
| 576 | } \ |
| 577 | EXPORT_SYMBOL(get_gpiop_ ## name); |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 578 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 579 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 580 | GET_GPIO_P(data) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 581 | GET_GPIO_P(dir) |
| 582 | GET_GPIO_P(inen) |
| 583 | GET_GPIO_P(polar) |
| 584 | GET_GPIO_P(edge) |
| 585 | GET_GPIO_P(both) |
| 586 | GET_GPIO_P(maska) |
| 587 | GET_GPIO_P(maskb) |
| 588 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 589 | |
| 590 | #ifdef CONFIG_PM |
| 591 | /*********************************************************** |
| 592 | * |
| 593 | * FUNCTIONS: Blackfin PM Setup API |
| 594 | * |
| 595 | * INPUTS/OUTPUTS: |
| 596 | * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS |
| 597 | * type - |
| 598 | * PM_WAKE_RISING |
| 599 | * PM_WAKE_FALLING |
| 600 | * PM_WAKE_HIGH |
| 601 | * PM_WAKE_LOW |
| 602 | * PM_WAKE_BOTH_EDGES |
| 603 | * |
| 604 | * DESCRIPTION: Blackfin PM Driver API |
| 605 | * |
| 606 | * CAUTION: |
| 607 | ************************************************************* |
| 608 | * MODIFICATION HISTORY : |
| 609 | **************************************************************/ |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 610 | int gpio_pm_wakeup_request(unsigned gpio, unsigned char type) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 611 | { |
| 612 | unsigned long flags; |
| 613 | |
| 614 | if ((check_gpio(gpio) < 0) || !type) |
| 615 | return -EINVAL; |
| 616 | |
| 617 | local_irq_save(flags); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 618 | wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio); |
| 619 | wakeup_flags_map[gpio] = type; |
| 620 | local_irq_restore(flags); |
| 621 | |
| 622 | return 0; |
| 623 | } |
| 624 | EXPORT_SYMBOL(gpio_pm_wakeup_request); |
| 625 | |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 626 | void gpio_pm_wakeup_free(unsigned gpio) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 627 | { |
| 628 | unsigned long flags; |
| 629 | |
| 630 | if (check_gpio(gpio) < 0) |
| 631 | return; |
| 632 | |
| 633 | local_irq_save(flags); |
| 634 | |
| 635 | wakeup_map[gpio_bank(gpio)] &= ~gpio_bit(gpio); |
| 636 | |
| 637 | local_irq_restore(flags); |
| 638 | } |
| 639 | EXPORT_SYMBOL(gpio_pm_wakeup_free); |
| 640 | |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 641 | static int bfin_gpio_wakeup_type(unsigned gpio, unsigned char type) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 642 | { |
| 643 | port_setup(gpio, GPIO_USAGE); |
| 644 | set_gpio_dir(gpio, 0); |
| 645 | set_gpio_inen(gpio, 1); |
| 646 | |
| 647 | if (type & (PM_WAKE_RISING | PM_WAKE_FALLING)) |
| 648 | set_gpio_edge(gpio, 1); |
| 649 | else |
| 650 | set_gpio_edge(gpio, 0); |
| 651 | |
| 652 | if ((type & (PM_WAKE_BOTH_EDGES)) == (PM_WAKE_BOTH_EDGES)) |
| 653 | set_gpio_both(gpio, 1); |
| 654 | else |
| 655 | set_gpio_both(gpio, 0); |
| 656 | |
| 657 | if ((type & (PM_WAKE_FALLING | PM_WAKE_LOW))) |
| 658 | set_gpio_polar(gpio, 1); |
| 659 | else |
| 660 | set_gpio_polar(gpio, 0); |
| 661 | |
| 662 | SSYNC(); |
| 663 | |
| 664 | return 0; |
| 665 | } |
| 666 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 667 | u32 bfin_pm_standby_setup(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 668 | { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 669 | u16 bank, mask, i, gpio; |
| 670 | |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 671 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 672 | mask = wakeup_map[gpio_bank(i)]; |
| 673 | bank = gpio_bank(i); |
| 674 | |
| 675 | gpio_bank_saved[bank].maskb = gpio_bankb[bank]->maskb; |
| 676 | gpio_bankb[bank]->maskb = 0; |
| 677 | |
| 678 | if (mask) { |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 679 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 680 | gpio_bank_saved[bank].fer = *port_fer[bank]; |
| 681 | #endif |
| 682 | gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; |
| 683 | gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar; |
| 684 | gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; |
| 685 | gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; |
| 686 | gpio_bank_saved[bank].both = gpio_bankb[bank]->both; |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 687 | gpio_bank_saved[bank].reserved = |
| 688 | reserved_gpio_map[bank]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 689 | |
| 690 | gpio = i; |
| 691 | |
| 692 | while (mask) { |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 693 | if ((mask & 1) && (wakeup_flags_map[gpio] != |
| 694 | PM_WAKE_IGNORE)) { |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 695 | reserved_gpio_map[gpio_bank(gpio)] |= |
Michael Hennerich | 581d62a | 2007-06-14 13:30:23 +0800 | [diff] [blame] | 696 | gpio_bit(gpio); |
| 697 | bfin_gpio_wakeup_type(gpio, |
| 698 | wakeup_flags_map[gpio]); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 699 | set_gpio_data(gpio, 0); /*Clear*/ |
| 700 | } |
| 701 | gpio++; |
| 702 | mask >>= 1; |
| 703 | } |
| 704 | |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 705 | bfin_internal_set_wake(sic_iwr_irqs[bank], 1); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 706 | gpio_bankb[bank]->maskb_set = wakeup_map[gpio_bank(i)]; |
| 707 | } |
| 708 | } |
| 709 | |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 710 | AWA_DUMMY_READ(maskb_set); |
| 711 | |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 712 | return 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 713 | } |
| 714 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 715 | void bfin_pm_standby_restore(void) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 716 | { |
| 717 | u16 bank, mask, i; |
| 718 | |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 719 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 720 | mask = wakeup_map[gpio_bank(i)]; |
| 721 | bank = gpio_bank(i); |
| 722 | |
| 723 | if (mask) { |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 724 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 725 | *port_fer[bank] = gpio_bank_saved[bank].fer; |
| 726 | #endif |
| 727 | gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; |
| 728 | gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir; |
| 729 | gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar; |
| 730 | gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; |
| 731 | gpio_bankb[bank]->both = gpio_bank_saved[bank].both; |
Michael Hennerich | 581d62a | 2007-06-14 13:30:23 +0800 | [diff] [blame] | 732 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 733 | reserved_gpio_map[bank] = |
| 734 | gpio_bank_saved[bank].reserved; |
Michael Hennerich | cfefe3c | 2008-02-09 04:12:37 +0800 | [diff] [blame] | 735 | bfin_internal_set_wake(sic_iwr_irqs[bank], 0); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | gpio_bankb[bank]->maskb = gpio_bank_saved[bank].maskb; |
| 739 | } |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 740 | AWA_DUMMY_READ(maskb); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 741 | } |
| 742 | |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 743 | void bfin_gpio_pm_hibernate_suspend(void) |
| 744 | { |
| 745 | int i, bank; |
| 746 | |
| 747 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { |
| 748 | bank = gpio_bank(i); |
| 749 | |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 750 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 751 | gpio_bank_saved[bank].fer = *port_fer[bank]; |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 752 | #if defined(BF527_FAMILY) || defined(BF518_FAMILY) |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 753 | gpio_bank_saved[bank].mux = *port_mux[bank]; |
| 754 | #else |
| 755 | if (bank == 0) |
| 756 | gpio_bank_saved[bank].mux = bfin_read_PORT_MUX(); |
| 757 | #endif |
| 758 | #endif |
| 759 | gpio_bank_saved[bank].data = gpio_bankb[bank]->data; |
| 760 | gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; |
| 761 | gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar; |
| 762 | gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; |
| 763 | gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; |
| 764 | gpio_bank_saved[bank].both = gpio_bankb[bank]->both; |
| 765 | gpio_bank_saved[bank].maska = gpio_bankb[bank]->maska; |
| 766 | } |
| 767 | |
| 768 | AWA_DUMMY_READ(maska); |
| 769 | } |
| 770 | |
| 771 | void bfin_gpio_pm_hibernate_restore(void) |
| 772 | { |
| 773 | int i, bank; |
| 774 | |
| 775 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { |
| 776 | bank = gpio_bank(i); |
| 777 | |
Bryan Wu | 2f6f4bc | 2008-11-18 17:48:21 +0800 | [diff] [blame] | 778 | #if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) |
| 779 | #if defined(BF527_FAMILY) || defined(BF518_FAMILY) |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 780 | *port_mux[bank] = gpio_bank_saved[bank].mux; |
| 781 | #else |
| 782 | if (bank == 0) |
| 783 | bfin_write_PORT_MUX(gpio_bank_saved[bank].mux); |
| 784 | #endif |
| 785 | *port_fer[bank] = gpio_bank_saved[bank].fer; |
| 786 | #endif |
| 787 | gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; |
| 788 | gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir; |
| 789 | gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar; |
| 790 | gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; |
| 791 | gpio_bankb[bank]->both = gpio_bank_saved[bank].both; |
| 792 | |
| 793 | gpio_bankb[bank]->data_set = gpio_bank_saved[bank].data |
| 794 | | gpio_bank_saved[bank].dir; |
| 795 | |
| 796 | gpio_bankb[bank]->maska = gpio_bank_saved[bank].maska; |
| 797 | } |
| 798 | AWA_DUMMY_READ(maska); |
| 799 | } |
| 800 | |
| 801 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 802 | #endif |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 803 | #else /* BF548_FAMILY */ |
Michael Hennerich | 1efc80b | 2008-07-19 16:57:32 +0800 | [diff] [blame] | 804 | #ifdef CONFIG_PM |
| 805 | |
| 806 | u32 bfin_pm_standby_setup(void) |
| 807 | { |
| 808 | return 0; |
| 809 | } |
| 810 | |
| 811 | void bfin_pm_standby_restore(void) |
| 812 | { |
| 813 | |
| 814 | } |
| 815 | |
| 816 | void bfin_gpio_pm_hibernate_suspend(void) |
| 817 | { |
| 818 | int i, bank; |
| 819 | |
| 820 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { |
| 821 | bank = gpio_bank(i); |
| 822 | |
| 823 | gpio_bank_saved[bank].fer = gpio_array[bank]->port_fer; |
| 824 | gpio_bank_saved[bank].mux = gpio_array[bank]->port_mux; |
| 825 | gpio_bank_saved[bank].data = gpio_array[bank]->port_data; |
| 826 | gpio_bank_saved[bank].data = gpio_array[bank]->port_data; |
| 827 | gpio_bank_saved[bank].inen = gpio_array[bank]->port_inen; |
| 828 | gpio_bank_saved[bank].dir = gpio_array[bank]->port_dir_set; |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | void bfin_gpio_pm_hibernate_restore(void) |
| 833 | { |
| 834 | int i, bank; |
| 835 | |
| 836 | for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { |
| 837 | bank = gpio_bank(i); |
| 838 | |
| 839 | gpio_array[bank]->port_mux = gpio_bank_saved[bank].mux; |
| 840 | gpio_array[bank]->port_fer = gpio_bank_saved[bank].fer; |
| 841 | gpio_array[bank]->port_inen = gpio_bank_saved[bank].inen; |
| 842 | gpio_array[bank]->port_dir_set = gpio_bank_saved[bank].dir; |
| 843 | gpio_array[bank]->port_set = gpio_bank_saved[bank].data |
| 844 | | gpio_bank_saved[bank].dir; |
| 845 | } |
| 846 | } |
| 847 | #endif |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 848 | |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 849 | unsigned short get_gpio_dir(unsigned gpio) |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 850 | { |
| 851 | return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio))); |
| 852 | } |
| 853 | EXPORT_SYMBOL(get_gpio_dir); |
| 854 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 855 | #endif /* BF548_FAMILY */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 856 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 857 | /*********************************************************** |
| 858 | * |
| 859 | * FUNCTIONS: Blackfin Peripheral Resource Allocation |
| 860 | * and PortMux Setup |
| 861 | * |
| 862 | * INPUTS/OUTPUTS: |
| 863 | * per Peripheral Identifier |
| 864 | * label String |
| 865 | * |
| 866 | * DESCRIPTION: Blackfin Peripheral Resource Allocation and Setup API |
| 867 | * |
| 868 | * CAUTION: |
| 869 | ************************************************************* |
| 870 | * MODIFICATION HISTORY : |
| 871 | **************************************************************/ |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 872 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 873 | int peripheral_request(unsigned short per, const char *label) |
| 874 | { |
| 875 | unsigned long flags; |
| 876 | unsigned short ident = P_IDENT(per); |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 877 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 878 | /* |
| 879 | * Don't cares are pins with only one dedicated function |
| 880 | */ |
| 881 | |
| 882 | if (per & P_DONTCARE) |
| 883 | return 0; |
| 884 | |
| 885 | if (!(per & P_DEFINED)) |
| 886 | return -ENODEV; |
| 887 | |
Mike Frysinger | 6c7ec0e | 2008-10-28 15:49:59 +0800 | [diff] [blame^] | 888 | if (check_gpio(ident)) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 889 | return -EINVAL; |
| 890 | |
| 891 | local_irq_save(flags); |
| 892 | |
Mike Frysinger | 6c7ec0e | 2008-10-28 15:49:59 +0800 | [diff] [blame^] | 893 | /* Can't do GPIO and peripheral at the same time */ |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 894 | if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) { |
Mike Frysinger | f85c4ab | 2008-03-26 08:34:23 +0800 | [diff] [blame] | 895 | dump_stack(); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 896 | printk(KERN_ERR |
Mike Frysinger | 6c7ec0e | 2008-10-28 15:49:59 +0800 | [diff] [blame^] | 897 | "%s: Peripheral %d is already reserved as GPIO by %s !\n", |
Harvey Harrison | b85d858 | 2008-04-23 09:39:01 +0800 | [diff] [blame] | 898 | __func__, ident, get_label(ident)); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 899 | local_irq_restore(flags); |
| 900 | return -EBUSY; |
| 901 | } |
| 902 | |
| 903 | if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) { |
| 904 | |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 905 | /* |
| 906 | * Pin functions like AMC address strobes my |
| 907 | * be requested and used by several drivers |
| 908 | */ |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 909 | |
Mike Frysinger | 6c7ec0e | 2008-10-28 15:49:59 +0800 | [diff] [blame^] | 910 | #ifdef BF548_FAMILY |
| 911 | u16 funct = get_portmux(ident); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 912 | |
Mike Frysinger | 6c7ec0e | 2008-10-28 15:49:59 +0800 | [diff] [blame^] | 913 | if (!((per & P_MAYSHARE) && (funct == P_FUNCT2MUX(per)))) { |
| 914 | #else |
| 915 | if (!(per & P_MAYSHARE)) { |
| 916 | #endif |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 917 | /* |
| 918 | * Allow that the identical pin function can |
| 919 | * be requested from the same driver twice |
| 920 | */ |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 921 | |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 922 | if (cmp_label(ident, label) == 0) |
| 923 | goto anyway; |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 924 | |
Mike Frysinger | f85c4ab | 2008-03-26 08:34:23 +0800 | [diff] [blame] | 925 | dump_stack(); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 926 | printk(KERN_ERR |
| 927 | "%s: Peripheral %d function %d is already reserved by %s !\n", |
Harvey Harrison | b85d858 | 2008-04-23 09:39:01 +0800 | [diff] [blame] | 928 | __func__, ident, P_FUNCT2MUX(per), get_label(ident)); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 929 | local_irq_restore(flags); |
| 930 | return -EBUSY; |
| 931 | } |
| 932 | } |
| 933 | |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 934 | anyway: |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 935 | reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident); |
| 936 | |
Mike Frysinger | 6c7ec0e | 2008-10-28 15:49:59 +0800 | [diff] [blame^] | 937 | #ifdef BF548_FAMILY |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 938 | portmux_setup(ident, P_FUNCT2MUX(per)); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 939 | #else |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 940 | portmux_setup(per, P_FUNCT2MUX(per)); |
Mike Frysinger | 6c7ec0e | 2008-10-28 15:49:59 +0800 | [diff] [blame^] | 941 | #endif |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 942 | port_setup(ident, PERIPHERAL_USAGE); |
| 943 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 944 | local_irq_restore(flags); |
| 945 | set_label(ident, label); |
| 946 | |
| 947 | return 0; |
| 948 | } |
| 949 | EXPORT_SYMBOL(peripheral_request); |
| 950 | |
Mike Frysinger | 6817937 | 2008-04-24 05:04:24 +0800 | [diff] [blame] | 951 | int peripheral_request_list(const unsigned short per[], const char *label) |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 952 | { |
| 953 | u16 cnt; |
| 954 | int ret; |
| 955 | |
| 956 | for (cnt = 0; per[cnt] != 0; cnt++) { |
Michael Hennerich | 314c98d | 2007-07-24 18:03:45 +0800 | [diff] [blame] | 957 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 958 | ret = peripheral_request(per[cnt], label); |
Michael Hennerich | 314c98d | 2007-07-24 18:03:45 +0800 | [diff] [blame] | 959 | |
| 960 | if (ret < 0) { |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 961 | for ( ; cnt > 0; cnt--) |
Michael Hennerich | 314c98d | 2007-07-24 18:03:45 +0800 | [diff] [blame] | 962 | peripheral_free(per[cnt - 1]); |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 963 | |
| 964 | return ret; |
Michael Hennerich | 314c98d | 2007-07-24 18:03:45 +0800 | [diff] [blame] | 965 | } |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | return 0; |
| 969 | } |
| 970 | EXPORT_SYMBOL(peripheral_request_list); |
| 971 | |
| 972 | void peripheral_free(unsigned short per) |
| 973 | { |
| 974 | unsigned long flags; |
| 975 | unsigned short ident = P_IDENT(per); |
| 976 | |
| 977 | if (per & P_DONTCARE) |
| 978 | return; |
| 979 | |
| 980 | if (!(per & P_DEFINED)) |
| 981 | return; |
| 982 | |
| 983 | if (check_gpio(ident) < 0) |
| 984 | return; |
| 985 | |
| 986 | local_irq_save(flags); |
| 987 | |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 988 | if (unlikely(!(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident)))) { |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 989 | local_irq_restore(flags); |
| 990 | return; |
| 991 | } |
| 992 | |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 993 | if (!(per & P_MAYSHARE)) |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 994 | port_setup(ident, GPIO_USAGE); |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 995 | |
| 996 | reserved_peri_map[gpio_bank(ident)] &= ~gpio_bit(ident); |
| 997 | |
Michael Hennerich | 2acde90 | 2007-10-11 00:24:40 +0800 | [diff] [blame] | 998 | set_label(ident, "free"); |
| 999 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1000 | local_irq_restore(flags); |
| 1001 | } |
| 1002 | EXPORT_SYMBOL(peripheral_free); |
| 1003 | |
Mike Frysinger | 6817937 | 2008-04-24 05:04:24 +0800 | [diff] [blame] | 1004 | void peripheral_free_list(const unsigned short per[]) |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1005 | { |
| 1006 | u16 cnt; |
Mike Frysinger | d171c23 | 2008-03-26 08:35:46 +0800 | [diff] [blame] | 1007 | for (cnt = 0; per[cnt] != 0; cnt++) |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1008 | peripheral_free(per[cnt]); |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1009 | } |
| 1010 | EXPORT_SYMBOL(peripheral_free_list); |
| 1011 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1012 | /*********************************************************** |
| 1013 | * |
| 1014 | * FUNCTIONS: Blackfin GPIO Driver |
| 1015 | * |
| 1016 | * INPUTS/OUTPUTS: |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1017 | * gpio PIO Number between 0 and MAX_BLACKFIN_GPIOS |
| 1018 | * label String |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1019 | * |
| 1020 | * DESCRIPTION: Blackfin GPIO Driver API |
| 1021 | * |
| 1022 | * CAUTION: |
| 1023 | ************************************************************* |
| 1024 | * MODIFICATION HISTORY : |
| 1025 | **************************************************************/ |
| 1026 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1027 | int gpio_request(unsigned gpio, const char *label) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1028 | { |
| 1029 | unsigned long flags; |
| 1030 | |
| 1031 | if (check_gpio(gpio) < 0) |
| 1032 | return -EINVAL; |
| 1033 | |
| 1034 | local_irq_save(flags); |
| 1035 | |
Michael Hennerich | 2acde90 | 2007-10-11 00:24:40 +0800 | [diff] [blame] | 1036 | /* |
| 1037 | * Allow that the identical GPIO can |
| 1038 | * be requested from the same driver twice |
| 1039 | * Do nothing and return - |
| 1040 | */ |
| 1041 | |
| 1042 | if (cmp_label(gpio, label) == 0) { |
| 1043 | local_irq_restore(flags); |
| 1044 | return 0; |
| 1045 | } |
| 1046 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1047 | if (unlikely(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
Mike Frysinger | f85c4ab | 2008-03-26 08:34:23 +0800 | [diff] [blame] | 1048 | dump_stack(); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1049 | printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n", |
| 1050 | gpio, get_label(gpio)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1051 | local_irq_restore(flags); |
| 1052 | return -EBUSY; |
| 1053 | } |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1054 | if (unlikely(reserved_peri_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
Mike Frysinger | f85c4ab | 2008-03-26 08:34:23 +0800 | [diff] [blame] | 1055 | dump_stack(); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1056 | printk(KERN_ERR |
| 1057 | "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n", |
| 1058 | gpio, get_label(gpio)); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1059 | local_irq_restore(flags); |
| 1060 | return -EBUSY; |
| 1061 | } |
| 1062 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1063 | reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1064 | |
| 1065 | local_irq_restore(flags); |
| 1066 | |
| 1067 | port_setup(gpio, GPIO_USAGE); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1068 | set_label(gpio, label); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1069 | |
| 1070 | return 0; |
| 1071 | } |
| 1072 | EXPORT_SYMBOL(gpio_request); |
| 1073 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1074 | void gpio_free(unsigned gpio) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1075 | { |
| 1076 | unsigned long flags; |
| 1077 | |
| 1078 | if (check_gpio(gpio) < 0) |
| 1079 | return; |
| 1080 | |
| 1081 | local_irq_save(flags); |
| 1082 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1083 | if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1084 | dump_stack(); |
Mike Frysinger | f85c4ab | 2008-03-26 08:34:23 +0800 | [diff] [blame] | 1085 | gpio_error(gpio); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1086 | local_irq_restore(flags); |
| 1087 | return; |
| 1088 | } |
| 1089 | |
Michael Hennerich | c58c214 | 2007-10-04 00:35:05 +0800 | [diff] [blame] | 1090 | reserved_gpio_map[gpio_bank(gpio)] &= ~gpio_bit(gpio); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1091 | |
Michael Hennerich | 2acde90 | 2007-10-11 00:24:40 +0800 | [diff] [blame] | 1092 | set_label(gpio, "free"); |
| 1093 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1094 | local_irq_restore(flags); |
| 1095 | } |
| 1096 | EXPORT_SYMBOL(gpio_free); |
| 1097 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1098 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1099 | #ifdef BF548_FAMILY |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1100 | int gpio_direction_input(unsigned gpio) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1101 | { |
| 1102 | unsigned long flags; |
| 1103 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1104 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
| 1105 | gpio_error(gpio); |
| 1106 | return -EINVAL; |
| 1107 | } |
| 1108 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1109 | local_irq_save(flags); |
| 1110 | gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); |
| 1111 | gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); |
| 1112 | local_irq_restore(flags); |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1113 | |
| 1114 | return 0; |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1115 | } |
| 1116 | EXPORT_SYMBOL(gpio_direction_input); |
| 1117 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1118 | int gpio_direction_output(unsigned gpio, int value) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1119 | { |
| 1120 | unsigned long flags; |
| 1121 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1122 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
| 1123 | gpio_error(gpio); |
| 1124 | return -EINVAL; |
| 1125 | } |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1126 | |
| 1127 | local_irq_save(flags); |
| 1128 | gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio); |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1129 | gpio_set_value(gpio, value); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1130 | gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio); |
| 1131 | local_irq_restore(flags); |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1132 | |
| 1133 | return 0; |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1134 | } |
| 1135 | EXPORT_SYMBOL(gpio_direction_output); |
| 1136 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1137 | void gpio_set_value(unsigned gpio, int arg) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1138 | { |
| 1139 | if (arg) |
| 1140 | gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); |
| 1141 | else |
| 1142 | gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio); |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1143 | } |
| 1144 | EXPORT_SYMBOL(gpio_set_value); |
| 1145 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1146 | int gpio_get_value(unsigned gpio) |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1147 | { |
| 1148 | return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio))); |
| 1149 | } |
| 1150 | EXPORT_SYMBOL(gpio_get_value); |
| 1151 | |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 1152 | void bfin_gpio_irq_prepare(unsigned gpio) |
| 1153 | { |
| 1154 | unsigned long flags; |
| 1155 | |
| 1156 | port_setup(gpio, GPIO_USAGE); |
| 1157 | |
| 1158 | local_irq_save(flags); |
| 1159 | gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); |
| 1160 | gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); |
| 1161 | local_irq_restore(flags); |
| 1162 | } |
| 1163 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1164 | #else |
| 1165 | |
Michael Hennerich | 803a8d2 | 2008-05-17 16:01:51 +0800 | [diff] [blame] | 1166 | int gpio_get_value(unsigned gpio) |
| 1167 | { |
| 1168 | unsigned long flags; |
| 1169 | int ret; |
| 1170 | |
| 1171 | if (unlikely(get_gpio_edge(gpio))) { |
| 1172 | local_irq_save(flags); |
| 1173 | set_gpio_edge(gpio, 0); |
| 1174 | ret = get_gpio_data(gpio); |
| 1175 | set_gpio_edge(gpio, 1); |
| 1176 | local_irq_restore(flags); |
| 1177 | |
| 1178 | return ret; |
| 1179 | } else |
| 1180 | return get_gpio_data(gpio); |
| 1181 | } |
| 1182 | EXPORT_SYMBOL(gpio_get_value); |
| 1183 | |
| 1184 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1185 | int gpio_direction_input(unsigned gpio) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1186 | { |
| 1187 | unsigned long flags; |
| 1188 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1189 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
| 1190 | gpio_error(gpio); |
| 1191 | return -EINVAL; |
| 1192 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1193 | |
| 1194 | local_irq_save(flags); |
| 1195 | gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio); |
| 1196 | gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio); |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 1197 | AWA_DUMMY_READ(inen); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1198 | local_irq_restore(flags); |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1199 | |
| 1200 | return 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1201 | } |
| 1202 | EXPORT_SYMBOL(gpio_direction_input); |
| 1203 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1204 | int gpio_direction_output(unsigned gpio, int value) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1205 | { |
| 1206 | unsigned long flags; |
| 1207 | |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1208 | if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { |
| 1209 | gpio_error(gpio); |
| 1210 | return -EINVAL; |
| 1211 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1212 | |
| 1213 | local_irq_save(flags); |
| 1214 | gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 1215 | |
| 1216 | if (value) |
| 1217 | gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); |
| 1218 | else |
| 1219 | gpio_bankb[gpio_bank(gpio)]->data_clear = gpio_bit(gpio); |
| 1220 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1221 | gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio); |
Michael Hennerich | 2b39331 | 2007-10-10 16:58:49 +0800 | [diff] [blame] | 1222 | AWA_DUMMY_READ(dir); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1223 | local_irq_restore(flags); |
Michael Hennerich | acbcd26 | 2008-01-22 18:36:20 +0800 | [diff] [blame] | 1224 | |
| 1225 | return 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1226 | } |
| 1227 | EXPORT_SYMBOL(gpio_direction_output); |
Mike Frysinger | 168f121 | 2007-10-11 00:22:35 +0800 | [diff] [blame] | 1228 | |
| 1229 | /* If we are booting from SPI and our board lacks a strong enough pull up, |
| 1230 | * the core can reset and execute the bootrom faster than the resistor can |
| 1231 | * pull the signal logically high. To work around this (common) error in |
| 1232 | * board design, we explicitly set the pin back to GPIO mode, force /CS |
| 1233 | * high, and wait for the electrons to do their thing. |
| 1234 | * |
| 1235 | * This function only makes sense to be called from reset code, but it |
| 1236 | * lives here as we need to force all the GPIO states w/out going through |
| 1237 | * BUG() checks and such. |
| 1238 | */ |
| 1239 | void bfin_gpio_reset_spi0_ssel1(void) |
| 1240 | { |
Michael Hennerich | 4d5f4ed | 2007-08-27 16:46:17 +0800 | [diff] [blame] | 1241 | u16 gpio = P_IDENT(P_SPI0_SSEL1); |
| 1242 | |
| 1243 | port_setup(gpio, GPIO_USAGE); |
| 1244 | gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); |
Michael Hennerich | a2c8cfe | 2008-01-22 17:20:10 +0800 | [diff] [blame] | 1245 | AWA_DUMMY_READ(data_set); |
Mike Frysinger | 168f121 | 2007-10-11 00:22:35 +0800 | [diff] [blame] | 1246 | udelay(1); |
| 1247 | } |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1248 | |
Michael Hennerich | affee2b2 | 2008-04-24 08:10:10 +0800 | [diff] [blame] | 1249 | void bfin_gpio_irq_prepare(unsigned gpio) |
| 1250 | { |
| 1251 | port_setup(gpio, GPIO_USAGE); |
| 1252 | } |
| 1253 | |
Michael Hennerich | d2b11a4 | 2007-08-28 16:47:46 +0800 | [diff] [blame] | 1254 | #endif /*BF548_FAMILY */ |
Mike Frysinger | 1545a11 | 2007-12-24 16:54:48 +0800 | [diff] [blame] | 1255 | |
| 1256 | #if defined(CONFIG_PROC_FS) |
| 1257 | static int gpio_proc_read(char *buf, char **start, off_t offset, |
| 1258 | int len, int *unused_i, void *unused_v) |
| 1259 | { |
| 1260 | int c, outlen = 0; |
| 1261 | |
| 1262 | for (c = 0; c < MAX_RESOURCES; c++) { |
| 1263 | if (!check_gpio(c) && (reserved_gpio_map[gpio_bank(c)] & gpio_bit(c))) |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 1264 | len = sprintf(buf, "GPIO_%d: %s \t\tGPIO %s\n", c, |
Mike Frysinger | 1545a11 | 2007-12-24 16:54:48 +0800 | [diff] [blame] | 1265 | get_label(c), get_gpio_dir(c) ? "OUTPUT" : "INPUT"); |
| 1266 | else if (reserved_peri_map[gpio_bank(c)] & gpio_bit(c)) |
Michael Hennerich | fac3cf4 | 2007-12-24 20:07:03 +0800 | [diff] [blame] | 1267 | len = sprintf(buf, "GPIO_%d: %s \t\tPeripheral\n", c, get_label(c)); |
Mike Frysinger | 1545a11 | 2007-12-24 16:54:48 +0800 | [diff] [blame] | 1268 | else |
| 1269 | continue; |
| 1270 | buf += len; |
| 1271 | outlen += len; |
| 1272 | } |
| 1273 | return outlen; |
| 1274 | } |
| 1275 | |
| 1276 | static __init int gpio_register_proc(void) |
| 1277 | { |
| 1278 | struct proc_dir_entry *proc_gpio; |
| 1279 | |
| 1280 | proc_gpio = create_proc_entry("gpio", S_IRUGO, NULL); |
| 1281 | if (proc_gpio) |
| 1282 | proc_gpio->read_proc = gpio_proc_read; |
| 1283 | return proc_gpio != NULL; |
| 1284 | } |
Mike Frysinger | 1545a11 | 2007-12-24 16:54:48 +0800 | [diff] [blame] | 1285 | __initcall(gpio_register_proc); |
| 1286 | #endif |