tao3530.c 4.8 KB

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