Tom Rix | e63e590 | 2009-10-17 12:41:06 -0500 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004-2009 |
| 3 | * Texas Instruments Incorporated, <www.ti.com> |
| 4 | * Richard Woodruff <r-woodruff2@ti.com> |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | #include <common.h> |
| 25 | #include <twl4030.h> |
| 26 | #include <asm/io.h> |
| 27 | #include <asm/arch/mux.h> |
| 28 | #include <asm/arch/mem.h> |
| 29 | #include <asm/arch/sys_proto.h> |
| 30 | #include <asm/mach-types.h> |
| 31 | #include "sdp.h" |
| 32 | |
| 33 | const omap3_sysinfo sysinfo = { |
| 34 | DDR_DISCRETE, |
| 35 | "OMAP3 SDP3430 board", |
| 36 | #if defined(CONFIG_ENV_IS_IN_ONENAND) |
| 37 | "OneNAND", |
| 38 | #elif defined(CONFIG_ENV_IS_IN_NAND) |
| 39 | "NAND", |
| 40 | #else |
| 41 | "NOR", |
| 42 | #endif |
| 43 | }; |
| 44 | |
| 45 | /* Timing definitions for GPMC controller for Sibley NOR */ |
| 46 | static const u32 gpmc_sdp_nor[] = { |
| 47 | SDP3430_NOR_GPMC_CONF1, |
| 48 | SDP3430_NOR_GPMC_CONF2, |
| 49 | SDP3430_NOR_GPMC_CONF3, |
| 50 | SDP3430_NOR_GPMC_CONF4, |
| 51 | SDP3430_NOR_GPMC_CONF5, |
| 52 | SDP3430_NOR_GPMC_CONF6, |
| 53 | /*CONF7- computed as params */ |
| 54 | }; |
| 55 | |
| 56 | /* |
| 57 | * Timing definitions for GPMC controller for Debug Board |
| 58 | * Debug board contains access to ethernet and DIP Switch setting |
| 59 | * information etc. |
| 60 | */ |
| 61 | static const u32 gpmc_sdp_debug[] = { |
| 62 | SDP3430_DEBUG_GPMC_CONF1, |
| 63 | SDP3430_DEBUG_GPMC_CONF2, |
| 64 | SDP3430_DEBUG_GPMC_CONF3, |
| 65 | SDP3430_DEBUG_GPMC_CONF4, |
| 66 | SDP3430_DEBUG_GPMC_CONF5, |
| 67 | SDP3430_DEBUG_GPMC_CONF6, |
| 68 | /*CONF7- computed as params */ |
| 69 | }; |
| 70 | |
| 71 | /* Timing defintions for GPMC OneNAND */ |
| 72 | static const u32 gpmc_sdp_onenand[] = { |
| 73 | SDP3430_ONENAND_GPMC_CONF1, |
| 74 | SDP3430_ONENAND_GPMC_CONF2, |
| 75 | SDP3430_ONENAND_GPMC_CONF3, |
| 76 | SDP3430_ONENAND_GPMC_CONF4, |
| 77 | SDP3430_ONENAND_GPMC_CONF5, |
| 78 | SDP3430_ONENAND_GPMC_CONF6, |
| 79 | /*CONF7- computed as params */ |
| 80 | }; |
| 81 | |
| 82 | /* GPMC definitions for GPMC NAND */ |
| 83 | static const u32 gpmc_sdp_nand[] = { |
| 84 | SDP3430_NAND_GPMC_CONF1, |
| 85 | SDP3430_NAND_GPMC_CONF2, |
| 86 | SDP3430_NAND_GPMC_CONF3, |
| 87 | SDP3430_NAND_GPMC_CONF4, |
| 88 | SDP3430_NAND_GPMC_CONF5, |
| 89 | SDP3430_NAND_GPMC_CONF6, |
| 90 | /*CONF7- computed as params */ |
| 91 | }; |
| 92 | |
| 93 | /* gpmc_cfg is initialized by gpmc_init and we use it here */ |
| 94 | extern struct gpmc *gpmc_cfg; |
| 95 | |
| 96 | /** |
| 97 | * @brief board_init - gpmc and basic setup as phase1 of boot sequence |
| 98 | * |
| 99 | * @return 0 |
| 100 | */ |
| 101 | int board_init(void) |
| 102 | { |
| 103 | DECLARE_GLOBAL_DATA_PTR; |
| 104 | |
| 105 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 106 | /* TODO: Dynamically pop out CS mapping and program accordingly */ |
| 107 | /* Configure devices for default ON ON ON settings */ |
| 108 | enable_gpmc_cs_config(gpmc_sdp_nor, &gpmc_cfg->cs[0], |
| 109 | CONFIG_SYS_FLASH_BASE, GPMC_SIZE_128M); |
| 110 | enable_gpmc_cs_config(gpmc_sdp_nand, &gpmc_cfg->cs[1], 0x28000000, |
| 111 | GPMC_SIZE_16M); |
| 112 | enable_gpmc_cs_config(gpmc_sdp_onenand, &gpmc_cfg->cs[2], 0x20000000, |
| 113 | GPMC_SIZE_16M); |
| 114 | enable_gpmc_cs_config(gpmc_sdp_debug, &gpmc_cfg->cs[3], DEBUG_BASE, |
| 115 | GPMC_SIZE_16M); |
| 116 | /* board id for Linux */ |
| 117 | gd->bd->bi_arch_number = MACH_TYPE_OMAP_3430SDP; |
| 118 | /* boot param addr */ |
| 119 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | #define LAN_RESET_REGISTER (CONFIG_LAN91C96_BASE + 0x01c) |
| 125 | #define ETH_CONTROL_REG (CONFIG_LAN91C96_BASE + 0x30b) |
| 126 | |
| 127 | /** |
| 128 | * @brief ether_init Take the Ethernet controller out of reset and wait |
| 129 | * for the EEPROM load to complete. |
| 130 | */ |
| 131 | static void ether_init(void) |
| 132 | { |
| 133 | #ifdef CONFIG_DRIVER_LAN91C96 |
| 134 | int cnt = 20; |
| 135 | |
| 136 | writew(0x0, LAN_RESET_REGISTER); |
| 137 | do { |
| 138 | writew(0x1, LAN_RESET_REGISTER); |
| 139 | udelay(100); |
| 140 | if (cnt == 0) |
| 141 | goto reset_err_out; |
| 142 | --cnt; |
| 143 | } while (readw(LAN_RESET_REGISTER) != 0x1); |
| 144 | |
| 145 | cnt = 20; |
| 146 | |
| 147 | do { |
| 148 | writew(0x0, LAN_RESET_REGISTER); |
| 149 | udelay(100); |
| 150 | if (cnt == 0) |
| 151 | goto reset_err_out; |
| 152 | --cnt; |
| 153 | } while (readw(LAN_RESET_REGISTER) != 0x0000); |
| 154 | udelay(1000); |
| 155 | |
| 156 | writeb(readb(ETH_CONTROL_REG) & ~0x1, ETH_CONTROL_REG); |
| 157 | udelay(1000); |
| 158 | reset_err_out: |
| 159 | return; |
| 160 | |
| 161 | #endif |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * @brief misc_init_r - Configure SDP board specific configurations |
| 166 | * such as power configurations, ethernet initialization as phase2 of |
| 167 | * boot sequence |
| 168 | * |
| 169 | * @return 0 |
| 170 | */ |
| 171 | int misc_init_r(void) |
| 172 | { |
| 173 | /* Partial setup: |
| 174 | * VAUX3 - 2.8V for DVI |
| 175 | * VPLL1 - 1.8V |
| 176 | * VDAC - 1.8V |
| 177 | * and turns on LEDA/LEDB (not needed ... NOP?) |
| 178 | */ |
| 179 | twl4030_power_init(); |
| 180 | |
| 181 | /* FIXME finish setup: |
| 182 | * VAUX1 - 2.8V for mainboard I/O |
| 183 | * VAUX2 - 2.8V for camera |
| 184 | * VAUX4 - 1.8V for OMAP3 CSI |
| 185 | * VMMC1 - 3.15V (init, variable) for MMC1 |
| 186 | * VMMC2 - 1.85V for MMC2 |
| 187 | * VSIM - off (init, variable) for MMC1.DAT[3..7], SIM |
| 188 | * VPLL2 - 1.8V |
| 189 | */ |
| 190 | ether_init(); |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * @brief set_muxconf_regs Setting up the configuration Mux registers |
| 197 | * specific to the hardware. Many pins need to be moved from protect |
| 198 | * to primary mode. |
| 199 | */ |
| 200 | void set_muxconf_regs(void) |
| 201 | { |
| 202 | /* platform specific muxes */ |
| 203 | MUX_SDP3430(); |
| 204 | } |