Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
Jimmy Zhang | b365530 | 2014-07-02 17:45:18 -0700 | [diff] [blame] | 16 | #include <assert.h> |
Julius Werner | 85620db | 2013-11-13 18:22:15 -0800 | [diff] [blame] | 17 | #include <arch/exception.h> |
Stefan Reinauer | a9bc3bf | 2015-07-09 00:18:03 +0200 | [diff] [blame] | 18 | #include <arch/stages.h> |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 19 | #include <bootblock_common.h> |
Gabe Black | 7f07475 | 2013-09-29 06:32:27 -0700 | [diff] [blame] | 20 | #include <cbfs.h> |
| 21 | #include <console/console.h> |
Aaron Durbin | 825a5a8 | 2015-03-20 16:42:17 -0500 | [diff] [blame] | 22 | #include <program_loading.h> |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 23 | #include <soc/clock.h> |
Jimmy Zhang | bf04eda | 2014-02-11 17:21:20 -0800 | [diff] [blame] | 24 | #include <soc/nvidia/tegra/apbmisc.h> |
Julius Werner | f0d21ff3 | 2014-10-20 13:24:14 -0700 | [diff] [blame] | 25 | #include <soc/pinmux.h> |
| 26 | #include <soc/power.h> |
Daisuke Nojiri | 1b05d88 | 2014-08-27 11:48:03 -0700 | [diff] [blame] | 27 | #include <vendorcode/google/chromeos/chromeos.h> |
Gabe Black | ca436cb | 2013-09-29 07:06:08 -0700 | [diff] [blame] | 28 | |
Aaron Durbin | 825a5a8 | 2015-03-20 16:42:17 -0500 | [diff] [blame] | 29 | static void run_next_stage(void *entry) |
| 30 | { |
| 31 | ASSERT(entry); |
| 32 | clock_cpu0_config(entry); |
| 33 | |
| 34 | power_enable_and_ungate_cpu(); |
| 35 | |
| 36 | /* Repair ram on cluster0 and cluster1 after CPU is powered on. */ |
| 37 | ram_repair(); |
| 38 | |
| 39 | clock_cpu0_remove_reset(); |
| 40 | |
| 41 | clock_halt_avp(); |
| 42 | } |
| 43 | |
Gabe Black | 7f07475 | 2013-09-29 06:32:27 -0700 | [diff] [blame] | 44 | void main(void) |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 45 | { |
Ken Chang | 41359bd | 2014-04-21 17:54:28 +0800 | [diff] [blame] | 46 | // enable pinmux clamp inputs |
| 47 | clamp_tristate_inputs(); |
| 48 | |
Jimmy Zhang | bf04eda | 2014-02-11 17:21:20 -0800 | [diff] [blame] | 49 | // enable JTAG at the earliest stage |
| 50 | enable_jtag(); |
| 51 | |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 52 | clock_early_uart(); |
Gabe Black | ca436cb | 2013-09-29 07:06:08 -0700 | [diff] [blame] | 53 | |
Gabe Black | 58f3062 | 2013-10-04 06:17:22 -0700 | [diff] [blame] | 54 | // Serial out, tristate off. |
| 55 | pinmux_set_config(PINMUX_KB_ROW9_INDEX, PINMUX_KB_ROW9_FUNC_UA3); |
| 56 | // Serial in, tristate_on. |
| 57 | pinmux_set_config(PINMUX_KB_ROW10_INDEX, PINMUX_KB_ROW10_FUNC_UA3 | |
Julius Werner | edf6b57 | 2013-10-25 17:49:26 -0700 | [diff] [blame] | 58 | PINMUX_PULL_UP | |
Gabe Black | 58f3062 | 2013-10-04 06:17:22 -0700 | [diff] [blame] | 59 | PINMUX_INPUT_ENABLE); |
Julius Werner | edf6b57 | 2013-10-25 17:49:26 -0700 | [diff] [blame] | 60 | // Mux some pins away from uart A. |
| 61 | pinmux_set_config(PINMUX_UART2_CTS_N_INDEX, |
| 62 | PINMUX_UART2_CTS_N_FUNC_UB3 | |
Julius Werner | edf6b57 | 2013-10-25 17:49:26 -0700 | [diff] [blame] | 63 | PINMUX_INPUT_ENABLE); |
| 64 | pinmux_set_config(PINMUX_UART2_RTS_N_INDEX, |
| 65 | PINMUX_UART2_RTS_N_FUNC_UB3); |
Gabe Black | 58f3062 | 2013-10-04 06:17:22 -0700 | [diff] [blame] | 66 | |
Julius Werner | 85620db | 2013-11-13 18:22:15 -0800 | [diff] [blame] | 67 | if (CONFIG_BOOTBLOCK_CONSOLE) { |
Gabe Black | 7f07475 | 2013-09-29 06:32:27 -0700 | [diff] [blame] | 68 | console_init(); |
Julius Werner | 85620db | 2013-11-13 18:22:15 -0800 | [diff] [blame] | 69 | exception_init(); |
| 70 | } |
Gabe Black | 7f07475 | 2013-09-29 06:32:27 -0700 | [diff] [blame] | 71 | |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 72 | clock_init(); |
| 73 | |
| 74 | bootblock_mainboard_init(); |
| 75 | |
| 76 | pinmux_set_config(PINMUX_CORE_PWR_REQ_INDEX, |
| 77 | PINMUX_CORE_PWR_REQ_FUNC_PWRON); |
| 78 | pinmux_set_config(PINMUX_CPU_PWR_REQ_INDEX, |
| 79 | PINMUX_CPU_PWR_REQ_FUNC_CPU); |
| 80 | pinmux_set_config(PINMUX_PWR_INT_N_INDEX, |
| 81 | PINMUX_PWR_INT_N_FUNC_PMICINTR | |
Gabe Black | d40be11 | 2013-10-09 23:45:07 -0700 | [diff] [blame] | 82 | PINMUX_INPUT_ENABLE); |
| 83 | |
Aaron Durbin | 825a5a8 | 2015-03-20 16:42:17 -0500 | [diff] [blame] | 84 | run_romstage(); |
| 85 | } |
Gabe Black | 7f07475 | 2013-09-29 06:32:27 -0700 | [diff] [blame] | 86 | |
Aaron Durbin | 825a5a8 | 2015-03-20 16:42:17 -0500 | [diff] [blame] | 87 | void platform_prog_run(struct prog *prog) |
| 88 | { |
| 89 | run_next_stage(prog_entry(prog)); |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 90 | } |