Tom Warren | 41b6838 | 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 | 96b7c43 | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 26 | #include <asm/arch/clock.h> |
| 27 | #include <asm/arch/funcmux.h> |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 28 | #include <asm/arch/tegra.h> |
Lucas Stach | e80f7ca | 2012-09-29 10:02:08 +0000 | [diff] [blame^] | 29 | #include <asm/arch-tegra/board.h> |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 30 | #include <asm/arch-tegra/pmc.h> |
| 31 | #include <asm/arch-tegra/sys_proto.h> |
| 32 | #include <asm/arch-tegra/warmboot.h> |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 33 | |
| 34 | DECLARE_GLOBAL_DATA_PTR; |
| 35 | |
Simon Glass | 96b7c43 | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 36 | enum { |
| 37 | /* UARTs which we can enable */ |
| 38 | UARTA = 1 << 0, |
| 39 | UARTB = 1 << 1, |
| 40 | UARTD = 1 << 3, |
| 41 | UART_COUNT = 4, |
| 42 | }; |
| 43 | |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 44 | /* |
| 45 | * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0, |
| 46 | * so we are using this value to identify memory size. |
| 47 | */ |
| 48 | |
| 49 | unsigned int query_sdram_size(void) |
| 50 | { |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 51 | struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE; |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 52 | u32 reg; |
| 53 | |
| 54 | reg = readl(&pmc->pmc_scratch20); |
Marek Vasut | 8148e11 | 2011-10-24 23:41:39 +0000 | [diff] [blame] | 55 | debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg); |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 56 | |
| 57 | /* bits 31:28 in OdmData are used for RAM size */ |
| 58 | switch ((reg) >> 28) { |
| 59 | case 1: |
| 60 | return 0x10000000; /* 256 MB */ |
| 61 | case 2: |
Stephen Warren | b60fa39 | 2012-01-06 12:14:41 +0000 | [diff] [blame] | 62 | default: |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 63 | return 0x20000000; /* 512 MB */ |
| 64 | case 3: |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 65 | return 0x40000000; /* 1GB */ |
| 66 | } |
| 67 | } |
| 68 | |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 69 | int dram_init(void) |
| 70 | { |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 71 | /* We do not initialise DRAM here. We just query the size */ |
Simon Glass | f6fcbbd | 2011-11-05 03:56:57 +0000 | [diff] [blame] | 72 | gd->ram_size = query_sdram_size(); |
Tom Warren | 41b6838 | 2011-01-27 10:58:05 +0000 | [diff] [blame] | 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 77 | int checkboard(void) |
| 78 | { |
| 79 | printf("Board: %s\n", sysinfo.board_string); |
| 80 | return 0; |
| 81 | } |
| 82 | #endif /* CONFIG_DISPLAY_BOARDINFO */ |
Simon Glass | 5f3a899 | 2011-11-05 03:56:49 +0000 | [diff] [blame] | 83 | |
Stephen Warren | 59f9010 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 84 | static int uart_configs[] = { |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 85 | #if defined(CONFIG_TEGRA_UARTA_UAA_UAB) |
Stephen Warren | 59f9010 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 86 | FUNCMUX_UART1_UAA_UAB, |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 87 | #elif defined(CONFIG_TEGRA_UARTA_GPU) |
Stephen Warren | e4c01a8 | 2012-05-16 05:59:59 +0000 | [diff] [blame] | 88 | FUNCMUX_UART1_GPU, |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 89 | #elif defined(CONFIG_TEGRA_UARTA_SDIO1) |
Lucas Stach | 4de6eec | 2012-05-16 08:21:02 +0000 | [diff] [blame] | 90 | FUNCMUX_UART1_SDIO1, |
Stephen Warren | 59f9010 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 91 | #else |
| 92 | FUNCMUX_UART1_IRRX_IRTX, |
| 93 | #endif |
| 94 | FUNCMUX_UART2_IRDA, |
| 95 | -1, |
| 96 | FUNCMUX_UART4_GMC, |
| 97 | -1, |
| 98 | }; |
| 99 | |
Simon Glass | 96b7c43 | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 100 | /** |
| 101 | * Set up the specified uarts |
| 102 | * |
| 103 | * @param uarts_ids Mask containing UARTs to init (UARTx) |
| 104 | */ |
| 105 | static void setup_uarts(int uart_ids) |
| 106 | { |
| 107 | static enum periph_id id_for_uart[] = { |
| 108 | PERIPH_ID_UART1, |
| 109 | PERIPH_ID_UART2, |
| 110 | PERIPH_ID_UART3, |
| 111 | PERIPH_ID_UART4, |
| 112 | }; |
| 113 | size_t i; |
| 114 | |
| 115 | for (i = 0; i < UART_COUNT; i++) { |
| 116 | if (uart_ids & (1 << i)) { |
| 117 | enum periph_id id = id_for_uart[i]; |
| 118 | |
Stephen Warren | 59f9010 | 2012-05-14 13:13:45 +0000 | [diff] [blame] | 119 | funcmux_select(id, uart_configs[i]); |
Simon Glass | 96b7c43 | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 120 | clock_ll_start_uart(id); |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | void board_init_uart_f(void) |
| 126 | { |
| 127 | int uart_ids = 0; /* bit mask of which UART ids to enable */ |
| 128 | |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 129 | #ifdef CONFIG_TEGRA_ENABLE_UARTA |
Simon Glass | 96b7c43 | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 130 | uart_ids |= UARTA; |
| 131 | #endif |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 132 | #ifdef CONFIG_TEGRA_ENABLE_UARTB |
Simon Glass | 96b7c43 | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 133 | uart_ids |= UARTB; |
| 134 | #endif |
Tom Warren | 22562a4 | 2012-09-04 17:00:24 -0700 | [diff] [blame] | 135 | #ifdef CONFIG_TEGRA_ENABLE_UARTD |
Simon Glass | 96b7c43 | 2011-11-28 15:04:39 +0000 | [diff] [blame] | 136 | uart_ids |= UARTD; |
| 137 | #endif |
| 138 | setup_uarts(uart_ids); |
| 139 | } |
Simon Glass | 410012f | 2012-01-09 13:22:15 +0000 | [diff] [blame] | 140 | |
| 141 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 142 | void enable_caches(void) |
| 143 | { |
| 144 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 145 | dcache_enable(); |
| 146 | } |
| 147 | #endif |