wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 4 | * Marius Groeger <mgroeger@sysgo.de> |
| 5 | * |
| 6 | * (C) Copyright 2002 |
| 7 | * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> |
| 8 | * |
| 9 | * (C) Copyright 2003 |
| 10 | * Texas Instruments, <www.ti.com> |
| 11 | * Kshitij Gupta <Kshitij@ti.com> |
| 12 | * |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 13 | * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004 |
wdenk | e537b3b | 2004-02-23 23:54:43 +0000 | [diff] [blame] | 14 | * |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 15 | * See file CREDITS for list of people who contributed to this |
| 16 | * project. |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or |
| 19 | * modify it under the terms of the GNU General Public License as |
| 20 | * published by the Free Software Foundation; either version 2 of |
| 21 | * the License, or (at your option) any later version. |
| 22 | * |
| 23 | * This program is distributed in the hope that it will be useful, |
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | * GNU General Public License for more details. |
| 27 | * |
| 28 | * You should have received a copy of the GNU General Public License |
| 29 | * along with this program; if not, write to the Free Software |
| 30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 31 | * MA 02111-1307 USA |
| 32 | */ |
| 33 | |
| 34 | #include <common.h> |
| 35 | #if defined(CONFIG_OMAP1610) |
| 36 | #include <./configs/omap1510.h> |
| 37 | #endif |
| 38 | |
wdenk | 920e91b | 2004-06-09 15:25:53 +0000 | [diff] [blame] | 39 | #ifdef CONFIG_CS_AUTOBOOT |
| 40 | unsigned long omap_flash_base; |
| 41 | #endif |
| 42 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 43 | void flash__init (void); |
| 44 | void ether__init (void); |
| 45 | void set_muxconf_regs (void); |
| 46 | void peripheral_power_enable (void); |
| 47 | |
| 48 | #define COMP_MODE_ENABLE ((unsigned int)0x0000EAEF) |
| 49 | |
| 50 | static inline void delay (unsigned long loops) |
| 51 | { |
| 52 | __asm__ volatile ("1:\n" |
| 53 | "subs %0, %1, #1\n" |
| 54 | "bne 1b":"=r" (loops):"0" (loops)); |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | * Miscellaneous platform dependent initialisations |
| 59 | */ |
| 60 | |
| 61 | int board_init (void) |
| 62 | { |
| 63 | DECLARE_GLOBAL_DATA_PTR; |
| 64 | |
wdenk | 82db02f | 2004-07-11 22:19:26 +0000 | [diff] [blame] | 65 | if (machine_is_omap_h2()) |
| 66 | gd->bd->bi_arch_number = MACH_TYPE_OMAP_H2; |
| 67 | else if (machine_is_omap_innovator()) |
| 68 | gd->bd->bi_arch_number = MACH_TYPE_OMAP_INNOVATOR; |
| 69 | else |
| 70 | gd->bd->bi_arch_number = MACH_TYPE_OMAP_GENERIC; |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 71 | |
| 72 | /* adress of boot parameters */ |
| 73 | gd->bd->bi_boot_params = 0x10000100; |
| 74 | |
| 75 | /* Configure MUX settings */ |
| 76 | set_muxconf_regs (); |
| 77 | peripheral_power_enable (); |
| 78 | |
| 79 | /* this speeds up your boot a quite a bit. However to make it |
| 80 | * work, you need make sure your kernel startup flush bug is fixed. |
| 81 | * ... rkw ... |
| 82 | */ |
| 83 | icache_enable (); |
| 84 | |
| 85 | flash__init (); |
| 86 | ether__init (); |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | int misc_init_r (void) |
| 92 | { |
| 93 | /* currently empty */ |
| 94 | return (0); |
| 95 | } |
| 96 | |
| 97 | /****************************** |
| 98 | Routine: |
| 99 | Description: |
| 100 | ******************************/ |
| 101 | void flash__init (void) |
| 102 | { |
| 103 | #define EMIFS_GlB_Config_REG 0xfffecc0c |
| 104 | unsigned int regval; |
wdenk | 920e91b | 2004-06-09 15:25:53 +0000 | [diff] [blame] | 105 | |
| 106 | #ifdef CONFIG_CS_AUTOBOOT |
| 107 | /* Check swapping of CS0 and CS3, set flash base accordingly */ |
wdenk | 5110817 | 2004-06-09 15:37:23 +0000 | [diff] [blame] | 108 | omap_flash_base = ((*((u32 *)OMAP_EMIFS_CONFIG_REG) & 0x02) == 0) ? |
| 109 | PHYS_FLASH_1_BM0 : PHYS_FLASH_1_BM1; |
wdenk | 920e91b | 2004-06-09 15:25:53 +0000 | [diff] [blame] | 110 | #endif |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 111 | regval = *((volatile unsigned int *) EMIFS_GlB_Config_REG); |
| 112 | /* Turn off write protection for flash devices. */ |
| 113 | regval = regval | 0x0001; |
| 114 | *((volatile unsigned int *) EMIFS_GlB_Config_REG) = regval; |
| 115 | } |
| 116 | /************************************************************* |
| 117 | Routine:ether__init |
| 118 | Description: take the Ethernet controller out of reset and wait |
| 119 | for the EEPROM load to complete. |
| 120 | *************************************************************/ |
| 121 | void ether__init (void) |
| 122 | { |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 123 | #define ETH_CONTROL_REG 0x0400030b |
| 124 | |
| 125 | #ifdef CONFIG_H2_OMAP1610 |
| 126 | #define LAN_RESET_REGISTER 0x0400001c |
| 127 | |
wdenk | e537b3b | 2004-02-23 23:54:43 +0000 | [diff] [blame] | 128 | /* The debug board on which the lan chip resides may not be powered |
| 129 | * ON at the same time as the OMAP chip. So wait in a loop until the |
| 130 | * lan reset register (on the debug board) is available (powered on) |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 131 | * and reset the lan chip. |
| 132 | */ |
| 133 | |
| 134 | *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0000; |
| 135 | do { |
| 136 | *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0001; |
| 137 | udelay (3); |
| 138 | } while (*((volatile unsigned short *) LAN_RESET_REGISTER) != 0x0001); |
wdenk | e537b3b | 2004-02-23 23:54:43 +0000 | [diff] [blame] | 139 | |
wdenk | e97d3d9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 140 | do { |
| 141 | *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0000; |
| 142 | udelay (3); |
| 143 | } while (*((volatile unsigned short *) LAN_RESET_REGISTER) != 0x0000); |
| 144 | #endif |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 145 | |
| 146 | *((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01; |
| 147 | udelay (3); |
| 148 | } |
| 149 | |
| 150 | /****************************** |
| 151 | Routine: |
| 152 | Description: |
| 153 | ******************************/ |
| 154 | int dram_init (void) |
| 155 | { |
| 156 | DECLARE_GLOBAL_DATA_PTR; |
| 157 | |
| 158 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 159 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | /****************************************************** |
| 165 | Routine: set_muxconf_regs |
| 166 | Description: Setting up the configuration Mux registers |
| 167 | specific to the hardware |
| 168 | *******************************************************/ |
| 169 | void set_muxconf_regs (void) |
| 170 | { |
| 171 | volatile unsigned int *MuxConfReg; |
| 172 | /* set each registers to its reset value; */ |
| 173 | MuxConfReg = |
| 174 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0); |
| 175 | /* setup for UART1 */ |
| 176 | *MuxConfReg &= ~(0x02000000); /* bit 25 */ |
| 177 | /* setup for UART2 */ |
| 178 | *MuxConfReg &= ~(0x01000000); /* bit 24 */ |
| 179 | /* Disable Uwire CS Hi-Z */ |
| 180 | *MuxConfReg |= 0x08000000; |
| 181 | MuxConfReg = |
| 182 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_3); |
| 183 | *MuxConfReg = 0x00000000; |
| 184 | MuxConfReg = |
| 185 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_4); |
| 186 | *MuxConfReg = 0x00000000; |
| 187 | MuxConfReg = |
| 188 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_5); |
| 189 | *MuxConfReg = 0x00000000; |
| 190 | MuxConfReg = |
| 191 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_6); |
| 192 | /*setup mux for UART3 */ |
| 193 | *MuxConfReg |= 0x00000001; /* bit3, 1, 0 (mux0 5,5,26) */ |
| 194 | *MuxConfReg &= ~0x0000003e; |
| 195 | MuxConfReg = |
| 196 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_7); |
| 197 | *MuxConfReg = 0x00000000; |
| 198 | MuxConfReg = |
| 199 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_8); |
| 200 | /* Disable Uwire CS Hi-Z */ |
| 201 | *MuxConfReg |= 0x00001200; /*bit 9 for CS0 12 for CS3 */ |
| 202 | MuxConfReg = |
| 203 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_9); |
| 204 | /* Need to turn on bits 21 and 12 in FUNC_MUX_CTRL_9 so the */ |
| 205 | /* hardware will actually use TX and RTS based on bit 25 in */ |
| 206 | /* FUNC_MUX_CTRL_0. I told you this thing was screwy! */ |
| 207 | *MuxConfReg |= 0x00201000; |
| 208 | MuxConfReg = |
| 209 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_A); |
| 210 | *MuxConfReg = 0x00000000; |
| 211 | MuxConfReg = |
| 212 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_B); |
| 213 | *MuxConfReg = 0x00000000; |
| 214 | MuxConfReg = |
| 215 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_C); |
| 216 | /* setup for UART2 */ |
| 217 | /* Need to turn on bits 27 and 24 in FUNC_MUX_CTRL_C so the */ |
| 218 | /* hardware will actually use TX and RTS based on bit 24 in */ |
| 219 | /* FUNC_MUX_CTRL_0. */ |
| 220 | *MuxConfReg |= 0x09000000; |
| 221 | MuxConfReg = |
| 222 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_0); |
| 223 | *MuxConfReg = 0x00000000; |
| 224 | MuxConfReg = |
| 225 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_1); |
| 226 | *MuxConfReg = 0x00000000; |
| 227 | /* mux setup for SD/MMC driver */ |
| 228 | MuxConfReg = |
| 229 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_2); |
| 230 | *MuxConfReg &= 0xFFFE0FFF; |
| 231 | MuxConfReg = |
| 232 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_3); |
| 233 | *MuxConfReg = 0x00000000; |
| 234 | MuxConfReg = |
| 235 | (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0); |
| 236 | /* bit 13 for MMC2 XOR_CLK */ |
| 237 | *MuxConfReg &= ~(0x00002000); |
| 238 | /* bit 29 for UART 1 */ |
| 239 | *MuxConfReg &= ~(0x00002000); |
| 240 | MuxConfReg = |
| 241 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0); |
| 242 | /* Configure for USB. Turn on VBUS_CTRL and VBUS_MODE. */ |
| 243 | *MuxConfReg |= 0x000C0000; |
| 244 | MuxConfReg = |
| 245 | (volatile unsigned int *) ((unsigned int)USB_TRANSCEIVER_CTRL); |
| 246 | *MuxConfReg &= ~(0x00000070); |
| 247 | *MuxConfReg &= ~(0x00000008); |
| 248 | *MuxConfReg |= 0x00000003; |
| 249 | *MuxConfReg |= 0x00000180; |
| 250 | MuxConfReg = |
| 251 | (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0); |
| 252 | /* bit 17, software controls VBUS */ |
| 253 | *MuxConfReg &= ~(0x00020000); |
| 254 | /* Enable USB 48 and 12M clocks */ |
| 255 | *MuxConfReg |= 0x00000200; |
| 256 | *MuxConfReg &= ~(0x00000180); |
| 257 | /*2.75V for MMCSDIO1 */ |
| 258 | MuxConfReg = |
| 259 | (volatile unsigned int *) ((unsigned int) VOLTAGE_CTRL_0); |
| 260 | *MuxConfReg = 0x00001FE7; |
| 261 | MuxConfReg = |
| 262 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_0); |
| 263 | *MuxConfReg = 0x00000000; |
| 264 | MuxConfReg = |
| 265 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_1); |
| 266 | *MuxConfReg = 0x00000000; |
| 267 | MuxConfReg = |
| 268 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2); |
| 269 | *MuxConfReg = 0x00000000; |
| 270 | MuxConfReg = |
| 271 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_3); |
| 272 | *MuxConfReg = 0x00000000; |
| 273 | MuxConfReg = |
| 274 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_4); |
| 275 | *MuxConfReg = 0x00000000; |
| 276 | MuxConfReg = |
| 277 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_4); |
| 278 | *MuxConfReg = 0x00000000; |
| 279 | /* Turn on UART2 48 MHZ clock */ |
| 280 | MuxConfReg = |
| 281 | (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0); |
| 282 | *MuxConfReg |= 0x40000000; |
| 283 | MuxConfReg = |
| 284 | (volatile unsigned int *) ((unsigned int) USB_OTG_CTRL); |
| 285 | /* setup for USB VBus detection OMAP161x */ |
| 286 | *MuxConfReg |= 0x00040000; /* bit 18 */ |
| 287 | MuxConfReg = |
| 288 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2); |
| 289 | /* PullUps for SD/MMC driver */ |
| 290 | *MuxConfReg |= ~(0xFFFE0FFF); |
| 291 | MuxConfReg = |
| 292 | (volatile unsigned int *) ((unsigned int)COMP_MODE_CTRL_0); |
| 293 | *MuxConfReg = COMP_MODE_ENABLE; |
| 294 | } |
| 295 | |
| 296 | /****************************************************** |
| 297 | Routine: peripheral_power_enable |
| 298 | Description: Enable the power for UART1 |
| 299 | *******************************************************/ |
| 300 | void peripheral_power_enable (void) |
| 301 | { |
| 302 | #define UART1_48MHZ_ENABLE ((unsigned short)0x0200) |
| 303 | #define SW_CLOCK_REQUEST ((volatile unsigned short *)0xFFFE0834) |
| 304 | |
| 305 | *SW_CLOCK_REQUEST |= UART1_48MHZ_ENABLE; |
| 306 | } |