wdenk | 6f21347 | 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 | 63e73c9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 13 | * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004 |
wdenk | 028ab6b | 2004-02-23 23:54:43 +0000 | [diff] [blame^] | 14 | * |
wdenk | 6f21347 | 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 | |
| 39 | void flash__init (void); |
| 40 | void ether__init (void); |
| 41 | void set_muxconf_regs (void); |
| 42 | void peripheral_power_enable (void); |
| 43 | |
| 44 | #define COMP_MODE_ENABLE ((unsigned int)0x0000EAEF) |
| 45 | |
| 46 | static inline void delay (unsigned long loops) |
| 47 | { |
| 48 | __asm__ volatile ("1:\n" |
| 49 | "subs %0, %1, #1\n" |
| 50 | "bne 1b":"=r" (loops):"0" (loops)); |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * Miscellaneous platform dependent initialisations |
| 55 | */ |
| 56 | |
| 57 | int board_init (void) |
| 58 | { |
| 59 | DECLARE_GLOBAL_DATA_PTR; |
| 60 | |
| 61 | /* arch number of OMAP 1510-Board */ |
| 62 | /* to be changed for OMAP 1610 Board */ |
| 63 | gd->bd->bi_arch_number = 234; |
| 64 | |
| 65 | /* adress of boot parameters */ |
| 66 | gd->bd->bi_boot_params = 0x10000100; |
| 67 | |
| 68 | /* Configure MUX settings */ |
| 69 | set_muxconf_regs (); |
| 70 | peripheral_power_enable (); |
| 71 | |
| 72 | /* this speeds up your boot a quite a bit. However to make it |
| 73 | * work, you need make sure your kernel startup flush bug is fixed. |
| 74 | * ... rkw ... |
| 75 | */ |
| 76 | icache_enable (); |
| 77 | |
| 78 | flash__init (); |
| 79 | ether__init (); |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | int misc_init_r (void) |
| 85 | { |
| 86 | /* currently empty */ |
| 87 | return (0); |
| 88 | } |
| 89 | |
| 90 | /****************************** |
| 91 | Routine: |
| 92 | Description: |
| 93 | ******************************/ |
| 94 | void flash__init (void) |
| 95 | { |
| 96 | #define EMIFS_GlB_Config_REG 0xfffecc0c |
| 97 | unsigned int regval; |
| 98 | regval = *((volatile unsigned int *) EMIFS_GlB_Config_REG); |
| 99 | /* Turn off write protection for flash devices. */ |
| 100 | regval = regval | 0x0001; |
| 101 | *((volatile unsigned int *) EMIFS_GlB_Config_REG) = regval; |
| 102 | } |
| 103 | /************************************************************* |
| 104 | Routine:ether__init |
| 105 | Description: take the Ethernet controller out of reset and wait |
| 106 | for the EEPROM load to complete. |
| 107 | *************************************************************/ |
| 108 | void ether__init (void) |
| 109 | { |
wdenk | 63e73c9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 110 | #define ETH_CONTROL_REG 0x0400030b |
| 111 | |
| 112 | #ifdef CONFIG_H2_OMAP1610 |
| 113 | #define LAN_RESET_REGISTER 0x0400001c |
| 114 | |
wdenk | 028ab6b | 2004-02-23 23:54:43 +0000 | [diff] [blame^] | 115 | /* The debug board on which the lan chip resides may not be powered |
| 116 | * ON at the same time as the OMAP chip. So wait in a loop until the |
| 117 | * lan reset register (on the debug board) is available (powered on) |
wdenk | 63e73c9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 118 | * and reset the lan chip. |
| 119 | */ |
| 120 | |
| 121 | *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0000; |
| 122 | do { |
| 123 | *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0001; |
| 124 | udelay (3); |
| 125 | } while (*((volatile unsigned short *) LAN_RESET_REGISTER) != 0x0001); |
wdenk | 028ab6b | 2004-02-23 23:54:43 +0000 | [diff] [blame^] | 126 | |
wdenk | 63e73c9 | 2004-02-23 22:22:28 +0000 | [diff] [blame] | 127 | do { |
| 128 | *((volatile unsigned short *) LAN_RESET_REGISTER) = 0x0000; |
| 129 | udelay (3); |
| 130 | } while (*((volatile unsigned short *) LAN_RESET_REGISTER) != 0x0000); |
| 131 | #endif |
wdenk | 6f21347 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 132 | |
| 133 | *((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01; |
| 134 | udelay (3); |
| 135 | } |
| 136 | |
| 137 | /****************************** |
| 138 | Routine: |
| 139 | Description: |
| 140 | ******************************/ |
| 141 | int dram_init (void) |
| 142 | { |
| 143 | DECLARE_GLOBAL_DATA_PTR; |
| 144 | |
| 145 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 146 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | /****************************************************** |
| 152 | Routine: set_muxconf_regs |
| 153 | Description: Setting up the configuration Mux registers |
| 154 | specific to the hardware |
| 155 | *******************************************************/ |
| 156 | void set_muxconf_regs (void) |
| 157 | { |
| 158 | volatile unsigned int *MuxConfReg; |
| 159 | /* set each registers to its reset value; */ |
| 160 | MuxConfReg = |
| 161 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0); |
| 162 | /* setup for UART1 */ |
| 163 | *MuxConfReg &= ~(0x02000000); /* bit 25 */ |
| 164 | /* setup for UART2 */ |
| 165 | *MuxConfReg &= ~(0x01000000); /* bit 24 */ |
| 166 | /* Disable Uwire CS Hi-Z */ |
| 167 | *MuxConfReg |= 0x08000000; |
| 168 | MuxConfReg = |
| 169 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_3); |
| 170 | *MuxConfReg = 0x00000000; |
| 171 | MuxConfReg = |
| 172 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_4); |
| 173 | *MuxConfReg = 0x00000000; |
| 174 | MuxConfReg = |
| 175 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_5); |
| 176 | *MuxConfReg = 0x00000000; |
| 177 | MuxConfReg = |
| 178 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_6); |
| 179 | /*setup mux for UART3 */ |
| 180 | *MuxConfReg |= 0x00000001; /* bit3, 1, 0 (mux0 5,5,26) */ |
| 181 | *MuxConfReg &= ~0x0000003e; |
| 182 | MuxConfReg = |
| 183 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_7); |
| 184 | *MuxConfReg = 0x00000000; |
| 185 | MuxConfReg = |
| 186 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_8); |
| 187 | /* Disable Uwire CS Hi-Z */ |
| 188 | *MuxConfReg |= 0x00001200; /*bit 9 for CS0 12 for CS3 */ |
| 189 | MuxConfReg = |
| 190 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_9); |
| 191 | /* Need to turn on bits 21 and 12 in FUNC_MUX_CTRL_9 so the */ |
| 192 | /* hardware will actually use TX and RTS based on bit 25 in */ |
| 193 | /* FUNC_MUX_CTRL_0. I told you this thing was screwy! */ |
| 194 | *MuxConfReg |= 0x00201000; |
| 195 | MuxConfReg = |
| 196 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_A); |
| 197 | *MuxConfReg = 0x00000000; |
| 198 | MuxConfReg = |
| 199 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_B); |
| 200 | *MuxConfReg = 0x00000000; |
| 201 | MuxConfReg = |
| 202 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_C); |
| 203 | /* setup for UART2 */ |
| 204 | /* Need to turn on bits 27 and 24 in FUNC_MUX_CTRL_C so the */ |
| 205 | /* hardware will actually use TX and RTS based on bit 24 in */ |
| 206 | /* FUNC_MUX_CTRL_0. */ |
| 207 | *MuxConfReg |= 0x09000000; |
| 208 | MuxConfReg = |
| 209 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_0); |
| 210 | *MuxConfReg = 0x00000000; |
| 211 | MuxConfReg = |
| 212 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_1); |
| 213 | *MuxConfReg = 0x00000000; |
| 214 | /* mux setup for SD/MMC driver */ |
| 215 | MuxConfReg = |
| 216 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_2); |
| 217 | *MuxConfReg &= 0xFFFE0FFF; |
| 218 | MuxConfReg = |
| 219 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_3); |
| 220 | *MuxConfReg = 0x00000000; |
| 221 | MuxConfReg = |
| 222 | (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0); |
| 223 | /* bit 13 for MMC2 XOR_CLK */ |
| 224 | *MuxConfReg &= ~(0x00002000); |
| 225 | /* bit 29 for UART 1 */ |
| 226 | *MuxConfReg &= ~(0x00002000); |
| 227 | MuxConfReg = |
| 228 | (volatile unsigned int *) ((unsigned int) FUNC_MUX_CTRL_0); |
| 229 | /* Configure for USB. Turn on VBUS_CTRL and VBUS_MODE. */ |
| 230 | *MuxConfReg |= 0x000C0000; |
| 231 | MuxConfReg = |
| 232 | (volatile unsigned int *) ((unsigned int)USB_TRANSCEIVER_CTRL); |
| 233 | *MuxConfReg &= ~(0x00000070); |
| 234 | *MuxConfReg &= ~(0x00000008); |
| 235 | *MuxConfReg |= 0x00000003; |
| 236 | *MuxConfReg |= 0x00000180; |
| 237 | MuxConfReg = |
| 238 | (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0); |
| 239 | /* bit 17, software controls VBUS */ |
| 240 | *MuxConfReg &= ~(0x00020000); |
| 241 | /* Enable USB 48 and 12M clocks */ |
| 242 | *MuxConfReg |= 0x00000200; |
| 243 | *MuxConfReg &= ~(0x00000180); |
| 244 | /*2.75V for MMCSDIO1 */ |
| 245 | MuxConfReg = |
| 246 | (volatile unsigned int *) ((unsigned int) VOLTAGE_CTRL_0); |
| 247 | *MuxConfReg = 0x00001FE7; |
| 248 | MuxConfReg = |
| 249 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_0); |
| 250 | *MuxConfReg = 0x00000000; |
| 251 | MuxConfReg = |
| 252 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_1); |
| 253 | *MuxConfReg = 0x00000000; |
| 254 | MuxConfReg = |
| 255 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2); |
| 256 | *MuxConfReg = 0x00000000; |
| 257 | MuxConfReg = |
| 258 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_3); |
| 259 | *MuxConfReg = 0x00000000; |
| 260 | MuxConfReg = |
| 261 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_4); |
| 262 | *MuxConfReg = 0x00000000; |
| 263 | MuxConfReg = |
| 264 | (volatile unsigned int *) ((unsigned int) PULL_DWN_CTRL_4); |
| 265 | *MuxConfReg = 0x00000000; |
| 266 | /* Turn on UART2 48 MHZ clock */ |
| 267 | MuxConfReg = |
| 268 | (volatile unsigned int *) ((unsigned int) MOD_CONF_CTRL_0); |
| 269 | *MuxConfReg |= 0x40000000; |
| 270 | MuxConfReg = |
| 271 | (volatile unsigned int *) ((unsigned int) USB_OTG_CTRL); |
| 272 | /* setup for USB VBus detection OMAP161x */ |
| 273 | *MuxConfReg |= 0x00040000; /* bit 18 */ |
| 274 | MuxConfReg = |
| 275 | (volatile unsigned int *) ((unsigned int) PU_PD_SEL_2); |
| 276 | /* PullUps for SD/MMC driver */ |
| 277 | *MuxConfReg |= ~(0xFFFE0FFF); |
| 278 | MuxConfReg = |
| 279 | (volatile unsigned int *) ((unsigned int)COMP_MODE_CTRL_0); |
| 280 | *MuxConfReg = COMP_MODE_ENABLE; |
| 281 | } |
| 282 | |
| 283 | /****************************************************** |
| 284 | Routine: peripheral_power_enable |
| 285 | Description: Enable the power for UART1 |
| 286 | *******************************************************/ |
| 287 | void peripheral_power_enable (void) |
| 288 | { |
| 289 | #define UART1_48MHZ_ENABLE ((unsigned short)0x0200) |
| 290 | #define SW_CLOCK_REQUEST ((volatile unsigned short *)0xFFFE0834) |
| 291 | |
| 292 | *SW_CLOCK_REQUEST |= UART1_48MHZ_ENABLE; |
| 293 | } |