tegra124: Implement driver code for the pinmux, pingroup controls, and GPIOs

Hardware / Coreboot - Gabe Black [google.com] - 19 August 2014 15:46 UTC

The pins on tegra are controlled by three different units, the pinmux, the pin group controls, and the GPIO banks. Each of these units controls some aspect of the pins, and they layer together and interact in interesting ways.

By default, the GPIOs are configured to pass through the special purpose IO that the pinmux is configured to and so can be ignored unless a GPIO is needed. The pinmux controls which special purpose signal passes through, along with pull ups, downs, and whether the output is tristated. The pingroup controls change the parameters of a group of pins which all have to do with a related function unit.

The enum which holds constants related to the pinmux is relatively involved and may not be entirely complete or correct due to slightly inconsistent, incomplete, or missing documentation related to the pinmux. Considerable effort has been made to make it as accurate as possible. It includes a constant which is the index into the pinmux control registers for that pin, what each of the functions supported by that pin are, and which GPIO it corresponds to. The GPIO constant is named after the GPIO and is the pinmux register index for the pin for that GPIO. That way, when you need to turn on a GPIO, you can use that constant along with the pinmux manipulating functions to enable its tristate and pull up/down mode in addition to setting up the GPIO controls.

Also, while in general I prefer not to use macros or the preprocessor when writing C code, in this case the set of constants in the enums was too large and cumbersome to manage without them. Since they're being used to construct a table in a straightforward way, hopefully their negative aspects will be minimized.

In addition to the low level functions in each driver, the GPIO code also includes some high level functions to set up input or output GPIOs since that will probably be a very common thing to want to do.

Old-Change-Id: I48efa58d1b5520c0367043cef76b6d3a7a18530d

08d5a89 tegra124: Implement driver code for the pinmux, pingroup controls, and GPIOs.
src/soc/nvidia/tegra/gpio.c | 240 ++++++++++++++++++++
src/soc/nvidia/tegra/gpio.h | 63 ++++++
src/soc/nvidia/tegra/pingroup.c | 35 +++
src/soc/nvidia/tegra/pingroup.h | 43 ++++
src/soc/nvidia/tegra/pinmux.c | 35 +++
src/soc/nvidia/tegra/pinmux.h | 44 ++++
src/soc/nvidia/tegra124/Makefile.inc | 3 +
src/soc/nvidia/tegra124/gpio.h | 67 ++++++
src/soc/nvidia/tegra124/include/soc/addressmap.h | 2 +
src/soc/nvidia/tegra124/pingroup.h | 67 ++++++
src/soc/nvidia/tegra124/pinmux.h | 260 ++++++++++++++++++++++
11 files changed, 859 insertions(+)

Upstream: review.coreboot.org


  • Share