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
92 #define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE)
144 #define PERIPHERAL_USAGE 1
147 #if defined(BF518_FAMILY)
148 #define MAX_BLACKFIN_GPIOS 40
191 #define PORT_F GPIO_PF0
192 #define PORT_G GPIO_PG0
193 #define PORT_H GPIO_PH0
199 #define MAX_BLACKFIN_GPIOS 16
220 #if defined(BF538_FAMILY)
222 * For now only support PORTF GPIOs.
223 * PORT C,D and E are for peripheral usage only
225 #define MAX_BLACKFIN_GPIOS 16
227 #define GPIO_PF0 0 /* PF */
243 #define GPIO_PC0 16 /* PC */
251 #define GPIO_PD0 32 /* PD */
265 #define GPIO_PE0 48 /* PE */
282 #define PORT_F GPIO_PF0
283 #define PORT_C GPIO_PC0
284 #define PORT_D GPIO_PD0
285 #define PORT_E GPIO_PE0
288 #if defined(BF527_FAMILY) || defined(BF537_FAMILY)
289 #define MAX_BLACKFIN_GPIOS 48
340 #define PORT_F GPIO_PF0
341 #define PORT_G GPIO_PG0
342 #define PORT_H GPIO_PH0
347 #include <mach/gpio.h>
351 #define MAX_BLACKFIN_GPIOS 48
402 #define PORT_FIO0 GPIO_0
403 #define PORT_FIO1 GPIO_16
404 #define PORT_FIO2 GPIO_32
409 /***********************************************************
411 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
414 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
417 * DESCRIPTION: These functions abstract direct register access
418 * to Blackfin processor General Purpose
421 * CAUTION: These functions do not belong to the GPIO Driver API
422 *************************************************************
423 * MODIFICATION HISTORY :
424 **************************************************************/
427 void set_gpio_dir(unsigned, unsigned short);
428 void set_gpio_inen(unsigned, unsigned short);
429 void set_gpio_polar(unsigned, unsigned short);
430 void set_gpio_edge(unsigned, unsigned short);
431 void set_gpio_both(unsigned, unsigned short);
432 void set_gpio_data(unsigned, unsigned short);
433 void set_gpio_maska(unsigned, unsigned short);
434 void set_gpio_maskb(unsigned, unsigned short);
435 void set_gpio_toggle(unsigned);
436 void set_gpiop_dir(unsigned, unsigned short);
437 void set_gpiop_inen(unsigned, unsigned short);
438 void set_gpiop_polar(unsigned, unsigned short);
439 void set_gpiop_edge(unsigned, unsigned short);
440 void set_gpiop_both(unsigned, unsigned short);
441 void set_gpiop_data(unsigned, unsigned short);
442 void set_gpiop_maska(unsigned, unsigned short);
443 void set_gpiop_maskb(unsigned, unsigned short);
444 unsigned short get_gpio_dir(unsigned);
445 unsigned short get_gpio_inen(unsigned);
446 unsigned short get_gpio_polar(unsigned);
447 unsigned short get_gpio_edge(unsigned);
448 unsigned short get_gpio_both(unsigned);
449 unsigned short get_gpio_maska(unsigned);
450 unsigned short get_gpio_maskb(unsigned);
451 unsigned short get_gpio_data(unsigned);
452 unsigned short get_gpiop_dir(unsigned);
453 unsigned short get_gpiop_inen(unsigned);
454 unsigned short get_gpiop_polar(unsigned);
455 unsigned short get_gpiop_edge(unsigned);
456 unsigned short get_gpiop_both(unsigned);
457 unsigned short get_gpiop_maska(unsigned);
458 unsigned short get_gpiop_maskb(unsigned);
459 unsigned short get_gpiop_data(unsigned);
463 unsigned short dummy1;
464 unsigned short data_clear;
465 unsigned short dummy2;
466 unsigned short data_set;
467 unsigned short dummy3;
468 unsigned short toggle;
469 unsigned short dummy4;
470 unsigned short maska;
471 unsigned short dummy5;
472 unsigned short maska_clear;
473 unsigned short dummy6;
474 unsigned short maska_set;
475 unsigned short dummy7;
476 unsigned short maska_toggle;
477 unsigned short dummy8;
478 unsigned short maskb;
479 unsigned short dummy9;
480 unsigned short maskb_clear;
481 unsigned short dummy10;
482 unsigned short maskb_set;
483 unsigned short dummy11;
484 unsigned short maskb_toggle;
485 unsigned short dummy12;
487 unsigned short dummy13;
488 unsigned short polar;
489 unsigned short dummy14;
491 unsigned short dummy15;
493 unsigned short dummy16;
500 unsigned int bfin_pm_standby_setup(void);
501 void bfin_pm_standby_restore(void);
503 void bfin_gpio_pm_hibernate_restore(void);
504 void bfin_gpio_pm_hibernate_suspend(void);
507 #define PM_WAKE_RISING 0x1
508 #define PM_WAKE_FALLING 0x2
509 #define PM_WAKE_HIGH 0x4
510 #define PM_WAKE_LOW 0x8
511 #define PM_WAKE_BOTH_EDGES (PM_WAKE_RISING | PM_WAKE_FALLING)
512 #define PM_WAKE_IGNORE 0xF0
514 int gpio_pm_wakeup_request(unsigned gpio, unsigned char type);
515 void gpio_pm_wakeup_free(unsigned gpio);
519 unsigned short maska;
520 unsigned short maskb;
522 unsigned short polar;
528 unsigned short reserved;
531 #endif /*CONFIG_BF54x*/
533 /***********************************************************
535 * FUNCTIONS: Blackfin GPIO Driver
538 * gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
541 * DESCRIPTION: Blackfin GPIO Driver API
544 *************************************************************
545 * MODIFICATION HISTORY :
546 **************************************************************/
549 int bfin_gpio_request(unsigned gpio, const char *label);
550 void bfin_gpio_free(unsigned gpio);
551 int bfin_gpio_direction_input(unsigned gpio);
552 int bfin_gpio_direction_output(unsigned gpio, int value);
553 int bfin_gpio_get_value(unsigned gpio);
554 void bfin_gpio_set_value(unsigned gpio, int value);
557 #define bfin_gpio_set_value(gpio, value) set_gpio_data(gpio, value)
560 #ifdef CONFIG_GPIOLIB
561 #include <asm-generic/gpio.h> /* cansleep wrappers */
563 static inline int gpio_get_value(unsigned int gpio)
565 if (gpio < MAX_BLACKFIN_GPIOS)
566 return bfin_gpio_get_value(gpio);
568 return __gpio_get_value(gpio);
571 static inline void gpio_set_value(unsigned int gpio, int value)
573 if (gpio < MAX_BLACKFIN_GPIOS)
574 bfin_gpio_set_value(gpio, value);
576 __gpio_set_value(gpio, value);
579 static inline int gpio_cansleep(unsigned int gpio)
581 return __gpio_cansleep(gpio);
584 #else /* !CONFIG_GPIOLIB */
586 static inline int gpio_request(unsigned gpio, const char *label)
588 return bfin_gpio_request(gpio, label);
591 static inline void gpio_free(unsigned gpio)
593 return bfin_gpio_free(gpio);
596 static inline int gpio_direction_input(unsigned gpio)
598 return bfin_gpio_direction_input(gpio);
601 static inline int gpio_direction_output(unsigned gpio, int value)
603 return bfin_gpio_direction_output(gpio, value);
606 static inline int gpio_get_value(unsigned gpio)
608 return bfin_gpio_get_value(gpio);
611 static inline void gpio_set_value(unsigned gpio, int value)
613 return bfin_gpio_set_value(gpio, value);
616 #include <asm-generic/gpio.h> /* cansleep wrappers */
617 #endif /* !CONFIG_GPIOLIB */
620 static inline int gpio_to_irq(unsigned gpio)
622 return (gpio + GPIO_IRQ_BASE);
625 static inline int irq_to_gpio(unsigned irq)
627 return (irq - GPIO_IRQ_BASE);
630 #endif /* __ASSEMBLY__ */
632 #endif /* __ARCH_BLACKFIN_GPIO_H__ */