ARM: tegra: uncompress.h: Choose a UART at runtime
authorStephen Warren <swarren@nvidia.com>
Fri, 6 Jan 2012 10:43:21 +0000 (10:43 +0000)
committerOlof Johansson <olof@lixom.net>
Tue, 7 Feb 2012 02:25:00 +0000 (18:25 -0800)
commitfe2639892cb618d5c42ea4570feea8dc497d0487
tree8d545ebb7ab0c39aa24ca1963a103e918c49e8ec
parent31bac1375bda9787f18b2f60e0e1ca62258ea09c
ARM: tegra: uncompress.h: Choose a UART at runtime

With this change we automatically detect which UART to use for
for printing during decompression. The detection involves coordination
with the bootloader: it's expected that the bootloader will leave a
'D' (for [D]ebug) in the UART scratchpad register for whichever UART we
should use for debugging.

If we don't find any such UART, we fall back to the UART that was
specified during config time: CONFIG_TEGRA_DEBUG_UART_XXX.

As a side effect of this change, uncompress debug messages will work
if you've specified CONFIG_TEGRA_DEBUG_UART_NONE, provided the
bootloader obeys the protocol.

This change is in line with what is documented in
Documentation/arm/Booting.

Other approaches considered:
* Hardcode based on machine ID (as many other ARM boards do).
  OK, but nice to not have yet another place to add per-board
  code. Better to have bootloader parse device tree and pass us
  this info.
* Check for TXE bit (like SA1110). Nice (and doesn't require
  a bootloader change), but a little less explicit. Also: if
  bootloader (for some reason) uses another UART, it needs to
  remember to turn it off before jumping to the kernel or we may
  print to it. NOTE: adapting this patch to check TXE too would
  be easy if desired.

Signed-off-by: Doug Anderson <dianders@chromium.org>
[swarren: Added clock/reset condition checks]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Doug Anderson <dianders@chromium.org>
Acked-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Olof Johansson <olof@lixom.net>
arch/arm/mach-tegra/include/mach/uncompress.h