omap1610innovator.c 9.0 KB

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