diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2013-06-25 10:17:15 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-07-22 19:23:14 -0400 |
commit | eb6002d5e2eaf8b8c0ee11c8e47bbe7473b4c434 (patch) | |
tree | 34f41aa6aaedfc8392acd9c6cb8718ea1cee6cfa /Documentation/pinctrl.txt | |
parent | ad81f0545ef01ea651886dddac4bef6cec930092 (diff) |
pinctrl: elaborate a bit on arrangements in doc
This elaborates a bit on the pin control and pin muxing
logic vs GPIO arangements in the hardware.
Inspired by some drawings in a mail from Christian Ruppert.
Both arrangements are confirmed to exist in practice.
Cc: Rob Landley <rob@landley.net>
Reviewed-by: Christian Ruppert <christian.ruppert@abilis.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'Documentation/pinctrl.txt')
-rw-r--r-- | Documentation/pinctrl.txt | 91 |
1 files changed, 85 insertions, 6 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt index 052e13af2d38..d2d7fc05a8fd 100644 --- a/Documentation/pinctrl.txt +++ b/Documentation/pinctrl.txt | |||
@@ -795,18 +795,97 @@ special GPIO-handler is registered. | |||
795 | GPIO mode pitfalls | 795 | GPIO mode pitfalls |
796 | ================== | 796 | ================== |
797 | 797 | ||
798 | Sometime the developer may be confused by a datasheet talking about a pin | 798 | Due to the naming conventions used by hardware engineers, where "GPIO" |
799 | being possible to set into "GPIO mode". It appears that what hardware | 799 | is taken to mean different things than what the kernel does, the developer |
800 | engineers mean with "GPIO mode" is not necessarily the use case that is | 800 | may be confused by a datasheet talking about a pin being possible to set |
801 | implied in the kernel interface <linux/gpio.h>: a pin that you grab from | 801 | into "GPIO mode". It appears that what hardware engineers mean with |
802 | kernel code and then either listen for input or drive high/low to | 802 | "GPIO mode" is not necessarily the use case that is implied in the kernel |
803 | assert/deassert some external line. | 803 | interface <linux/gpio.h>: a pin that you grab from kernel code and then |
804 | either listen for input or drive high/low to assert/deassert some | ||
805 | external line. | ||
804 | 806 | ||
805 | Rather hardware engineers think that "GPIO mode" means that you can | 807 | Rather hardware engineers think that "GPIO mode" means that you can |
806 | software-control a few electrical properties of the pin that you would | 808 | software-control a few electrical properties of the pin that you would |
807 | not be able to control if the pin was in some other mode, such as muxed in | 809 | not be able to control if the pin was in some other mode, such as muxed in |
808 | for a device. | 810 | for a device. |
809 | 811 | ||
812 | The GPIO portions of a pin and its relation to a certain pin controller | ||
813 | configuration and muxing logic can be constructed in several ways. Here | ||
814 | are two examples: | ||
815 | |||
816 | (A) | ||
817 | pin config | ||
818 | logic regs | ||
819 | | +- SPI | ||
820 | Physical pins --- pad --- pinmux -+- I2C | ||
821 | | +- mmc | ||
822 | | +- GPIO | ||
823 | pin | ||
824 | multiplex | ||
825 | logic regs | ||
826 | |||
827 | Here some electrical properties of the pin can be configured no matter | ||
828 | whether the pin is used for GPIO or not. If you multiplex a GPIO onto a | ||
829 | pin, you can also drive it high/low from "GPIO" registers. | ||
830 | Alternatively, the pin can be controlled by a certain peripheral, while | ||
831 | still applying desired pin config properties. GPIO functionality is thus | ||
832 | orthogonal to any other device using the pin. | ||
833 | |||
834 | In this arrangement the registers for the GPIO portions of the pin controller, | ||
835 | or the registers for the GPIO hardware module are likely to reside in a | ||
836 | separate memory range only intended for GPIO driving, and the register | ||
837 | range dealing with pin config and pin multiplexing get placed into a | ||
838 | different memory range and a separate section of the data sheet. | ||
839 | |||
840 | (B) | ||
841 | |||
842 | pin config | ||
843 | logic regs | ||
844 | | +- SPI | ||
845 | Physical pins --- pad --- pinmux -+- I2C | ||
846 | | | +- mmc | ||
847 | | | | ||
848 | GPIO pin | ||
849 | multiplex | ||
850 | logic regs | ||
851 | |||
852 | In this arrangement, the GPIO functionality can always be enabled, such that | ||
853 | e.g. a GPIO input can be used to "spy" on the SPI/I2C/MMC signal while it is | ||
854 | pulsed out. It is likely possible to disrupt the traffic on the pin by doing | ||
855 | wrong things on the GPIO block, as it is never really disconnected. It is | ||
856 | possible that the GPIO, pin config and pin multiplex registers are placed into | ||
857 | the same memory range and the same section of the data sheet, although that | ||
858 | need not be the case. | ||
859 | |||
860 | From a kernel point of view, however, these are different aspects of the | ||
861 | hardware and shall be put into different subsystems: | ||
862 | |||
863 | - Registers (or fields within registers) that control electrical | ||
864 | properties of the pin such as biasing and drive strength should be | ||
865 | exposed through the pinctrl subsystem, as "pin configuration" settings. | ||
866 | |||
867 | - Registers (or fields within registers) that control muxing of signals | ||
868 | from various other HW blocks (e.g. I2C, MMC, or GPIO) onto pins should | ||
869 | be exposed through the pinctrl subssytem, as mux functions. | ||
870 | |||
871 | - Registers (or fields within registers) that control GPIO functionality | ||
872 | such as setting a GPIO's output value, reading a GPIO's input value, or | ||
873 | setting GPIO pin direction should be exposed through the GPIO subsystem, | ||
874 | and if they also support interrupt capabilities, through the irqchip | ||
875 | abstraction. | ||
876 | |||
877 | Depending on the exact HW register design, some functions exposed by the | ||
878 | GPIO subsystem may call into the pinctrl subsystem in order to | ||
879 | co-ordinate register settings across HW modules. In particular, this may | ||
880 | be needed for HW with separate GPIO and pin controller HW modules, where | ||
881 | e.g. GPIO direction is determined by a register in the pin controller HW | ||
882 | module rather than the GPIO HW module. | ||
883 | |||
884 | Electrical properties of the pin such as biasing and drive strength | ||
885 | may be placed at some pin-specific register in all cases or as part | ||
886 | of the GPIO register in case (B) especially. This doesn't mean that such | ||
887 | properties necessarily pertain to what the Linux kernel calls "GPIO". | ||
888 | |||
810 | Example: a pin is usually muxed in to be used as a UART TX line. But during | 889 | Example: a pin is usually muxed in to be used as a UART TX line. But during |
811 | system sleep, we need to put this pin into "GPIO mode" and ground it. | 890 | system sleep, we need to put this pin into "GPIO mode" and ground it. |
812 | 891 | ||