Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010,2011 |
| 3 | * NVIDIA Corporation <www.nvidia.com> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <asm/io.h> |
Simon Glass | f9f3e1b | 2012-04-02 13:18:46 +0000 | [diff] [blame] | 26 | #include <asm/arch/ap20.h> |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 27 | #include <asm/arch/clock.h> |
| 28 | #include <asm/arch/funcmux.h> |
Simon Glass | f9f3e1b | 2012-04-02 13:18:46 +0000 | [diff] [blame] | 29 | #include <asm/arch/pmc.h> |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 30 | #include <asm/arch/sys_proto.h> |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 31 | #include <asm/arch/tegra20.h> |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 35 | enum { |
| 36 | /* UARTs which we can enable */ |
| 37 | UARTA = 1 << 0, |
| 38 | UARTB = 1 << 1, |
| 39 | UARTD = 1 << 3, |
| 40 | UART_COUNT = 4, |
| 41 | }; |
| 42 | |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 43 | /* |
| 44 | * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0, |
| 45 | * so we are using this value to identify memory size. |
| 46 | */ |
| 47 | |
| 48 | unsigned int query_sdram_size(void) |
| 49 | { |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 50 | struct pmc_ctlr *const pmc = (struct pmc_ctlr *)TEGRA20_PMC_BASE; |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 51 | u32 reg; |
| 52 | |
| 53 | reg = readl(&pmc->pmc_scratch20); |
Marek Vasut | 4a34af7 | 2011-10-24 23:41:39 +0000 | [diff] [blame] | 54 | debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg); |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 55 | |
| 56 | /* bits 31:28 in OdmData are used for RAM size */ |
| 57 | switch ((reg) >> 28) { |
| 58 | case 1: |
| 59 | return 0x10000000; /* 256 MB */ |
| 60 | case 2: |
Stephen Warren | 9057e65 | 2012-01-06 12:14:41 +0000 | [diff] [blame] | 61 | default: |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 62 | return 0x20000000; /* 512 MB */ |
| 63 | case 3: |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 64 | return 0x40000000; /* 1GB */ |
| 65 | } |
| 66 | } |
| 67 | |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 68 | int dram_init(void) |
| 69 | { |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 70 | /* We do not initialise DRAM here. We just query the size */ |
Simon Glass | 7f8c070 | 2011-11-05 03:56:57 +0000 | [diff] [blame] | 71 | gd->ram_size = query_sdram_size(); |
Tom Warren | 3f82b1d | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 76 | int checkboard(void) |
| 77 | { |
| 78 | printf("Board: %s\n", sysinfo.board_string); |
| 79 | return 0; |
| 80 | } |
| 81 | #endif /* CONFIG_DISPLAY_BOARDINFO */ |
Simon Glass | e43d6ed | 2011-11-05 03:56:49 +0000 | [diff] [blame] | 82 | |
| 83 | #ifdef CONFIG_ARCH_CPU_INIT |
| 84 | /* |
| 85 | * Note this function is executed by the ARM7TDMI AVP. It does not return |
| 86 | * in this case. It is also called once the A9 starts up, but does nothing in |
| 87 | * that case. |
| 88 | */ |
| 89 | int arch_cpu_init(void) |
| 90 | { |
| 91 | /* Fire up the Cortex A9 */ |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 92 | tegra20_start(); |
Simon Glass | ccdd6ea | 2011-11-28 15:04:35 +0000 | [diff] [blame] | 93 | |
| 94 | /* We didn't do this init in start.S, so do it now */ |
| 95 | cpu_init_cp15(); |
| 96 | |
Simon Glass | 905ed41 | 2011-11-28 15:04:36 +0000 | [diff] [blame] | 97 | /* Initialize essential common plls */ |
| 98 | clock_early_init(); |
| 99 | |
Simon Glass | e43d6ed | 2011-11-05 03:56:49 +0000 | [diff] [blame] | 100 | return 0; |
| 101 | } |
| 102 | #endif |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 103 | |
Stephen Warren | b9607e7 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 104 | static int uart_configs[] = { |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 105 | #if defined(CONFIG_TEGRA20_UARTA_UAA_UAB) |
Stephen Warren | b9607e7 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 106 | FUNCMUX_UART1_UAA_UAB, |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 107 | #elif defined(CONFIG_TEGRA20_UARTA_GPU) |
Stephen Warren | e21649b | 2012-05-16 05:59:59 +0000 | [diff] [blame] | 108 | FUNCMUX_UART1_GPU, |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 109 | #elif defined(CONFIG_TEGRA20_UARTA_SDIO1) |
Lucas Stach | a2cfe63 | 2012-05-16 08:21:02 +0000 | [diff] [blame] | 110 | FUNCMUX_UART1_SDIO1, |
Stephen Warren | b9607e7 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 111 | #else |
| 112 | FUNCMUX_UART1_IRRX_IRTX, |
| 113 | #endif |
| 114 | FUNCMUX_UART2_IRDA, |
| 115 | -1, |
| 116 | FUNCMUX_UART4_GMC, |
| 117 | -1, |
| 118 | }; |
| 119 | |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 120 | /** |
| 121 | * Set up the specified uarts |
| 122 | * |
| 123 | * @param uarts_ids Mask containing UARTs to init (UARTx) |
| 124 | */ |
| 125 | static void setup_uarts(int uart_ids) |
| 126 | { |
| 127 | static enum periph_id id_for_uart[] = { |
| 128 | PERIPH_ID_UART1, |
| 129 | PERIPH_ID_UART2, |
| 130 | PERIPH_ID_UART3, |
| 131 | PERIPH_ID_UART4, |
| 132 | }; |
| 133 | size_t i; |
| 134 | |
| 135 | for (i = 0; i < UART_COUNT; i++) { |
| 136 | if (uart_ids & (1 << i)) { |
| 137 | enum periph_id id = id_for_uart[i]; |
| 138 | |
Stephen Warren | b9607e7 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 139 | funcmux_select(id, uart_configs[i]); |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 140 | clock_ll_start_uart(id); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | void board_init_uart_f(void) |
| 146 | { |
| 147 | int uart_ids = 0; /* bit mask of which UART ids to enable */ |
| 148 | |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 149 | #ifdef CONFIG_TEGRA20_ENABLE_UARTA |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 150 | uart_ids |= UARTA; |
| 151 | #endif |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 152 | #ifdef CONFIG_TEGRA20_ENABLE_UARTB |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 153 | uart_ids |= UARTB; |
| 154 | #endif |
Allen Martin | 00a2749 | 2012-08-31 08:30:00 +0000 | [diff] [blame] | 155 | #ifdef CONFIG_TEGRA20_ENABLE_UARTD |
Simon Glass | bb6997f | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 156 | uart_ids |= UARTD; |
| 157 | #endif |
| 158 | setup_uarts(uart_ids); |
| 159 | } |
Simon Glass | bd29cb0 | 2012-01-09 13:22:15 +0000 | [diff] [blame] | 160 | |
| 161 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 162 | void enable_caches(void) |
| 163 | { |
| 164 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 165 | dcache_enable(); |
| 166 | } |
| 167 | #endif |