omap3logic.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. * SPDX-License-Identifier: GPL-2.0+
  13. */
  14. #include <common.h>
  15. #include <dm.h>
  16. #include <ns16550.h>
  17. #include <netdev.h>
  18. #include <flash.h>
  19. #include <nand.h>
  20. #include <i2c.h>
  21. #include <twl4030.h>
  22. #include <asm/io.h>
  23. #include <asm/arch/mmc_host_def.h>
  24. #include <asm/arch/mux.h>
  25. #include <asm/arch/mem.h>
  26. #include <asm/arch/sys_proto.h>
  27. #include <asm/gpio.h>
  28. #include <asm/mach-types.h>
  29. #include "omap3logic.h"
  30. DECLARE_GLOBAL_DATA_PTR;
  31. /*
  32. * two dimensional array of strucures containining board name and Linux
  33. * machine IDs; row it selected based on CPU column is slected based
  34. * on hsusb0_data5 pin having a pulldown resistor
  35. */
  36. static const struct ns16550_platdata omap3logic_serial = {
  37. OMAP34XX_UART1,
  38. 2,
  39. V_NS16550_CLK
  40. };
  41. U_BOOT_DEVICE(omap3logic_uart) = {
  42. "ns16550_serial",
  43. &omap3logic_serial
  44. };
  45. static struct board_id {
  46. char *name;
  47. int machine_id;
  48. } boards[2][2] = {
  49. {
  50. {
  51. .name = "OMAP35xx SOM LV",
  52. .machine_id = MACH_TYPE_OMAP3530_LV_SOM,
  53. },
  54. {
  55. .name = "OMAP35xx Torpedo",
  56. .machine_id = MACH_TYPE_OMAP3_TORPEDO,
  57. },
  58. },
  59. {
  60. {
  61. .name = "DM37xx SOM LV",
  62. .machine_id = MACH_TYPE_DM3730_SOM_LV,
  63. },
  64. {
  65. .name = "DM37xx Torpedo",
  66. .machine_id = MACH_TYPE_DM3730_TORPEDO,
  67. },
  68. },
  69. };
  70. /*
  71. * BOARD_ID_GPIO - GPIO of pin with optional pulldown resistor on SOM LV
  72. */
  73. #define BOARD_ID_GPIO 189 /* hsusb0_data5 pin */
  74. /*
  75. * Routine: board_init
  76. * Description: Early hardware init.
  77. */
  78. int board_init(void)
  79. {
  80. struct board_id *board;
  81. unsigned int val;
  82. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  83. /* boot param addr */
  84. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  85. /*
  86. * To identify between a SOM LV and Torpedo module,
  87. * a pulldown resistor is on hsusb0_data5 for the SOM LV module.
  88. * Drive the pin (and let it soak), then read it back.
  89. * If the pin is still high its a Torpedo. If low its a SOM LV
  90. */
  91. /* Mux hsusb0_data5 as a GPIO */
  92. MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M4));
  93. if (gpio_request(BOARD_ID_GPIO, "husb0_data5.gpio_189") == 0) {
  94. /*
  95. * Drive BOARD_ID_GPIO - the pulldown resistor on the SOM LV
  96. * will drain the voltage.
  97. */
  98. gpio_direction_output(BOARD_ID_GPIO, 0);
  99. gpio_set_value(BOARD_ID_GPIO, 1);
  100. /* Let it soak for a bit */
  101. sdelay(0x100);
  102. /*
  103. * Read state of BOARD_ID_GPIO as an input and if its set.
  104. * If so the board is a Torpedo
  105. */
  106. gpio_direction_input(BOARD_ID_GPIO);
  107. val = gpio_get_value(BOARD_ID_GPIO);
  108. gpio_free(BOARD_ID_GPIO);
  109. board = &boards[!!(get_cpu_family() == CPU_OMAP36XX)][!!val];
  110. printf("Board: %s\n", board->name);
  111. /* Set the machine_id passed to Linux */
  112. gd->bd->bi_arch_number = board->machine_id;
  113. }
  114. /* restore hsusb0_data5 pin as hsusb0_data5 */
  115. MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0));
  116. return 0;
  117. }
  118. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  119. int board_mmc_init(bd_t *bis)
  120. {
  121. return omap_mmc_init(0, 0, 0, -1, -1);
  122. }
  123. #endif
  124. #if defined(CONFIG_GENERIC_MMC)
  125. void board_mmc_power_init(void)
  126. {
  127. twl4030_power_mmc_init(0);
  128. }
  129. #endif
  130. #ifdef CONFIG_SMC911X
  131. /* GPMC CS1 settings for Logic SOM LV/Torpedo LAN92xx Ethernet chip */
  132. static const u32 gpmc_lan92xx_config[] = {
  133. NET_LAN92XX_GPMC_CONFIG1,
  134. NET_LAN92XX_GPMC_CONFIG2,
  135. NET_LAN92XX_GPMC_CONFIG3,
  136. NET_LAN92XX_GPMC_CONFIG4,
  137. NET_LAN92XX_GPMC_CONFIG5,
  138. NET_LAN92XX_GPMC_CONFIG6,
  139. };
  140. int board_eth_init(bd_t *bis)
  141. {
  142. enable_gpmc_cs_config(gpmc_lan92xx_config, &gpmc_cfg->cs[1],
  143. CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
  144. return smc911x_initialize(0, CONFIG_SMC911X_BASE);
  145. }
  146. #endif
  147. /*
  148. * IEN - Input Enable
  149. * IDIS - Input Disable
  150. * PTD - Pull type Down
  151. * PTU - Pull type Up
  152. * DIS - Pull type selection is inactive
  153. * EN - Pull type selection is active
  154. * M0 - Mode 0
  155. * The commented string gives the final mux configuration for that pin
  156. */
  157. /*
  158. * Routine: set_muxconf_regs
  159. * Description: Setting up the configuration Mux registers specific to the
  160. * hardware. Many pins need to be moved from protect to primary
  161. * mode.
  162. */
  163. void set_muxconf_regs(void)
  164. {
  165. /*GPMC*/
  166. MUX_VAL(CP(GPMC_A1), (IDIS | PTU | EN | M0));
  167. MUX_VAL(CP(GPMC_A2), (IDIS | PTU | EN | M0));
  168. MUX_VAL(CP(GPMC_A3), (IDIS | PTU | EN | M0));
  169. MUX_VAL(CP(GPMC_A4), (IDIS | PTU | EN | M0));
  170. MUX_VAL(CP(GPMC_A5), (IDIS | PTU | EN | M0));
  171. MUX_VAL(CP(GPMC_A6), (IDIS | PTU | EN | M0));
  172. MUX_VAL(CP(GPMC_A7), (IDIS | PTU | EN | M0));
  173. MUX_VAL(CP(GPMC_A8), (IDIS | PTU | EN | M0));
  174. MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M0));
  175. MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M0));
  176. MUX_VAL(CP(GPMC_D0), (IEN | PTU | EN | M0));
  177. MUX_VAL(CP(GPMC_D1), (IEN | PTU | EN | M0));
  178. MUX_VAL(CP(GPMC_D2), (IEN | PTU | EN | M0));
  179. MUX_VAL(CP(GPMC_D3), (IEN | PTU | EN | M0));
  180. MUX_VAL(CP(GPMC_D4), (IEN | PTU | EN | M0));
  181. MUX_VAL(CP(GPMC_D5), (IEN | PTU | EN | M0));
  182. MUX_VAL(CP(GPMC_D6), (IEN | PTU | EN | M0));
  183. MUX_VAL(CP(GPMC_D7), (IEN | PTU | EN | M0));
  184. MUX_VAL(CP(GPMC_D8), (IEN | PTU | EN | M0));
  185. MUX_VAL(CP(GPMC_D9), (IEN | PTU | EN | M0));
  186. MUX_VAL(CP(GPMC_D10), (IEN | PTU | EN | M0));
  187. MUX_VAL(CP(GPMC_D11), (IEN | PTU | EN | M0));
  188. MUX_VAL(CP(GPMC_D12), (IEN | PTU | EN | M0));
  189. MUX_VAL(CP(GPMC_D13), (IEN | PTU | EN | M0));
  190. MUX_VAL(CP(GPMC_D14), (IEN | PTU | EN | M0));
  191. MUX_VAL(CP(GPMC_D15), (IEN | PTU | EN | M0));
  192. MUX_VAL(CP(GPMC_NCS0), (IDIS | PTU | EN | M0));
  193. MUX_VAL(CP(GPMC_NCS1), (IDIS | PTU | EN | M0));
  194. MUX_VAL(CP(GPMC_NCS2), (IDIS | PTU | EN | M0));
  195. MUX_VAL(CP(GPMC_NCS3), (IDIS | PTD | DIS | M0));
  196. MUX_VAL(CP(GPMC_NCS5), (IDIS | PTU | DIS | M4));
  197. MUX_VAL(CP(GPMC_NCS7), (IDIS | PTD | DIS | M1)); /*GPMC_IO_DIR*/
  198. MUX_VAL(CP(GPMC_NBE0_CLE), (IDIS | PTU | EN | M0));
  199. MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0));
  200. /*Expansion card */
  201. MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0));
  202. MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0));
  203. MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0));
  204. MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0));
  205. MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0));
  206. MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0));
  207. /* Serial Console */
  208. MUX_VAL(CP(UART1_TX), (IDIS | PTD | DIS | M0));
  209. MUX_VAL(CP(UART1_RTS), (IDIS | PTD | DIS | M0));
  210. MUX_VAL(CP(UART1_CTS), (IEN | PTU | DIS | M0));
  211. MUX_VAL(CP(UART1_RX), (IEN | PTD | DIS | M0));
  212. /* I2C */
  213. MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0));
  214. MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0));
  215. MUX_VAL(CP(I2C3_SCL), (IEN | PTU | EN | M0));
  216. MUX_VAL(CP(I2C3_SDA), (IEN | PTU | EN | M0));
  217. MUX_VAL(CP(HDQ_SIO), (IEN | PTU | EN | M0));
  218. /*Control and debug */
  219. MUX_VAL(CP(SYS_NIRQ), (IEN | PTU | EN | M0));
  220. MUX_VAL(CP(SYS_OFF_MODE), (IEN | PTD | DIS | M0));
  221. MUX_VAL(CP(SYS_CLKOUT1), (IEN | PTD | DIS | M0));
  222. MUX_VAL(CP(SYS_CLKOUT2), (IEN | PTU | EN | M0));
  223. MUX_VAL(CP(JTAG_NTRST), (IEN | PTD | DIS | M0));
  224. MUX_VAL(CP(SDRC_CKE0), (IDIS | PTU | EN | M0));
  225. }