aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/pinctrl.txt
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2013-06-25 10:17:15 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-07-22 19:23:14 -0400
commiteb6002d5e2eaf8b8c0ee11c8e47bbe7473b4c434 (patch)
tree34f41aa6aaedfc8392acd9c6cb8718ea1cee6cfa /Documentation/pinctrl.txt
parentad81f0545ef01ea651886dddac4bef6cec930092 (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.txt91
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.
795GPIO mode pitfalls 795GPIO mode pitfalls
796================== 796==================
797 797
798Sometime the developer may be confused by a datasheet talking about a pin 798Due to the naming conventions used by hardware engineers, where "GPIO"
799being possible to set into "GPIO mode". It appears that what hardware 799is taken to mean different things than what the kernel does, the developer
800engineers mean with "GPIO mode" is not necessarily the use case that is 800may be confused by a datasheet talking about a pin being possible to set
801implied in the kernel interface <linux/gpio.h>: a pin that you grab from 801into "GPIO mode". It appears that what hardware engineers mean with
802kernel 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
803assert/deassert some external line. 803interface <linux/gpio.h>: a pin that you grab from kernel code and then
804either listen for input or drive high/low to assert/deassert some
805external line.
804 806
805Rather hardware engineers think that "GPIO mode" means that you can 807Rather hardware engineers think that "GPIO mode" means that you can
806software-control a few electrical properties of the pin that you would 808software-control a few electrical properties of the pin that you would
807not be able to control if the pin was in some other mode, such as muxed in 809not be able to control if the pin was in some other mode, such as muxed in
808for a device. 810for a device.
809 811
812The GPIO portions of a pin and its relation to a certain pin controller
813configuration and muxing logic can be constructed in several ways. Here
814are 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
827Here some electrical properties of the pin can be configured no matter
828whether the pin is used for GPIO or not. If you multiplex a GPIO onto a
829pin, you can also drive it high/low from "GPIO" registers.
830Alternatively, the pin can be controlled by a certain peripheral, while
831still applying desired pin config properties. GPIO functionality is thus
832orthogonal to any other device using the pin.
833
834In this arrangement the registers for the GPIO portions of the pin controller,
835or the registers for the GPIO hardware module are likely to reside in a
836separate memory range only intended for GPIO driving, and the register
837range dealing with pin config and pin multiplexing get placed into a
838different 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
852In this arrangement, the GPIO functionality can always be enabled, such that
853e.g. a GPIO input can be used to "spy" on the SPI/I2C/MMC signal while it is
854pulsed out. It is likely possible to disrupt the traffic on the pin by doing
855wrong things on the GPIO block, as it is never really disconnected. It is
856possible that the GPIO, pin config and pin multiplex registers are placed into
857the same memory range and the same section of the data sheet, although that
858need not be the case.
859
860From a kernel point of view, however, these are different aspects of the
861hardware 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
877Depending on the exact HW register design, some functions exposed by the
878GPIO subsystem may call into the pinctrl subsystem in order to
879co-ordinate register settings across HW modules. In particular, this may
880be needed for HW with separate GPIO and pin controller HW modules, where
881e.g. GPIO direction is determined by a register in the pin controller HW
882module rather than the GPIO HW module.
883
884Electrical properties of the pin such as biasing and drive strength
885may be placed at some pin-specific register in all cases or as part
886of the GPIO register in case (B) especially. This doesn't mean that such
887properties necessarily pertain to what the Linux kernel calls "GPIO".
888
810Example: a pin is usually muxed in to be used as a UART TX line. But during 889Example: a pin is usually muxed in to be used as a UART TX line. But during
811system sleep, we need to put this pin into "GPIO mode" and ground it. 890system sleep, we need to put this pin into "GPIO mode" and ground it.
812 891