diff options
-rw-r--r-- | Documentation/powerpc/booting-without-of.txt | 52 | ||||
-rw-r--r-- | arch/powerpc/Kconfig | 5 | ||||
-rw-r--r-- | include/asm-powerpc/gpio.h | 56 |
3 files changed, 113 insertions, 0 deletions
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt index 2aafda9254f0..528b4822f451 100644 --- a/Documentation/powerpc/booting-without-of.txt +++ b/Documentation/powerpc/booting-without-of.txt | |||
@@ -88,6 +88,10 @@ Table of Contents | |||
88 | 3) OpenPIC Interrupt Controllers | 88 | 3) OpenPIC Interrupt Controllers |
89 | 4) ISA Interrupt Controllers | 89 | 4) ISA Interrupt Controllers |
90 | 90 | ||
91 | VIII - Specifying GPIO information for devices | ||
92 | 1) gpios property | ||
93 | 2) gpio-controller nodes | ||
94 | |||
91 | Appendix A - Sample SOC node for MPC8540 | 95 | Appendix A - Sample SOC node for MPC8540 |
92 | 96 | ||
93 | 97 | ||
@@ -3431,6 +3435,54 @@ encodings listed below: | |||
3431 | 2 = high to low edge sensitive type enabled | 3435 | 2 = high to low edge sensitive type enabled |
3432 | 3 = low to high edge sensitive type enabled | 3436 | 3 = low to high edge sensitive type enabled |
3433 | 3437 | ||
3438 | VIII - Specifying GPIO information for devices | ||
3439 | ============================================== | ||
3440 | |||
3441 | 1) gpios property | ||
3442 | ----------------- | ||
3443 | |||
3444 | Nodes that makes use of GPIOs should define them using `gpios' property, | ||
3445 | format of which is: <&gpio-controller1-phandle gpio1-specifier | ||
3446 | &gpio-controller2-phandle gpio2-specifier | ||
3447 | 0 /* holes are permitted, means no GPIO 3 */ | ||
3448 | &gpio-controller4-phandle gpio4-specifier | ||
3449 | ...>; | ||
3450 | |||
3451 | Note that gpio-specifier length is controller dependent. | ||
3452 | |||
3453 | gpio-specifier may encode: bank, pin position inside the bank, | ||
3454 | whether pin is open-drain and whether pin is logically inverted. | ||
3455 | |||
3456 | Example of the node using GPIOs: | ||
3457 | |||
3458 | node { | ||
3459 | gpios = <&qe_pio_e 18 0>; | ||
3460 | }; | ||
3461 | |||
3462 | In this example gpio-specifier is "18 0" and encodes GPIO pin number, | ||
3463 | and empty GPIO flags as accepted by the "qe_pio_e" gpio-controller. | ||
3464 | |||
3465 | 2) gpio-controller nodes | ||
3466 | ------------------------ | ||
3467 | |||
3468 | Every GPIO controller node must have #gpio-cells property defined, | ||
3469 | this information will be used to translate gpio-specifiers. | ||
3470 | |||
3471 | Example of two SOC GPIO banks defined as gpio-controller nodes: | ||
3472 | |||
3473 | qe_pio_a: gpio-controller@1400 { | ||
3474 | #gpio-cells = <2>; | ||
3475 | compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank"; | ||
3476 | reg = <0x1400 0x18>; | ||
3477 | gpio-controller; | ||
3478 | }; | ||
3479 | |||
3480 | qe_pio_e: gpio-controller@1460 { | ||
3481 | #gpio-cells = <2>; | ||
3482 | compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank"; | ||
3483 | reg = <0x1460 0x18>; | ||
3484 | gpio-controller; | ||
3485 | }; | ||
3434 | 3486 | ||
3435 | Appendix A - Sample SOC node for MPC8540 | 3487 | Appendix A - Sample SOC node for MPC8540 |
3436 | ======================================== | 3488 | ======================================== |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 1d4d19f6d6e1..c51b6bba5fce 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -81,6 +81,11 @@ config GENERIC_FIND_NEXT_BIT | |||
81 | bool | 81 | bool |
82 | default y | 82 | default y |
83 | 83 | ||
84 | config GENERIC_GPIO | ||
85 | bool | ||
86 | help | ||
87 | Generic GPIO API support | ||
88 | |||
84 | config ARCH_NO_VIRT_TO_BUS | 89 | config ARCH_NO_VIRT_TO_BUS |
85 | def_bool PPC64 | 90 | def_bool PPC64 |
86 | 91 | ||
diff --git a/include/asm-powerpc/gpio.h b/include/asm-powerpc/gpio.h new file mode 100644 index 000000000000..77ad3a890f30 --- /dev/null +++ b/include/asm-powerpc/gpio.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Generic GPIO API implementation for PowerPC. | ||
3 | * | ||
4 | * Copyright (c) 2007-2008 MontaVista Software, Inc. | ||
5 | * | ||
6 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef __ASM_POWERPC_GPIO_H | ||
15 | #define __ASM_POWERPC_GPIO_H | ||
16 | |||
17 | #include <linux/errno.h> | ||
18 | #include <asm-generic/gpio.h> | ||
19 | |||
20 | #ifdef CONFIG_HAVE_GPIO_LIB | ||
21 | |||
22 | /* | ||
23 | * We don't (yet) implement inlined/rapid versions for on-chip gpios. | ||
24 | * Just call gpiolib. | ||
25 | */ | ||
26 | static inline int gpio_get_value(unsigned int gpio) | ||
27 | { | ||
28 | return __gpio_get_value(gpio); | ||
29 | } | ||
30 | |||
31 | static inline void gpio_set_value(unsigned int gpio, int value) | ||
32 | { | ||
33 | __gpio_set_value(gpio, value); | ||
34 | } | ||
35 | |||
36 | static inline int gpio_cansleep(unsigned int gpio) | ||
37 | { | ||
38 | return __gpio_cansleep(gpio); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * Not implemented, yet. | ||
43 | */ | ||
44 | static inline int gpio_to_irq(unsigned int gpio) | ||
45 | { | ||
46 | return -ENOSYS; | ||
47 | } | ||
48 | |||
49 | static inline int irq_to_gpio(unsigned int irq) | ||
50 | { | ||
51 | return -EINVAL; | ||
52 | } | ||
53 | |||
54 | #endif /* CONFIG_HAVE_GPIO_LIB */ | ||
55 | |||
56 | #endif /* __ASM_POWERPC_GPIO_H */ | ||