nyan: Use the new pinmux functions as part of UART setup.

The pins for the UART had been configured manually using hardcoded offsets and
values. Now that we have pinmux functions for that sort of thing, we should
use that instead. This also provides a very simple test for the pinmux code.

Ultimately this code should be wrapped in a function which handles setting up
any of the UARTs which is appropriately parameterized and which would be
called from the bootblock main instead of being in it, but for now this is
sufficient.

Old-Change-Id: I69e36fa5fc9b6f3f5ef7f1be3e9f18cdbfdd7fe9
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://chromium-review.googlesource.com/171807
Reviewed-by: Ronald Minnich <rminnich@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
(cherry picked from commit d29e655b68143e86199ab1d74f89e125b16b67cc)

tegra124: Call the set_avp_clock_to_clkm function in the bootblock.

We had a hardcoded version of the set_avp_clock_to_clkm function in the
bootblock, and we had to use it until now because the real version uses
udelay, and until now that hadn't been implemented. Also, replace the delay
loop in the hacky_hardcoded_uart_setup_function with a call to the real thing.

Old-Change-Id: I6df9421bcad484e0855c67649683d474d78e4883
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://chromium-review.googlesource.com/172045
Reviewed-by: Gabe Black <gabeblack@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
(cherry picked from commit 4c6dd4c7cade7d922a258e0371e43972bce77249)

Squashed two tegra124 bootblock related commits.

Change-Id: I0ce6321a04b11b7f1250ef3816fe46732777988d
Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com>
Reviewed-on: http://review.coreboot.org/6861
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
Gabe Black 2013-10-04 06:17:22 -07:00 committed by Isaac Christensen
parent dda0e66d9c
commit 58f3062580
1 changed files with 14 additions and 31 deletions

View File

@ -21,37 +21,13 @@
#include <arch/io.h> #include <arch/io.h>
#include <cbfs.h> #include <cbfs.h>
#include <console/console.h> #include <console/console.h>
#include <delay.h>
#include "clock.h"
#include "pinmux.h"
static void hacky_hardcoded_uart_setup_function(void) static void hacky_hardcoded_uart_setup_function(void)
{ {
int i;
/*
* On poweron, AVP clock source (also called system clock) is set to
* PLLP_out0 with frequency set at 1MHz. Before initializing PLLP, we
* need to move the system clock's source to CLK_M temporarily. And
* then switch it to PLLP_out4 (204MHz) at a later time.
*/
write32((0 << 12) | (0 << 8) | (0 << 4) | (0 << 0) | (2 << 28),
(void *)(0x60006000 + 0x28));
// wait a little bit (nominally 2-3 us)
for (i = 0; i < 0x10000; i++)
__asm__ __volatile__("");
// Set function.
setbits_le32((void *)(0x70000000 + 0x3000 + 0x2e0), 3 << 0);
setbits_le32((void *)(0x70000000 + 0x3000 + 0x2e4), 3 << 0);
// Output.
clrbits_le32((void *)(0x70000000 + 0x3000 + 0x2e0), 1 << 5);
// Input.
setbits_le32((void *)(0x70000000 + 0x3000 + 0x2e4), 1 << 5);
// Disable tristate.
clrbits_le32((void *)(0x70000000 + 0x3000 + 0x2e0), 1 << 4);
clrbits_le32((void *)(0x70000000 + 0x3000 + 0x2e4), 1 << 4);
// Assert UART reset and enable clock. // Assert UART reset and enable clock.
setbits_le32((void *)(0x60006000 + 4 + 0), 1 << 6); setbits_le32((void *)(0x60006000 + 4 + 0), 1 << 6);
@ -61,9 +37,7 @@ static void hacky_hardcoded_uart_setup_function(void)
// Set the clock source. // Set the clock source.
clrbits_le32((void *)(0x60006000 + 0x100 + 4 * 0x1e), 3 << 30); clrbits_le32((void *)(0x60006000 + 0x100 + 4 * 0x1e), 3 << 30);
// wait a little bit (nominally 2us?) udelay(2);
for (i = 0; i < 0x10000; i++)
__asm__ __volatile__("");
// De-assert reset to UART. // De-assert reset to UART.
clrbits_le32((void *)(0x60006000 + 4 + 0), 1 << 6); clrbits_le32((void *)(0x60006000 + 4 + 0), 1 << 6);
@ -73,8 +47,17 @@ void main(void)
{ {
void *entry; void *entry;
set_avp_clock_to_clkm();
hacky_hardcoded_uart_setup_function(); hacky_hardcoded_uart_setup_function();
// Serial out, tristate off.
pinmux_set_config(PINMUX_KB_ROW9_INDEX, PINMUX_KB_ROW9_FUNC_UA3);
// Serial in, tristate_on.
pinmux_set_config(PINMUX_KB_ROW10_INDEX, PINMUX_KB_ROW10_FUNC_UA3 |
PINMUX_TRISTATE |
PINMUX_INPUT_ENABLE);
if (CONFIG_BOOTBLOCK_CONSOLE) if (CONFIG_BOOTBLOCK_CONSOLE)
console_init(); console_init();