2 * File: arch/blackfin/kernel/bfin_gpio.h
4 * Author: Michael Hennerich (hennerich@blackfin.uclinux.org)
10 * Copyright 2004-2008 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
31 * Number BF537/6/4 BF561 BF533/2/1
44 * GPIO_10 PF10 PF10 PF10
45 * GPIO_11 PF11 PF11 PF11
46 * GPIO_12 PF12 PF12 PF12
47 * GPIO_13 PF13 PF13 PF13
48 * GPIO_14 PF14 PF14 PF14
49 * GPIO_15 PF15 PF15 PF15
84 #ifndef __ARCH_BLACKFIN_GPIO_H__
85 #define __ARCH_BLACKFIN_GPIO_H__
87 #define gpio_bank(x) ((x) >> 4)
88 #define gpio_bit(x) (1<<((x) & 0xF))
89 #define gpio_sub_n(x) ((x) & 0xF)
91 #define GPIO_BANKSIZE 16
143 #define PERIPHERAL_USAGE 1
147 #define MAX_BLACKFIN_GPIOS 16
168 #if defined(BF527_FAMILY) || defined(BF537_FAMILY)
169 #define MAX_BLACKFIN_GPIOS 48
220 #define PORT_F GPIO_PF0
221 #define PORT_G GPIO_PG0
222 #define PORT_H GPIO_PH0
227 #include <asm-blackfin/mach-bf548/gpio.h>
231 #define MAX_BLACKFIN_GPIOS 48
282 #define PORT_FIO0 GPIO_0
283 #define PORT_FIO1 GPIO_16
284 #define PORT_FIO2 GPIO_32
289 /***********************************************************
291 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
294 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
297 * DESCRIPTION: These functions abstract direct register access
298 * to Blackfin processor General Purpose
301 * CAUTION: These functions do not belong to the GPIO Driver API
302 *************************************************************
303 * MODIFICATION HISTORY :
304 **************************************************************/
307 void set_gpio_dir(unsigned, unsigned short);
308 void set_gpio_inen(unsigned, unsigned short);
309 void set_gpio_polar(unsigned, unsigned short);
310 void set_gpio_edge(unsigned, unsigned short);
311 void set_gpio_both(unsigned, unsigned short);
312 void set_gpio_data(unsigned, unsigned short);
313 void set_gpio_maska(unsigned, unsigned short);
314 void set_gpio_maskb(unsigned, unsigned short);
315 void set_gpio_toggle(unsigned);
316 void set_gpiop_dir(unsigned, unsigned short);
317 void set_gpiop_inen(unsigned, unsigned short);
318 void set_gpiop_polar(unsigned, unsigned short);
319 void set_gpiop_edge(unsigned, unsigned short);
320 void set_gpiop_both(unsigned, unsigned short);
321 void set_gpiop_data(unsigned, unsigned short);
322 void set_gpiop_maska(unsigned, unsigned short);
323 void set_gpiop_maskb(unsigned, unsigned short);
324 unsigned short get_gpio_dir(unsigned);
325 unsigned short get_gpio_inen(unsigned);
326 unsigned short get_gpio_polar(unsigned);
327 unsigned short get_gpio_edge(unsigned);
328 unsigned short get_gpio_both(unsigned);
329 unsigned short get_gpio_maska(unsigned);
330 unsigned short get_gpio_maskb(unsigned);
331 unsigned short get_gpio_data(unsigned);
332 unsigned short get_gpiop_dir(unsigned);
333 unsigned short get_gpiop_inen(unsigned);
334 unsigned short get_gpiop_polar(unsigned);
335 unsigned short get_gpiop_edge(unsigned);
336 unsigned short get_gpiop_both(unsigned);
337 unsigned short get_gpiop_maska(unsigned);
338 unsigned short get_gpiop_maskb(unsigned);
339 unsigned short get_gpiop_data(unsigned);
343 unsigned short dummy1
;
344 unsigned short data_clear
;
345 unsigned short dummy2
;
346 unsigned short data_set
;
347 unsigned short dummy3
;
348 unsigned short toggle
;
349 unsigned short dummy4
;
350 unsigned short maska
;
351 unsigned short dummy5
;
352 unsigned short maska_clear
;
353 unsigned short dummy6
;
354 unsigned short maska_set
;
355 unsigned short dummy7
;
356 unsigned short maska_toggle
;
357 unsigned short dummy8
;
358 unsigned short maskb
;
359 unsigned short dummy9
;
360 unsigned short maskb_clear
;
361 unsigned short dummy10
;
362 unsigned short maskb_set
;
363 unsigned short dummy11
;
364 unsigned short maskb_toggle
;
365 unsigned short dummy12
;
367 unsigned short dummy13
;
368 unsigned short polar
;
369 unsigned short dummy14
;
371 unsigned short dummy15
;
373 unsigned short dummy16
;
379 #define PM_WAKE_RISING 0x1
380 #define PM_WAKE_FALLING 0x2
381 #define PM_WAKE_HIGH 0x4
382 #define PM_WAKE_LOW 0x8
383 #define PM_WAKE_BOTH_EDGES (PM_WAKE_RISING | PM_WAKE_FALLING)
385 int gpio_pm_wakeup_request(unsigned gpio
, unsigned char type
);
386 void gpio_pm_wakeup_free(unsigned gpio
);
387 unsigned int gpio_pm_setup(void);
388 void gpio_pm_restore(void);
392 unsigned short data_clear
;
393 unsigned short data_set
;
394 unsigned short toggle
;
395 unsigned short maska
;
396 unsigned short maska_clear
;
397 unsigned short maska_set
;
398 unsigned short maska_toggle
;
399 unsigned short maskb
;
400 unsigned short maskb_clear
;
401 unsigned short maskb_set
;
402 unsigned short maskb_toggle
;
404 unsigned short polar
;
410 unsigned short reserved
;
414 /***********************************************************
416 * FUNCTIONS: Blackfin GPIO Driver
419 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
422 * DESCRIPTION: Blackfin GPIO Driver API
425 *************************************************************
426 * MODIFICATION HISTORY :
427 **************************************************************/
429 int gpio_request(unsigned, const char *);
430 void gpio_free(unsigned);
432 void gpio_set_value(unsigned gpio
, int arg
);
433 int gpio_get_value(unsigned gpio
);
436 #define gpio_get_value(gpio) get_gpio_data(gpio)
437 #define gpio_set_value(gpio, value) set_gpio_data(gpio, value)
440 int gpio_direction_input(unsigned gpio
);
441 int gpio_direction_output(unsigned gpio
, int value
);
443 #include <asm-generic/gpio.h> /* cansleep wrappers */
446 static inline int gpio_to_irq(unsigned gpio
)
448 return (gpio
+ GPIO_IRQ_BASE
);
451 static inline int irq_to_gpio(unsigned irq
)
453 return (irq
- GPIO_IRQ_BASE
);
456 #endif /* __ASSEMBLY__ */
458 #endif /* __ARCH_BLACKFIN_GPIO_H__ */