tao3530.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Maintainer :
  4. * Tapani Utriainen <linuxfae@technexion.com>
  5. */
  6. #include <common.h>
  7. #include <bootstage.h>
  8. #include <malloc.h>
  9. #include <netdev.h>
  10. #include <twl4030.h>
  11. #include <asm/io.h>
  12. #include <asm/arch/mmc_host_def.h>
  13. #include <asm/arch/mem.h>
  14. #include <asm/arch/mux.h>
  15. #include <asm/arch/sys_proto.h>
  16. #include <asm/arch/gpio.h>
  17. #include <asm/gpio.h>
  18. #include <asm/mach-types.h>
  19. #include <usb.h>
  20. #include <asm/ehci-omap.h>
  21. #include "tao3530.h"
  22. DECLARE_GLOBAL_DATA_PTR;
  23. int tao3530_revision(void)
  24. {
  25. int ret = 0;
  26. /* char *label argument is unused in gpio_request() */
  27. ret = gpio_request(65, "");
  28. if (ret) {
  29. puts("Error: GPIO 65 not available\n");
  30. goto out;
  31. }
  32. MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M4));
  33. ret = gpio_request(1, "");
  34. if (ret) {
  35. puts("Error: GPIO 1 not available\n");
  36. goto out2;
  37. }
  38. MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M4));
  39. ret = gpio_direction_input(65);
  40. if (ret) {
  41. puts("Error: GPIO 65 not available for input\n");
  42. goto out3;
  43. }
  44. ret = gpio_direction_input(1);
  45. if (ret) {
  46. puts("Error: GPIO 1 not available for input\n");
  47. goto out3;
  48. }
  49. ret = gpio_get_value(65) << 1 | gpio_get_value(1);
  50. out3:
  51. MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M0));
  52. gpio_free(1);
  53. out2:
  54. MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M0));
  55. gpio_free(65);
  56. out:
  57. return ret;
  58. }
  59. #ifdef CONFIG_SPL_BUILD
  60. /*
  61. * Routine: get_board_mem_timings
  62. * Description: If we use SPL then there is no x-loader nor config header
  63. * so we have to setup the DDR timings ourself on both banks.
  64. */
  65. void get_board_mem_timings(struct board_sdrc_timings *timings)
  66. {
  67. #if defined(CONFIG_SYS_BOARD_OMAP3_HA)
  68. /*
  69. * Switch baseboard LED to red upon power-on
  70. */
  71. MUX_OMAP3_HA();
  72. /* Request a gpio before using it */
  73. gpio_request(111, "");
  74. /* Sets the gpio as output and its value to 1, switch LED to red */
  75. gpio_direction_output(111, 1);
  76. #endif
  77. if (tao3530_revision() < 3) {
  78. /* 256MB / Bank */
  79. timings->mcfg = MCFG(256 << 20, 14); /* RAS-width 14 */
  80. timings->ctrla = HYNIX_V_ACTIMA_165;
  81. timings->ctrlb = HYNIX_V_ACTIMB_165;
  82. } else {
  83. /* 128MB / Bank */
  84. timings->mcfg = MCFG(128 << 20, 13); /* RAS-width 13 */
  85. timings->ctrla = MICRON_V_ACTIMA_165;
  86. timings->ctrlb = MICRON_V_ACTIMB_165;
  87. }
  88. timings->mr = MICRON_V_MR_165;
  89. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  90. }
  91. #endif
  92. /*
  93. * Routine: board_init
  94. * Description: Early hardware init.
  95. */
  96. int board_init(void)
  97. {
  98. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  99. /* board id for Linux */
  100. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_TAO3530;
  101. /* boot param addr */
  102. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  103. return 0;
  104. }
  105. /*
  106. * Routine: misc_init_r
  107. * Description: Configure board specific parts
  108. */
  109. int misc_init_r(void)
  110. {
  111. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  112. struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
  113. twl4030_power_init();
  114. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  115. /* Configure GPIOs to output */
  116. /* GPIO23 */
  117. writel(~(GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
  118. writel(~(GPIO31 | GPIO30 | GPIO22 | GPIO21 |
  119. GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
  120. /* Set GPIOs */
  121. writel(GPIO10 | GPIO8 | GPIO2 | GPIO1,
  122. &gpio6_base->setdataout);
  123. writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  124. GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
  125. switch (tao3530_revision()) {
  126. case 0:
  127. puts("TAO-3530 REV Reserve 1\n");
  128. break;
  129. case 1:
  130. puts("TAO-3530 REV Reserve 2\n");
  131. break;
  132. case 2:
  133. puts("TAO-3530 REV Cx\n");
  134. break;
  135. case 3:
  136. puts("TAO-3530 REV Ax/Bx\n");
  137. break;
  138. default:
  139. puts("Unknown board revision\n");
  140. }
  141. omap_die_id_display();
  142. return 0;
  143. }
  144. /*
  145. * Routine: set_muxconf_regs
  146. * Description: Setting up the configuration Mux registers specific to the
  147. * hardware. Many pins need to be moved from protect to primary
  148. * mode.
  149. */
  150. void set_muxconf_regs(void)
  151. {
  152. MUX_TAO3530();
  153. #if defined(CONFIG_SYS_BOARD_OMAP3_HA)
  154. MUX_OMAP3_HA();
  155. #endif
  156. }
  157. #if defined(CONFIG_MMC)
  158. int board_mmc_init(bd_t *bis)
  159. {
  160. omap_mmc_init(0, 0, 0, -1, -1);
  161. return 0;
  162. }
  163. #endif
  164. #if defined(CONFIG_MMC)
  165. void board_mmc_power_init(void)
  166. {
  167. twl4030_power_mmc_init(0);
  168. }
  169. #endif
  170. #if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
  171. /* Call usb_stop() before starting the kernel */
  172. void show_boot_progress(int val)
  173. {
  174. if (val == BOOTSTAGE_ID_RUN_OS)
  175. usb_stop();
  176. }
  177. static struct omap_usbhs_board_data usbhs_bdata = {
  178. .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
  179. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  180. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
  181. };
  182. int ehci_hcd_init(int index, enum usb_init_type init,
  183. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  184. {
  185. return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
  186. }
  187. int ehci_hcd_stop(int index)
  188. {
  189. return omap_ehci_hcd_stop();
  190. }
  191. #endif /* CONFIG_USB_EHCI_HCD */