omap1610innovator.c 9.1 KB

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