omap3logic.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * (C) Copyright 2011
  3. * Logic Product Development <www.logicpd.com>
  4. *
  5. * Author :
  6. * Peter Barada <peter.barada@logicpd.com>
  7. *
  8. * Derived from Beagle Board and 3430 SDP code by
  9. * Richard Woodruff <r-woodruff2@ti.com>
  10. * Syed Mohammed Khasim <khasim@ti.com>
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. */
  30. #include <common.h>
  31. #include <netdev.h>
  32. #include <flash.h>
  33. #include <nand.h>
  34. #include <i2c.h>
  35. #include <twl4030.h>
  36. #include <asm/io.h>
  37. #include <asm/arch/mmc_host_def.h>
  38. #include <asm/arch/mux.h>
  39. #include <asm/arch/mem.h>
  40. #include <asm/arch/sys_proto.h>
  41. #include <asm/gpio.h>
  42. #include <asm/mach-types.h>
  43. #include "omap3logic.h"
  44. DECLARE_GLOBAL_DATA_PTR;
  45. /*
  46. * two dimensional array of strucures containining board name and Linux
  47. * machine IDs; row it selected based on CPU column is slected based
  48. * on hsusb0_data5 pin having a pulldown resistor
  49. */
  50. static struct board_id {
  51. char *name;
  52. int machine_id;
  53. } boards[2][2] = {
  54. {
  55. {
  56. .name = "OMAP35xx SOM LV",
  57. .machine_id = MACH_TYPE_OMAP3530_LV_SOM,
  58. },
  59. {
  60. .name = "OMAP35xx Torpedo",
  61. .machine_id = MACH_TYPE_OMAP3_TORPEDO,
  62. },
  63. },
  64. {
  65. {
  66. .name = "DM37xx SOM LV",
  67. .machine_id = MACH_TYPE_DM3730_SOM_LV,
  68. },
  69. {
  70. .name = "DM37xx Torpedo",
  71. .machine_id = MACH_TYPE_DM3730_TORPEDO,
  72. },
  73. },
  74. };
  75. /*
  76. * BOARD_ID_GPIO - GPIO of pin with optional pulldown resistor on SOM LV
  77. */
  78. #define BOARD_ID_GPIO 189 /* hsusb0_data5 pin */
  79. /*
  80. * Routine: board_init
  81. * Description: Early hardware init.
  82. */
  83. int board_init(void)
  84. {
  85. struct board_id *board;
  86. unsigned int val;
  87. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  88. /* boot param addr */
  89. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  90. /*
  91. * To identify between a SOM LV and Torpedo module,
  92. * a pulldown resistor is on hsusb0_data5 for the SOM LV module.
  93. * Drive the pin (and let it soak), then read it back.
  94. * If the pin is still high its a Torpedo. If low its a SOM LV
  95. */
  96. /* Mux hsusb0_data5 as a GPIO */
  97. MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M4));
  98. if (gpio_request(BOARD_ID_GPIO, "husb0_data5.gpio_189") == 0) {
  99. /*
  100. * Drive BOARD_ID_GPIO - the pulldown resistor on the SOM LV
  101. * will drain the voltage.
  102. */
  103. gpio_direction_output(BOARD_ID_GPIO, 0);
  104. gpio_set_value(BOARD_ID_GPIO, 1);
  105. /* Let it soak for a bit */
  106. sdelay(0x100);
  107. /*
  108. * Read state of BOARD_ID_GPIO as an input and if its set.
  109. * If so the board is a Torpedo
  110. */
  111. gpio_direction_input(BOARD_ID_GPIO);
  112. val = gpio_get_value(BOARD_ID_GPIO);
  113. gpio_free(BOARD_ID_GPIO);
  114. board = &boards[!!(get_cpu_family() == CPU_OMAP36XX)][!!val];
  115. printf("Board: %s\n", board->name);
  116. /* Set the machine_id passed to Linux */
  117. gd->bd->bi_arch_number = board->machine_id;
  118. }
  119. /* restore hsusb0_data5 pin as hsusb0_data5 */
  120. MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0));
  121. return 0;
  122. }
  123. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  124. int board_mmc_init(bd_t *bis)
  125. {
  126. return omap_mmc_init(0, 0, 0, -1, -1);
  127. }
  128. #endif
  129. #ifdef CONFIG_SMC911X
  130. /* GPMC CS1 settings for Logic SOM LV/Torpedo LAN92xx Ethernet chip */
  131. static const u32 gpmc_lan92xx_config[] = {
  132. NET_LAN92XX_GPMC_CONFIG1,
  133. NET_LAN92XX_GPMC_CONFIG2,
  134. NET_LAN92XX_GPMC_CONFIG3,
  135. NET_LAN92XX_GPMC_CONFIG4,
  136. NET_LAN92XX_GPMC_CONFIG5,
  137. NET_LAN92XX_GPMC_CONFIG6,
  138. };
  139. int board_eth_init(bd_t *bis)
  140. {
  141. enable_gpmc_cs_config(gpmc_lan92xx_config, &gpmc_cfg->cs[1],
  142. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  143. return smc911x_initialize(0, CONFIG_SMC911X_BASE);
  144. }
  145. #endif
  146. /*
  147. * IEN - Input Enable
  148. * IDIS - Input Disable
  149. * PTD - Pull type Down
  150. * PTU - Pull type Up
  151. * DIS - Pull type selection is inactive
  152. * EN - Pull type selection is active
  153. * M0 - Mode 0
  154. * The commented string gives the final mux configuration for that pin
  155. */
  156. /*
  157. * Routine: set_muxconf_regs
  158. * Description: Setting up the configuration Mux registers specific to the
  159. * hardware. Many pins need to be moved from protect to primary
  160. * mode.
  161. */
  162. void set_muxconf_regs(void)
  163. {
  164. /*GPMC*/
  165. MUX_VAL(CP(GPMC_A1), (IDIS | PTU | EN | M0));
  166. MUX_VAL(CP(GPMC_A2), (IDIS | PTU | EN | M0));
  167. MUX_VAL(CP(GPMC_A3), (IDIS | PTU | EN | M0));
  168. MUX_VAL(CP(GPMC_A4), (IDIS | PTU | EN | M0));
  169. MUX_VAL(CP(GPMC_A5), (IDIS | PTU | EN | M0));
  170. MUX_VAL(CP(GPMC_A6), (IDIS | PTU | EN | M0));
  171. MUX_VAL(CP(GPMC_A7), (IDIS | PTU | EN | M0));
  172. MUX_VAL(CP(GPMC_A8), (IDIS | PTU | EN | M0));
  173. MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M0));
  174. MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M0));
  175. MUX_VAL(CP(GPMC_D0), (IEN | PTU | EN | M0));
  176. MUX_VAL(CP(GPMC_D1), (IEN | PTU | EN | M0));
  177. MUX_VAL(CP(GPMC_D2), (IEN | PTU | EN | M0));
  178. MUX_VAL(CP(GPMC_D3), (IEN | PTU | EN | M0));
  179. MUX_VAL(CP(GPMC_D4), (IEN | PTU | EN | M0));
  180. MUX_VAL(CP(GPMC_D5), (IEN | PTU | EN | M0));
  181. MUX_VAL(CP(GPMC_D6), (IEN | PTU | EN | M0));
  182. MUX_VAL(CP(GPMC_D7), (IEN | PTU | EN | M0));
  183. MUX_VAL(CP(GPMC_D8), (IEN | PTU | EN | M0));
  184. MUX_VAL(CP(GPMC_D9), (IEN | PTU | EN | M0));
  185. MUX_VAL(CP(GPMC_D10), (IEN | PTU | EN | M0));
  186. MUX_VAL(CP(GPMC_D11), (IEN | PTU | EN | M0));
  187. MUX_VAL(CP(GPMC_D12), (IEN | PTU | EN | M0));
  188. MUX_VAL(CP(GPMC_D13), (IEN | PTU | EN | M0));
  189. MUX_VAL(CP(GPMC_D14), (IEN | PTU | EN | M0));
  190. MUX_VAL(CP(GPMC_D15), (IEN | PTU | EN | M0));
  191. MUX_VAL(CP(GPMC_NCS0), (IDIS | PTU | EN | M0));
  192. MUX_VAL(CP(GPMC_NCS1), (IDIS | PTU | EN | M0));
  193. MUX_VAL(CP(GPMC_NCS2), (IDIS | PTU | EN | M0));
  194. MUX_VAL(CP(GPMC_NCS3), (IDIS | PTD | DIS | M0));
  195. MUX_VAL(CP(GPMC_NCS5), (IDIS | PTU | DIS | M4));
  196. MUX_VAL(CP(GPMC_NCS7), (IDIS | PTD | DIS | M1)); /*GPMC_IO_DIR*/
  197. MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTU | EN | M0));
  198. MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0));
  199. /*Expansion card */
  200. MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0));
  201. MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0));
  202. MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0));
  203. MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0));
  204. MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0));
  205. MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0));
  206. /* Serial Console */
  207. MUX_VAL(CP(UART1_TX), (IDIS | PTD | DIS | M0));
  208. MUX_VAL(CP(UART1_RTS), (IDIS | PTD | DIS | M0));
  209. MUX_VAL(CP(UART1_CTS), (IEN | PTU | DIS | M0));
  210. MUX_VAL(CP(UART1_RX), (IEN | PTD | DIS | M0));
  211. /* I2C */
  212. MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0));
  213. MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0));
  214. MUX_VAL(CP(I2C3_SCL), (IEN | PTU | EN | M0));
  215. MUX_VAL(CP(I2C3_SDA), (IEN | PTU | EN | M0));
  216. MUX_VAL(CP(HDQ_SIO), (IEN | PTU | EN | M0));
  217. /*Control and debug */
  218. MUX_VAL(CP(SYS_NIRQ), (IEN | PTU | EN | M0));
  219. MUX_VAL(CP(SYS_OFF_MODE), (IEN | PTD | DIS | M0));
  220. MUX_VAL(CP(SYS_CLKOUT1), (IEN | PTD | DIS | M0));
  221. MUX_VAL(CP(SYS_CLKOUT2), (IEN | PTU | EN | M0));
  222. MUX_VAL(CP(JTAG_nTRST), (IEN | PTD | DIS | M0));
  223. MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0));
  224. }